EDU-523 Lost automatic code inspection warnings
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Mon, 1 Feb 2016 15:59:09 +0000 (18:59 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Mon, 1 Feb 2016 16:00:42 +0000 (19:00 +0300)
EP was registered in wrong plugin.xml

python/educational-python/course-creator-python/src/com/jetbrains/edu/coursecreator/PyCCRunTests.java
python/educational-python/resources/META-INF/plugin.xml
python/educational-python/src/META-INF/PyCharmEduPlugin.xml
python/educational-python/src/com/jetbrains/python/edu/PyDebugCurrentFile.java
python/educational-python/src/com/jetbrains/python/edu/PyEduAddParametersAction.java
python/educational-python/src/com/jetbrains/python/edu/PyExecuteFileExtensionPoint.java
python/educational-python/src/com/jetbrains/python/edu/PyExecuteFileLineMarkerProvider.java
python/educational-python/student-python/resources/META-INF/plugin.xml

index bbd9fe1e40a6591e712173040dfc6411947dbf24..5af7f8b164e89eabdbe3c8714eea6c7115dc69aa 100644 (file)
@@ -1,6 +1,7 @@
 package com.jetbrains.edu.coursecreator;
 
 import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.project.Project;
 import com.jetbrains.edu.coursecreator.actions.PyCCRunTestsAction;
 import com.jetbrains.python.edu.PyExecuteFileExtensionPoint;
 import org.jetbrains.annotations.NotNull;
@@ -12,4 +13,8 @@ public class PyCCRunTests implements PyExecuteFileExtensionPoint {
     return new PyCCRunTestsAction();
   }
 
+  @Override
+  public boolean accept(Project project) {
+    return CCProjectService.getInstance(project).getCourse() != null;
+  }
 }
\ No newline at end of file
index 9ac09a537219e78899d738c905f00078d7826895..1c93e40ca43457f1e4b3a0847a64de77e35050a4 100644 (file)
       ]]>
   </change-notes>
 
-  <!-- please see http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
-       on how to target different products -->
-
   <depends>com.intellij.modules.lang</depends>
 
+  <extensionPoints>
+    <extensionPoint qualifiedName="Edu.executeFile" interface="com.jetbrains.python.edu.PyExecuteFileExtensionPoint"/>
+  </extensionPoints>
+
+  <extensions defaultExtensionNs="com.intellij">
+    <codeInsight.lineMarkerProvider language="Python" implementationClass="com.jetbrains.python.edu.PyExecuteFileLineMarkerProvider"/>
+  </extensions>
+
+  <extensions defaultExtensionNs="Edu">
+    <executeFile implementation="com.jetbrains.python.edu.PyEduAddParametersAction" order="last"/>
+    <executeFile implementation="com.jetbrains.python.edu.PyDebugCurrentFile"/>
+
+  </extensions>
+
   <project-components>
 
   </project-components>
index 29ae11e1ca4e67abc982ef8670a96071639a74f7..a8aa6f5787632886a28484b31c187a2a5f757ae5 100644 (file)
     </component>
   </application-components>
 
-  <extensionPoints>
-    <extensionPoint qualifiedName="Edu.executeFile" interface="com.jetbrains.python.edu.PyExecuteFileExtensionPoint"/>
-  </extensionPoints>
-
   <extensions defaultExtensionNs="com.intellij">
       <programRunner implementation="com.jetbrains.python.edu.debugger.PyEduDebugRunner"/>
       <executor implementation="com.jetbrains.python.edu.debugger.PyEduDebugExecutor" order="first,after run"/>
       <consoleInputFilterProvider implementation="com.jetbrains.python.edu.debugger.PyEduConsoleInputFilterProvider"/>
   </extensions>
-  <extensions defaultExtensionNs="Edu">
-    <executeFile implementation="com.jetbrains.python.edu.PyEduAddParametersAction" order="last"/>
-    <executeFile implementation="com.jetbrains.python.edu.PyDebugCurrentFile"/>
-
-  </extensions>
 
 </idea-plugin>
index f9f9a6883e5efb167f4080f660f51fe7c4963e2b..227f132f31596e76f911db0d58745c0a3fcd0412 100644 (file)
@@ -2,6 +2,8 @@ package com.jetbrains.python.edu;
 
 import com.intellij.execution.actions.RunContextAction;
 import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.project.Project;
+import com.intellij.util.PlatformUtils;
 import com.jetbrains.python.edu.debugger.PyEduDebugExecutor;
 import org.jetbrains.annotations.Nullable;
 
@@ -10,7 +12,15 @@ public class PyDebugCurrentFile implements PyExecuteFileExtensionPoint {
   @Nullable
   @Override
   public AnAction getRunAction() {
+    if (!PlatformUtils.isPyCharmEducational()) {
+      return null;
+    }
     return new RunContextAction(PyEduDebugExecutor.getInstance());
   }
+
+  @Override
+  public boolean accept(Project project) {
+    return PlatformUtils.isPyCharmEducational();
+  }
 }
 
index 50189cc5dd105801fcf2f4d399038f3cded72ee7..9d8b2fd94b38304c26d64fbcdf58c419316a9b0b 100644 (file)
@@ -3,15 +3,23 @@ package com.jetbrains.python.edu;
 import com.intellij.execution.actions.EditRunConfigurationsAction;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
-import org.jetbrains.annotations.NotNull;
+import com.intellij.openapi.project.Project;
+import com.intellij.util.PlatformUtils;
+import org.jetbrains.annotations.Nullable;
 
 public class PyEduAddParametersAction implements PyExecuteFileExtensionPoint {
-  @NotNull
+
+  @Nullable
   @Override
   public AnAction getRunAction() {
     return new AddParametersAction();
   }
 
+  @Override
+  public boolean accept(Project project) {
+    return PlatformUtils.isPyCharmEducational();
+  }
+
   private static class AddParametersAction extends EditRunConfigurationsAction {
     @Override
     public void update(AnActionEvent e) {
index d0c54fe86b3b8d8eaf3757e2f3a61f0530ea2286..20a507fe48428da91dd73c3771a311e717ae0c1e 100644 (file)
@@ -17,6 +17,7 @@ package com.jetbrains.python.edu;
 
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
 import org.jetbrains.annotations.Nullable;
 
 public interface PyExecuteFileExtensionPoint {
@@ -26,4 +27,5 @@ public interface PyExecuteFileExtensionPoint {
   @Nullable
   AnAction getRunAction();
 
+  boolean accept(Project project);
 }
index e037bf944e833863ffb37c31b3e505f6df4026d2..3bdc9f22bc3f5b631a40f11848d61756529ab464 100644 (file)
@@ -13,9 +13,12 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.markup.GutterIconRenderer;
 import com.intellij.psi.PsiElement;
 import com.intellij.util.Function;
+import com.intellij.util.PlatformUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -36,12 +39,34 @@ public class PyExecuteFileLineMarkerProvider implements LineMarkerProvider {
     }
     PsiElement file = elements.get(0).getContainingFile();
     final RunContextAction runAction = new RunContextAction(DefaultRunExecutor.getRunExecutorInstance());
+    final PyExecuteFileExtensionPoint[] extensions =
+      ApplicationManager.getApplication().getExtensions(PyExecuteFileExtensionPoint.EP_NAME);
+
+    final List<AnAction> actions = new ArrayList<AnAction>();
+    final DefaultActionGroup group = new DefaultActionGroup();
+    if (PlatformUtils.isPyCharmEducational()) {
+      group.add(runAction);
+    }
+    for (PyExecuteFileExtensionPoint extension : extensions) {
+      AnAction action = extension.getRunAction();
+      if (action != null && extension.accept(file.getProject())) {
+        actions.add(action);
+        group.add(action);
+      }
+    }
+
+    if (actions.isEmpty() && !PlatformUtils.isPyCharmEducational()) {
+      return;
+    }
+
+    Icon icon = PlatformUtils.isPyCharmEducational() ? AllIcons.Actions.Execute : actions.get(0).getTemplatePresentation().getIcon();
     final LineMarkerInfo<PsiElement> markerInfo = new LineMarkerInfo<PsiElement>(
-      file, file.getTextRange(), AllIcons.Actions.Execute, Pass.UPDATE_OVERRIDEN_MARKERS,
+      file, file.getTextRange(), icon, Pass.UPDATE_OVERRIDEN_MARKERS,
       new Function<PsiElement, String>() {
         @Override
         public String fun(PsiElement e) {
-          return "Execute '" + e.getContainingFile().getName() + "'";
+          String text = "Execute '" + e.getContainingFile().getName() + "'";
+          return PlatformUtils.isPyCharmEducational() ? text : actions.get(0).getTemplatePresentation().getText();
         }
       }, null,
       GutterIconRenderer.Alignment.RIGHT) {
@@ -51,22 +76,17 @@ public class PyExecuteFileLineMarkerProvider implements LineMarkerProvider {
         return new LineMarkerGutterIconRenderer<PsiElement>(this) {
           @Override
           public AnAction getClickAction() {
-            return runAction;
+            return PlatformUtils.isPyCharmEducational() ? runAction : actions.get(0);
           }
 
           @Nullable
           @Override
           public ActionGroup getPopupMenuActions() {
-            final DefaultActionGroup group = new DefaultActionGroup();
-            group.add(runAction);
-            final PyExecuteFileExtensionPoint[] extensions =
-              ApplicationManager.getApplication().getExtensions(PyExecuteFileExtensionPoint.EP_NAME);
-            for (PyExecuteFileExtensionPoint extension : extensions) {
-              final AnAction action = extension.getRunAction();
-              if (action == null) {
-                continue;
-              }
-              group.add(action);
+            if (!PlatformUtils.isPyCharmEducational() && actions.isEmpty()) {
+              return null;
+            }
+            if (actions.size() == 1) {
+              return null;
             }
             return group;
           }
index 6bb96a57f776830bc45d189bb241139becd93336..8638261999fb8c76cfec54b120adfb7b0898c6e5 100644 (file)
@@ -23,7 +23,6 @@
 
   <extensions defaultExtensionNs="com.intellij">
     <directoryProjectGenerator implementation="com.jetbrains.edu.learning.PyStudyDirectoryProjectGenerator"/>
-    <codeInsight.lineMarkerProvider language="Python" implementationClass="com.jetbrains.python.edu.PyExecuteFileLineMarkerProvider"/>
   </extensions>
   <extensions defaultExtensionNs="Pythonid">
     <inspectionExtension implementation="com.jetbrains.edu.learning.highlighting.PyStudyInspectionExtension"/>