EA-48679 - UOE: MavenServerEmbedderImpl.evaluateEffectivePom phpstorm/130.1593
authorSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Mon, 12 Aug 2013 09:44:29 +0000 (13:44 +0400)
committerSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Mon, 12 Aug 2013 09:44:55 +0000 (13:44 +0400)
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenShowEffectivePom.java

index 5346407aa42bd3201af092edca969079f0488020..5564984a835d3622e22c420ddd22b36a239a72ac 100644 (file)
@@ -35,8 +35,8 @@ import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.util.Alarm;
-import com.intellij.util.Consumer;
 import com.intellij.util.EventDispatcher;
+import com.intellij.util.NullableConsumer;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.ui.UIUtil;
 import com.intellij.util.ui.update.Update;
@@ -735,7 +735,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
     });
   }
 
-  public void evaluateEffectivePom(@NotNull final MavenProject mavenProject, @NotNull final Consumer<String> consumer) {
+  public void evaluateEffectivePom(@NotNull final MavenProject mavenProject, @NotNull final NullableConsumer<String> consumer) {
     runWhenFullyOpen(new Runnable() {
       @Override
       public void run() {
@@ -757,9 +757,14 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
                                                new MavenProjectsTree.EmbedderTask() {
                                                  @Override
                                                  public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
-                                                   String res =
-                                                     embedder.evaluateEffectivePom(mavenProject.getFile(), mavenProject.getActivatedProfilesIds());
-                                                   consumer.consume(res);
+                                                   try {
+                                                     String res =
+                                                       embedder.evaluateEffectivePom(mavenProject.getFile(), mavenProject.getActivatedProfilesIds());
+                                                     consumer.consume(res);
+                                                   }
+                                                   catch (UnsupportedOperationException e) {
+                                                     consumer.consume(null); // null means UnsupportedOperationException
+                                                   }
                                                  }
                                                });
           }
index 1c1a39ceca80e04aea7a2800bba80484c7389515..55e9f52fe5518cc1e6e510ab9b61b0f30ad8fa45 100644 (file)
@@ -13,7 +13,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileFactory;
-import com.intellij.util.Consumer;
+import com.intellij.util.NullableConsumer;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.idea.maven.project.MavenProject;
@@ -51,13 +51,13 @@ public class MavenShowEffectivePom extends AnAction implements DumbAware {
                      }).notify(project);
   }
 
-  public static void actionPerformed(@NotNull final Project project, @NotNull VirtualFile file) {
+  public static void actionPerformed(@NotNull final Project project, @NotNull final VirtualFile file) {
     final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
 
     final MavenProject mavenProject = manager.findProject(file);
     assert mavenProject != null;
 
-    manager.evaluateEffectivePom(mavenProject, new Consumer<String>() {
+    manager.evaluateEffectivePom(mavenProject, new NullableConsumer<String>() {
       @Override
       public void consume(final String s) {
         ApplicationManager.getApplication().invokeLater(new Runnable() {
@@ -65,6 +65,11 @@ public class MavenShowEffectivePom extends AnAction implements DumbAware {
           public void run() {
             if (project.isDisposed()) return;
 
+            if (s == null) { // null means UnsupportedOperationException
+              showUnsupportedNotification(project, file);
+              return;
+            }
+
             String fileName = mavenProject.getMavenId().getArtifactId() + "-effective-pom.xml";
             PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(fileName, XMLLanguage.INSTANCE, s);
             try {