moved everything python-specific to python part of educational plugin appcode/140.2453 clion/140.2452
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Fri, 13 Feb 2015 11:56:53 +0000 (14:56 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Fri, 13 Feb 2015 11:56:53 +0000 (14:56 +0300)
24 files changed:
python/edu/course-creator-python/resources/META-INF/plugin.xml
python/edu/course-creator-python/src/com/jetbrains/edu/coursecreator/PyCCLanguageManager.java [moved from python/edu/course-creator-python/src/com/jetbrains/edu/coursecreator/PyStudyLanguageManager.java with 94% similarity]
python/edu/interactive-learning-python/resources/META-INF/plugin.xml
python/edu/interactive-learning-python/src/com/jetbrains/edu/learning/PyStudyExecutor.java
python/edu/interactive-learning-python/src/com/jetbrains/edu/learning/PyStudyLanguageManager.java [new file with mode: 0644]
python/edu/interactive-learning-python/src/com/jetbrains/edu/learning/PyStudyTestRunner.java
python/educational/course-creator/resources/META-INF/plugin.xml
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/CCLanguageManager.java [moved from python/educational/course-creator/src/com/jetbrains/edu/coursecreator/StudyLanguageManager.java with 78% similarity]
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/CCUtils.java
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCCreateCourseArchive.java
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCCreateTask.java
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCCreateTaskFile.java
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCRunTestsAction.java
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/ui/CreateTaskFileDialog.java
python/educational/interactive-learning/resources/META-INF/plugin.xml
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyLanguageManager.java [new file with mode: 0644]
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyNames.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyProjectGenerator.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyTaskManager.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyUtils.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/actions/StudyCheckAction.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/course/AnswerPlaceholder.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/course/Course.java
python/educational/interactive-learning/src/com/jetbrains/edu/learning/course/Task.java

index 1b015984d136f2d0f73b6d57fee02c61cd0b3558..1bb7f23ba546f6c70082bac531454fb54cacb32b 100644 (file)
@@ -28,7 +28,7 @@
   </extensions>
 
   <extensions defaultExtensionNs="Edu">
-    <StudyLanguageManager implementationClass="com.jetbrains.edu.coursecreator.PyStudyLanguageManager" language="Python"/>
+    <CCLanguageManager implementationClass="com.jetbrains.edu.coursecreator.PyCCLanguageManager" language="Python"/>
   </extensions>
 
   <application-components>
similarity index 94%
rename from python/edu/course-creator-python/src/com/jetbrains/edu/coursecreator/PyStudyLanguageManager.java
rename to python/edu/course-creator-python/src/com/jetbrains/edu/coursecreator/PyCCLanguageManager.java
index be2f399ffe581421f6def67c043a6becf7f4bbd6..2f6db75f6dccc4ac374496f2779af3950fc928d4 100644 (file)
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.io.File;
 
-public class PyStudyLanguageManager implements StudyLanguageManager {
+public class PyCCLanguageManager implements CCLanguageManager {
   @Nullable
   @Override
   public String getDefaultTaskFileExtension() {
index 21610c1dc0eea09e56e231b5a598eb0e26905499..a9eca088e5f120404b7c943c3a2c453e3edaf618 100644 (file)
@@ -31,6 +31,7 @@
   </extensions>
   <extensions defaultExtensionNs="Edu">
     <StudyExecutor implementationClass="com.jetbrains.edu.learning.PyStudyExecutor" language="Python"/>
+    <StudyLanguageManager implementationClass="com.jetbrains.edu.learning.PyStudyLanguageManager" language="Python"/>
   </extensions>
   <actions>
     <action id="WelcomeScreen.PythonIntro" class="com.jetbrains.edu.learning.actions.PyStudyIntroductionCourseAction"
index a78c55861d56d5bb2551b3558f4389cb81196d91..f3950f7469cf3d8707fefd8645a661345f2ebfa8 100644 (file)
@@ -61,9 +61,12 @@ public class PyStudyExecutor implements StudyExecutor {
                                                @NotNull final String sdkPath,
                                                @NotNull final Task currentTask) {
     if (!currentTask.getUserTests().isEmpty()) {
-      cmd.addParameter(new File(project.getBaseDir().getPath(), StudyNames.USER_TESTER).getPath());
-      cmd.addParameter(sdkPath);
-      cmd.addParameter(filePath);
+      StudyLanguageManager manager = StudyUtils.getLanguageManager(currentTask.getLesson().getCourse());
+      if (manager != null) {
+        cmd.addParameter(new File(project.getBaseDir().getPath(), manager.getUserTester()).getPath());
+        cmd.addParameter(sdkPath);
+        cmd.addParameter(filePath);
+      }
     }
     else {
       cmd.addParameter(filePath);
diff --git a/python/edu/interactive-learning-python/src/com/jetbrains/edu/learning/PyStudyLanguageManager.java b/python/edu/interactive-learning-python/src/com/jetbrains/edu/learning/PyStudyLanguageManager.java
new file mode 100644 (file)
index 0000000..1b04ea6
--- /dev/null
@@ -0,0 +1,24 @@
+package com.jetbrains.edu.learning;
+
+import org.jetbrains.annotations.NotNull;
+
+public class PyStudyLanguageManager implements StudyLanguageManager {
+
+  @NotNull
+  @Override
+  public String getTestFileName() {
+    return "tests.py";
+  }
+
+  @NotNull
+  @Override
+  public String getTestHelperFileName() {
+    return "test_helper.py";
+  }
+
+  @NotNull
+  @Override
+  public String getUserTester() {
+    return "user_tester.py";
+  }
+}
index 9515533d3d6452d7459674f49c86224481475254..267d14f72b2286387d85ad16f4e46878dd0f116a 100644 (file)
@@ -2,6 +2,7 @@ package com.jetbrains.edu.learning;
 
 import com.intellij.execution.ExecutionException;
 import com.intellij.execution.configurations.GeneralCommandLine;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.Sdk;
@@ -17,6 +18,7 @@ import java.util.Map;
 
 public class PyStudyTestRunner extends StudyTestRunner {
   private static final String PYTHONPATH = "PYTHONPATH";
+  private static final Logger LOG = Logger.getInstance(PyStudyTestRunner.class.getName());
 
   PyStudyTestRunner(@NotNull final Task task, @NotNull final VirtualFile taskDir) {
     super(task, taskDir);
@@ -24,7 +26,13 @@ public class PyStudyTestRunner extends StudyTestRunner {
 
   public Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
     final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
-    final File testRunner = new File(myTaskDir.getPath(), myTask.getTestFile());
+    Course course = myTask.getLesson().getCourse();
+    StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
+    if (manager == null) {
+      LOG.info("Language manager is null for " + course.getLanguageById().getDisplayName());
+      return null;
+    }
+    final File testRunner = new File(myTaskDir.getPath(), manager.getTestFileName());
     final GeneralCommandLine commandLine = new GeneralCommandLine();
     commandLine.withWorkDirectory(myTaskDir.getPath());
     final Map<String, String> env = commandLine.getEnvironment();
@@ -38,8 +46,6 @@ public class PyStudyTestRunner extends StudyTestRunner {
       if (pythonPath != null) {
         commandLine.setExePath(pythonPath);
         commandLine.addParameter(testRunner.getPath());
-        final Course course = StudyTaskManager.getInstance(project).getCourse();
-        assert course != null;
         File resourceFile = new File(course.getCourseDirectory());
         commandLine.addParameter(resourceFile.getPath());
         commandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
index f15d2598fae954155bd4471d97b526b8e29e8c40..3aee001aecbc056e5d4ca6ee4c8ce5affbcbd287 100644 (file)
@@ -38,7 +38,7 @@
   </project-components>
 
   <extensionPoints>
-    <extensionPoint qualifiedName="Edu.StudyLanguageManager" beanClass="com.intellij.lang.LanguageExtensionPoint">
+    <extensionPoint qualifiedName="Edu.CCLanguageManager" beanClass="com.intellij.lang.LanguageExtensionPoint">
     </extensionPoint>
   </extensionPoints>
 
similarity index 78%
rename from python/educational/course-creator/src/com/jetbrains/edu/coursecreator/StudyLanguageManager.java
rename to python/educational/course-creator/src/com/jetbrains/edu/coursecreator/CCLanguageManager.java
index cce016575e09d70ab41c0299814c974a425a33dd..98029f4dbb8141ccffb8c330d497d832d8ba9b53 100644 (file)
@@ -8,8 +8,8 @@ import org.jetbrains.annotations.Nullable;
 
 import java.io.File;
 
-public interface StudyLanguageManager {
-  LanguageExtension<StudyLanguageManager> INSTANCE = new LanguageExtension<StudyLanguageManager>("Edu.StudyLanguageManager");
+public interface CCLanguageManager {
+  LanguageExtension<CCLanguageManager> INSTANCE = new LanguageExtension<CCLanguageManager>("Edu.CCLanguageManager");
 
   @Nullable
   String getDefaultTaskFileExtension();
index d453a59c92ae661d69ba96157eafdfe7a1b794cb..f5ca9378eebf4c04e3d1c1c4f2181857e16eb3db 100644 (file)
@@ -61,8 +61,8 @@ public class CCUtils {
   }
 
   @Nullable
-  public static StudyLanguageManager getStudyLanguageManager(@NotNull final Course course) {
+  public static CCLanguageManager getStudyLanguageManager(@NotNull final Course course) {
     Language language = Language.findLanguageByID(course.getLanguage());
-    return language == null ? null :  StudyLanguageManager.INSTANCE.forLanguage(language);
+    return language == null ? null :  CCLanguageManager.INSTANCE.forLanguage(language);
   }
 }
index ac774b3659e7419407d899a658213adc7c2980f7..3b8768286c99ab0ba43d2562505c86754a98d3bc 100644 (file)
@@ -22,7 +22,7 @@ import com.intellij.util.io.ZipUtil;
 import com.jetbrains.edu.coursecreator.CCDocumentListener;
 import com.jetbrains.edu.coursecreator.CCProjectService;
 import com.jetbrains.edu.coursecreator.CCUtils;
-import com.jetbrains.edu.coursecreator.StudyLanguageManager;
+import com.jetbrains.edu.coursecreator.CCLanguageManager;
 import com.jetbrains.edu.coursecreator.format.*;
 import com.jetbrains.edu.coursecreator.ui.CreateCourseArchiveDialog;
 import org.jetbrains.annotations.NotNull;
@@ -210,7 +210,7 @@ public class CCCreateCourseArchive extends DumbAwareAction {
     try {
       File zipFile = new File(myLocationDir, myZipName + ".zip");
       ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
-      final StudyLanguageManager manager = CCUtils.getStudyLanguageManager(course);
+      final CCLanguageManager manager = CCUtils.getStudyLanguageManager(course);
       for (Map.Entry<String, Lesson> entry : lessons.entrySet()) {
         final VirtualFile lessonDir = baseDir.findChild(entry.getKey());
         if (lessonDir == null) continue;
index 538fc76b59f2117659b4fe54d593affae30cc430..85b2a6d5b19d2e997f8cab8390db158fb82b69c4 100644 (file)
@@ -7,7 +7,6 @@ import com.intellij.ide.fileTemplates.FileTemplateUtil;
 import com.intellij.ide.util.DirectoryChooserUtil;
 import com.intellij.ide.util.DirectoryUtil;
 import com.intellij.ide.util.EditorHelper;
-import com.intellij.lang.Language;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.LangDataKeys;
@@ -23,9 +22,9 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
 import com.intellij.util.PlatformIcons;
+import com.jetbrains.edu.coursecreator.CCLanguageManager;
 import com.jetbrains.edu.coursecreator.CCProjectService;
 import com.jetbrains.edu.coursecreator.CCUtils;
-import com.jetbrains.edu.coursecreator.StudyLanguageManager;
 import com.jetbrains.edu.coursecreator.format.Course;
 import com.jetbrains.edu.coursecreator.format.Lesson;
 import com.jetbrains.edu.coursecreator.format.Task;
@@ -74,22 +73,21 @@ public class CCCreateTask extends DumbAwareAction {
       public void run() {
         final PsiDirectory taskDirectory = DirectoryUtil.createSubdirectories("task" + (size + 1), lessonDir, "\\/");
         if (taskDirectory != null) {
-          Language language = Language.findLanguageByID(course.getLanguage());
-          if (language == null) {
+          CCLanguageManager manager = CCUtils.getStudyLanguageManager(course);
+          if (manager == null) {
             return;
           }
-          final StudyLanguageManager studyLanguageManager = StudyLanguageManager.INSTANCE.forLanguage(language);
-          CCUtils.markDirAsSourceRoot(taskDirectory.getVirtualFile(), project);
 
+          CCUtils.markDirAsSourceRoot(taskDirectory.getVirtualFile(), project);
           final Task task = new Task(taskName);
           task.setIndex(size + 1);
           lesson.addTask(task, taskDirectory);
 
-          createFromTemplateAndOpen(taskDirectory, studyLanguageManager.getTestsTemplate(project), view);
+          createFromTemplateAndOpen(taskDirectory, manager.getTestsTemplate(project), view);
           createFromTemplateAndOpen(taskDirectory, FileTemplateManager.getInstance(project).getInternalTemplate("task.html"), view);
-          String defaultExtension = studyLanguageManager.getDefaultTaskFileExtension();
+          String defaultExtension = manager.getDefaultTaskFileExtension();
           if (defaultExtension != null) {
-            FileTemplate taskFileTemplate = studyLanguageManager.getTaskFileTemplateForExtension(project,
+            FileTemplate taskFileTemplate = manager.getTaskFileTemplateForExtension(project,
                                                                                           defaultExtension);
             createFromTemplateAndOpen(taskDirectory, taskFileTemplate, view);
             if (taskFileTemplate != null) {
index 374a141fa06756724a5aa2b4696b87a74423c3e5..5483b1ef8eaaddf24f31190c606c973e9547f541 100644 (file)
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
 import com.jetbrains.edu.coursecreator.CCProjectService;
 import com.jetbrains.edu.coursecreator.CCUtils;
-import com.jetbrains.edu.coursecreator.StudyLanguageManager;
+import com.jetbrains.edu.coursecreator.CCLanguageManager;
 import com.jetbrains.edu.coursecreator.format.Course;
 import com.jetbrains.edu.coursecreator.format.Lesson;
 import com.jetbrains.edu.coursecreator.format.Task;
@@ -68,15 +68,15 @@ public class CCCreateTaskFile extends DumbAwareAction {
     if (type == null) {
       return;
     }
-    final StudyLanguageManager studyLanguageManager = CCUtils.getStudyLanguageManager(course);
-    if (studyLanguageManager == null) {
+    final CCLanguageManager CCLanguageManager = CCUtils.getStudyLanguageManager(course);
+    if (CCLanguageManager == null) {
       return;
     }
     final String extension = type.getDefaultExtension();
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       @Override
       public void run() {
-        final FileTemplate taskTemplate = studyLanguageManager.getTaskFileTemplateForExtension(project, extension);
+        final FileTemplate taskTemplate = CCLanguageManager.getTaskFileTemplateForExtension(project, extension);
         final String answerFileName = taskFileName + ".answer." + extension;
         try {
           if (taskTemplate == null) {
index bb4187026691e1ddd66637dfa010ae937c35a4d5..451c39eb54ade1141566d0127334113db9580f49 100644 (file)
@@ -36,7 +36,7 @@ import com.intellij.psi.PsiFile;
 import com.intellij.util.containers.HashMap;
 import com.jetbrains.edu.coursecreator.CCProjectService;
 import com.jetbrains.edu.coursecreator.CCUtils;
-import com.jetbrains.edu.coursecreator.StudyLanguageManager;
+import com.jetbrains.edu.coursecreator.CCLanguageManager;
 import com.jetbrains.edu.coursecreator.format.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -133,7 +133,7 @@ public abstract class CCRunTestsAction extends AnAction {
         clearTestEnvironment(taskDir, project);
         for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
           final String name = entry.getKey();
-          StudyLanguageManager manager = CCUtils.getStudyLanguageManager(course);
+          CCLanguageManager manager = CCUtils.getStudyLanguageManager(course);
           if (manager == null) {
             return;
           }
index 6c79854aaba8cda4e80c46de5d8a58e99a6f3b7d..9f3afb1b32c04688ee2a8286695e40a3b9ff58af 100644 (file)
@@ -9,7 +9,7 @@ import com.intellij.ui.DoubleClickListener;
 import com.intellij.ui.ListScrollingUtil;
 import com.intellij.ui.components.JBList;
 import com.jetbrains.edu.coursecreator.CCUtils;
-import com.jetbrains.edu.coursecreator.StudyLanguageManager;
+import com.jetbrains.edu.coursecreator.CCLanguageManager;
 import com.jetbrains.edu.coursecreator.format.Course;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -55,7 +55,7 @@ public class CreateTaskFileDialog extends DialogWrapper {
       }
     }.installOn(myList);
 
-    StudyLanguageManager manager = CCUtils.getStudyLanguageManager(myCourse);
+    CCLanguageManager manager = CCUtils.getStudyLanguageManager(myCourse);
     if (manager != null) {
       String extension = manager.getDefaultTaskFileExtension();
       ListScrollingUtil.selectItem(myList, FileTypeManager.getInstance().getFileTypeByExtension(extension != null ? extension : "txt"));
index 49254d96293d550b88d5d35b18570141ceda1b5e..8985e75d19540ea5fa9549379f71faaaba0af276 100644 (file)
@@ -36,6 +36,7 @@
 
   <extensionPoints>
     <extensionPoint qualifiedName="Edu.StudyExecutor" beanClass="com.intellij.lang.LanguageExtensionPoint"/>
+    <extensionPoint qualifiedName="Edu.StudyLanguageManager" beanClass="com.intellij.lang.LanguageExtensionPoint"/>
   </extensionPoints>
 
   <actions>
diff --git a/python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyLanguageManager.java b/python/educational/interactive-learning/src/com/jetbrains/edu/learning/StudyLanguageManager.java
new file mode 100644 (file)
index 0000000..429b90c
--- /dev/null
@@ -0,0 +1,17 @@
+package com.jetbrains.edu.learning;
+
+import com.intellij.lang.LanguageExtension;
+import org.jetbrains.annotations.NotNull;
+
+public interface StudyLanguageManager {
+  LanguageExtension<StudyLanguageManager> INSTANCE = new LanguageExtension<StudyLanguageManager>("Edu.StudyLanguageManager");
+
+  @NotNull
+  String getTestFileName();
+
+  @NotNull
+  String getTestHelperFileName();
+
+  @NotNull
+  String getUserTester();
+}
index 842a99ef9f1eda2db60e92fe366c5288318beaaa..0755e2a99809cb46fb9f76ec917db2e6f122d76c 100644 (file)
@@ -20,10 +20,7 @@ import org.jetbrains.annotations.NonNls;
 @NonNls
 public class StudyNames {
   public static final String TASK_HTML = "task.html";
-  public static final String TASK_TESTS = "tests.py";
   public static final String LESSON = "lesson";
-  public static final String TEST_HELPER = "test_helper.py";
-  public static final String USER_TESTER = "user_tester.py";
   public static final String LESSON_DIR = "lesson";
   public static final String TEST_TAB_NAME = "test";
   public static final String USER_TEST_INPUT = "input";
index fae6b652e35731e963b76620b3ba4a9d5f4bc75c..ff8c4f4af509474bb77278a57670e526d8d83d06 100644 (file)
@@ -152,7 +152,12 @@ public class StudyProjectGenerator {
             LOG.error("ERROR copying file " + name);
           }
         }
-        final File testsFile = new File(taskDirectory, "tests.py");
+        StudyLanguageManager languageManager = StudyUtils.getLanguageManager(course);
+        if (languageManager == null) {
+          LOG.info("Language manager is null for " + course.getLanguageById().getDisplayName());
+          return;
+        }
+        final File testsFile = new File(taskDirectory, languageManager.getTestFileName());
         FileUtil.createIfDoesntExist(testsFile);
         try {
           FileUtil.writeToFile(testsFile, task.getTestsText());
index 97e1e39a983d49f1a8570921fe33e049eb61b999..efc68ca8ba9759b36832882a1c260851b06e49a7 100644 (file)
@@ -194,20 +194,28 @@ public class StudyTaskManager implements ProjectComponent, PersistentStateCompon
     if (!resourceDirectory.exists()) {
       return;
     }
+    StudyLanguageManager manager = StudyUtils.getLanguageManager(myCourse);
+    if (manager == null) {
+      LOG.info("Study Language Manager is null for " + myCourse.getLanguageById().getDisplayName());
+      return;
+    }
     final File[] files = resourceDirectory.listFiles();
     if (files == null) return;
     for (File file : files) {
-      if (file.getName().equals(StudyNames.TEST_HELPER)) {
-        copyFile(file, new File(myProject.getBasePath(), StudyNames.TEST_HELPER));
+      String testHelper = manager.getTestHelperFileName();
+      if (file.getName().equals(testHelper)) {
+        copyFile(file, new File(myProject.getBasePath(), testHelper));
       }
       if (file.getName().startsWith(StudyNames.LESSON)) {
         final File[] tasks = file.listFiles();
         if (tasks == null) continue;
         for (File task : tasks) {
           final File taskDescr = new File(task, StudyNames.TASK_HTML);
-          final File taskTests = new File(task, StudyNames.TASK_TESTS);
+          String testFileName = manager.getTestFileName();
+          final File taskTests = new File(task, testFileName);
           copyFile(taskDescr, new File(new File(new File(myProject.getBasePath(), file.getName()), task.getName()), StudyNames.TASK_HTML));
-          copyFile(taskTests, new File(new File(new File(myProject.getBasePath(), file.getName()), task.getName()), StudyNames.TASK_TESTS));
+          copyFile(taskTests, new File(new File(new File(myProject.getBasePath(), file.getName()), task.getName()),
+                                       testFileName));
         }
       }
     }
index 585cc3da0dcc4fdd3d4f1bd412aff1ad2046b113..64f74ce7bc040fa6536771f50f9663263c9ee9d3 100644 (file)
@@ -205,7 +205,7 @@ public class StudyUtils {
 
   @Nullable
   public static Sdk findSdk(@NotNull final Task task, @NotNull final Project project) {
-    final Language language = task.getLesson().getCourse().getLanguage();
+    final Language language = task.getLesson().getCourse().getLanguageById();
     return StudyExecutor.INSTANCE.forLanguage(language).findSdk(project);
   }
 
@@ -233,13 +233,13 @@ public class StudyUtils {
 
   @NotNull
   public static StudyTestRunner getTestRunner(@NotNull final Task task, @NotNull final VirtualFile taskDir) {
-    final Language language = task.getLesson().getCourse().getLanguage();
+    final Language language = task.getLesson().getCourse().getLanguageById();
     return StudyExecutor.INSTANCE.forLanguage(language).getTestRunner(task, taskDir);
   }
 
   public static RunContentExecutor getExecutor(@NotNull final Project project, @NotNull final Task currentTask,
                                                @NotNull final ProcessHandler handler) {
-    final Language language = currentTask.getLesson().getCourse().getLanguage();
+    final Language language = currentTask.getLesson().getCourse().getLanguageById();
     return StudyExecutor.INSTANCE.forLanguage(language).getExecutor(project, handler);
   }
 
@@ -248,7 +248,7 @@ public class StudyUtils {
                                               @NotNull final String filePath,
                                               @NotNull final String sdkPath,
                                               @NotNull final Task currentTask) {
-    final Language language = currentTask.getLesson().getCourse().getLanguage();
+    final Language language = currentTask.getLesson().getCourse().getLanguageById();
     StudyExecutor.INSTANCE.forLanguage(language).setCommandLineParameters(cmd, project, filePath, sdkPath, currentTask);
   }
 
@@ -259,7 +259,7 @@ public class StudyUtils {
   }
 
   public static void showNoSdkNotification(@NotNull final Task currentTask, @NotNull final Project project) {
-    final Language language = currentTask.getLesson().getCourse().getLanguage();
+    final Language language = currentTask.getLesson().getCourse().getLanguageById();
     StudyExecutor.INSTANCE.forLanguage(language).showNoSdkNotification(project);
   }
 
@@ -274,4 +274,13 @@ public class StudyUtils {
     balloon.showInCenterOf(checkButton);
     Disposer.register(project, balloon);
   }
+
+  /**
+   * returns language manager which contains all the information about language specific file names
+   */
+  @Nullable
+  public static StudyLanguageManager getLanguageManager(@NotNull final Course course) {
+    Language language = course.getLanguageById();
+    return language == null ? null : StudyLanguageManager.INSTANCE.forLanguage(language);
+  }
 }
index 7d31dd194344d90e08e1781e173f063842e110cd..004b58399a24d07bd2a60bda27f6474ce2b06726 100644 (file)
@@ -50,7 +50,7 @@ import java.util.Map;
 public class StudyCheckAction extends DumbAwareAction {
 
   private static final Logger LOG = Logger.getInstance(StudyCheckAction.class.getName());
-  private static final String ANSWERS_POSTFIX = "_answers.py";
+  private static final String ANSWERS_POSTFIX = "_answers";
   public static final String ACTION_ID = "CheckAction";
   public static final String SHORTCUT = "ctrl alt pressed ENTER";
 
@@ -337,7 +337,7 @@ public class StudyCheckAction extends DumbAwareAction {
     VirtualFile copy = null;
     try {
 
-      copy = file.copy(this, taskDir, file.getNameWithoutExtension() + ANSWERS_POSTFIX);
+      copy = file.copy(this, taskDir, file.getNameWithoutExtension() + ANSWERS_POSTFIX + "." + file.getExtension());
       final FileDocumentManager documentManager = FileDocumentManager.getInstance();
       final Document document = documentManager.getDocument(copy);
       if (document != null) {
index 63b65733fd2db5ec7771af3948598fff71ef0a23..9bac4fd2763463f40654fdc4ecbf3faf8bdbdf21 100644 (file)
@@ -20,7 +20,6 @@ import com.jetbrains.edu.learning.StudyTestRunner;
 import com.jetbrains.edu.learning.StudyUtils;
 import org.jetbrains.annotations.NotNull;
 
-import java.awt.*;
 import java.awt.*;
 import java.io.File;
 import java.io.IOException;
@@ -30,7 +29,7 @@ import java.io.IOException;
  */
 
 public class AnswerPlaceholder implements Comparable, Stateful {
-  private static final String WINDOW_POSTFIX = "_window.py";
+  private static final String WINDOW_POSTFIX = "_window";
   private static final Logger LOG = Logger.getInstance(AnswerPlaceholder.class);
   private int line = 0;
   private int start = 0;
@@ -104,7 +103,7 @@ public class AnswerPlaceholder implements Comparable, Stateful {
         g.setColor(color);
         Point point = editor.logicalPositionToXY(editor.offsetToLogicalPosition(highlighter.getStartOffset()));
         Point pointEnd = editor.logicalPositionToXY(editor.offsetToLogicalPosition(highlighter.getEndOffset()));
-        g.drawRect(point.x, point.y - 2, (pointEnd.x - point.x), editor.getLineHeight() + 1);
+        g.drawRect(point.x, point.y, (pointEnd.x - point.x), editor.getLineHeight() + 1);
       }
     });
     editor.getCaretModel().moveToOffset(startOffset);
@@ -205,7 +204,7 @@ public class AnswerPlaceholder implements Comparable, Stateful {
 
     try {
       final VirtualFile windowCopy =
-        answerFile.copy(this, answerFile.getParent(), answerFile.getNameWithoutExtension() + myIndex + WINDOW_POSTFIX);
+        answerFile.copy(this, answerFile.getParent(), answerFile.getNameWithoutExtension() + myIndex + WINDOW_POSTFIX + "." + answerFile.getExtension());
       final FileDocumentManager documentManager = FileDocumentManager.getInstance();
       final Document windowDocument = documentManager.getDocument(windowCopy);
       if (windowDocument != null) {
index 4dd9091837b2cbd6a57932e1df0ea75c4e45b77f..b3241f3ea8196d6371fa498002a93c087d27a3c4 100644 (file)
@@ -113,10 +113,13 @@ public class Course {
     myUpToDate = upToDate;
   }
 
-  public Language getLanguage() {
+  public Language getLanguageById() {
     return Language.findLanguageByID(myLanguage);
   }
 
+  public String getLanguage() {
+    return myLanguage;
+  }
   public void setLanguage(@NotNull final String language) {
     myLanguage = language;
   }
index c488c35d4dcf12c478e062b354d12ccad986cfa1..a6e358ff7b6d7f3e0ffbc6d7032f3f31212714ef 100644 (file)
@@ -21,7 +21,6 @@ import java.util.Map;
  */
 public class Task implements Stateful {
   public static final String TASK_DIR = "task";
-  private static final String ourTestFile = "tests.py";
   private String name;
   private String text;
   private String testsText;
@@ -76,10 +75,6 @@ public class Task implements Stateful {
     return userTests;
   }
 
-  public String getTestFile() {
-    return ourTestFile;
-  }
-
   public String getText() {
     return text;
   }