IDEA-136868 AE at com.intellij.codeInsight.daemon.impl.analysis.IncreaseLanguageLevel...
authorpeter <peter@jetbrains.com>
Tue, 24 Feb 2015 08:34:04 +0000 (09:34 +0100)
committerpeter <peter@jetbrains.com>
Tue, 24 Feb 2015 09:21:40 +0000 (10:21 +0100)
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java

index 87867565f63adf2c17951d0af39fa99d325cf338..466903efaf3000c29fea869d5cf515861b0e2601 100644 (file)
@@ -86,20 +86,20 @@ public class IncreaseLanguageLevelFix implements IntentionAction {
     LOG.assertTrue(virtualFile != null);
     final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
     final LanguageLevel moduleLevel = module == null ? null : LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
-    if (moduleLevel != null && isLanguageLevelAcceptable(project, module, myLevel)) {
-      final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
-      rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(myLevel);
-      ApplicationManager.getApplication().runWriteAction(new Runnable() {
-        @Override
-        public void run() {
+    ApplicationManager.getApplication().runWriteAction(new Runnable() {
+      @Override
+      public void run() {
+        if (moduleLevel != null && isLanguageLevelAcceptable(project, module, myLevel)) {
+          final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
+          rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(myLevel);
           rootModel.commit();
         }
-      });
-    }
-    else {
-      LanguageLevelProjectExtension.getInstance(project).setLanguageLevel(myLevel);
-      ProjectRootManagerEx.getInstanceEx(project).makeRootsChange(EmptyRunnable.INSTANCE, false, true);
-    }
+        else {
+          LanguageLevelProjectExtension.getInstance(project).setLanguageLevel(myLevel);
+          ProjectRootManagerEx.getInstanceEx(project).makeRootsChange(EmptyRunnable.INSTANCE, false, true);
+        }
+      }
+    });
   }
 
   @Nullable