Merge branch 'master' of git.labs.intellij.net:idea/community
authorirengrig <Irina.Chernushina@jetbrains.com>
Fri, 26 Mar 2010 12:55:59 +0000 (15:55 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Fri, 26 Mar 2010 12:55:59 +0000 (15:55 +0300)
115 files changed:
build/scripts/dist.gant
java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java
java/debugger/impl/src/com/intellij/debugger/actions/AddToWatchActionHandler.java
java/debugger/impl/src/com/intellij/debugger/impl/GenericDebuggerRunner.java
java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java
java/execution/openapi/src/com/intellij/execution/runners/JavaPatchableProgramRunner.java
java/execution/openapi/src/com/intellij/execution/runners/JavaProgramPatcher.java [new file with mode: 0644]
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromSourcesMode.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTableEditor.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/MoveFieldAssignmentToInitializerAction.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/MoveInitializerToConstructorAction.java
java/java-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java
java/java-impl/src/com/intellij/psi/impl/PsiImplUtil.java
java/java-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java
java/java-impl/src/com/intellij/psi/impl/light/LightVariableBase.java
java/java-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiReferenceListImpl.java
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java
java/java-impl/src/com/intellij/psi/impl/source/tree/JavaChangeUtilSupport.java
java/java-impl/src/com/intellij/psi/impl/source/tree/java/ExpressionPsiElement.java
java/java-impl/src/com/intellij/psi/impl/source/tree/java/ReplaceExpressionUtil.java
java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
java/java-impl/src/com/intellij/slicer/SliceManager.java
java/java-impl/src/com/intellij/slicer/SlicePanel.java
java/openapi/src/com/intellij/psi/util/TypeConversionUtil.java
lib/nanoxml-2.2.3.jar
lib/src/nanoxml.zip
platform/lang-api/src/com/intellij/codeInspection/LocalInspectionTool.java
platform/lang-api/src/com/intellij/lang/folding/LanguageFolding.java
platform/lang-api/src/com/intellij/psi/stubs/StubIndex.java
platform/lang-api/src/com/intellij/util/xml/NanoXmlUtil.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java
platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockUtil.java
platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java
platform/lang-impl/src/com/intellij/codeInsight/template/macro/EnumMacro.java [moved from java/java-impl/src/com/intellij/codeInsight/template/macro/EnumMacro.java with 100% similarity]
platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java
platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleViewImpl.java
platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
platform/lang-impl/src/com/intellij/execution/junit/RuntimeConfigurationProducer.java
platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java
platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java
platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.java
platform/lang-impl/src/com/intellij/psi/impl/DebugUtil.java
platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java
platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistry.java
platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
platform/lang-impl/src/com/intellij/util/indexing/IndexStorage.java
platform/lang-impl/src/com/intellij/util/indexing/MapIndexStorage.java
platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
platform/lang-impl/src/com/intellij/util/indexing/MemoryIndexStorage.java
platform/platform-api/src/com/intellij/ide/util/DelegatingProgressIndicator.java [moved from java/idea-ui/src/com/intellij/ide/util/importProject/DelegatingProgressIndicator.java with 98% similarity]
platform/platform-api/src/com/intellij/projectImport/ProjectOpenProcessor.java
platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java
platform/platform-impl/src/com/intellij/ide/actions/ToolWindowsGroup.java
platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/IterationState.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java
platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerAdapter.java
platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerEx.java
platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerListener.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
platform/platform-resources/src/META-INF/LangExtensions.xml
platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
platform/util/src/com/intellij/util/containers/ContainerUtil.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/merge/MultipleFileMergeDialog.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsUpdate/UpdateReceivedFileProcessor.java
plugins/devkit/src/inspections/PluginXmlDomInspection.java
plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java
plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java [new file with mode: 0644]
plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/ERelativePathUtil.java [new file with mode: 0644]
plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java
plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java
plugins/eclipse/testData/iml/workspaceOnly/test/.classpath
plugins/eclipse/testData/round/allProps/eclipse-ws-3.4.1-a/all-props/.classpath
plugins/eclipse/testData/round/sourcesAfterAll/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/round/sourcesAfterAll/test/.project [new file with mode: 0644]
plugins/eclipse/testData/round/unknownCon/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/round/unknownCon/test/.project [new file with mode: 0644]
plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java
plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseMultimoduleTest.java
plugins/groovy/hotswap/build.xml
plugins/groovy/hotswap/gragent.jar
plugins/groovy/hotswap/pluginSrc/META-INF/plugin.xml
plugins/groovy/hotswap/pluginSrc/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyReferenceAdjuster.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/params/GrParameterListImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/LightParameterList.java
plugins/java-i18n/src/com/intellij/codeInspection/i18n/folding/PropertyFoldingBuilder.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java
plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java
plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java
plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java
resources-en/src/messages/JavaErrorMessages.properties
resources/src/META-INF/IdeaPlugin.xml
xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java

index c86653a66d57900c09b37e0994479e66eb8cb46a..abca05386d75f901c38014313f3224aa99eee53d 100644 (file)
@@ -168,7 +168,7 @@ private def layoutMac(Map args, String home, Paths paths) {
     replacefilter(token: "@@jdk_req@@", value: args.jdk_req)
   }
 
-  def root = isEap() ? "${version}-${args.buildNumbder}.app" : "IntelliJ IDEA ${version} CE.app"
+  def root = isEap() ? "${version}-${args.buildNumber}.app" : "IntelliJ IDEA ${version} CE.app"
 
   ant.zip(zipfile: "$paths.artifacts/idea${args.buildNumber}.mac.zip") {
     [paths.distAll, paths.distMac].each {
index 770fc0989716d741eb9811cb78a993cfc48c75ac..1ff3398a72e922faae32553e8244b8463d6f2863 100644 (file)
@@ -432,17 +432,17 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
   }
 
   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>();
+    final THashSet<String> notDeletedJars = new THashSet<String>();
     if (LOG.isDebugEnabled()) {
       LOG.debug("Deleting outdated files...");
     }
 
+    int notDeletedFilesCount = 0;
     final Artifact[] allArtifacts = ArtifactManager.getInstance(context.getProject()).getArtifacts();
-
     List<File> filesToRefresh = new ArrayList<File>();
     for (String fullPath : paths) {
       boolean isUnderOutput = false;
@@ -460,23 +460,44 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
       if (isUnderOutput && !isInArtifactsToBuild) continue;
 
       int end = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR);
-      String filePath = end != -1 ? fullPath.substring(0, end) : fullPath;
-      if (end != -1) {
-        deletedJars.add(filePath);
+      boolean isJar = end != -1;
+      String filePath = isJar ? fullPath.substring(0, end) : fullPath;
+      boolean deleted = false;
+      if (isJar) {
+        if (notDeletedJars.contains(filePath)) {
+          continue;
+        }
+        deleted = deletedJars.contains(filePath);
       }
+
       File file = new File(FileUtil.toSystemDependentName(filePath));
-      filesToRefresh.add(file);
-      boolean deleted = FileUtil.delete(file);
-      if (!deleted && LOG.isDebugEnabled()) {
-        LOG.debug("Cannot delete file " + file);
+      if (!deleted) {
+        filesToRefresh.add(file);
+        deleted = FileUtil.delete(file);
       }
 
       if (deleted) {
+        if (isJar) {
+          deletedJars.add(filePath);
+        }
         if (testMode) {
           CompilerManagerImpl.addDeletedPath(file.getAbsolutePath());
         }
         getOutputItemsCache(context.getProject()).remove(fullPath);
       }
+      else {
+        if (isJar) {
+          notDeletedJars.add(filePath);
+        }
+        if (notDeletedFilesCount++ > 50) {
+          context.addMessage(CompilerMessageCategory.WARNING, "Deletion of outdated files stopped because too many files cannot be deleted", null, -1, -1);
+          break;
+        }
+        context.addMessage(CompilerMessageCategory.WARNING, "Cannot delete file '" + filePath + "'", null, -1, -1);
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Cannot delete file " + file);
+        }
+      }
     }
 
     CompilerUtil.refreshIOFiles(filesToRefresh);
index e1df811cee258c1a5977003e13dfdedf42dedfcb..c4e82a0cb1167fa81f9b69415413d32f2bbfed9e 100644 (file)
@@ -32,10 +32,8 @@ import com.intellij.debugger.ui.impl.MainWatchPanel;
 import com.intellij.debugger.ui.impl.VariablesPanel;
 import com.intellij.debugger.ui.impl.WatchDebuggerTree;
 import com.intellij.debugger.ui.impl.watch.*;
-import com.intellij.ide.DataManager;
 import com.intellij.idea.ActionsBundle;
 import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -47,15 +45,10 @@ import org.jetbrains.annotations.NotNull;
 public class AddToWatchActionHandler extends DebuggerActionHandler {
   @Override
   public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
-    DataContext context = DataManager.getInstance().getDataContext();
-    if (context == null) {
-      return false;
-    }
-
-    DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(context);
+    DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(event.getDataContext());
     boolean enabled = false;
     if (selectedNodes != null && selectedNodes.length > 0) {
-      if (DebuggerAction.getPanel(context) instanceof VariablesPanel) {
+      if (DebuggerAction.getPanel(event.getDataContext()) instanceof VariablesPanel) {
         enabled = true;
         for (DebuggerTreeNodeImpl node : selectedNodes) {
           NodeDescriptorImpl descriptor = node.getDescriptor();
@@ -75,10 +68,7 @@ public class AddToWatchActionHandler extends DebuggerActionHandler {
 
   @Override
   public void perform(@NotNull Project project, AnActionEvent event) {
-    DataContext context = DataManager.getInstance().getDataContext();
-    if (context == null) return;
-
-    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(context);
+    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(event.getDataContext());
 
     if(debuggerContext == null) return;
 
@@ -92,7 +82,7 @@ public class AddToWatchActionHandler extends DebuggerActionHandler {
       return;
     }
 
-    final DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(context);
+    final DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(event.getDataContext());
 
     if(selectedNodes != null && selectedNodes.length > 0) {
       addFromNodes(debuggerContext, watchPanel, selectedNodes);
index 67b0c34b469a4971c316e044c0e9a7995ec68c75..dca79b50e200eb43cbedd374c27b10912c043c9d 100644 (file)
@@ -64,6 +64,7 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
                                                          ExecutionEnvironment env) throws ExecutionException {
     if (state instanceof JavaCommandLine) {
       final JavaParameters parameters = ((JavaCommandLine)state).getJavaParameters();
+      runCustomPatchers(parameters, state.getRunnerSettings(), executor);
       RemoteConnection connection = DebuggerManagerImpl.createDebugParameters(parameters, true, DebuggerSettings.getInstance().DEBUGGER_TRANSPORT, "", false);
       return attachVirtualMachine(project, executor, state, contentToReuse, env, connection, true);
     }
@@ -107,6 +108,7 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
 
   public void patch(JavaParameters javaParameters, RunnerSettings settings, final boolean beforeExecution) throws ExecutionException {
     doPatch(javaParameters, settings);
+    runCustomPatchers(javaParameters, settings, Executor.EXECUTOR_EXTENSION_NAME.findExtension(DefaultDebugExecutor.class));
   }
 
   private static RemoteConnection doPatch(final JavaParameters javaParameters, final RunnerSettings settings) throws ExecutionException {
index 2387443ee892abc42e3935b2d174d552d4e0e607..ca73da57b4ac72e2ae065f8847ac43b163466d6a 100644 (file)
@@ -62,6 +62,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
   }
 
   public void patch(JavaParameters javaParameters, RunnerSettings settings, final boolean beforeExecution) throws ExecutionException {
+    runCustomPatchers(javaParameters, settings, Executor.EXECUTOR_EXTENSION_NAME.findExtension(DefaultRunExecutor.class));
   }
 
   public void checkConfiguration(final RunnerSettings settings, final ConfigurationPerRunnerSettings configurationPerRunnerSettings)
@@ -82,7 +83,8 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
     ExecutionResult executionResult;
     boolean shouldAddDefaultActions = true;
     if (state instanceof JavaCommandLine) {
-      patch(((JavaCommandLine)state).getJavaParameters(), state.getRunnerSettings(), true);
+      final JavaParameters parameters = ((JavaCommandLine)state).getJavaParameters();
+      patch(parameters, state.getRunnerSettings(), true);
       final ProcessProxy proxy = ProcessProxyFactory.getInstance().createCommandLineProxy((JavaCommandLine)state);
       executionResult = state.execute(executor, this);
       if (proxy != null && executionResult != null) {
index 4dd7aac1a2427c9821262775100708479a43362d..15994339c7f155097edeedcbf1ee76e790c80947 100644 (file)
@@ -16,7 +16,9 @@
 package com.intellij.execution.runners;
 
 import com.intellij.execution.ExecutionException;
+import com.intellij.execution.Executor;
 import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.RunProfile;
 import com.intellij.execution.configurations.RunnerSettings;
 import com.intellij.openapi.util.JDOMExternalizable;
 
@@ -27,5 +29,11 @@ public abstract class JavaPatchableProgramRunner<Settings extends JDOMExternaliz
 
   public abstract void patch(JavaParameters javaParameters, RunnerSettings settings, final boolean beforeExecution) throws ExecutionException;
 
-                                      
+
+  protected static void runCustomPatchers(JavaParameters javaParameters, RunnerSettings settings, Executor executor) {
+    final RunProfile profile = settings.getRunProfile();
+    for (JavaProgramPatcher patcher : JavaProgramPatcher.EP_NAME.getExtensions()) {
+      patcher.patchJavaParameters(executor, profile, javaParameters);
+    }
+  }
 }
diff --git a/java/execution/openapi/src/com/intellij/execution/runners/JavaProgramPatcher.java b/java/execution/openapi/src/com/intellij/execution/runners/JavaProgramPatcher.java
new file mode 100644 (file)
index 0000000..f12af7e
--- /dev/null
@@ -0,0 +1,17 @@
+package com.intellij.execution.runners;
+
+import com.intellij.execution.Executor;
+import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.openapi.extensions.ExtensionPointName;
+
+/**
+ * Patch Java command line before running/debugging
+ *
+ * @author peter
+ */
+public abstract class JavaProgramPatcher {
+  public static final ExtensionPointName<JavaProgramPatcher> EP_NAME = ExtensionPointName.create("com.intellij.java.programPatcher");
+
+  public abstract void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters);
+}
index 68b05c3cc4996265008f7ba621d133e1bb838ef1..1f46d71a13ed11ff6661130c9fbf4f44c3cc4ab1 100644 (file)
@@ -20,6 +20,7 @@
  */
 package com.intellij.ide.util.newProjectWizard.modes;
 
+import com.intellij.ide.util.DelegatingProgressIndicator;
 import com.intellij.ide.util.importProject.*;
 import com.intellij.ide.util.newProjectWizard.ProjectFromSourcesBuilder;
 import com.intellij.ide.util.newProjectWizard.ProjectNameStep;
index 255e8c0388d67f4e2566642e382ecaaa2a907b97..51324effc5600d1b62412c869a6e4b6319fc9806 100644 (file)
@@ -674,6 +674,11 @@ public class LibraryTableEditor implements Disposable, LibraryEditorListener {
     protected OrderRootType getRootType() {
       return AnnotationOrderRootType.getInstance();
     }
+
+    @Override
+    protected FileChooserDescriptor createDescriptor() {
+      return new FileChooserDescriptor(false, true, false, false, false, false);
+    }
   }
 
   private class AttachJavadocAction extends AttachItemAction {
index 1cbbbf85cba42ecd6cd54efdb6701bde9d4e5862..baec1e02f339e0b59f9b3b5d61921913173fc855 100644 (file)
@@ -51,7 +51,7 @@ import java.util.List;
 
 public class HighlightClassUtil {
   public static final String INTERFACE_EXPECTED = JavaErrorMessages.message("interface.expected");
-  public static final String CLASS_EXPECTED = JavaErrorMessages.message("class.expected");
+  public static final String NO_INTERFACE_EXPECTED = JavaErrorMessages.message("no.interface.expected");
   private static final String STATIC_DECLARATION_IN_INNER_CLASS = JavaErrorMessages.message("static.declaration.in.inner.class");
   private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
 
@@ -397,7 +397,7 @@ public class HighlightClassUtil {
     if (extendFrom.isInterface() != mustBeInterface) {
       errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
                                                       context,
-                                                      mustBeInterface ? INTERFACE_EXPECTED : CLASS_EXPECTED);
+                                                      mustBeInterface ? INTERFACE_EXPECTED : NO_INTERFACE_EXPECTED);
       PsiClassType type =
         JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(extendFrom, resolveResult.getSubstitutor());
       QuickFixAction.registerQuickFixAction(errorResult, new ChangeExtendsToImplementsFix(aClass, type));
index b4e0cfd4ae1fa8f368f0a8d9be13ab54287f1a0c..fbf5c50a80b7aa22d9eaf5e2c87fa73014b92baf 100644 (file)
@@ -61,8 +61,8 @@ public class HighlightMethodUtil {
                                      HighlightUtil.formatClass(method2.getContainingClass()));
   }
 
-  public static HighlightInfo checkMethodWeakerPrivileges(MethodSignatureBackedByPsiMethod methodSignature,
-                                                          List<HierarchicalMethodSignature> superMethodSignatures,
+  public static HighlightInfo checkMethodWeakerPrivileges(@NotNull MethodSignatureBackedByPsiMethod methodSignature,
+                                                          @NotNull List<HierarchicalMethodSignature> superMethodSignatures,
                                                           boolean includeRealPositionInfo) {
     PsiMethod method = methodSignature.getMethod();
     PsiModifierList modifierList = method.getModifierList();
index 9aaed86e9c53b3e850483aafd55b4b25eab1b001..483b627ae1280856066ae5370839f49c915235ef 100644 (file)
@@ -37,7 +37,6 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
@@ -935,10 +934,14 @@ public class HighlightUtil {
                                                expr.getTextRange().getEndOffset() + 1,
                                                JavaErrorMessages.message("dot.expected.after.super.or.this"));
     }
-    PsiClass aClass = qualifier == null ? PsiTreeUtil.getParentOfType(expr, PsiClass.class) : (PsiClass)qualifier.resolve();
+    PsiElement resolved = null;
+    PsiClass aClass = qualifier == null ? PsiTreeUtil.getParentOfType(expr, PsiClass.class) : (resolved = qualifier.resolve()) instanceof PsiClass ? (PsiClass)resolved : null;
+    if (resolved != null && !(resolved instanceof PsiClass)) {
+      return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, JavaErrorMessages.message("class.expected"));
+    }
     if (aClass == null) return null;
     if (qualifier != null && aClass.isInterface()) {
-      return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, HighlightClassUtil.CLASS_EXPECTED);
+      return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, HighlightClassUtil.NO_INTERFACE_EXPECTED);
     }
     if (!HighlightClassUtil.hasEnclosingInstanceInScope(aClass, expr, false)) {
       return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
index 03890d57873d85e278edcb18c935f13d501f0d8b..9a8fe6f60cbe1279c8e9e0ec5f1e56fbc6d92cf2 100644 (file)
 package com.intellij.codeInsight.intention.impl;
 
 import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.PsiEquivalenceUtil;
+import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.editor.colors.EditorColors;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
@@ -96,6 +99,7 @@ public class MoveFieldAssignmentToInitializerAction extends BaseIntentionAction
     final Ref<Boolean> result = new Ref<Boolean>(Boolean.TRUE);
     final List<PsiAssignmentExpression> totalUsages = new ArrayList<PsiAssignmentExpression>();
     PsiClass containingClass = field.getContainingClass();
+    assert containingClass != null;
     containingClass.accept(new JavaRecursiveElementVisitor(){
       private PsiCodeBlock currentInitializingBlock; //ctr or class initializer
 
@@ -178,7 +182,9 @@ public class MoveFieldAssignmentToInitializerAction extends BaseIntentionAction
         statement.delete();
       }
     }
-    editor.getCaretModel().moveToOffset(field.getTextOffset());
-    editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
+
+    EditorColorsManager manager = EditorColorsManager.getInstance();
+    TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
+    HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[] {field.getInitializer()}, attributes, false,null);
   }
 }
index e71d52aa19e13f834aadc2a8212e56efa30fdf03..454a77dc13ba69db2a6f663ff04e812e6076b3f4 100644 (file)
@@ -20,11 +20,14 @@ import com.intellij.codeInsight.CodeInsightUtilBase;
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils;
+import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
 import com.intellij.codeInsight.intention.QuickFixFactory;
 import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.editor.colors.EditorColors;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
@@ -77,6 +80,7 @@ public class MoveInitializerToConstructorAction extends PsiElementBaseIntentionA
     if (constructors.length == 0) {
       IntentionAction addDefaultConstructorFix = QuickFixFactory.getInstance().createAddDefaultConstructorFix(aClass);
       addDefaultConstructorFix.invoke(project, editor, file);
+      editor.getCaretModel().moveToOffset(offset); //restore caret
       constructorsToAddInitialization = Arrays.asList(aClass.getConstructors());
     }
     else {
@@ -90,24 +94,27 @@ public class MoveInitializerToConstructorAction extends PsiElementBaseIntentionA
       }
     }
 
-    PsiElement toMove = null;
+    PsiExpressionStatement toMove = null;
     for (PsiMethod constructor : constructorsToAddInitialization) {
       PsiCodeBlock codeBlock = constructor.getBody();
       if (codeBlock == null) {
         CreateFromUsageUtils.setupMethodBody(constructor);
         codeBlock = constructor.getBody();
       }
-      PsiElement added = addAssignment(codeBlock, field);
+      PsiExpressionStatement added = addAssignment(codeBlock, field);
       if (toMove == null) toMove = added;
     }
     field.getInitializer().delete();
     if (toMove != null) {
-      editor.getCaretModel().moveToOffset(toMove.getTextOffset());
-      editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
+      PsiAssignmentExpression assignment = (PsiAssignmentExpression)toMove.getExpression();
+      PsiExpression expression = assignment.getRExpression();
+      EditorColorsManager manager = EditorColorsManager.getInstance();
+      TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
+      HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[] {expression}, attributes, false,null);
     }
   }
 
-  private static PsiElement addAssignment(@NotNull PsiCodeBlock codeBlock, @NotNull PsiField field) throws IncorrectOperationException {
+  private static PsiExpressionStatement addAssignment(@NotNull PsiCodeBlock codeBlock, @NotNull PsiField field) throws IncorrectOperationException {
     PsiElementFactory factory = JavaPsiFacade.getInstance(codeBlock.getProject()).getElementFactory();
     PsiExpressionStatement statement = (PsiExpressionStatement)factory.createStatementFromText(field.getName()+" = y;", codeBlock);
     PsiAssignmentExpression expression = (PsiAssignmentExpression)statement.getExpression();
@@ -133,7 +140,7 @@ public class MoveInitializerToConstructorAction extends PsiElementBaseIntentionA
     }
     PsiElement newStatement = codeBlock.addBefore(statement,anchor);
     replaceWithQualifiedReferences(newStatement, newStatement);
-    return newStatement;
+    return (PsiExpressionStatement)newStatement;
   }
 
   private static boolean containsReference(final PsiElement element, final PsiField field) {
index 755e568d170dea6e26a2d8489981f39ef1dca163..8b04b2608c54afdd548f270dd823a89419ded244 100644 (file)
@@ -133,7 +133,7 @@ public class JCiPUtil {
     }
   }
 
-  private static class ImmutableTagVisitor extends JavaRecursiveElementVisitor {
+  private static class ImmutableTagVisitor extends JavaRecursiveElementWalkingVisitor {
     private boolean found = false;
 
     public void visitDocTag(PsiDocTag tag) {
index d466d532ad7a4fa1bb01f10d60b829a31f53e5bd..403654b77975e3e9aa2ac256823884d8e15d9dec 100644 (file)
@@ -130,7 +130,8 @@ public class PsiImplUtil {
       if (parameter.equals(parameters[i])) return i;
     }
     LOG.error("Parameter " + parameter + " not found among parameters: " + Arrays.asList(parameters)+
-              ". parameterList' parent: "+parameterList.getParent()+"; parameter.getParent()==paramList: "+(parameter.getParent()==parameterList));
+              ". parameterList' parent: "+parameterList.getParent()+"; parameter.getParent()==paramList: "+(parameter.getParent()==parameterList)
+              +"; "+parameterList.getClass());
     return -1;
   }
 
index 93f7c2fa3b29a719f27b5962035368c052fb0d3b..ec3460bd7d70a3ebac6e0ec3bc7498caa506a1a6 100644 (file)
@@ -134,7 +134,7 @@ public class PsiJavaParserFacadeImpl extends PsiParserFacadeImpl implements PsiJ
     TreeElement decl = getJavaParsingContext(holderElement, level).getDeclarationParsing().parseDeclarationText(myManager, level, text,
                                                                                                                 DeclarationParsing.Context.CLASS_CONTEXT);
     if (decl == null || decl.getElementType() != JavaElementType.METHOD) {
-      throw new IncorrectOperationException("Incorrect method \"" + text + "\".");
+      throw new IncorrectOperationException("Incorrect method '" + text + "'. Context:"+context+"; Level:"+level+"; parsed: "+(decl == null ? null : DebugUtil.treeToString(decl, false)));
     }
     holderElement.rawAddChildren(decl);
     return (PsiMethod)SourceTreeToPsiMap.treeElementToPsi(decl);
@@ -273,7 +273,7 @@ public class PsiJavaParserFacadeImpl extends PsiParserFacadeImpl implements PsiJ
     String catchSectionText = buffer.toString();
     final FileElement holderElement = DummyHolderFactory.createHolder(myManager, context).getTreeElement();
     TreeElement catchSection = getJavaParsingContext(holderElement).getStatementParsing().parseCatchSectionText(catchSectionText);
-    LOG.assertTrue(catchSection != null && catchSection.getElementType() == JavaElementType.CATCH_SECTION);
+    LOG.assertTrue(catchSection != null && catchSection.getElementType() == JavaElementType.CATCH_SECTION, catchSectionText);
     holderElement.rawAddChildren(catchSection);
     PsiCatchSection psiCatchSection = (PsiCatchSection)SourceTreeToPsiMap.treeElementToPsi(catchSection);
 
index b06079cefae020f2a2aa9e67e13aa7d7cdcaf1db..cc0b68f257e60c094168caad422aba48e898b759 100644 (file)
@@ -34,7 +34,7 @@ public abstract class LightVariableBase extends LightElement implements PsiVaria
   protected PsiElement myScope;
   protected PsiIdentifier myNameIdentifier;
   protected final PsiType myType;
-  protected PsiModifierList myModifierList;
+  protected final PsiModifierList myModifierList;
   protected boolean myWritable;
 
   public LightVariableBase(PsiManager manager, PsiIdentifier nameIdentifier, @NotNull PsiType type, boolean writable, PsiElement scope) {
index b75e794651fcaf8285f96d23f0a4722e7f712b03..cb280f2e422a67dfdefc067b292f0fcea4d00806 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.psi.filters.*;
 import com.intellij.psi.filters.classes.AnnotationTypeFilter;
 import com.intellij.psi.filters.element.ModifierFilter;
 import com.intellij.psi.impl.CheckUtil;
+import com.intellij.psi.impl.DebugUtil;
 import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.PsiManagerEx;
 import com.intellij.psi.impl.source.parsing.Parsing;
@@ -61,7 +62,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
   private final int myHC = ourHC++;
 
   @Override
-  public int hashCode() {
+  public final int hashCode() {
     return myHC;
   }
 
@@ -100,7 +101,6 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
       if (isQualified()) {
         return CLASS_OR_PACKAGE_NAME_KIND;
       }
-
       return CLASS_NAME_KIND;
     }
     if (i == JavaElementType.NEW_EXPRESSION) {
@@ -175,7 +175,10 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
 
     while (parent != null && parent.getPsi() instanceof PsiExpression) {
       parent = parent.getTreeParent();
-      message += " Parent: '" + parent+"'; ";
+      message += " Parent: '" + parent+"'; \n";
+    }
+    if (parent != null) {
+      message += DebugUtil.treeToString(parent, false);
     }
     LOG.error(message);
     return CLASS_NAME_KIND;
@@ -570,6 +573,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
     switch (getKind()) {
       case CLASS_OR_PACKAGE_NAME_KIND:
         if (resolve() instanceof PsiPackage) return true;
+        //noinspection fallthrough
       case CLASS_NAME_KIND:
         break;
 
index b3ed3b29b897c0416a3ccd5c4a8549334473b96d..f6df63bb1adaef11b96c9ddd78857d3a299e5010 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.codeInsight.daemon.impl.analysis.AnnotationsHighlightUtil;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.util.Condition;
 import com.intellij.psi.*;
-import com.intellij.psi.augment.PsiAugmentProvider;
 import com.intellij.psi.impl.CheckUtil;
 import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.cache.ModifierFlags;
@@ -30,7 +29,6 @@ import com.intellij.psi.impl.source.tree.Factory;
 import com.intellij.psi.impl.source.tree.JavaElementType;
 import com.intellij.psi.impl.source.tree.TreeElement;
 import com.intellij.psi.tree.IElementType;
-import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.ContainerUtil;
 import gnu.trove.THashMap;
@@ -261,9 +259,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement<PsiModifierListStub>
 
   @NotNull
   public PsiAnnotation[] getAnnotations() {
-    final PsiAnnotation[] owns = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
-    final List<PsiAnnotation> augments = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
-    return ArrayUtil.mergeArrayAndCollection(owns, augments, PsiAnnotation.ARRAY_FACTORY);
+    return getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
   }
 
   @NotNull
index e4bebf7d64b218cb97d54a4759c488c2e2efb537..4fd9911286517cdd931ee094cf704c926501cb9e 100644 (file)
@@ -18,17 +18,13 @@ package com.intellij.psi.impl.source;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
-import com.intellij.psi.augment.PsiAugmentProvider;
 import com.intellij.psi.impl.java.stubs.PsiClassReferenceListStub;
 import com.intellij.psi.impl.source.tree.JavaElementType;
 import com.intellij.psi.stubs.IStubElementType;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.tree.TokenSet;
-import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.List;
-
 public final class PsiReferenceListImpl extends JavaStubPsiElement<PsiClassReferenceListStub> implements PsiReferenceList {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiReferenceListImpl");
   private static final TokenSet REFERENCE_BIT_SET = TokenSet.create(Constants.JAVA_CODE_REFERENCE);
@@ -43,10 +39,7 @@ public final class PsiReferenceListImpl extends JavaStubPsiElement<PsiClassRefer
 
   @NotNull
   public PsiJavaCodeReferenceElement[] getReferenceElements() {
-    final PsiJavaCodeReferenceElement[] owns =
-      calcTreeElement().getChildrenAsPsiElements(REFERENCE_BIT_SET, Constants.PSI_REFERENCE_ELEMENT_ARRAY_CONSTRUCTOR);
-    final List<PsiJavaCodeReferenceElement> augments = PsiAugmentProvider.collectAugments(this, PsiJavaCodeReferenceElement.class);
-    return ArrayUtil.mergeArrayAndCollection(owns, augments, PsiJavaCodeReferenceElement.ARRAY_FACTORY);
+    return calcTreeElement().getChildrenAsPsiElements(REFERENCE_BIT_SET, Constants.PSI_REFERENCE_ELEMENT_ARRAY_CONSTRUCTOR);
   }
 
   @NotNull
index 1dc3f02b28d8210f2674c82f52ee3c89d00a930f..0bbde75e0251c94ab713a6a82da69579df70da28 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleSettings;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.impl.source.Constants;
 import com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl;
 import com.intellij.psi.impl.source.SourceJavaCodeReference;
 import com.intellij.psi.impl.source.SourceTreeToPsiMap;
@@ -33,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
 
-public class ReferenceAdjuster implements Constants {
+public class ReferenceAdjuster {
   private final boolean myUseFqClassnamesInJavadoc;
   private final boolean myUseFqClassNames;
 
@@ -52,8 +51,9 @@ public class ReferenceAdjuster implements Constants {
 
   public TreeElement process(TreeElement element, boolean addImports, boolean uncompleteCode) {
     IElementType elementType = element.getElementType();
-    if (elementType == JAVA_CODE_REFERENCE || elementType == REFERENCE_EXPRESSION) {
-      if (elementType == JAVA_CODE_REFERENCE || element.getTreeParent().getElementType() == REFERENCE_EXPRESSION || uncompleteCode) {
+    if (elementType == JavaElementType.JAVA_CODE_REFERENCE || elementType == JavaElementType.REFERENCE_EXPRESSION) {
+      if (elementType == JavaElementType.JAVA_CODE_REFERENCE || element.getTreeParent().getElementType() ==
+                                                                JavaElementType.REFERENCE_EXPRESSION || uncompleteCode) {
         final PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)SourceTreeToPsiMap.treeElementToPsi(element);
         final PsiReferenceParameterList parameterList = ref.getParameterList();
         if (parameterList != null) {
@@ -64,7 +64,7 @@ public class ReferenceAdjuster implements Constants {
         }
 
         boolean rightKind = true;
-        if (elementType == JAVA_CODE_REFERENCE) {
+        if (elementType == JavaElementType.JAVA_CODE_REFERENCE) {
           int kind = ((PsiJavaCodeReferenceElementImpl)element).getKind();
           rightKind = kind == PsiJavaCodeReferenceElementImpl.CLASS_NAME_KIND ||
             kind == PsiJavaCodeReferenceElementImpl.CLASS_OR_PACKAGE_NAME_KIND;
@@ -144,13 +144,13 @@ public class ReferenceAdjuster implements Constants {
   }
 
   private static void addReferencesInRange(ArrayList<ASTNode> array, TreeElement parent, int startOffset, int endOffset) {
-    if (parent.getElementType() == ElementType.JAVA_CODE_REFERENCE || parent.getElementType() == ElementType.REFERENCE_EXPRESSION) {
+    if (parent.getElementType() == JavaElementType.JAVA_CODE_REFERENCE || parent.getElementType() == JavaElementType.REFERENCE_EXPRESSION) {
       array.add(parent);
       return;
     }
 
     if (parent.getPsi() instanceof PsiFile && JspPsiUtil.isInJspFile(parent.getPsi())) {
-      final JspFile jspFile = (JspPsiUtil.getJspFile(parent.getPsi()));
+      final JspFile jspFile = JspPsiUtil.getJspFile(parent.getPsi());
       JspClass jspClass = (JspClass) jspFile.getJavaClass();
       addReferencesInRange(array, (TreeElement)jspClass.getNode(), startOffset, endOffset);
       return;
@@ -170,7 +170,7 @@ public class ReferenceAdjuster implements Constants {
       if (startOffset <= offset + length && offset <= endOffset) {
         final IElementType type = child.getElementType();
 
-        if (type == ElementType.JAVA_CODE_REFERENCE || type == ElementType.REFERENCE_EXPRESSION) {
+        if (type == JavaElementType.JAVA_CODE_REFERENCE || type == JavaElementType.REFERENCE_EXPRESSION) {
           array.add(child);
         } else {
           addReferencesInRangeForComposite(array, child, startOffset - offset, endOffset - offset);
index 14b44609ccc5b323e6c7358468498a6e31617509..a942342c68b7b0c84b8190186a0bca061dc6f1b9 100644 (file)
@@ -32,10 +32,12 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.impl.DebugUtil;
 import com.intellij.psi.impl.GeneratedMarkerVisitor;
 import com.intellij.psi.impl.light.LightTypeElement;
-import com.intellij.psi.impl.source.*;
+import com.intellij.psi.impl.source.DummyHolderFactory;
+import com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl;
+import com.intellij.psi.impl.source.PsiTypeElementImpl;
+import com.intellij.psi.impl.source.SourceTreeToPsiMap;
 import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
 import com.intellij.psi.impl.source.parsing.ExpressionParsing;
 import com.intellij.psi.impl.source.parsing.JavaParsingContext;
@@ -188,42 +190,19 @@ public class JavaChangeUtilSupport implements TreeGenerator, TreeCopyHandler {
       }
       PsiClassType classType = (PsiClassType)type;
 
+      final FileElement holderElement = DummyHolderFactory.createHolder(manager, original).getTreeElement();
+      String text = classType.getPresentableText();
+      CompositeElement fromT = Parsing.parseTypeText(manager, text, 0, text.length(), holderElement.getCharTable());
+      holderElement.rawAddChildren(fromT);
+      PsiTypeElementImpl result = (PsiTypeElementImpl)SourceTreeToPsiMap.treeElementToPsi(fromT);
 
-      if (true)
-      {
-        final FileElement holderElement = DummyHolderFactory.createHolder(manager, original).getTreeElement();
-        String text = classType.getPresentableText();
-        CompositeElement fromT = Parsing.parseTypeText(manager, text, 0, text.length(), holderElement.getCharTable());
-        holderElement.rawAddChildren(fromT);
-        PsiTypeElementImpl result = (PsiTypeElementImpl)SourceTreeToPsiMap.treeElementToPsi(fromT);
-
-        CodeEditUtil.setNodeGenerated(result, generated);
-        if(generated) {
-          PsiJavaCodeReferenceElement ref = result.getInnermostComponentReferenceElement();
-          if (ref != null) ((CompositeElement)ref.getNode()).acceptTree(new GeneratedMarkerVisitor());
-        }
-        encodeInfoInTypeElement(result, classType);
-        return result;
+      CodeEditUtil.setNodeGenerated(result, generated);
+      if(generated) {
+        PsiJavaCodeReferenceElement ref = result.getInnermostComponentReferenceElement();
+        if (ref != null) ((CompositeElement)ref.getNode()).acceptTree(new GeneratedMarkerVisitor());
       }
-
-      //if (true)
-      //{
-      //  TreeElement copy;
-      //  if (classType instanceof PsiClassReferenceType) {
-      //    final PsiElement ref = ((PsiClassReferenceType)type).getReference();
-      //    copy = ChangeUtil.generateTreeElement(ref, table,manager);
-      //  }
-      //  else {
-      //    copy = createReference(original.getManager(), classType.getPresentableText(), table, generated);
-      //  }
-      //
-      //  CompositeElement element = ASTFactory.composite(JavaElementType.TYPE);
-      //  CodeEditUtil.setNodeGenerated(element, generated);
-      //  element.rawAddChildren(copy);
-      //  encodeInfoInTypeElement(element, classType);
-      //
-      //  return element;
-      //}
+      encodeInfoInTypeElement(result, classType);
+      return result;
     }
     return null;
   }
@@ -476,11 +455,10 @@ public class JavaChangeUtilSupport implements TreeGenerator, TreeCopyHandler {
       }
       else {
         final ASTNode reference = typeElement.findChildByType(JavaElementType.JAVA_CODE_REFERENCE);
-        if (reference == null) {
-          LOG.error(DebugUtil.treeToString(typeElement, false));
+        // can be not the case for "? name"
+        if (reference instanceof CompositeElement) {
+          encodeClassTypeInfoInReference((CompositeElement)reference, resolveResult.getElement(), resolveResult.getSubstitutor());
         }
-
-        encodeClassTypeInfoInReference((CompositeElement)reference, resolveResult.getElement(), resolveResult.getSubstitutor());
       }
     }
   }
index a6efaba849d0e0d16ab5539624832dd30986be83..b229c9327a4e4d95a920b069864f52cf9adec362 100644 (file)
@@ -28,7 +28,7 @@ public class ExpressionPsiElement extends CompositePsiElement {
   private final int myHC = ourHC++;
 
   @Override
-  public int hashCode() {
+  public final int hashCode() {
     return myHC;
   }
 
index f016798a5f6be3dbbd1358bae874ae30d292a2b0..86bd01fc7b5409b3b1c1ab70b27ff508f7392a9f 100644 (file)
@@ -17,15 +17,16 @@ package com.intellij.psi.impl.source.tree.java;
 
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.psi.JavaTokenType;
 import com.intellij.psi.PsiBinaryExpression;
-import com.intellij.psi.impl.source.Constants;
 import com.intellij.psi.impl.source.SourceTreeToPsiMap;
 import com.intellij.psi.impl.source.tree.ChildRole;
 import com.intellij.psi.impl.source.tree.CompositeElement;
 import com.intellij.psi.impl.source.tree.ElementType;
+import com.intellij.psi.impl.source.tree.JavaElementType;
 import com.intellij.psi.tree.IElementType;
 
-public class ReplaceExpressionUtil implements Constants {
+public class ReplaceExpressionUtil {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.ReplaceExpressionUtil");
 
   public static boolean isNeedParenthesis(ASTNode oldExpr, ASTNode newExpr) {
@@ -35,51 +36,54 @@ public class ReplaceExpressionUtil implements Constants {
     int parentPriority = getExpressionPriority(oldParent);
     if (priority > parentPriority) return false;
     IElementType i = oldParent.getElementType();
-    if (i == ASSIGNMENT_EXPRESSION) {
-      if (priority < parentPriority) return true;
-      return ((CompositeElement)oldParent).getChildRole(oldExpr) == ChildRole.LOPERAND ? true : false;
+    if (i == JavaElementType.ASSIGNMENT_EXPRESSION) {
+      return priority < parentPriority || ((CompositeElement)oldParent).getChildRole(oldExpr) == ChildRole.LOPERAND;
     }
-    else if (i == CONDITIONAL_EXPRESSION) {
+    else if (i == JavaElementType.CONDITIONAL_EXPRESSION) {
       int role = ((CompositeElement)oldParent).getChildRole(oldExpr);
       if (role == ChildRole.THEN_EXPRESSION) return false;
-      if (priority < parentPriority) return true;
-      return role == ChildRole.ELSE_EXPRESSION ? false : true;
+      return priority < parentPriority || role != ChildRole.ELSE_EXPRESSION;
     }
-    else if (i == BINARY_EXPRESSION) {
+    else if (i == JavaElementType.BINARY_EXPRESSION) {
       if (priority < parentPriority) return true;
       final IElementType opType = ((PsiBinaryExpression)SourceTreeToPsiMap.treeElementToPsi(oldParent)).getOperationSign().getTokenType();
-      return ((CompositeElement)oldParent).getChildRole(oldExpr) == ChildRole.LOPERAND ? false : opType != PLUS && opType != ASTERISK && opType != ANDAND;
+      return ((CompositeElement)oldParent).getChildRole(oldExpr) != ChildRole.LOPERAND &&
+             opType != JavaTokenType.PLUS &&
+             opType != JavaTokenType.ASTERISK &&
+             opType != JavaTokenType.ANDAND;
     }
-    else if (i == INSTANCE_OF_EXPRESSION) {
+    else if (i == JavaElementType.INSTANCE_OF_EXPRESSION) {
       return priority < parentPriority;
     }
-    else if (i == PREFIX_EXPRESSION || i == TYPE_CAST_EXPRESSION) {
+    else if (i == JavaElementType.PREFIX_EXPRESSION || i == JavaElementType.TYPE_CAST_EXPRESSION) {
       return priority < parentPriority;
     }
-    else if (i == POSTFIX_EXPRESSION) {
+    else if (i == JavaElementType.POSTFIX_EXPRESSION) {
       return priority <= parentPriority;
     }
-    else if (i == REFERENCE_EXPRESSION) {
+    else if (i == JavaElementType.REFERENCE_EXPRESSION) {
       return priority < parentPriority;
     }
-    else if (i == METHOD_CALL_EXPRESSION) {
+    else if (i == JavaElementType.METHOD_CALL_EXPRESSION) {
       return false;
     }
-    else if (i == NEW_EXPRESSION) {
+    else if (i == JavaElementType.NEW_EXPRESSION) {
       return false;
     }
-    else if (i == ARRAY_ACCESS_EXPRESSION) {
+    else if (i == JavaElementType.ARRAY_ACCESS_EXPRESSION) {
       int role = ((CompositeElement)oldParent).getChildRole(oldExpr);
-      if (role == ChildRole.ARRAY_DIMENSION) return false;
-      return priority < parentPriority;
+      return role != ChildRole.ARRAY_DIMENSION && priority < parentPriority;
     }
-    else if (i == ARRAY_INITIALIZER_EXPRESSION) {
+    else if (i == JavaElementType.ARRAY_INITIALIZER_EXPRESSION) {
       return false;
     }
-    else if (i == PARENTH_EXPRESSION) {
+    else if (i == JavaElementType.PARENTH_EXPRESSION) {
       return false;
     }
-    else if (i == LITERAL_EXPRESSION || i == THIS_EXPRESSION || i == SUPER_EXPRESSION || i == CLASS_OBJECT_ACCESS_EXPRESSION) {
+    else if (i == JavaElementType.LITERAL_EXPRESSION ||
+             i == JavaElementType.THIS_EXPRESSION ||
+             i == JavaElementType.SUPER_EXPRESSION ||
+             i == JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION) {
       return false;
     }
 
@@ -89,68 +93,67 @@ public class ReplaceExpressionUtil implements Constants {
 
   private static int getExpressionPriority(ASTNode expr) {
     IElementType i = expr.getElementType();
-    if (i == ASSIGNMENT_EXPRESSION) {
+    if (i == JavaElementType.ASSIGNMENT_EXPRESSION) {
       return 0;
     }
-    else if (i == CONDITIONAL_EXPRESSION) {
+    else if (i == JavaElementType.CONDITIONAL_EXPRESSION) {
       return 1;
     }
-    else if (i == BINARY_EXPRESSION) {
-      {
-        IElementType opType = ((PsiBinaryExpression)SourceTreeToPsiMap.treeElementToPsi(expr)).getOperationSign().getTokenType();
-        if (opType == OROR) {
-          return 2;
-        }
-        else if (opType == ANDAND) {
-          return 3;
-        }
-        else if (opType == OR) {
-          return 4;
-        }
-        else if (opType == XOR) {
-          return 5;
-        }
-        else if (opType == AND) {
-          return 6;
-        }
-        else if (opType == EQEQ || opType == NE) {
-          return 7;
-        }
-        else if (opType == LT || opType == GT || opType == LE || opType == GE) {
-          return 8;
-        }
-        else if (opType == LTLT || opType == GTGT || opType == GTGTGT) {
-          return 9;
-        }
-        else if (opType == PLUS || opType == MINUS) {
-          return 10;
-        }
-        else if (opType == ASTERISK || opType == DIV || opType == PERC) {
-          return 11;
-        }
+    else if (i == JavaElementType.BINARY_EXPRESSION) {
+      IElementType opType = ((PsiBinaryExpression)SourceTreeToPsiMap.treeElementToPsi(expr)).getOperationSign().getTokenType();
+      if (opType == JavaTokenType.OROR) {
+        return 2;
+      }
+      else if (opType == JavaTokenType.ANDAND) {
+        return 3;
+      }
+      else if (opType == JavaTokenType.OR) {
+        return 4;
+      }
+      else if (opType == JavaTokenType.XOR) {
+        return 5;
+      }
+      else if (opType == JavaTokenType.AND) {
+        return 6;
+      }
+      else if (opType == JavaTokenType.EQEQ || opType == JavaTokenType.NE) {
+        return 7;
+      }
+      else if (opType == JavaTokenType.LT || opType == JavaTokenType.GT || opType == JavaTokenType.LE || opType == JavaTokenType.GE) {
+        return 8;
+      }
+      else if (opType == JavaTokenType.LTLT || opType == JavaTokenType.GTGT || opType == JavaTokenType.GTGTGT) {
+        return 9;
+      }
+      else if (opType == JavaTokenType.PLUS || opType == JavaTokenType.MINUS) {
+        return 10;
+      }
+      else if (opType == JavaTokenType.ASTERISK || opType == JavaTokenType.DIV || opType == JavaTokenType.PERC) {
+        return 11;
       }
-
-
       return 8;
     }
-    else if (i == INSTANCE_OF_EXPRESSION) {
+    else if (i == JavaElementType.INSTANCE_OF_EXPRESSION) {
       return 8;
     }
-    else if (i == PREFIX_EXPRESSION || i == TYPE_CAST_EXPRESSION) {
+    else if (i == JavaElementType.PREFIX_EXPRESSION || i == JavaElementType.TYPE_CAST_EXPRESSION) {
       return 12;
     }
-    else if (i == POSTFIX_EXPRESSION) {
+    else if (i == JavaElementType.POSTFIX_EXPRESSION) {
       return 13;
     }
-    else if (i == LITERAL_EXPRESSION || i == REFERENCE_EXPRESSION || i == THIS_EXPRESSION || i == SUPER_EXPRESSION || i ==
-                                                                                                                      PARENTH_EXPRESSION ||
-             i == METHOD_CALL_EXPRESSION ||
-             i == CLASS_OBJECT_ACCESS_EXPRESSION ||
-             i == NEW_EXPRESSION ||
-             i == ARRAY_ACCESS_EXPRESSION ||
-             i == ARRAY_INITIALIZER_EXPRESSION ||
-             i == JAVA_CODE_REFERENCE ||
-             i == EMPTY_EXPRESSION) {
+    else if (i == JavaElementType.LITERAL_EXPRESSION ||
+             i == JavaElementType.REFERENCE_EXPRESSION ||
+             i == JavaElementType.THIS_EXPRESSION ||
+             i == JavaElementType.SUPER_EXPRESSION ||
+             i == JavaElementType.PARENTH_EXPRESSION ||
+             i == JavaElementType.METHOD_CALL_EXPRESSION ||
+             i == JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION ||
+             i == JavaElementType.NEW_EXPRESSION ||
+             i == JavaElementType.ARRAY_ACCESS_EXPRESSION ||
+             i == JavaElementType.ARRAY_INITIALIZER_EXPRESSION ||
+             i == JavaElementType.JAVA_CODE_REFERENCE ||
+             i == JavaElementType.EMPTY_EXPRESSION) {
       return 14;
     }
     else {
index 9b1f92c478d52b694cafbf19816850ebb9dcec80..a7bd1a866b912d9d080de53cbda68cdc1d4d159d 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi.scope.conflictResolvers;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.psi.infos.CandidateInfo;
@@ -37,6 +38,8 @@ import java.util.Map;
  * To change this template use Options | File Templates.
  */
 public class JavaMethodsConflictResolver implements PsiConflictResolver{
+  private static final Logger LOG = Logger.getInstance("#com.intellij.psi.scope.conflictResolvers.JavaMethodsConflictResolver");
+
   private final PsiElement myArgumentsList;
   private final PsiType[] myActualParameterTypes;
 
@@ -419,6 +422,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
                                                     final PsiResolveHelper resolveHelper) {
     PsiSubstitutor substitutor = resolveHelper.inferTypeArguments(typeParameters, types1, types2, PsiUtil.getLanguageLevel(myArgumentsList));
     for (PsiTypeParameter typeParameter : typeParameters) {
+      LOG.assertTrue(typeParameter != null);
       if (!substitutor.getSubstitutionMap().containsKey(typeParameter)) {
         substitutor = substitutor.put(typeParameter, TypeConversionUtil.typeParameterErasure(typeParameter));
       }
index 07b674caefaa0b8e934ddac693faad15ae760b29..21940971ba969494f5f785f16e923c9e303e6a52 100644 (file)
@@ -290,7 +290,6 @@ public class InlineToAnonymousClassProcessor extends BaseRefactoringProcessor {
     PsiClass superClass = aClass.getSuperClass();
     PsiClassType[] interfaceTypes = aClass.getImplementsListTypes();
     if (interfaceTypes.length > 0 && !InlineToAnonymousClassHandler.isRedundantImplements(superClass, interfaceTypes [0])) {
-      assert interfaceTypes.length == 1;
       superType = interfaceTypes [0];
     }
     else {
index d2788c7d9ea60867254a4d950b396bf279067dc7..d536914a553e27579cf40eb3d1b0ae23289d8ad6 100644 (file)
@@ -72,7 +72,7 @@ import java.util.List;
 
 public abstract class IntroduceVariableBase extends IntroduceHandlerBase implements RefactoringActionHandler {
   private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.introduceVariable.IntroduceVariableBase");
-  private static final @NonNls String PREFER_STATEMENTS_OPTION = "introduce.variable.prefer.statements";
+  @NonNls private static final String PREFER_STATEMENTS_OPTION = "introduce.variable.prefer.statements";
 
   protected static String REFACTORING_NAME = RefactoringBundle.message("introduce.variable.title");
 
index 1eea7a00c8fc85183b78edbd990ead9d883e8af1..566402b9b8e3ebb0d74aaac09c72348e7730f5fd 100644 (file)
@@ -123,7 +123,8 @@ public class SliceManager implements PersistentStateComponent<SliceManager.Store
     final SliceToolwindowSettings sliceToolwindowSettings = SliceToolwindowSettings.getInstance(myProject);
     final ContentManager contentManager = dataFlowToThis ? myBackContentManager : myForthContentManager;
     final Content[] myContent = new Content[1];
-    final SlicePanel slicePanel = new SlicePanel(myProject, dataFlowToThis, rootNode, splitByLeafExpressions) {
+    ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(dataFlowToThis ? BACK_TOOLWINDOW_ID : FORTH_TOOLWINDOW_ID);
+    final SlicePanel slicePanel = new SlicePanel(myProject, dataFlowToThis, rootNode, splitByLeafExpressions, toolWindow) {
       protected void close() {
         contentManager.removeContent(myContent[0], true);
       }
@@ -149,7 +150,7 @@ public class SliceManager implements PersistentStateComponent<SliceManager.Store
     contentManager.addContent(myContent[0]);
     contentManager.setSelectedContent(myContent[0]);
 
-    ToolWindowManager.getInstance(myProject).getToolWindow(dataFlowToThis ? BACK_TOOLWINDOW_ID : FORTH_TOOLWINDOW_ID).activate(null);
+    toolWindow.activate(null);
   }
 
   public static String getElementDescription(String prefix, PsiElement element, String suffix) {
index a2277f3f36761d0d14ed4b8b4c25079041f2204a..46d086c555e630af3d9cb79ce6a3a65a1199e593 100644 (file)
@@ -26,6 +26,10 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Splitter;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.IconLoader;
+import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.openapi.wm.ToolWindowAnchor;
+import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
+import com.intellij.openapi.wm.ex.ToolWindowManagerListener;
 import com.intellij.pom.Navigatable;
 import com.intellij.ui.*;
 import com.intellij.ui.treeStructure.Tree;
@@ -75,9 +79,30 @@ public abstract class SlicePanel extends JPanel implements TypeSafeDataProvider,
   private UsagePreviewPanel myUsagePreviewPanel;
   private final Project myProject;
   private boolean isDisposed;
+  private final ToolWindow myToolWindow;
 
-  public SlicePanel(Project project, boolean dataFlowToThis, SliceNode rootNode, boolean splitByLeafExpressions) {
+  public SlicePanel(final Project project, boolean dataFlowToThis, SliceNode rootNode, boolean splitByLeafExpressions, final ToolWindow toolWindow) {
     super(new BorderLayout());
+    myToolWindow = toolWindow;
+    final ToolWindowManagerListener listener = new ToolWindowManagerListener() {
+      ToolWindowAnchor myAnchor = toolWindow.getAnchor();
+      public void toolWindowRegistered(@NotNull String id) {
+      }
+
+      public void stateChanged() {
+        if (toolWindow.getAnchor() != myAnchor) {
+          myAnchor = myToolWindow.getAnchor();
+          layoutPanel();
+        }
+      }
+    };
+    ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(listener);
+    Disposer.register(this, new Disposable() {
+      public void dispose() {
+        ToolWindowManagerEx.getInstanceEx(project).removeToolWindowManagerListener(listener);
+      }
+    });
+
     ApplicationManager.getApplication().assertIsDispatchThread();
     myProject = project;
     myTree = createTree();
@@ -110,7 +135,8 @@ public abstract class SlicePanel extends JPanel implements TypeSafeDataProvider,
     }
     removeAll();
     if (isPreview()) {
-      Splitter splitter = new Splitter(false, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
+      boolean vertical = myToolWindow.getAnchor() == ToolWindowAnchor.LEFT || myToolWindow.getAnchor() == ToolWindowAnchor.RIGHT;
+      Splitter splitter = new Splitter(vertical, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
       splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));
       myUsagePreviewPanel = new UsagePreviewPanel(myProject);
       Disposer.register(this, myUsagePreviewPanel);
index 1647efb410fe5548c8f462a7c9f1b21bf0ba1275..b77c47cd11b198f7526b50e36b7da707b45e9052 100644 (file)
@@ -1062,11 +1062,11 @@ public class TypeConversionUtil {
     return type != null && isPrimitiveWrapper(type.getCanonicalText());
   }
 
-  public static PsiType typeParameterErasure(final PsiTypeParameter typeParameter) {
+  public static PsiType typeParameterErasure(@NotNull PsiTypeParameter typeParameter) {
     return typeParameterErasure(typeParameter, PsiSubstitutor.EMPTY);
   }
 
-  private static PsiType typeParameterErasure(final PsiTypeParameter typeParameter, final PsiSubstitutor beforeSubstitutor) {
+  private static PsiType typeParameterErasure(@NotNull PsiTypeParameter typeParameter, final PsiSubstitutor beforeSubstitutor) {
     final PsiClassType[] extendsList = typeParameter.getExtendsList().getReferencedTypes();
     if (extendsList.length > 0) {
       final PsiClass psiClass = extendsList[0].resolve();
index ac0c46b3323d2ca8a2f2ecad93c3e160c7e63653..237a15828d752701ace06b08501e9fc787beb822 100644 (file)
Binary files a/lib/nanoxml-2.2.3.jar and b/lib/nanoxml-2.2.3.jar differ
index 7f120aad7f15210b0c70b0bcb704e73f92bf5298..e1d297e4ebd2027ccfe07908d4ae09f669b299ff 100644 (file)
Binary files a/lib/src/nanoxml.zip and b/lib/src/nanoxml.zip differ
index c64f169ae8b66f4772215c4151c89a1742dc7334..9a3c82c882e5e855bb94fa9530be44eacf9c508b 100644 (file)
@@ -20,6 +20,7 @@
 package com.intellij.codeInspection;
 
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiElementVisitor;
 import com.intellij.psi.PsiFile;
@@ -39,7 +40,11 @@ public abstract class LocalInspectionTool extends InspectionProfileEntry {
   @Pattern("[a-zA-Z_0-9.]+")
   @NonNls
   @NotNull public String getID() {
-    return getShortName();
+    String id = getShortName();
+    if (!StringUtil.isJavaIdentifier(id)) {
+      LOG.error("Inspection ID must satisfy [a-zA-Z_0-9.]+ pattern. Inspection: "+getClass()+"; Id: '"+id+"'");
+    }
+    return id;
   }
 
   @NonNls
@@ -101,4 +106,4 @@ public abstract class LocalInspectionTool extends InspectionProfileEntry {
   public void inspectionStarted(LocalInspectionToolSession session) {}
 
   public void inspectionFinished(LocalInspectionToolSession session) {}
-}
\ No newline at end of file
+}
index 232118cf37a4b7141e559a35766f6b518d046224..95dfbdfe9458d0ae1aa2ba66333b81f57e723ad8 100644 (file)
@@ -32,7 +32,6 @@ import java.util.List;
  */
 public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
   public static final LanguageFolding INSTANCE = new LanguageFolding();
-  private FoldingBuilder myBuilder;
 
   private LanguageFolding() {
     super("com.intellij.lang.foldingBuilder");
@@ -56,8 +55,7 @@ public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
       }
     }
     else {
-      return (extensions.size() == 1) ? extensions.get(0) : myBuilder == null
-         ? myBuilder = new CompositeFoldingBuilder(extensions) : myBuilder;
+      return (extensions.size() == 1) ? extensions.get(0) : new CompositeFoldingBuilder(extensions);
     }
 
     l.putUserData(getLanguageCache(), result);
index c331e6e9441dfd1c8fd0c777b2b3d0e2979873d5..c4b2dfa0595512924034b29268c09b0dbc2eec0c 100644 (file)
@@ -20,7 +20,6 @@
 package com.intellij.psi.stubs;
 
 import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.CachedSingletonsRegistry;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.search.GlobalSearchScope;
@@ -43,4 +42,5 @@ public abstract class StubIndex {
   );
 
   public abstract <Key> Collection<Key> getAllKeys(StubIndexKey<Key, ?> indexKey, @NotNull Project project);
+  public abstract <Key> Collection<Key> getAllKeysWithValues(StubIndexKey<Key, ?> indexKey, @NotNull Project project);
 }
index a4f1a65e099bf483daa2c88bdf236709617a6823..64b8a3e9b8d35dbcb8f9cd244192bfaf2c72f2fd 100644 (file)
@@ -336,6 +336,10 @@ public class NanoXmlUtil {
   }
 
   public static class ParserStoppedException extends RuntimeException {
+    @Override
+    public Throwable fillInStackTrace() {
+      return this;
+    }
   }
 
   private static class RootTagInfoBuilder implements IXMLBuilder {
index 6808a1c00379b998b2e9cd22107de2a3e2142dcc..1337e4a22da66b0c5ed9bafae8436bb6e1571355 100644 (file)
@@ -17,6 +17,7 @@
 package com.intellij.application.options.codeStyle;
 
 import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.ui.DetailsComponent;
 import com.intellij.psi.codeStyle.CodeStyleScheme;
 import com.intellij.util.Alarm;
@@ -103,19 +104,23 @@ public class CodeStyleMainPanel extends JPanel {
 
   public void onCurrentSchemeChanged() {
     myLayout.show(mySettingsPanel, WAIT_CARD);
-
-    myAlarm.cancelAllRequests();
-    final Runnable request = new Runnable() {
+    final Runnable replaceLayout = new Runnable() {
       public void run() {
-        SwingUtilities.invokeLater(new Runnable() {
-          public void run() {
-            ensureCurrentPanel().onSomethingChanged();
-            myLayout.show(mySettingsPanel, myModel.getSelectedScheme().getName());
-          }
-        });
+        ensureCurrentPanel().onSomethingChanged();
+        myLayout.show(mySettingsPanel, myModel.getSelectedScheme().getName());
       }
     };
-    myAlarm.addRequest(request, 200);
+    if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
+      replaceLayout.run();
+    } else {
+      myAlarm.cancelAllRequests();
+      final Runnable request = new Runnable() {
+        public void run() {
+          SwingUtilities.invokeLater(replaceLayout);
+        }
+      };
+      myAlarm.addRequest(request, 200);
+    }
   }
 
   public NewCodeStyleSettingsPanel[] getPanels() {
index cc1fb0cb56d1e34c1be51ec3be7c51960bbb0333..9eec9a0cea81575389a5849d5a0aa13414b8408d 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.lang.Language;
 import com.intellij.openapi.editor.*;
 import com.intellij.openapi.editor.ex.EditorEx;
 import com.intellij.openapi.editor.highlighter.HighlighterIterator;
+import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiDocumentManager;
@@ -50,6 +51,7 @@ public class CodeBlockUtil {
     PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
     if (file == null) return;
 
+    IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
     final IndentGuideDescriptor guide = editor.getIndentsModel().getCaretIndentGuide();
     if (guide != null) {
       editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(guide.endLine, guide.indentLevel));
@@ -73,6 +75,7 @@ public class CodeBlockUtil {
     int selectionStart = editor.getSelectionModel().getLeadSelectionOffset();
     if (file == null) return;
 
+    IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
     final IndentGuideDescriptor guide = editor.getIndentsModel().getCaretIndentGuide();
     if (guide != null) {
       editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(guide.startLine, guide.indentLevel));
index 266cf04b32fd8af2396fe82519405b44e9b3b5fe..3ed1e6921b5eee5505f1d8d52b3aee5bb6079e6e 100644 (file)
@@ -54,26 +54,24 @@ public class FoldingUpdate {
   }
 
   @Nullable
-  static Runnable updateFoldRegions(@NotNull final Editor editor, @NotNull final PsiFile file, final boolean applyDefaultState, final boolean quick) {
+  static Runnable updateFoldRegions(@NotNull final Editor editor, @NotNull PsiFile file, final boolean applyDefaultState, final boolean quick) {
     ApplicationManager.getApplication().assertReadAccessAllowed();
 
     final Project project = file.getProject();
     final Document document = editor.getDocument();
     LOG.assertTrue(!PsiDocumentManager.getInstance(project).isUncommited(document));
 
-
     CachedValue<Runnable> value = editor.getUserData(CODE_FOLDING_KEY);
     if (value != null && value.hasUpToDateValue() && !applyDefaultState) return null;
     if (quick) return getUpdateResult(file, document, quick, project, editor, applyDefaultState).getValue();
     
     return CachedValuesManager.getManager(project).getCachedValue(editor, CODE_FOLDING_KEY, new CachedValueProvider<Runnable>() {
       public Result<Runnable> compute() {
-        PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
+        Document document = editor.getDocument();
+        PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
         return getUpdateResult(file, document, quick, project, editor, applyDefaultState);
       }
     }, false);
-
-
   }
 
   private static CachedValueProvider.Result<Runnable> getUpdateResult(PsiFile file,
index eec5aee1cf99224684d20a0385f5f12277da4336..559fa1f8b1ca83261078c9c79723b7ae16f2e223 100644 (file)
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -61,9 +62,7 @@ public abstract class BaseRunConfigurationAction extends ActionGroup {
     final ConfigurationContext context = new ConfigurationContext(dataContext);
     final RunnerAndConfigurationSettingsImpl existing = context.findExisting();
     if (existing == null) {
-      final List<RuntimeConfigurationProducer> producers =
-        PreferedProducerFind.findPreferredProducers(context.getLocation(), context, true);
-      LOG.assertTrue(producers != null);
+      final List<RuntimeConfigurationProducer> producers = getEnabledProducers(context);
       if (producers.size() > 1) {
         final AnAction[] children = new AnAction[producers.size()];
         int chldIdx = 0;
@@ -86,14 +85,32 @@ public abstract class BaseRunConfigurationAction extends ActionGroup {
     return EMPTY_ARRAY;
   }
 
+  @NotNull
+  private List<RuntimeConfigurationProducer> getEnabledProducers(ConfigurationContext context) {
+    final List<RuntimeConfigurationProducer> preferred = PreferedProducerFind.findPreferredProducers(context.getLocation(), context, true);
+    if (preferred == null) {
+      return Collections.emptyList();
+    }
+
+    final List<RuntimeConfigurationProducer> producers = new ArrayList<RuntimeConfigurationProducer>();
+    for (RuntimeConfigurationProducer producer : preferred) {
+      if (isEnabledFor(producer.getConfiguration().getConfiguration())) {
+        producers.add(producer);
+      }
+    }
+    return producers;
+  }
+
+  protected boolean isEnabledFor(RunConfiguration configuration) {
+    return true;
+  }
+
   @Override
   public boolean canBePerformed(DataContext dataContext) {
     final ConfigurationContext context = new ConfigurationContext(dataContext);
     final RunnerAndConfigurationSettingsImpl existing = context.findExisting();
     if (existing == null) {
-      final List<RuntimeConfigurationProducer> producers =
-        PreferedProducerFind.findPreferredProducers(context.getLocation(), context, true);
-      LOG.assertTrue(producers != null);
+      final List<RuntimeConfigurationProducer> producers = getEnabledProducers(context);
       return producers.size() <= 1;
     }
     return true;
@@ -167,8 +184,11 @@ public abstract class BaseRunConfigurationAction extends ActionGroup {
       presentation.setEnabled(true);
       presentation.setVisible(true);
       final String name = suggestRunActionName((LocatableConfiguration)configuration.getConfiguration());
-      final List<RuntimeConfigurationProducer> producers = PreferedProducerFind.findPreferredProducers(context.getLocation(), context, true);
-      LOG.assertTrue(producers != null);
+      final List<RuntimeConfigurationProducer> producers = getEnabledProducers(context);
+      if (!producers.isEmpty()) {
+        //todo[nik,anna] it's dirty fix. Otherwise wrong configuration will be returned from context.getConfiguration()  
+        context.getConfiguration(producers.get(0));
+      }
       updatePresentation(presentation, context.findExisting() != null || producers.size() <= 1 ? " " + name : "", context);
     }
   }
index 89c18a78e4848c76f407a9bd20e82fceb1e6d674..860153ca68bdea37cbc5446762dcd259a85c4aaf 100644 (file)
@@ -17,6 +17,7 @@
 package com.intellij.execution.actions;
 
 import com.intellij.execution.*;
+import com.intellij.execution.configurations.RunConfiguration;
 import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
 import com.intellij.execution.runners.ProgramRunner;
 import com.intellij.execution.runners.ExecutionEnvironment;
@@ -44,7 +45,7 @@ public class RunContextAction extends BaseRunConfigurationAction {
     }
     runManager.setActiveConfiguration(configuration);
 
-    final ProgramRunner runner = getRunner(myExecutor.getId(), configuration);
+    final ProgramRunner runner = getRunner(configuration.getConfiguration());
     if (runner != null) {
       try {
         runner.execute(myExecutor, new ExecutionEnvironment(runner, configuration, context.getDataContext()));
@@ -55,9 +56,14 @@ public class RunContextAction extends BaseRunConfigurationAction {
     }
   }
 
+  @Override
+  protected boolean isEnabledFor(RunConfiguration configuration) {
+    return getRunner(configuration) != null;
+  }
+
   @Nullable
-  private static ProgramRunner getRunner(final String executorId, final RunnerAndConfigurationSettingsImpl selectedConfiguration) {
-    return RunnerRegistry.getInstance().getRunner(executorId, selectedConfiguration.getConfiguration());
+  private ProgramRunner getRunner(final RunConfiguration configuration) {
+    return RunnerRegistry.getInstance().getRunner(myExecutor.getId(), configuration);
   }
 
   protected void updatePresentation(final Presentation presentation, final String actionText, final ConfigurationContext context) {
@@ -68,7 +74,7 @@ public class RunContextAction extends BaseRunConfigurationAction {
       configuration = context.getConfiguration();
     }
 
-    final boolean b = configuration != null && getRunner(myExecutor.getId(), configuration) != null;
+    final boolean b = configuration != null && getRunner(configuration.getConfiguration()) != null;
     presentation.setEnabled(b);
     presentation.setVisible(b);
   }
index 25c4b21b184d4fd90929b3c2a204a3c2d1419695..c97630421dd33ab834aefef69e684fbb9bc02eea 100644 (file)
@@ -82,7 +82,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
   private final EditorEx myConsoleEditor;
   private final EditorEx myHistoryViewer;
   private final Document myEditorDocument;
-  private PsiFile myFile;
+  protected PsiFile myFile;
 
   private final JPanel myPanel = new JPanel(new BorderLayout());
 
index 7ce4a9bec7cfc70342cad8065f6a6ef204332ed3..7ae6e4e046c85db6b3767349f77431a6cd37074c 100644 (file)
@@ -33,8 +33,12 @@ public class LanguageConsoleViewImpl extends ConsoleViewImpl {
   private LanguageConsoleImpl myConsole;
 
   public LanguageConsoleViewImpl(final Project project, String title, final Language language) {
+    this(project, new LanguageConsoleImpl(project, title, language));
+  }
+
+  protected LanguageConsoleViewImpl(final Project project, final LanguageConsoleImpl console) {
     super(project, true);
-    myConsole = new LanguageConsoleImpl(project, title, language);
+    myConsole = console;
     Disposer.register(this, myConsole);
     Disposer.register(project, this);
   }
index d4280015a46cf5740849ee973e1137d218b7f5cd..63827766164e7c09f0997b2093a16570791f5619 100644 (file)
@@ -582,6 +582,15 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
 
   private Editor doCreateEditor() {
     final EditorEx editor = createRealEditor();
+    editor.addEditorMouseListener(new EditorMouseAdapter() {
+      public void mouseReleased(final EditorMouseEvent e) {
+        final MouseEvent mouseEvent = e.getMouseEvent();
+        if (!mouseEvent.isPopupTrigger()) {
+          navigate(e);
+        }
+      }
+    });
+
     editor.addEditorMouseListener(new EditorPopupHandler() {
       public void invokePopup(final EditorMouseEvent event) {
         final MouseEvent mouseEvent = event.getMouseEvent();
@@ -642,15 +651,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
     scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
     scheme.setColor(EditorColors.RIGHT_MARGIN_COLOR, null);
 
-    editor.addEditorMouseListener(new EditorMouseAdapter() {
-      public void mouseReleased(final EditorMouseEvent e) {
-        final MouseEvent mouseEvent = e.getMouseEvent();
-        if (!mouseEvent.isPopupTrigger()) {
-          navigate(e);
-        }
-      }
-    });
-
     final ConsoleViewImpl consoleView = this;
     editor.getContentComponent().addKeyListener(new KeyListener() {
       private int historyPosition = myHistory.size();
index 7577ecf2ae30b8b10ac14afa3ccd265494e36435..22711037dcbba1bfe381cf44a35486c77a570129 100644 (file)
@@ -41,7 +41,11 @@ public abstract class RuntimeConfigurationProducer implements Comparable {
   private RunnerAndConfigurationSettingsImpl myConfiguration;
 
   public RuntimeConfigurationProducer(final ConfigurationType configurationType) {
-    myConfigurationFactory = configurationType.getConfigurationFactories()[0];
+    this(configurationType.getConfigurationFactories()[0]);
+  }
+
+  protected RuntimeConfigurationProducer(ConfigurationFactory configurationFactory) {
+    myConfigurationFactory = configurationFactory;
   }
 
   public RuntimeConfigurationProducer createProducer(final Location location, final ConfigurationContext context) {
index f04b16e4f04df638107c9eb62f48743e447fe519..3e16395081b5eff36bbfe874112f750e9eb7bf4b 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Factory;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.ui.content.Content;
 import com.intellij.usageView.UsageInfo;
@@ -72,7 +73,7 @@ public class FindInProjectManager {
     Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
     if (editor != null){
       String s = editor.getSelectionModel().getSelectedText();
-      if (s != null && !s.contains("\r") && !s.contains("\n")){
+      if (!StringUtil.isEmpty(s) && !s.contains("\r") && !s.contains("\n")){
         findModel.setStringToFind(s);
       }
     }
index fc6dc528a4d014c47f77649a6fbd2334c8ab9d56..5c83d5216b3a69b5c6fb74bc30c52854389fe1b0 100644 (file)
@@ -46,6 +46,7 @@ import com.intellij.openapi.ui.MessageType;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Factory;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.util.text.TrigramBuilder;
 import com.intellij.openapi.vcs.FileStatus;
@@ -411,17 +412,19 @@ public class FindInProjectUtil {
     if (psiDirectory == null || findModel.isWithSubdirectories() && fileIndex.isInContent(psiDirectory.getVirtualFile())) {
       final Pattern fileMaskRegExp = createFileMaskRegExp(findModel);
       // optimization
-      final Collection<PsiFile> filesForFastWordSearch = getFilesForFastWordSearch(findModel, project, psiDirectory, fileMaskRegExp, module);
-      if (filesForFastWordSearch != null && canOptimizeForFastWordSearch(findModel)) return filesForFastWordSearch;
+      Pair<Boolean, Collection<PsiFile>> fastWords = getFilesForFastWordSearch(findModel, project, psiDirectory, fileMaskRegExp, module);
+      final Collection<PsiFile> filesForFastWordSearch = fastWords.getSecond();
+
+      if (fastWords.getFirst() && canOptimizeForFastWordSearch(findModel)) return filesForFastWordSearch;
 
       class EnumContentIterator implements ContentIterator {
-        final List<PsiFile> myFiles = new ArrayList<PsiFile>(filesForFastWordSearch == null ? Collections.<PsiFile>emptyList() : filesForFastWordSearch);
+        final List<PsiFile> myFiles = new ArrayList<PsiFile>(filesForFastWordSearch);
         final PsiManager psiManager = PsiManager.getInstance(project);
 
         public boolean processFile(VirtualFile virtualFile) {
           if (!virtualFile.isDirectory() && (fileMaskRegExp == null || fileMaskRegExp.matcher(virtualFile.getName()).matches()) ) {
             final PsiFile psiFile = psiManager.findFile(virtualFile);
-            if (psiFile != null && (filesForFastWordSearch == null || !filesForFastWordSearch.contains(psiFile))) {
+            if (psiFile != null && !filesForFastWordSearch.contains(psiFile)) {
               myFiles.add(psiFile);
             }
           }
@@ -489,12 +492,12 @@ public class FindInProjectUtil {
     return true;
   }
 
-  @Nullable
-  private static Collection<PsiFile> getFilesForFastWordSearch(final FindModel findModel, final Project project,
+  @NotNull
+  private static Pair<Boolean, Collection<PsiFile>> getFilesForFastWordSearch(final FindModel findModel, final Project project,
                                                                final PsiDirectory psiDirectory, final Pattern fileMaskRegExp,
                                                                final Module module) {
     if (DumbService.getInstance(project).isDumb()) {
-      return null;
+      return new Pair<Boolean, Collection<PsiFile>>(false, Collections.<PsiFile>emptyList());
     }
 
     PsiManager pm = PsiManager.getInstance(project);
@@ -510,6 +513,7 @@ public class FindInProjectUtil {
 
     Set<Integer> keys = new THashSet<Integer>(30);
     Set<PsiFile> resultFiles = new THashSet<PsiFile>();
+    boolean fast = false;
 
     if (TrigramIndex.ENABLED) {
       TIntHashSet trigrams = TrigramBuilder.buildTrigram(findModel.getStringToFind());
@@ -519,6 +523,7 @@ public class FindInProjectUtil {
       }
 
       if (!keys.isEmpty()) {
+        fast = true;
         List<VirtualFile> hits = new ArrayList<VirtualFile>();
         FileBasedIndex.getInstance()
           .getFilesWithKey(TrigramIndex.INDEX_ID, keys, new CommonProcessors.CollectProcessor<VirtualFile>(hits), scope);
@@ -528,7 +533,7 @@ public class FindInProjectUtil {
         }
 
         filterMaskedFiles(resultFiles, fileMaskRegExp);
-        if (resultFiles.isEmpty()) return resultFiles;
+        if (resultFiles.isEmpty()) return new Pair<Boolean, Collection<PsiFile>>(true, resultFiles);
       }
     }
 
@@ -536,50 +541,47 @@ public class FindInProjectUtil {
     // $ is used to separate words when indexing plain-text files but not when indexing
     // Java identifiers, so we can't consistently break a string containing $ characters into words
 
-    if (findModel.isWholeWordsOnly() && findModel.getStringToFind().indexOf('$') < 0) {
-      List<String> words = StringUtil.getWordsIn(findModel.getStringToFind());
+    fast |= findModel.isWholeWordsOnly() && findModel.getStringToFind().indexOf('$') < 0;
 
-      // hope long words are rare
-      Collections.sort(words, new Comparator<String>() {
-        public int compare(final String o1, final String o2) {
-          return o2.length() - o1.length();
-        }
-      });
+    List<String> words = StringUtil.getWordsIn(findModel.getStringToFind());
 
-      for (int i = 0; i < words.size(); i++) {
-        String word = words.get(i);
+    // hope long words are rare
+    Collections.sort(words, new Comparator<String>() {
+      public int compare(final String o1, final String o2) {
+        return o2.length() - o1.length();
+      }
+    });
 
-        PsiFile[] files = cacheManager.getFilesWithWord(word, UsageSearchContext.ANY, scope, findModel.isCaseSensitive());
-        if (files.length == 0) {
-          resultFiles.clear();
-          break;
-        }
-  
-        final List<PsiFile> psiFiles = Arrays.asList(files);
+    for (int i = 0; i < words.size(); i++) {
+      String word = words.get(i);
 
-        if (i == 0 && keys.isEmpty()) {
-          resultFiles.addAll(psiFiles);
-        }
-        else {
-          resultFiles.retainAll(psiFiles);
-        }
+      PsiFile[] files = cacheManager.getFilesWithWord(word, UsageSearchContext.ANY, scope, findModel.isCaseSensitive());
+      if (files.length == 0) {
+        resultFiles.clear();
+        break;
+      }
 
-        filterMaskedFiles(resultFiles, fileMaskRegExp);
-        if (resultFiles.isEmpty()) break;
+      final List<PsiFile> psiFiles = Arrays.asList(files);
+
+      if (i == 0 && keys.isEmpty()) {
+        resultFiles.addAll(psiFiles);
+      }
+      else {
+        resultFiles.retainAll(psiFiles);
       }
 
-      // in case our word splitting is incorrect
-      PsiFile[] allWordsFiles =
-        cacheManager.getFilesWithWord(findModel.getStringToFind(), UsageSearchContext.ANY, scope, findModel.isCaseSensitive());
-      resultFiles.addAll(Arrays.asList(allWordsFiles));
-    }
-    else if (!TrigramIndex.ENABLED) {
-      return null;
+      filterMaskedFiles(resultFiles, fileMaskRegExp);
+      if (resultFiles.isEmpty()) break;
     }
 
+    // in case our word splitting is incorrect
+    PsiFile[] allWordsFiles =
+      cacheManager.getFilesWithWord(findModel.getStringToFind(), UsageSearchContext.ANY, scope, findModel.isCaseSensitive());
+    resultFiles.addAll(Arrays.asList(allWordsFiles));
+
     filterMaskedFiles(resultFiles, fileMaskRegExp);
 
-    return resultFiles;
+    return new Pair<Boolean, Collection<PsiFile>>(fast, resultFiles);
   }
 
   private static GlobalSearchScope moduleContentScope(final Module module) {
index 083e0f0110f6f6a4d14400309584b979b4879af7..f13f6ff99698b07cb36cdffef108e6d2ebcf6e69 100644 (file)
@@ -216,7 +216,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
       }
     }
 
-    if (file != null) {
+    if (file != null && file.isValid()) {
       if (file.isDirectory()) {
         if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) {
           Module module = ModuleUtil.findModuleForFile(file, myProject);
index 508188c9b9c8c77d9be44755edd34a02fedb86b4..8b12ca1326bcefe00ffb7db05519f77fd7dd78bf 100644 (file)
@@ -48,17 +48,17 @@ public class DebugUtil {
     return false;
   }
 
-  public static String psiTreeToString(PsiElement element, boolean skipWhitespaces) {
+  public static String psiTreeToString(@NotNull PsiElement element, boolean skipWhitespaces) {
     return treeToString(SourceTreeToPsiMap.psiElementToTree(element), skipWhitespaces);
   }
 
-  public static String treeToString(ASTNode root, boolean skipWhitespaces) {
+  public static String treeToString(@NotNull ASTNode root, boolean skipWhitespaces) {
     StringBuilder buffer = new StringBuilder();
     treeToBuffer(buffer, root, 0, skipWhitespaces, false, false);
     return buffer.toString();
   }
 
-  public static String treeToString(ASTNode root, boolean skipWhitespaces, boolean showRanges) {
+  public static String treeToString(@NotNull ASTNode root, boolean skipWhitespaces, boolean showRanges) {
     StringBuilder buffer = new StringBuilder();
     treeToBuffer(buffer, root, 0, skipWhitespaces, showRanges, false);
     return buffer.toString();
@@ -77,8 +77,8 @@ public class DebugUtil {
     return buffer.toString();
   }
 
-  public static void treeToBuffer(StringBuilder buffer,
-                                  ASTNode root,
+  public static void treeToBuffer(@NotNull StringBuilder buffer,
+                                  @NotNull ASTNode root,
                                   int indent,
                                   boolean skipWhiteSpaces,
                                   boolean showRanges,
@@ -192,31 +192,28 @@ public class DebugUtil {
 
   }
 
-  public static void checkTreeStructure(ASTNode anyElement) {
+  public static void checkTreeStructure(@NotNull ASTNode anyElement) {
     ASTNode root = anyElement;
     while (root.getTreeParent() != null) {
       root = root.getTreeParent();
     }
     if (root instanceof CompositeElement) {
       synchronized (PsiLock.LOCK) {
-        checkSubtree(root);
+        checkSubtree((CompositeElement)root);
       }
     }
   }
 
-  private static void checkSubtree(ASTNode root) {
-    if (!(root instanceof CompositeElement)) return;
-    CompositeElement node = (CompositeElement)root;
-
-    if (node.rawFirstChild() == null) {
-      if (node.rawLastChild() != null) {
-        throw new IncorrectTreeStructureException(node, "firstChild == null, but lastChild != null");
+  private static void checkSubtree(CompositeElement root) {
+    if (root.rawFirstChild() == null) {
+      if (root.rawLastChild() != null) {
+        throw new IncorrectTreeStructureException(root, "firstChild == null, but lastChild != null");
       }
     }
     else {
       for (ASTNode child = root.getFirstChildNode(); child != null; child = child.getTreeNext()) {
         if (child instanceof CompositeElement) {
-          checkSubtree(child);
+          checkSubtree((CompositeElement)child);
         }
         if (child.getTreeParent() != root) {
           throw new IncorrectTreeStructureException(child, "child has wrong parent value");
@@ -243,7 +240,7 @@ public class DebugUtil {
     }
   }
 
-  public static void checkParentChildConsistent(ASTNode element) {
+  public static void checkParentChildConsistent(@NotNull ASTNode element) {
     ASTNode treeParent = element.getTreeParent();
     if (treeParent == null) return;
     ASTNode[] elements = treeParent.getChildren(null);
@@ -253,13 +250,13 @@ public class DebugUtil {
     //LOG.debug("checked consistence: "+System.identityHashCode(element));
   }
 
-  public static void checkSameCharTabs(ASTNode element1, ASTNode element2) {
+  public static void checkSameCharTabs(@NotNull ASTNode element1, @NotNull ASTNode element2) {
     final CharTable fromCharTab = SharedImplUtil.findCharTableByTree(element1);
     final CharTable toCharTab = SharedImplUtil.findCharTableByTree(element2);
     LOG.assertTrue(fromCharTab == toCharTab);
   }
 
-  public static String psiToString(final PsiElement element, final boolean skipWhitespaces) {
+  public static String psiToString(@NotNull PsiElement element, final boolean skipWhitespaces) {
     return psiToString(element, skipWhitespaces, false);
   }
 
@@ -276,8 +273,8 @@ public class DebugUtil {
     return result.toString();
   }
   
-  public static void psiToBuffer(StringBuilder buffer,
-                                 PsiElement root,
+  public static void psiToBuffer(@NotNull StringBuilder buffer,
+                                 @NotNull PsiElement root,
                                  int indent,
                                  boolean skipWhiteSpaces,
                                  boolean showRanges,
index cecbef3dcdaaf4b1d5da1d68ee6461488c56a07d..17c8b6dafdba4cd2e32d60d21926ff287217b8f3 100644 (file)
@@ -181,7 +181,7 @@ public class IndexCacheManagerImpl implements CacheManager{
           count[0] += value.intValue();
           return true;
         }
-      }, GlobalSearchScope.allScope(myProject));
+      }, GlobalSearchScope.fileScope(myProject, file));
     return count[0];
   }
 
index 00da810a2a4d68a58f35fb95a92faac65f1695f5..c0b6324ef8309d6d14fffc588313c0678069da2f 100644 (file)
@@ -45,14 +45,13 @@ class SelfElementInfo implements SmartPointerElementInfo {
     LOG.assertTrue(anchor.isPhysical());
     myFile = anchor.getContainingFile();
     TextRange range = anchor.getTextRange();
+    LOG.assertTrue(range != null, anchor);
 
     myProject = myFile.getProject();
     final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
     Document document = documentManager.getDocument(myFile);
 
-    // LOG.assertTrue(!documentManager.isUncommited(document));
-
-    assert document != null : myFile.getName();
+    LOG.assertTrue(document != null, myFile.getName());
     if (documentManager.isUncommited(document)) {
       mySyncMarkerIsValid = false;
       myMarker = document.createRangeMarker(0, 0, false);
index b65d1f79b725cdeae9ac205bf40211bf0ccf65a6..e11f3fa44d3cb0cd8681db82c40bc980fc9b59f3 100644 (file)
@@ -240,10 +240,10 @@ public class ReferenceProvidersRegistry extends PsiReferenceRegistrar {
     }
 
     List<PsiReference> result = new ArrayList<PsiReference>();
-    final Double maxPriority = firstProvider.getThird();
+    final double maxPriority = firstProvider.getThird();
     next: for (Trinity<PsiReferenceProvider, ProcessingContext, Double> trinity : providers) {
       final PsiReference[] refs = trinity.getFirst().getReferencesByElement(context, trinity.getSecond());
-      if (!trinity.getThird().equals(maxPriority)) {
+      if (trinity.getThird().doubleValue() != maxPriority) {
         for (PsiReference ref : refs) {
           for (PsiReference reference : result) {
             if (ref != null && reference.getRangeInElement().contains(ref.getRangeInElement())) {
index 8261e7ecd88c200845091f8f5d2fcd69fa99a78b..d477b52f28ecd0b38d4ceca1fde6a0cc5eb61db2 100644 (file)
@@ -305,6 +305,27 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
     return Collections.emptyList();
   }
 
+  @Override
+  public <K> Collection<K> getAllKeysWithValues(StubIndexKey<K, ?> indexKey, @NotNull Project project) {
+    FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, GlobalSearchScope.allScope(project));
+
+    final MyIndex<K> index = (MyIndex<K>)myIndices.get(indexKey);
+    try {
+      return index.getAllKeysMapped();
+    }
+    catch (StorageException e) {
+      forceRebuild(e);
+    }
+    catch (RuntimeException e) {
+      final Throwable cause = e.getCause();
+      if (cause instanceof IOException || cause instanceof StorageException) {
+        forceRebuild(e);
+      }
+      throw e;
+    }
+    return Collections.emptyList();
+  }
+
   @NotNull
   public String getComponentName() {
     return "Stub.IndexManager";
index 1536a39d25d3c74df9962f9163922abba531469f..49673c807237cf88ccd444c2e84a50604fd02f27 100644 (file)
@@ -42,8 +42,10 @@ public interface IndexStorage<Key, Value> extends Flushable {
 
   boolean processKeys(Processor<Key> processor) throws StorageException;
 
+  Collection<Key> getKeysWithValues() throws StorageException;
+
   Collection<Key> getKeys() throws StorageException;
-  
+
   void close() throws StorageException;
 
   void flush() throws IOException;
index 763ce45e4ecd233543b70d010f33e74b4c181872..7f2cf7a4f26aa8cf87a5ab23b741139f43d14546 100644 (file)
@@ -147,6 +147,30 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
     }
   }
 
+  public Collection<Key> getKeysWithValues() throws StorageException {
+    l.lock();
+    try {
+      myCache.clear(); // this will ensure that all new keys are made into the map
+      return myMap.getAllKeysWithExistingMapping();
+    }
+    catch (IOException e) {
+      throw new StorageException(e);
+    }
+    catch (RuntimeException e) {
+      final Throwable cause = e.getCause();
+      if (cause instanceof IOException) {
+        throw new StorageException(cause);
+      }
+      if (cause instanceof StorageException) {
+        throw (StorageException)cause;
+      }
+      throw e;
+    }
+    finally {
+      l.unlock();
+    }
+  }
+
   public void close() throws StorageException {
     try {
       flush();
index 64dc66fbfa8855d475227e0c352587920fce4744..2da93dc8fb661e1cf2bb96de76cc82caee2214c2 100644 (file)
@@ -150,6 +150,17 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
     return allKeys;
   }
 
+  public Collection<Key> getAllKeysMapped() throws StorageException {
+    final Lock lock = getReadLock();
+    try {
+      lock.lock();
+      return myStorage.getKeysWithValues();
+    }
+    finally {
+      lock.unlock();
+    }
+  }
+
   public boolean processAllKeys(Processor<Key> processor) throws StorageException {
     final Lock lock = getReadLock();
     try {
index 6f6fb0ba1f4b751bad7976495060aff3e390b5c7..6d58f9e1d75e85c1a7fad7b9892b8fbe5fac233a 100644 (file)
@@ -101,8 +101,11 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
   }
 
   public boolean processKeys(final Processor<Key> processor) throws StorageException {
-    final Set<Key> stopList = new HashSet<Key>();
+    return doProcessKeys(processor, myBackendStorage.getKeys());
+  }
 
+  private boolean doProcessKeys(final Processor<Key> processor, Collection<Key> backendKeys) {
+    final Set<Key> stopList = new HashSet<Key>();
     Processor<Key> decoratingProcessor = new Processor<Key>() {
       public boolean process(final Key key) {
         if (stopList.contains(key)) return true;
@@ -117,7 +120,18 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
       if (!decoratingProcessor.process(key)) return false;
       stopList.add(key);
     }
-    return myBackendStorage.processKeys(decoratingProcessor);
+    for (Key backendKey : backendKeys) {
+      if (!decoratingProcessor.process(backendKey))
+        return false;
+    }
+    return true;
+  }
+
+  public Collection<Key> getKeysWithValues() throws StorageException {
+    final Collection<Key> backendKeys = myBackendStorage.getKeysWithValues();
+    final Set<Key> keys = new HashSet<Key>();
+    doProcessKeys(new CommonProcessors.CollectProcessor<Key>(keys), backendKeys);
+    return keys;
   }
 
   public void addValue(final Key key, final int inputId, final Value value) throws StorageException {
similarity index 98%
rename from java/idea-ui/src/com/intellij/ide/util/importProject/DelegatingProgressIndicator.java
rename to platform/platform-api/src/com/intellij/ide/util/DelegatingProgressIndicator.java
index c626b47124c1c2258a55deea2c5f1f9dbc83c282..ee32f516aa266f103fc085eb105042a48277fcba 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.ide.util.importProject;
+package com.intellij.ide.util;
 
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.progress.EmptyProgressIndicator;
index 7a90cbd39fc437902f3ff63fc426c1b2ce9afa09..909f49481ced04523acd43cd263b2f2fb7efa06a 100644 (file)
@@ -20,6 +20,7 @@
 package com.intellij.projectImport;
 
 import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
@@ -39,4 +40,14 @@ public abstract class ProjectOpenProcessor {
 
   @Nullable
   public abstract Project doOpenProject(@NotNull VirtualFile virtualFile, Project projectToClose, boolean forceOpenInNewFrame);
+
+  @Nullable
+  public static ProjectOpenProcessor getImportProvider(VirtualFile file) {
+    for (ProjectOpenProcessor provider : Extensions.getExtensions(EXTENSION_POINT_NAME)) {
+      if (provider.canOpenProject(file)) {
+        return provider;
+      }
+    }
+    return null;
+  }
 }
\ No newline at end of file
index 8248da96c861f9b258f2767ddbef59c4111b7d0d..70d445aa6998844b3cd0b18caac0f0f90a1f0cec 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.ide.actions;
 
 import com.intellij.ide.highlighter.ProjectFileType;
-import com.intellij.ide.impl.ProjectUtil;
 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.fileChooser.FileElement;
@@ -59,7 +58,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
 
   @Nullable
   public static Icon getImporterIcon(final VirtualFile virtualFile, final boolean open) {
-    final ProjectOpenProcessor provider = ProjectUtil.getImportProvider(virtualFile);
+    final ProjectOpenProcessor provider = ProjectOpenProcessor.getImportProvider(virtualFile);
     if(provider!=null) {
       return provider.getIcon();
     }
@@ -73,7 +72,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor {
 
   private static boolean isProjectFile(final VirtualFile file) {
     return (!file.isDirectory() && file.getName().toLowerCase().endsWith(ProjectFileType.DOT_DEFAULT_EXTENSION)) ||
-           (ProjectUtil.getImportProvider(file) != null);
+           (ProjectOpenProcessor.getImportProvider(file) != null);
   }
 
   private static boolean isProjectDirectory(final VirtualFile virtualFile) {
index 01aee3f80f9628a2f9972cb3966b6d6ca4943a65..7be9a633c3ea426aea8a4a813085b30d8a396bb6 100644 (file)
@@ -28,6 +28,7 @@ import com.intellij.openapi.wm.ToolWindowId;
 import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
 import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
 import com.intellij.util.containers.HashMap;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
@@ -132,7 +133,7 @@ public final class ToolWindowsGroup extends ActionGroup {
   }
 
   private final class MyToolWindowManagerListener extends ToolWindowManagerAdapter{
-    public void toolWindowRegistered(String id){
+    public void toolWindowRegistered(@NotNull String id){
       addActionForToolWindow(id);
     }
   }
index d1dcd4b60608d972292a8e48de197ebc071f6c72..bbae5258b73a7d10518ad7215765361d95ccb2f2 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.ide.highlighter.WorkspaceFileType;
 import com.intellij.openapi.components.StorageScheme;
 import com.intellij.openapi.components.impl.stores.IProjectStore;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
@@ -110,23 +109,13 @@ public class ProjectUtil {
         virtualFile.isDirectory() && virtualFile.findChild(DIRECTORY_BASED_PROJECT_DIR) != null) {
       return openProject(path, projectToClose, forceOpenInNewFrame);
     }
-    ProjectOpenProcessor provider = getImportProvider(virtualFile);
+    ProjectOpenProcessor provider = ProjectOpenProcessor.getImportProvider(virtualFile);
     if (provider != null) {
       return provider.doOpenProject(virtualFile, projectToClose, forceOpenInNewFrame);
     }
     return null;
   }
 
-  @Nullable
-  public static ProjectOpenProcessor getImportProvider(VirtualFile file) {
-    for (ProjectOpenProcessor provider : Extensions.getExtensions(ProjectOpenProcessor.EXTENSION_POINT_NAME)) {
-      if (provider.canOpenProject(file)) {
-        return provider;
-      }
-    }
-    return null;
-  }
-
   @Nullable
   public static Project openProject(final String path, Project projectToClose, boolean forceOpenInNewFrame) {
     File file = new File(path);
index 8526d8f6fdda1d54f24d33dca4a16a2ee388d1df..751c55b52c2e6e68c29d861ee6f066aa6ca15428 100644 (file)
@@ -88,12 +88,16 @@ public final class ActionMenu extends JMenu {
   }
 
   public void removeNotify() {
+    uninstallSynchronizer();
+    super.removeNotify();
+  }
+
+  private void uninstallSynchronizer() {
     if (myMenuItemSynchronizer != null) {
       myGroup.removePropertyChangeListener(myMenuItemSynchronizer);
       myPresentation.removePropertyChangeListener(myMenuItemSynchronizer);
       myMenuItemSynchronizer = null;
     }
-    super.removeNotify();
   }
 
   public void updateUI() {
@@ -201,6 +205,11 @@ public final class ActionMenu extends JMenu {
       for (Component menuComponent : getMenuComponents()) {
         if (menuComponent instanceof ActionMenu) {
           ((ActionMenu)menuComponent).clearItems();
+          if (SystemInfo.isMacSystemMenu) {
+            // hideNotify is not called on Macs
+            ((ActionMenu)menuComponent).uninstallSynchronizer();
+          }
+
         }
         else if (menuComponent instanceof ActionMenuItem) {
           ((ActionMenuItem)menuComponent).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F24, 0));
index 7c94e5034f760fabb5b995b3efea632f4c733e09..a1b8c3dc79aa6369e370e536a38f6e62ad725759 100644 (file)
@@ -75,6 +75,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
   private static int originalVersion = -1;
 
   private StorageScheme myScheme = StorageScheme.DEFAULT;
+  private String myCachedLocation;
 
   ProjectStoreImpl(final ProjectEx project) {
     super(project);
@@ -198,6 +199,8 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
       LocalFileSystem.getInstance().refreshAndFindFileByPath(workspacePath);
       stateStorageManager.addMacro(WS_FILE_MACRO, workspacePath);
     }
+
+    myCachedLocation = null;
   }
 
   private static void useOldWsContent(final String filePath, final IFile ws) {
@@ -251,13 +254,17 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
 
   @Nullable
   public String getLocation() {
-    if (myScheme == StorageScheme.DEFAULT) {
-      return getProjectFilePath();
-    }
-    else {
-      final VirtualFile baseDir = getProjectBaseDir();
-      return baseDir == null ? null : baseDir.getPath();
+    if (myCachedLocation == null) {
+      if (myScheme == StorageScheme.DEFAULT) {
+        myCachedLocation = getProjectFilePath();
+      }
+      else {
+        final VirtualFile baseDir = getProjectBaseDir();
+        myCachedLocation = baseDir == null ? null : baseDir.getPath();
+      }
     }
+
+    return myCachedLocation;
   }
 
   @NotNull
index aae9bffc60939774ccd0a2ae1882e771254c2cfe..2bf806f037014d44b9301d4a5da0ba1f2559bb0e 100644 (file)
@@ -2158,6 +2158,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
 
   public int logicalPositionToOffset(@NotNull LogicalPosition pos) {
     assertReadAccess();
+    assertIsDispatchThread();
     if (myDocument.getLineCount() == 0) return 0;
 
     if (pos.line < 0) throw new IndexOutOfBoundsException("Wrong line: " + pos.line);
index 548f983e306ed54079ad6048bd8a15d54017e7f1..1865603f46ebcd057b3163ee10bf5f241e9225c0 100644 (file)
@@ -30,6 +30,7 @@ public abstract class HighlighterList {
   private final SortedList<RangeHighlighterImpl> mySegmentHighlighters = new SortedList<RangeHighlighterImpl>(MY_RANGE_COMPARATOR) {
     @Override
     protected void sort(List<RangeHighlighterImpl> delegate) {
+      assertDispatchThread();
       Iterator<RangeHighlighterImpl> it = delegate.iterator();
       boolean needSort = false;
       RangeHighlighterImpl lastHighlighter = null;
@@ -69,8 +70,9 @@ public abstract class HighlighterList {
 
   private static final Comparator<RangeHighlighterImpl> MY_RANGE_COMPARATOR = new Comparator<RangeHighlighterImpl>() {
     public int compare(RangeHighlighterImpl r1, RangeHighlighterImpl r2) {
-      if (r1.getAffectedAreaStartOffset() != r2.getAffectedAreaStartOffset()) {
-        return r1.getAffectedAreaStartOffset() - r2.getAffectedAreaStartOffset();
+      int o = r1.getAffectedAreaStartOffset() - r2.getAffectedAreaStartOffset();
+      if (o != 0) {
+        return o;
       }
 
       if (r1.getLayer() != r2.getLayer()) {
index f5e8a8c8cef80a513d0bc24aef3d1a3e896ed0b7..f1338b78b5b10112dc1fadbe0a7ee293a8df69cc 100644 (file)
@@ -15,7 +15,7 @@
  */
 package com.intellij.openapi.editor.impl;
 
-import com.intellij.openapi.application.ex.ApplicationManagerEx;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.CaretModel;
 import com.intellij.openapi.editor.FoldRegion;
@@ -79,7 +79,7 @@ public final class IterationState {
   private final Color myReadOnlyColor;
 
   public IterationState(EditorEx editor, int start, boolean useCaretAndSelection) {
-    ApplicationManagerEx.getApplicationEx().assertIsDispatchThread(editor.getComponent());
+    ApplicationManager.getApplication().assertReadAccessAllowed();
     myDocument = (DocumentEx)editor.getDocument();
     myStartOffset = start;
     myEnd = editor.getDocument().getTextLength();
@@ -553,4 +553,4 @@ public final class IterationState {
       return o1Length - o2Length;
     }
   }
-}
\ No newline at end of file
+}
index b801faaf87a399dd8561ec8916ca2fdbb173379d..407962dda71e9123bc441275bd3ae97610e10f73 100644 (file)
@@ -106,7 +106,7 @@ final class EditorTabbedContainer implements Disposable {
         updateTabBorder();
       }
 
-      public void toolWindowRegistered(final String id) {
+      public void toolWindowRegistered(@NotNull final String id) {
         updateTabBorder();
       }
     });
index cbe101e04e85abf3a11a8c5466fa651d17f901bf..ce95fa2763bf0d46d75898f834ff019bd3a4ddb1 100644 (file)
  */
 package com.intellij.openapi.wm.ex;
 
+import org.jetbrains.annotations.NotNull;
 
 
 public class ToolWindowManagerAdapter implements ToolWindowManagerListener{
-  public void toolWindowRegistered(final String id){}
+  public void toolWindowRegistered(@NotNull final String id){}
 
   public void stateChanged(){}
 }
index 27ef6b896319b1cc330bb8e6e92f4efafe9fb144..981ced945fd2b72a13e5a507134d23751564521a 100644 (file)
@@ -17,21 +17,21 @@ package com.intellij.openapi.wm.ex;
 
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.openapi.wm.ToolWindowAnchor;
+import com.intellij.openapi.wm.ToolWindowManager;
 import com.intellij.openapi.wm.impl.DesktopLayout;
+import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import java.util.List;
 
-public abstract class ToolWindowManagerEx extends ToolWindowManager{
+public abstract class ToolWindowManagerEx extends ToolWindowManager {
   public static ToolWindowManagerEx getInstanceEx(final Project project){
     return (ToolWindowManagerEx)getInstance(project);
   }
 
-  public abstract void addToolWindowManagerListener(ToolWindowManagerListener l);
-
-  public abstract void removeToolWindowManagerListener(ToolWindowManagerListener l);
+  public abstract void addToolWindowManagerListener(@NotNull ToolWindowManagerListener l);
+  public abstract void removeToolWindowManagerListener(@NotNull ToolWindowManagerListener l);
 
   /**
    * @return <code>ID</code> of tool window that was activated last time.
@@ -55,11 +55,11 @@ public abstract class ToolWindowManagerEx extends ToolWindowManager{
   /**
    * Copied <code>layout</code> into internal layout and rearranges tool windows.
    */
-  public abstract void setLayout(DesktopLayout layout);
+  public abstract void setLayout(@NotNull DesktopLayout layout);
 
   public abstract void clearSideStack();
 
-  public abstract void hideToolWindow(String id, boolean hideSide);
+  public abstract void hideToolWindow(@NotNull String id, boolean hideSide);
 
-  public abstract List<String> getIdsOn(final ToolWindowAnchor anchor);
+  public abstract List<String> getIdsOn(@NotNull ToolWindowAnchor anchor);
 }
index 72f5c981129b3edc326f4a82016c5478e80abb86..79e769a4e0160406ca2287d1c661e9bc017f2545 100644 (file)
  */
 package com.intellij.openapi.wm.ex;
 
-import com.intellij.openapi.wm.ToolWindowManager;
+import org.jetbrains.annotations.NotNull;
 
 import java.util.EventListener;
 
 public interface ToolWindowManagerListener extends EventListener{
   /**
-   * Invoked when tool window with specified <code>id</code> is registered in <code>ToolWindowMnagare</code>.
+   * Invoked when tool window with specified <code>id</code> is registered in {@link ToolWindowManagerEx}.
    * @param id <code>id</code> of registered tool window.
    */
-  void toolWindowRegistered(String id);
+  void toolWindowRegistered(@NotNull String id);
 
   void stateChanged();
 }
\ No newline at end of file
index 338ce18de3e83770cd2fb72285bcfbbe3e36a7ec..17200e81d3b9103f2868fb50dbb6af8594e65fec 100644 (file)
@@ -56,7 +56,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
   public void notifyByBalloon(@NotNull final String toolWindowId, @NotNull final MessageType type, @NotNull final String htmlBody) {
   }
 
-  private static final ToolWindow HEADLESS_WINDOW = new ToolWindow(){
+  public static final ToolWindow HEADLESS_WINDOW = new ToolWindow(){
     public boolean isActive() {
       return false;
     }
@@ -308,11 +308,11 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
                               @Nullable final HyperlinkListener listener) {
   }
 
-  public void addToolWindowManagerListener(ToolWindowManagerListener l) {
+  public void addToolWindowManagerListener(@NotNull ToolWindowManagerListener l) {
 
   }
 
-  public void removeToolWindowManagerListener(ToolWindowManagerListener l) {
+  public void removeToolWindowManagerListener(@NotNull ToolWindowManagerListener l) {
   }
 
   public String getLastActiveToolWindowId() {
@@ -334,16 +334,16 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
     return new DesktopLayout();
   }
 
-  public void setLayout(DesktopLayout layout) {
+  public void setLayout(@NotNull DesktopLayout layout) {
   }
 
   public void clearSideStack() {
   }
 
-  public void hideToolWindow(final String id, final boolean hideSide) {
+  public void hideToolWindow(@NotNull final String id, final boolean hideSide) {
   }
 
-  public List<String> getIdsOn(final ToolWindowAnchor anchor) {
+  public List<String> getIdsOn(@NotNull final ToolWindowAnchor anchor) {
     return new ArrayList<String>();
   }
 }
index eb653d04a7498bbe0e6cfdd49f401837b2f611c0..440ab961135d98694d7b1d281831a8027346e8cd 100644 (file)
@@ -293,11 +293,11 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
     execute(commandsList);
   }
 
-  public void addToolWindowManagerListener(final ToolWindowManagerListener l) {
+  public void addToolWindowManagerListener(@NotNull final ToolWindowManagerListener l) {
     myListenerList.add(ToolWindowManagerListener.class, l);
   }
 
-  public void removeToolWindowManagerListener(final ToolWindowManagerListener l) {
+  public void removeToolWindowManagerListener(@NotNull final ToolWindowManagerListener l) {
     myListenerList.remove(ToolWindowManagerListener.class, l);
   }
 
@@ -571,7 +571,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
     return myLayout.getInfo(id, true);
   }
 
-  public List<String> getIdsOn(final ToolWindowAnchor anchor) {
+  public List<String> getIdsOn(@NotNull final ToolWindowAnchor anchor) {
     return myLayout.getVisibleIdsOn(anchor, this);
   }
 
@@ -593,7 +593,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
     execute(commandList);
   }
 
-  public void hideToolWindow(final String id, final boolean hideSide) {
+  public void hideToolWindow(@NotNull final String id, final boolean hideSide) {
     hideToolWindow(id, hideSide, true);
   }
 
@@ -913,7 +913,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
     return myLayoutToRestoreLater;
   }
 
-  public void setLayout(final DesktopLayout layout) {
+  public void setLayout(@NotNull final DesktopLayout layout) {
     ApplicationManager.getApplication().assertIsDispatchThread();
     final ArrayList<FinalizableCommand> commandList = new ArrayList<FinalizableCommand>();
     // hide tool window that are invisible in new layout
index 8b4ee0f05f4349e1abbd09074c0b73529da818d4..47415b50f0b07917d1e7d8794567a8557b6a61f9 100644 (file)
   <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.CompleteSmartMacro"/>
   <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.ClassNameCompleteMacro"/>
 
+  <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.EnumMacro"/>
+  
   <fileBasedIndex implementation="com.intellij.psi.impl.cache.impl.todo.TodoIndex" />
   <fileBasedIndex implementation="com.intellij.psi.impl.cache.impl.id.IdIndex" />
   <fileBasedIndex implementation="com.intellij.psi.search.FilenameIndex"/>
index d6504bd173f090fc04fbf69754609aecbdccd510..ff7be9f4f218de0f747331738980f51915b99d2a 100644 (file)
@@ -343,18 +343,19 @@ public class PlatformTestUtil {
     // Allow 10% more in case of test machine is busy.
     // For faster machines (expectedOnMyMachine < expected) allow nonlinear performance rating:
     // just perform better than acceptable expected
+    int percentage = (int)(100.0 * (actual - expectedOnMyMachine) / expectedOnMyMachine);
+    String failMessage = message + "." +
+                         " Operation took " + percentage + "% longer than expected." +
+                         " Expected on my machine: " + expectedOnMyMachine + "." +
+                         " Actual: " + actual + "." +
+                         " Expected on Etalon machine: " + expected + ";" +
+                         " Actual on Etalon: " + actual * ETALON_TIMING / Timings.MACHINE_TIMING;
     if (actual > expectedOnMyMachine * acceptableChangeFactor &&
         (expectedOnMyMachine > expected || actual > expected * acceptableChangeFactor)) {
-      int percentage = (int)(((float)100 * (actual - expectedOnMyMachine)) / expectedOnMyMachine);
-      Assert.fail(message + ". Operation took " + percentage + "% longer than expected. Expected on my machine: " + expectedOnMyMachine +
-                  ". Actual: " + actual + ". Expected on Etalon machine: " + expected + "; Actual on Etalon: " +
-                  (actual * ETALON_TIMING / Timings.MACHINE_TIMING));
+      Assert.fail(failMessage);
     }
     else {
-      int percentage = (int)(((float)100 * (actual - expectedOnMyMachine)) / expectedOnMyMachine);
-      System.out.println(message + ". Operation took " + percentage + "% longer than expected. Expected on my machine: " +
-                         expectedOnMyMachine + ". Actual: " + actual + ". Expected on Etalon machine: " + expected +
-                         "; Actual on Etalon: " + (actual * ETALON_TIMING / Timings.MACHINE_TIMING));
+      System.out.println(failMessage);
     }
   }
 
@@ -382,6 +383,7 @@ public class PlatformTestUtil {
         System.gc();
         System.gc();
         System.gc();
+        System.out.println("Another epic fail: "+e.getMessage() +"; Attempts remained: "+attempts);
       }
     }
   }
index 84d369fa577891d4a27c16a9a4202776136b64bd..480169201388dc593afce022c2d684142e13211f 100644 (file)
@@ -29,6 +29,7 @@ import java.lang.reflect.Array;
 import java.util.*;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
 public class ContainerUtil {
   private static final int INSERTION_SORT_THRESHOLD = 10;
 
index 26bc7508ee3ce6036e596911cc8410816e0f6d2e..1c077171018d4173b7c8a81c346f19b1eb979a38 100644 (file)
@@ -142,7 +142,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
                     public void setValue(Value value) {
                       config.REMOVE_EMPTY_INACTIVE_CHANGELISTS = value;
                     }
-                  }, "<html>The empty changelist '" + StringUtil.last(oldDefaultList.getName(), 30, true) + "' is no longer active.<br>" +
+                  }, "<html>The empty changelist '" + StringUtil.first(oldDefaultList.getName(), 30, true) + "' is no longer active.<br>" +
                      "Do you want to remove it?</html>", "&Remember my choice");
                   dialog.show();
                   if (!dialog.isOK()) {
index dfd2f1438a3b8fc977b0b08c895f61ac191245f7..3a574acad0f412f4c4bfdb3575b6862c7ac34176 100644 (file)
@@ -36,6 +36,7 @@ import com.intellij.openapi.vcs.VcsBundle;
 import com.intellij.openapi.vcs.VcsException;
 import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.projectImport.ProjectOpenProcessor;
 import com.intellij.ui.ColoredTableCellRenderer;
 import com.intellij.ui.SimpleTextAttributes;
 import com.intellij.ui.table.TableView;
@@ -320,7 +321,8 @@ public class MultipleFileMergeDialog extends DialogWrapper {
   private void checkMarkModifiedProject(final VirtualFile file) {
     if (file.getFileType() == StdFileTypes.IDEA_MODULE ||
         file.getFileType() == StdFileTypes.IDEA_PROJECT ||
-        file.getFileType() == StdFileTypes.IDEA_WORKSPACE) {
+        file.getFileType() == StdFileTypes.IDEA_WORKSPACE ||
+        ProjectOpenProcessor.getImportProvider(file) != null) {
       myProjectManager.saveChangedProjectFile(file, myProject);
     }
   }
index 75d13422ddf221815b29769f29f5af7b091d3bdd..c2aaa983dc248b58d83f520f8619e217b6c55374 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.fileTypes.FileTypeManager;
 import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.projectImport.ProjectOpenProcessor;
 
 import java.io.File;
 import java.io.IOException;
@@ -64,6 +65,7 @@ public class UpdateReceivedFileProcessor implements ReceivedFileProcessor {
 
   private static boolean isProjectOrModuleFile(VirtualFile virtualFile) {
     if (virtualFile == null) return false;
+    if (ProjectOpenProcessor.getImportProvider(virtualFile) != null) return true;
     FileType fileType = FileTypeManager.getInstance().getFileTypeByFile(virtualFile);
     return
       fileType == StdFileTypes.IDEA_PROJECT
index 6efe89a615f350528ec0f5d84c2d44b03ac01b63..dcbd367df17f81d2ff12546ef5bbd42831533aa2 100644 (file)
@@ -50,7 +50,7 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
   @NonNls
   @NotNull
   public String getShortName() {
-    return "Plugin.xmlValidity";
+    return "PluginXmlValidity";
   }
 
   @Nullable
index bfa1cdc646e699057b1b971f54960b5a667b5ec3..fbce1a65a30480c651407b0dbf5cd769ad14a2c6 100644 (file)
@@ -20,11 +20,15 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleServiceManager;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 public class EclipseModuleManager {
   private CachedXmlDocumentSet myDocumentSet;
   private Map<String, String> myEclipseVariablePaths = new HashMap<String, String>();
+  private Set<String> myUnknownCons = new HashSet<String>();
+  private boolean myForceConfigureJDK = false;
   private static final String SRC_PREFIX = "src:";
 
   public EclipseModuleManager(Module module) {}
@@ -56,4 +60,20 @@ public class EclipseModuleManager {
   public String getEclipseSrcVariablePath(String path) {
     return myEclipseVariablePaths.get(SRC_PREFIX + path);
   }
+
+  public void registerUnknownCons(String con) {
+    myUnknownCons.add(con);
+  }
+
+  public Set<String> getUnknownCons() {
+    return myUnknownCons;
+  }
+
+  public boolean isForceConfigureJDK() {
+    return myForceConfigureJDK;
+  }
+
+  public void setForceConfigureJDK() {
+    myForceConfigureJDK = true;
+  }
 }
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java
new file mode 100644 (file)
index 0000000..88ba107
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * User: anna
+ * Date: 25-Mar-2010
+ */
+package org.jetbrains.idea.eclipse.conversion;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ModuleRootModel;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.JarFileSystem;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.openapi.vfs.ex.http.HttpFileSystem;
+import org.jdom.Element;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.jetbrains.idea.eclipse.EclipseXml.*;
+import static org.jetbrains.idea.eclipse.conversion.ERelativePathUtil.*;
+
+public class EJavadocUtil {
+  private EJavadocUtil() {
+  }
+
+  @Nullable
+  static List<String> getJavadocAttribute(Element element, ModuleRootModel model, final List<String> currentRoots) {
+    Element attributes = element.getChild("attributes");
+    if (attributes == null) {
+      return null;
+    }
+    List<String> result = new ArrayList<String>();
+    for (Object o : attributes.getChildren("attribute")) {
+      if (Comparing.strEqual(((Element)o).getAttributeValue("name"), "javadoc_location")) {
+        Element attribute = (Element)o;
+        String javadocPath = attribute.getAttributeValue("value");
+        if (!SystemInfo.isWindows) {
+          javadocPath = javadocPath.replaceFirst(FILE_PROTOCOL, FILE_PROTOCOL + "/");
+        }
+        result.add(toIdeaJavadocUrl(model, javadocPath, currentRoots));
+      }
+    }
+    return result;
+  }
+
+  static String toIdeaJavadocUrl(ModuleRootModel model, String javadocPath, List<String> currentRoots) {
+    if (javadocPath.startsWith(FILE_PROTOCOL)) {
+      if (new File(javadocPath.substring(FILE_PROTOCOL.length())).exists()) {
+        return VfsUtil.pathToUrl(javadocPath.substring(FILE_PROTOCOL.length()));
+      }
+    }
+    else {
+      final String protocol = VirtualFileManager.extractProtocol(javadocPath);
+      if (Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) {
+        return javadocPath;
+      }
+      else if (javadocPath.startsWith(JAR_PREFIX)) {
+        final String jarJavadocPath = javadocPath.substring(JAR_PREFIX.length());
+        if (jarJavadocPath.startsWith(PLATFORM_PROTOCOL)) {
+          String relativeToPlatform = jarJavadocPath.substring(PLATFORM_PROTOCOL.length() + "resource".length());
+          final String currentModulePath = getCurrentRoot(model).getParent().getPath() + relativeToPlatform;
+          if (isJarFileExist(currentModulePath)) {
+            return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, currentModulePath);
+          }
+          else {
+            final String moduleName = getRootPath(relativeToPlatform);
+            final String relativeToModulePathWithJarSuffix = getRelativeToRootPath(relativeToPlatform);
+            final String relativeToModulePath = stripPathInsideJar(relativeToModulePathWithJarSuffix);
+            final Module otherModule = ModuleManager.getInstance(model.getModule().getProject()).findModuleByName(moduleName);
+            String url = null;
+            if (otherModule != null && otherModule != model.getModule()) {
+              url = relativeToOtherModule(otherModule, relativeToModulePath);
+            }
+            else if (currentRoots != null) {
+              url = relativeToContentRoots(currentRoots, getCurrentRoot(model).getPath(), relativeToModulePath);
+            }
+
+            if (url != null) {
+              assert relativeToModulePathWithJarSuffix != null;
+              assert relativeToModulePath != null;
+              if (relativeToModulePath.length() < relativeToModulePathWithJarSuffix.length()) {
+                url += relativeToModulePathWithJarSuffix.substring(relativeToModulePath.length());
+              }
+              return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, VfsUtil.urlToPath(url));
+            }
+          }
+        }
+        else if (jarJavadocPath.startsWith(FILE_PROTOCOL)) {
+          final String localFile = jarJavadocPath.substring(FILE_PROTOCOL.length());
+          if (isJarFileExist(localFile)) {
+            return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, localFile);
+          }
+        }
+      }
+    }
+    return javadocPath;
+  }
+
+  @Nullable
+  private static String stripPathInsideJar(@Nullable String relativeToModulePathWithJarSuffix) {
+    String relativeToModulePath = relativeToModulePathWithJarSuffix;
+    if (relativeToModulePath != null) {
+      int jarSufIdx = relativeToModulePathWithJarSuffix.indexOf(JarFileSystem.JAR_SEPARATOR);
+      if (jarSufIdx != -1) {
+        relativeToModulePath = relativeToModulePath.substring(0, jarSufIdx);
+      }
+    }
+    return relativeToModulePath;
+  }
+
+  static boolean isJarFileExist(String path) {
+    final int jarSufIdx = path.indexOf(JarFileSystem.JAR_SEPARATOR);
+    if (jarSufIdx != -1) {
+      path = path.substring(0, jarSufIdx);
+    }
+    return new File(path).exists();
+  }
+
+  static String toEclipseJavadocPath(ModuleRootModel model, String javadocPath) {
+    final String protocol = VirtualFileManager.extractProtocol(javadocPath);
+    if (!Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) {
+      final String path = VfsUtil.urlToPath(javadocPath);
+      final VirtualFile contentRoot = getCurrentRoot(model);
+      final Project project = model.getModule().getProject();
+      final VirtualFile baseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir();
+      if (Comparing.strEqual(protocol, JarFileSystem.getInstance().getProtocol())) {
+        final VirtualFile javadocFile =
+          JarFileSystem.getInstance().getVirtualFileForJar(VirtualFileManager.getInstance().findFileByUrl(javadocPath));
+        if (javadocFile != null) {
+          String relativeUrl = relativeToOtherModule(project, javadocFile);
+          if (relativeUrl == null && VfsUtil.isAncestor(baseDir, javadocFile, false)) {
+            relativeUrl = "/" + VfsUtil.getRelativePath(javadocFile, baseDir, '/');
+          }
+          if (relativeUrl != null) {
+            if (javadocPath.indexOf(JarFileSystem.JAR_SEPARATOR) == -1) {
+              javadocPath = StringUtil.trimEnd(javadocPath, "/") + JarFileSystem.JAR_SEPARATOR;
+            }
+            javadocPath = JAR_PREFIX +
+                          PLATFORM_PROTOCOL +
+                          "resource" +
+                          relativeUrl +
+                          javadocPath.substring(javadocFile.getUrl().length() - 1);
+          }
+          else {
+            javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/");
+          }
+        }
+        else {
+          javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/");
+        }
+      }
+      else if (new File(path).exists()) {
+        javadocPath = FILE_PROTOCOL + StringUtil.trimStart(path, "/");
+      }
+    }
+    return javadocPath;
+  }
+
+  private static VirtualFile getCurrentRoot(ModuleRootModel model) {
+    final VirtualFile contentRoot = getContentRoot(model);
+    assert contentRoot != null;
+    return contentRoot;
+  }
+}
\ No newline at end of file
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/ERelativePathUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/ERelativePathUtil.java
new file mode 100644 (file)
index 0000000..d81de85
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * User: anna
+ * Date: 25-Mar-2010
+ */
+package org.jetbrains.idea.eclipse.conversion;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ContentEntry;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.ModuleRootModel;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.eclipse.importWizard.EclipseProjectFinder;
+
+import java.io.File;
+import java.util.List;
+
+public class ERelativePathUtil {
+  private ERelativePathUtil() {
+  }
+
+  /**
+   * @param path path in format /module_root/relative_path
+   * @return module_root
+   */
+  @NotNull
+  public static String getRootPath(String path) {
+    int secondSlIdx = path.indexOf('/', 1);
+    return secondSlIdx > 1 ? path.substring(1, secondSlIdx) : path.substring(1);
+  }
+
+  /**
+   * @param path path in format /module_root/relative_path
+   * @return relative_path or null if /module_root
+   */
+  @Nullable
+  public static String getRelativeToRootPath(String path) {
+    final int secondSlIdx = path.indexOf('/', 1);
+    return secondSlIdx != -1 && secondSlIdx + 1 < path.length() ? path.substring(secondSlIdx + 1) : null;
+  }
+
+  @Nullable
+  public static String relativeToContentRoots(final @NotNull List<String> currentRoots,
+                                              final @NotNull String rootPath,
+                                              final @Nullable String relativeToRootPath) {
+    for (String currentRoot : currentRoots) {
+      if (currentRoot.endsWith(rootPath)
+          || Comparing.strEqual(rootPath, EclipseProjectFinder.findProjectName(currentRoot))) { //rootPath = content_root <=> applicable root: abs_path/content_root
+        if (relativeToRootPath == null) {
+          return VfsUtil.pathToUrl(currentRoot);
+        }
+        final File relativeToOtherModuleFile = new File(currentRoot, relativeToRootPath);
+        if (relativeToOtherModuleFile.exists()) {
+          return VfsUtil.pathToUrl(relativeToOtherModuleFile.getPath());
+        }
+      }
+    }
+    return null;
+  }
+
+  /**
+   * @param otherModule check file relative to module content root
+   * @param relativeToOtherModule local path (paths inside jars are rejected)
+   * @return url
+   */
+  @Nullable
+  public static String relativeToOtherModule(final @NotNull Module otherModule, final @Nullable String relativeToOtherModule) {
+    final VirtualFile[] contentRoots = ModuleRootManager.getInstance(otherModule).getContentRoots();
+    for (VirtualFile contentRoot : contentRoots) {
+      if (relativeToOtherModule == null) {
+        return contentRoot.getUrl();
+      }
+      final VirtualFile fileUnderModuleContentRoot = contentRoot.findFileByRelativePath(relativeToOtherModule);
+      if (fileUnderModuleContentRoot != null) {
+        return fileUnderModuleContentRoot.getUrl();
+      }
+    }
+    return null;
+  }
+
+  @Nullable
+  public static String relativeToOtherModule(final @NotNull Project project, final @NotNull VirtualFile file) {
+    final Module module = ModuleUtil.findModuleForFile(file, project);
+    if (module != null) {
+      final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
+      for (VirtualFile otherRoot : contentRoots) {
+        if (VfsUtil.isAncestor(otherRoot, file, false)) {
+          return "/" + module.getName() + "/" + VfsUtil.getRelativePath(file, otherRoot, '/');
+        }
+      }
+    }
+    return null;
+  }
+
+  @Nullable
+  public static VirtualFile getContentRoot(final ModuleRootModel model) {
+    final ContentEntry[] entries = model.getContentEntries();
+    if (entries.length > 0) {
+      return entries[0].getFile();
+    }
+    return null;
+  }
+}
\ No newline at end of file
index 815624003b79b05ab59c9a8414a82366fe8406d2..beb55d7c235336b07d709966042f7346b2f4fd66 100644 (file)
@@ -32,12 +32,10 @@ import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
 import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
-import com.intellij.openapi.vfs.ex.http.HttpFileSystem;
 import com.intellij.util.ArrayUtil;
 import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
@@ -45,7 +43,6 @@ import org.jetbrains.annotations.Nullable;
 import org.jetbrains.idea.eclipse.EclipseXml;
 import org.jetbrains.idea.eclipse.IdeaXml;
 import org.jetbrains.idea.eclipse.config.EclipseModuleManager;
-import org.jetbrains.idea.eclipse.importWizard.EclipseProjectFinder;
 import org.jetbrains.idea.eclipse.util.ErrorLog;
 
 import java.io.File;
@@ -55,6 +52,8 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 
+import static org.jetbrains.idea.eclipse.conversion.ERelativePathUtil.*;
+
 public class EclipseClasspathReader {
   private final String myRootPath;
   private final Project myProject;
@@ -69,7 +68,6 @@ public class EclipseClasspathReader {
 
   public void init(ModifiableRootModel model) {
     myContentEntry = model.addContentEntry(VfsUtil.pathToUrl(myRootPath));
-    model.inheritSdk();
   }
 
   public static void collectVariables(Set<String> usedVariables, Element classpathElement) {
@@ -122,6 +120,10 @@ public class EclipseClasspathReader {
         ErrorLog.rethrow(ErrorLog.Level.Warning, null, EclipseXml.CLASSPATH_FILE, e);
       }
     }
+    if (!model.isSdkInherited() && model.getSdkName() == null) {
+      EclipseModuleManager.getInstance(model.getModule()).setForceConfigureJDK();
+      model.inheritSdk();
+    }
   }
 
   private void readClasspathEntry(ModifiableRootModel rootModel,
@@ -152,6 +154,7 @@ public class EclipseClasspathReader {
       }
       else {
         getContentEntry().addSourceFolder(VfsUtil.pathToUrl(myRootPath + "/" + path), testPattern != null && testPattern.length() > 0 && path.matches(testPattern));
+        rearrangeOrderEntryOfType(rootModel, ModuleSourceOrderEntry.class);
       }
     }
 
@@ -164,14 +167,14 @@ public class EclipseClasspathReader {
       final Library library = rootModel.getModuleLibraryTable().getModifiableModel().createLibrary(libName);
       final Library.ModifiableModel modifiableModel = library.getModifiableModel();
 
-      modifiableModel.addRoot(getUrl(path), OrderRootType.CLASSES);
+      modifiableModel.addRoot(getUrl(path, rootModel), OrderRootType.CLASSES);
 
       final String sourcePath = element.getAttributeValue(EclipseXml.SOURCEPATH_ATTR);
       if (sourcePath != null) {
-        modifiableModel.addRoot(getUrl(sourcePath), OrderRootType.SOURCES);
+        modifiableModel.addRoot(getUrl(sourcePath, rootModel), OrderRootType.SOURCES);
       }
 
-      final List<String> docPaths = getJavadocAttribute(element);
+      final List<String> docPaths = EJavadocUtil.getJavadocAttribute(element, rootModel, myCurrentRoots);
       if (docPaths != null) {
         for (String docPath : docPaths) {
           modifiableModel.addRoot(docPath, JavadocOrderRootType.getInstance());
@@ -205,7 +208,8 @@ public class EclipseClasspathReader {
       }
       usedVariables.add(clsVar);
 
-      final String url = getUrl(PathMacroManager.getInstance(rootModel.getModule()).expandPath(getVariableRelatedPath(clsVar, clsPath)));
+      final String url = getUrl(PathMacroManager.getInstance(rootModel.getModule()).expandPath(getVariableRelatedPath(clsVar, clsPath)),
+                                rootModel);
       EclipseModuleManager.getInstance(rootModel.getModule()).registerEclipseVariablePath(url, path);
       modifiableModel.addRoot(url, OrderRootType.CLASSES);
 
@@ -225,12 +229,13 @@ public class EclipseClasspathReader {
           srcPath = null;
         }
         usedVariables.add(srcVar);
-        final String srcUrl = getUrl(PathMacroManager.getInstance(rootModel.getModule()).expandPath(getVariableRelatedPath(srcVar, srcPath)));
+        final String srcUrl = getUrl(PathMacroManager.getInstance(rootModel.getModule()).expandPath(getVariableRelatedPath(srcVar, srcPath)),
+                                     rootModel);
         EclipseModuleManager.getInstance(rootModel.getModule()).registerEclipseSrcVariablePath(srcUrl, srcPathAttr);
         modifiableModel.addRoot(srcUrl, OrderRootType.SOURCES);
       }
 
-      final List<String> docPaths = getJavadocAttribute(element);
+      final List<String> docPaths = EJavadocUtil.getJavadocAttribute(element, rootModel, myCurrentRoots);
       if (docPaths != null) {
         for (String docPath : docPaths) {
           modifiableModel.addRoot(docPath, JavadocOrderRootType.getInstance());
@@ -261,9 +266,7 @@ public class EclipseClasspathReader {
             unknownJdks.add(jdkName);
           }
         }
-        OrderEntry[] orderEntries = rootModel.getOrderEntries();
-        orderEntries = ArrayUtil.append(orderEntries, orderEntries[0]);
-        rootModel.rearrangeOrderEntries(ArrayUtil.remove(orderEntries, 0));
+        rearrangeOrderEntryOfType(rootModel, JdkOrderEntry.class);
       }
       else if (path.startsWith(EclipseXml.USER_LIBRARY)) {
         addNamedLibrary(rootModel, unknownLibraries, exported, getPresentableName(path), LibraryTablesRegistrar.PROJECT_LEVEL);
@@ -274,6 +277,9 @@ public class EclipseClasspathReader {
         final Library.ModifiableModel modifiableModel = library.getModifiableModel();
         modifiableModel.addRoot(getJunitClsUrl(junitName.contains("4")), OrderRootType.CLASSES);
         modifiableModel.commit();
+      } else {
+        EclipseModuleManager.getInstance(rootModel.getModule()).registerUnknownCons(path);
+        addNamedLibrary(rootModel, new ArrayList<String>(), exported, path, LibraryTablesRegistrar.APPLICATION_LEVEL);
       }
     }
     else {
@@ -281,6 +287,19 @@ public class EclipseClasspathReader {
     }
   }
 
+  private static void rearrangeOrderEntryOfType(ModifiableRootModel rootModel, Class<? extends OrderEntry> orderEntryClass) {
+    OrderEntry[] orderEntries = rootModel.getOrderEntries();
+    int moduleSourcesIdx = 0;
+    for (OrderEntry orderEntry : orderEntries) {
+      if (orderEntryClass.isAssignableFrom(orderEntry.getClass())) {
+        break;
+      }
+      moduleSourcesIdx++;
+    }
+    orderEntries = ArrayUtil.append(orderEntries, orderEntries[moduleSourcesIdx]);
+    rootModel.rearrangeOrderEntries(ArrayUtil.remove(orderEntries, moduleSourcesIdx));
+  }
+
   public static void setupOutput(ModifiableRootModel rootModel, final String path) {
     final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class);
     compilerModuleExtension.setCompilerOutputPath(VfsUtil.pathToUrl(path));
@@ -350,7 +369,7 @@ public class EclipseClasspathReader {
     return var == null ? null : ("$" + var + "$" + (path == null ? "" : ("/" + path)));
   }
 
-  private String getUrl(final String path) {
+  private String getUrl(final String path, ModifiableRootModel model) {
     String url = null;
     if (path.startsWith("/")) {
       final String relativePath = new File(myRootPath).getParent() + "/" + path;
@@ -365,7 +384,7 @@ public class EclipseClasspathReader {
         final String relativeToRootPath = getRelativeToRootPath(path);
 
         final Module otherModule = ModuleManager.getInstance(myProject).findModuleByName(rootPath);
-        if (otherModule != null) {
+        if (otherModule != null && otherModule != model.getModule()) {
           url = relativeToOtherModule(otherModule, relativeToRootPath);
         }
         else if (myCurrentRoots != null) {
@@ -392,104 +411,6 @@ public class EclipseClasspathReader {
     return url;
   }
 
-  /**
-   * @param path path in format /module_root/relative_path
-   * @return module_root
-   */
-  @NotNull
-  private static String getRootPath(String path) {
-    int secondSlIdx = path.indexOf('/', 1);
-    return secondSlIdx > 1 ? path.substring(1, secondSlIdx) : path.substring(1);
-  }
-
-  /**
-   * @param path path in format /module_root/relative_path
-   * @return relative_path or null if /module_root
-   */
-  @Nullable
-  private static String getRelativeToRootPath(String path) {
-    final int secondSlIdx = path.indexOf('/', 1);
-    return secondSlIdx != -1 && secondSlIdx + 1 < path.length() ? path.substring(secondSlIdx + 1) : null;
-  }
-
-  @Nullable
-  private static String relativeToContentRoots(final @NotNull List<String> currentRoots,
-                                               final @NotNull String rootPath,
-                                               final @Nullable String relativeToRootPath) {
-    for (String currentRoot : currentRoots) {
-      if (currentRoot.endsWith(rootPath) || Comparing.strEqual(rootPath, EclipseProjectFinder.findProjectName(currentRoot))) { //rootPath = content_root <=> applicable root: abs_path/content_root
-        if (relativeToRootPath == null) {
-          return VfsUtil.pathToUrl(currentRoot);
-        }
-        final File relativeToOtherModuleFile = new File(currentRoot, relativeToRootPath);
-        if (relativeToOtherModuleFile.exists()) {
-          return VfsUtil.pathToUrl(relativeToOtherModuleFile.getPath());
-        }
-      }
-    }
-    return null;
-  }
-
-  @Nullable
-  private static String relativeToOtherModule(final @NotNull Module otherModule, final @Nullable String relativeToOtherModule) {
-    final VirtualFile[] contentRoots = ModuleRootManager.getInstance(otherModule).getContentRoots();
-    for (VirtualFile contentRoot : contentRoots) {
-      if (relativeToOtherModule == null) {
-        return contentRoot.getUrl();
-      }
-      final File relativeToOtherModuleFile = new File(contentRoot.getPath(), relativeToOtherModule);
-      if (relativeToOtherModuleFile.exists()) {
-        return VfsUtil.pathToUrl(relativeToOtherModuleFile.getPath());
-      }
-    }
-    return null;
-  }
-
-  @Nullable
-  private List<String> getJavadocAttribute(Element element) {
-    Element attributes = element.getChild("attributes");
-    if (attributes == null) {
-      return null;
-    }
-    List<String> result = new ArrayList<String>();
-    for (Object o : attributes.getChildren("attribute")) {
-      if (Comparing.strEqual(((Element)o).getAttributeValue("name"), "javadoc_location")) {
-        Element attribute = (Element)o;
-        String javadocPath = attribute.getAttributeValue("value");
-        if (!SystemInfo.isWindows) {
-          javadocPath = javadocPath.replaceFirst(EclipseXml.FILE_PROTOCOL, EclipseXml.FILE_PROTOCOL + "/");
-        }
-        if (javadocPath.startsWith(EclipseXml.FILE_PROTOCOL) &&
-            new File(javadocPath.substring(EclipseXml.FILE_PROTOCOL.length())).exists()) {
-          result.add(VfsUtil.pathToUrl(javadocPath.substring(EclipseXml.FILE_PROTOCOL.length())));
-        }
-        else {
-
-          final String protocol = VirtualFileManager.extractProtocol(javadocPath);
-          if (Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) {
-            result.add(javadocPath);
-          }
-          else if (javadocPath.startsWith(EclipseXml.JAR_PREFIX)) {
-            final String jarJavadocPath = javadocPath.substring(EclipseXml.JAR_PREFIX.length());
-            if (jarJavadocPath.startsWith(EclipseXml.PLATFORM_PROTOCOL)) {
-              String relativeToPlatform = jarJavadocPath.substring(EclipseXml.PLATFORM_PROTOCOL.length() + "resources".length());
-              result
-                .add(VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, new File(myRootPath).getParent() + "/" + relativeToPlatform));
-            }
-            else if (jarJavadocPath.startsWith(EclipseXml.FILE_PROTOCOL)) {
-              result
-                .add(VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, jarJavadocPath.substring(EclipseXml.FILE_PROTOCOL.length())));
-            }
-            else {
-              result.add(javadocPath);
-            }
-          }
-        }
-      }
-    }
-    return result;
-  }
-
   static String getJunitClsUrl(final boolean version4) {
     String url = version4 ? JavaSdkUtil.getJunit4JarPath() : JavaSdkUtil.getJunit3JarPath();
     final VirtualFile localFile = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(url));
index 12d951734a0fb2815a4cf5dc1c6017c34bd69277..64026b06035ea09b4742b90968793b01a51189b1 100644 (file)
  */
 package org.jetbrains.idea.eclipse.conversion;
 
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.JavaSdkType;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.roots.*;
 import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
 import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileManager;
-import com.intellij.openapi.vfs.ex.http.HttpFileSystem;
 import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
@@ -41,7 +37,6 @@ import org.jetbrains.idea.eclipse.EclipseXml;
 import org.jetbrains.idea.eclipse.IdeaXml;
 import org.jetbrains.idea.eclipse.config.EclipseModuleManager;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -148,7 +143,9 @@ public class EclipseClasspathWriter {
       }
       else {
         final Element orderEntry;
-        if (Comparing.strEqual(libraryName, IdeaXml.ECLIPSE_LIBRARY)) {
+        if (EclipseModuleManager.getInstance(libraryOrderEntry.getOwnerModule()).getUnknownCons().contains(libraryName)) {
+          orderEntry = addOrderEntry(EclipseXml.CON_KIND, libraryName, classpathRoot);
+        } else if (Comparing.strEqual(libraryName, IdeaXml.ECLIPSE_LIBRARY)) {
           orderEntry = addOrderEntry(EclipseXml.CON_KIND, EclipseXml.ECLIPSE_PLATFORM, classpathRoot);
         }
         else {
@@ -159,7 +156,9 @@ public class EclipseClasspathWriter {
     }
     else if (entry instanceof JdkOrderEntry) {
       if (entry instanceof InheritedJdkOrderEntry) {
-        addOrderEntry(EclipseXml.CON_KIND, EclipseXml.JRE_CONTAINER, classpathRoot);
+        if (!EclipseModuleManager.getInstance(entry.getOwnerModule()).isForceConfigureJDK()) {
+          addOrderEntry(EclipseXml.CON_KIND, EclipseXml.JRE_CONTAINER, classpathRoot);
+        }
       }
       else {
         final Sdk jdk = ((JdkOrderEntry)entry).getJdk();
@@ -197,7 +196,7 @@ public class EclipseClasspathWriter {
         if (VfsUtil.isAncestor(contentRoot, file, false)) {
           return VfsUtil.getRelativePath(file, contentRoot, '/');
         } else {
-          final String path = relativeToOtherModulePath(project, file);
+          final String path = ERelativePathUtil.relativeToOtherModule(project, file);
           if (path != null) {
             return path;
           }
@@ -226,40 +225,23 @@ public class EclipseClasspathWriter {
     }
   }
 
-  @Nullable
-  private static String relativeToOtherModulePath(Project project, VirtualFile file) {
-    final Module module = ModuleUtil.findModuleForFile(file, project);
-    if (module != null) {
-      final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
-      for (VirtualFile otherRoot : contentRoots) {
-        if (VfsUtil.isAncestor(otherRoot, file, false)) {
-          return "/" + module.getName() + "/" + VfsUtil.getRelativePath(file, otherRoot, '/');
-        }
-      }
-    }
-    return null;
-  }
-
   @Nullable
   private VirtualFile getContentRoot() {
-    final ContentEntry[] entries = myModel.getContentEntries();
-    if (entries.length > 0) {
-      return entries[0].getFile();
-    }
-    return null;
+    return ERelativePathUtil.getContentRoot(myModel);
   }
 
   private void setupLibraryAttributes(Element orderEntry, LibraryOrderEntry libraryOrderEntry) {
     final List<String> eclipseUrls = new ArrayList<String>();
     final String[] docUrls = libraryOrderEntry.getUrls(JavadocOrderRootType.getInstance());
     for (String docUrl : docUrls) {
-      eclipseUrls.add(getJavadocPath(docUrl));
+      eclipseUrls.add(EJavadocUtil.toEclipseJavadocPath(myModel, docUrl));
     }
 
     final List children = new ArrayList(orderEntry.getChildren(EclipseXml.ATTRIBUTES_TAG));
     for (Object o : children) {
       final Element attsElement = (Element)o;
-      for (Object a : attsElement.getChildren(EclipseXml.ATTRIBUTE_TAG)) {
+      final ArrayList attTags = new ArrayList(attsElement.getChildren(EclipseXml.ATTRIBUTE_TAG));
+      for (Object a : attTags) {
         Element attElement = (Element)a;
         if (Comparing.strEqual(attElement.getAttributeValue("name"), EclipseXml.JAVADOC_LOCATION)) {
           final String javadocPath = attElement.getAttributeValue("value");
@@ -284,45 +266,6 @@ public class EclipseClasspathWriter {
     }
   }
 
-  private String getJavadocPath(String javadocPath) {
-    final String protocol = VirtualFileManager.extractProtocol(javadocPath);
-    if (!Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) {
-      final String path = VfsUtil.urlToPath(javadocPath);
-      final VirtualFile contentRoot = getContentRoot();
-      final Project project = myModel.getModule().getProject();
-      final VirtualFile baseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir();
-      if (Comparing.strEqual(protocol, JarFileSystem.getInstance().getProtocol())) {
-        final VirtualFile javadocFile =
-          JarFileSystem.getInstance().getVirtualFileForJar(VirtualFileManager.getInstance().findFileByUrl(javadocPath));
-        if (javadocFile != null) {
-          String relativeUrl = relativeToOtherModulePath(project, javadocFile);
-          if (relativeUrl == null && VfsUtil.isAncestor(baseDir, javadocFile, false)) {
-            relativeUrl = "/" + VfsUtil.getRelativePath(javadocFile, baseDir, '/');
-          }
-          if (relativeUrl != null) {
-            if (javadocPath.indexOf(JarFileSystem.JAR_SEPARATOR) == -1) {
-              javadocPath = StringUtil.trimEnd(javadocPath, "/") + JarFileSystem.JAR_SEPARATOR;
-            }
-            javadocPath = EclipseXml.JAR_PREFIX +
-                          EclipseXml.PLATFORM_PROTOCOL +
-                          "resource" +
-                          relativeUrl +
-                          javadocPath.substring(javadocFile.getUrl().length() - 1);
-          } else {
-            javadocPath = EclipseXml.JAR_PREFIX + EclipseXml.FILE_PROTOCOL + StringUtil.trimStart(path, "/");
-          }
-        }
-        else {
-          javadocPath = EclipseXml.JAR_PREFIX + EclipseXml.FILE_PROTOCOL + StringUtil.trimStart(path, "/");
-        }
-      }
-      else if (new File(path).exists()) {
-        javadocPath = EclipseXml.FILE_PROTOCOL + StringUtil.trimStart(path, "/");
-      }
-    }
-    return javadocPath;
-  }
-
   private Element addOrderEntry(String kind, String path, Element classpathRoot) {
     final Element element = myOldEntries.get(kind + getJREKey(path));
     if (element != null){
index 62e727489dfa0ce049b82e4f6b3e96966deb69c7..6fd8960f341a360bccdc4c2c59169c9cf60432cb 100644 (file)
@@ -4,7 +4,7 @@
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="lib" path="test.jar" sourcepath="testSrc.jar">
                <attributes>
-                       <attribute name="javadoc_location" value="jar:platform:/resources/test/testJavadoc.jar!/a"/>
+                       <attribute name="javadoc_location" value="jar:platform:/resource/test/testJavadoc.jar!/a"/>
                </attributes>
        </classpathentry>
        <classpathentry kind="lib" path="/testOut.jar" sourcepath="/testOutSrc.jar"/>
index 41ed674863108f49b0584d80000eb43141ab7b25..f75da1b1fe06ce5e83b53c9beb77b564fb128c13 100644 (file)
                        <attribute name="javadoc_location" value="jar:file:/$ROOT$/eclipse-vars/lib-7/jar-all-7.zip!/"/>
                </attributes>
        </classpathentry>
+       <classpathentry exported="true" kind="var" path="ECLIPSE_VARS/lib-7/jar-every/lib-7.jar" sourcepath="/ECLIPSE_VARS/lib-7/copy-every/src">
+               <attributes>
+                       <attribute name="javadoc_location" value="jar:platform:/resource/ws-internals/lib-5/NotValidZip.zip!/doc/api"/>
+               </attributes>
+       </classpathentry>
        <classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/lib-8"/>
        <classpathentry exported="true" kind="var" path="ECLIPSE_VARS_LIB_9_CLS" sourcepath="/ECLIPSE_VARS_LIB_9_SRC"/>
        <classpathentry exported="true" kind="var" path="ECLIPSE_VARS_LIB_A_CLS" sourcepath="/ECLIPSE_VARS_LIB_A_SRC"/>
diff --git a/plugins/eclipse/testData/round/sourcesAfterAll/test/.classpath b/plugins/eclipse/testData/round/sourcesAfterAll/test/.classpath
new file mode 100644 (file)
index 0000000..3f3893a
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="src" path=""/>
+       <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/plugins/eclipse/testData/round/sourcesAfterAll/test/.project b/plugins/eclipse/testData/round/sourcesAfterAll/test/.project
new file mode 100644 (file)
index 0000000..f5a6693
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>root</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/plugins/eclipse/testData/round/unknownCon/test/.classpath b/plugins/eclipse/testData/round/unknownCon/test/.classpath
new file mode 100644 (file)
index 0000000..609aa00
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="gen"/>
+       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/eclipse/testData/round/unknownCon/test/.project b/plugins/eclipse/testData/round/unknownCon/test/.project
new file mode 100644 (file)
index 0000000..b908668
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>MarketEnabler</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
index d6929da6df672b0f9cb78399a973616b1fbb775e..2dc6c706c0c55351ce4f7aefc47897305f239d11 100644 (file)
@@ -202,4 +202,13 @@ public class EclipseClasspathTest extends IdeaTestCase {
     doTest();
   }
 
+  public void testUnknownCon() throws Exception {
+    doTest();
+  }
+
+  public void testSourcesAfterAll() throws Exception {
+    doTest();
+  }
+
+
 }
index 504dc991805718cda2e7e5a300ad02faa710e6bb..0121f2f3cd81a864cc9f9e1d6d13e8f12f95283a 100644 (file)
@@ -25,9 +25,12 @@ import com.intellij.openapi.application.PluginPathManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.testFramework.IdeaTestCase;
+import junit.framework.Assert;
 
 import java.io.File;
 import java.io.IOException;
@@ -49,7 +52,20 @@ public class EclipseMultimoduleTest extends IdeaTestCase {
       LOG.error(e);
     }
     final ModifiableRootModel model = ModuleRootManager.getInstance(getModule()).getModifiableModel();
-    model.addContentEntry(LocalFileSystem.getInstance().findFileByPath(getProject().getBaseDir().getPath() + "/eclipse-ws-3.4.1-a/ws-internals"));
+    final VirtualFile file =
+      ApplicationManager.getApplication().runWriteAction(
+          new Computable<VirtualFile>() {
+            public VirtualFile compute() {
+              return LocalFileSystem.getInstance().refreshAndFindFileByPath(getProject().getBaseDir().getPath() + "/eclipse-ws-3.4.1-a/ws-internals");
+            }
+          }
+      );
+    if (file != null) {
+      model.addContentEntry(file);
+    } else {
+      model.dispose();
+      Assert.assertTrue("File not found", false);
+    }
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
         public void run(){
             model.commit();
index cf1fd28b30e7140fb334db142b18d56645f5b5b9..67870ab492d44070b9aaeca324f2bbf2814a8226 100644 (file)
@@ -21,7 +21,7 @@
       </fileset>
     </copy>
 
-    <javac source="1.5" destdir="anttask.classes" fork="true">
+    <javac source="1.5" target="1.5" destdir="anttask.classes" fork="true">
       <src path="anttask.src"/>
       <classpath>
         <fileset dir="${build.lib.path}">
index c41823ca567750999f07bb0a18d849c0e30c1bc5..381cf407f248cc6ed959aa9c8cc7d7c4be035b94 100644 (file)
Binary files a/plugins/groovy/hotswap/gragent.jar and b/plugins/groovy/hotswap/gragent.jar differ
index 8e6056ec495bacedf9d6bf06329b20168d3c28ad..c9ae3335026f94e1a0196eca050ef4a7e8e063dd 100644 (file)
@@ -2,13 +2,13 @@
   <id>org.intellij.groovy.hotswap</id>
   <name>Groovy HotSwap</name>
   <description>Enables HotSwap functionality in Groovy classes</description>
-  <version>0.2</version>
-  <idea-version since-build="93.90" until-build="96.1"/>
+  <version>0.5</version>
+  <idea-version since-build="94.632" until-build="96.1"/>
   <vendor logo="/org/jetbrains/plugins/groovy/images/groovy_16x16.png" url="http://www.jetbrains.com">JetBrains Inc.</vendor>
   <depends>org.intellij.groovy</depends>
 
   <extensions defaultExtensionNs="com.intellij">
-    <programRunner implementation="org.jetbrains.plugins.groovy.debugger.GroovyHotSwapper"/>
+    <java.programPatcher implementation="org.jetbrains.plugins.groovy.debugger.GroovyHotSwapper"/>
   </extensions>
 
 </idea-plugin>
index 5dcf5743021a31c3a3625fbcc1589b7a9e3dd298..98d46dff20b9549fe49e9dc8d59d3683136ee585 100644 (file)
@@ -1,23 +1,16 @@
 package org.jetbrains.plugins.groovy.debugger;
 
-import com.intellij.debugger.impl.GenericDebuggerRunner;
-import com.intellij.execution.ExecutionException;
 import com.intellij.execution.Executor;
-import com.intellij.execution.application.ApplicationConfiguration;
-import com.intellij.execution.configurations.JavaCommandLine;
 import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.RunConfiguration;
 import com.intellij.execution.configurations.RunProfile;
-import com.intellij.execution.configurations.RunProfileState;
 import com.intellij.execution.executors.DefaultDebugExecutor;
-import com.intellij.execution.runners.ExecutionEnvironment;
-import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.execution.runners.JavaProgramPatcher;
 import com.intellij.openapi.application.PluginPathManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.search.FilenameIndex;
 import com.intellij.util.PathUtil;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyFileTypeLoader;
-import org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfiguration;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -27,17 +20,7 @@ import java.util.List;
 /**
  * @author peter
  */
-public class GroovyHotSwapper extends GenericDebuggerRunner {
-  public boolean canRun(@NotNull final String executorId, @NotNull final RunProfile profile) {
-    if (!executorId.equals(DefaultDebugExecutor.EXECUTOR_ID)) {
-      return false;
-    }
-    if ("false".equals(System.getProperty("enable.groovy.hotswap", "true"))) {
-      return false;
-    }
-
-    return profile instanceof GroovyScriptRunConfiguration || profile instanceof ApplicationConfiguration;
-  }
+public class GroovyHotSwapper extends JavaProgramPatcher {
 
   private static boolean endsWithAny(String s, List<String> endings) {
     for (String extension : endings) {
@@ -61,23 +44,17 @@ public class GroovyHotSwapper extends GenericDebuggerRunner {
     return false;
   }
 
-  @NotNull
-  public String getRunnerId() {
-    return "GroovyHotSwapper";
-  }
-
-  @Override
-  protected RunContentDescriptor createContentDescriptor(Project project,
-                                                         Executor executor,
-                                                         RunProfileState state,
-                                                         RunContentDescriptor contentToReuse,
-                                                         ExecutionEnvironment env) throws ExecutionException {
-    if (state instanceof JavaCommandLine && containsGroovyClasses(project)) {
-      final JavaParameters params = ((JavaCommandLine)state).getJavaParameters();
-      params.getVMParametersList().add("-javaagent:" + getAgentJarPath());
+  public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
+    if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
+      return;
+    }
+    if ("false".equals(System.getProperty("enable.groovy.hotswap", "true"))) {
+      return;
     }
 
-    return super.createContentDescriptor(project, executor, state, contentToReuse, env);
+    if (configuration instanceof RunConfiguration && containsGroovyClasses(((RunConfiguration)configuration).getProject())) {
+      javaParameters.getVMParametersList().add("-javaagent:" + getAgentJarPath());
+    }
   }
 
   private static String getAgentJarPath() {
index 1f39d35e8c32f6ed016c48d3c21c40c0533228fb..08d9c2bbb81a9fd71c788fb6fe477e86ecb7e68b 100644 (file)
@@ -41,8 +41,7 @@ public class GroovyReferenceAdjuster extends ReferenceAdjuster {
     }
   }
 
-  private int collectReferences(PsiElement element, int currOffset, int startInElement, int endInElement, List<GrCodeReferenceElement> result
-  ) {
+  private static int collectReferences(PsiElement element, int currOffset, int startInElement, int endInElement, List<GrCodeReferenceElement> result) {
     if (element instanceof GrCodeReferenceElement && startInElement <= currOffset && currOffset <= endInElement) {
       result.add((GrCodeReferenceElement) element);
     }
index 09e2d0fc6b3251290060a5b6b43c048ddd0b7e08..e2d5d72ac588aeebe4f48d1eb2669682d7939bcf 100644 (file)
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.params;
 
 import com.intellij.lang.ASTNode;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiParameter;
 import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mCOMMA;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
+import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mCOMMA;
+
 /**
  * @author: Dmitry.Krasilschikov
  * @date: 26.03.2007
  */
 public class GrParameterListImpl extends GroovyPsiElementImpl implements GrParameterList {
+  private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.lang.psi.impl.statements.params.GrParameterListImpl");
   public GrParameterListImpl(@NotNull ASTNode node) {
     super(node);
   }
@@ -53,12 +57,8 @@ public class GrParameterListImpl extends GroovyPsiElementImpl implements GrParam
   }
 
   public int getParameterIndex(PsiParameter parameter) {
-    PsiParameter[] parameters = getParameters();
-    for (int i = 0; i < parameters.length; i++) {
-      if (parameters[i].equals(parameter)) return i;
-    }
-
-    return -1;
+    LOG.assertTrue(parameter.getParent() == this);
+    return PsiImplUtil.getParameterIndex(parameter, this);
   }
 
   public int getParametersCount() {
index 6b351646a281e05c7bdf726e0cf4e60ac8bd0ee1..8ca9bd9d23e47cb20f1bfc81f6365e7117d32b34 100644 (file)
  */
 package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Computable;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.light.LightElement;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -26,11 +28,12 @@ import org.jetbrains.plugins.groovy.GroovyFileType;
  * @author ven
  */
 public class LightParameterList extends LightElement implements PsiParameterList {
+  private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.LightParameterList");
+
   private final Computable<LightParameter[]> myParametersComputation;
   private LightParameter[] myParameters = null;
 
-  protected LightParameterList(PsiManager manager,
-                               Computable<LightParameter[]> parametersComputation) {
+  protected LightParameterList(PsiManager manager, Computable<LightParameter[]> parametersComputation) {
     super(manager, GroovyFileType.GROOVY_LANGUAGE);
     myParametersComputation = parametersComputation;
   }
@@ -52,19 +55,17 @@ public class LightParameterList extends LightElement implements PsiParameterList
 
   @NotNull
   public PsiParameter[] getParameters() {
-    if (myParameters == null) {
-      myParameters = myParametersComputation.compute();
+    synchronized (PsiLock.LOCK) {
+      if (myParameters == null) {
+        myParameters = myParametersComputation.compute();
+      }
+      return myParameters;
     }
-
-    return myParameters;
   }
 
   public int getParameterIndex(PsiParameter parameter) {
-    final PsiParameter[] parameters = getParameters();
-    for (int i = 0; i < parameters.length; i++) {
-      if (parameter.equals(parameters[i])) return i;
-    }
-    return -1;
+    LOG.assertTrue(parameter.getParent() == this);
+    return PsiImplUtil.getParameterIndex(parameter, this);
   }
 
   public int getParametersCount() {
index 3a3b1dc37a421ab0de20bc73c3bf5c0d53c9324d..8bd5bdd314293a3dfd8594ca9bc960bfaca68a94 100644 (file)
@@ -22,7 +22,10 @@ import com.intellij.lang.ASTNode;
 import com.intellij.lang.StdLanguages;
 import com.intellij.lang.folding.FoldingBuilderEx;
 import com.intellij.lang.folding.FoldingDescriptor;
+import com.intellij.lang.properties.parsing.PropertyStubElementType;
 import com.intellij.lang.properties.psi.Property;
+import com.intellij.lang.properties.psi.impl.PropertyImpl;
+import com.intellij.lang.properties.psi.impl.PropertyStubImpl;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.util.Key;
 import com.intellij.psi.*;
@@ -41,6 +44,7 @@ import java.util.*;
 public class PropertyFoldingBuilder extends FoldingBuilderEx {
   private static final int FOLD_MAX_LENGTH = 50;
   private static final Key<Property> CACHE = Key.create("i18n.property.cache");
+  public static final Property NULL = new PropertyImpl(new PropertyStubImpl(null, null), new PropertyStubElementType());
 
   @NotNull
   public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement element, @NotNull Document document, boolean quick) {
@@ -71,6 +75,7 @@ public class PropertyFoldingBuilder extends FoldingBuilderEx {
   }
 
   private static void checkLiteral(PsiLiteralExpression expression, List<FoldingDescriptor> result) {
+    expression.getUserData(CACHE);
     if (isI18nProperty(expression)) {
       final Property property = getI18nProperty(expression);
       final HashSet<Object> set = new HashSet<Object>();
@@ -158,6 +163,7 @@ public class PropertyFoldingBuilder extends FoldingBuilderEx {
   @Nullable
   private static Property getI18nProperty(PsiLiteralExpression literal) {
     final Property property = literal.getUserData(CACHE);
+    if (property == NULL) return null;
     if (property != null && property.isValid()) return property;
     if (isI18nProperty(literal)) {
       final PsiReference[] references = literal.getReferences();
@@ -197,10 +203,17 @@ public class PropertyFoldingBuilder extends FoldingBuilderEx {
 
   public static boolean isI18nProperty(PsiLiteralExpression expr) {
     if (! isStringLiteral(expr)) return false;
+    final Property property = expr.getUserData(CACHE);
+    if (property == NULL) return false;
+    if (property != null) return true;
 
     final Map<String, Object> annotationParams = new HashMap<String, Object>();
     annotationParams.put(AnnotationUtil.PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER, null);
-    return JavaI18nUtil.mustBePropertyKey(expr, annotationParams);
+    final boolean isI18n = JavaI18nUtil.mustBePropertyKey(expr, annotationParams);
+    if (!isI18n) {
+      expr.putUserData(CACHE, NULL);
+    }
+    return isI18n;
   }
 
   private static boolean isStringLiteral(PsiLiteralExpression expr) {
index 6ad7ae100d47e96b404c94a8094d0cc12253af08..1f2ce8f6dca096589b05ded5afc3f48ffea2190b 100644 (file)
@@ -224,26 +224,38 @@ public class MavenDomProjectProcessorUtils {
                                     @NotNull final Function<MavenDomProfile, T> domProfileFunction,
                                     @NotNull final Function<MavenDomProjectModel, T> projectDomFunction) {
 
+    return process(projectDom, processor, project, domProfileFunction, projectDomFunction, new HashSet<MavenDomProjectModel>());
+  }
+
+  public static <T> boolean process(@NotNull MavenDomProjectModel projectDom,
+                                    @NotNull final Processor<T> processor,
+                                    @NotNull final Project project,
+                                    @NotNull final Function<MavenDomProfile, T> domProfileFunction,
+                                    @NotNull final Function<MavenDomProjectModel, T> projectDomFunction,
+                                    final Set<MavenDomProjectModel> processed) {
+    if (processed.contains(projectDom))  return true;
+    processed.add(projectDom);
+
     MavenProject mavenProjectOrNull = MavenDomUtil.findProject(projectDom);
 
     if (processSettingsXml(mavenProjectOrNull, processor, project, domProfileFunction)) return true;
     if (processProject(projectDom, mavenProjectOrNull, processor, project, domProfileFunction, projectDomFunction)) return true;
 
-    return processParentProjectFile(projectDom, processor, project, domProfileFunction, projectDomFunction);
+    return processParentProjectFile(projectDom, processor, project, domProfileFunction, projectDomFunction, processed);
   }
 
   private static <T> boolean processParentProjectFile(MavenDomProjectModel projectDom,
                                                       final Processor<T> processor,
                                                       final Project project,
                                                       final Function<MavenDomProfile, T> domProfileFunction,
-                                                      final Function<MavenDomProjectModel, T> projectDomFunction) {
+                                                      final Function<MavenDomProjectModel, T> projectDomFunction,
+                                                      final Set<MavenDomProjectModel> processed) {
     Boolean aBoolean = new MyMavenParentProjectFileProcessor<Boolean>(project) {
       protected Boolean doProcessParent(VirtualFile parentFile) {
         MavenDomProjectModel parentProjectDom = MavenDomUtil.getMavenDomProjectModel(project, parentFile);
         if (parentProjectDom == null) return false;
-        MavenProject parentMavenProject = MavenDomUtil.findProject(parentProjectDom);
 
-        return processProject(parentProjectDom, parentMavenProject, processor, project, domProfileFunction, projectDomFunction);
+        return MavenDomProjectProcessorUtils.process(parentProjectDom, processor, project, domProfileFunction, projectDomFunction, processed);
       }
     }.process(projectDom);
 
index 61cbe9521080f32f4dc7a5f66b1a9d752a7aa0bd..0161d147559a42bf4220c77e6e1aa1ab286860f8 100644 (file)
@@ -107,14 +107,13 @@ public class MavenModuleImporter {
 
   private void configDependencies() {
     for (MavenArtifact artifact : myMavenProject.getDependencies()) {
-      boolean isExportable = artifact.isExportable();
       DependencyScope scope = selectScope(artifact.getScope());
       MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
       if (depProject != null) {
-        myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), isExportable, scope);
+        myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), scope);
       }
       else if (myMavenProject.isSupportedDependency(artifact)) {
-        myRootModelAdapter.addLibraryDependency(artifact, isExportable, scope, myModifiableModelsProvider, myMavenProject);
+        myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
       }
     }
   }
index 6f26888d62759fefcd40063e9444bdb68d391dbb..c4b35c9ee506558b0dcca0541e7f32920290a955 100644 (file)
@@ -194,7 +194,7 @@ public class MavenRootModelAdapter {
     return new Path(path);
   }
 
-  public void addModuleDependency(String moduleName, boolean isExportable, DependencyScope scope) {
+  public void addModuleDependency(String moduleName, DependencyScope scope) {
     Module m = findModuleByName(moduleName);
 
     ModuleOrderEntry e;
@@ -205,7 +205,6 @@ public class MavenRootModelAdapter {
       e = myRootModel.addInvalidModuleEntry(moduleName);
     }
 
-    e.setExported(isExportable);
     e.setScope(scope);
   }
 
@@ -215,7 +214,6 @@ public class MavenRootModelAdapter {
   }
 
   public void addLibraryDependency(MavenArtifact artifact,
-                                   boolean isExportable,
                                    DependencyScope scope,
                                    MavenModifiableModelsProvider provider,
                                    MavenProject project) {
@@ -234,7 +232,6 @@ public class MavenRootModelAdapter {
     }
 
     LibraryOrderEntry e = myRootModel.addLibraryEntry(library);
-    e.setExported(isExportable);
     e.setScope(scope);
   }
 
index 07d0ff2eeeb1a7beb7a33f1877ae8725594659d4..3dafecaf117734f9523947b8a0b424fb284f8ce4 100644 (file)
@@ -201,7 +201,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
     assertModuleDeps(moduleName, LibraryOrderEntry.class, expectedDeps);
   }
 
-  protected void assertExportedModuleDeps(String moduleName, String... expectedDeps) {
+  protected void assertExportedDeps(String moduleName, String... expectedDeps) {
     final List<String> actual = new ArrayList<String>();
 
     getRootManager(moduleName).processOrder(new RootPolicy<Object>() {
index 5278c6c029a12287e1f73cb7f61aec3a36c6b01e..1c81148600e5d52298313ac1612b387ad8183a49 100644 (file)
@@ -21,7 +21,6 @@ import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
-import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.idea.maven.MavenImportingTestCase;
@@ -526,30 +525,7 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
     assertModuleModuleDepScope("m1", "m4", DependencyScope.TEST);
   }
 
-  public void testOptionalLibraryDependencyIsNotExportable() throws Exception {
-    importProject("<groupId>test</groupId>" +
-                  "<artifactId>project</artifactId>" +
-                  "<version>1</version>" +
-
-                  "<dependencies>" +
-                  "  <dependency>" +
-                  "    <groupId>group</groupId>" +
-                  "    <artifactId>lib1</artifactId>" +
-                  "    <version>1</version>" +
-                  "  </dependency>" +
-                  "  <dependency>" +
-                  "    <groupId>group</groupId>" +
-                  "    <artifactId>lib2</artifactId>" +
-                  "    <version>1</version>" +
-                  "    <optional>true</optional>" +
-                  "  </dependency>" +
-                  "</dependencies>");
-
-    assertModules("project");
-    assertExportedModuleDeps("project", "Maven: group:lib1:1");
-  }
-
-  public void testOptionalModuleDependencyIsNotExportable() throws Exception {
+  public void testDependenciesAreNotExported() throws Exception {
     createProjectPom("<groupId>test</groupId>" +
                      "<artifactId>project</artifactId>" +
                      "<packaging>pom</packaging>" +
@@ -558,7 +534,6 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
                      "<modules>" +
                      "  <module>m1</module>" +
                      "  <module>m2</module>" +
-                     "  <module>m3</module>" +
                      "</modules>");
 
     createModulePom("m1", "<groupId>test</groupId>" +
@@ -572,10 +547,9 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
                           "    <version>1</version>" +
                           "  </dependency>" +
                           "  <dependency>" +
-                          "    <groupId>test</groupId>" +
-                          "    <artifactId>m3</artifactId>" +
+                          "    <groupId>lib</groupId>" +
+                          "    <artifactId>lib</artifactId>" +
                           "    <version>1</version>" +
-                          "    <optional>true</optional>" +
                           "  </dependency>" +
                           "</dependencies>");
 
@@ -583,55 +557,8 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
                           "<artifactId>m2</artifactId>" +
                           "<version>1</version>");
 
-    createModulePom("m3", "<groupId>test</groupId>" +
-                          "<artifactId>m3</artifactId>" +
-                          "<version>1</version>");
-
     importProject();
-
-    assertExportedModuleDeps("m1", "m2");
-  }
-
-  public void testOnlyCompileAndRuntimeDependenciesAreExported() throws Exception {
-    importProject("<groupId>test</groupId>" +
-                  "<artifactId>project</artifactId>" +
-                  "<version>1</version>" +
-
-                  "<dependencies>" +
-                  "  <dependency>" +
-                  "    <groupId>test</groupId>" +
-                  "    <artifactId>compile</artifactId>" +
-                  "    <scope>compile</scope>" +
-                  "    <version>1</version>" +
-                  "  </dependency>" +
-                  "  <dependency>" +
-                  "    <groupId>test</groupId>" +
-                  "    <artifactId>runtime</artifactId>" +
-                  "    <scope>runtime</scope>" +
-                  "    <version>1</version>" +
-                  "  </dependency>" +
-                  "  <dependency>" +
-                  "    <groupId>test</groupId>" +
-                  "    <artifactId>test</artifactId>" +
-                  "    <scope>test</scope>" +
-                  "    <version>1</version>" +
-                  "  </dependency>" +
-                  "  <dependency>" +
-                  "    <groupId>test</groupId>" +
-                  "    <artifactId>provided</artifactId>" +
-                  "    <scope>provided</scope>" +
-                  "    <version>1</version>" +
-                  "  </dependency>" +
-                  "  <dependency>" +
-                  "    <groupId>test</groupId>" +
-                  "    <artifactId>system</artifactId>" +
-                  "    <scope>system</scope>" +
-                  "    <systemPath>${java.home}/lib/tools.jar</systemPath>" +
-                  "    <version>1</version>" +
-                  "  </dependency>" +
-                  "</dependencies>");
-
-    assertExportedModuleDeps("project", "Maven: test:compile:1", "Maven: test:runtime:1");
+    assertExportedDeps("m1");
   }
 
   public void testTransitiveDependencies() throws Exception {
index 4ca965c04af36b265a10dfc87454f8618ccb2829..e9e459da1b7fc5b619555b53a5666df2a5669bb7 100644 (file)
@@ -36,7 +36,7 @@ public class IdentifierSplitter extends BaseSplitter {
   private static final Pattern WORD_EXT = Pattern.compile("(\\p{L}*?)[-_$\\[\\]]");
 
   @NonNls
-  private static final Pattern WORD_BRACES = Pattern.compile("(['\"]+?)(.*?)(['\"]+?)");
+  private static final Pattern WORD_IN_QUOTES = Pattern.compile("'([^']*)'");
 
   public IdentifierSplitter() {
 
@@ -49,12 +49,11 @@ public class IdentifierSplitter extends BaseSplitter {
       return null;
     }
 
-    List<TextRange> extracted = new ArrayList<TextRange>();
-    extracted.add(range);
+    List<TextRange> extracted = excludeByPattern(text, range, WORD_IN_QUOTES, 1);
 
-    /*if (extracted == null) {
+    if (extracted == null) {
       return null;
-    }*/
+    }
 
     List<CheckArea> results = new ArrayList<CheckArea>();
 
@@ -66,6 +65,7 @@ public class IdentifierSplitter extends BaseSplitter {
       }
 
 
+
       if (words.size() == 1) {
         addWord(text, results, false, words.get(0));
         continue;
index ad17208478e504d251d4dc472d88d861e2d651d6..95b644b99e6dae9658ad9cf0060cba6c9fa267f9 100644 (file)
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
 
 public class TextSplitter extends BaseSplitter {
 
-  private static final Pattern EXTENDED_WORD_AND_SPECIAL = Pattern.compile("[&#]?\\p{L}*'?\\p{L}(_*\\p{L})*");
+  private static final Pattern EXTENDED_WORD_AND_SPECIAL = Pattern.compile("[&#]?\\p{L}+'?\\p{L}(_*\\p{L})*");
 
   public List<CheckArea> split(@Nullable String text, @NotNull TextRange range) {
     if (text == null || StringUtil.isEmpty(text)) {
index 54ec68178f5f327996a543a5d15d742700e7b145..e48295b41a94778b093180ea1ea860a8e1e25c47 100644 (file)
@@ -54,18 +54,25 @@ public class SplitterTest extends TestCase {
     correctListToCheck(checkAreas, text, new String[]{"Token"});
   }
 
/* public void testWordInBr1() {
 public void testIdentifierInSingleQuotes() {
     String text = "'fill'";
     List<CheckArea> checkAreas = SplitterFactory.getInstance().getIdentifierSplitter().split(text);
     correctListToCheck(checkAreas, text, new String[]{"fill"});
   }
 
-  public void testWordInBr2() {
-    String text = "\"fill\"";
-    List<CheckArea> checkAreas = SplitterFactory.getInstance().getIdentifierSplitter().split(text);
-    correctListToCheck(checkAreas, text, new String[]{"fill"});
+
+   public void testWordsInSingleQuotesWithSep() {
+    String text = "'test-something'";
+    List<CheckArea> checkAreas = SplitterFactory.getInstance().getStringLiteralSplitter().split(text);
+    correctListToCheck(checkAreas, text, new String[]{"test","something"});
   }
-*/
+
+   public void testComplexWordsInQuotes() {
+    String text = "\"test-customer's'\"";
+    List<CheckArea> checkAreas = SplitterFactory.getInstance().getPlainTextSplitter().split(text);
+    correctListToCheck(checkAreas, text, new String[]{"test","customer's"});
+  }
+
   public void testCapitalizedWithShortWords() {
     String text = "IntelliJ";
     List<CheckArea> checkAreas = SplitterFactory.getInstance().getIdentifierSplitter().split(text);
index 29e83d684e07db11e46826d89f09da3623630e2a..fc5068c4ad23f3539d54ae9e25f414229cb06e14 100644 (file)
@@ -86,7 +86,8 @@ unchecked.overriding=Unchecked overriding
 local.enum=Enum must not be local
 
 interface.expected=Interface expected here
-class.expected=No interface expected here
+no.interface.expected=No interface expected here
+class.expected=Class name expected here
 implements.after.interface=No implements clause allowed for interface
 static.declaration.in.inner.class=Inner classes cannot have static declarations
 class.must.be.abstract=Class ''{0}'' must either be declared abstract or implement abstract method ''{1}'' in ''{2}''
index a0a2e8aa027511237492a6d9845681357bdc4e37..665b7b8078e724508941b48253549d94bbe7f2af 100644 (file)
@@ -82,6 +82,9 @@
     <extensionPoint name="debugger.jvmDebugProvider"
                     interface="com.intellij.debugger.engine.JVMDebugProvider"/>
 
+    <extensionPoint name="java.programPatcher"
+                    beanClass="com.intellij.execution.runners.JavaProgramPatcher"/>
+
     <extensionPoint name="OrderRootTypeUI"
                     beanClass="com.intellij.openapi.extensions.KeyedFactoryEPBean"/>
 
 
     <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.ClassNameMacro"/>
     <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.QualifiedClassNameMacro"/>
-    <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.EnumMacro"/>
 
     <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.CurrentPackageMacro"/>
     <liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.RightSideTypeMacro"/>
index 1a0d4b38e176bdcde6574b779738c07ea4c33f4d..a3b28dd8d8873d4aa14c3750cb1d554a89bf1a8f 100644 (file)
@@ -69,7 +69,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
   private final int myHC = ourHC++;
 
   @Override
-  public int hashCode() {
+  public final int hashCode() {
     return myHC;
   }
 
index b8de42b8fe7c362a825a395ac77d31f6eeb1ae0a..66625c5ab7a75736eca3b1a116f1da4863130eb8 100644 (file)
@@ -96,7 +96,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
   private final int myHC = ourHC++;
 
   @Override
-  public int hashCode() {
+  public final int hashCode() {
     return myHC;
   }