</extensions>
<extensions defaultExtensionNs="Edu">
<studyActionsProvider implementation="com.jetbrains.edu.coursecreator.CCStudyActionsProvider"/>
- <studyCheckActionListener implementation="com.jetbrains.edu.coursecreator.CCStudyCheckActionListener"/>
+ <studyActionListener implementation="com.jetbrains.edu.coursecreator.CCStudyActionListener"/>
</extensions>
<project-components>
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.DocumentUtil;
-import com.jetbrains.edu.learning.StudyCheckActionListener;
+import com.jetbrains.edu.learning.StudyActionListener;
import com.jetbrains.edu.learning.StudyUtils;
+import com.jetbrains.edu.learning.core.EduUtils;
+import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.Task;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import java.util.Map;
-public class CCStudyCheckActionListener implements StudyCheckActionListener {
+public class CCStudyActionListener implements StudyActionListener {
@Override
public void beforeCheck(AnActionEvent event) {
Project project = event.getProject();
patternDocument.replaceString(0, patternDocument.getTextLength(), document.getCharsSequence());
FileDocumentManager.getInstance().saveDocument(patternDocument);
});
+ TaskFile target = new TaskFile();
+ TaskFile.copy(taskFile, target);
+ for (AnswerPlaceholder placeholder : target.getAnswerPlaceholders()) {
+ placeholder.setUseLength(false);
+ }
+ EduUtils.createStudentDocument(project, target, child, patternDocument);
}
}
}
if (CCUtils.isTestsFile(project, createdFile)
|| EduNames.TASK_HTML.equals(name)
|| name.contains(EduNames.WINDOW_POSTFIX)
- || name.contains(EduNames.WINDOWS_POSTFIX)) {
+ || name.contains(EduNames.WINDOWS_POSTFIX)
+ || name.contains(EduNames.ANSWERS_POSTFIX)) {
return;
}
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.SelectionModel;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.ui.JBColor;
+import com.intellij.util.DocumentUtil;
import com.jetbrains.edu.coursecreator.ui.CCCreateAnswerPlaceholderDialog;
import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.core.EduAnswerPlaceholderPainter;
import com.jetbrains.edu.learning.core.EduNames;
+import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import org.jetbrains.annotations.NotNull;
final AnswerPlaceholder answerPlaceholder = new AnswerPlaceholder();
answerPlaceholder.setLine(lineNumber);
answerPlaceholder.setStart(realStart);
+ answerPlaceholder.setUseLength(false);
String selectedText = model.getSelectedText();
answerPlaceholder.setPossibleAnswer(selectedText);
int index = taskFile.getAnswerPlaceholders().size() + 1;
answerPlaceholder.setIndex(index);
taskFile.addAnswerPlaceholder(answerPlaceholder);
+ answerPlaceholder.setTaskFile(taskFile);
taskFile.sortAnswerPlaceholders();
- EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, false, JBColor.BLUE);
- EduAnswerPlaceholderPainter.createGuardedBlocks(editor, answerPlaceholder, false);
+
+
+ computeInitialState(project, file, taskFile, document);
+
+ EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, JBColor.BLUE);
+ EduAnswerPlaceholderPainter.createGuardedBlocks(editor, answerPlaceholder);
+ }
+
+ private static void computeInitialState(Project project, PsiFile file, TaskFile taskFile, Document document) {
+ Document patternDocument = StudyUtils.getPatternDocument(taskFile, file.getName());
+ if (patternDocument == null) {
+ return;
+ }
+ DocumentUtil.writeInRunUndoTransparentAction(() -> {
+ patternDocument.replaceString(0, patternDocument.getTextLength(), document.getCharsSequence());
+ FileDocumentManager.getInstance().saveDocument(patternDocument);
+ });
+ TaskFile target = new TaskFile();
+ TaskFile.copy(taskFile, target);
+ List<AnswerPlaceholder> placeholders = target.getAnswerPlaceholders();
+ for (AnswerPlaceholder placeholder : placeholders) {
+ placeholder.setUseLength(false);
+ }
+ EduUtils.createStudentDocument(project, target, file.getVirtualFile(), patternDocument);
+
+ for (int i = 0; i < placeholders.size(); i++) {
+ AnswerPlaceholder fromPlaceholder = placeholders.get(i);
+ taskFile.getAnswerPlaceholders().get(i).setInitialState(fromPlaceholder);
+ }
}
@Override
answerPlaceholders.remove(answerPlaceholder);
final Editor editor = state.getEditor();
editor.getMarkupModel().removeAllHighlighters();
- StudyUtils.drawAllWindows(editor, taskFile, false);
- EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile, false);
+ StudyUtils.drawAllWindows(editor, taskFile);
+ EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
}
}
private static void updateView(@NotNull final Editor editor,
@NotNull final TaskFile taskFile) {
editor.getMarkupModel().removeAllHighlighters();
- StudyUtils.drawAllWindows(editor, taskFile, false);
+ StudyUtils.drawAllWindows(editor, taskFile);
}
@Override
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
- final String text = document.getText(TextRange.create(offset, offset + answerPlaceholder.getLength()));
+ final String text = document.getText(TextRange.create(offset, offset + answerPlaceholder.getRealLength()));
answerPlaceholder.setTaskText(text);
answerPlaceholder.init();
final VirtualFile hints = project.getBaseDir().findChild(EduNames.HINTS);
}
}
- document.replaceString(offset, offset + answerPlaceholder.getLength(), answerPlaceholder.getPossibleAnswer());
+ document.replaceString(offset, offset + answerPlaceholder.getRealLength(), answerPlaceholder.getPossibleAnswer());
FileDocumentManager.getInstance().saveDocument(document);
}
});
}
});
for (AnswerPlaceholder answerPlaceholder : taskFileCopy.getAnswerPlaceholders()) {
- EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, true, JBColor.BLUE);
+ EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, JBColor.BLUE);
}
JPanel header = new JPanel();
header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS));
myAnswerPlaceholder.setTaskText(StringUtil.notNullize(answerPlaceholderText));
myAnswerPlaceholder.setLength(StringUtil.notNullize(answerPlaceholderText).length());
myAnswerPlaceholder.setHint(myPanel.getHintText());
- AnswerPlaceholder.MyInitialState initialState = new AnswerPlaceholder.MyInitialState(myAnswerPlaceholder.getLine(), answerPlaceholderText.length(), myAnswerPlaceholder.getStart());
- myAnswerPlaceholder.setInitialState(initialState);
super.doOKAction();
}
<extensionPoint qualifiedName="Edu.studyPluginConfigurator" interface="com.jetbrains.edu.learning.StudyPluginConfigurator"/>
<extensionPoint qualifiedName="Edu.studyActionsProvider" interface="com.jetbrains.edu.learning.StudyActionsProvider"/>
<extensionPoint qualifiedName="Edu.studyTwitterPluginConfigurator" interface="com.jetbrains.edu.learning.StudyTwitterPluginConfigurator"/>
- <extensionPoint qualifiedName="Edu.studyCheckActionListener" interface="com.jetbrains.edu.learning.StudyCheckActionListener"/>
+ <extensionPoint qualifiedName="Edu.studyActionListener" interface="com.jetbrains.edu.learning.StudyActionListener"/>
</extensionPoints>
<actions>
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.extensions.ExtensionPointName;
-public interface StudyCheckActionListener {
- ExtensionPointName<StudyCheckActionListener> EP_NAME = ExtensionPointName.create("Edu.studyCheckActionListener");
+public interface StudyActionListener {
+ ExtensionPointName<StudyActionListener> EP_NAME = ExtensionPointName.create("Edu.studyActionListener");
void beforeCheck(AnActionEvent event);
}
Document document = FileDocumentManager.getInstance().getDocument(file);
assert document != null;
int startOffset = placeholder.getRealStartOffset(document);
- return Collections.singletonList(new TextRange(startOffset, startOffset + placeholder.getLength()));
+ return Collections.singletonList(new TextRange(startOffset, startOffset + placeholder.getRealLength()));
}
}
}
public static void drawAllWindows(Editor editor, TaskFile taskFile) {
- drawAllWindows(editor, taskFile, true);
- }
-
- public static void drawAllWindows(Editor editor, TaskFile taskFile, boolean useLength) {
editor.getMarkupModel().removeAllHighlighters();
final Project project = editor.getProject();
if (project == null) return;
final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
final JBColor color = taskManager.getColor(answerPlaceholder);
- EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, useLength, color);
+ EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, color);
}
final Document document = editor.getDocument();
EditorActionManager.getInstance()
.setReadonlyFragmentModificationHandler(document, new EduAnswerPlaceholderDeleteHandler(editor));
- EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile, useLength);
+ EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
editor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null);
}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Ref;
-import com.jetbrains.edu.learning.StudyCheckActionListener;
+import com.jetbrains.edu.learning.StudyActionListener;
import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.checker.StudyCheckUtils;
import icons.InteractiveLearningIcons;
StudyCheckUtils.showTestResultPopUp("Checking is not available while indexing is in progress", MessageType.WARNING.getPopupBackground(), project);
return;
}
- for (StudyCheckActionListener listener : Extensions.getExtensions(StudyCheckActionListener.EP_NAME)) {
+ for (StudyActionListener listener : Extensions.getExtensions(StudyActionListener.EP_NAME)) {
listener.beforeCheck(e);
}
check(project);
continue;
}
int offset = placeholder.getRealStartOffset(document);
- document.deleteString(offset, offset + placeholder.getLength());
+ document.deleteString(offset, offset + placeholder.getRealLength());
document.insertString(offset, answer);
}
}
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
+import com.jetbrains.edu.learning.StudyActionListener;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.StudyState;
if (project == null) {
return;
}
+ for (StudyActionListener listener : Extensions.getExtensions(StudyActionListener.EP_NAME)) {
+ listener.beforeCheck(e);
+ }
final AnswerPlaceholder answerPlaceholder = getAnswerPlaceholder(e);
if (answerPlaceholder == null) {
return;
public void run() {
Document document = studyState.getEditor().getDocument();
int offset = answerPlaceholder.getRealStartOffset(document);
- document.deleteString(offset, offset + answerPlaceholder.getLength());
+ document.deleteString(offset, offset + answerPlaceholder.getRealLength());
document.insertString(offset, text);
}
});
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.problems.WolfTheProblemSolver;
+import com.jetbrains.edu.learning.StudyActionListener;
+import com.jetbrains.edu.learning.StudyState;
+import com.jetbrains.edu.learning.StudyTaskManager;
+import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.core.EduAnswerPlaceholderPainter;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.StudyStatus;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
-import com.jetbrains.edu.learning.StudyState;
-import com.jetbrains.edu.learning.StudyTaskManager;
-import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.editor.StudyEditor;
import com.jetbrains.edu.learning.navigation.StudyNavigator;
import org.jetbrains.annotations.NotNull;
WolfTheProblemSolver.getInstance(project).clearProblems(studyState.getVirtualFile());
taskFile.setHighlightErrors(false);
StudyUtils.drawAllWindows(editor, taskFile);
- EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile, true);
+ EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
public void actionPerformed(@NotNull AnActionEvent event) {
final Project project = event.getProject();
if (project != null) {
+ for (StudyActionListener listener : Extensions.getExtensions(StudyActionListener.EP_NAME)) {
+ listener.beforeCheck(event);
+ }
refresh(project);
}
}
import com.intellij.openapi.wm.ex.StatusBarEx;
import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.jetbrains.edu.learning.core.EduDocumentListener;
+import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.Task;
import java.util.Map;
public class StudyCheckUtils {
- private static final String ANSWERS_POSTFIX = "_answers";
private static final Logger LOG = Logger.getInstance(StudyCheckUtils.class);
private StudyCheckUtils() {
VirtualFile copy = null;
try {
- copy = file.copy(taskDir, taskDir, file.getNameWithoutExtension() + ANSWERS_POSTFIX + "." + file.getExtension());
+ copy = file.copy(taskDir, taskDir, file.getNameWithoutExtension() + EduNames.ANSWERS_POSTFIX + "." + file.getExtension());
final FileDocumentManager documentManager = FileDocumentManager.getInstance();
final Document document = documentManager.getDocument(copy);
if (document != null) {
continue;
}
final int start = answerPlaceholder.getRealStartOffset(document);
- final int end = start + answerPlaceholder.getLength();
+ final int end = start + answerPlaceholder.getRealLength();
final String text = answerPlaceholder.getPossibleAnswer();
document.replaceString(start, end, text);
}
EduDocumentListener listener = new EduDocumentListener(windowTaskFile);
windowDocument.addDocumentListener(listener);
int start = placeholder.getRealStartOffset(windowDocument);
- int end = start + placeholder.getLength();
+ int end = start + placeholder.getRealLength();
final AnswerPlaceholder userAnswerPlaceholder = usersTaskFile.getAnswerPlaceholders().get(placeholder.getIndex());
int userStart = userAnswerPlaceholder.getRealStartOffset(usersDocument);
- int userEnd = userStart + userAnswerPlaceholder.getLength();
+ int userEnd = userStart + userAnswerPlaceholder.getRealLength();
String text = usersDocument.getText(new TextRange(userStart, userEnd));
windowDocument.replaceString(start, end, text);
ApplicationManager.getApplication().runWriteAction(() -> {
}
public static void drawAnswerPlaceholder(@NotNull final Editor editor, @NotNull final AnswerPlaceholder placeholder,
- boolean useLength, @NotNull final JBColor color) {
+ @NotNull final JBColor color) {
final Document document = editor.getDocument();
- if (useLength && !placeholder.isValid(document)) {
+ if (!placeholder.isValid(document)) {
return;
}
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
final Project project = editor.getProject();
assert project != null;
final int startOffset = placeholder.getRealStartOffset(document);
- final int length = placeholder.getLength();
- final int replacementLength = placeholder.getPossibleAnswerLength();
- int highlighterLength = useLength ? length : replacementLength;
- final int endOffset = startOffset + highlighterLength;
+ final int length = placeholder.getRealLength();
+ final int endOffset = startOffset + length;
textAttributes.setEffectColor(color);
RangeHighlighter
highlighter = editor.getMarkupModel().addRangeHighlighter(startOffset, endOffset, PLACEHOLDERS_LAYER,
}
- public static void createGuardedBlocks(@NotNull final Editor editor, TaskFile taskFile, boolean useLength) {
+ public static void createGuardedBlocks(@NotNull final Editor editor, TaskFile taskFile) {
for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
- createGuardedBlocks(editor, answerPlaceholder, useLength);
+ createGuardedBlocks(editor, answerPlaceholder);
}
}
- public static void createGuardedBlocks(@NotNull final Editor editor, AnswerPlaceholder placeholder, boolean useLength) {
+ public static void createGuardedBlocks(@NotNull final Editor editor, AnswerPlaceholder placeholder) {
Document document = editor.getDocument();
if (document instanceof DocumentImpl) {
DocumentImpl documentImpl = (DocumentImpl)document;
List<RangeMarker> blocks = documentImpl.getGuardedBlocks();
- if (useLength && !placeholder.isValid(document)) return;
+ if (!placeholder.isValid(document)) return;
int start = placeholder.getRealStartOffset(document);
- final int length = useLength ? placeholder.getLength() : placeholder.getPossibleAnswerLength();
+ final int length = placeholder.getRealLength();
int end = start + length;
if (start != 0) {
createGuardedBlock(editor, blocks, start - 1, start);
public class EduDocumentListener extends DocumentAdapter {
private final TaskFile myTaskFile;
private final boolean myTrackLength;
- private final boolean usePossibleAnswerLength;
private final List<AnswerPlaceholderWrapper> myAnswerPlaceholders = new ArrayList<AnswerPlaceholderWrapper>();
public EduDocumentListener(TaskFile taskFile) {
myTaskFile = taskFile;
myTrackLength = true;
- usePossibleAnswerLength = false;
}
public EduDocumentListener(TaskFile taskFile, boolean trackLength) {
myTaskFile = taskFile;
myTrackLength = trackLength;
- usePossibleAnswerLength = false;
}
- public EduDocumentListener(TaskFile taskFile, boolean trackLength, boolean usePossibleAnswerLength) {
- myTaskFile = taskFile;
- myTrackLength = trackLength;
- this.usePossibleAnswerLength = usePossibleAnswerLength;
- }
-
-
//remembering old end before document change because of problems
// with fragments containing "\n"
@Override
myAnswerPlaceholders.clear();
for (AnswerPlaceholder answerPlaceholder : myTaskFile.getAnswerPlaceholders()) {
int twStart = answerPlaceholder.getRealStartOffset(document);
- int length = usePossibleAnswerLength ? answerPlaceholder.getPossibleAnswerLength() : answerPlaceholder.getLength();
+ int length = answerPlaceholder.getRealLength();
int twEnd = twStart + length;
myAnswerPlaceholders.add(new AnswerPlaceholderWrapper(answerPlaceholder, twStart, twEnd));
}
int length = twEnd - twStart;
answerPlaceholder.setLine(line);
answerPlaceholder.setStart(start);
- if (usePossibleAnswerLength) {
+ if (!answerPlaceholder.getUseLength()) {
answerPlaceholder.setPossibleAnswer(document.getText(TextRange.create(twStart, twStart + length)));
}
else if (myTrackLength) {
public static final String USER_TEST_OUTPUT = "output";
public static final String WINDOW_POSTFIX = "_window.";
public static final String WINDOWS_POSTFIX = "_windows";
+ public static final String ANSWERS_POSTFIX = "_answers";
public static final String USER_TESTS = "userTests";
public static final String TESTS_FILE = "tests.py";
public static final String TEST_HELPER = "test_helper.py";
fileWindows = taskDir.createChildData(taskFile, name);
printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
- int length = useLength ? answerPlaceholder.getLength() : answerPlaceholder.getPossibleAnswerLength();
+ int length = answerPlaceholder.getRealLength();
if (!answerPlaceholder.isValid(document, length)) {
printWriter.println("#educational_plugin_window = ");
continue;
});
}
}, "Create Student File", "Create Student File");
+ createStudentDocument(project, taskFile, file, document);
+ }
+
+ public static void createStudentDocument(@NotNull Project project,
+ @NotNull TaskFile taskFile,
+ VirtualFile file,
+ final Document document) {
EduDocumentListener listener = new EduDocumentListener(taskFile, false);
document.addDocumentListener(listener);
taskFile.sortAnswerPlaceholders();
private MyInitialState myInitialState;
private StudyStatus myStatus = StudyStatus.Uninitialized;
private boolean mySelected = false;
+ private boolean myUseLength = true;
@Transient private TaskFile myTaskFile;
myIndex = index;
}
+ /**
+ * in actions {@link AnswerPlaceholder#getRealLength()} should be used
+ */
public int getLength() {
return length;
}
line = myInitialState.myLine;
start = myInitialState.myStart;
length = myInitialState.myLength;
+ if (!getUseLength()) {
+ possibleAnswer = myTaskText;
+ }
}
public StudyStatus getStatus() {
}
public void init() {
- setInitialState(new MyInitialState(line, possibleAnswer.length(), start));
+ setInitialState(new MyInitialState(line, myTaskText.length(), start));
+ }
+
+ public boolean getUseLength() {
+ return myUseLength;
+ }
+
+ /**
+ * @return length or possible answer length
+ */
+ public int getRealLength() {
+ return myUseLength ? getLength() : getPossibleAnswerLength();
+ }
+
+ public void setUseLength(boolean useLength) {
+ myUseLength = useLength;
+ }
+
+ public void setInitialState(AnswerPlaceholder placeholder) {
+ setInitialState(new MyInitialState(placeholder.line, placeholder.length, placeholder.start));
}
public static class MyInitialState {
for (AnswerPlaceholder placeholder : myAnswerPlaceholders) {
if (placeholder.getLine() <= line) {
int realStartOffset = placeholder.getRealStartOffset(document);
- int placeholderLength = useAnswerLength ? placeholder.getPossibleAnswerLength() : placeholder.getLength();
+ int placeholderLength = placeholder.getRealLength();
final int length = placeholderLength > 0 ? placeholderLength : 0;
int endOffset = realStartOffset + length;
if (realStartOffset <= offset && offset <= endOffset) {
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.problems.WolfTheProblemSolver;
import com.jetbrains.edu.learning.StudyTaskManager;
+import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.core.EduDocumentListener;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
-import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.navigation.StudyNavigator;
import com.jetbrains.edu.learning.ui.StudyToolWindowFactory;
import org.jetbrains.annotations.NotNull;
return;
}
int startOffset = answerPlaceholder.getRealStartOffset(editor.getDocument());
- editor.getSelectionModel().setSelection(startOffset, startOffset + answerPlaceholder.getLength());
+ editor.getSelectionModel().setSelection(startOffset, startOffset + answerPlaceholder.getRealLength());
answerPlaceholder.setSelected(true);
}
}
return;
}
+ StudyEditor.addDocumentListener(document, new EduDocumentListener(taskFile, true));
+
if (!taskFile.getAnswerPlaceholders().isEmpty()) {
StudyNavigator.navigateToFirstAnswerPlaceholder(editor, taskFile);
boolean isStudyProject = EduNames.STUDY.equals(course.getCourseType());
- StudyEditor.addDocumentListener(document, new EduDocumentListener(taskFile, true,
- !isStudyProject));
- StudyUtils.drawAllWindows(editor, taskFile, isStudyProject);
+ StudyUtils.drawAllWindows(editor, taskFile);
if (isStudyProject) {
editor.addEditorMouseListener(new WindowSelectionListener(taskFile));
}