Merge branch 'master' of git@git.labs.intellij.net:idea/community
authorKirill Kalishev <kirill.kalishev@jetbrains.com>
Fri, 27 Nov 2009 12:46:59 +0000 (15:46 +0300)
committerKirill Kalishev <kirill.kalishev@jetbrains.com>
Fri, 27 Nov 2009 12:46:59 +0000 (15:46 +0300)
125 files changed:
build.txt
build/scripts/dist.gant
java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java
java/debugger/impl/src/com/intellij/debugger/actions/CustomizeContextViewAction.java
java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurationType.java
java/execution/impl/src/com/intellij/execution/junit2/info/MethodLocation.java
java/idea-ui/src/com/intellij/facet/impl/ui/facetType/FacetTypeEditor.java
java/idea-ui/src/com/intellij/ide/util/projectWizard/ExistingModuleLoader.java
java/idea-ui/src/com/intellij/openapi/project/impl/IdeaProjectManagerImpl.java
java/idea-ui/src/com/intellij/openapi/projectRoots/ui/SdkEditor.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java
java/java-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassToInnerProcessor.java
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesProcessor.java
java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java
java/java-impl/src/com/intellij/refactoring/util/RefactoringConflictsUtil.java
java/java-impl/src/com/intellij/slicer/SliceUtil.java
java/java-tests/testData/refactoring/pushDown/usagesInXml/before/a/A.form [new file with mode: 0644]
java/java-tests/testData/refactoring/pushDown/usagesInXml/before/a/A.java [new file with mode: 0644]
java/java-tests/testData/refactoring/pushDown/usagesInXml/before/b/B.java [new file with mode: 0644]
java/java-tests/testData/refactoring/renameLocal/RenameInPlaceQualifyFieldReference.java [new file with mode: 0644]
java/java-tests/testData/refactoring/renameLocal/RenameInPlaceQualifyFieldReference_after.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/PushDownMultifileTest.java [moved from java/java-tests/testSrc/com/intellij/refactoring/PushDownImportsTest.java with 62% similarity]
java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java
native/breakgen/breakgen.sln [new file with mode: 0644]
native/breakgen/breakgen.vcproj [new file with mode: 0644]
platform/lang-api/src/com/intellij/codeInsight/daemon/HighlightDisplayKey.java
platform/lang-api/src/com/intellij/execution/Location.java
platform/lang-api/src/com/intellij/execution/PsiLocation.java
platform/lang-api/src/com/intellij/psi/impl/include/FileIncludeManager.java
platform/lang-impl/src/com/intellij/codeEditor/printing/PrintDialog.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/NavigationUtil.java
platform/lang-impl/src/com/intellij/codeInspection/InspectionApplication.java
platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
platform/lang-impl/src/com/intellij/conversion/ConversionResult.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/conversion/ConversionService.java
platform/lang-impl/src/com/intellij/conversion/ProjectConverter.java
platform/lang-impl/src/com/intellij/conversion/impl/ConversionResultImpl.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/conversion/impl/ConversionRunner.java
platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java
platform/lang-impl/src/com/intellij/execution/actions/ConfigurationContext.java
platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
platform/lang-impl/src/com/intellij/execution/impl/TypeTemplatesConfigurable.java
platform/lang-impl/src/com/intellij/execution/junit/RuntimeConfigurationProducer.java
platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java
platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java
platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiFactoryImpl.java
platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java
platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java
platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.java
platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java
platform/lang-impl/src/com/intellij/ide/projectView/BaseProjectTreeBuilder.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractPsiBasedNode.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleListNode.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/StructureViewModuleNode.java
platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java
platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java
platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java
platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java
platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeManagerImpl.java
platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeProvider.java
platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/ResolveCache.java
platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java
platform/platform-api/src/com/intellij/openapi/options/UnnamedConfigurableGroup.java
platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
platform/platform-impl/src/com/intellij/openapi/command/impl/EditorChangeAction.java
platform/platform-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/FileBasedStorage.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/XmlElementStorage.java
platform/platform-impl/src/com/intellij/openapi/options/TabbedConfigurable.java
platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java
platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java
platform/platform-impl/src/com/intellij/ui/EditorComboBox.java
platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java
platform/platform-impl/src/com/intellij/ui/TabbedPaneWrapper.java
platform/platform-impl/src/com/intellij/ui/content/TabbedPaneContentUI.java
platform/platform-resources-en/src/misc/registry.properties
platform/platform-resources/src/idea/Keymap_Default.xml
platform/util/src/com/intellij/openapi/util/BuildNumber.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/EditAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleChangeListBrowser.java
platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
platform/vcs-impl/src/com/intellij/openapi/vcs/ex/Range.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsFileStatusProvider.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsConfigurationDialogFactory.java
plugins/IntelliLang/src/LanguageInjectionConfiguration.xml
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/Settings.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/SettingsUI.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/JavaLanguageInjectionSupport.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/xml/XmlLanguageInjectionSupport.java
plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/AntElementFactory.java
plugins/copyright/src/com/maddyhome/idea/copyright/CopyrightManager.java
plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringActionHandlerImpl.java
plugins/groovy/src/META-INF/plugin.xml
plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyInjector.java [deleted file]
plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/IndexedExpressionConversionIntention.java
plugins/junit/src/com/intellij/execution/junit/JUnitConfigurationType.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java
plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationType.java
plugins/ui-designer/src/com/intellij/uiDesigner/actions/ShowJavadocAction.java
plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java
plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormEditorErrorCollector.java
resources/src/META-INF/IdeaPlugin.xml
xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
xml/impl/src/com/intellij/codeInspection/htmlInspections/AddCustomTagOrAttributeIntentionAction.java
xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java

index b478d314c4c569cb84417ccc78daf1bf3d5a926c..db948d0cd46e831ac82fb6eb17d1f891a6a054df 100644 (file)
--- a/build.txt
+++ b/build.txt
@@ -1 +1 @@
-90.SNAPSHOT
+92.SNAPSHOT
index 730f810dc6d617db5ab699deb276177481df3a77..a011295fb3457ce96cad1d2de571ec7a75042e8e 100644 (file)
@@ -71,7 +71,7 @@ target('default': 'The default target') {
           version: "Maia",
           system_selector: "IntelliJIdeaCE90",
           jdk_req: "1.6*",
-          vmoptions: "-Xms32m -Xmx256m -XX:MaxPermSize=150m -ea",
+          vmoptions: "-Xms128m -Xmx512m -XX:MaxPermSize=250m -ea",
           home, out)
 }
 
index 9cfbf27ec0c5f71ebc53a1704acc706c8876a2e8..30816ea692995671dde2d850a65ce2d55a021ac8 100644 (file)
@@ -61,6 +61,7 @@ import com.intellij.openapi.ui.MessageType;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -103,10 +104,11 @@ public class CompileDriver {
   private final Map<Module, String> myModuleOutputPaths = new HashMap<Module, String>();
   private final Map<Module, String> myModuleTestOutputPaths = new HashMap<Module, String>();
 
-  @NonNls private static final String VERSION_FILE_NAME = "version.dat";
-  @NonNls private static final String LOCK_FILE_NAME = "in_progress.dat";
+  private static final String VERSION_FILE_NAME = "version.dat";
+  private static final String LOCK_FILE_NAME = "in_progress.dat";
 
-  @NonNls private static final boolean GENERATE_CLASSPATH_INDEX = "true".equals(System.getProperty("generate.classpath.index"));
+  private static final boolean GENERATE_CLASSPATH_INDEX = "true".equals(System.getProperty("generate.classpath.index"));
+  private static final String PROP_PERFORM_INITIAL_REFRESH = "compiler.perform.outputs.refresh.on.start";
 
   private static final FileProcessingCompilerAdapterFactory FILE_PROCESSING_COMPILER_ADAPTER_FACTORY = new FileProcessingCompilerAdapterFactory() {
     public FileProcessingCompilerAdapter create(CompileContext context, FileProcessingCompiler compiler) {
@@ -616,76 +618,78 @@ public class CompileDriver {
         return ExitStatus.ERRORS;
       }
 
-      final long refreshStart = System.currentTimeMillis();
-
-      // need this to make sure the VFS is built
       boolean needRecalcOutputDirs = false;
-      //final List<VirtualFile> outputsToRefresh = new ArrayList<VirtualFile>();
+      if (Registry.is(PROP_PERFORM_INITIAL_REFRESH)) {
+        final long refreshStart = System.currentTimeMillis();
 
-      final VirtualFile[] all = context.getAllOutputDirectories();
+        // need this to make sure the VFS is built
+        //final List<VirtualFile> outputsToRefresh = new ArrayList<VirtualFile>();
 
-      final ProgressIndicator progressIndicator = context.getProgressIndicator();
+        final VirtualFile[] all = context.getAllOutputDirectories();
 
-      final int totalCount = all.length + myGenerationCompilerModuleToOutputDirMap.size() * 2;
-      final CountDownLatch latch = new CountDownLatch(totalCount);
-      final Runnable decCount = new Runnable() {
-        public void run() {
-          latch.countDown();
-          progressIndicator.setFraction(((double)(totalCount - latch.getCount())) / totalCount);
-        }
-      };
-      progressIndicator.pushState();
-      progressIndicator.setText("Inspecting output directories...");
-      final boolean asyncMode = !ApplicationManager.getApplication().isDispatchThread(); // must not lock awt thread with latch.await()
-      try {
-        for (VirtualFile output : all) {
-          if (output.isValid()) {
-            walkChildren(output, context);
+        final ProgressIndicator progressIndicator = context.getProgressIndicator();
+
+        final int totalCount = all.length + myGenerationCompilerModuleToOutputDirMap.size() * 2;
+        final CountDownLatch latch = new CountDownLatch(totalCount);
+        final Runnable decCount = new Runnable() {
+          public void run() {
+            latch.countDown();
+            progressIndicator.setFraction(((double)(totalCount - latch.getCount())) / totalCount);
           }
-          else {
-            needRecalcOutputDirs = true;
-            final File file = new File(output.getPath());
-            if (!file.exists()) {
-              final boolean created = file.mkdirs();
-              if (!created) {
-                context.addMessage(CompilerMessageCategory.ERROR, "Failed to create output directory " + file.getPath(), null, 0, 0);
+        };
+        progressIndicator.pushState();
+        progressIndicator.setText("Inspecting output directories...");
+        final boolean asyncMode = !ApplicationManager.getApplication().isDispatchThread(); // must not lock awt thread with latch.await()
+        try {
+          for (VirtualFile output : all) {
+            if (output.isValid()) {
+              walkChildren(output, context);
+            }
+            else {
+              needRecalcOutputDirs = true;
+              final File file = new File(output.getPath());
+              if (!file.exists()) {
+                final boolean created = file.mkdirs();
+                if (!created) {
+                  context.addMessage(CompilerMessageCategory.ERROR, "Failed to create output directory " + file.getPath(), null, 0, 0);
+                  return ExitStatus.ERRORS;
+                }
+              }
+              output = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
+              if (output == null) {
+                context.addMessage(CompilerMessageCategory.ERROR, "Failed to locate output directory " + file.getPath(), null, 0, 0);
                 return ExitStatus.ERRORS;
               }
             }
-            output = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
-            if (output == null) {
-              context.addMessage(CompilerMessageCategory.ERROR, "Failed to locate output directory " + file.getPath(), null, 0, 0);
-              return ExitStatus.ERRORS;
-            }
+            output.refresh(asyncMode, true, decCount);
+            //outputsToRefresh.add(output);
+          }
+          for (Pair<IntermediateOutputCompiler, Module> pair : myGenerationCompilerModuleToOutputDirMap.keySet()) {
+            final Pair<VirtualFile, VirtualFile> generated = myGenerationCompilerModuleToOutputDirMap.get(pair);
+            walkChildren(generated.getFirst(), context);
+            //outputsToRefresh.add(generated.getFirst());
+            generated.getFirst().refresh(asyncMode, true, decCount);
+            walkChildren(generated.getSecond(), context);
+            //outputsToRefresh.add(generated.getSecond());
+            generated.getSecond().refresh(asyncMode, true, decCount);
           }
-          output.refresh(asyncMode, true, decCount);
-          //outputsToRefresh.add(output);
-        }
-        for (Pair<IntermediateOutputCompiler, Module> pair : myGenerationCompilerModuleToOutputDirMap.keySet()) {
-          final Pair<VirtualFile, VirtualFile> generated = myGenerationCompilerModuleToOutputDirMap.get(pair);
-          walkChildren(generated.getFirst(), context);
-          //outputsToRefresh.add(generated.getFirst());
-          generated.getFirst().refresh(asyncMode, true, decCount);
-          walkChildren(generated.getSecond(), context);
-          //outputsToRefresh.add(generated.getSecond());
-          generated.getSecond().refresh(asyncMode, true, decCount);
-        }
 
-        //RefreshQueue.getInstance().refresh(false, true, null, outputsToRefresh.toArray(new VirtualFile[outputsToRefresh.size()]));
-        try {
-          latch.await(); // wait until all threads are refreshed
+          //RefreshQueue.getInstance().refresh(false, true, null, outputsToRefresh.toArray(new VirtualFile[outputsToRefresh.size()]));
+          try {
+            latch.await(); // wait until all threads are refreshed
+          }
+          catch (InterruptedException e) {
+            LOG.info(e);
+          }
         }
-        catch (InterruptedException e) {
-          LOG.info(e);
+        finally {
+          progressIndicator.popState();
         }
-      }
-      finally {
-        progressIndicator.popState();
-      }
 
-      final long initialRefreshTime = System.currentTimeMillis() - refreshStart;
-      CompilerUtil.logDuration("Initial VFS refresh", initialRefreshTime);
-      CompilerUtil.ourRefreshTime += initialRefreshTime;
+        final long initialRefreshTime = System.currentTimeMillis() - refreshStart;
+        CompilerUtil.logDuration("Initial VFS refresh", initialRefreshTime);
+        CompilerUtil.ourRefreshTime += initialRefreshTime;
+      }
 
       DumbService.getInstance(myProject).waitForSmartMode();
 
index e3f531cba86315fd269cb1229b9d34dc1d98e8ac..43d967f299d4e90171c22af14566cb8536e46067 100644 (file)
@@ -37,6 +37,7 @@ import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
@@ -413,7 +414,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
     final List<String> filesToDelete = context.getUserData(FILES_TO_DELETE_KEY);
     final Set<String> deletedJars;
     if (filesToDelete != null) {
-      deletedJars = deleteFiles(context.getProject(), filesToDelete);
+      deletedJars = deleteFiles(filesToDelete, context);
     }
     else {
       deletedJars = Collections.emptySet();
@@ -422,14 +423,34 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
     return deletedJars;
   }
 
-  protected Set<String> deleteFiles(final Project project, final List<String> paths) {
+  private Set<String> deleteFiles(final List<String> paths, CompileContext context) {
+
+    final Set<Artifact> artifactsToBuild = getAffectedArtifacts(context);
+
     final boolean testMode = ApplicationManager.getApplication().isUnitTestMode();
     final THashSet<String> deletedJars = new THashSet<String>();
     if (LOG.isDebugEnabled()) {
       LOG.debug("Deleting outdated files...");
     }
+
+    final Artifact[] allArtifacts = ArtifactManager.getInstance(context.getProject()).getArtifacts();
+
     List<File> filesToRefresh = new ArrayList<File>();
     for (String fullPath : paths) {
+      boolean isUnderOutput = false;
+      boolean isInArtifactsToBuild = false;
+      for (Artifact artifact : allArtifacts) {
+        final String path = artifact.getOutputPath();
+        if (!StringUtil.isEmpty(path) && FileUtil.startsWith(fullPath, path)) {
+          isUnderOutput = true;
+          if (artifactsToBuild.contains(artifact)) {
+            isInArtifactsToBuild = true;
+            break;
+          }
+        }
+      }
+      if (isUnderOutput && !isInArtifactsToBuild) continue;
+
       int end = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR);
       String filePath = end != -1 ? fullPath.substring(0, end) : fullPath;
       if (end != -1) {
@@ -446,7 +467,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
         if (testMode) {
           CompilerManagerImpl.addDeletedPath(file.getAbsolutePath());
         }
-        getOutputItemsCache(project).remove(fullPath);
+        getOutputItemsCache(context.getProject()).remove(fullPath);
       }
     }
 
index 3220ea9d7e2ad658a4ef52aed97ea6152e9bd9dc..32f9aab192f37880514138501c3edf043001b1ec 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.debugger.settings.UserRenderersConfigurable;
 import com.intellij.debugger.ui.impl.FrameDebuggerTree;
 import com.intellij.debugger.ui.impl.watch.DebuggerTree;
 import com.intellij.idea.ActionsBundle;
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.options.CompositeConfigurable;
@@ -30,6 +31,7 @@ import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.options.TabbedConfigurable;
 import com.intellij.openapi.options.ex.SingleConfigurableEditor;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
 
 import javax.swing.*;
 import java.util.ArrayList;
@@ -44,7 +46,8 @@ public class CustomizeContextViewAction extends DebuggerAction{
   public void actionPerformed(AnActionEvent e) {
     final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
 
-    final CompositeConfigurable configurable = new TabbedConfigurable() {
+    Disposable disposable = Disposer.newDisposable();
+    final CompositeConfigurable configurable = new TabbedConfigurable(disposable) {
       protected List<Configurable> createConfigurables() {
         ArrayList<Configurable> array = new ArrayList<Configurable>();
         array.add(new DebuggerDataViewsConfigurable(project));
@@ -70,7 +73,9 @@ public class CustomizeContextViewAction extends DebuggerAction{
       }
     };
 
-    new SingleConfigurableEditor(project, configurable).show();
+    SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
+    Disposer.register(editor.getDisposable(), disposable);
+    editor.show();
   }
 
   public void update(AnActionEvent e) {
index 651936a755b0f0822da8228f778d08e50111dcdb..f457a826bcdd8c7dcf3df10eafb0e967d9a413aa 100644 (file)
@@ -18,7 +18,9 @@ package com.intellij.execution.application;
 import com.intellij.execution.*;
 import com.intellij.execution.configurations.ConfigurationFactory;
 import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.impl.RunManagerImpl;
 import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.IconLoader;
@@ -77,8 +79,19 @@ public class ApplicationConfigurationType implements LocatableConfigurationType
     if (aClass == null) {
       return false;
     }
-    return Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), ((ApplicationConfiguration)configuration).MAIN_CLASS_NAME)
-           && Comparing.equal(JavaExecutionUtil.findModule(aClass), ((ApplicationConfiguration)configuration).getConfigurationModule().getModule());
+    if (Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), ((ApplicationConfiguration)configuration).MAIN_CLASS_NAME)) {
+      if (Comparing.equal(location.getModule(), ((ApplicationConfiguration)configuration).getConfigurationModule().getModule())) {
+        return true;
+      }
+      final Module configurationModule = ((ApplicationConfiguration)configuration).getConfigurationModule().getModule();
+      if (Comparing.equal(location.getModule(), configurationModule)) return true;
+
+      final Module predefinedModule =
+        ((ApplicationConfiguration)((RunManagerImpl)RunManagerEx.getInstanceEx(location.getProject())).getConfigurationTemplate(myFactory)
+          .getConfiguration()).getConfigurationModule().getModule();
+      return Comparing.equal(predefinedModule, configurationModule);
+    }
+    return false;
   }
 
   public static PsiClass getMainClass(PsiElement element) {
index 4591bfa0980362cc9d87dc1b7dc969bed6417c54..4db2ce33a13b14b757232ca33de4243ee5d9bde7 100644 (file)
@@ -18,11 +18,14 @@ package com.intellij.execution.junit2.info;
 import com.intellij.execution.Location;
 import com.intellij.execution.PsiLocation;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.util.Iterator;
 
@@ -55,6 +58,12 @@ public class MethodLocation extends Location<PsiMethod> {
     return myProject;
   }
 
+  @Nullable
+  @Override
+  public Module getModule() {
+    return ModuleUtil.findModuleForPsiElement(myMethod);
+  }
+
   public PsiClass getContainingClass() {
     return myClassLocation.getPsiElement();
   }
index c1c5a3d7a80c79bc9ba27622e8089058b0b72b6e..a6d890f5bf00c819bc9298ba95372cea5d4ebcd5 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.facet.impl.autodetecting.FacetAutodetectingManager;
 import com.intellij.facet.ui.DefaultFacetSettingsEditor;
 import com.intellij.facet.ui.FacetEditor;
 import com.intellij.facet.ui.MultipleFacetSettingsEditor;
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ConfigurationException;
@@ -31,6 +32,7 @@ import com.intellij.openapi.options.UnnamedConfigurableGroup;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.ui.TabbedPaneWrapper;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -50,6 +52,7 @@ public class FacetTypeEditor extends UnnamedConfigurableGroup {
   private MultipleFacetSettingsEditor myAllFacetsEditor;
   private List<Configurable> myCurrentConfigurables;
   private TabbedPaneWrapper myTabbedPane;
+  private final Disposable myDisposable = Disposer.newDisposable();
 
   public <C extends FacetConfiguration> FacetTypeEditor(@NotNull Project project, final StructureConfigurableContext context, @NotNull FacetType<?, C> facetType) {
     myProject = project;
@@ -87,6 +90,12 @@ public class FacetTypeEditor extends UnnamedConfigurableGroup {
     return null;
   }
 
+  @Override
+  public void disposeUIResources() {
+    Disposer.dispose(myDisposable);
+    super.disposeUIResources();
+  }
+
   public JComponent createComponent() {
     MultipleFacetSettingsEditor allFacetsEditor = createAllFacetsEditor();
     if (myAllFacetsEditor != null) {
@@ -106,7 +115,7 @@ public class FacetTypeEditor extends UnnamedConfigurableGroup {
       return myCurrentConfigurables.get(0).createComponent();
     }
 
-    myTabbedPane = new TabbedPaneWrapper();
+    myTabbedPane = new TabbedPaneWrapper(myDisposable);
     for (Configurable configurable : myCurrentConfigurables) {
       myTabbedPane.addTab(configurable.getDisplayName(), configurable.getIcon(), configurable.createComponent(), null);
     }
index 8f68c567f4f658bbc1febbb1583b008e9e2cebfd..e9dbe1d539e91333d01a52abb5000a306099d81d 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.ide.util.projectWizard;
 import com.intellij.CommonBundle;
 import com.intellij.application.options.PathMacrosCollector;
 import com.intellij.application.options.PathMacrosImpl;
+import com.intellij.conversion.ConversionResult;
 import com.intellij.conversion.ConversionService;
 import com.intellij.ide.IdeBundle;
 import com.intellij.openapi.application.PathMacros;
@@ -76,7 +77,8 @@ public class ExistingModuleLoader extends ModuleBuilder {
     final File file = new File(getModuleFilePath());
     if (file.exists()) {
       try {
-        if (!ConversionService.getInstance().convertModule(dest, file)) {
+        final ConversionResult result = ConversionService.getInstance().convertModule(dest, file);
+        if (result.openingIsCanceled()) {
           return false;
         }
         final Document document = JDOMUtil.loadDocument(file);
index 158665c99a13f48fc7c06faa1797b8d131125312..a7e11074f5f1775ecf5a0f19dcf44a3f79db714e 100644 (file)
  */
 package com.intellij.openapi.project.impl;
 
+import com.intellij.conversion.ConversionResult;
 import com.intellij.conversion.ConversionService;
+import com.intellij.conversion.impl.ConversionResultImpl;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.startup.StartupManager;
 import com.intellij.openapi.vfs.ex.VirtualFileManagerEx;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.io.File;
+import java.io.IOException;
 
 /**
  * @author mike
@@ -32,17 +37,40 @@ public class IdeaProjectManagerImpl extends ProjectManagerImpl {
     super(virtualFileManagerEx);
   }
 
-  @Nullable
-  protected Pair<Class, Object> convertProject(final String filePath) throws ProcessCanceledException {
+  @NotNull
+  private static ConversionResult convertProject(final String filePath) throws ProcessCanceledException {
     final String fp = canonicalize(filePath);
 
     final File f = new File(fp);
     if (fp != null && f.exists() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
-      final boolean converted = ConversionService.getInstance().convert(fp);
-      if (!converted) {
-        throw new ProcessCanceledException();
+      return ConversionService.getInstance().convert(fp);
+    }
+    return ConversionResultImpl.CONVERSION_NOT_NEEDED;
+  }
+
+  @Nullable
+  protected Project convertAndLoadProject(String filePath, boolean convert) throws IOException {
+    final ConversionResult conversionResult;
+    if (convert) {
+      conversionResult = convertProject(filePath);
+      if (conversionResult.openingIsCanceled()) {
+        return null;
       }
     }
-    return null;
+    else {
+      conversionResult = null;
+    }
+
+    final Project project = loadProjectWithProgress(filePath);
+    if (project == null) return null;
+
+    if (conversionResult != null && !conversionResult.conversionNotNeeded()) {
+      StartupManager.getInstance(project).registerPostStartupActivity(new Runnable() {
+        public void run() {
+          conversionResult.postStartupActivity(project);
+        }
+      });
+    }
+    return project;
   }
 }
index 3896faf53c4eb6e3b05e25e64887493d8adee313..1e1fda075583294768e0f2e4c213a2e044b3ebe7 100644 (file)
@@ -83,7 +83,7 @@ public class SdkEditor implements Configurable, Place.Navigator {
   private String myInitialPath;
   private final History myHistory;
 
-  private Disposable myDisposable = Disposer.newDisposable();
+  private final Disposable myDisposable = Disposer.newDisposable();
 
   public SdkEditor(NotifiableSdkModel sdkModel, History history, final ProjectJdkImpl sdk) {
     mySdkModel = sdkModel;
index ee1c28d0f9eb2fedf6f06fe03230eeadd0912b80..6594fcacc4c59e845917686e4a4559c06837f9fe 100644 (file)
@@ -70,14 +70,17 @@ import com.intellij.psi.util.PropertyUtil;
 import com.intellij.psi.util.PsiUtilBase;
 import com.intellij.util.Processor;
 import com.intellij.util.Query;
-import gnu.trove.THashMap;
 import gnu.trove.THashSet;
+import gnu.trove.TObjectIntHashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.annotations.PropertyKey;
 import org.jetbrains.annotations.TestOnly;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
 
 public class PostHighlightingPass extends TextEditorHighlightingPass {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.PostHighlightingPass");
@@ -98,6 +101,8 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
   private HighlightDisplayKey myUnusedSymbolKey;
   private boolean myDeadCodeEnabled;
   private boolean myInLibrary;
+  private HighlightDisplayKey myDeadCodeKey;
+  private HighlightInfoType myDeadCodeInfoType;
 
   private PostHighlightingPass(@NotNull Project project,
                                @NotNull PsiFile file,
@@ -214,9 +219,9 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     myUnusedSymbolInspection = unusedSymbolTool == null ? null : (UnusedSymbolLocalInspection)unusedSymbolTool.getTool();
     LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || myUnusedSymbolInspection != null);
 
-    HighlightDisplayKey deadCodeKey = HighlightDisplayKey.find(DeadCodeInspection.SHORT_NAME);
+    myDeadCodeKey = HighlightDisplayKey.find(DeadCodeInspection.SHORT_NAME);
     myDeadCodeInspection = (DeadCodeInspection)profile.getInspectionTool(DeadCodeInspection.SHORT_NAME, myFile);
-    myDeadCodeEnabled = profile.isToolEnabled(deadCodeKey, myFile);
+    myDeadCodeEnabled = profile.isToolEnabled(myDeadCodeKey, myFile);
     if (unusedImportEnabled && JspPsiUtil.isInJspFile(myFile)) {
       final JspFile jspFile = JspPsiUtil.getJspFile(myFile);
       if (jspFile != null) {
@@ -224,6 +229,8 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
       }
     }
 
+    myDeadCodeInfoType = myDeadCodeKey == null ? null : new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(myDeadCodeKey, myFile).getSeverity(), HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
+
     if (!unusedSymbolEnabled && !unusedImportEnabled) {
       return;
     }
@@ -287,7 +294,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     if (isImplicitUsage(variable)) return null;
     if (!myRefCountHolder.isReferenced(variable)) {
       String message = JavaErrorMessages.message("local.variable.is.never.used", identifier.getText());
-      HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
+      HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
       QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveUnusedVariableFix(variable), myUnusedSymbolKey);
       return highlightInfo;
     }
@@ -295,7 +302,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     boolean referenced = myRefCountHolder.isReferencedForRead(variable);
     if (!referenced && !isImplicitRead(variable)) {
       String message = JavaErrorMessages.message("local.variable.is.not.used.for.reading", identifier.getText());
-      HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
+      HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
       QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveUnusedVariableFix(variable), myUnusedSymbolKey);
       return highlightInfo;
     }
@@ -304,7 +311,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
       referenced = myRefCountHolder.isReferencedForWrite(variable);
       if (!referenced && !isImplicitWrite(variable)) {
         String message = JavaErrorMessages.message("local.variable.is.not.assigned", identifier.getText());
-        final HighlightInfo unusedSymbolInfo = createUnusedSymbolInfo(identifier, message);
+        final HighlightInfo unusedSymbolInfo = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
         QuickFixAction.registerQuickFixAction(unusedSymbolInfo, new EmptyIntentionAction(UnusedSymbolLocalInspection.DISPLAY_NAME), myUnusedSymbolKey);
         return unusedSymbolInfo;
       }
@@ -346,8 +353,12 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     return false;
   }
 
-  private static HighlightInfo createUnusedSymbolInfo(PsiElement element, String message) {
-    return HighlightInfo.createHighlightInfo(HighlightInfoType.UNUSED_SYMBOL, element, message);
+  private HighlightInfo createUnusedSymbolInfo(PsiElement element, String message, final HighlightInfoType highlightInfoType) {
+    return HighlightInfo.createHighlightInfo(highlightInfoType, element, message);
+  }
+
+  private HighlightInfo createDeadCodeInfo(PsiElement element, String message) {
+    return HighlightInfo.createHighlightInfo(myDeadCodeInfoType, element, message);
   }
 
   @Nullable
@@ -377,7 +388,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
       final boolean writeReferenced = myRefCountHolder.isReferencedForWrite(field);
       if (!writeReferenced && !isImplicitWrite(field)) {
         String message = JavaErrorMessages.message("private.field.is.not.assigned", identifier.getText());
-        final HighlightInfo info = createUnusedSymbolInfo(identifier, message);
+        final HighlightInfo info = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
 
         QuickFixAction.registerQuickFixAction(info, new CreateGetterOrSetterFix(false, true, field), myUnusedSymbolKey);
         QuickFixAction.registerQuickFixAction(info, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field), null);
@@ -391,13 +402,13 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
       }
     }
     else if (!myRefCountHolder.isReferenced(field) && weAreSureThereAreNoUsages(field)) {
-      return formatUnusedSymbolHighlightInfo("field.is.not.used", field, "fields");
+      return formatUnusedSymbolHighlightInfo("field.is.not.used", field, "fields", myDeadCodeKey, myDeadCodeInfoType);
     }
     return null;
   }
 
   private HighlightInfo suggestionsToMakeFieldUsed(final PsiField field, final PsiIdentifier identifier, final String message) {
-    HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
+    HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
     QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveUnusedVariableFix(field), myUnusedSymbolKey);
     QuickFixAction.registerQuickFixAction(highlightInfo, new CreateGetterOrSetterFix(true, false, field), myUnusedSymbolKey);
     QuickFixAction.registerQuickFixAction(highlightInfo, new CreateGetterOrSetterFix(false, true, field), myUnusedSymbolKey);
@@ -449,7 +460,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
       PsiIdentifier identifier = parameter.getNameIdentifier();
       assert identifier != null;
       String message = JavaErrorMessages.message("parameter.is.not.used", identifier.getText());
-      return createUnusedSymbolInfo(identifier, message);
+      return createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
     }
     return null;
   }
@@ -459,6 +470,9 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     if (myRefCountHolder.isReferenced(method)) return null;
     boolean isPrivate = method.hasModifierProperty(PsiModifier.PRIVATE);
     PsiClass containingClass = method.getContainingClass();
+    HighlightInfoType highlightInfoType = HighlightInfoType.UNUSED_SYMBOL;
+    HighlightDisplayKey highlightDisplayKey = myUnusedSymbolKey;
+
     if (isPrivate) {
       if (HighlightMethodUtil.isSerializationRelatedMethod(method, containingClass) ||
           isIntentionalPrivateConstructor(method, containingClass)) {
@@ -470,12 +484,17 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     }
     else {
       //class maybe used in some weird way, e.g. from XML, therefore the only constructor is used too
-      if (containingClass != null && method.isConstructor() && containingClass.getConstructors().length == 1 && !isClassUnused(containingClass)) return null;
+      if (containingClass != null && method.isConstructor() && containingClass.getConstructors().length == 1 && isClassUnused(containingClass) == USED) return null;
       if (isImplicitUsage(method)) return null;
 
-      if (method.findSuperMethods().length != 0 || !weAreSureThereAreNoUsages(method)) {
+      if (method.findSuperMethods().length != 0) {
         return null;
       }
+      if (!weAreSureThereAreNoUsages(method)) {
+        return null;
+      }
+      highlightInfoType = myDeadCodeInfoType;
+      highlightDisplayKey = myDeadCodeKey;
     }
     String key = isPrivate
                  ? method.isConstructor() ? "private.constructor.is.not.used" : "private.method.is.not.used"
@@ -483,8 +502,8 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     String symbolName = HighlightMessageUtil.getSymbolName(method, PsiSubstitutor.EMPTY);
     String message = JavaErrorMessages.message(key, symbolName);
     PsiIdentifier identifier = method.getNameIdentifier();
-    final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
-    QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(method), myUnusedSymbolKey);
+    final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, highlightInfoType);
+    QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(method), highlightDisplayKey);
     SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(method, new Processor<String>() {
       public boolean process(final String annoName) {
         QuickFixAction.registerQuickFixAction(highlightInfo, myUnusedSymbolInspection.createQuickFix(annoName, "methods"));
@@ -540,49 +559,70 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
 
   @Nullable
   private HighlightInfo processClass(PsiClass aClass) {
-    if (!isClassUnused(aClass)) return null;
-    String element = "classes";
+    int usage = isClassUnused(aClass);
+    if (usage == USED) return null;
+
+    String pattern;
+    HighlightDisplayKey highlightDisplayKey;
+    HighlightInfoType highlightInfoType;
     if (aClass.getContainingClass() != null && aClass.hasModifierProperty(PsiModifier.PRIVATE)) {
-      String pattern = aClass.isInterface()
+      pattern = aClass.isInterface()
                        ? "private.inner.interface.is.not.used"
                        : "private.inner.class.is.not.used";
-      return formatUnusedSymbolHighlightInfo(pattern, aClass, element);
+      highlightDisplayKey = myUnusedSymbolKey;
+      highlightInfoType = HighlightInfoType.UNUSED_SYMBOL;
     }
-    if (aClass.getParent() instanceof PsiDeclarationStatement) { // local class
-      return formatUnusedSymbolHighlightInfo("local.class.is.not.used", aClass, element);
+    else if (aClass.getParent() instanceof PsiDeclarationStatement) { // local class
+      pattern = "local.class.is.not.used";
+      highlightDisplayKey = myUnusedSymbolKey;
+      highlightInfoType = HighlightInfoType.UNUSED_SYMBOL;
     }
-    if (aClass instanceof PsiTypeParameter) {
-      return formatUnusedSymbolHighlightInfo("type.parameter.is.not.used", aClass, element);
+    else if (aClass instanceof PsiTypeParameter) {
+      pattern = "type.parameter.is.not.used";
+      highlightDisplayKey = myUnusedSymbolKey;
+      highlightInfoType = HighlightInfoType.UNUSED_SYMBOL;
+    }
+    else {
+      pattern = "class.is.not.used";
+      highlightDisplayKey = myDeadCodeKey;
+      highlightInfoType = myDeadCodeInfoType;
     }
-    return formatUnusedSymbolHighlightInfo("class.is.not.used", aClass, element);
+    return formatUnusedSymbolHighlightInfo(pattern, aClass, "classes", highlightDisplayKey, highlightInfoType);
   }
 
-  private final Map<PsiClass, Boolean> unusedClassCache = new THashMap<PsiClass, Boolean>();
-  private boolean isClassUnused(PsiClass aClass) {
-    if (aClass == null) return false;
-    Boolean result = unusedClassCache.get(aClass);
-    if (result == null) {
+  private static final int USED = 1;
+  private static final int UNUSED_LOCALLY = 2;
+  private static final int UNUSED_GLOBALLY = 3;
+  private final TObjectIntHashMap<PsiClass> unusedClassCache = new TObjectIntHashMap<PsiClass>();
+  private int isClassUnused(PsiClass aClass) {
+    if (aClass == null) return USED;
+    int result = unusedClassCache.get(aClass);
+    if (result == 0) {
       result = isReallyUnused(aClass);
       unusedClassCache.put(aClass, result);
     }
     return result;
   }
 
-  private boolean isReallyUnused(PsiClass aClass) {
-    if (isImplicitUsage(aClass) || myRefCountHolder.isReferenced(aClass)) return false;
-    return aClass.getContainingClass() != null && aClass.hasModifierProperty(PsiModifier.PRIVATE) ||
+  private int isReallyUnused(PsiClass aClass) {
+    if (isImplicitUsage(aClass) || myRefCountHolder.isReferenced(aClass)) return USED;
+    if (aClass.getContainingClass() != null && aClass.hasModifierProperty(PsiModifier.PRIVATE) ||
            aClass.getParent() instanceof PsiDeclarationStatement ||
-           aClass instanceof PsiTypeParameter ||
-           weAreSureThereAreNoUsages(aClass);
+           aClass instanceof PsiTypeParameter) return UNUSED_LOCALLY;
+    if (weAreSureThereAreNoUsages(aClass)) return UNUSED_GLOBALLY;
+    return USED;
   }
 
   private HighlightInfo formatUnusedSymbolHighlightInfo(@PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String pattern,
-                                                        PsiNameIdentifierOwner aClass, final String element) {
+                                                        PsiNameIdentifierOwner aClass,
+                                                        final String element,
+                                                        final HighlightDisplayKey highlightDisplayKey,
+                                                        final HighlightInfoType highlightInfoType) {
     String symbolName = aClass.getName();
     String message = JavaErrorMessages.message(pattern, symbolName);
     PsiElement identifier = aClass.getNameIdentifier();
-    final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
-    QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(aClass), myUnusedSymbolKey);
+    final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, highlightInfoType);
+    QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(aClass), highlightDisplayKey);
     SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes((PsiModifierListOwner)aClass, new Processor<String>() {
       public boolean process(final String annoName) {
         QuickFixAction.registerQuickFixAction(highlightInfo, myUnusedSymbolInspection.createQuickFix(annoName, element));
index 5a3f81e861779a6c2c70bec432406b1b428c6952..f612d9f45f8d72aa679e9ca3f0b4fa5eab65da19 100644 (file)
@@ -71,6 +71,7 @@ public class CreateClassDialog extends DialogWrapper {
     myClassName = targetClassName;
     myProject = project;
     myPackageComponent = new PackageNameReferenceEditorCombo( targetPackageName != null ? targetPackageName : "", myProject, RECENTS_KEY, CodeInsightBundle.message("dialog.create.class.package.chooser.title"));
+    myPackageComponent.setTextFieldPreferredWidth(40);
 
     init();
 
index 2cdded1a9a67dd9afb546901f582aa9c300ea55e..360d33225dd1c6cf784392655d2346ddd9879ee6 100644 (file)
@@ -181,11 +181,8 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
 
   @NotNull
   public LanguageLevel getLanguageLevel() {
-    return getClassStub().getLanguageLevel();
-  }
-
-  private PsiClassStub<?> getClassStub() {
-    return (PsiClassStub)getStub().getChildrenStubs().get(0);
+    final List stubs = getStub().getChildrenStubs();
+    return stubs.size() > 0 ? ((PsiClassStub<?>)stubs.get(0)).getLanguageLevel() : LanguageLevel.HIGHEST;
   }
 
   public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
index d4581d0cbdb0a088046c415c898309bd8559bd8f..803ddbb2f13aadad6d64a70d19f83ddee1e3e2a4 100644 (file)
@@ -251,7 +251,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
               reportedNonDelegatedUsages.put(nonDelegatedMember, reportedContainers);
             }
             final PsiElement container = ConflictsUtil.getContainer(element);
-            if (container != null && !reportedContainers.contains(container)) {
+            if (!reportedContainers.contains(container)) {
               String message = RefactoringBundle.message("0.uses.1.of.an.instance.of.a.2", RefactoringUIUtil.getDescription(container, true),
                                                          RefactoringUIUtil.getDescription(nonDelegatedMember, true), classDescription);
               conflicts.putValue(container, CommonRefactoringUtil.capitalize(message));
@@ -266,7 +266,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
               reportedUpcasts.put(upcastedTo, reportedContainers);
             }
             final PsiElement container = ConflictsUtil.getContainer(element);
-            if (container != null && !reportedContainers.contains(container)) {
+            if (!reportedContainers.contains(container)) {
               String message = RefactoringBundle.message("0.upcasts.an.instance.of.1.to.2",
                                                          RefactoringUIUtil.getDescription(container, true), classDescription,
                                                          RefactoringUIUtil.getDescription(upcastedTo, false));
index 00e63c9bf772f34c4591573bed16ae9a352d9804..53feada2a7b8deefd745110b9cf907c0a24e3faf 100644 (file)
@@ -208,12 +208,13 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
     Map<PsiMember, Set<PsiMember>> result = new HashMap<PsiMember, Set<PsiMember>>();
 
     for (UsageInfo usage : usages) {
-      final PsiMember container = ConflictsUtil.getContainer(usage.getElement());
-      if (container == null) continue;    // usage in import statement
-      Set<PsiMember> inaccessibleReferenced = result.get(container);
+      final PsiElement container = ConflictsUtil.getContainer(usage.getElement());
+      if (!(container instanceof PsiMember)) continue;    // usage in import statement
+      PsiMember memberContainer = (PsiMember)container;
+      Set<PsiMember> inaccessibleReferenced = result.get(memberContainer);
       if (inaccessibleReferenced == null) {
         inaccessibleReferenced = new HashSet<PsiMember>();
-        result.put(container, inaccessibleReferenced);
+        result.put(memberContainer, inaccessibleReferenced);
         for (PsiMember member : referencedElements) {
           if (!PsiUtil.isAccessible(member, usage.getElement(), null)) {
             inaccessibleReferenced.add(member);
index 2ed7bb68b76d1b97a06143c238162699c3738ef4..e2a6f8c20ad417390680d86c2794672c40855591 100644 (file)
@@ -369,7 +369,6 @@ public class MoveClassToInnerProcessor extends BaseRefactoringProcessor {
 
     public void addConflict(final PsiElement targetElement, final PsiElement sourceElement) {
       PsiElement container = ConflictsUtil.getContainer(sourceElement);
-      if (container == null) return;
       if (!myReportedContainers.contains(container)) {
         myReportedContainers.add(container);
         String targetDescription = (targetElement == myClassToMove)
index 30bb4b4159c41cf104c08eb576d0104ee9815f57..3555beafb89e993017bbc4d8a49bb9f8e3128ce0 100644 (file)
@@ -245,7 +245,6 @@ public class MoveClassesOrPackagesProcessor extends BaseRefactoringProcessor {
         if (PsiModifier.PACKAGE_LOCAL.equals(visibility)) {
           if (PsiTreeUtil.getParentOfType(element, PsiImportStatement.class) != null) continue;
           PsiElement container = ConflictsUtil.getContainer(element);
-          if (container == null) continue;
           HashSet<PsiElement> reported = reportedClassToContainers.get(aClass);
           if (reported == null) {
             reported = new HashSet<PsiElement>();
index a200b2d0e4d03756093f106efe0385372482c85f..977840429415ee2af1cfc0199bd0da0bf0dd3091 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.psi.util.PsiUtil;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.usageView.UsageViewUtil;
 import com.intellij.util.containers.MultiMap;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.Map;
@@ -34,13 +35,13 @@ public class ConflictsUtil {
   private ConflictsUtil() {
   }
 
-  @Nullable
-  public static PsiMember getContainer(PsiElement place) {
+  @NotNull
+  public static PsiElement getContainer(PsiElement place) {
     PsiElement parent = place;
     while (true) {
       if (parent instanceof PsiMember && !(parent instanceof PsiTypeParameter))
-        return (PsiMember)parent;
-      if (parent instanceof PsiFile) return null;
+        return parent;
+      if (parent instanceof PsiFile) return parent;
       parent = parent.getParent();
     }
   }
index 4a2bfd0e119eeee3ce1e47c4eb8d64da3909a47b..9cca54530051c6b0120af2cc6ab16dacba5af1d4 100644 (file)
@@ -242,7 +242,6 @@ public class RefactoringConflictsUtil {
             PsiElement container;
             if (usageFile instanceof PsiJavaFile) {
               container = ConflictsUtil.getContainer(element);
-              if (container == null) container = usageFile;
             }
             else {
               container = usageFile;
index a6896609ccd3535686a40a457e7793bab91835a7..d7e51d6d702c581c75219966e92a7d989db4bb1f 100644 (file)
@@ -223,7 +223,7 @@ public class SliceUtil {
 
     final Set<PsiReference> processed = new THashSet<PsiReference>(); //usages of super method and overridden method can overlap
     for (final PsiMethod superMethod : superMethods) {
-      if (!MethodReferencesSearch.search(superMethod, parent.getScope().toSearchScope(), false).forEach(new Processor<PsiReference>() {
+      if (!MethodReferencesSearch.search(superMethod, parent.getScope().toSearchScope(), true).forEach(new Processor<PsiReference>() {
         public boolean process(final PsiReference reference) {
           SliceManager.getInstance(parameter.getProject()).checkCanceled();
           synchronized (processed) {
diff --git a/java/java-tests/testData/refactoring/pushDown/usagesInXml/before/a/A.form b/java/java-tests/testData/refactoring/pushDown/usagesInXml/before/a/A.form
new file mode 100644 (file)
index 0000000..e49f0fe
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="a.A">
+  <grid id="27dc6" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+    <margin top="0" left="0" bottom="0" right="0"/>
+    <constraints>
+      <xy x="20" y="20" width="500" height="400"/>
+    </constraints>
+    <properties/>
+    <border type="none"/>
+    <children>
+      <component id="3ec2f" class="javax.swing.JTextField" binding="textField1" default-binding="true">
+        <constraints>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
+            <preferred-size width="150" height="-1"/>
+          </grid>
+        </constraints>
+        <properties/>
+      </component>
+      <hspacer id="38a16">
+        <constraints>
+          <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+        </constraints>
+      </hspacer>
+      <vspacer id="e9ce3">
+        <constraints>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+        </constraints>
+      </vspacer>
+    </children>
+  </grid>
+</form>
diff --git a/java/java-tests/testData/refactoring/pushDown/usagesInXml/before/a/A.java b/java/java-tests/testData/refactoring/pushDown/usagesInXml/before/a/A.java
new file mode 100644 (file)
index 0000000..c762127
--- /dev/null
@@ -0,0 +1,4 @@
+package a;
+public class A {
+  private JTextField textField1;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/pushDown/usagesInXml/before/b/B.java b/java/java-tests/testData/refactoring/pushDown/usagesInXml/before/b/B.java
new file mode 100644 (file)
index 0000000..399835a
--- /dev/null
@@ -0,0 +1,4 @@
+package b;
+
+import a.*;
+class B extends A {}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/renameLocal/RenameInPlaceQualifyFieldReference.java b/java/java-tests/testData/refactoring/renameLocal/RenameInPlaceQualifyFieldReference.java
new file mode 100644 (file)
index 0000000..f6268b3
--- /dev/null
@@ -0,0 +1,6 @@
+class Test {
+  int myI;
+  void foo(int <caret>i){
+    myI = i;
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/renameLocal/RenameInPlaceQualifyFieldReference_after.java b/java/java-tests/testData/refactoring/renameLocal/RenameInPlaceQualifyFieldReference_after.java
new file mode 100644 (file)
index 0000000..8afd91e
--- /dev/null
@@ -0,0 +1,6 @@
+class Test {
+  int myI;
+  void foo(int i){
+    this.myI = i;
+  }
+}
\ No newline at end of file
similarity index 62%
rename from java/java-tests/testSrc/com/intellij/refactoring/PushDownImportsTest.java
rename to java/java-tests/testSrc/com/intellij/refactoring/PushDownMultifileTest.java
index 62dd14af370a0e3eaf89c02ce47586549a9250ce..4f677709076757173732e4b1ea4091041af49a0a 100644 (file)
@@ -9,13 +9,14 @@ import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiMethod;
 import com.intellij.refactoring.memberPushDown.PushDownProcessor;
 import com.intellij.refactoring.util.DocCommentPolicy;
 import com.intellij.refactoring.util.classMembers.MemberInfo;
 
 //push first method from class a.A to class b.B
-public class PushDownImportsTest extends MultiFileTestCase {
+public class PushDownMultifileTest extends MultiFileTestCase {
   protected String getTestRoot() {
     return "/refactoring/pushDown/";
   }
@@ -79,4 +80,36 @@ public class PushDownImportsTest extends MultiFileTestCase {
   public void testStaticImportOfPushedMethod() throws Exception {
     doTest();
   }
+
+  public void testUsagesInXml() throws Exception {
+    try {
+      doTest(new PerformAction() {
+        public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
+          final PsiClass srcClass = myJavaFacade.findClass("a.A");
+          assertTrue("Source class not found", srcClass != null);
+
+          final PsiClass targetClass = myJavaFacade.findClass("b.B");
+          assertTrue("Target class not found", targetClass != null);
+
+          final PsiField[] fields = srcClass.getFields();
+          assertTrue("No methods found", fields.length > 0);
+          final MemberInfo[] membersToMove = new MemberInfo[1];
+          final MemberInfo memberInfo = new MemberInfo(fields[0]);
+          memberInfo.setChecked(true);
+          membersToMove[0] = memberInfo;
+
+          new PushDownProcessor(getProject(), membersToMove, srcClass, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
+
+
+          //LocalFileSystem.getInstance().refresh(false);
+          //FileDocumentManager.getInstance().saveAllDocuments();
+        }
+      });
+    }
+    catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
+      assertEquals(e.getMessage(), "Class <b><code>b.B</code></b> is package local and will not be accessible from file <b><code>A.form</code></b>.");
+      return;
+    }
+    fail("Conflict was not detected");
+  }
 }
\ No newline at end of file
index eae34289f04f0fc2cdd3ddf6eda663fbbabbd3da..250940681e512e6af658cfaaba8631e304bbaca6 100644 (file)
@@ -1,10 +1,19 @@
 package com.intellij.refactoring;
 
+import com.intellij.JavaTestUtil;
 import com.intellij.codeInsight.TargetElementUtilBase;
+import com.intellij.codeInsight.lookup.LookupManager;
+import com.intellij.codeInsight.lookup.impl.TestLookupManager;
+import com.intellij.codeInsight.template.TemplateManager;
+import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
 import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiNameIdentifierOwner;
+import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.refactoring.rename.RenameProcessor;
+import com.intellij.refactoring.rename.inplace.ResolveSnapshotProvider;
+import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
 import com.intellij.testFramework.LightCodeInsightTestCase;
-import com.intellij.JavaTestUtil;
 
 /**
  * @author ven
@@ -37,4 +46,37 @@ public class RenameLocalTest extends LightCodeInsightTestCase {
     new RenameProcessor(getProject(), element, newName, true, true).run();
     checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
   }
+
+  public void testRenameInPlaceQualifyFieldReference() throws Exception {
+    doTestInplaceRenameCollisionsResolved("myI");
+  }
+
+  //reference itself won't be renamed
+  private void doTestInplaceRenameCollisionsResolved(String newName) throws Exception {
+    configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
+    PsiElement element = TargetElementUtilBase.findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
+    assertNotNull(element);
+    final PsiMethod methodScope = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
+    assertNotNull(methodScope);
+
+    ResolveSnapshotProvider resolveSnapshotProvider = VariableInplaceRenamer.INSTANCE.forLanguage(getFile().getLanguage());
+    assertNotNull(resolveSnapshotProvider);
+    final ResolveSnapshotProvider.ResolveSnapshot snapshot = resolveSnapshotProvider.createSnapshot(methodScope);
+    assertNotNull(snapshot);
+
+    VariableInplaceRenamer renamer = new VariableInplaceRenamer((PsiNameIdentifierOwner)element, getEditor());
+    ((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(true);
+    try {
+      renamer.performInplaceRename();
+    }
+    finally {
+      renamer.finish();
+      snapshot.apply(newName);
+
+      TemplateManagerImpl.getTemplateState(myEditor).gotoEnd();
+      ((TestLookupManager)LookupManager.getInstance(getProject())).clearLookup();
+      ((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(false);
+    }
+    checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
+  }
 }
diff --git a/native/breakgen/breakgen.sln b/native/breakgen/breakgen.sln
new file mode 100644 (file)
index 0000000..385ab27
--- /dev/null
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "breakgen", "breakgen.vcproj", "{AE14C87F-E99B-4363-BE34-917FAF98258F}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Debug|x64 = Debug|x64
+               Release|Win32 = Release|Win32
+               Release|x64 = Release|x64
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Debug|Win32.ActiveCfg = Debug|Win32
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Debug|Win32.Build.0 = Debug|Win32
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Debug|x64.ActiveCfg = Debug|x64
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|Win32.ActiveCfg = Release|Win32
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|Win32.Build.0 = Release|Win32
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|x64.ActiveCfg = Release|x64
+               {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|x64.Build.0 = Release|x64
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/native/breakgen/breakgen.vcproj b/native/breakgen/breakgen.vcproj
new file mode 100644 (file)
index 0000000..4f02b6a
--- /dev/null
@@ -0,0 +1,337 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9,00"
+       Name="breakgen"
+       ProjectGUID="{AE14C87F-E99B-4363-BE34-917FAF98258F}"
+       RootNamespace="breakgen"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+               <Platform
+                       Name="x64"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="C:\Java\jdk1.6.0_14\include;C:\Java\jdk1.6.0_14\include\win32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|x64"
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|x64"
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="C:\Java\jdk1.6.0_14\include;C:\Java\jdk1.6.0_14\include\win32"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+               </Filter>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\AppMain.c"
+                               >
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
index e1dfc72e6b1f7ca7a0e4629878451b3e36d18cb5..3ccad92eb7c54ca29321f9facac732273c007914 100644 (file)
 package com.intellij.codeInsight.daemon;
 
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Comparing;
 import com.intellij.util.containers.HashMap;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.Map;
@@ -26,19 +28,28 @@ import java.util.Map;
 public class HighlightDisplayKey {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.HighlightDisplayKey");
 
-  private static final HashMap<String,HighlightDisplayKey> ourMap = new HashMap<String, HighlightDisplayKey>();
+  private static final HashMap<String,HighlightDisplayKey> ourNameToKeyMap = new HashMap<String, HighlightDisplayKey>();
+  private static final HashMap<String,HighlightDisplayKey> ourIdToKeyMap = new HashMap<String, HighlightDisplayKey>();
   private static final Map<HighlightDisplayKey, String> ourKeyToDisplayNameMap = new HashMap<HighlightDisplayKey, String>();
   private static final Map<HighlightDisplayKey, String> ourKeyToAlternativeIDMap = new HashMap<HighlightDisplayKey, String>();
 
   private final String myName;
   private final String myID;
 
-  public static HighlightDisplayKey find(@NonNls String name){
-    return ourMap.get(name);
+  public static HighlightDisplayKey find(@NonNls @NotNull String name){
+    return ourNameToKeyMap.get(name);
+  }
+
+  public static HighlightDisplayKey findById(@NonNls @NotNull String id){
+    HighlightDisplayKey key = ourIdToKeyMap.get(id);
+    if (key != null) return key;
+    key = ourNameToKeyMap.get(id);
+    if (key != null && key.getID().equals(id)) return key;
+    return null;
   }
 
   @Nullable
-  public static HighlightDisplayKey register(@NonNls String name) {
+  public static HighlightDisplayKey register(@NonNls @NotNull String name) {
     if (find(name) != null) {
       LOG.info("Key with name \'" + name + "\' already registered");
       return null;
@@ -47,7 +58,7 @@ public class HighlightDisplayKey {
   }
 
   @Nullable
-  public static HighlightDisplayKey register(@NonNls String name, String displayName, @NonNls String id){
+  public static HighlightDisplayKey register(@NonNls @NotNull String name, @NotNull String displayName, @NotNull @NonNls String id){
     if (find(name) != null) {
       LOG.info("Key with name \'" + name + "\' already registered");
       return null;
@@ -58,22 +69,25 @@ public class HighlightDisplayKey {
   }
 
   @Nullable
-  public static HighlightDisplayKey register(@NonNls String name, String displayName) {
+  public static HighlightDisplayKey register(@NonNls @NotNull String name, @NotNull String displayName) {
     return register(name, displayName, name);
   }
 
-  public static String getDisplayNameByKey(HighlightDisplayKey key){
-    return ourKeyToDisplayNameMap.get(key);
+  public static String getDisplayNameByKey(@Nullable HighlightDisplayKey key){
+    return key == null ? null : ourKeyToDisplayNameMap.get(key);
   }
 
-  private HighlightDisplayKey(String name) {
+  private HighlightDisplayKey(@NotNull String name) {
     this(name, name);
   }
 
-  public HighlightDisplayKey(@NonNls final String name, @NonNls final String ID) {
+  public HighlightDisplayKey(@NonNls @NotNull final String name, @NotNull @NonNls final String ID) {
     myName = name;
     myID = ID;
-    ourMap.put(myName, this);
+    ourNameToKeyMap.put(myName, this);
+    if (!Comparing.equal(ID, name)) {
+      ourIdToKeyMap.put(ID, this);
+    }
   }
 
   public String toString() {
@@ -84,7 +98,7 @@ public class HighlightDisplayKey {
     return myID;
   }
 
-  public static HighlightDisplayKey register(String shortName, String displayName, String id, String alternativeID) {
+  public static HighlightDisplayKey register(@NotNull String shortName, @NotNull String displayName, @NotNull String id, String alternativeID) {
     final HighlightDisplayKey key = register(shortName, displayName, id);
     if (alternativeID != null) {
       ourKeyToAlternativeIDMap.put(key, alternativeID);
@@ -92,7 +106,7 @@ public class HighlightDisplayKey {
     return key;
   }
 
-  public static String getAlternativeID(HighlightDisplayKey key) {
+  public static String getAlternativeID(@NotNull HighlightDisplayKey key) {
     return ourKeyToAlternativeIDMap.get(key);
   }
 }
index 1ad81e1e66a3b83b3cc2c5d6cc7f1ddad0188f3a..8babfe7f402bb276cac77056cc43ee8736223989 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.execution;
 
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
+import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiElement;
@@ -79,4 +80,7 @@ public abstract class Location<E extends PsiElement> {
   public PsiLocation<E> toPsiLocation() {
     return new PsiLocation<E>(getProject(), getPsiElement());
   }
+
+  @Nullable
+  public abstract Module getModule();
 }
index 42f161a9f404cbca51c49a45705f93c7e3ba4327..27fe3f61e94413ffd29e93d77789837957bce0f4 100644 (file)
@@ -16,6 +16,8 @@
 package com.intellij.execution;
 
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
@@ -28,10 +30,18 @@ public class PsiLocation<E extends PsiElement> extends Location<E> {
   private static final Logger LOG = Logger.getInstance("#com.intellij.execution.PsiLocation");
   private final E myPsiElement;
   private final Project myProject;
+  private final Module myModule;
 
   public PsiLocation(@NotNull final Project project, @NotNull final E psiElement) {
     myPsiElement = psiElement;
     myProject = project;
+    myModule = ModuleUtil.findModuleForPsiElement(psiElement);
+  }
+
+  public PsiLocation(Project project, Module module, E psiElement) {
+    myPsiElement = psiElement;
+    myProject = project;
+    myModule = module;
   }
 
   @NotNull
@@ -44,6 +54,11 @@ public class PsiLocation<E extends PsiElement> extends Location<E> {
     return myProject;
   }
 
+  @Override
+  public Module getModule() {
+    return myModule;
+  }
+
   @NotNull
   public <T extends PsiElement> Iterator<Location<T>> getAncestors(final Class<T> ancestorClass, final boolean strict) {
     final T first;
@@ -87,8 +102,12 @@ public class PsiLocation<E extends PsiElement> extends Location<E> {
   }
 
   public static <T extends PsiElement> Location<T> fromPsiElement(final T element) {
+    return fromPsiElement(element, null);
+  }
+
+  public static <T extends PsiElement> Location<T> fromPsiElement(T element, Module module) {
     if (element == null) return null;
     if (!element.isValid()) return null;
-    return new PsiLocation<T>(element.getProject(), element);
+    return module != null ? new PsiLocation<T>(element.getProject(), module, element) : new PsiLocation<T>(element.getProject(), element);
   }
 }
index c606eef5f6ddd9c106142feee410eed04ef41fdb..834f6772f29da83a48de4e228bd08031c0fbfeab 100644 (file)
@@ -19,6 +19,7 @@ package com.intellij.psi.impl.include;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileSystemItem;
 import org.jetbrains.annotations.Nullable;
 
@@ -36,5 +37,5 @@ public abstract class FileIncludeManager {
   public abstract VirtualFile[] getIncludingFiles(VirtualFile file, boolean compileTimeOnly);
 
   @Nullable
-  public abstract PsiFileSystemItem resolveFileReference(String text, VirtualFile context);
+  public abstract PsiFileSystemItem resolveFileReference(String text, PsiFile context);
 }
index 2a7012fca87ab98fa00bae0a7feb909ed3293475..9689bc84db94e96356ef1d92f7281e0e81e0c855 100644 (file)
@@ -146,7 +146,7 @@ class PrintDialog extends DialogWrapper {
   }
 
   protected JComponent createCenterPanel() {
-    TabbedPaneWrapper tabbedPaneWrapper = new TabbedPaneWrapper();
+    TabbedPaneWrapper tabbedPaneWrapper = new TabbedPaneWrapper(myDisposable);
     tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.settings.tab"), createPrintSettingsPanel());
     tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.header.footer.tab"), createHeaderAndFooterPanel());
     tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.advanced.tab"), createAdvancedPanel());
index 1ef0a90b418431527ebe085c407407895e18ca7a..9909a3dfb5fd7d31209bf875a81f8b0e82c1206b 100644 (file)
@@ -131,8 +131,9 @@ public class InspectionProfileConvertor {
     return rootElement;
   }
 
-  private void renameOldDefaultsProfile() {
-    final File profileDirectory = myManager.getProfileDirectory();
+  private static void renameOldDefaultsProfile() {
+    final File profileDirectory = InspectionProfileManager.getProfileDirectory();
+    if (profileDirectory == null) return;
     final File[] files = profileDirectory.listFiles(new FileFilter() {
       public boolean accept(File pathname) {
         return pathname.getPath().endsWith(File.separator + DEFAULT_XML);
index f31c8c90b265f2e198b2422216a31f831deb35af..7ce05c83a03b68d813401fb13bba78d1343970e9 100644 (file)
@@ -20,10 +20,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.IntentionManager;
-import com.intellij.codeInspection.CustomSuppressableInspectionTool;
-import com.intellij.codeInspection.InspectionProfileEntry;
-import com.intellij.codeInspection.LocalInspectionTool;
-import com.intellij.codeInspection.ProblemHighlightType;
+import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.actions.CleanupInspectionIntention;
 import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
 import com.intellij.codeInspection.ex.QuickFixWrapper;
@@ -391,9 +388,14 @@ public class HighlightInfo {
     public List<IntentionAction> getOptions(@NotNull PsiElement element) {
       if (myOptions == null && myKey != null) {
         List<IntentionAction> options = IntentionManager.getInstance().getStandardIntentionOptions(myKey, element);
-        final InspectionProfileEntry tool = InspectionProjectProfileManager.getInstance(element.getProject())
-          .getInspectionProfile()
-          .getInspectionTool(myKey.toString(), element);
+        InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getInspectionProfile();
+        InspectionProfileEntry tool = profile.getInspectionTool(myKey.toString(), element);
+        if (!(tool instanceof LocalInspectionToolWrapper)) {
+          HighlightDisplayKey key = HighlightDisplayKey.findById(myKey.toString());
+          if (key != null) {
+            tool = profile.getInspectionTool(key.toString(), element);
+          }
+        }
         if (tool instanceof LocalInspectionToolWrapper) {
           final LocalInspectionTool localInspectionTool = ((LocalInspectionToolWrapper)tool).getTool();
           Class aClass = myAction.getClass();
index d3ae32d304d3fa88a4def366b44137d54d8ab6a5..e2fe36e585cdcee45b9a259afb4b63602ba461ef 100644 (file)
@@ -161,7 +161,7 @@ public class IntentionManagerImpl extends IntentionManager {
     return result;
   }
 
-  public List<IntentionAction> getStandardIntentionOptions(@NotNull final HighlightDisplayKey displayKey, final PsiElement context) {
+  public List<IntentionAction> getStandardIntentionOptions(@NotNull final HighlightDisplayKey displayKey, @NotNull final PsiElement context) {
     List<IntentionAction> options = new ArrayList<IntentionAction>(9);
     options.add(new EditInspectionToolsSettingsAction(displayKey));
     options.add(new RunInspectionIntention(displayKey));
index 213a762273a5ae5d861d606d053b8d7e5a3dd16c..a7deb1f9bdb56f5cebece1aaae4e6a167ed0ba95 100644 (file)
@@ -19,15 +19,21 @@ package com.intellij.codeInsight.navigation;
 import com.intellij.ide.util.DefaultPsiElementCellRenderer;
 import com.intellij.ide.util.EditSourceUtil;
 import com.intellij.ide.util.PsiElementListCellRenderer;
+import com.intellij.navigation.NavigationItem;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.TextEditor;
 import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.openapi.ui.popup.PopupChooserBuilder;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.Navigatable;
 import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
 import com.intellij.psi.search.PsiElementProcessor;
-import com.intellij.ui.awt.RelativePoint;
 
 import javax.swing.*;
-import java.awt.event.MouseEvent;
 
 /**
  * @author ven
@@ -79,7 +85,38 @@ public final class NavigationUtil {
     return builder.setItemChoosenCallback(runnable).createPopup();
   }
 
-  public static void showPsiElementPopup(PsiElement[] elements, String title, MouseEvent event) {
-    getPsiElementPopup(elements, title).show(new RelativePoint(event));
+  public static void activateFileWithPsiElement(PsiElement elt) {
+    if (!activatePsiElementIfOpen(elt)) {
+      ((NavigationItem)elt).navigate(true);
+    }
+  }
+
+  private static boolean activatePsiElementIfOpen(PsiElement elt) {
+    final PsiFile file = elt.getContainingFile();
+    if (file == null || !file.isValid()) return false;
+
+    VirtualFile vFile = file.getVirtualFile();
+    if (vFile == null) return false;
+
+    final FileEditorManager fem = FileEditorManager.getInstance(elt.getProject());
+    if (!fem.isFileOpen(vFile)) return false;
+
+    final TextRange range = elt.getTextRange();
+    if (range == null) return false;
+
+    final FileEditor[] editors = fem.getEditors(vFile);
+    for (FileEditor editor : editors) {
+      if (editor instanceof TextEditor) {
+        final Editor text = ((TextEditor)editor).getEditor();
+        final int offset = text.getCaretModel().getOffset();
+
+        if (range.contains(offset)) {
+          fem.openFile(vFile, true);
+          return true;
+        }
+      }
+    }
+
+    return false;
   }
 }
index d367e751847d6bd4d203bf1f8482cb42c1b43402..608c0f3c9852dccba21a9e7850e152c4d60aa557 100644 (file)
@@ -112,7 +112,7 @@ public class InspectionApplication {
       }
 
       logMessage(1, InspectionsBundle.message("inspection.application.opening.project"));
-      if (!ConversionService.getInstance().convertSilently(myProjectPath, createConversionListener())) {
+      if (ConversionService.getInstance().convertSilently(myProjectPath, createConversionListener()).openingIsCanceled()) {
         if (myErrorCodeRequired) System.exit(1);
         return;
       }
index 2c8f98c85e778772eba176b747e535bcbce6e2a0..8f3eb70f965ce1df5a72e6504fa5ec7ad95dccb2 100644 (file)
@@ -168,9 +168,10 @@ public class ToolsImpl implements Tools {
           final InspectionProfileEntry copyTool =
             ((InspectionProfileImpl)profile).myRegistrar.createInspectionTool(myShortName, tool);
           copyTool.readSettings(scopeElement);
-          HighlightDisplayLevel scopeLevel = level;
-          if (errorLevel != null){
-            scopeLevel = HighlightDisplayLevel.find(((SeverityProvider)profileManager).getOwnSeverityRegistrar().getSeverity(errorLevel));
+          HighlightDisplayLevel scopeLevel = errorLevel != null ?
+             HighlightDisplayLevel.find(((SeverityProvider)profileManager).getOwnSeverityRegistrar().getSeverity(errorLevel)) : null;
+          if (scopeLevel == null) {
+            scopeLevel = level;
           }
           if (namedScope != null) {
             addTool(namedScope, copyTool, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
diff --git a/platform/lang-impl/src/com/intellij/conversion/ConversionResult.java b/platform/lang-impl/src/com/intellij/conversion/ConversionResult.java
new file mode 100644 (file)
index 0000000..d311faa
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.conversion;
+
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public interface ConversionResult {
+  boolean conversionNotNeeded();
+
+  boolean openingIsCanceled();
+
+  void postStartupActivity(@NotNull Project project);
+}
index 59bce0763247f49d2368f6adef6d3cd5c87e17d0..4c79b51b86c745347775d863a6256ef96c46f6cc 100644 (file)
@@ -31,11 +31,15 @@ public abstract class ConversionService {
     return ServiceManager.getService(ConversionService.class);
   }
 
-  public abstract boolean convertSilently(@NotNull String projectPath);
+  @NotNull
+  public abstract ConversionResult convertSilently(@NotNull String projectPath);
 
-  public abstract boolean convertSilently(@NotNull String projectPath, @NotNull ConversionListener conversionListener);
+  @NotNull
+  public abstract ConversionResult convertSilently(@NotNull String projectPath, @NotNull ConversionListener conversionListener);
 
-  public abstract boolean convert(@NotNull String projectPath);
+  @NotNull
+  public abstract ConversionResult convert(@NotNull String projectPath);
 
-  public abstract boolean convertModule(@NotNull Project project, @NotNull File moduleFile);
+  @NotNull
+  public abstract ConversionResult convertModule(@NotNull Project project, @NotNull File moduleFile);
 }
index 808dd94dd18537a034f99ae5590c73df85fb3570..681ce6a709ce9489da0359f9b1242ad9d7357505 100644 (file)
@@ -50,6 +50,10 @@ public abstract class ProjectConverter {
     return Collections.emptyList();
   }
 
+  public Collection<File> getCreatedFiles() {
+    return Collections.emptyList();
+  }
+
   public void preProcessingFinished() throws CannotConvertException {
   }
 
diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionResultImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionResultImpl.java
new file mode 100644 (file)
index 0000000..78413a3
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.conversion.impl;
+
+import com.intellij.conversion.ConversionResult;
+import com.intellij.openapi.application.Application;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.AbstractVcsHelper;
+import com.intellij.openapi.vcs.VcsShowConfirmationOptionImpl;
+import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
+import com.intellij.openapi.vcs.changes.actions.EditAction;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+import java.util.*;
+
+/**
+ * @author nik
+ */
+public class ConversionResultImpl implements ConversionResult {
+  public static final ConversionResultImpl CONVERSION_NOT_NEEDED = new ConversionResultImpl(false, false, false);
+  public static final ConversionResultImpl CONVERSION_CANCELED = new ConversionResultImpl(true, true, false);
+  public static final ConversionResultImpl ERROR_OCCURRED = new ConversionResultImpl(true, false, true);
+  private boolean myConversionNeeded;
+  private boolean myConversionCanceled;
+  private boolean myErrorOccurred;
+  private Set<File> myChangedFiles = new HashSet<File>();
+  private Set<File> myCreatedFiles = new HashSet<File>();
+
+  public ConversionResultImpl(boolean conversionNeeded, boolean conversionCanceled, boolean errorOccurred) {
+    myConversionNeeded = conversionNeeded;
+    myConversionCanceled = conversionCanceled;
+    myErrorOccurred = errorOccurred;
+  }
+
+  public ConversionResultImpl(List<ConversionRunner> converters) {
+    this(true, false, false);
+    for (ConversionRunner converter : converters) {
+      myChangedFiles.addAll(converter.getAffectedFiles());
+      myCreatedFiles.addAll(converter.getCreatedFiles());
+    }
+  }
+
+  public boolean conversionNotNeeded() {
+    return !myConversionNeeded;
+  }
+
+  public boolean openingIsCanceled() {
+    return myConversionCanceled || myErrorOccurred;
+  }
+
+  public void postStartupActivity(@NotNull Project project) {
+    final Application application = ApplicationManager.getApplication();
+    if (application.isHeadlessEnvironment() || application.isUnitTestMode()) {
+      return;
+    }
+
+    List<VirtualFile> changedFiles = findVirtualFiles(myChangedFiles);
+    if (!changedFiles.isEmpty()) {
+      EditAction.editFilesAndShowErrors(project, changedFiles);
+    }
+
+    final List<VirtualFile> createdFiles = findVirtualFiles(myCreatedFiles);
+    if (!createdFiles.isEmpty()) {
+      final VcsShowConfirmationOptionImpl option = new VcsShowConfirmationOptionImpl("", "", "", "", "");
+      final Collection<VirtualFile> selected = AbstractVcsHelper.getInstance(project)
+        .selectFilesToProcess(createdFiles, "Files Created", "Select files to be added to version control", null, null, option);
+      if (selected != null && !selected.isEmpty()) {
+        final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(project);
+        changeListManager.addUnversionedFiles(changeListManager.getDefaultChangeList(), new ArrayList<VirtualFile>(selected));
+      }
+    }
+  }
+
+  private static List<VirtualFile> findVirtualFiles(Collection<File> ioFiles) {
+    List<VirtualFile> files = new ArrayList<VirtualFile>();
+    for (File file : ioFiles) {
+      ContainerUtil.addIfNotNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file), files);
+    }
+    return files;
+  }
+}
index 38ebf2f849f0e388e47cac1861d1f8ed2ebd9a6d..20ba88d3454a861ef81bf3623b25460e2b078bc2 100644 (file)
@@ -73,6 +73,10 @@ public class ConversionRunner {
     return myModuleFileConverter != null && myModuleFileConverter.isConversionNeeded(myContext.getModuleSettings(moduleFile));
   }
 
+  public Collection<File> getCreatedFiles() {
+    return myConverter.getCreatedFiles();
+  }
+
   public Set<File> getAffectedFiles() {
     Set<File> affectedFiles = new HashSet<File>();
     if (myProcessProjectFile) {
index e6a54544f19dde5bd11ae82e271300eca527bbdf..6b40da9c5dd4d4241c4048c0e9c6b44f07da9253 100644 (file)
 
 package com.intellij.conversion.impl;
 
-import com.intellij.conversion.CannotConvertException;
-import com.intellij.conversion.ConversionListener;
-import com.intellij.conversion.ConversionService;
-import com.intellij.conversion.ConverterProvider;
+import com.intellij.conversion.*;
 import com.intellij.conversion.impl.ui.ConvertProjectDialog;
 import com.intellij.ide.IdeBundle;
 import com.intellij.openapi.application.PathManager;
@@ -53,8 +50,9 @@ import java.util.*;
 public class ConversionServiceImpl extends ConversionService {
   private static final Logger LOG = Logger.getInstance("#com.intellij.conversion.impl.ConversionServiceImpl");
 
+  @NotNull
   @Override
-  public boolean convertSilently(@NotNull String projectPath) {
+  public ConversionResult convertSilently(@NotNull String projectPath) {
     return convertSilently(projectPath, new ConversionListener() {
       public void conversionNeeded() {
       }
@@ -70,11 +68,12 @@ public class ConversionServiceImpl extends ConversionService {
     });
   }
 
+  @NotNull
   @Override
-  public boolean convertSilently(@NotNull String projectPath, @NotNull ConversionListener listener) {
+  public ConversionResult convertSilently(@NotNull String projectPath, @NotNull ConversionListener listener) {
     try {
       if (!isConversionNeeded(projectPath)) {
-        return true;
+        return ConversionResultImpl.CONVERSION_NOT_NEEDED;
       }
 
       listener.conversionNeeded();
@@ -89,7 +88,7 @@ public class ConversionServiceImpl extends ConversionService {
       final List<File> readOnlyFiles = ConversionRunner.getReadOnlyFiles(affectedFiles);
       if (!readOnlyFiles.isEmpty()) {
         listener.cannotWriteToFiles(readOnlyFiles);
-        return false;
+        return ConversionResultImpl.ERROR_OCCURRED;
       }
       final File backupDir = ProjectConversionUtil.backupFiles(affectedFiles, context.getProjectBaseDir());
       for (ConversionRunner runner : runners) {
@@ -100,7 +99,7 @@ public class ConversionServiceImpl extends ConversionService {
       context.saveFiles(affectedFiles);
       listener.successfullyConverted(backupDir);
       saveConversionResult(context);
-      return true;
+      return new ConversionResultImpl(runners);
     }
     catch (CannotConvertException e) {
       listener.error(e.getMessage());
@@ -108,14 +107,15 @@ public class ConversionServiceImpl extends ConversionService {
     catch (IOException e) {
       listener.error(e.getMessage());
     }
-    return false;
+    return ConversionResultImpl.ERROR_OCCURRED;
   }
 
+  @NotNull
   @Override
-  public boolean convert(@NotNull String projectPath) {
+  public ConversionResult convert(@NotNull String projectPath) {
     try {
       if (!isConversionNeeded(projectPath)) {
-        return true;
+        return ConversionResultImpl.CONVERSION_NOT_NEEDED;
       }
 
       final ConversionContextImpl context = new ConversionContextImpl(projectPath);
@@ -124,19 +124,19 @@ public class ConversionServiceImpl extends ConversionService {
       dialog.show();
       if (dialog.isConverted()) {
         saveConversionResult(context);
-        return true;
+        return new ConversionResultImpl(converters);
       }
-      return false;
+      return ConversionResultImpl.CONVERSION_CANCELED;
     }
     catch (CannotConvertException e) {
       LOG.info(e);
       Messages.showErrorDialog(IdeBundle.message("error.cannot.convert.project", e.getMessage()),
                                IdeBundle.message("title.cannot.convert.project"));
-      return false;
+      return ConversionResultImpl.ERROR_OCCURRED;
     }
   }
 
-  private List<ConversionRunner> getConversionRunners(ConversionContextImpl context) throws CannotConvertException {
+  private static List<ConversionRunner> getConversionRunners(ConversionContextImpl context) throws CannotConvertException {
     final List<ConversionRunner> converters = getSortedConverters(context);
     final Iterator<ConversionRunner> iterator = converters.iterator();
 
@@ -153,7 +153,7 @@ public class ConversionServiceImpl extends ConversionService {
     return converters;
   }
 
-  public boolean isConversionNeeded(String projectPath) throws CannotConvertException {
+  public static boolean isConversionNeeded(String projectPath) throws CannotConvertException {
     final ConversionContextImpl context = new ConversionContextImpl(projectPath);
     final List<ConversionRunner> runners = getSortedConverters(context);
     if (runners.isEmpty()) {
@@ -168,7 +168,7 @@ public class ConversionServiceImpl extends ConversionService {
     return false;
   }
 
-  private List<ConversionRunner> getSortedConverters(final ConversionContextImpl context) throws CannotConvertException {
+  private static List<ConversionRunner> getSortedConverters(final ConversionContextImpl context) throws CannotConvertException {
     final CachedConversionResult conversionResult = loadCachedConversionResult(context.getProjectFile());
     final Map<String, Long> oldMap = conversionResult.myProjectFilesTimestamps;
     Map<String, Long> newMap = getProjectFilesMap(context);
@@ -209,7 +209,7 @@ public class ConversionServiceImpl extends ConversionService {
     return map;
   }
 
-  private List<ConversionRunner> createConversionRunners(ConversionContextImpl context, final Set<String> performedConversionIds) {
+  private static List<ConversionRunner> createConversionRunners(ConversionContextImpl context, final Set<String> performedConversionIds) {
     List<ConversionRunner> runners = new ArrayList<ConversionRunner>();
     final ConverterProvider[] providers = ConverterProvider.EP_NAME.getExtensions();
     for (ConverterProvider provider : providers) {
@@ -232,7 +232,7 @@ public class ConversionServiceImpl extends ConversionService {
     return runners;
   }
 
-  public void saveConversionResult(String projectPath) {
+  public static void saveConversionResult(String projectPath) {
     try {
       saveConversionResult(new ConversionContextImpl(projectPath));
     }
@@ -241,14 +241,14 @@ public class ConversionServiceImpl extends ConversionService {
     }
   }
 
-  private void saveConversionResult(ConversionContextImpl context) {
+  private static void saveConversionResult(ConversionContextImpl context) {
     final CachedConversionResult conversionResult = new CachedConversionResult();
     for (ConverterProvider provider : ConverterProvider.EP_NAME.getExtensions()) {
       conversionResult.myAppliedConverters.add(provider.getId());
     }
     conversionResult.myProjectFilesTimestamps = getProjectFilesMap(context);
     final File infoFile = getConversionInfoFile(context.getProjectFile());
-    infoFile.getParentFile().mkdirs();
+    FileUtil.createParentDirs(infoFile);
     try {
       JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(conversionResult)), infoFile, SystemProperties.getLineSeparator());
     }
@@ -258,7 +258,7 @@ public class ConversionServiceImpl extends ConversionService {
   }
 
   @NotNull
-  private CachedConversionResult loadCachedConversionResult(File projectFile) {
+  private static CachedConversionResult loadCachedConversionResult(File projectFile) {
     try {
       final File infoFile = getConversionInfoFile(projectFile);
       if (!infoFile.exists()) {
@@ -274,28 +274,29 @@ public class ConversionServiceImpl extends ConversionService {
     }
   }
 
-  private File getConversionInfoFile(@NotNull File projectFile) {
+  private static File getConversionInfoFile(@NotNull File projectFile) {
     String dirName = PathUtil.suggestFileName(projectFile.getName() + Integer.toHexString(projectFile.getAbsolutePath().hashCode()));
     return new File(PathManager.getSystemPath() + File.separator + "conversion" + File.separator + dirName + ".xml");
   }
 
-  public boolean convertModule(@NotNull final Project project, @NotNull final File moduleFile) {
+  @NotNull
+  public ConversionResult convertModule(@NotNull final Project project, @NotNull final File moduleFile) {
     final IProjectStore stateStore = ((ProjectImpl)project).getStateStore();
     String projectPath = FileUtil.toSystemDependentName(stateStore.getLocation());
 
     if (!isConversionNeeded(projectPath, moduleFile)) {
-      return true;
+      return ConversionResultImpl.CONVERSION_NOT_NEEDED;
     }
 
     final int res = Messages.showYesNoDialog(project, IdeBundle.message("message.module.file.has.an.older.format.do.you.want.to.convert.it"),
                                              IdeBundle.message("dialog.title.convert.module"), Messages.getQuestionIcon());
     if (res != 0) {
-      return false;
+      return ConversionResultImpl.CONVERSION_CANCELED;
     }
     if (!moduleFile.canWrite()) {
       Messages.showErrorDialog(project, IdeBundle.message("error.message.cannot.modify.file.0", moduleFile.getAbsolutePath()),
                                IdeBundle.message("dialog.title.convert.module"));
-      return false;
+      return ConversionResultImpl.ERROR_OCCURRED;
     }
 
     try {
@@ -310,18 +311,20 @@ public class ConversionServiceImpl extends ConversionService {
       context.saveFiles(Collections.singletonList(moduleFile));
       Messages.showInfoMessage(project, IdeBundle.message("message.your.module.was.succesfully.converted.br.old.version.was.saved.to.0", backupFile.getAbsolutePath()),
                                IdeBundle.message("dialog.title.convert.module"));
-      return true;
+      return new ConversionResultImpl(runners);
     }
     catch (CannotConvertException e) {
+      LOG.info(e);
       Messages.showErrorDialog(IdeBundle.message("error.cannot.load.project", e.getMessage()), "Cannot Convert Module");
-      return false;
+      return ConversionResultImpl.ERROR_OCCURRED;
     }
     catch (IOException e) {
-      return false;
+      LOG.info(e);
+      return ConversionResultImpl.ERROR_OCCURRED;
     }
   }
 
-  private boolean isConversionNeeded(String projectPath, File moduleFile) {
+  private static boolean isConversionNeeded(String projectPath, File moduleFile) {
     try {
       ConversionContextImpl context = new ConversionContextImpl(projectPath);
       final List<ConversionRunner> runners = createConversionRunners(context, Collections.<String>emptySet());
@@ -349,7 +352,7 @@ public class ConversionServiceImpl extends ConversionService {
     public Map<String, Long> myProjectFilesTimestamps = new HashMap<String, Long>();
   }
 
-  private class ConverterProvidersGraph implements GraphGenerator.SemiGraph<ConverterProvider> {
+  private static class ConverterProvidersGraph implements GraphGenerator.SemiGraph<ConverterProvider> {
     private final ConverterProvider[] myProviders;
 
     public ConverterProvidersGraph(ConverterProvider[] providers) {
index cab0e613460ffd71be11afb4d6cfc2c838b714fb..5cc0e0137d47472b02384b3a057e69d493004f04 100644 (file)
@@ -71,7 +71,7 @@ public class ConfigurationContext {
       myLocation = null;
       return;
     }
-    myLocation = new PsiLocation<PsiElement>(project, element);
+    myLocation = new PsiLocation<PsiElement>(project, myModule, element);
   }
 
   public RunnerAndConfigurationSettingsImpl getConfiguration() {
index af7b866bed13e90cd5fd5add2c2ac5c42d2c2ea4..a6abff4db54025818b6ca6384902b7afe7d940c5 100644 (file)
@@ -329,7 +329,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
     mySelectedConfiguration = configuration;
   }
 
-  public static boolean canRunConfiguration(@NotNull final RunnerAndConfigurationSettingsImpl configuration, final @NotNull Executor executor) {
+  public static boolean canRunConfiguration(@NotNull final RunnerAndConfigurationSettingsImpl configuration, @NotNull final Executor executor) {
     try {
       configuration.checkSettings(executor);
     }
@@ -755,14 +755,16 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
   private Map<Key<? extends BeforeRunTask>, BeforeRunTaskProvider> myBeforeStepsMap;
   private Map<String, Key<? extends BeforeRunTask>> myProviderKeysMap;
 
-  private synchronized @NotNull BeforeRunTaskProvider getProvider(Key<? extends BeforeRunTask> providerId) {
+  @NotNull
+  private synchronized BeforeRunTaskProvider getProvider(Key<? extends BeforeRunTask> providerId) {
     if (myBeforeStepsMap == null) {
       initProviderMaps();
     }
     return myBeforeStepsMap.get(providerId);
   }
 
-  private synchronized @NotNull Key<? extends BeforeRunTask> getProviderKey(String keyString) {
+  @NotNull
+  private synchronized Key<? extends BeforeRunTask> getProviderKey(String keyString) {
     if (myProviderKeysMap == null) {
       initProviderMaps();
     }
index bd9078cd8b21a52da377053f59f3e27c812e7341..58922126a6673baff56c7bd853fb297d1d5ec407 100644 (file)
@@ -35,10 +35,10 @@ class TypeTemplatesConfigurable implements Configurable {
   private final Configurable[] myConfigurables;
   private TabbedPaneWrapper myTabbedPane;
 
-  public TypeTemplatesConfigurable(final ConfigurationType type, final RunManagerImpl runManager) {
+  public TypeTemplatesConfigurable(final ConfigurationType type, final RunManagerImpl runManager, Project project) {
     myType = type;
     myConfigurables = new Configurable[getFactories().length];
-    myTabbedPane = new TabbedPaneWrapper();
+    myTabbedPane = new TabbedPaneWrapper(project);
     final ConfigurationFactory[] factories = getFactories();
     for (int i = 0; i < factories.length; i++) {
       final ConfigurationFactory factory = factories[i];
@@ -103,7 +103,7 @@ class TypeTemplatesConfigurable implements Configurable {
     final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
     return factories.length == 1
            ? new TemplateConfigurable(runManager.getConfigurationTemplate(factories[0]))
-           : new TypeTemplatesConfigurable(type, runManager);
+           : new TypeTemplatesConfigurable(type, runManager, project);
   }
 
   private static class TemplateConfigurable extends SettingsEditorConfigurable<RunnerAndConfigurationSettingsImpl> {
index 54c9843749a157e74c93f645391f1d6701618c12..7577ecf2ae30b8b10ac14afa3ccd265494e36435 100644 (file)
@@ -50,7 +50,7 @@ public abstract class RuntimeConfigurationProducer implements Comparable {
 
     if (result.myConfiguration != null) {
       final PsiElement psiElement = result.getSourceElement();
-      final Location<PsiElement> _location = PsiLocation.fromPsiElement(psiElement);
+      final Location<PsiElement> _location = PsiLocation.fromPsiElement(psiElement, location != null ? location.getModule() : null);
       if (_location != null) {
         // replace with existing configuration if any
         final ConfigurationType type = result.myConfiguration.getType();
index c6102811bbc0c44039f31d4dce03da6407a6a663..6d51e9ac9a31f39fe50117a63af678abf8f0fe02 100644 (file)
@@ -271,14 +271,14 @@ public class RunContentBuilder implements LogConsoleManager, Disposable  {
     myUi.removeContent(content, true);
   }
 
-  private class MyRunContentDescriptor extends RunContentDescriptor {
+  private static class MyRunContentDescriptor extends RunContentDescriptor {
     private final boolean myReuseProhibited;
-    private final Disposable[] myAdditionalDisposables;
+    private final Disposable myAdditionalDisposable;
 
-    public MyRunContentDescriptor(final RunProfile profile, final ExecutionResult executionResult, final boolean reuseProhibited, final JComponent component, final Disposable... additionalDisposables) {
+    public MyRunContentDescriptor(final RunProfile profile, final ExecutionResult executionResult, final boolean reuseProhibited, final JComponent component, @NotNull Disposable additionalDisposable) {
       super(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), component, profile.getName(), profile.getIcon());
       myReuseProhibited = reuseProhibited;
-      myAdditionalDisposables = additionalDisposables;
+      myAdditionalDisposable = additionalDisposable;
     }
 
     public boolean isContentReuseProhibited() {
@@ -286,9 +286,7 @@ public class RunContentBuilder implements LogConsoleManager, Disposable  {
     }
 
     public void dispose() {
-      for (final Disposable disposable : myAdditionalDisposables) {
-        Disposer.dispose(disposable);
-      }
+      Disposer.dispose(myAdditionalDisposable);
       super.dispose();
     }
   }
index 7aaf139c48f321f38d455464a8c8c88c8bd58c25..77089d104736b9db1e71f44c93ee2250da0c044e 100644 (file)
@@ -64,7 +64,7 @@ public class GridCellImpl implements GridCell, Disposable {
   private JBPopup myPopup;
   private boolean myDisposed;
 
-  public GridCellImpl(ViewContextEx context, GridImpl container, GridImpl.Placeholder placeholder, PlaceInGrid placeInGrid) {
+  public GridCellImpl(ViewContextEx context, @NotNull GridImpl container, GridImpl.Placeholder placeholder, PlaceInGrid placeInGrid) {
     myContext = context;
     myContainer = container;
 
index c225d56264e269d1a291edb03b44ed1d53077834..0326cc00909b30a73894ec9661aa5ee6eb804cfd 100644 (file)
@@ -29,7 +29,6 @@ public class RunnerLayoutUiFactoryImpl extends RunnerLayoutUi.Factory {
   }
 
   public RunnerLayoutUi create(@NotNull final String runnerType, @NotNull final String runnerTitle, @NotNull final String sessionName, @NotNull final Disposable parent) {
-    final RunnerLayoutUiImpl ui = new RunnerLayoutUiImpl(myProject, parent, runnerType, runnerTitle, sessionName);
-    return ui;
+    return new RunnerLayoutUiImpl(myProject, parent, runnerType, runnerTitle, sessionName);
   }
 }
index 1d7247387b57e27f23f45a9ebdd9c3d3f9a288c6..3af8318c75d1a97dd9d203b3675dcf35f8804e96 100644 (file)
@@ -31,7 +31,6 @@ import com.intellij.openapi.util.ActionCallback;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.wm.IdeFocusManager;
-import com.intellij.ui.FocusTrackback;
 import com.intellij.ui.content.Content;
 import com.intellij.ui.content.ContentFactory;
 import com.intellij.ui.content.ContentManager;
@@ -43,7 +42,6 @@ import javax.swing.*;
 import java.awt.*;
 
 public class RunnerLayoutUiImpl implements Disposable, RunnerLayoutUi, LayoutStateDefaults, LayoutViewOptions {
-  private final Project myProject;
   private final RunnerLayout myLayout;
   private final JPanel myContentPanel;
   private final RunnerContentUi myContentUI;
@@ -52,18 +50,15 @@ public class RunnerLayoutUiImpl implements Disposable, RunnerLayoutUi, LayoutSta
   public static final Key<String> CONTENT_TYPE = Key.create("ContentType");
 
   public RunnerLayoutUiImpl(Project project, Disposable parent, String runnerType, String runnerTitle, String sessionName) {
-    myProject = project;
     myLayout = RunnerLayoutSettings.getInstance().getLayout(runnerType);
     Disposer.register(parent, this);
 
-    myContentUI = new RunnerContentUi(myProject, this, ActionManager.getInstance(), IdeFocusManager.getInstance(myProject), myLayout,
+    myContentUI = new RunnerContentUi(project, this, ActionManager.getInstance(), IdeFocusManager.getInstance(project), myLayout,
                                            runnerTitle + " - " + sessionName);
 
-
     myContentPanel = new JPanel(new BorderLayout());
 
-    myViewsContentManager = getContentFactory().
-      createContentManager(myContentUI.getContentUI(), false, myProject);
+    myViewsContentManager = getContentFactory().createContentManager(myContentUI.getContentUI(), false, project);
     Disposer.register(this, myViewsContentManager);
 
     myContentPanel.add(myViewsContentManager.getComponent(), BorderLayout.CENTER);
index fc4c29f45a799f4cfce0501e5563aacef32bc8ff..8422a9efde361648591cfd786c659b4a541c59cc 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.intellij.ide.actions;
 
+import com.intellij.codeInsight.navigation.NavigationUtil;
 import com.intellij.featureStatistics.FeatureUsageTracker;
 import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
 import com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent;
@@ -29,6 +30,7 @@ import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiElement;
 
 public class GotoClassAction extends GotoActionBase implements DumbAware {
   public void gotoActionPerformed(AnActionEvent e) {
@@ -53,7 +55,12 @@ public class GotoClassAction extends GotoActionBase implements DumbAware {
       }
 
       public void elementChosen(Object element) {
-        ((NavigationItem)element).navigate(true);
+        if (element instanceof PsiElement) {
+          NavigationUtil.activateFileWithPsiElement((PsiElement)element);
+        }
+        else {
+          ((NavigationItem)element).navigate(true);
+        }
       }
     }, ModalityState.current(), true);
   }
@@ -61,4 +68,4 @@ public class GotoClassAction extends GotoActionBase implements DumbAware {
   protected boolean hasContributors() {
     return ChooseByNameRegistry.getInstance().getClassModelContributors().length > 0;
   }
-}
\ No newline at end of file
+}
index e672c21aafdf35b3d3317cf6a85cefdb0dc45ed3..1632fbac6f7ddd935670621c8a6b7ecb8a32dde9 100644 (file)
@@ -23,10 +23,7 @@ import com.intellij.ide.structureView.StructureView;
 import com.intellij.ide.structureView.StructureViewBuilder;
 import com.intellij.ide.structureView.StructureViewWrapper;
 import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.ActionManager;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.actionSystem.TimerListener;
+import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.fileEditor.FileEditor;
 import com.intellij.openapi.fileEditor.FileEditorManager;
@@ -42,10 +39,12 @@ import com.intellij.openapi.wm.ToolWindow;
 import com.intellij.openapi.wm.ToolWindowId;
 import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
+import com.intellij.openapi.wm.impl.IdeRootPane;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.util.Alarm;
 import com.intellij.util.IJSwingUtilities;
 import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
@@ -66,6 +65,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
 
   private final JPanel myPanel;
   private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
+  private final String myKey = new String("DATA_SELECTOR");
 
   // -------------------------------------------------------------------------
   // Constructor
@@ -73,7 +73,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
 
   public StructureViewWrapperImpl(Project project) {
     myProject = project;
-    myPanel = new JPanel(new BorderLayout());
+    myPanel = new ContentPanel();
     myPanel.setBackground(UIUtil.getTreeTextBackground());
 
     ActionManager.getInstance().addTimerListener(500, new TimerListener() {
@@ -106,9 +106,11 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
 
     if (focusWindow == mywindow) {
       final Component owner = focusManager.getFocusOwner();
-      if (owner == null || SwingUtilities.isDescendingFrom(owner, myPanel)) return;
+      if (owner instanceof IdeRootPane) return;
 
       final DataContext dataContext = DataManager.getInstance().getDataContext(owner);
+      if (dataContext.getData(myKey) == this) return;
+
       final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
       if (files != null && files.length == 1) {
         setFile(files[0]);
@@ -254,4 +256,15 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
     // it means that window is registered
     return toolWindow != null && toolWindow.isVisible();
   }
+
+  private class ContentPanel extends JPanel implements DataProvider {
+    public ContentPanel() {
+      super(new BorderLayout());
+    }
+
+    public Object getData(@NonNls String dataId) {
+      if (dataId == myKey) return StructureViewWrapperImpl.this;
+      return null;
+    }
+  }
 }
index de2fa5fefb94ec7e8a1d445f933aef0d0f0574d0..ee2a386498bdccf7ce792e291be57da005b2f800 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.intellij.ide.impl.convert;
 
-import com.intellij.conversion.ConversionService;
 import com.intellij.conversion.impl.ConversionServiceImpl;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.components.*;
@@ -77,7 +76,7 @@ public class ProjectFileVersionImpl extends ProjectFileVersion implements Projec
       filePath = baseDir != null ? baseDir.getPath() : null;
     }
     if (filePath != null) {
-      ((ConversionServiceImpl)ConversionService.getInstance()).saveConversionResult(FileUtil.toSystemDependentName(filePath));
+      ConversionServiceImpl.saveConversionResult(FileUtil.toSystemDependentName(filePath));
     }
     else {
       LOG.info("Cannot save conversion result: filePath == null");
index fcdcac24422feb5f5297c435d0867e6424143623..bc3c7a7829952a025d960bdfac5854467833dae9 100644 (file)
@@ -24,7 +24,10 @@ import com.intellij.ide.util.treeView.NodeDescriptor;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.util.StatusBarProgress;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.ActionCallback;
+import com.intellij.openapi.util.AsyncResult;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.psi.PsiDirectory;
@@ -57,7 +60,7 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
   }
 
   protected boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
-    return nodeDescriptor.getParentDescriptor() == null;
+    return nodeDescriptor.getParentDescriptor() == null || ((AbstractTreeNode)nodeDescriptor).isAlwaysExpand();
   }
 
   protected final void expandNodeChildren(final DefaultMutableTreeNode node) {
index a1e5831efbc6d6eac4e46aa0720fc2bb994d3c42..4dd0e245524d5084f111b338b956590fd760f303 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
+import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.SimpleTextAttributes;
@@ -38,12 +39,18 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> {
       return;
     }
     presentation.setPresentableText(getValue().getName());
-    presentation.addText(getValue().getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
-    
+    if (showModuleNameInBold()) {
+      presentation.addText(getValue().getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
+    }
+
     presentation.setOpenIcon(getValue().getModuleType().getNodeIcon(true));
     presentation.setClosedIcon(getValue().getModuleType().getNodeIcon(false));
   }
 
+  protected boolean showModuleNameInBold() {
+    return true;
+  }
+
 
   public String getTestPresentation() {
     return "Module";
@@ -51,8 +58,17 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> {
 
   @Override
   public boolean contains(@NotNull VirtualFile file) {
+    final VirtualFile testee;
+    if (file.getFileSystem() instanceof JarFileSystem) {
+      testee = JarFileSystem.getInstance().getVirtualFileForJar(file);
+      if (testee == null) return false;
+    }
+    else {
+      testee = file;
+    }
+    
     for (VirtualFile root : ModuleRootManager.getInstance(getValue()).getContentRoots()) {
-      if (VfsUtil.isAncestor(root, file, false)) return true;
+      if (VfsUtil.isAncestor(root, testee, false)) return true;
     }
     return false;
   }
index 58ed145c44d73d6e96a8d8943748e8eb535c030f..1f6ddbfec8989c8f7ca67b11617460201906cf7b 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.intellij.ide.projectView.impl.nodes;
 
+import com.intellij.codeInsight.navigation.NavigationUtil;
 import com.intellij.ide.projectView.PresentationData;
 import com.intellij.ide.projectView.ProjectViewNode;
 import com.intellij.ide.projectView.ProjectViewNodeDecorator;
@@ -187,7 +188,12 @@ public abstract class AbstractPsiBasedNode<Value> extends ProjectViewNode<Value>
 
   public void navigate(boolean requestFocus) {
     if (canNavigate()) {
-      getNavigationItem().navigate(requestFocus);
+      if (requestFocus) {
+        NavigationUtil.activateFileWithPsiElement(extractPsiFromValue());
+      }
+      else {
+        getNavigationItem().navigate(requestFocus);
+      }
     }
   }
 
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleListNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleListNode.java
new file mode 100644 (file)
index 0000000..8339800
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.intellij.ide.projectView.impl.nodes;
+
+import com.intellij.ide.projectView.PresentationData;
+import com.intellij.ide.projectView.ProjectViewNode;
+import com.intellij.ide.projectView.ViewSettings;
+import com.intellij.ide.util.treeView.AbstractTreeNode;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.Icons;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class ModuleListNode extends ProjectViewNode<Module> {
+
+  public ModuleListNode(Project project, Module value, ViewSettings viewSettings) {
+    super(project, value, viewSettings);
+  }
+
+  public ModuleListNode(final Project project, final Object value, final ViewSettings viewSettings) {
+    this(project, (Module)value, viewSettings);
+  }
+
+  @NotNull
+  public Collection<AbstractTreeNode> getChildren() {
+    Module module = getValue();
+
+    final Module[] deps = ModuleRootManager.getInstance(module).getDependencies(true);
+    final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
+    for (Module dependency : deps) {
+      children.add(new ProjectViewModuleNode(myProject, dependency, getSettings()) {
+        @Override
+        protected boolean showModuleNameInBold() {
+          return false;
+        }
+      });
+    }
+
+    return children;
+  }
+
+
+  public String getTestPresentation() {
+    return "Modules";
+  }
+
+  public boolean contains(@NotNull VirtualFile file) {
+    return someChildContainsFile(file);
+  }
+
+  public void update(PresentationData presentation) {
+    presentation.setPresentableText("Module Dependencies");
+    presentation.setIcons(Icons.CLOSED_MODULE_GROUP_ICON);
+  }
+
+  public boolean canNavigate() {
+    return false;
+  }
+
+  public boolean canNavigateToSource() {
+    return false;
+  }
+
+  @Override
+  public boolean isAlwaysExpand() {
+    return true;
+  }
+}
index fc663a133279e6e7189a8f8f28aca50f7f75a6ed..fde7b58371888662af8b571ad47973fcfb7e3291 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.ide.projectView.impl.nodes;
 
 import com.intellij.ide.projectView.ViewSettings;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -29,8 +28,6 @@ import java.util.Collection;
 import java.util.List;
 
 public class StructureViewModuleNode extends AbstractModuleNode {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode");
-
   public StructureViewModuleNode(Project project, Module value, ViewSettings viewSettings) {
     super(project, value, viewSettings);
   }
@@ -38,7 +35,14 @@ public class StructureViewModuleNode extends AbstractModuleNode {
   @NotNull
   public Collection<AbstractTreeNode> getChildren() {
     final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(2);
-    children.add(new LibraryGroupNode(getProject(), new LibraryGroupElement(getValue()), getSettings()));
+    children.add(new LibraryGroupNode(getProject(), new LibraryGroupElement(getValue()), getSettings()) {
+      @Override
+      public boolean isAlwaysExpand() {
+        return true;
+      }
+    });
+
+    children.add(new ModuleListNode(getProject(), getValue(), getSettings()));
     return children;
   }
 
index 5ed15808a2b9c9731c43289d75a3a1701aac42ff..0e64e5c46f31f14bddef4326a373aeac439649ae 100644 (file)
@@ -168,6 +168,11 @@ public class PsiViewerDialog extends DialogWrapper {
     return "#com.intellij.internal.psiView.PsiViewerDialog";
   }
 
+  @Override
+  protected String getHelpId() {
+    return "reference.psi.viewer";
+  }
+
   public JComponent getPreferredFocusedComponent() {
     return myEditor.getContentComponent();
   }
@@ -258,7 +263,9 @@ public class PsiViewerDialog extends DialogWrapper {
     });
 
     myShowWhiteSpacesBox.setSelected(settings.showWhiteSpaces);
+    treeStructure.setShowWhiteSpaces(settings.showWhiteSpaces);
     myShowTreeNodesCheckBox.setSelected(settings.showTreeNodes);
+    treeStructure.setShowTreeNodes(settings.showTreeNodes);
 
     final ChoosePsiTypeButton typeButton = new ChoosePsiTypeButton();
     myButtonPanel.add(typeButton.createCustomComponent(myPresentation), BorderLayout.CENTER);
index c589a55e9f14a5e1aadc37e1cbe0882c6d8a1930..aa90849b85f79e7b3416fa62da7e8c9cb25be231 100644 (file)
@@ -504,11 +504,11 @@ public class ModuleRootManagerImpl extends ModuleRootManager implements ModuleCo
             final ArrayList<String> names1 = rootModel.processOrder(new RootPolicy<ArrayList<String>>() {
               public ArrayList<String> visitModuleOrderEntry(ModuleOrderEntry moduleOrderEntry, ArrayList<String> strings) {
                 final Module module = moduleOrderEntry.getModule();
-                if (module != null) {
+                if (module != null && !module.isDisposed()) {
                   strings.add(module.getName());
                 } else {
                   final Module moduleToBeRenamed = moduleModel.getModuleToBeRenamed(moduleOrderEntry.getModuleName());
-                  if (moduleToBeRenamed != null) {
+                  if (moduleToBeRenamed != null && !moduleToBeRenamed.isDisposed()) {
                     strings.add(moduleToBeRenamed.getName());
                   }
                 }
index c0bf408b4b2986f6dd1ef9ab00afb2b76a79855a..97962fb896941db9b1e2cd8ac72ae21aaca68e28 100644 (file)
@@ -342,6 +342,7 @@ public class InspectionProfileManager extends ApplicationProfileManager implemen
     mySchemesManager.addNewScheme(profile, true);
   }
 
+  @Nullable
   public static File getProfileDirectory() {
     String directoryPath = PathManager.getConfigPath() + File.separator + INSPECTION_DIR;
     File directory = new File(directoryPath);
index 49a3c4570d6d062ca5d5aa171add5cf05e773fb5..690684e9e5f25b69be2caf0d2a85ed88d5750025 100644 (file)
@@ -137,7 +137,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
             }
           }
           if (!levels.isEmpty()) {
-            if (Messages.showOkCancelDialog(myWholePanel, "Undefined severities detected: " +
+            if (Messages.showYesNoDialog(myWholePanel, "Undefined severities detected: " +
                                                           StringUtil.join(levels, ", ") +
                                                           ". Do you want to create them?", "Warning", Messages.getWarningIcon()) ==
                 DialogWrapper.OK_EXIT_CODE) {
index dab42858b3bfdbaad813ba5404f0334cbf95b77c..fea3861e633b3a8141e6ef5a12f351f80b6f3b0d 100644 (file)
@@ -40,7 +40,7 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
 
   private final FileIncludeProvider[] myProviders = Extensions.getExtensions(FileIncludeProvider.EP_NAME);
 
-  public static final ID<FileIncludeIndex.Key,List<FileIncludeInfoImpl>> INDEX_ID = ID.create("fileIncludes");
+  public static final ID<Key,List<FileIncludeInfoImpl>> INDEX_ID = ID.create("fileIncludes");
 
   public static List<FileIncludeInfoImpl> getIncludes(VirtualFile file, GlobalSearchScope scope) {
     final List<FileIncludeInfoImpl> result = new ArrayList<FileIncludeInfoImpl>();
@@ -64,7 +64,7 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
     return result;
   }
 
-  public ID<FileIncludeIndex.Key, List<FileIncludeInfoImpl>> getName() {
+  public ID<Key, List<FileIncludeInfoImpl>> getName() {
     return INDEX_ID;
   }
 
index 87e2fc582049a6bdad3cb97af50e791a1210752b..018363cd40edf065204191610a528dd672fb6183 100644 (file)
@@ -53,9 +53,9 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
 
   private final IncludeCacheHolder myIncludedHolder = new IncludeCacheHolder("compile time includes", "runtime includes") {
     @Override
-    protected VirtualFile[] computeFiles(VirtualFile file, boolean compileTimeOnly) {
+    protected VirtualFile[] computeFiles(PsiFile file, boolean compileTimeOnly) {
       GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
-      List<FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludes(file, scope);
+      List<FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludes(file.getVirtualFile(), scope);
       ArrayList<VirtualFile> files = new ArrayList<VirtualFile>();
       for (FileIncludeInfoImpl info : infoList) {
         if (compileTimeOnly && info.runtimeOnly) {
@@ -63,9 +63,9 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
         }
         FileIncludeProvider includeProvider = myProviderMap.get(info.providerId);
         if (includeProvider != null) {
-          VirtualFile virtualFile = includeProvider.resolveInclude(info, file, myProject);
+          PsiFileSystemItem virtualFile = includeProvider.resolveInclude(info, file, myProject);
           if (virtualFile != null) {
-            files.add(virtualFile);
+            files.add(virtualFile.getVirtualFile());
           }
         }
       }
@@ -75,14 +75,16 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
 
   private final IncludeCacheHolder myIncludingHolder = new IncludeCacheHolder("compile time contexts", "runtime contexts") {
     @Override
-    protected VirtualFile[] computeFiles(VirtualFile file, boolean compileTimeOnly) {
+    protected VirtualFile[] computeFiles(PsiFile file, boolean compileTimeOnly) {
       MultiMap<VirtualFile,FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludingFileCandidates(file.getName(), GlobalSearchScope.allScope(myProject));
       ArrayList<VirtualFile> files = new ArrayList<VirtualFile>();
       for (VirtualFile candidate : infoList.keySet()) {
+        PsiFile psiFile = myPsiManager.findFile(candidate);
+        if (psiFile == null) continue;
         for (FileIncludeInfoImpl info : infoList.get(candidate)) {
           FileIncludeProvider includeProvider = myProviderMap.get(info.providerId);
           if (includeProvider != null) {
-            if (file.equals(includeProvider.resolveInclude(info, candidate, myProject))) {
+            if (file.equals(includeProvider.resolveInclude(info, psiFile, myProject))) {
               files.add(candidate);
             }
           }
@@ -118,34 +120,29 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
   }
 
   @Override
-  public PsiFileSystemItem resolveFileReference(String text, VirtualFile context) {
+  public PsiFileSystemItem resolveFileReference(String text, PsiFile context) {
         
-    PsiFile originalFile = myPsiManager.findFile(context);
-    if (originalFile == null) {
-      return null;
-    }
-
     PsiFileImpl psiFile = (PsiFileImpl)myPsiFileFactory.createFileFromText("dummy.txt", text);
-    psiFile.setOriginalFile(originalFile);
+    psiFile.setOriginalFile(context);
 
     return new FileReferenceSet(psiFile).resolve();
   }
 
   private abstract class IncludeCacheHolder {
 
-    private final Key<ParameterizedCachedValue<VirtualFile[], VirtualFile>> COMPILE_TIME_KEY;
-    private final Key<ParameterizedCachedValue<VirtualFile[], VirtualFile>> RUNTIME_KEY;
+    private final Key<ParameterizedCachedValue<VirtualFile[], PsiFile>> COMPILE_TIME_KEY;
+    private final Key<ParameterizedCachedValue<VirtualFile[], PsiFile>> RUNTIME_KEY;
 
-    private final ParameterizedCachedValueProvider<VirtualFile[], VirtualFile> COMPILE_TIME_PROVIDER = new IncludedFilesProvider(false) {
+    private final ParameterizedCachedValueProvider<VirtualFile[], PsiFile> COMPILE_TIME_PROVIDER = new IncludedFilesProvider(false) {
       @Override
-      protected VirtualFile[] computeFiles(VirtualFile file, boolean compileTimeOnly) {
+      protected VirtualFile[] computeFiles(PsiFile file, boolean compileTimeOnly) {
         return IncludeCacheHolder.this.computeFiles(file, compileTimeOnly);
       }
     };
 
-    private final ParameterizedCachedValueProvider<VirtualFile[], VirtualFile> RUNTIME_PROVIDER = new IncludedFilesProvider(true) {
+    private final ParameterizedCachedValueProvider<VirtualFile[], PsiFile> RUNTIME_PROVIDER = new IncludedFilesProvider(true) {
       @Override
-      protected VirtualFile[] computeFiles(VirtualFile file, boolean compileTimeOnly) {
+      protected VirtualFile[] computeFiles(PsiFile file, boolean compileTimeOnly) {
         return IncludeCacheHolder.this.computeFiles(file, compileTimeOnly);
       }
     };
@@ -179,9 +176,11 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
     }
 
     private void getFilesRecursively(VirtualFile file, boolean compileTimeOnly, List<VirtualFile[]> result) {
+      PsiFile psiFile = myPsiManager.findFile(file);
+      if (psiFile == null) return;
       VirtualFile[] includes = compileTimeOnly
-                               ? myCachedValuesManager.getParameterizedCachedValue(file, COMPILE_TIME_KEY, COMPILE_TIME_PROVIDER, false, file)
-                               : myCachedValuesManager.getParameterizedCachedValue(file, RUNTIME_KEY, RUNTIME_PROVIDER, false, file);
+                               ? myCachedValuesManager.getParameterizedCachedValue(psiFile, COMPILE_TIME_KEY, COMPILE_TIME_PROVIDER, false, psiFile)
+                               : myCachedValuesManager.getParameterizedCachedValue(psiFile, RUNTIME_KEY, RUNTIME_PROVIDER, false, psiFile);
       if (includes.length != 0) {
         result.add(includes);
         for (VirtualFile include : includes) {
@@ -190,23 +189,23 @@ public class FileIncludeManagerImpl extends FileIncludeManager {
       }
     }
 
-    protected abstract VirtualFile[] computeFiles(VirtualFile file, boolean compileTimeOnly);
+    protected abstract VirtualFile[] computeFiles(PsiFile file, boolean compileTimeOnly);
 
   }
 
-  private abstract class IncludedFilesProvider implements ParameterizedCachedValueProvider<VirtualFile[], VirtualFile> {
+  private abstract static class IncludedFilesProvider implements ParameterizedCachedValueProvider<VirtualFile[], PsiFile> {
     private boolean myRuntimeOnly;
 
     public IncludedFilesProvider(boolean runtimeOnly) {
       myRuntimeOnly = runtimeOnly;
     }
 
-    protected abstract VirtualFile[] computeFiles(VirtualFile file, boolean compileTimeOnly);
+    protected abstract VirtualFile[] computeFiles(PsiFile file, boolean compileTimeOnly);
 
-    public CachedValueProvider.Result<VirtualFile[]> compute(VirtualFile param) {
+    public CachedValueProvider.Result<VirtualFile[]> compute(PsiFile param) {
       VirtualFile[] value = computeFiles(param, myRuntimeOnly);
       // todo: we need "url modification tracker" for VirtualFile 
-      return CachedValueProvider.Result.create(value, ArrayUtil.append(value, param));
+      return CachedValueProvider.Result.create(value, ArrayUtil.append(value, param.getVirtualFile()));
     }
   }
 }
index ca34190400767a3ed789b38081fab52a2b9c5b14..031865cffb30a6f2e17aa1e64c1cc6ae6c10e669 100644 (file)
@@ -19,8 +19,9 @@ package com.intellij.psi.impl.include;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.indexing.FileContent;
+import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileSystemItem;
+import com.intellij.util.indexing.FileContent;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -40,8 +41,7 @@ public abstract class FileIncludeProvider {
   public abstract FileIncludeInfo[] getIncludeInfos(FileContent content);
 
   @Nullable
-  public VirtualFile resolveInclude(FileIncludeInfo include, VirtualFile context, Project project) {
-    PsiFileSystemItem fileSystemItem = FileIncludeManager.getManager(project).resolveFileReference(include.path, context);
-    return fileSystemItem == null ? null : fileSystemItem.getVirtualFile();
+  public PsiFileSystemItem resolveInclude(FileIncludeInfo include, PsiFile context, Project project) {
+    return FileIncludeManager.getManager(project).resolveFileReference(include.path, context);
   }
 }
index 3b3123be9d1014461aa499793cb3f4142f8b4459..50a7e0c4196f73eaef950723fd628cb153edfa3e 100644 (file)
@@ -27,11 +27,9 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.*;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.PomManager;
 import com.intellij.pom.PomModelAspect;
@@ -71,7 +69,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
       final CommandProcessor processor = CommandProcessor.getInstance();
       if (processor != null) {
         final Project project = processor.getCurrentCommandProject();
-        if(project == myProject) {
+        if (project == myProject) {
           myPostponedCounter++;
         }
       }
@@ -81,7 +79,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
       final CommandProcessor processor = CommandProcessor.getInstance();
       if (processor != null) {
         final Project project = processor.getCurrentCommandProject();
-        if(project == myProject) {
+        if (project == myProject) {
           decrementPostponedCounter();
         }
       }
@@ -92,7 +90,8 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
     myProject = project;
     myPsiManager = psiManager;
     myTreeAspect = treeAspect;
-    PomManager.getModel(psiManager.getProject()).registerAspect(PostprocessReformattingAspect.class, this, Collections.singleton((PomModelAspect)treeAspect));
+    PomManager.getModel(psiManager.getProject())
+      .registerAspect(PostprocessReformattingAspect.class, this, Collections.singleton((PomModelAspect)treeAspect));
 
     ApplicationManager.getApplication().addApplicationListener(myApplicationListener);
     Disposer.register(project, this);
@@ -103,7 +102,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
   }
 
   public void disablePostprocessFormattingInside(final Runnable runnable) {
-    disablePostprocessFormattingInside(new Computable<Object>() {
+    disablePostprocessFormattingInside(new NullableComputable<Object>() {
       public Object compute() {
         runnable.run();
         return null;
@@ -111,7 +110,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
     });
   }
 
-  public <T> T disablePostprocessFormattingInside(Computable<T> computable){
+  public <T> T disablePostprocessFormattingInside(Computable<T> computable) {
     try {
       myDisabledCounter++;
       return computable.compute();
@@ -123,8 +122,9 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
   }
 
   private int myPostponedCounter = 0;
+
   public void postponeFormattingInside(final Runnable runnable) {
-    postponeFormattingInside(new Computable<Object>() {
+    postponeFormattingInside(new NullableComputable<Object>() {
       public Object compute() {
         runnable.run();
         return null;
@@ -132,7 +132,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
     });
   }
 
-  public <T> T postponeFormattingInside(Computable<T> computable){
+  public <T> T postponeFormattingInside(Computable<T> computable) {
     try {
       //if(myPostponedCounter == 0) myDisabled = false;
       myPostponedCounter++;
@@ -145,83 +145,100 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
 
   private void decrementPostponedCounter() {
     if (--myPostponedCounter == 0) {
-      if(!ApplicationManager.getApplication().isWriteAccessAllowed()){
+      if (!ApplicationManager.getApplication().isWriteAccessAllowed()) {
         ApplicationManager.getApplication().runWriteAction(new Runnable() {
           public void run() {
             doPostponedFormatting();
           }
         });
       }
-      else doPostponedFormatting();
+      else {
+        doPostponedFormatting();
+      }
       //myDisabled = true;
     }
   }
 
-  public void update(PomModelEvent event) {
-    synchronized(PsiLock.LOCK){
-      if(isDisabled() || myPostponedCounter == 0 && !ApplicationManager.getApplication().isUnitTestMode()) return;
-      final TreeChangeEvent changeSet = (TreeChangeEvent)event.getChangeSet(myTreeAspect);
-      if(changeSet == null) return;
-      final PsiElement psiElement = changeSet.getRootElement().getPsi();
-      if(psiElement == null) return;
-      PsiFile containingFile = InjectedLanguageUtil.getTopLevelFile(psiElement);
-      final FileViewProvider viewProvider = containingFile.getViewProvider();
-
-      if(!viewProvider.isEventSystemEnabled()) return;
-      myUpdatedProviders.add(viewProvider);
-      for (final ASTNode node : changeSet.getChangedElements()) {
-        final TreeChange treeChange = changeSet.getChangesByElement(node);
-        for (final ASTNode affectedChild : treeChange.getAffectedChildren()) {
-          final ChangeInfo childChange = treeChange.getChangeByChild(affectedChild);
-          switch(childChange.getChangeType()){
-            case ChangeInfo.ADD:
-            case ChangeInfo.REPLACE:
-              postponeFormatting(viewProvider, affectedChild);
-              break;
-            case ChangeInfo.CONTENTS_CHANGED:
-              if(!CodeEditUtil.isNodeGenerated(affectedChild))
-                ((TreeElement)affectedChild).acceptTree(new RecursiveTreeElementWalkingVisitor(){
-                  protected void visitNode(TreeElement element) {
-                    if(CodeEditUtil.isNodeGenerated(element)){
-                      postponeFormatting(viewProvider, element);
-                      return;
+  private final Object LOCK = new Object();
+
+  private void atomic(Runnable r) {
+    synchronized (LOCK) {
+      ProgressManager.getInstance().executeNonCancelableSection(r);
+    }
+  }
+
+  public void update(final PomModelEvent event) {
+    atomic(new Runnable() {
+      public void run() {
+        if (isDisabled() || myPostponedCounter == 0 && !ApplicationManager.getApplication().isUnitTestMode()) return;
+        final TreeChangeEvent changeSet = (TreeChangeEvent)event.getChangeSet(myTreeAspect);
+        if (changeSet == null) return;
+        final PsiElement psiElement = changeSet.getRootElement().getPsi();
+        if (psiElement == null) return;
+        PsiFile containingFile = InjectedLanguageUtil.getTopLevelFile(psiElement);
+        final FileViewProvider viewProvider = containingFile.getViewProvider();
+
+        if (!viewProvider.isEventSystemEnabled()) return;
+        myUpdatedProviders.add(viewProvider);
+        for (final ASTNode node : changeSet.getChangedElements()) {
+          final TreeChange treeChange = changeSet.getChangesByElement(node);
+          for (final ASTNode affectedChild : treeChange.getAffectedChildren()) {
+            final ChangeInfo childChange = treeChange.getChangeByChild(affectedChild);
+            switch (childChange.getChangeType()) {
+              case ChangeInfo.ADD:
+              case ChangeInfo.REPLACE:
+                postponeFormatting(viewProvider, affectedChild);
+                break;
+              case ChangeInfo.CONTENTS_CHANGED:
+                if (!CodeEditUtil.isNodeGenerated(affectedChild)) {
+                  ((TreeElement)affectedChild).acceptTree(new RecursiveTreeElementWalkingVisitor() {
+                    protected void visitNode(TreeElement element) {
+                      if (CodeEditUtil.isNodeGenerated(element)) {
+                        postponeFormatting(viewProvider, element);
+                        return;
+                      }
+                      super.visitNode(element);
                     }
-                    super.visitNode(element);
-                  }
-                });
-              break;
+                  });
+                }
+                break;
+            }
           }
         }
       }
-    }
+    });
   }
 
-  public void doPostponedFormatting(){
-    synchronized(PsiLock.LOCK){
-      if(isDisabled()) return;
-      try{
-        for (final FileViewProvider viewProvider : myUpdatedProviders) {
-          doPostponedFormatting(viewProvider);
+  public void doPostponedFormatting() {
+    atomic(new Runnable() {
+      public void run() {
+        if (isDisabled()) return;
+        try {
+          for (final FileViewProvider viewProvider : myUpdatedProviders) {
+            doPostponedFormatting(viewProvider);
+          }
+        }
+        finally {
+          LOG.assertTrue(myReformatElements.isEmpty());
+          myUpdatedProviders.clear();
+          myReformatElements.clear();
         }
       }
-      finally {
-        LOG.assertTrue(myReformatElements.isEmpty());
-        myUpdatedProviders.clear();
-        myReformatElements.clear();
-      }
-    }
+    });
   }
 
   public void doPostponedFormatting(final FileViewProvider viewProvider) {
-    synchronized(PsiLock.LOCK){
-      if(isDisabled()) return;
+    atomic(new Runnable() {
+      public void run() {
+        if (isDisabled()) return;
 
-      disablePostprocessFormattingInside(new Runnable() {
-        public void run() {
-          doPostponedFormattingInner(viewProvider);
-        }
-      });
-    }
+        disablePostprocessFormattingInside(new Runnable() {
+          public void run() {
+            doPostponedFormattingInner(viewProvider);
+          }
+        });
+      }
+    });
   }
 
   public boolean isViewProviderLocked(final FileViewProvider fileViewProvider) {
@@ -235,7 +252,8 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
   private void postponeFormatting(final FileViewProvider viewProvider, final ASTNode child) {
     if (!CodeEditUtil.isNodeGenerated(child) && child.getElementType() != TokenType.WHITE_SPACE) {
       final int oldIndent = CodeEditUtil.getOldIndentation(child);
-      LOG.assertTrue(oldIndent >= 0, "for not generated items old indentation must be defined: element=" + child + ", text=" + child.getText());
+      LOG.assertTrue(oldIndent >= 0,
+                     "for not generated items old indentation must be defined: element=" + child + ", text=" + child.getText());
     }
     List<ASTNode> list = myReformatElements.get(viewProvider);
     if (list == null) {
@@ -260,10 +278,10 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
       public int compare(final RangeMarker o1, final RangeMarker o2) {
         if (o1.equals(o2)) return 0;
         final int diff = o2.getEndOffset() - o1.getEndOffset();
-        if (diff == 0){
-          if(o1.getStartOffset() == o2.getStartOffset()) return 0;
-          if(o1.getStartOffset() == o1.getEndOffset()) return -1; // empty ranges first
-          if(o2.getStartOffset() == o2.getEndOffset()) return 1; // empty ranges first
+        if (diff == 0) {
+          if (o1.getStartOffset() == o2.getStartOffset()) return 0;
+          if (o1.getStartOffset() == o1.getEndOffset()) return -1; // empty ranges first
+          if (o2.getStartOffset() == o2.getEndOffset()) return 1; // empty ranges first
           return o1.getStartOffset() - o2.getStartOffset();
         }
         return diff;
@@ -280,10 +298,11 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
       checkPsiIsCorrect(key);
     }
 
-    while(!rangesToProcess.isEmpty()){
+    while (!rangesToProcess.isEmpty()) {
       // now we have to normalize actions so that they not intersect and ordered in most appropriate way
       // (free reformating -> reindent -> formating under reindent)
-      final List<Pair<RangeMarker, ? extends PostponedAction>> normalizedActions = normalizeAndReorderPostponedActions(rangesToProcess, document);
+      final List<Pair<RangeMarker, ? extends PostponedAction>> normalizedActions =
+        normalizeAndReorderPostponedActions(rangesToProcess, document);
 
       // only in following loop real changes in document are made
       for (final Pair<RangeMarker, ? extends PostponedAction> normalizedAction : normalizedActions) {
@@ -317,14 +336,15 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
 
       if (!expectedPsi.equals(actualPsiTree)) {
         myReformatElements.clear();
-        assert expectedPsi.equals(actualPsiTree): "Refactored psi should be the same as result of parsing";
+        assert expectedPsi.equals(actualPsiTree) : "Refactored psi should be the same as result of parsing";
       }
     }
 
 
   }
 
-  private List<Pair<RangeMarker, ? extends PostponedAction>> normalizeAndReorderPostponedActions(final TreeMap<RangeMarker, PostponedAction> rangesToProcess, Document document) {
+  private List<Pair<RangeMarker, ? extends PostponedAction>> normalizeAndReorderPostponedActions(final TreeMap<RangeMarker, PostponedAction> rangesToProcess,
+                                                                                                 Document document) {
     final List<Pair<RangeMarker, ReformatAction>> freeFormatingActions = new ArrayList<Pair<RangeMarker, ReformatAction>>();
     final List<Pair<RangeMarker, ReindentAction>> indentActions = new ArrayList<Pair<RangeMarker, ReindentAction>>();
 
@@ -344,10 +364,12 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
                (accumulatedRange.getStartOffset() == textRange.getEndOffset() &&
                 !canStickActionsTogether(accumulatedRangeAction, accumulatedRange, action, textRange))) {
         // action can be pushed
-        if (accumulatedRangeAction instanceof ReindentAction)
+        if (accumulatedRangeAction instanceof ReindentAction) {
           indentActions.add(new Pair<RangeMarker, ReindentAction>(accumulatedRange, (ReindentAction)accumulatedRangeAction));
-        else
+        }
+        else {
           freeFormatingActions.add(new Pair<RangeMarker, ReformatAction>(accumulatedRange, (ReformatAction)accumulatedRangeAction));
+        }
 
         accumulatedRange = textRange;
         accumulatedRangeAction = action;
@@ -362,7 +384,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
           // and manage heading whitespace because formatter does not edit it in previous action
           iterator = rangesToProcess.entrySet().iterator();
           //noinspection StatementWithEmptyBody
-          while(iterator.next().getKey() != textRange);
+          while (iterator.next().getKey() != textRange) ;
         }
         final RangeMarker rangeToProcess = document.createRangeMarker(textRange.getEndOffset(), accumulatedRange.getEndOffset());
         freeFormatingActions.add(new Pair<RangeMarker, ReformatAction>(rangeToProcess, new ReformatWithHeadingWhitespaceAction()));
@@ -373,23 +395,29 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
       else {
         if (!(accumulatedRangeAction instanceof ReindentAction)) {
           iterator.remove();
-          if(accumulatedRangeAction instanceof ReformatAction && action instanceof ReformatWithHeadingWhitespaceAction &&
-             accumulatedRange.getStartOffset() == textRange.getStartOffset() ||
-             accumulatedRangeAction instanceof ReformatWithHeadingWhitespaceAction && action instanceof ReformatAction &&
-             accumulatedRange.getStartOffset() < textRange.getStartOffset()){
+          if (accumulatedRangeAction instanceof ReformatAction &&
+              action instanceof ReformatWithHeadingWhitespaceAction &&
+              accumulatedRange.getStartOffset() == textRange.getStartOffset() ||
+              accumulatedRangeAction instanceof ReformatWithHeadingWhitespaceAction &&
+              action instanceof ReformatAction &&
+              accumulatedRange.getStartOffset() < textRange.getStartOffset()) {
             accumulatedRangeAction = action;
           }
           accumulatedRange = document.createRangeMarker(Math.min(accumulatedRange.getStartOffset(), textRange.getStartOffset()),
                                                         Math.max(accumulatedRange.getEndOffset(), textRange.getEndOffset()));
         }
-        else if(action instanceof ReindentAction) iterator.remove(); // TODO[ik]: need to be fixed to correctly process indent inside indent
+        else if (action instanceof ReindentAction) {
+          iterator.remove();
+        } // TODO[ik]: need to be fixed to correctly process indent inside indent
       }
     }
-    if (accumulatedRange != null){
-      if (accumulatedRangeAction instanceof ReindentAction)
+    if (accumulatedRange != null) {
+      if (accumulatedRangeAction instanceof ReindentAction) {
         indentActions.add(new Pair<RangeMarker, ReindentAction>(accumulatedRange, (ReindentAction)accumulatedRangeAction));
-      else
+      }
+      else {
         freeFormatingActions.add(new Pair<RangeMarker, ReformatAction>(accumulatedRange, (ReformatAction)accumulatedRangeAction));
+      }
     }
 
     final List<Pair<RangeMarker, ? extends PostponedAction>> result =
@@ -406,13 +434,16 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
                                           final PostponedAction nextAction,
                                           final RangeMarker nextRange) {
     // empty reformat markers can't sticked together with any action
-    if(nextAction instanceof ReformatWithHeadingWhitespaceAction && nextRange.getStartOffset() == nextRange.getEndOffset()) return false;
-    if(currentAction instanceof ReformatWithHeadingWhitespaceAction && currentRange.getStartOffset() == currentRange.getEndOffset()) return false;
+    if (nextAction instanceof ReformatWithHeadingWhitespaceAction && nextRange.getStartOffset() == nextRange.getEndOffset()) return false;
+    if (currentAction instanceof ReformatWithHeadingWhitespaceAction && currentRange.getStartOffset() == currentRange.getEndOffset()) {
+      return false;
+    }
     // reindent actions can't be sticked at all
     return !(currentAction instanceof ReindentAction);
   }
 
-  private void createActionsMap(final List<ASTNode> astNodes, final FileViewProvider provider,
+  private void createActionsMap(final List<ASTNode> astNodes,
+                                final FileViewProvider provider,
                                 final TreeMap<RangeMarker, PostponedAction> rangesToProcess) {
     final Set<ASTNode> nodesToProcess = new HashSet<ASTNode>(astNodes);
     final Document document = provider.getDocument();
@@ -424,16 +455,17 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
 
       ((TreeElement)node).acceptTree(new RecursiveTreeElementVisitor() {
         boolean inGeneratedContext = !isGenerated;
+
         protected boolean visitNode(TreeElement element) {
-          if(nodesToProcess.contains(element)) return false;
+          if (nodesToProcess.contains(element)) return false;
           final boolean currentNodeGenerated = CodeEditUtil.isNodeGenerated(element);
           CodeEditUtil.setNodeGenerated(element, false);
-          if(currentNodeGenerated && !inGeneratedContext){
+          if (currentNodeGenerated && !inGeneratedContext) {
             rangesToProcess.put(document.createRangeMarker(element.getTextRange()), new ReformatAction());
             inGeneratedContext = true;
           }
-          if(!currentNodeGenerated && inGeneratedContext){
-            if(element.getElementType() == TokenType.WHITE_SPACE) return false;
+          if (!currentNodeGenerated && inGeneratedContext) {
+            if (element.getElementType() == TokenType.WHITE_SPACE) return false;
             final int oldIndent = CodeEditUtil.getOldIndentation(element);
             LOG.assertTrue(oldIndent >= 0, "for not generated items old indentation must be defined");
             rangesToProcess.put(document.createRangeMarker(element.getTextRange()), new ReindentAction(oldIndent));
@@ -442,13 +474,15 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
           return true;
         }
 
-        @Override public void visitComposite(CompositeElement composite) {
+        @Override
+        public void visitComposite(CompositeElement composite) {
           boolean oldGeneratedContext = inGeneratedContext;
           super.visitComposite(composite);
           inGeneratedContext = oldGeneratedContext;
         }
 
-        @Override public void visitLeaf(LeafElement leaf) {
+        @Override
+        public void visitLeaf(LeafElement leaf) {
           boolean oldGeneratedContext = inGeneratedContext;
           super.visitLeaf(leaf);
           inGeneratedContext = oldGeneratedContext;
@@ -457,25 +491,26 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
     }
   }
 
-  private void handleReformatMarkers(final FileViewProvider key,
-                                                                  final TreeMap<RangeMarker, PostponedAction> rangesToProcess) {
+  private void handleReformatMarkers(final FileViewProvider key, final TreeMap<RangeMarker, PostponedAction> rangesToProcess) {
     final Document document = key.getDocument();
     for (final FileElement fileElement : ((SingleRootFileViewProvider)key).getKnownTreeRoots()) {
-      fileElement.acceptTree(
-        new RecursiveTreeElementWalkingVisitor(){
-          protected void visitNode(TreeElement element) {
-            if(CodeEditUtil.isMarkedToReformatBefore(element)) {
-              CodeEditUtil.markToReformatBefore(element, false);
-              rangesToProcess.put(document.createRangeMarker(element.getStartOffset(), element.getStartOffset()),
-                             new ReformatWithHeadingWhitespaceAction());
-            }
-            super.visitNode(element);
+      fileElement.acceptTree(new RecursiveTreeElementWalkingVisitor() {
+        protected void visitNode(TreeElement element) {
+          if (CodeEditUtil.isMarkedToReformatBefore(element)) {
+            CodeEditUtil.markToReformatBefore(element, false);
+            rangesToProcess.put(document.createRangeMarker(element.getStartOffset(), element.getStartOffset()),
+                                new ReformatWithHeadingWhitespaceAction());
           }
-        });
+          super.visitNode(element);
+        }
+      });
     }
   }
 
-  private static void adjustIndentationInRange(final PsiFile file, final Document document, final TextRange[] indents, final int indentAdjustment) {
+  private static void adjustIndentationInRange(final PsiFile file,
+                                               final Document document,
+                                               final TextRange[] indents,
+                                               final int indentAdjustment) {
     final Helper formatHelper = HelperFactory.createHelper(file.getFileType(), file.getProject());
     final CharSequence charsSequence = document.getCharsSequence();
     for (final TextRange indent : indents) {
@@ -492,7 +527,7 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
     final int startOffset = document.getLineStartOffset(document.getLineNumber(firstWhitespace));
     int endOffset = startOffset;
     final CharSequence charsSequence = document.getCharsSequence();
-    while(Character.isWhitespace(charsSequence.charAt(endOffset++)));
+    while (Character.isWhitespace(charsSequence.charAt(endOffset++))) ;
     final String newIndentStr = charsSequence.subSequence(startOffset, endOffset - 1).toString();
     return formatHelper.getIndent(newIndentStr, true);
   }
@@ -520,16 +555,16 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
   private class ReformatAction implements PostponedAction {
     public void processRange(RangeMarker marker, final FileViewProvider viewProvider) {
       final CodeFormatterFacade codeFormatter = getFormatterFacade(viewProvider);
-      codeFormatter.processTextWithoutHeadWhitespace(viewProvider.getPsi(viewProvider.getBaseLanguage()),
-                                                     marker.getStartOffset(), marker.getEndOffset());
+      codeFormatter.processTextWithoutHeadWhitespace(viewProvider.getPsi(viewProvider.getBaseLanguage()), marker.getStartOffset(),
+                                                     marker.getEndOffset());
     }
   }
 
-  private class ReformatWithHeadingWhitespaceAction extends ReformatAction{
+  private class ReformatWithHeadingWhitespaceAction extends ReformatAction {
     public void processRange(RangeMarker marker, final FileViewProvider viewProvider) {
       final CodeFormatterFacade codeFormatter = getFormatterFacade(viewProvider);
       codeFormatter.processText(viewProvider.getPsi(viewProvider.getBaseLanguage()), marker.getStartOffset(),
-                                marker.getStartOffset() == marker.getEndOffset() ? marker.getEndOffset() + 1: marker.getEndOffset());
+                                marker.getStartOffset() == marker.getEndOffset() ? marker.getEndOffset() + 1 : marker.getEndOffset());
     }
 
   }
@@ -545,13 +580,11 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
     public void processRange(RangeMarker marker, final FileViewProvider viewProvider) {
       final Document document = viewProvider.getDocument();
       final PsiFile psiFile = viewProvider.getPsi(viewProvider.getBaseLanguage());
-      final CharSequence charsSequence = document.getCharsSequence().subSequence(marker.getStartOffset(),
-                                                                                 marker.getEndOffset());
+      final CharSequence charsSequence = document.getCharsSequence().subSequence(marker.getStartOffset(), marker.getEndOffset());
       final int oldIndent = getOldIndent();
       final TextRange[] whitespaces = CharArrayUtil.getIndents(charsSequence, marker.getStartOffset());
       final int indentAdjustment = getNewIndent(psiFile, marker.getStartOffset()) - oldIndent;
-      if(indentAdjustment != 0)
-        adjustIndentationInRange(psiFile, document, whitespaces, indentAdjustment);
+      if (indentAdjustment != 0) adjustIndentationInRange(psiFile, document, whitespaces, indentAdjustment);
     }
 
     private int getOldIndent() {
@@ -566,7 +599,8 @@ public class PostprocessReformattingAspect implements PomModelAspect, Disposable
   public void projectClosed() {
   }
 
-  @NotNull @NonNls
+  @NotNull
+  @NonNls
   public String getComponentName() {
     return "Postponed reformatting model";
   }
index 199678c6a676650838d3b0eaeea1d432cfe2a817..c0f4485ef8dcbb7883069ce75aa13cbe24068c7a 100644 (file)
@@ -152,16 +152,26 @@ public class ResolveCache {
   }
 
   private static final Key<Thread[]> IS_BEING_RESOLVED_KEY = Key.create("ResolveCache.IS_BEING_RESOLVED_KEY");
+
   private static boolean lockElement(PsiReference ref) {
-    PsiElement element = ref.getElement();
+    return lockElement(ref.getElement(), IS_BEING_RESOLVED_KEY);
+  }
 
+  /**
+   * Implementation of per thread lock to prevent element-analysing recursive algorithms from infinite looping.
+   * @see #unlockElement
+   * @param element
+   * @param key
+   * @return lock status
+   */
+  public static boolean lockElement(PsiElement element, Key<Thread[]> key) {
     final Thread currentThread = Thread.currentThread();
     while (true) {
-      Thread[] lockingThreads = element.getUserData(IS_BEING_RESOLVED_KEY);
+      Thread[] lockingThreads = element.getUserData(key);
       Thread[] newThreads;
       if (lockingThreads == null) {
         newThreads = new Thread[]{currentThread};
-        if (((UserDataHolderEx)element).putUserDataIfAbsent(IS_BEING_RESOLVED_KEY, newThreads) == newThreads) {
+        if (((UserDataHolderEx)element).putUserDataIfAbsent(key, newThreads) == newThreads) {
           break;
         }
       }
@@ -170,12 +180,12 @@ public class ResolveCache {
           return false;
         }
         newThreads = ArrayUtil.append(lockingThreads, currentThread);
-        if (((UserDataHolderEx)element).replace(IS_BEING_RESOLVED_KEY, lockingThreads, newThreads)) {
+        if (((UserDataHolderEx)element).replace(key, lockingThreads, newThreads)) {
           break;
         }
       }
     }
-    Thread[] data = element.getUserData(IS_BEING_RESOLVED_KEY);
+    Thread[] data = element.getUserData(key);
     int i = ArrayUtil.find(data, currentThread);
     assert i != -1;
     assert i == ArrayUtil.lastIndexOf(data, currentThread);
@@ -184,10 +194,18 @@ public class ResolveCache {
   }
 
   private static void unlockElement(PsiReference ref) {
-    PsiElement element = ref.getElement();
+    unlockElement(ref.getElement(), IS_BEING_RESOLVED_KEY);
+  }
+
+  /**
+   * @see #lockElement
+   * @param element
+   * @param key
+   */
+  public static void unlockElement(PsiElement element , Key<Thread[]> key) {
     final Thread currentThread = Thread.currentThread();
     while (true) {
-      Thread[] lockingThreads = element.getUserData(IS_BEING_RESOLVED_KEY);
+      Thread[] lockingThreads = element.getUserData(key);
       Thread[] newThreads;
       if (lockingThreads.length == 1) {
         assert lockingThreads[0] == currentThread : "Locking thread = " + lockingThreads[0] + "; current=" + currentThread;
@@ -202,11 +220,11 @@ public class ResolveCache {
         assert newThreads.length == lockingThreads.length - 1 : "Locking threads = " + Arrays.asList(lockingThreads) + "; newThreads=" + Arrays.asList(newThreads);
         assert ArrayUtil.find(newThreads, currentThread) == -1;
       }
-      if (((UserDataHolderEx)element).replace(IS_BEING_RESOLVED_KEY, lockingThreads, newThreads)) {
+      if (((UserDataHolderEx)element).replace(key, lockingThreads, newThreads)) {
         break;
       }
     }
-    Thread[] data = element.getUserData(IS_BEING_RESOLVED_KEY);
+    Thread[] data = element.getUserData(key);
     assert data == null || ArrayUtil.find(data, currentThread) == -1;
   }
 
index 6bda9f016e4b04ef78128d94f67f1db678ae5f7a..7e4a0e219d04b5c74d67ec37cb81db3162911e37 100644 (file)
@@ -66,7 +66,7 @@ import java.util.Map;
  */
 public class VariableInplaceRenamer {
   private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.inplace.VariableInplaceRenamer");
-  private static final LanguageExtension<ResolveSnapshotProvider> INSTANCE = new LanguageExtension<ResolveSnapshotProvider>(
+  public static final LanguageExtension<ResolveSnapshotProvider> INSTANCE = new LanguageExtension<ResolveSnapshotProvider>(
     "com.intellij.rename.inplace.resolveSnapshotProvider"
   );
 
index cf4ca81e1a1a68c3aa5d6a0e6576b931d26e437c..c7730b742ee961f78d460a0c0ab39ca76c276b9b 100644 (file)
@@ -17,8 +17,6 @@
 package com.intellij.util.indexing;
 
 import com.intellij.AppTopics;
-import com.intellij.concurrency.Job;
-import com.intellij.concurrency.JobScheduler;
 import com.intellij.ide.caches.CacheUpdater;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.application.*;
@@ -38,7 +36,6 @@ import com.intellij.openapi.project.*;
 import com.intellij.openapi.roots.*;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.vfs.*;
 import com.intellij.openapi.vfs.ex.VirtualFileManagerEx;
 import com.intellij.openapi.vfs.newvfs.BulkFileListener;
@@ -118,7 +115,6 @@ public class FileBasedIndex implements ApplicationComponent {
   private final Map<Document, PsiFile> myTransactionMap = new HashMap<Document, PsiFile>();
 
   private static final int ALREADY_PROCESSED = 0x02;
-  private static final String USE_MULTITHREADED_INDEXING = "fileIndex.multithreaded";
   private @Nullable String myConfigPath;
   private @Nullable String mySystemPath;
   private final boolean myIsUnitTestMode;
@@ -545,7 +541,7 @@ public class FileBasedIndex implements ApplicationComponent {
     }
   }
 
-  private boolean isUpToDateCheckEnabled() {
+  private static boolean isUpToDateCheckEnabled() {
     final Integer value = myUpToDateCheckState.get();
     return value == null || value.intValue() == 0;
   }
@@ -1193,9 +1189,6 @@ private boolean indexUnsavedDocument(final Document document, final ID<?, ?> req
 
     PsiFile psiFile = null;
 
-    final Ref<ProcessCanceledException> pce = Ref.create(null);
-
-    final List<Runnable> tasks = new ArrayList<Runnable>();
     for (final ID<?, ?> indexId : myIndices.keySet()) {
       if (shouldIndexFile(file, indexId)) {
         if (fc == null) {
@@ -1219,50 +1212,21 @@ private boolean indexUnsavedDocument(final Document document, final ID<?, ?> req
           fc.putUserData(PROJECT, project);
         }
 
-        final FileContent _fc = fc;
-        tasks.add(new Runnable() {
-          public void run() {
-            try {
-              ProgressManager.checkCanceled();
-              updateSingleIndex(indexId, file, _fc);
-            }
-            catch (ProcessCanceledException e) {
-              pce.set(e);
-            }
-            catch (StorageException e) {
-              requestRebuild(indexId);
-              LOG.info(e);
-            }
-          }
-        });
-      }
-    }
-
-    if (tasks.size() > 0) {
-      if (Registry.get(USE_MULTITHREADED_INDEXING).asBoolean() && !myIsUnitTestMode) {
-        final Job<Object> job = JobScheduler.getInstance().createJob("IndexJob", Job.DEFAULT_PRIORITY / 2);
         try {
-          for (Runnable task : tasks) {
-            job.addTask(task);
-          }
-          job.scheduleAndWaitForResults();
+          ProgressManager.checkCanceled();
+          updateSingleIndex(indexId, file, fc);
         }
-        catch (Throwable throwable) {
-          LOG.info(throwable);
+        catch (ProcessCanceledException e) {
+          myChangedFilesCollector.scheduleForUpdate(file);
+          throw e;
         }
-      }
-      else {
-        for (Runnable task : tasks) {
-          task.run();
+        catch (StorageException e) {
+          requestRebuild(indexId);
+          LOG.info(e);
         }
       }
     }
 
-    if (!pce.isNull()) {
-      myChangedFilesCollector.scheduleForUpdate(file);
-      throw pce.get();
-    }
-
     if (psiFile != null) {
       psiFile.putUserData(PsiFileImpl.BUILDING_STUB, null);
     }
@@ -1608,7 +1572,9 @@ private boolean indexUnsavedDocument(final Document document, final ID<?, ?> req
     public Collection<VirtualFile> getAllFilesToUpdate() {
       r.lock();
       try {
-        if (myFilesToUpdate.isEmpty())  return Collections.EMPTY_LIST;
+        if (myFilesToUpdate.isEmpty()) {
+          return Collections.emptyList();
+        }
         return new ArrayList<VirtualFile>(myFilesToUpdate);
       }
       finally {
index e17a3f58eb09f7156a5a50f8017dd36f40affe2a..07db76352e7b2f6dfc62f7188d51de17865ac244 100644 (file)
@@ -26,8 +26,7 @@ public class UnnamedConfigurableGroup implements UnnamedConfigurable {
 
   public JComponent createComponent() {
     JPanel panel = new JPanel(new VerticalFlowLayout());
-    for (int i = 0; i < myConfigurables.size(); i++) {
-      UnnamedConfigurable configurable = myConfigurables.get(i);
+    for (UnnamedConfigurable configurable : myConfigurables) {
       panel.add(configurable.createComponent());
     }
 
@@ -35,27 +34,27 @@ public class UnnamedConfigurableGroup implements UnnamedConfigurable {
   }
 
   public boolean isModified() {
-    for (int i = 0; i < myConfigurables.size(); i++) {
-      if (myConfigurables.get(i).isModified()) return true;
+    for (UnnamedConfigurable myConfigurable : myConfigurables) {
+      if (myConfigurable.isModified()) return true;
     }
     return false;
   }
 
   public void apply() throws ConfigurationException {
-    for (int i = 0; i < myConfigurables.size(); i++) {
-      myConfigurables.get(i).apply();
+    for (UnnamedConfigurable myConfigurable : myConfigurables) {
+      myConfigurable.apply();
     }
   }
 
   public void reset() {
-    for (int i = 0; i < myConfigurables.size(); i++) {
-      myConfigurables.get(i).reset();
+    for (UnnamedConfigurable myConfigurable : myConfigurables) {
+      myConfigurable.reset();
     }
   }
 
   public void disposeUIResources() {
-    for (int i = 0; i < myConfigurables.size(); i++) {
-      myConfigurables.get(i).disposeUIResources();
+    for (UnnamedConfigurable myConfigurable : myConfigurables) {
+      myConfigurable.disposeUIResources();
     }
   }
 
index c5356c0a3efdb2f4d876735e1f6e751be93f4031..747f8e8e9f1e5928a009b7876cb554218ff32c7e 100644 (file)
@@ -59,21 +59,21 @@ public class JBTabsImpl extends JComponent
 
   ActionManager myActionManager;
   public final List<TabInfo> myVisibleInfos = new ArrayList<TabInfo>();
-  final Map<TabInfo, Integer> myHiddenInfos = new HashMap<TabInfo, Integer>();
+  private final Map<TabInfo, Integer> myHiddenInfos = new HashMap<TabInfo, Integer>();
 
-  TabInfo mySelectedInfo;
+  private TabInfo mySelectedInfo;
   public final Map<TabInfo, TabLabel> myInfo2Label = new HashMap<TabInfo, TabLabel>();
   public final Map<TabInfo, Toolbar> myInfo2Toolbar = new HashMap<TabInfo, Toolbar>();
   public Dimension myHeaderFitSize;
 
-  Insets myInnerInsets = new Insets(0, 0, 0, 0);
+  private Insets myInnerInsets = new Insets(0, 0, 0, 0);
 
-  final List<EventListener> myTabMouseListeners = new ArrayList<EventListener>();
-  final List<TabsListener> myTabListeners = new ArrayList<TabsListener>();
+  private final List<EventListener> myTabMouseListeners = new ArrayList<EventListener>();
+  private final List<TabsListener> myTabListeners = new ArrayList<TabsListener>();
   public boolean myFocused;
 
-  Getter<ActionGroup> myPopupGroup;
-  String myPopupPlace;
+  private Getter<ActionGroup> myPopupGroup;
+  private String myPopupPlace;
 
   TabInfo myPopupInfo;
   DefaultActionGroup myNavigationActions;
@@ -83,19 +83,19 @@ public class JBTabsImpl extends JComponent
 
   public boolean myHorizontalSide = true;
 
-  boolean myStealthTabMode = false;
+  private boolean myStealthTabMode = false;
 
-  DataProvider myDataProvider;
+  private DataProvider myDataProvider;
 
-  WeakHashMap<Component, Component> myDeferredToRemove = new WeakHashMap<Component, Component>();
+  private final WeakHashMap<Component, Component> myDeferredToRemove = new WeakHashMap<Component, Component>();
 
-  SingleRowLayout mySingleRowLayout = new SingleRowLayout(this);
-  TableLayout myTableLayout = new TableLayout(this);
+  private final SingleRowLayout mySingleRowLayout = new SingleRowLayout(this);
+  private final TableLayout myTableLayout = new TableLayout(this);
 
 
   private TabLayout myLayout = mySingleRowLayout;
   LayoutPassInfo myLastLayoutPass;
-  TabInfo myLastPaintedSelection;
+  private TabInfo myLastPaintedSelection;
 
   public boolean myForcedRelayout;
 
@@ -110,16 +110,16 @@ public class JBTabsImpl extends JComponent
   private boolean myRequestFocusOnLastFocusedComponent = false;
   private boolean myListenerAdded;
   final Set<TabInfo> myAttractions = new HashSet<TabInfo>();
-  Animator myAnimator;
-  List<TabInfo> myAllTabs;
-  boolean myPaintBlocked;
-  BufferedImage myImage;
-  IdeFocusManager myFocusManager;
-  boolean myAdjustBorders = true;
+  private Animator myAnimator;
+  private List<TabInfo> myAllTabs;
+  private boolean myPaintBlocked;
+  private BufferedImage myImage;
+  private IdeFocusManager myFocusManager;
+  private boolean myAdjustBorders = true;
 
   boolean myAddNavigationGroup = true;
 
-  boolean myGhostsAlwaysVisible = false;
+  private boolean myGhostsAlwaysVisible = false;
   private boolean myDisposed;
   private boolean myToDrawBorderIfTabsHidden = true;
   private Color myActiveTabFillIn;
@@ -135,12 +135,11 @@ public class JBTabsImpl extends JComponent
   private long myRemoveDefferredRequest;
   private boolean myTestMode;
 
-  JBTabsPosition myPosition = JBTabsPosition.top;
+  private JBTabsPosition myPosition = JBTabsPosition.top;
 
   private final TabsBorder myBorder = new TabsBorder(this);
   private BaseNavigationAction myNextAction;
   private BaseNavigationAction myPrevAction;
-  private Disposable myParent;
 
   private boolean myWasEverShown;
 
@@ -153,15 +152,15 @@ public class JBTabsImpl extends JComponent
     this(project, project);
   }
 
-  public JBTabsImpl(@NotNull Project project, Disposable parent) {
+  public JBTabsImpl(@NotNull Project project, @NotNull Disposable parent) {
     this(project, ActionManager.getInstance(), IdeFocusManager.getInstance(project), parent);
   }
 
-  public JBTabsImpl(@Nullable Project project, IdeFocusManager focusManager, Disposable parent) {
+  public JBTabsImpl(@Nullable Project project, IdeFocusManager focusManager, @NotNull Disposable parent) {
     this(project, ActionManager.getInstance(), focusManager, parent);
   }
 
-  public JBTabsImpl(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, Disposable parent) {
+  public JBTabsImpl(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
     myProject = project;
     myActionManager = actionManager;
     myFocusManager = focusManager != null ? focusManager : PassThroughtIdeFocusManager.getInstance();
@@ -169,10 +168,7 @@ public class JBTabsImpl extends JComponent
     setOpaque(true);
     setPaintBorder(-1, -1, -1, -1);
 
-    myParent = parent;
-    if (myParent != null) {
-      Disposer.register(myParent, this);
-    }
+    Disposer.register(parent, this);
 
     myNavigationActions = new DefaultActionGroup();
 
index 70e068e1d450ebb9a0428224c81a791c636b53ed..ccd4acd0031523abaa42333fc503da83be0fe6dc 100644 (file)
@@ -50,16 +50,13 @@ class EditorChangeAction implements UndoableAction {
   }
 
   public void undo() {
-    doUndoRedo(myNewString, myOldString);
+    exchangeStrings(myNewString, myOldString);
     getDocument().setModificationStamp(myTimeStamp);
+    refreshFileStatus();
   }
 
   public void redo() {
-    doUndoRedo(myOldString, myNewString);
-  }
-
-  private void doUndoRedo(CharSequence from, CharSequence to) {
-    exchangeStrings(from, to);
+    exchangeStrings(myOldString, myNewString);
     refreshFileStatus();
   }
 
index 4f9388fee64cc5480cf5d729646ac3db1a17add5..f28547bbd5f9cc8a49678d3bf203d3ef29efb8f9 100644 (file)
@@ -144,6 +144,8 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
   }
 
   protected void disposeComponents() {
+    assert !myDisposeCompleted : "Already disposed!";
+
     final List<Object> components = myComponentsRegistry.getRegisteredImplementations();
     myDisposed = true;
 
index 22af3f4bae6d4aba8335f8ecd293327f8a441926..de5f7f6cae311842922a74a4d2539cdfef569ec6 100644 (file)
@@ -187,36 +187,6 @@ public class FileBasedStorage extends XmlElementStorage {
 
   }
 
-  private VirtualFile ensureVirtualFile() {
-    if (!myFile.exists()) {
-      File ioFile = new File(myFile.getPath());
-      FileUtil.createIfDoesntExist(ioFile);
-    }
-
-    return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myFile);
-
-    /*
-VirtualFile result = LocalFileSystem.getInstance().findFileByIoFile(myFile);
-    if (result != null) {
-      return result;
-    }
-    if (myFile.exists()) {
-      FileUtil.delete(new File(myFile.getAbsolutePath()));
-    }
-    VirtualFile parentVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(myFile.getParentFile());
-    LOG.assertTrue(parentVirtualFile != null);
-    try {
-      return parentVirtualFile.createChildData(this, myFile.getName());
-    }
-    catch (IOException e) {
-      LOG.error(e);
-      return null;
-    }
-    
-    * */
-  }
-
-
   protected void loadState(final StorageData result, final Element element) throws StateStorageException {
     ((FileStorageData)result).myFileName = myFile.getAbsolutePath();
     ((FileStorageData)result).myFilePath = myFile.getAbsolutePath();
index f67d966d698858c953d75cec0783d9dcc5ad4f24..142b39871bf51ea81471b2918c530901bc6d7861 100644 (file)
@@ -136,7 +136,7 @@ public class StorageUtil {
 
   @Nullable
   static VirtualFile getVirtualFile(final IFile ioFile) {
-    return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
+    return LocalFileSystem.getInstance().findFileByIoFile(ioFile);
   }
 
   public static byte[] printDocument(final Document document) throws StateStorage.StateStorageException {
index 2c9bfc019450a2b497af17201af4dee929b1d9b0..cf3e7cc0694057c9b6abd8114e418dd610407bde 100644 (file)
@@ -560,7 +560,7 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
           final String name = element.getAttributeValue(NAME);
 
           if (name == null) {
-            LOG.error("Broken content in file : " + this);
+            LOG.info("Broken content in file : " + this);
             continue;
           }
 
index 091eb5d7166f07cd274303236e261f8bb158b2fb..05aeb2f360639a828780b3710068f744b42bbc02 100644 (file)
@@ -15,7 +15,9 @@
  */
 package com.intellij.openapi.options;
 
+import com.intellij.openapi.Disposable;
 import com.intellij.ui.TabbedPaneWrapper;
+import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import java.awt.*;
@@ -25,9 +27,14 @@ import java.awt.*;
  */
 public abstract class TabbedConfigurable extends CompositeConfigurable<Configurable> {
   protected TabbedPaneWrapper myTabbedPane;
+  private final Disposable myParent;
+
+  protected TabbedConfigurable(@NotNull Disposable parent) {
+    myParent = parent;
+  }
 
   public JComponent createComponent() {
-    myTabbedPane = new TabbedPaneWrapper();
+    myTabbedPane = new TabbedPaneWrapper(myParent);
     createConfigurableTabs();
     final JComponent component = myTabbedPane.getComponent();
     component.setPreferredSize(new Dimension(500, 400));
index b547da1eec87f44323da8ae2d229eb272e152c98..e35aad68ff4ffe896d9a9bdcfaf53dd75115bb63 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.application.PathManager;
-import com.intellij.openapi.application.ex.ApplicationEx;
 import com.intellij.openapi.application.ex.ApplicationManagerEx;
 import com.intellij.openapi.application.impl.ApplicationImpl;
 import com.intellij.openapi.components.ExportableApplicationComponent;
@@ -212,7 +211,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
     try {
       ProjectImpl project =
         createAndInitProject(projectName, filePath, false, isDummy, ApplicationManager.getApplication().isUnitTestMode(),
-                             useDefaultProjectSettings ? getDefaultProject() : null, null);
+                             useDefaultProjectSettings ? getDefaultProject() : null);
       if (LOG_PROJECT_LEAKAGE_IN_TESTS) {
         myProjects.put(project, null);
       }
@@ -242,17 +241,13 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
   }
 
   private ProjectImpl createAndInitProject(String projectName, String filePath, boolean isDefault, boolean isDummy, boolean isOptimiseTestLoadSpeed,
-                                    @Nullable Project template, @Nullable Pair<Class, Object> additionalPicoContainerComponents) throws IOException {
+                                           @Nullable Project template) throws IOException {
     if (isDummy) {
       throw new UnsupportedOperationException("Dummy project is deprecated and shall not be used anymore.");
     }
     final ProjectImpl project = isDefault ? new DefaultProject(this, filePath, isOptimiseTestLoadSpeed, projectName) :
                                 new ProjectImpl(this, filePath, isOptimiseTestLoadSpeed, projectName);
 
-    if (additionalPicoContainerComponents != null) {
-      project.getPicoContainer().registerComponentInstance(additionalPicoContainerComponents.first, additionalPicoContainerComponents.second);
-    }
-
     ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectLifecycleListener.TOPIC).beforeProjectLoaded(project);
 
     try {
@@ -291,7 +286,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
   @Nullable
   public Project loadProject(String filePath) throws IOException, JDOMException, InvalidDataException {
     try {
-      return loadProject(filePath, null);
+      return doLoadProject(filePath);
     }
     catch (StateStorage.StateStorageException e) {
       throw new IOException(e.getMessage());
@@ -299,11 +294,11 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
   }
 
   @Nullable
-  private Project loadProject(String filePath, Pair<Class, Object> additionalPicoContainerComponents) throws IOException, StateStorage.StateStorageException {
+  private Project doLoadProject(String filePath) throws IOException, StateStorage.StateStorageException {
     filePath = canonicalize(filePath);
     ProjectImpl project = null;
     try {
-      project = createAndInitProject(null, filePath, false, false, false, null, additionalPicoContainerComponents);
+      project = createAndInitProject(null, filePath, false, false, false, null);
     }
     catch (ProcessCanceledException e) {
       if (project != null) {
@@ -336,7 +331,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
   public synchronized Project getDefaultProject() {
     if (myDefaultProject == null) {
       try {
-        myDefaultProject = createAndInitProject(null, null, true, false, ApplicationManager.getApplication().isUnitTestMode(), null, null);
+        myDefaultProject = createAndInitProject(null, null, true, false, ApplicationManager.getApplication().isUnitTestMode(), null);
         myDefaultProjectRootElement = null;
       }
       catch (IOException e) {
@@ -428,26 +423,20 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
     return loadAndOpenProject(filePath, true);
   }
 
+  @Nullable
+  protected Project convertAndLoadProject(String filePath, boolean convert) throws IOException {
+    return loadProjectWithProgress(filePath);
+  }
+
   @Nullable
   public Project loadAndOpenProject(final String filePath, final boolean convert) throws IOException, JDOMException, InvalidDataException {
     try {
 
-      final Pair<Class, Object> convertorComponent;
-      if (convert) {
-        try {
-          convertorComponent = convertProject(filePath);
-        }
-        catch (ProcessCanceledException e) {
-          return null;
-        }
-      }
-      else {
-        convertorComponent = null;
+      Project project = convertAndLoadProject(filePath, convert);
+      if (project == null) {
+        return null;
       }
 
-      Project project = loadProjectWithProgress(filePath, convertorComponent);
-      if (project == null) return null;
-
       if (!openProject(project)) {
         Disposer.dispose(project);
         return null;
@@ -461,12 +450,12 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
   }
 
   @Nullable
-  public Project loadProjectWithProgress(final String filePath, final Pair<Class, Object> convertorComponent) throws IOException {
-    return loadProjectWithProgress(filePath, convertorComponent, null);
+  public Project loadProjectWithProgress(final String filePath) throws IOException {
+    return loadProjectWithProgress(filePath, null);
   }
 
   @Nullable
-  public Project loadProjectWithProgress(final String filePath, final Pair<Class, Object> convertorComponent, Ref<Boolean> canceled) throws IOException {
+  public Project loadProjectWithProgress(final String filePath, Ref<Boolean> canceled) throws IOException {
     final IOException[] io = {null};
     final StateStorage.StateStorageException[] stateStorage = {null};
 
@@ -483,7 +472,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
             indicator.setText(ProjectBundle.message("loading.components.for", filePath));
             indicator.setIndeterminate(true);
           }
-          project[0] = loadProject(filePath, convertorComponent);
+          project[0] = doLoadProject(filePath);
         }
         catch (IOException e) {
           io[0] = e;
@@ -550,11 +539,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
     }
   }
 
-  @Nullable
-  protected Pair<Class, Object> convertProject(final String filePath) throws ProcessCanceledException {
-    return null;
-  }
-
   private static void notifyProjectOpenFailed() {
     ApplicationManager.getApplication().getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).projectOpenFailed();
   }
index 1ac2c913a1e775f6cd91aeabc08e77f7382c912e..5a61075032e2855f8bfc9358606068938f770ecf 100644 (file)
@@ -38,6 +38,7 @@ import java.util.List;
 
 public class FileWatcher {
   @NonNls public static final String PROPERTY_WATCHER_DISABLED = "filewatcher.disabled";
+  @NonNls private static final String PROPERTY_WATCHER_EXECUTABLE_PATH = "idea.filewatcher.executable.path";
 
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.impl.local.FileWatcher");
 
@@ -180,7 +181,15 @@ public class FileWatcher {
     shutdownProcess();
 
     @NonNls final String executableName = SystemInfo.isWindows ? "fsnotifier.exe" : "fsnotifier";
-    notifierProcess = Runtime.getRuntime().exec(new String[]{PathManager.getBinPath() + File.separatorChar + executableName});
+
+    String alternatePathToFilewatcherExecutable = System.getProperty(PROPERTY_WATCHER_EXECUTABLE_PATH);
+    if (alternatePathToFilewatcherExecutable != null) {
+      if (!new File(alternatePathToFilewatcherExecutable).exists()) {
+        alternatePathToFilewatcherExecutable = null;
+      }
+    }
+    final String pathToExecutable = alternatePathToFilewatcherExecutable != null? FileUtil.toSystemDependentName(alternatePathToFilewatcherExecutable) : PathManager.getBinPath() + File.separatorChar + executableName;
+    notifierProcess = Runtime.getRuntime().exec(new String[]{pathToExecutable});
     
     notifierReader = new BufferedReader(new InputStreamReader(notifierProcess.getInputStream()));
     notifierWriter = new BufferedWriter(new OutputStreamWriter(notifierProcess.getOutputStream()));
index 53a0ff26d4e45113253b1509be186b02a30bbb20..f5069208f44fa5612cef7c3c52746ff7e751ea4b 100644 (file)
@@ -84,7 +84,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor {
     Ref<Boolean> cancelled = new Ref<Boolean>();
     if (projectDir.exists()) {
       try {
-        project = ((ProjectManagerImpl) projectManager).loadProjectWithProgress(baseDir.getPath(), null, cancelled);
+        project = ((ProjectManagerImpl) projectManager).loadProjectWithProgress(baseDir.getPath(), cancelled);
       }
       catch (Exception e) {
         // ignore
index 732a018faa435ee60f3818a4a7c8904203920315..93c933a961d9eda55ea10e39325a46ffcd736c7f 100644 (file)
@@ -233,7 +233,12 @@ public class EditorComboBox extends JComboBox implements DocumentListener {
   }
 
   private void setEditor() {
-    myEditorField = new EditorTextField(myDocument, myProject, myFileType, myIsViewer);
+    myEditorField = new EditorTextField(myDocument, myProject, myFileType, myIsViewer) {
+      @Override
+      protected boolean shouldHaveBorder() {
+        return UIManager.getBorder("ComboBox.border") == null;
+      }
+    };
     final ComboBoxEditor editor = new MyEditor();
     setEditor(editor);
     setRenderer(new EditorComboBoxRenderer(editor));
index bec0ef3d163282628e176a1392bf86f452d672fc..9d7ae9799e435d509df33e38c506c6daabef5968 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.ui.tabs.*;
 import com.intellij.ui.tabs.impl.JBTabsImpl;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
@@ -35,8 +36,8 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
   private final JBTabs myTabs;
   private final CopyOnWriteArraySet<ChangeListener> myListeners = new CopyOnWriteArraySet<ChangeListener>();
 
-  public JBTabsPaneImpl(@Nullable Project project, int tabPlacement, Disposable parent) {
-    myTabs = new JBTabsImpl(project, ActionManager.getInstance(), project != null ? IdeFocusManager.getInstance(project) : null, parent);
+  public JBTabsPaneImpl(@Nullable Project project, int tabPlacement, @NotNull Disposable parent) {
+    myTabs = new JBTabsImpl(project, ActionManager.getInstance(), project == null ? null : IdeFocusManager.getInstance(project), parent);
     myTabs.addListener(new TabsListener.Adapter() {
       @Override
       public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) {
index 17930f2ff928f5e0e9a701919fddd54d86efe0ba..fad4918474e413f443266df06a1a470c55335783 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.actionSystem.DataProvider;
 import com.intellij.openapi.actionSystem.IdeActions;
 import com.intellij.openapi.application.ex.ApplicationEx;
 import com.intellij.openapi.application.ex.ApplicationManagerEx;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
 import com.intellij.ui.tabs.JBTabs;
@@ -38,7 +37,6 @@ import java.awt.event.MouseListener;
  * @author Vladimir Kondratyev
  */
 public class TabbedPaneWrapper  {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.ui.TabbedPaneWrapper");
   private static final PrevNextActionsDescriptor DEFAULT_SHORTCUTS = new PrevNextActionsDescriptor(IdeActions.ACTION_NEXT_TAB, IdeActions.ACTION_PREVIOUS_TAB);
   protected TabbedPane myTabbedPane;
   protected JComponent myTabbedPaneHolder;
@@ -51,11 +49,7 @@ public class TabbedPaneWrapper  {
     }
   }
 
-  public TabbedPaneWrapper(){
-    this(SwingConstants.TOP);
-  }
-
-  public TabbedPaneWrapper(Disposable parentDisposable) {
+  public TabbedPaneWrapper(@NotNull Disposable parentDisposable) {
     this(SwingConstants.TOP, DEFAULT_SHORTCUTS, parentDisposable);
   }
 
@@ -66,16 +60,7 @@ public class TabbedPaneWrapper  {
    * <code>SwingConstants.LEFT</code>, <code>SwingConstants.BOTTOM</code> or
    * <code>SwingConstants.RIGHT</code>.
    */
-  public TabbedPaneWrapper(final int tabPlacement) {
-    this(tabPlacement, DEFAULT_SHORTCUTS);
-  }
-
-
-  public TabbedPaneWrapper(int tabPlacement, PrevNextActionsDescriptor installKeyboardNavigation) {
-    this(tabPlacement, installKeyboardNavigation, null);
-  }
-
-  public TabbedPaneWrapper(int tabPlacement, PrevNextActionsDescriptor installKeyboardNavigation, final Disposable parentDisposable) {
+  public TabbedPaneWrapper(int tabPlacement, PrevNextActionsDescriptor installKeyboardNavigation, @NotNull Disposable parentDisposable) {
     final TabFactory factory;
     if (SwingConstants.BOTTOM == tabPlacement || SwingConstants.TOP == tabPlacement) {
       factory = new JBTabsFactory(this, null, parentDisposable);
@@ -354,7 +339,7 @@ public class TabbedPaneWrapper  {
   public static final class TabWrapper extends JPanel implements DataProvider{
     private JComponent myComponent;
 
-    protected boolean myCustomFocus = true;
+    boolean myCustomFocus = true;
 
     public TabWrapper(@NotNull final JComponent component) {
       super(new BorderLayout());
@@ -499,7 +484,7 @@ public class TabbedPaneWrapper  {
     private final Disposable myParent;
     private final TabbedPaneWrapper myWrapper;
 
-    private JBTabsFactory(TabbedPaneWrapper wrapper, Project project, Disposable parent) {
+    private JBTabsFactory(TabbedPaneWrapper wrapper, Project project, @NotNull Disposable parent) {
       myWrapper = wrapper;
       myProject = project;
       myParent = parent;
@@ -535,14 +520,6 @@ public class TabbedPaneWrapper  {
   }
 
   public static class AsJBTabs extends TabbedPaneWrapper {
-    public AsJBTabs(@NotNull Project project) {
-      this(project, SwingConstants.TOP);
-    }
-
-    public AsJBTabs(@NotNull Project project, int tabPlacement) {
-      this(project, tabPlacement, DEFAULT_SHORTCUTS, project);
-    }
-
     public AsJBTabs(@Nullable Project project, int tabPlacement, PrevNextActionsDescriptor installKeyboardNavigation, @NotNull Disposable parent) {
       super(false);
       init(tabPlacement, installKeyboardNavigation, new JBTabsFactory(this, project, parent));
@@ -554,16 +531,9 @@ public class TabbedPaneWrapper  {
   }
 
   public static class AsJTabbedPane extends TabbedPaneWrapper {
-    public AsJTabbedPane() {
-      this(SwingConstants.TOP);
-    }
-
     public AsJTabbedPane(int tabPlacement) {
-      this(tabPlacement, DEFAULT_SHORTCUTS);
-    }
-
-    public AsJTabbedPane(int tabPlacement, PrevNextActionsDescriptor installKeyboardNavigation) {
-      init(tabPlacement, installKeyboardNavigation, new JTabbedPaneFactory(this));
+      super(false);
+      init(tabPlacement, DEFAULT_SHORTCUTS, new JTabbedPaneFactory(this));
     }
   }
 
index 15093b3fdf211d3591eda906b2c4790751bb992b..4b48aff3b3d85c9e60b00f7531084af92d5d3b0a 100644 (file)
@@ -136,7 +136,6 @@ public class TabbedPaneContentUI implements ContentUI, PropertyChangeListener {
     }
 
     private class MyTabbedPane extends TabbedPaneImpl {
-
       public MyTabbedPane(int tabPlacement) {
         super(tabPlacement);
         addMouseListener(new MyPopupHandler());
index 35fe382c6e0b7e2506d72c43dbe7864fc83654ee..07e4cfea1f86a3119d34c5ff25be661887876ab6 100644 (file)
@@ -2,10 +2,6 @@ fileIndex.background=false
 fileIndex.background.description=Build/update file indices in background
 fileIndex.background.restartRequired=true
 
-fileIndex.multithreaded=true
-fileIndex.multithreaded.description=When indexing a file start indexers in parallel threads
-fileIndex.multithreaded.restartRequired=false 
-
 actionSystem.fixLostTyping=true
 actionSystem.fixLostTyping.description=Redispatch events, lost between actions and dialog show/close
 actionSystem.fixStickyFocusedWindows=true
@@ -43,4 +39,8 @@ debugger.valueTooltipAutoShow.description=Auto show tooltip on mouse over
 
 filesystem.useNative=true
 
-analyze.exceptions.on.the.fly=false
\ No newline at end of file
+analyze.exceptions.on.the.fly=false
+
+compiler.perform.outputs.refresh.on.start=true
+compiler.perform.outputs.refresh.on.start.description=Whether to perform initial FS refresh before compilation starts. Need this to detect external changes to output dirs
+compiler.perform.outputs.refresh.on.start.restartRequired=false
index 8e45ab1ec2369e0bdedaaf088626dee40efdfc81..bcd2646b13c58c1cddd64fbd93d1fd2738eec9c8 100644 (file)
     <keyboard-shortcut first-keystroke="control 3"/>
   </action>
   <action id="FileChooser.NewFolder">
+    <keyboard-shortcut first-keystroke="alt INSERT"/>
     <keyboard-shortcut first-keystroke="control N"/>
   </action>
   <action id="PopupHector">
index 80808f118cc03825dcc0111baf1c0d9f3f34fd92..93ca51f997823deafac3ad13c3267209a5cf1e46 100644 (file)
@@ -25,6 +25,7 @@ public class BuildNumber implements Comparable<BuildNumber> {
   private final String myProductCode;
   private final int myBaselineVersion;
   private final int myBuildNumber;
+  private static final String BUILD_NUMBER = "__BUILD_NUMBER__";
 
   public BuildNumber(String productCode, int baselineVersion, int buildNumber) {
     myProductCode = productCode;
@@ -63,7 +64,7 @@ public class BuildNumber implements Comparable<BuildNumber> {
   public static BuildNumber fromString(String version) {
     if (version == null) return null;
 
-    if ("__BUILD_NUMBER__".equals(version)) return new BuildNumber("IU", 92, Integer.MAX_VALUE);
+    if (BUILD_NUMBER.equals(version)) return new BuildNumber("IU", 92, Integer.MAX_VALUE);
 
     String code = version;
     int productSeparator = code.indexOf('-');
@@ -88,25 +89,10 @@ public class BuildNumber implements Comparable<BuildNumber> {
         throw new RuntimeException("Unparseable version number: " + version);
       }
 
-      if ("SNAPSHOT".equals(code) || "__BUILD_NUMBER__".equals(code)) {
-        buildNumber = Integer.MAX_VALUE;
-      }
-      else {
-        try {
-          buildNumber = Integer.parseInt(code);
-        }
-        catch (NumberFormatException e) {
-          throw new RuntimeException("Unparseable version number: " + version);
-        }
-      }
+      buildNumber = parseBuildNumber(version, code);
     }
     else {
-      try {
-        buildNumber = Integer.parseInt(code);
-      }
-      catch (NumberFormatException e) {
-        throw new RuntimeException("Unparseable version number: " + version);
-      }
+      buildNumber = parseBuildNumber(version, code);
 
       if (buildNumber <= 2000) {
         // it's probably a baseline, not a build number
@@ -119,6 +105,18 @@ public class BuildNumber implements Comparable<BuildNumber> {
     return new BuildNumber(productCode, baselineVersion, buildNumber);
   }
 
+  private static int parseBuildNumber(String version, String code) {
+    if ("SNAPSHOT".equals(code) || BUILD_NUMBER.equals(code)) {
+      return Integer.MAX_VALUE;
+    }
+    try {
+      return Integer.parseInt(code);
+    }
+    catch (NumberFormatException e) {
+      throw new RuntimeException("Unparseable version number: " + version);
+    }
+  }
+
   @Override
   public String toString() {
     return asString();
index 4f2970dae47057dd5a9c2cf4226543bd297ecada..b8672686477b0ea2cdfaa83f16d12c01e1f05e39 100644 (file)
@@ -179,7 +179,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
     final UpToDateLineNumberProvider getUpToDateLineNumber = new UpToDateLineNumberProviderImpl(
       editor.getDocument(),
       project,
-      upToDateContent, file);
+      upToDateContent);
 
     editor.getGutter().closeAllAnnotations();
 
index 101ba139c5f55d8f82bff209467450c1bde28e44..b78d6ce6550952cc636cc6b57ef40cc11bcfee24 100644 (file)
@@ -39,6 +39,10 @@ public class EditAction extends AnAction {
   public void actionPerformed(AnActionEvent e) {
     final Project project = e.getData(PlatformDataKeys.PROJECT);
     List<VirtualFile> files = e.getData(VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY);
+    editFilesAndShowErrors(project, files);
+  }
+
+  public static void editFilesAndShowErrors(Project project, List<VirtualFile> files) {
     final List<VcsException> exceptions = new ArrayList<VcsException>();
     editFiles(project, files, exceptions);
     if (!exceptions.isEmpty()) {
index 2195b581f339296e0073f1922cae2f32ae440b52..096f810a1d298c95e330d6445b3c58544914b884 100644 (file)
@@ -319,7 +319,7 @@ public class MultipleChangeListBrowser extends ChangesBrowser {
     public void addToolbarActions(final DialogWrapper dialogWrapper) {
       final Icon icon = IconLoader.getIcon("/vcs/refresh.png");
       if (myBrowser.myChangesToDisplay == null) {
-        myBrowser.addToolbarAction(new AnAction() {
+        myBrowser.addToolbarAction(new AnAction("Refresh Changes") {
           @Override
           public void actionPerformed(AnActionEvent e) {
             myBrowser.rebuildList();
index ab83cad1840ecb8cc527f73c0bd71a54756b549e..c585dc362212a5351bac7b0b5525af2d62afb993 100644 (file)
@@ -46,7 +46,6 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vcs.VcsBundle;
 import com.intellij.openapi.vcs.actions.ShowNextChangeMarkerAction;
 import com.intellij.openapi.vcs.actions.ShowPrevChangeMarkerAction;
-import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
 import com.intellij.openapi.vfs.ReadonlyStatusHandler;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.HintListener;
@@ -70,7 +69,6 @@ public class LineStatusTracker {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.ex.LineStatusTracker");
   private final Document myDocument;
   private final Document myUpToDateDocument;
-  private final VirtualFile myVf;
   @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) private List<Range> myRanges = new ArrayList<Range>();
   private final Project myProject;
   @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) private int myHighlighterCount = 0;
@@ -80,15 +78,12 @@ public class LineStatusTracker {
   private boolean myIsReleased = false;
   private boolean myIsInitialized = false;
   private boolean myBulkUpdate;
-  private VcsDirtyScopeManager myDirtyScopeManager;
 
-  public LineStatusTracker(Document document, Document upToDateDocument, Project project, VirtualFile vf) {
+  public LineStatusTracker(Document document, Document upToDateDocument, Project project) {
     myDocument = document;
     myUpToDateDocument = upToDateDocument;
-    myVf = vf;
     myUpToDateDocument.putUserData(UndoManager.DONT_RECORD_UNDO, Boolean.TRUE);
     myProject = project;
-    myDirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
   }
 
   public synchronized void initialize(@NotNull final String upToDateContent) {
@@ -386,10 +381,6 @@ public class LineStatusTracker {
       shiftRanges(rangesAfterChange, linesShift);
 
       if (!changedRanges.equals(newChangedRanges)) {
-        if ((myVf != null) && newChangedRanges.isEmpty() && (! changedRanges.isEmpty())) {
-          FileDocumentManager.getInstance().saveDocument(myDocument);
-          myDirtyScopeManager.fileDirty(myVf);
-        }
         replaceRanges(changedRanges, newChangedRanges);
 
         myRanges = new ArrayList<Range>();
@@ -532,8 +523,15 @@ public class LineStatusTracker {
 
   @Nullable
   public Range getNextRange(int line) {
+    final Range currentRange = getRangeForLine(line);
+    if (currentRange != null) {
+      return getNextRange(currentRange);
+    }
+
     for (Range range : myRanges) {
-      if (range.getOffset2() < line) continue;
+      if (line > range.getOffset1() || line > range.getOffset2()) {
+        continue;
+      }
       return range;
     }
     return null;
@@ -541,14 +539,34 @@ public class LineStatusTracker {
 
   @Nullable
   public Range getPrevRange(int line) {
+    final Range currentRange = getRangeForLine(line);
+    if (currentRange != null) {
+      return getPrevRange(currentRange);
+    }
+
     for (ListIterator<Range> iterator = myRanges.listIterator(myRanges.size()); iterator.hasPrevious();) {
       Range range = iterator.previous();
-      if (range.getOffset1() > line) continue;
+      if (range.getOffset1() > line) {
+        continue;
+      }
       return range;
     }
     return null;
   }
 
+  @Nullable
+  public Range getRangeForLine(final int line) {
+    for (final Range range : myRanges) {
+      if (range.getType() == Range.DELETED && line == range.getOffset1()) {
+        return range;
+      }
+      else if (line >= range.getOffset1() && line < range.getOffset2()) {
+        return range;
+      }
+    }
+    return null;
+  }
+
   public static abstract class MyAction extends AnAction implements DumbAware {
     protected final LineStatusTracker myLineStatusTracker;
     protected final Range myRange;
@@ -810,16 +828,16 @@ public class LineStatusTracker {
     return file.getName();
   }
 
-  public static LineStatusTracker createOn(Document doc, String upToDateContent, Project project, VirtualFile vf) {
+  public static LineStatusTracker createOn(Document doc, String upToDateContent, Project project) {
     Document document = EditorFactory.getInstance().createDocument(StringUtil.convertLineSeparators(upToDateContent));
-    final LineStatusTracker tracker = new LineStatusTracker(doc, document, project, vf);
+    final LineStatusTracker tracker = new LineStatusTracker(doc, document, project);
     tracker.initialize(upToDateContent);
     return tracker;
   }
 
-  public static LineStatusTracker createOn(Document doc, Project project, VirtualFile vf) {
+  public static LineStatusTracker createOn(Document doc, Project project) {
     Document document = EditorFactory.getInstance().createDocument("");
-    return new LineStatusTracker(doc, document, project, vf);
+    return new LineStatusTracker(doc, document, project);
   }
 
 }
index e82cb42b24800a109cbe0ab071f5fda27a6907a5..2e341af967007dababb7d2d1a4e304a570fdcbdd 100644 (file)
@@ -155,7 +155,9 @@ public class Range {
 
   public Range mergeWith(Range range, LineStatusTracker tracker) {
     tracker.removeHighlighter(getHighlighter());
+    setHighlighter(null);
     tracker.removeHighlighter(range.getHighlighter());
+    range.setHighlighter(null);
     Range result = new Range(myOffset1, range.myOffset2, myUpToDateOffset1, range.myUpToDateOffset2, mergedStatusWith(range));
     return result;
   }
index 5ce376ef357b6ede9909131fb2149af1733cc0b9..8abf8dbf2d5bbd5202d1dcaad0d631d3a4427861 100644 (file)
@@ -22,6 +22,7 @@
  */
 package com.intellij.openapi.vcs.impl;
 
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.components.ProjectComponent;
 import com.intellij.openapi.diagnostic.Logger;
@@ -48,7 +49,6 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileAdapter;
 import com.intellij.openapi.vfs.VirtualFileEvent;
 import com.intellij.openapi.vfs.VirtualFileManager;
-import com.intellij.openapi.Disposable;
 import com.intellij.testFramework.LightVirtualFile;
 import com.intellij.util.Alarm;
 import com.intellij.util.containers.HashMap;
@@ -172,11 +172,11 @@ public class LineStatusTrackerManager implements ProjectComponent {
   }
 
 
-  public LineStatusTracker setUpToDateContent(final Document document, final String lastUpToDateContent, final VirtualFile vf) {
+  public LineStatusTracker setUpToDateContent(final Document document, final String lastUpToDateContent) {
     trackAwtThread();
     LineStatusTracker result = myLineStatusTrackers.get(document);
     if (result == null) {
-      result = LineStatusTracker.createOn(document, lastUpToDateContent, myProject, vf);
+      result = LineStatusTracker.createOn(document, lastUpToDateContent, myProject);
       myLineStatusTrackers.put(document, result);
     }
     return result;
@@ -184,7 +184,7 @@ public class LineStatusTrackerManager implements ProjectComponent {
 
   private LineStatusTracker createTrackerForDocument(Document document, VirtualFile vf) {
     LOG.assertTrue(!myLineStatusTrackers.containsKey(document));
-    LineStatusTracker result = LineStatusTracker.createOn(document, myProject, vf);
+    LineStatusTracker result = LineStatusTracker.createOn(document, myProject);
     myLineStatusTrackers.put(document, result);
     return result;
   }
index 5e22d632a6d8b65644e0dcc6da1da396543c518c..14d668f06285084d3036d27a30519f0b682451f9 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vcs.ex.LineStatusTracker;
 import com.intellij.openapi.vcs.ex.Range;
-import com.intellij.openapi.vfs.VirtualFile;
 
 import java.util.List;
 
@@ -31,19 +30,17 @@ public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvide
   private final Document myDocument;
   private final Project myProject;
   private final String myUpToDateContent;
-  private final VirtualFile myVf;
 
-  public UpToDateLineNumberProviderImpl(Document document, Project project, String upToDateContent, VirtualFile vf) {
+  public UpToDateLineNumberProviderImpl(Document document, Project project, String upToDateContent) {
     myDocument = document;
     myProject = project;
     myUpToDateContent = upToDateContent;
-    myVf = vf;
   }
 
   public int getLineNumber(int currentNumber) {
     LineStatusTracker tracker = LineStatusTrackerManager.getInstance(myProject).getLineStatusTracker(myDocument);
     if (tracker == null) {
-      tracker = LineStatusTrackerManager.getInstance(myProject).setUpToDateContent(myDocument, myUpToDateContent, myVf);
+      tracker = LineStatusTrackerManager.getInstance(myProject).setUpToDateContent(myDocument, myUpToDateContent);
     }
     return calcLineNumber(tracker, currentNumber);
   }
index ab11eacb883650218bfa95cf5ef6ee635cfce414..7c7ab4799a672764743b1c1480f8f71a97629d23 100644 (file)
@@ -45,7 +45,7 @@ public class VcsFileStatusProvider implements FileStatusProvider {
 
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.VcsFileStatusProvider");
 
-  private VcsFileStatusProvider(final Project project,
+  public VcsFileStatusProvider(final Project project,
                                final FileStatusManagerImpl fileStatusManager,
                                final ProjectLevelVcsManager vcsManager,
                                ChangeListManager changeListManager,
index bc39c6159ead3d49914e699b78548e33ddfc170f..8184d916a6ef04f4cd16f4fc98150593d1e3a979 100644 (file)
@@ -116,7 +116,7 @@ public class BreakpointsConfigurationDialogFactory {
     }
 
     protected JComponent createCenterPanel() {
-      myTabbedPane = new TabbedPaneWrapper();
+      myTabbedPane = new TabbedPaneWrapper(getDisposable());
       myPanel = new JPanel(new BorderLayout());
 
       for (BreakpointPanelProvider<?> panelProvider : myBreakpointPanelProviders) {
index cd064c00a0711f390e3e290518220e9dfff0c3f5..2b18e260f1eceaf7027dddafc0296f7e85231420 100644 (file)
     <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("query").definedInClass("groovy.sql.Sql"))]]></place>
     <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("rows").definedInClass("groovy.sql.Sql"))]]></place>
   </injection>
+  <injection language="Groovy" injector-id="groovy">
+    <display-name>GroovyShell (groovy.lang)</display-name>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("evaluate").withParameters("java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("evaluate").withParameters("java.lang.String", "java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("evaluate").withParameters("java.lang.String", "java.lang.String", "java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("parse").withParameters("java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("parse").withParameters("java.lang.String", "java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("run").withParameters("java.lang.String", "java.lang.String", "java.lang.String[]").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[groovyElement().methodCallParameter(0, psiMethod().withName("run").withParameters("java.lang.String", "java.lang.String", "java.util.List").definedInClass("groovy.lang.GroovyShell"))]]></place>
+  </injection>
+  <injection language="Groovy" injector-id="java">
+    <display-name>GroovyShell (groovy.lang)</display-name>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("evaluate").withParameters("java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("evaluate").withParameters("java.lang.String", "java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("evaluate").withParameters("java.lang.String", "java.lang.String", "java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("parse").withParameters("java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("parse").withParameters("java.lang.String", "java.lang.String").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("run").withParameters("java.lang.String", "java.lang.String", "java.lang.String[]").definedInClass("groovy.lang.GroovyShell"))]]></place>
+    <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("run").withParameters("java.lang.String", "java.lang.String", "java.util.List").definedInClass("groovy.lang.GroovyShell"))]]></place>
+  </injection>
   <injection language="SQL" injector-id="java">
     <display-name>BatchSqlUpdate (org.springframework.jdbc.object)</display-name>
     <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("BatchSqlUpdate").withParameters("javax.sql.DataSource", "java.lang.String").definedInClass("org.springframework.jdbc.object.BatchSqlUpdate"))]]></place>
     <place><![CDATA[xmlTag().withLocalName(string().matches("sql|select|insert|update|delete|statement")).withNamespace(string().matches("http://ibatis.apache.org/dtd/sql-map-2.dtd"))]]></place>
     <apply-to-subtags />
   </injection>
+  <injection language="SQL" injector-id="xml">
+    <display-name>iBatis3: sql|select|insert|update|delete</display-name>
+    <place><![CDATA[xmlTag().withLocalName(string().matches("sql|select|insert|update|delete")).withNamespace(string().matches("http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"))]]></place>
+    <apply-to-subtags />
+  </injection>
   <injection language="CSS" injector-id="xml">
     <display-name>style</display-name>
     <place><![CDATA[xmlTag().withLocalName(string().matches("style")).withNamespace(string().matches("http://www.w3.org/1999/xhtml"))]]></place>
index 2a384c8dec6840bbf348efa509b4f2b46e8ac4e6..4758c661c1a8d68a7a595081166664302744c825 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.intellij.plugins.intelliLang;
 
+import com.intellij.ide.DataManager;
 import com.intellij.ide.ui.SplitterProportionsDataImpl;
 import com.intellij.lang.Language;
 import com.intellij.openapi.actionSystem.*;
@@ -29,10 +30,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.SplitterProportionsData;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.Factory;
-import com.intellij.openapi.util.IconLoader;
+import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.*;
@@ -58,6 +56,8 @@ import javax.swing.*;
 import javax.swing.table.TableCellRenderer;
 import java.awt.*;
 import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.util.*;
 import java.util.List;
 
@@ -126,7 +126,7 @@ public class InjectionsSettingsUI implements Configurable {
         addInjection(injection);
       }
     };
-    final Factory<BaseInjection> producer = new Factory<BaseInjection>() {
+    final Factory<BaseInjection> producer = new NullableFactory<BaseInjection>() {
       public BaseInjection create() {
         return getSelectedInjection();
       }
@@ -152,7 +152,6 @@ public class InjectionsSettingsUI implements Configurable {
       @Override
       public void actionPerformed(final AnActionEvent e) {
         performAdd(e);
-        updateCountLabel();
       }
     };
     final AnAction removeAction = new AnAction("Remove", "Remove", Icons.DELETE_ICON) {
@@ -164,7 +163,6 @@ public class InjectionsSettingsUI implements Configurable {
       @Override
       public void actionPerformed(final AnActionEvent e) {
         performRemove();
-        updateCountLabel();
       }
     };
 
@@ -178,16 +176,29 @@ public class InjectionsSettingsUI implements Configurable {
 
       @Override
       public void actionPerformed(final AnActionEvent e) {
-        final int row = myInjectionsTable.getSelectedRow();
+        performEditAction(e);
+      }
+    };
+    final AnAction copyAction = new AnAction("Duplicate", "Duplicate", Icons.DUPLICATE_ICON) {
+      @Override
+      public void update(final AnActionEvent e) {
         final AnAction action = getEditAction();
-        action.actionPerformed(e);
-        ((ListTableModel)myInjectionsTable.getModel()).fireTableDataChanged();
-        myInjectionsTable.getSelectionModel().setSelectionInterval(row, row);
-        updateCountLabel();
+        e.getPresentation().setEnabled(action != null);
+        if (action != null) action.update(e);
+      }
+
+      @Override
+      public void actionPerformed(final AnActionEvent e) {
+        final BaseInjection injection = getSelectedInjection();
+        if (injection != null) {
+          addInjection(injection.copy());
+          //performEditAction(e);
+        }
       }
     };
     group.add(addAction);
     group.add(removeAction);
+    group.add(copyAction);
     group.add(editAction);
 
     addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myInjectionsTable);
@@ -212,7 +223,6 @@ public class InjectionsSettingsUI implements Configurable {
       @Override
       public void actionPerformed(final AnActionEvent e) {
         performSelectedInjectionsEnabled(false);
-        updateCountLabel();
       }
     });
 
@@ -220,12 +230,22 @@ public class InjectionsSettingsUI implements Configurable {
       @Override
       public void actionPerformed(final AnActionEvent e) {
         performToggleAction();
-        updateCountLabel();
       }
     }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), myInjectionsTable);
     return group;
   }
 
+  private void performEditAction(AnActionEvent e) {
+    final AnAction action = getEditAction();
+    if (action != null) {
+      final int row = myInjectionsTable.getSelectedRow();
+      action.actionPerformed(e);
+      ((ListTableModel)myInjectionsTable.getModel()).fireTableDataChanged();
+      myInjectionsTable.getSelectionModel().setSelectionInterval(row, row);
+      updateCountLabel();
+    }
+  }
+
   private void updateCountLabel() {
     int placesCount = 0;
     int enablePlacesCount = 0;
@@ -246,6 +266,7 @@ public class InjectionsSettingsUI implements Configurable {
     }
   }
 
+  @Nullable
   private AnAction getEditAction() {
     final BaseInjection injection = getSelectedInjection();
     final String supportId = injection == null? null : injection.getSupportId();
@@ -255,13 +276,13 @@ public class InjectionsSettingsUI implements Configurable {
   private void addInjection(final BaseInjection injection) {
     injection.initializePlaces(true);
     myInjections.add(injection);
-    ((ListTableModel<BaseInjection>)myInjectionsTable.getModel()).setItems(myInjections);
+    myInjectionsTable.getListTableModel().setItems(myInjections);
     final int index = myInjections.indexOf(injection);
     myInjectionsTable.getSelectionModel().setSelectionInterval(index, index);
     TableUtil.scrollSelectionToVisible(myInjectionsTable);
   }
 
-  private void sortInjections(final List<BaseInjection> injections) {
+  private static void sortInjections(final List<BaseInjection> injections) {
     Collections.sort(injections, new Comparator<BaseInjection>() {
       public int compare(final BaseInjection o1, final BaseInjection o2) {
         final int support = Comparing.compare(o1.getSupportId(), o2.getSupportId());
@@ -282,7 +303,7 @@ public class InjectionsSettingsUI implements Configurable {
     for (BaseInjection injection : myOriginalInjections) {
       myInjections.add(injection.copy());
     }
-    ((ListTableModel<BaseInjection>)myInjectionsTable.getModel()).setItems(myInjections);
+    myInjectionsTable.getListTableModel().setItems(myInjections);
     updateCountLabel();
   }
 
@@ -308,6 +329,7 @@ public class InjectionsSettingsUI implements Configurable {
       injection.setPlaceEnabled(null, enabled);
     }
     myInjectionsTable.updateUI();
+    updateCountLabel();
   }
 
   private void performToggleAction() {
@@ -326,17 +348,27 @@ public class InjectionsSettingsUI implements Configurable {
   private void performRemove() {
     final int selectedRow = myInjectionsTable.getSelectedRow();
     if (selectedRow < 0) return;
-    myInjections.removeAll(getSelectedInjections());
+    final List<BaseInjection> selected = getSelectedInjections();
+    main: for (Iterator<BaseInjection> it = myInjections.iterator(); it.hasNext(); ) {
+      final BaseInjection injection = it.next();
+      for (BaseInjection selectedInjection : selected) {
+        if (injection == selectedInjection) {
+          it.remove();
+          continue main;
+        }
+      }
+    }
     ((ListTableModel)myInjectionsTable.getModel()).fireTableDataChanged();
     final int index = Math.min(myInjections.size() - 1, selectedRow);
     myInjectionsTable.getSelectionModel().setSelectionInterval(index, index);
     TableUtil.scrollSelectionToVisible(myInjectionsTable);
+    updateCountLabel();
   }
 
   private List<BaseInjection> getSelectedInjections() {
     final ArrayList<BaseInjection> toRemove = new ArrayList<BaseInjection>();
     for (int row : myInjectionsTable.getSelectedRows()) {
-      toRemove.add((BaseInjection)myInjectionsTable.getItems().get(row));
+      toRemove.add(myInjectionsTable.getItems().get(row));
     }
     return toRemove;
   }
@@ -344,7 +376,7 @@ public class InjectionsSettingsUI implements Configurable {
   @Nullable
   private BaseInjection getSelectedInjection() {
     final int row = myInjectionsTable.getSelectedRow();
-    return row < 0? null : (BaseInjection)myInjectionsTable.getItems().get(row);
+    return row < 0? null : myInjectionsTable.getItems().get(row);
   }
 
   private void performAdd(final AnActionEvent e) {
@@ -353,8 +385,11 @@ public class InjectionsSettingsUI implements Configurable {
       group.add(action);
     }
 
-    JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, true)
-      .showUnderneathOf(myToolbar.getComponent());
+    JBPopupFactory.getInstance().createActionGroupPopup(null, group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, true, new Runnable() {
+      public void run() {
+        updateCountLabel();
+      }
+    }, -1).showUnderneathOf(myToolbar.getComponent());
   }
 
   @Nls
@@ -367,10 +402,10 @@ public class InjectionsSettingsUI implements Configurable {
   }
 
   public String getHelpTopic() {
-    return null;
+    return "reference.settings.injection.language.injection.settings";
   }
 
-  private class InjectionsTable extends TableView {
+  private class InjectionsTable extends TableView<BaseInjection> {
     private InjectionsTable(final List<BaseInjection> injections) {
       super(new ListTableModel<BaseInjection>(createInjectionColumnInfos(), injections, 1));
       setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);
@@ -389,7 +424,18 @@ public class InjectionsSettingsUI implements Configurable {
           return true;
         }
       });
-      final int[] max = new int[] {0} ;
+      final int[] max = new int[] {0};
+      addMouseListener(new MouseAdapter() {
+        public void mouseClicked(MouseEvent e) {
+          if (e.getClickCount() != 2) return;
+          final int row = rowAtPoint(e.getPoint());
+          if (row < 0) return;
+          if (columnAtPoint(e.getPoint()) <= 0) return;
+          myInjectionsTable.getSelectionModel().setSelectionInterval(row, row);
+          performEditAction(new AnActionEvent(e, DataManager.getInstance().getDataContext(InjectionsTable.this),
+                                              ActionPlaces.UNKNOWN, new Presentation(""), ActionManager.getInstance(), 0));
+        }
+      });
       ContainerUtil.process(InjectedLanguage.getAvailableLanguageIDs(), new Processor<String>() {
         public boolean process(final String languageId) {
           if (max[0] < languageId.length()) max[0] = languageId.length();
@@ -609,7 +655,6 @@ public class InjectionsSettingsUI implements Configurable {
         final List<BaseInjection> importingInjections = cfg.getInjections(supportId);
         if (currentInjections == null) {
           newInjections.addAll(importingInjections);
-          continue;
         }
         else {
           Configuration.importInjections(currentInjections, importingInjections, originalInjections, newInjections);
@@ -620,7 +665,7 @@ public class InjectionsSettingsUI implements Configurable {
       for (BaseInjection injection : newInjections) {
         injection.initializePlaces(true);
       }
-      ((ListTableModel<BaseInjection>)myInjectionsTable.getModel()).setItems(myInjections);
+      myInjectionsTable.getListTableModel().setItems(myInjections);
       final int n = newInjections.size();
       if (n > 1) {
         Messages.showInfoMessage(myProject, n + " entries have been successfully imported", "Import Successful");
index ba942d086416dd0f1084c8af75864fce84d799fc..fac5ce374751ef331278dde0ba4977e5df0e17a8 100644 (file)
@@ -61,7 +61,9 @@ public class Settings implements Configurable {
   @Nullable
   @NonNls
   public String getHelpTopic() {
-    return "IntelliLang.Configuration";
+    final Configurable child = mySettingsUI == null? null : mySettingsUI.getSelectedChild();
+    final String topic = child != null ? child.getHelpTopic() : null;
+    return topic != null? topic : "IntelliLang.Configuration";
   }
 
   public JComponent createComponent() {
index c652e76ff5e32e6c1de2f276bf9ec88778bb7135..84d0f0dc8be85e5b727cfe350cce3adca20b50e4 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
@@ -36,14 +37,15 @@ import java.util.Comparator;
  */
 class SettingsUI {
 
-  private JPanel myRoot = new JPanel(new BorderLayout());
-
   private Configurable[] myConfigurables;
 
+  private final JPanel myRoot = new JPanel(new BorderLayout());
+  private final JTabbedPane myTabbedPane;
+
 
   SettingsUI(@NotNull final Project project, Configuration configuration) {
-    final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
-    myRoot.add(tabbedPane);
+    myTabbedPane = new JTabbedPane(JTabbedPane.TOP);
+    myRoot.add(myTabbedPane);
 
     final ArrayList<Configurable> configurables = new ArrayList<Configurable>();
     for (LanguageInjectionSupport support : Extensions.getExtensions(LanguageInjectionSupport.EP_NAME)) {
@@ -57,7 +59,7 @@ class SettingsUI {
     configurables.add(0, new InjectionsSettingsUI(project, configuration));
     myConfigurables = configurables.toArray(new Configurable[configurables.size()]);
     for (Configurable configurable : configurables) {
-      tabbedPane.addTab(configurable.getDisplayName(), configurable.createComponent());
+      myTabbedPane.addTab(configurable.getDisplayName(), configurable.createComponent());
     }
   }
 
@@ -65,6 +67,13 @@ class SettingsUI {
     return myRoot;
   }
 
+  @Nullable
+  public Configurable getSelectedChild() {
+    final int index = myTabbedPane.getSelectedIndex();
+    if (index >= 0) return myConfigurables[index];
+    return null;
+  }
+
   public boolean isModified() {
     for (Configurable configurable : myConfigurables) {
       if (configurable.isModified()) return true;
index 418673477a2beea7cfe407358e9ed4989ebbef60..721cccf191989da7d996e136549690e04a73f687 100644 (file)
@@ -150,6 +150,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
     final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
     panel.reset();
     final DialogBuilder builder = new DialogBuilder(project);
+    builder.setHelpId("reference.settings.injection.language.injection.settings");
     builder.addOkAction();
     builder.addCancelAction();
     builder.setCenterPanel(panel.getComponent());
index 6d30ad81913c9dd651ad4506df82e55454e8b3d3..afd2c49bccc7ba835fe0fd8978076051054a1e95 100644 (file)
@@ -148,6 +148,7 @@ public class XmlLanguageInjectionSupport extends AbstractLanguageInjectionSuppor
     else throw new AssertionError();
     panel.reset();
     final DialogBuilder builder = new DialogBuilder(project);
+    builder.setHelpId("reference.settings.injectio