mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
compute initial state of placeholder correctly
This commit is contained in:
+1
-1
@@ -95,7 +95,7 @@ public class CCRefactoringElementListenerProvider implements RefactoringElementL
|
||||
return;
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
VirtualFile patternFile = StudyUtils.getPatternFile(project, taskFile, oldName);
|
||||
VirtualFile patternFile = StudyUtils.getPatternFile(taskFile, oldName);
|
||||
if (patternFile != null) {
|
||||
try {
|
||||
patternFile.delete(CCRefactoringElementListenerProvider.class);
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ public class CCUtils {
|
||||
if (child == null) {
|
||||
continue;
|
||||
}
|
||||
Document patternDocument = StudyUtils.getPatternDocument(project, entry.getValue(), name);
|
||||
Document patternDocument = StudyUtils.getPatternDocument(entry.getValue(), name);
|
||||
Document document = FileDocumentManager.getInstance().getDocument(child);
|
||||
if (document == null || patternDocument == null) {
|
||||
return;
|
||||
|
||||
+2
-3
@@ -84,7 +84,7 @@ public class CCAddAnswerPlaceholder extends CCAnswerPlaceholderAction {
|
||||
}
|
||||
|
||||
private static void computeInitialState(Project project, PsiFile file, TaskFile taskFile, Document document) {
|
||||
Document patternDocument = StudyUtils.getPatternDocument(project, taskFile, file.getName());
|
||||
Document patternDocument = StudyUtils.getPatternDocument(taskFile, file.getName());
|
||||
if (patternDocument == null) {
|
||||
return;
|
||||
}
|
||||
@@ -102,8 +102,7 @@ public class CCAddAnswerPlaceholder extends CCAnswerPlaceholderAction {
|
||||
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
AnswerPlaceholder fromPlaceholder = placeholders.get(i);
|
||||
AnswerPlaceholder.MyInitialState state = fromPlaceholder.getInitialState();
|
||||
taskFile.getAnswerPlaceholders().get(i).setInitialState(new AnswerPlaceholder.MyInitialState(state.getOffset(), state.getLength()));
|
||||
taskFile.getAnswerPlaceholders().get(i).setInitialState(new AnswerPlaceholder.MyInitialState(fromPlaceholder.getOffset(), fromPlaceholder.getLength()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public class CCHideFromStudent extends CCTaskFileActionBase {
|
||||
return;
|
||||
}
|
||||
String name = file.getName();
|
||||
VirtualFile patternFile = StudyUtils.getPatternFile(project, taskFile, name);
|
||||
VirtualFile patternFile = StudyUtils.getPatternFile(taskFile, name);
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
if (patternFile != null) {
|
||||
try {
|
||||
|
||||
@@ -393,12 +393,12 @@ public class StudyUtils {
|
||||
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile getPatternFile(@NotNull Project project, @NotNull TaskFile taskFile, String name) {
|
||||
public static VirtualFile getPatternFile(@NotNull TaskFile taskFile, String name) {
|
||||
Task task = taskFile.getTask();
|
||||
String lessonDir = EduNames.LESSON + String.valueOf(task.getLesson().getIndex());
|
||||
String taskDir = EduNames.TASK + String.valueOf(task.getIndex());
|
||||
Course course = task.getLesson().getCourse();
|
||||
File resourceFile = getCourseDirectory(project, course);
|
||||
File resourceFile = new File(course.getCourseDirectory());
|
||||
if (!resourceFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
@@ -411,8 +411,8 @@ public class StudyUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Document getPatternDocument(@NotNull Project project, @NotNull final TaskFile taskFile, String name) {
|
||||
VirtualFile patternFile = getPatternFile(project, taskFile, name);
|
||||
public static Document getPatternDocument(@NotNull final TaskFile taskFile, String name) {
|
||||
VirtualFile patternFile = getPatternFile(taskFile, name);
|
||||
if (patternFile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class StudyRefreshAnswerPlaceholder extends DumbAwareAction {
|
||||
}
|
||||
StudyEditor studyEditor = StudyUtils.getSelectedStudyEditor(project);
|
||||
final StudyState studyState = new StudyState(studyEditor);
|
||||
Document patternDocument = StudyUtils.getPatternDocument(project, answerPlaceholder.getTaskFile(), studyState.getVirtualFile().getName());
|
||||
Document patternDocument = StudyUtils.getPatternDocument(answerPlaceholder.getTaskFile(), studyState.getVirtualFile().getName());
|
||||
if (patternDocument == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-4
@@ -82,7 +82,7 @@ public class StudyRefreshTaskFileAction extends StudyActionWithShortcut {
|
||||
@NotNull final Project project,
|
||||
TaskFile taskFile,
|
||||
String name) {
|
||||
if (!resetDocument(project, document, taskFile, name)) {
|
||||
if (!resetDocument(document, taskFile, name)) {
|
||||
return false;
|
||||
}
|
||||
taskFile.getTask().setStatus(StudyStatus.Unchecked);
|
||||
@@ -111,11 +111,10 @@ public class StudyRefreshTaskFileAction extends StudyActionWithShortcut {
|
||||
}
|
||||
|
||||
|
||||
private static boolean resetDocument(@NotNull final Project project,
|
||||
@NotNull final Document document,
|
||||
private static boolean resetDocument(@NotNull final Document document,
|
||||
@NotNull final TaskFile taskFile,
|
||||
String fileName) {
|
||||
final Document patternDocument = StudyUtils.getPatternDocument(project, taskFile, fileName);
|
||||
final Document patternDocument = StudyUtils.getPatternDocument(taskFile, fileName);
|
||||
if (patternDocument == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-1
@@ -99,7 +99,9 @@ public class TaskFile {
|
||||
answerPlaceholderCopy.setIndex(answerPlaceholder.getIndex());
|
||||
answerPlaceholderCopy.setHint(answerPlaceholder.getHint());
|
||||
final AnswerPlaceholder.MyInitialState state = answerPlaceholder.getInitialState();
|
||||
answerPlaceholderCopy.setInitialState(new AnswerPlaceholder.MyInitialState(state.getOffset(), state.getLength()));
|
||||
if (state != null) {
|
||||
answerPlaceholderCopy.setInitialState(new AnswerPlaceholder.MyInitialState(state.getOffset(), state.getLength()));
|
||||
}
|
||||
answerPlaceholdersCopy.add(answerPlaceholderCopy);
|
||||
}
|
||||
target.name = source.name;
|
||||
|
||||
Reference in New Issue
Block a user