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);
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;
}
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;
}
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()));
}
}
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 {
@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;
}
}
@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;
}
}
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;
}
@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);
}
- 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;
}
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;