EDU-612 Placeholder without frame idea/163.355
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Jun 2016 14:18:43 +0000 (17:18 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 21 Jun 2016 14:22:14 +0000 (17:22 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCCreateCourseArchive.java
python/educational-core/student/src/com/jetbrains/edu/learning/checker/StudyCheckUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/core/EduAnswerPlaceholderPainter.java
python/educational-core/student/src/com/jetbrains/edu/learning/core/EduDocumentListener.java
python/educational-core/student/src/com/jetbrains/edu/learning/core/EduUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/courseFormat/AnswerPlaceholder.java
python/educational-core/student/src/com/jetbrains/edu/learning/navigation/StudyNavigator.java

index 05e9e87c60f8961c9f50fa74ea69386aa5a1dcae..8425c71b04830712a6fed37098903267a123c451 100644 (file)
@@ -26,10 +26,7 @@ import com.jetbrains.edu.coursecreator.ui.CreateCourseArchiveDialog;
 import com.jetbrains.edu.learning.StudyTaskManager;
 import com.jetbrains.edu.learning.core.EduNames;
 import com.jetbrains.edu.learning.core.EduUtils;
-import com.jetbrains.edu.learning.courseFormat.Course;
-import com.jetbrains.edu.learning.courseFormat.Lesson;
-import com.jetbrains.edu.learning.courseFormat.Task;
-import com.jetbrains.edu.learning.courseFormat.TaskFile;
+import com.jetbrains.edu.learning.courseFormat.*;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.*;
@@ -163,7 +160,11 @@ public class CCCreateCourseArchive extends DumbAwareAction {
 
   private static void resetTaskFiles(Map<TaskFile, TaskFile> savedTaskFiles) {
     for (Map.Entry<TaskFile, TaskFile> entry : savedTaskFiles.entrySet()) {
-      entry.getKey().setAnswerPlaceholders(entry.getValue().getAnswerPlaceholders());
+      List<AnswerPlaceholder> placeholders = entry.getValue().getAnswerPlaceholders();
+      for (AnswerPlaceholder placeholder : placeholders) {
+        placeholder.setUseLength(false);
+      }
+      entry.getKey().setAnswerPlaceholders(placeholders);
     }
   }
 
index 21d0983f252d56c48ff8c63a9642c89a3dc8ac2f..a14e89fa6c730baa7b88ee9957da0a492c4cfc90 100644 (file)
@@ -129,9 +129,6 @@ public class StudyCheckUtils {
       if (document == null) {
         continue;
       }
-      if (!answerPlaceholder.isValid(document)) {
-        continue;
-      }
       StudySmartChecker.smartCheck(answerPlaceholder, project, answerFile, answerTaskFile, taskFile, testRunner,
                                    virtualFile, document);
     }
@@ -154,9 +151,6 @@ public class StudyCheckUtils {
         EduDocumentListener listener = new EduDocumentListener(target);
         document.addDocumentListener(listener);
         for (AnswerPlaceholder answerPlaceholder : target.getAnswerPlaceholders()) {
-          if (!answerPlaceholder.isValid(document)) {
-            continue;
-          }
           final int start = answerPlaceholder.getOffset();
           final int end = start + answerPlaceholder.getRealLength();
           final String text = answerPlaceholder.getPossibleAnswer();
index 3902b942af009246346dd399b2cd6de49dedf35b..a9d8685603f358a64441a4f1630608cb8270f56b 100644 (file)
@@ -27,10 +27,6 @@ public class EduAnswerPlaceholderPainter {
 
   public static void drawAnswerPlaceholder(@NotNull final Editor editor, @NotNull final AnswerPlaceholder placeholder,
                                            @NotNull final JBColor color) {
-    final Document document = editor.getDocument();
-    if (!placeholder.isValid(document)) {
-      return;
-    }
     EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
     final TextAttributes textAttributes = new TextAttributes(scheme.getDefaultForeground(), scheme.getDefaultBackground(), null,
                                                                     EffectType.BOXED, Font.PLAIN);
@@ -68,7 +64,6 @@ public class EduAnswerPlaceholderPainter {
     if (document instanceof DocumentImpl) {
       DocumentImpl documentImpl = (DocumentImpl)document;
       List<RangeMarker> blocks = documentImpl.getGuardedBlocks();
-      if (!placeholder.isValid(document)) return;
       int start = placeholder.getOffset();
       final int length = placeholder.getRealLength();
       int end = start + length;
index 7105b4662b300d6e671ef0d63b7e2cb34395458f..836ecf9c4e33126ac5728d145bc008709ab4f3a3 100644 (file)
@@ -71,7 +71,6 @@ public class EduDocumentListener extends DocumentAdapter {
         AnswerPlaceholder answerPlaceholder = answerPlaceholderWrapper.getAnswerPlaceholder();
         int length = twEnd - twStart;
         answerPlaceholder.setOffset(twStart);
-        answerPlaceholder.setLength(length);
         if (!answerPlaceholder.getUseLength()) {
           answerPlaceholder.setPossibleAnswer(document.getText(TextRange.create(twStart, twStart + length)));
         }
index ecfa1ec3a13619158b0e49774fc8a986d32c17ad..e6e520fca01c89d6315a26e04b55cd19a2eccf0c 100644 (file)
@@ -82,10 +82,6 @@ public class EduUtils {
         printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
         for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
           int length = answerPlaceholder.getRealLength();
-          if (!answerPlaceholder.isValid(document, length)) {
-            printWriter.println("#educational_plugin_window = ");
-            continue;
-          }
           int start = answerPlaceholder.getOffset();
           final String windowDescription = document.getText(new TextRange(start, start + length));
           printWriter.println("#educational_plugin_window = " + windowDescription);
index 23fb46888d439e97087b31fcfa38bcd086974392..242da278aed04230e59c47189cc7f59dc2741702 100644 (file)
@@ -2,9 +2,7 @@ package com.jetbrains.edu.learning.courseFormat;
 
 import com.google.gson.annotations.Expose;
 import com.google.gson.annotations.SerializedName;
-import com.intellij.openapi.editor.Document;
 import com.intellij.util.xmlb.annotations.Transient;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -112,14 +110,6 @@ public class AnswerPlaceholder {
     return possibleAnswer.length();
   }
 
-  public boolean isValid(@NotNull final Document document) {
-    return isValid(document, length);
-  }
-
-  public boolean isValid(@NotNull final Document document, int length) {
-    return myOffset >= 0 && myOffset + length <= document.getTextLength();
-  }
-
   /**
    * Returns window to its initial state
    */
index 75b2c7709001bd0952b658b3e618b9d772d068a1..02b920104152b6ebea47e050e53fc27716b9bb38 100644 (file)
@@ -74,7 +74,7 @@ public class StudyNavigator {
   }
 
   public static  void navigateToAnswerPlaceholder(@NotNull final Editor editor, @NotNull final AnswerPlaceholder answerPlaceholder) {
-    if (editor.isDisposed() || !answerPlaceholder.isValid(editor.getDocument())) {
+    if (editor.isDisposed()) {
       return;
     }
     editor.getCaretModel().moveToOffset(answerPlaceholder.getOffset());