Merge remote-tracking branch 'origin/master'
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Fri, 3 Jun 2016 14:03:21 +0000 (17:03 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Fri, 3 Jun 2016 14:03:21 +0000 (17:03 +0300)
76 files changed:
RegExpSupport/src/org/intellij/lang/regexp/RegExpDocumentationProvider.java
RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java
RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHosts.java
RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.form
RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java
RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpIntentionAction.java
RegExpSupport/src/org/intellij/lang/regexp/psi/RegExpElementVisitor.java
RegExpSupport/src/org/intellij/lang/regexp/psi/RegExpOptions.java
RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpOptionsImpl.java
RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java
java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java
java/java-analysis-impl/src/com/intellij/codeInsight/NullityAnnotationModifier.java [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInsight/editorActions/JavaLineIndentProvider.java
java/java-impl/src/com/intellij/psi/impl/JavaRegExpHost.java
java/java-psi-api/src/com/intellij/psi/augment/TypeAnnotationModifier.java
java/java-psi-api/src/com/intellij/psi/impl/source/resolve/graphInference/PsiPolyExpressionUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PolyConditionalExpressionWithTargetPrimitive.java
java/java-tests/testData/inspection/dataFlow/fixture/GenericParameterNullity.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspection8Test.java
java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java
java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java
java/java-tests/testSrc/com/intellij/psi/JavaStubsTest.groovy
platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java
platform/diff-impl/src/com/intellij/diff/tools/util/FoldingModelSupport.java
platform/diff-impl/src/com/intellij/diff/tools/util/base/ListenerDiffViewerBase.java
platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java
platform/extensions/src/com/intellij/util/pico/DefaultPicoContainer.java
platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java
platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java
platform/lang-impl/src/com/intellij/execution/TestStateStorage.java
platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/SemanticEditorPosition.java
platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java
platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java
platform/platform-impl/src/com/intellij/diagnostic/IdeMessagePanel.java
platform/platform-impl/src/com/intellij/ide/MacOSApplicationProvider.java
platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaMenuBarBorder.java
platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaMenuItemBorder.java
platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaPopupMenuBorder.java
platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java
platform/platform-impl/src/com/intellij/ui/EditorTextField.java
platform/platform-impl/src/com/intellij/ui/mac/MacGestureSupportForEditor.java
platform/platform-tests/testSrc/com/intellij/ide/IdeEventQueueTest.java
platform/platform-tests/testSrc/com/intellij/psi/impl/search/LowLevelSearchUtilTest.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/CompoundTestFailedState.java [moved from platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisonFailedStates.java with 69% similarity]
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java
platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java
platform/testRunner/src/com/intellij/execution/testframework/Printer.java
platform/testRunner/src/com/intellij/execution/testframework/export/TestResultsXmlFormatter.java
platform/util/src/com/intellij/util/Restarter.java
plugins/git4idea/src/git4idea/reset/GitResetOperation.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxPropertyReference.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderImpl.java
plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java [new file with mode: 0644]
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java
plugins/maven/src/main/resources/META-INF/plugin.xml
python/src/com/jetbrains/python/facet/LibraryContributingFacet.java
resources/src/META-INF/IdeaPlugin.xml
spellchecker/src/com/intellij/spellchecker/jetbrains.dic

index 7f1da1937ee428462f05225a4d834e89882316da..0edb7c40d12df8c817ca3bd0b97f4dc24143f1ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -17,8 +17,8 @@ package org.intellij.lang.regexp;
 
 import com.intellij.lang.ASTNode;
 import com.intellij.lang.documentation.AbstractDocumentationProvider;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.PsiElement;
-import org.intellij.lang.regexp.psi.RegExpElement;
 import org.intellij.lang.regexp.psi.RegExpGroup;
 import org.intellij.lang.regexp.psi.RegExpProperty;
 import org.jetbrains.annotations.Nullable;
@@ -47,10 +47,12 @@ public final class RegExpDocumentationProvider extends AbstractDocumentationProv
     return null;
   }
 
+  @Override
   @Nullable
   public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
     if (element instanceof RegExpGroup) {
-      return "Capturing Group: " + ((RegExpElement)element).getUnescapedText();
+      final RegExpGroup group = (RegExpGroup)element;
+      return StringUtil.escapeXml(group.getUnescapedText());
     } else {
       return null;
     }
index 1155e09ce160c7db87bc8a78ec920e2235965e8f..c530f61e03dd7463f15adde43697d6b499c3d304 100644 (file)
  */
 package org.intellij.lang.regexp;
 
-import org.intellij.lang.regexp.psi.RegExpChar;
-import org.intellij.lang.regexp.psi.RegExpGroup;
-import org.intellij.lang.regexp.psi.RegExpNamedGroupRef;
-import org.intellij.lang.regexp.psi.RegExpSimpleClass;
+import com.intellij.psi.PsiElement;
+import org.intellij.lang.regexp.psi.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -42,6 +40,10 @@ public interface RegExpLanguageHost {
     return true;
   }
 
+  default boolean supportsInlineOptionFlag(char flag, PsiElement context) {
+    return true;
+  }
+
   boolean isValidCategory(@NotNull String category);
   @NotNull
   String[][] getAllKnownProperties();
index 71ac84ef0138bea1a0d236af624d1f7e8ae19d9f..2d3bd894144c9c15827684d46dda5348e269a628 100644 (file)
@@ -81,6 +81,11 @@ public final class RegExpLanguageHosts extends ClassExtension<RegExpLanguageHost
     }
   }
 
+  public boolean supportsInlineOptionFlag(char flag, PsiElement context) {
+    final RegExpLanguageHost host = findRegExpHost(context);
+    return host == null || host.supportsInlineOptionFlag(flag, context);
+  }
+
   public boolean supportsExtendedHexCharacter(@Nullable RegExpChar regExpChar) {
     final RegExpLanguageHost host = findRegExpHost(regExpChar);
     try {
index 9029a33969fc884de7d79f4fcfa04e0144eff7f9..e0196cb1b26cc21627baf0cffbe76c18bf649ba9 100644 (file)
@@ -1,92 +1,57 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.intellij.lang.regexp.intention.CheckRegExpForm">
-  <grid id="a29f0" binding="myRootPanel" custom-create="true" layout-manager="BorderLayout" hgap="0" vgap="0">
+  <grid id="38faf" binding="myRootPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+    <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
-      <xy x="20" y="20" width="376" height="134"/>
+      <xy x="20" y="20" width="376" height="163"/>
     </constraints>
     <properties/>
-    <border type="empty">
-      <size top="0" left="1" bottom="0" right="1"/>
-    </border>
+    <border type="none"/>
     <children>
-      <grid id="c2a42" layout-manager="BorderLayout" hgap="0" vgap="0">
-        <constraints border-constraint="Center"/>
+      <component id="5de69" class="com.intellij.ui.components.JBLabel" binding="myMessage">
+        <constraints>
+          <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <componentStyle value="SMALL"/>
+          <text value="Red means I can't hear you!"/>
+        </properties>
+      </component>
+      <vspacer id="dd293">
+        <constraints>
+          <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+        </constraints>
+      </vspacer>
+      <component id="b01c9" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <preferredSize width="55" height="16"/>
+          <text value="RegExp:"/>
+        </properties>
+      </component>
+      <component id="ec7ec" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <preferredSize width="55" height="16"/>
+          <text value="Sample:"/>
+        </properties>
+      </component>
+      <component id="d8697" class="com.intellij.ui.EditorTextField" binding="myRegExp" custom-create="true">
+        <constraints>
+          <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+        </constraints>
         <properties/>
-        <border type="none"/>
-        <children>
-          <grid id="a052" layout-manager="BorderLayout" hgap="0" vgap="0">
-            <constraints border-constraint="Center"/>
-            <properties/>
-            <border type="empty">
-              <size top="5" left="5" bottom="10" right="5"/>
-            </border>
-            <children>
-              <grid id="b7b2b" layout-manager="BorderLayout" hgap="0" vgap="0">
-                <constraints border-constraint="North"/>
-                <properties/>
-                <border type="none"/>
-                <children>
-                  <component id="d8697" class="com.intellij.ui.EditorTextField" binding="myRegExp" custom-create="true">
-                    <constraints border-constraint="Center"/>
-                    <properties/>
-                  </component>
-                  <component id="b01c9" class="javax.swing.JLabel">
-                    <constraints border-constraint="West"/>
-                    <properties>
-                      <alignmentX value="1.0"/>
-                      <preferredSize width="55" height="16"/>
-                      <text value="RegExp:"/>
-                    </properties>
-                  </component>
-                </children>
-              </grid>
-              <grid id="aab68" layout-manager="BorderLayout" hgap="0" vgap="0">
-                <constraints border-constraint="Center"/>
-                <properties/>
-                <border type="none"/>
-                <children>
-                  <component id="47807" class="com.intellij.ui.EditorTextField" binding="mySampleText" custom-create="true">
-                    <constraints border-constraint="Center"/>
-                    <properties/>
-                  </component>
-                  <component id="ec7ec" class="javax.swing.JLabel">
-                    <constraints border-constraint="West"/>
-                    <properties>
-                      <alignmentX value="1.0"/>
-                      <alignmentY value="0.0"/>
-                      <preferredSize width="55" height="16"/>
-                      <text value="Sample:"/>
-                    </properties>
-                  </component>
-                </children>
-              </grid>
-            </children>
-          </grid>
-          <grid id="fff6d" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-            <margin top="0" left="0" bottom="0" right="0"/>
-            <constraints border-constraint="South"/>
-            <properties/>
-            <border type="none"/>
-            <children>
-              <component id="5de69" class="com.intellij.ui.components.JBLabel" binding="myMessage">
-                <constraints>
-                  <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
-                </constraints>
-                <properties>
-                  <alignmentX value="0.5"/>
-                  <componentStyle value="SMALL"/>
-                  <text value="Red means I can't hear you!"/>
-                </properties>
-              </component>
-              <hspacer id="c8c90">
-                <constraints>
-                  <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
-                </constraints>
-              </hspacer>
-            </children>
-          </grid>
-        </children>
-      </grid>
+      </component>
+      <component id="47807" class="com.intellij.ui.EditorTextField" binding="mySampleText" custom-create="true">
+        <constraints>
+          <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+      </component>
     </children>
   </grid>
 </form>
index 925d37ba3d59b2c1e749be25607ac881a1996cf4..51fc4578920001a6185745c7f697aa519b94d16f 100644 (file)
@@ -21,14 +21,17 @@ import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CustomShortcutSet;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
+import com.intellij.openapi.editor.ex.EditorEx;
 import com.intellij.openapi.fileTypes.PlainTextFileType;
 import com.intellij.openapi.progress.ProcessCanceledException;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.Balloon;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.IdeFocusManager;
@@ -37,7 +40,6 @@ import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiLanguageInjectionHost;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
 import com.intellij.ui.EditorTextField;
-import com.intellij.ui.Gray;
 import com.intellij.ui.JBColor;
 import com.intellij.ui.components.JBLabel;
 import com.intellij.util.Alarm;
@@ -49,8 +51,6 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.TestOnly;
 
 import javax.swing.*;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.LineBorder;
 import java.awt.*;
 import java.util.regex.Pattern;
 
@@ -82,12 +82,17 @@ public class CheckRegExpForm {
     Document document = PsiDocumentManager.getInstance(myProject).getDocument(myRegexpFile);
 
     myRegExp = new EditorTextField(document, myProject, RegExpLanguage.INSTANCE.getAssociatedFileType());
-    myRegExp.setPreferredWidth(Math.max(JBUI.scale(300), myRegExp.getPreferredSize().width));
     final String sampleText = PropertiesComponent.getInstance(myProject).getValue(LAST_EDITED_REGEXP, "Sample Text");
-    mySampleText = new EditorTextField(sampleText, myProject, PlainTextFileType.INSTANCE);
-    mySampleText.setBorder(
-      new CompoundBorder(JBUI.Borders.empty(2, 2, 2, 4), new LineBorder(UIUtil.isUnderDarcula() ? Gray._100 : JBColor.border())));
+    mySampleText = new EditorTextField(sampleText, myProject, PlainTextFileType.INSTANCE) {
+      @Override
+      protected void updateBorder(@NotNull EditorEx editor) {
+        setupBorder(editor);
+      }
+    };
     mySampleText.setOneLineMode(false);
+    int preferredWidth = Math.max(JBUI.scale(250), myRegExp.getPreferredSize().width);
+    myRegExp.setPreferredWidth(preferredWidth);
+    mySampleText.setPreferredWidth(preferredWidth);
 
     myRootPanel = new JPanel(new BorderLayout()) {
       Disposable disposable;
@@ -112,7 +117,7 @@ public class CheckRegExpForm {
           public void documentChanged(DocumentEvent e) {
             updater.cancelAllRequests();
             if (!updater.isDisposed()) {
-              updater.addRequest(() -> updateBalloon(), 200);
+              updater.addRequest(CheckRegExpForm.this::updateBalloon, 200);
             }
           }
         };
@@ -130,6 +135,7 @@ public class CheckRegExpForm {
         PropertiesComponent.getInstance(myProject).setValue(LAST_EDITED_REGEXP, mySampleText.getText());
       }
     };
+    myRootPanel.setBorder(JBUI.Borders.empty(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
   }
 
   @NotNull
@@ -149,7 +155,9 @@ public class CheckRegExpForm {
       mySampleText.setBackground(correct != null && correct ? BACKGROUND_COLOR_MATCH : BACKGROUND_COLOR_NOMATCH);
       myMessage.setText(correct == null ? "Pattern is too complex" : correct ? "Matches!" : "No match");
       myRootPanel.revalidate();
-    }, o -> false);
+      Balloon balloon = JBPopupFactory.getInstance().getParentBalloonFor(myRootPanel);
+      if (balloon != null) balloon.revalidate();
+    }, ModalityState.current());
   }
 
   @TestOnly
index 6da84caa56ec6bbfc5101f41662143da04ccdb7f..aee165a4db8c33389cd443658d627e8fc5e8daee 100644 (file)
@@ -16,7 +16,9 @@
 package org.intellij.lang.regexp.intention;
 
 import com.intellij.codeInsight.intention.impl.QuickEditAction;
+import com.intellij.codeInsight.intention.impl.QuickEditHandler;
 import com.intellij.lang.Language;
+import com.intellij.lang.injection.InjectedLanguageManager;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -26,6 +28,7 @@ import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
+import com.intellij.util.IncorrectOperationException;
 import org.intellij.lang.regexp.RegExpLanguage;
 import org.jetbrains.annotations.NotNull;
 
@@ -44,7 +47,19 @@ public class CheckRegExpIntentionAction extends QuickEditAction implements Icona
       Language language = pair.first.getLanguage();
       return language.isKindOf(RegExpLanguage.INSTANCE);
     }
-    return false;
+    PsiFile baseFile = InjectedLanguageManager.getInstance(project).getTopLevelFile(file);
+    return baseFile != null && baseFile.getLanguage().isKindOf(RegExpLanguage.INSTANCE);
+  }
+
+  @Override
+  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+    PsiFile baseFile = InjectedLanguageManager.getInstance(project).getTopLevelFile(file);
+    if (baseFile == null || !baseFile.getLanguage().isKindOf(RegExpLanguage.INSTANCE)) {
+      super.invoke(project, editor, file);
+      return;
+    }
+    JComponent component = createBalloonComponent(file);
+    if (component != null) QuickEditHandler.showBalloon(editor, file, component);
   }
 
   @Override
index cd03b9e79b0cf54193c0b486f03e8331d178041a..53cb6f3cf5bc9f34759917944247cc1a1edc2773 100644 (file)
@@ -16,7 +16,6 @@
 package org.intellij.lang.regexp.psi;
 
 import com.intellij.psi.PsiElementVisitor;
-import org.intellij.lang.regexp.psi.impl.RegExpOptionsImpl;
 
 public class RegExpElementVisitor extends PsiElementVisitor {
 
@@ -43,7 +42,7 @@ public class RegExpElementVisitor extends PsiElementVisitor {
         visitRegExpElement(group);
     }
 
-    public void visitRegExpOptions(RegExpOptionsImpl options) {
+    public void visitRegExpOptions(RegExpOptions options) {
         visitRegExpElement(options);
     }
 
index dc927f1a7613773b9f9ec834fa0a3075d6c3e863..f29d10fd718e45b7fd4080925a3d282cbb1683ae 100644 (file)
  */
 package org.intellij.lang.regexp.psi;
 
+import com.intellij.lang.ASTNode;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * Represents an inline options element (?x) or (?-x). Returned from {@link org.intellij.lang.regexp.psi.RegExpSetOptions}
  */
 public interface RegExpOptions extends RegExpElement {
     /**
-     * Checks whether a certain option is set.
+     * @param flag  the flag to check, e.g. 'i'
+     * @return true, when the specified flag is switched on, false otherwise.
      */
-    boolean isSet(char option);
+    boolean isSwitchedOn(char flag);
+
+  /**
+   * It's possible for a flag to be both switched on and switched off.
+   * @param flag  the flag to check, e.g. 'd'
+   * @return true, when the specified flag is switched off, false otherwise.
+   */
+    boolean isSwitchedOff(char flag);
+
+    @Nullable
+    ASTNode getOptionsOn();
+
+    @Nullable
+    ASTNode getOptionsOff();
 }
index 46022bfde2a43eeb645b89ed0168bcfda20a845a..a557702b83e9eb107db67968b7595aba2fa88897 100644 (file)
@@ -17,19 +17,42 @@ package org.intellij.lang.regexp.psi.impl;
 
 import com.intellij.lang.ASTNode;
 
+import org.intellij.lang.regexp.RegExpTT;
 import org.intellij.lang.regexp.psi.RegExpElementVisitor;
 import org.intellij.lang.regexp.psi.RegExpOptions;
+import org.jetbrains.annotations.Nullable;
 
 public class RegExpOptionsImpl extends RegExpElementImpl implements RegExpOptions {
     public RegExpOptionsImpl(ASTNode astNode) {
         super(astNode);
     }
 
+    @Override
     public void accept(RegExpElementVisitor visitor) {
         visitor.visitRegExpOptions(this);
     }
 
-    public boolean isSet(char option) {
-        return getUnescapedText().indexOf(option) != -1;
+    @Override
+    public boolean isSwitchedOn(char flag) {
+        final ASTNode node = getOptionsOn();
+        return node != null && node.getText().indexOf(flag) >= 0;
+    }
+
+    @Override
+    public boolean isSwitchedOff(char flag) {
+        final ASTNode node = getOptionsOff();
+        return node != null && node.getText().indexOf(flag) > 0;
+    }
+
+    @Override
+    @Nullable
+    public ASTNode getOptionsOn() {
+        return getNode().findChildByType(RegExpTT.OPTIONS_ON);
+    }
+
+    @Override
+    @Nullable
+    public ASTNode getOptionsOff() {
+        return getNode().findChildByType(RegExpTT.OPTIONS_OFF);
     }
 }
index 1323e44d18e40c7d9bb4c3c20f72d83a37df3cb5..7817c1e08ce8877f6ca5d7a9df6ce556672e66f8 100644 (file)
@@ -30,6 +30,7 @@ import org.intellij.lang.regexp.RegExpLanguageHosts;
 import org.intellij.lang.regexp.RegExpTT;
 import org.intellij.lang.regexp.psi.*;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.math.BigInteger;
 import java.util.HashSet;
@@ -58,6 +59,27 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
     }
   }
 
+  @Override
+  public void visitRegExpOptions(RegExpOptions options) {
+    checkValidFlag(options.getOptionsOn(), options);
+    checkValidFlag(options.getOptionsOff(), options);
+  }
+
+  private void checkValidFlag(@Nullable ASTNode optionsNode, @NotNull RegExpOptions context) {
+    if (optionsNode == null) {
+      return;
+    }
+    final String text = optionsNode.getText();
+    final int start = (optionsNode.getElementType() == RegExpTT.OPTIONS_OFF) ? 1 : 0; // skip '-' if necessary
+    for (int i = start, length = text.length(); i < length; i++) {
+      final int c = text.codePointAt(i);
+      if (!Character.isBmpCodePoint(c) || !myLanguageHosts.supportsInlineOptionFlag((char)c, context)) {
+        final int offset = optionsNode.getStartOffset() + i;
+        myHolder.createErrorAnnotation(new TextRange(offset, offset + 1), "Unknown inline option flag");
+      }
+    }
+  }
+
   @Override
   public void visitRegExpCharRange(RegExpCharRange range) {
     final RegExpCharRange.Endpoint from = range.getFrom();
index d5f1ab56961d7b40ac1c7e60965a2e4a12053305..ad173f205ebb7c1937ff038bdaa60b1428148657 100644 (file)
@@ -44,7 +44,6 @@ import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.Getter;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
@@ -136,7 +135,6 @@ public abstract class JavaTestFrameworkRunnableState<T extends
     Disposer.register(getConfiguration().getProject(), consoleView);
 
     final OSProcessHandler handler = createHandler(executor);
-    handler.putUserData(TestStateStorage.RUN_CONFIGURATION_NAME_KEY, getConfiguration().getName());
     
     consoleView.attachToProcess(handler);
     final AbstractTestProxy root = viewer.getRoot();
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/NullityAnnotationModifier.java b/java/java-analysis-impl/src/com/intellij/codeInsight/NullityAnnotationModifier.java
new file mode 100644 (file)
index 0000000..f289e22
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight;
+
+import com.intellij.psi.PsiAnnotation;
+import com.intellij.psi.PsiClassType;
+import com.intellij.psi.PsiType;
+import com.intellij.psi.TypeAnnotationProvider;
+import com.intellij.psi.augment.TypeAnnotationModifier;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+/**
+ * @author peter
+ */
+public class NullityAnnotationModifier extends TypeAnnotationModifier {
+  @Nullable
+  @Override
+  public TypeAnnotationProvider modifyAnnotations(@NotNull PsiType inferenceVariableType, @NotNull PsiClassType boundType) {
+    PsiAnnotation[] annotations = inferenceVariableType.getAnnotations();
+    for (PsiAnnotation annotation : annotations) {
+      String qName = annotation.getQualifiedName();
+      if (qName != null && isMatchingAnnotation(boundType, annotation, qName)) {
+        return removeAnnotation(annotations, annotation);
+      }
+    }
+
+    return null;
+  }
+
+  @NotNull
+  private static TypeAnnotationProvider removeAnnotation(PsiAnnotation[] annotations, PsiAnnotation annotation) {
+    List<PsiAnnotation> list = ContainerUtil.newArrayList(annotations);
+    list.remove(annotation);
+    if (list.isEmpty()) {
+      return TypeAnnotationProvider.EMPTY;
+    }
+
+    PsiAnnotation[] array = list.toArray(PsiAnnotation.EMPTY_ARRAY);
+    return () -> array;
+  }
+
+  private static boolean isMatchingAnnotation(@NotNull PsiClassType boundType, PsiAnnotation annotation, String qName) {
+    NullableNotNullManager manager = NullableNotNullManager.getInstance(annotation.getProject());
+    return (manager.getNullables().contains(qName) || manager.getNotNulls().contains(qName)) && boundType.findAnnotation(qName) != null;
+  }
+}
index 3eeecf4c4baf6198f73880b7726d29fef64c6e10..3ff266534a195a7b5716fb049cc3d3b8cd363aec 100644 (file)
@@ -52,6 +52,7 @@ public class JavaLineIndentProvider extends JavaLikeLangLineIndentProvider {
     SYNTAX_MAP.put(JavaTokenType.C_STYLE_COMMENT, BlockComment);
     SYNTAX_MAP.put(JavaDocTokenType.DOC_COMMENT_START, DocBlockStart);
     SYNTAX_MAP.put(JavaDocTokenType.DOC_COMMENT_END, DocBlockEnd);
+    SYNTAX_MAP.put(JavaTokenType.COMMA, Comma);
   }
   
   @Nullable
index b0c3336fcb1961ae68dcc21b2951575c02bc6616..1f11b149cf1410d4df398c24a5ec5f105aff3843 100644 (file)
@@ -42,6 +42,23 @@ public class JavaRegExpHost implements RegExpLanguageHost {
     myPropertiesProvider = DefaultRegExpPropertiesProvider.getInstance();
   }
 
+  @Override
+  public boolean supportsInlineOptionFlag(char flag, PsiElement context) {
+    switch (flag) {
+      case 'i': // case-insensitive matching
+      case 'd': // Unix lines mode
+      case 'm': // multiline mode
+      case 's': // dotall mode
+      case 'u': // Unicode-aware case folding
+      case 'x': // whitespace and comments in pattern
+        return true;
+      case 'U': // Enables the Unicode version of Predefined character classes and POSIX character classes
+        return hasAtLeastJdkVersion(context, JavaSdkVersion.JDK_1_7);
+      default:
+        return false;
+    }
+  }
+
   @Override
   public boolean characterNeedsEscaping(char c) {
     return c == ']' || c == '}';
@@ -105,11 +122,10 @@ public class JavaRegExpHost implements RegExpLanguageHost {
   }
 
   private static boolean hasAtLeastJdkVersion(PsiElement element, JavaSdkVersion version) {
-    final JavaSdkVersion version1 = getJavaVersion(element);
-    return version1 != null && version1.isAtLeast(version);
+    return getJavaVersion(element).isAtLeast(version);
   }
 
-  @Nullable
+  @NotNull
   private static JavaSdkVersion getJavaVersion(PsiElement element) {
     final Module module = ModuleUtilCore.findModuleForPsiElement(element);
     if (module != null) {
index 56cf6abb0cd0ee60ded5d3d8e21efbb1c38cb2a6..962d725c2daa00e0784a8bb8ec0448ac316958f6 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.psi.PsiClassType;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.TypeAnnotationProvider;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 public abstract class TypeAnnotationModifier {
@@ -36,6 +37,6 @@ public abstract class TypeAnnotationModifier {
    * @return provider based on modified annotations or null if no applicable annotations found
    */
   @Nullable
-  public abstract TypeAnnotationProvider getTypeAnnotationProvider(PsiType inferenceVariableType, PsiClassType boundType);
+  public abstract TypeAnnotationProvider modifyAnnotations(@NotNull PsiType inferenceVariableType, @NotNull PsiClassType boundType);
 
 }
index 77ff31109a9fe214270ee5f2ca3adf0cf73be311..98893d49f8b4a93e287d387194acfdb30f44b7b8 100644 (file)
@@ -160,7 +160,7 @@ public class PsiPolyExpressionUtil {
   }
 
   private enum ConditionalKind {
-    BOOLEAN, NUMERIC
+    BOOLEAN, NUMERIC, NULL
   }
 
   private static ConditionalKind isBooleanOrNumeric(PsiExpression expr) {
@@ -192,14 +192,18 @@ public class PsiPolyExpressionUtil {
       final PsiExpression elseExpression = ((PsiConditionalExpression)expr).getElseExpression();
       final ConditionalKind thenKind = isBooleanOrNumeric(thenExpression);
       final ConditionalKind elseKind = isBooleanOrNumeric(elseExpression);
-      if (thenKind == elseKind || elseKind == null) return thenKind;
-      if (thenKind == null) return elseKind;
+      if (thenKind == elseKind || elseKind == ConditionalKind.NULL) return thenKind;
+      if (thenKind == ConditionalKind.NULL) return elseKind;
     }
     return null;
   }
 
   @Nullable
   private static ConditionalKind isBooleanOrNumericType(PsiType type) {
+    if (type == PsiType.NULL) {
+      return ConditionalKind.NULL;
+    }
+
     final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(type);
     if (TypeConversionUtil.isNumericType(type)) return ConditionalKind.NUMERIC;
     if (TypeConversionUtil.isBooleanType(type)) return ConditionalKind.BOOLEAN;
index 138991abf9f0e8f3287378b4b362ffc668195036..78949153555b4747839002a4cf28454f73fa7583 100644 (file)
@@ -74,7 +74,7 @@ public class InferenceVariable extends LightTypeParameter {
     if (variable != null) {
       for (TypeAnnotationModifier modifier : TypeAnnotationModifier.EP_NAME.getExtensions()) {
         if (boundType instanceof PsiClassType) {
-          final TypeAnnotationProvider annotationProvider = modifier.getTypeAnnotationProvider(inferenceVariableType, (PsiClassType)boundType);
+          final TypeAnnotationProvider annotationProvider = modifier.modifyAnnotations(inferenceVariableType, (PsiClassType)boundType);
           if (annotationProvider != null) {
             boundType = boundType.annotate(annotationProvider);
           }
index b71319b3a6f1ae7e157faf87e207d0e08cffab11..2c793103bf4f231433fdf8c5cfe3a196b4c74e56 100644 (file)
@@ -54,10 +54,16 @@ public class StringLiteralManipulator extends AbstractElementManipulator<PsiLite
   @NotNull
   public static TextRange getValueRange(@NotNull PsiLiteralExpression element) {
     int length = element.getTextLength();
-    IElementType type = ((PsiLiteralExpressionImpl)element).getLiteralElementType();
-    if (type != JavaTokenType.STRING_LITERAL && type != JavaTokenType.CHARACTER_LITERAL) {
-      return TextRange.from(0, length);
+    boolean isQuoted;
+    if (element instanceof PsiLiteralExpressionImpl) {
+      // avoid calling getValue(): it allocates new string, it returns null for invalid escapes
+      IElementType type = ((PsiLiteralExpressionImpl)element).getLiteralElementType();
+      isQuoted = type == JavaTokenType.STRING_LITERAL || type == JavaTokenType.CHARACTER_LITERAL;
     }
-    return new TextRange(1, Math.max(1, length - 1));
+    else {
+      final Object value = element.getValue();
+      isQuoted = value instanceof String || value instanceof Character;
+    }
+    return isQuoted ? new TextRange(1, Math.max(1, length - 1)) : TextRange.from(0, length);
   }
 }
index b3fd0e9ca2ed42b4acd9ca2b4fb712f9eeae5e95..64b5db73ea10bd7734965d0aca2cdbb449afd8da 100644 (file)
@@ -6,6 +6,11 @@ class Conditional {
     int a2 = b ? null : 1;
     int a3 = b ? null : f1();
     int a4 = b ? null : f2();
+    Long someNum = b ? getNum(5L) : <error descr="Incompatible types. Found: 'int', required: 'java.lang.Long'">0</error>;
+  }
+
+  private static <T> T getNum(T num) {
+    return num;
   }
 
   private static <T> T f() {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/GenericParameterNullity.java b/java/java-tests/testData/inspection/dataFlow/fixture/GenericParameterNullity.java
new file mode 100644 (file)
index 0000000..43c15c1
--- /dev/null
@@ -0,0 +1,28 @@
+import foo.*;
+
+class Test {
+
+  public void test() {
+
+    @NotNull
+    String a = notNull(getNullable());
+
+    @NotNull
+    String b = notNull(null);
+  }
+
+  @Nullable
+  public String getNullable() {
+    return null;
+  }
+
+  @NotNull
+  private static <T> T notNull(@Nullable T value) {
+
+    if (value == null) {
+      throw new RuntimeException("null");
+    }
+
+    return value;
+  }
+}
\ No newline at end of file
index 2abc6b4a06b30363f33de0e0c67af1357725fe60..a382393b7feca9fc936a610d3992f159894339df 100644 (file)
@@ -45,6 +45,7 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
   public void testMethodReferenceOnNullable() { doTest(); }
   public void testNullableVoidLambda() { doTest(); }
   public void testNullableForeachVariable() { doTestWithCustomAnnotations(); }
+  public void testGenericParameterNullity() { doTestWithCustomAnnotations(); }
   public void testOptionalOfNullable() { doTest(); }
   public void testPrimitiveInVoidLambda() { doTest(); }
   public void testNotNullLambdaParameter() { doTest(); }
index 6d234c54874b568b1f001d398b726562444d2bdf..6ccfb6ff49575b84296f09bff77a3f010c8abb9a 100644 (file)
@@ -82,7 +82,6 @@ public class BytecodeAnalysisIntegrationTest extends JavaCodeInsightFixtureTestC
   private void setUpLibraries() {
     String libDir = PathManagerEx.getCommunityHomePath() + "/lib";
     PsiTestUtil.addLibrary(myModule, "velocity", libDir, new String[]{"/velocity.jar!/"}, ArrayUtil.EMPTY_STRING_ARRAY);
-    //PsiTestUtil.addLibrary(myModule, "velocity", libDir, "velocity.jar");
   }
 
   private void setUpExternalUpAnnotations() {
index b86cb926a13c17aa82bf9646c4c70a20a348f96a..cd9fcbf9af4aea77d8631211e549260683237c73 100644 (file)
@@ -189,7 +189,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
   }
 
   private static void doTest(String clsPath, String txtPath) {
-    VirtualFile file = (clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local()).findFileByPath(clsPath);
+    VirtualFile file = (clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local()).refreshAndFindFileByPath(clsPath);
     assertNotNull(clsPath, file);
 
     String expected;
index 0acc8daa5308a22528903c6308f5b2216f8cd17f..f352b22826257045d6c20eafb038cd5f78c04597 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -23,23 +23,18 @@ class JavaStubsTest extends LightCodeInsightFixtureTestCase {
 
   public void "test resolve from annotation method default"() {
     def cls = myFixture.addClass("""
-public @interface BrokenAnnotation {
+      public @interface BrokenAnnotation {
+        enum Foo {DEFAULT, OTHER}
+        Foo value() default Foo.DEFAULT;
+      }
+      """.stripIndent())
 
-  public enum Foo {
-    DEFAULT,
-    OTHER
-  }
-
-  Foo value() default Foo.DEFAULT;
-}
-""")
-    
     def file = cls.containingFile as PsiFileImpl
     assert file.stub
-    
+
     def ref = (cls.methods[0] as PsiAnnotationMethod).defaultValue
     assert file.stub
-    
+
     assert ref instanceof PsiReferenceExpression
     assert ref.resolve() == cls.innerClasses[0].fields[0]
     assert file.stub
@@ -47,16 +42,16 @@ public @interface BrokenAnnotation {
 
   public void "test literal annotation value"() {
     def cls = myFixture.addClass("""
-class Foo {
-  @org.jetbrains.annotations.Contract(pure=true)
-  native int foo();
-}
-""")
+      class Foo {
+        @org.jetbrains.annotations.Contract(pure=true)
+        native int foo();
+      }
+      """.stripIndent())
 
     def file = cls.containingFile as PsiFileImpl
     assert ControlFlowAnalyzer.isPure(cls.methods[0])
     assert file.stub
     assert !file.contentsLoaded
   }
-  
-}
+
+}
\ No newline at end of file
index bbff39c7d03eb80190f62f87947f7d2b396f2047..7f5bb5abca6ffa1fbccb4a3afc2895db4597cfb0 100644 (file)
@@ -246,8 +246,9 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
       if (task.indicator.isCanceled()) {
         s += "; indicator: " + task.indicator;
       }
+      Document document = task.getDocument();
       boolean stillUncommitted = !task.project.isDisposed() &&
-                                 ((PsiDocumentManagerBase)PsiDocumentManager.getInstance(task.project)).isInUncommittedSet(task.document);
+                                 ((PsiDocumentManagerBase)PsiDocumentManager.getInstance(task.project)).isInUncommittedSet(document);
       if (stillUncommitted) {
         s += "; still uncommitted";
       }
@@ -345,11 +346,11 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     }
   }
 
-  private static boolean cancelAndRemoveFromQueue(@NotNull CommitTask newTask, @NotNull HashSetQueue<CommitTask> queue, @NotNull Object reason) {
+  private boolean cancelAndRemoveFromQueue(@NotNull CommitTask newTask, @NotNull HashSetQueue<CommitTask> queue, @NotNull Object reason) {
     CommitTask queuedTask = queue.find(newTask);
     if (queuedTask != null) {
       assert queuedTask != newTask;
-      queuedTask.cancel(reason, getInstance());
+      queuedTask.cancel(reason, this);
     }
     return queue.remove(newTask);
   }
@@ -382,7 +383,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
           return false;
         }
 
-        document = task.document;
+        document = task.getDocument();
         indicator = task.indicator;
         project = task.project;
 
@@ -413,7 +414,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
           public void run() {
             result.set(commitUnderProgress(commitTask, false));
           }
-        }, commitTask.indicator);
+        }, indicator);
         finishRunnable = result.get().first;
         success = finishRunnable != null;
         failureReason = result.get().second;
@@ -435,7 +436,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
       }
     }
     catch (ProcessCanceledException e) {
-      cancel(e + " (cancel reason: "+((UserDataHolder)task.indicator).getUserData(CommitTask.CANCEL_REASON)+")"); // leave queue unchanged
+      cancel(e + " (cancel reason: "+((UserDataHolder)task.indicator).getUserData(CANCEL_REASON)+")"); // leave queue unchanged
       success = false;
       failureReason = e;
     }
@@ -446,7 +447,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     }
 
     final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
-    if (!success && task != null && documentManager.isUncommited(task.document)) { // sync commit has not intervened
+    if (!success && task != null && documentManager.isUncommited(document)) { // sync commit has not intervened
       final Document finalDocument = document;
       final Project finalProject = project;
       List<Pair<PsiFileImpl, FileASTNode>> oldFileNodes =
@@ -541,9 +542,9 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     if (synchronously) {
       assert !task.indicator.isCanceled();
     }
-    final Project project = task.project;
 
-    final Document document = task.document;
+    final Document document = task.getDocument();
+    final Project project = task.project;
     final PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(project);
     final List<Processor<Document>> finishProcessors = new SmartList<Processor<Document>>();
     Runnable runnable = new Runnable() {
@@ -602,11 +603,21 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
       return new Pair<Runnable, Object>(null, "Indicator was canceled");
     }
 
-    Runnable result = new Runnable() {
+    Runnable result = createEdtRunnable(task, synchronously, finishProcessors);
+    return Pair.create(result, null);
+  }
+
+  @NotNull
+  private Runnable createEdtRunnable(@NotNull final CommitTask task,
+                                     final boolean synchronously,
+                                     @NotNull final List<Processor<Document>> finishProcessors) {
+    return new Runnable() {
       @Override
       public void run() {
         myApplication.assertIsDispatchThread();
-
+        Document document = task.getDocument();
+        Project project = task.project;
+        PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(project);
         boolean committed = project.isDisposed() || documentManager.isCommitted(document);
         synchronized (lock) {
           documentsToApplyInEDT.remove(task);
@@ -643,7 +654,6 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
         }
       }
     };
-    return Pair.create(result, null);
   }
 
   @NotNull
@@ -683,9 +693,9 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     UIUtil.dispatchAllInvocationEvents();
   }
 
-  private static class CommitTask {
-    static final Key<Object> CANCEL_REASON = Key.create("CANCEL_REASON");
-    @NotNull final Document document;
+  private static final Key<Object> CANCEL_REASON = Key.create("CANCEL_REASON");
+  private class CommitTask {
+    @NotNull private final Document document;
     @NotNull final Project project;
     private final int modificationSequence; // store initial document modification sequence here to check if it changed later before commit in EDT
 
@@ -698,12 +708,12 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     private final CharSequence myLastCommittedText;
     @NotNull final List<Pair<PsiFileImpl, FileASTNode>> myOldFileNodes;
 
-    protected CommitTask(@NotNull final Project project,
-                         @NotNull final Document document,
-                         @NotNull final List<Pair<PsiFileImpl, FileASTNode>> oldFileNodes,
-                         @NotNull ProgressIndicator indicator,
-                         @NotNull Object reason,
-                         @NotNull ModalityState currentModalityState) {
+    CommitTask(@NotNull final Project project,
+               @NotNull final Document document,
+               @NotNull final List<Pair<PsiFileImpl, FileASTNode>> oldFileNodes,
+               @NotNull ProgressIndicator indicator,
+               @NotNull Object reason,
+               @NotNull ModalityState currentModalityState) {
       this.document = document;
       this.project = project;
       this.indicator = indicator;
@@ -717,11 +727,13 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     @NonNls
     @Override
     public String toString() {
-      return "Doc: " + document + " (\"" + StringUtil.first(document.getImmutableCharSequence(), 40, true).toString().replaceAll("\n", " ") + "\")"
-             + (indicator.isCanceled() ? " (Canceled: " + ((UserDataHolder)indicator).getUserData(CANCEL_REASON) + ")":"")
-             +" Reason: " + reason
-             + (isStillValid() ? "" : "; changed: old seq="+modificationSequence+", new seq="+ ((DocumentEx)document).getModificationSequence())
-        ;
+      Document document = getDocument();
+      String docInfo = document + " (\"" + StringUtil.first(document.getImmutableCharSequence(), 40, true).toString().replaceAll("\n", " ") + "\")";
+      String indicatorInfo = indicator.isCanceled() ? " (Canceled: " + ((UserDataHolder)indicator).getUserData(CANCEL_REASON) + ")" : "";
+      String reasonInfo = " Reason: " + reason + (isStillValid() ? ""
+                                                                 : "; changed: old seq=" + modificationSequence + ", new seq=" +
+                                                                    ((DocumentEx)document).getModificationSequence());
+      return "Doc: " + docInfo + indicatorInfo + reasonInfo;
     }
 
     @Override
@@ -731,17 +743,18 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
 
       CommitTask task = (CommitTask)o;
 
-      return document.equals(task.document) && project.equals(task.project);
+      return Comparing.equal(getDocument(),task.getDocument()) && project.equals(task.project);
     }
 
     @Override
     public int hashCode() {
-      int result = document.hashCode();
+      int result = getDocument().hashCode();
       result = 31 * result + project.hashCode();
       return result;
     }
 
     public boolean isStillValid() {
+      Document document = getDocument();
       return ((DocumentEx)document).getModificationSequence() == modificationSequence;
     }
 
@@ -751,8 +764,17 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
 
         indicator.cancel();
         ((UserDataHolder)indicator).putUserData(CANCEL_REASON, reason);
+
+        synchronized (lock) {
+          documentsToCommit.remove(this);
+          documentsToApplyInEDT.remove(this);
+        }
       }
     }
+
+    Document getDocument() {
+      return document;
+    }
   }
 
   // public for Upsource
@@ -760,7 +782,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
   public Processor<Document> doCommit(@NotNull final CommitTask task,
                                       @NotNull final PsiFile file,
                                       @NotNull final FileASTNode oldFileNode) {
-    Document document = task.document;
+    Document document = task.getDocument();
     final CharSequence newDocumentText = document.getImmutableCharSequence();
     final TextRange changedPsiRange = getChangedPsiRange(file, task.myLastCommittedText, newDocumentText);
     if (changedPsiRange == null) {
@@ -944,4 +966,13 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
     return lock != null ? lock : ((UserDataHolderEx)document).putUserDataIfAbsent(DOCUMENT_LOCK, new ReentrantLock());
   }
   private static final Key<Lock> DOCUMENT_LOCK = Key.create("DOCUMENT_LOCK");
+
+  @TestOnly
+  int documentsToCommit() {
+    return documentsToCommit.size();
+  }
+  @TestOnly
+  int documentsToApplyInEDT() {
+    return documentsToApplyInEDT.size();
+  }
 }
index 32d72c5942174013299a549dbbf57050a08ff0c6..8cfb8bb0f2ce6ccbed2e5e0babaf16ec414115d2 100644 (file)
@@ -259,8 +259,8 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
   }
 
   private void switchFromStubToAst(List<Pair<StubBasedPsiElementBase, AstPath>> bindings) {
-    if (!bindings.isEmpty()) {
-      assert !myUseStrongRefs;
+    if (!bindings.isEmpty() && myUseStrongRefs) {
+      LOG.error(this + " of " + getClass() + "; " + bindings);
     }
 
     for (Pair<StubBasedPsiElementBase, AstPath> pair : bindings) {
index 97130c5d85f5c9045deef57a191c588c4839af1a..ded0cd8b6bc70cf18aba660cef09c1ea7cd8a90b 100644 (file)
@@ -410,8 +410,8 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
       if (!myEditor.isViewer()) {
         for (ChangedBlock block : blocks) {
           LineRange range = myMasterSide.select(block.getRange2(), block.getRange1());
+          if (range.isEmpty()) continue;
           TextRange textRange = DiffUtil.getLinesRange(myDocument, range.start, range.end);
-          if (textRange.isEmpty()) continue;
           guarderRangeBlocks.add(createGuardedBlock(textRange.getStartOffset(), textRange.getEndOffset()));
         }
         int textLength = myDocument.getTextLength(); // there are 'fake' newline at the very end
index 47f3f9f4ef08dc968839027089cd11b1a66930ce..f81d6f15969261f62ffd52506df52c98007a9a46 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.diff.tools.util;
 
+import com.intellij.diff.tools.util.base.TextDiffViewerUtil;
 import com.intellij.diff.util.DiffDividerDrawUtil;
 import com.intellij.diff.util.DiffDrawUtil;
 import com.intellij.diff.util.DiffUtil;
@@ -22,6 +23,7 @@ import com.intellij.diff.util.LineRange;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ReadAction;
+import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.FoldRegion;
 import com.intellij.openapi.editor.event.DocumentAdapter;
@@ -75,12 +77,14 @@ public class FoldingModelSupport {
     myShouldUpdateLineNumbers = new boolean[myCount];
 
     MyDocumentListener documentListener = new MyDocumentListener();
+    List<Document> documents = ContainerUtil.map(myEditors, EditorEx::getDocument);
+    TextDiffViewerUtil.installDocumentListeners(documentListener, documents, disposable);
+
     for (int i = 0; i < myCount; i++) {
       if (myCount > 1) {
         myEditors[i].getFoldingModel().addListener(new MyFoldingListener(i), disposable);
       }
       myEditors[i].getGutterComponentEx().setLineNumberConvertor(getLineConvertor(i));
-      myEditors[i].getDocument().addDocumentListener(documentListener, disposable);
     }
   }
 
index 1c74e4f84a3e15acaa5fca9e6c06b8463f53e8fa..e9d74176f44e2010861766d9845d8da50fdc7903 100644 (file)
@@ -25,43 +25,31 @@ import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
 import com.intellij.openapi.editor.event.DocumentListener;
 import com.intellij.openapi.vfs.*;
-import com.intellij.util.containers.HashSet;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.CalledInAwt;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 
 public abstract class ListenerDiffViewerBase extends DiffViewerBase {
-  @NotNull private final DocumentListener myDocumentListener;
-  @Nullable private final VirtualFileListener myFileListener;
-
   public ListenerDiffViewerBase(@NotNull DiffContext context, @NotNull ContentDiffRequest request) {
     super(context, request);
-    myDocumentListener = createDocumentListener();
-    myFileListener = createFileListener(request);
   }
 
   @Override
   protected void onInit() {
     super.onInit();
-    if (myFileListener != null) VirtualFileManager.getInstance().addVirtualFileListener(myFileListener);
 
-    for (Document document : getDocuments()) {
-      document.addDocumentListener(myDocumentListener);
-    }
-  }
+    VirtualFileListener fileListener = createFileListener(myRequest);
+    if (fileListener != null) VirtualFileManager.getInstance().addVirtualFileListener(fileListener, this);
 
-  @Override
-  protected void onDispose() {
-    if (myFileListener != null) VirtualFileManager.getInstance().removeVirtualFileListener(myFileListener);
-
-    for (Document document : getDocuments()) {
-      document.removeDocumentListener(myDocumentListener);
-    }
-    super.onDispose();
+    DocumentListener documentListener = createDocumentListener();
+    List<Document> documents = ContainerUtil.mapNotNull(myRequest.getContents(), (content) -> {
+      return content instanceof DocumentContent ? ((DocumentContent)content).getDocument() : null;
+    });
+    TextDiffViewerUtil.installDocumentListeners(documentListener, documents, this);
   }
 
   @NotNull
@@ -124,19 +112,4 @@ public abstract class ListenerDiffViewerBase extends DiffViewerBase {
   protected void onFileChange(@NotNull VirtualFileEvent event) {
     scheduleRediff();
   }
-
-  //
-  // Helpers
-  //
-
-  @NotNull
-  private Set<Document> getDocuments() {
-    Set<Document> documents = new HashSet<>();
-    for (DiffContent content : myRequest.getContents()) {
-      if (content instanceof DocumentContent) {
-        documents.add(((DocumentContent)content).getDocument());
-      }
-    }
-    return documents;
-  }
 }
index 9e44fde874aef6ca148d83ef7013c83d00c31fa5..05674c09ab288675d34ad6a671baf54239789cd2 100644 (file)
@@ -31,7 +31,9 @@ import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.actions.EditorActionUtil;
+import com.intellij.openapi.editor.event.DocumentListener;
 import com.intellij.openapi.editor.event.EditorMouseEvent;
 import com.intellij.openapi.editor.ex.EditorEx;
 import com.intellij.openapi.project.DumbAware;
@@ -100,6 +102,14 @@ public class TextDiffViewerUtil {
     return result;
   }
 
+  public static void installDocumentListeners(@NotNull DocumentListener listener,
+                                              @NotNull List<Document> documents,
+                                              @NotNull Disposable disposable) {
+    for (Document document : ContainerUtil.newHashSet(documents)) {
+      document.addDocumentListener(listener, disposable);
+    }
+  }
+
   public static void checkDifferentDocuments(@NotNull ContentDiffRequest request) {
     // Actually, this should be a valid case. But it has little practical sense and will require explicit checks everywhere.
     // Some listeners will be processed once instead of 2 times, some listeners will cause illegal document modifications.
index 0624371db0ac9ca6db84441d49480b8fef51f277..3d8008bea4e915c9e9c601941a297fe51051743d 100644 (file)
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.picocontainer.*;
 import org.picocontainer.defaults.*;
-import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
 
 import java.io.Serializable;
 import java.util.*;
index e74b7e7264410c572c9a9eed5a0ad9f200ffa917..5efe5c90ff57655b9d86ade272c1ec6ca0c814b5 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.projectRoots;
 
+import com.intellij.execution.CantRunException;
 import com.intellij.execution.CommandLineWrapperUtil;
 import com.intellij.execution.configurations.GeneralCommandLine;
 import com.intellij.execution.configurations.GeneralCommandLine.ParentEnvironmentType;
@@ -26,6 +27,7 @@ import com.intellij.openapi.application.ApplicationNamesInfo;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.util.text.StringUtilRt;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -262,24 +264,21 @@ public class JdkUtil {
       commandLine.addParameter(classpath);
     }
     catch (IOException e) {
-      LOG.error(e);
+      LOG.info(e);
+      throwUnableToCreateTempFile();
     }
     appendEncoding(javaParameters, commandLine, vmParametersList);
-    if (classpathFile != null) {
-      commandLine.addParameter(commandLineWrapper.getName());
-      commandLine.addParameter(classpathFile.getAbsolutePath());
-    }
+    commandLine.addParameter(commandLineWrapper.getName());
+    commandLine.addParameter(classpathFile.getAbsolutePath());
 
     if (vmParamsFile != null) {
       commandLine.addParameter("@vm_params");
       commandLine.addParameter(vmParamsFile.getAbsolutePath());
     }
 
-    if (classpathFile != null || vmParamsFile != null) {
-      final Set<File> filesToDelete = getFilesToDeleteUserData(commandLine);
-      ContainerUtil.addIfNotNull(classpathFile, filesToDelete);
-      ContainerUtil.addIfNotNull(vmParamsFile, filesToDelete);
-    }
+    final Set<File> filesToDelete = getFilesToDeleteUserData(commandLine);
+    ContainerUtil.addIfNotNull(classpathFile, filesToDelete);
+    ContainerUtil.addIfNotNull(vmParamsFile, filesToDelete);
   }
 
   private static void appendJarClasspathParams(SimpleJavaParameters javaParameters,
@@ -326,10 +325,15 @@ public class JdkUtil {
       }
     }
     catch (IOException e) {
-      LOG.error(e);
+      LOG.info(e);
+      throwUnableToCreateTempFile();
     }
   }
 
+  private static void throwUnableToCreateTempFile() {
+    throw new RuntimeException(new CantRunException("Failed to create temp file with long classpath in " + FileUtilRt.getTempDirectory()));
+  }
+
   private static boolean isClassPathJarEnabled(SimpleJavaParameters javaParameters, String currentPath) {
     if (javaParameters.isUseClasspathJar() && useClasspathJar()) {
       try {
index 95ed18ad89249b66cd5f1c7154c1d0d897faeeee..d7f68e856b2197a3ce0868337182dc71cf60f1b8 100644 (file)
@@ -224,7 +224,7 @@ public class InjectedGeneralHighlightingPass extends GeneralHighlightingPass imp
       TextRange textRange = place.getRangeInsideHost().shiftRight(host.getTextRange().getStartOffset());
       if (textRange.isEmpty()) continue;
       HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_BACKGROUND).range(textRange);
-      if (injectedAttributes != null) {
+      if (injectedAttributes != null && InjectedLanguageUtil.isHighlightInjectionBackground(host)) {
         builder.textAttributes(injectedAttributes);
       }
       if (addTooltips) {
@@ -248,7 +248,8 @@ public class InjectedGeneralHighlightingPass extends GeneralHighlightingPass imp
     highlightInjectedSyntax(injectedPsi, holder);
     for (int i = injectedStart; i < holder.size(); i++) {
       HighlightInfo info = holder.get(i);
-      final TextRange fixedTextRange = getFixedTextRange(documentWindow, info.startOffset);
+      final int startOffset = info.startOffset;
+      final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset);
       if (fixedTextRange == null) {
         info.setFromInjection(true);
         outInfos.add(info);
index 094374c22495aa39ea7c8b0be95d2d617d2f1c08..669ff357ff6aa9982b070f25d8167aa1f2427112 100644 (file)
@@ -194,30 +194,7 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
   public void navigate(int injectedOffset) {
     if (myAction.isShowInBalloon()) {
       final JComponent component = myAction.createBalloonComponent(myNewFile);
-      if (component != null) {
-        final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component)
-          .setShadow(true)
-          .setAnimationCycle(0)
-          .setHideOnClickOutside(true)
-          .setHideOnKeyOutside(true)
-          .setHideOnAction(false)
-          .setFillColor(UIUtil.getControlColor())
-          .createBalloon();
-        new AnAction() {
-          @Override
-          public void actionPerformed(AnActionEvent e) {
-            balloon.hide();
-          }
-        }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component);
-        Disposer.register(myNewFile.getProject(), balloon);
-        final Balloon.Position position = QuickEditAction.getBalloonPosition(myEditor);
-        RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor);
-        if (position == Balloon.Position.above) {
-          final Point p = point.getPoint();
-          point = new RelativePoint(point.getComponent(), new Point(p.x, p.y - myEditor.getLineHeight()));
-        }
-        balloon.show(point, position);
-      }
+      if (component != null) showBalloon(myEditor, myNewFile, component);
     }
     else {
       final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
@@ -245,6 +222,31 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
     }
   }
 
+  public static void showBalloon(Editor editor, PsiFile newFile, JComponent component) {
+    final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component)
+      .setShadow(true)
+      .setAnimationCycle(0)
+      .setHideOnClickOutside(true)
+      .setHideOnKeyOutside(true)
+      .setHideOnAction(false)
+      .setFillColor(UIUtil.getControlColor())
+      .createBalloon();
+    new AnAction() {
+      @Override
+      public void actionPerformed(AnActionEvent e) {
+        balloon.hide();
+      }
+    }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component);
+    Disposer.register(newFile.getProject(), balloon);
+    final Balloon.Position position = QuickEditAction.getBalloonPosition(editor);
+    RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
+    if (position == Balloon.Position.above) {
+      final Point p = point.getPoint();
+      point = new RelativePoint(point.getComponent(), new Point(p.x, p.y - editor.getLineHeight()));
+    }
+    balloon.show(point, position);
+  }
+
   @Override
   public void documentChanged(DocumentEvent e) {
     UndoManager undoManager = UndoManager.getInstance(myProject);
index cfc51040501dc054668800efca542f095095df87..5858cb70c3c4913507a2d00c643feef435cb77a5 100644 (file)
@@ -40,7 +40,6 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
@@ -457,6 +456,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
   public void finishLookup(char completionChar, @Nullable final LookupElement item) {
     //noinspection deprecation,unchecked
     if (item == null ||
+        !item.isValid() ||
         item instanceof EmptyLookupItem ||
         item.getObject() instanceof DeferredUserLookupValue &&
         item.as(LookupItem.CLASS_CONDITION_KEY) != null &&
index 24a472f07c7a5b9cbeed1157873018dbd8092a73..b291594aede05fb13b200eaa17d83f76fb54ab0c 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.application.PathManager;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.ThrowableComputable;
 import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.vfs.newvfs.persistent.FlushingDaemon;
@@ -44,8 +43,6 @@ import java.util.concurrent.ScheduledFuture;
  * @author Dmitry Avdeev
  */
 public class TestStateStorage implements Disposable {
-
-  public static Key<String> RUN_CONFIGURATION_NAME_KEY = Key.create("run.configuration.name");
   
   private static final File TEST_HISTORY_PATH = new File(PathManager.getSystemPath(), "testHistory");
 
index 319ed818c5bd1b57cf73b1a520545f9812bc30ed..5b440f0394cec24dd291fd232cad181db1f40bb5 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi.impl.source.codeStyle;
 
+import com.intellij.lang.Language;
 import com.intellij.openapi.editor.ex.EditorEx;
 import com.intellij.openapi.editor.highlighter.HighlighterIterator;
 import com.intellij.psi.tree.IElementType;
@@ -28,10 +29,12 @@ import org.jetbrains.annotations.Nullable;
 public abstract class SemanticEditorPosition {
   public interface SyntaxElement {}
   
+  private final EditorEx myEditor;
   private final HighlighterIterator myIterator;
   private final CharSequence myChars;
 
   public SemanticEditorPosition(@NotNull EditorEx editor, int offset) {
+    myEditor = editor;
     myChars = editor.getDocument().getCharsSequence();
     myIterator = editor.getHighlighter().createIterator(offset);
   }
@@ -88,6 +91,20 @@ public abstract class SemanticEditorPosition {
     }
     return this;
   }
+
+  public SemanticEditorPosition findLeftParenthesisBackwardsSkippingNested(@NotNull SyntaxElement leftParenthesis,
+                                                                            @NotNull SyntaxElement rightParenthesis) {
+    while (!myIterator.atEnd()) {
+      if (rightParenthesis.equals(map(myIterator.getTokenType()))) {
+        beforeParentheses(leftParenthesis, rightParenthesis);
+      }
+      else if (leftParenthesis.equals(map(myIterator.getTokenType()))) {
+        break; 
+      }
+      myIterator.retreat();
+    }
+    return this;
+  }
   
   public boolean isAfterOnSameLine(@NotNull SyntaxElement... syntaxElements) {
     myIterator.retreat();
@@ -137,6 +154,22 @@ public abstract class SemanticEditorPosition {
     return -1;
   }
 
+  public EditorEx getEditor() {
+    return myEditor;
+  }
+  
+  @Nullable
+  public Language getLanguage() {
+    return !myIterator.atEnd() ? myIterator.getTokenType().getLanguage() : null;
+  }
+  
+  public boolean isAtLanguage(@Nullable Language language) {
+    if (language != null && !myIterator.atEnd()) {
+      return language== Language.ANY || myIterator.getTokenType().getLanguage().is(language); 
+    }
+    return false;
+  }
+
   @Nullable
   public SyntaxElement getCurrElement() {
     return !myIterator.atEnd() ? map(myIterator.getTokenType()) : null;
index 5ecf62927ee4f2a9333559cfeceabea8bd1a1b2e..2f207a0c35b46e3c964bb65e840010eb80c46688 100644 (file)
@@ -54,7 +54,8 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
     ForKeyword,
     BlockComment,
     DocBlockStart,
-    DocBlockEnd
+    DocBlockEnd,
+    Comma
   }
   
   
@@ -79,7 +80,22 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
     if (getPosition(editor, offset).matchesRule(
       position -> position.isAt(Whitespace) &&
                   position.isAtMultiline())) {
-      if (getPosition(editor, offset).matchesRule(
+      //noinspection StatementWithEmptyBody
+      if (getPosition(editor, offset).before().isAt(Comma)) {
+        // TODO: Add support
+      }
+      else if (getPosition(editor, offset + 1).isAt(BlockClosingBrace)) {
+        return myFactory.createIndentCalculator(
+          NONE,
+          position -> {
+            position.findLeftParenthesisBackwardsSkippingNested(BlockOpeningBrace, BlockClosingBrace);
+            if (!position.isAtEnd()) {
+              return getBlockStatementStartOffset(position);
+            }
+            return -1;
+          });
+      }
+      else if (getPosition(editor, offset).matchesRule(
         position -> position
           .before()
           .beforeOptional(Semicolon)
@@ -95,8 +111,7 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
       else if (getPosition(editor, offset).matchesRule(
         position -> position.before().isAt(BlockOpeningBrace)
       )) {
-        return myFactory.createIndentCalculator(getIndentTypeInBlock(project, language),
-                                                JavaLikeLangLineIndentProvider::getBlockStartOffset);
+        return myFactory.createIndentCalculator(getIndentTypeInBlock(project, language), this::getBlockStatementStartOffset);
       }
       else if (getPosition(editor, offset).matchesRule(
         position -> position.before().isAt(Colon) && position.isAfterOnSameLine(SwitchCase, SwitchDefault)
@@ -138,7 +153,8 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
   }
 
 
-  private static int getBlockStartOffset(@NotNull SemanticEditorPosition position) {
+  private int getBlockStatementStartOffset(@NotNull SemanticEditorPosition position) {
+    Language currLanguage = position.getLanguage();
     position.before().beforeOptional(BlockOpeningBrace);
     if (position.isAt(Whitespace)) {
       if (position.isAtMultiline()) return position.after().getStartOffset();
@@ -148,8 +164,17 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
       position.beforeParentheses(LeftParenthesis, RightParenthesis);
     }
     while (!position.isAtEnd()) {
-      if (position.isAt(Whitespace) && position.isAtMultiline()) {
-        return position.after().getStartOffset();
+      if (currLanguage == Language.ANY || currLanguage == null) currLanguage = position.getLanguage();
+      if (position.isAt(Semicolon) ||
+          position.isAt(BlockOpeningBrace) ||
+          position.isAt(BlockClosingBrace) ||
+          ! ((position.getLanguage() != Language.ANY) && position.isAtLanguage(currLanguage))) {
+        SemanticEditorPosition statementStart = getPosition(position.getEditor(), position.getStartOffset());
+        if (statementStart.after().isAt(Whitespace) && statementStart.isAtMultiline()) {
+          if (!statementStart.after().isAtEnd()) {
+            return statementStart.getStartOffset();
+          }
+        }
       }
       position.before();
     }
index 83cf4baedf46808f174ae4868071b4c85f99c395..7832b40acfb3cb7d3b9a9ab07a013507ad1f4c4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -594,6 +594,10 @@ public class InjectedLanguageUtil {
     return LanguageUtil.isInjectableLanguage(language);
   }
 
+  public static boolean isHighlightInjectionBackground(@Nullable PsiLanguageInjectionHost host) {
+    return !(host instanceof InjectionBackgroundSuppressor);
+  }
+
   public static int getInjectedStart(@NotNull List<PsiLanguageInjectionHost.Shred> places) {
     PsiLanguageInjectionHost.Shred shred = places.get(0);
     PsiLanguageInjectionHost host = shred.getHost();
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionBackgroundSuppressor.java
new file mode 100644 (file)
index 0000000..a98d653
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.psi.impl.source.tree.injected;
+
+/**
+ * Marker interface that suppresses injection background.
+ *
+ * @author ignatov
+ */
+public interface InjectionBackgroundSuppressor {
+}
index ca3f72fc0dcedd02334258be34cf444e08d0de8c..6392d96d5b3734ff8411273c5b0030885118174a 100644 (file)
@@ -99,6 +99,7 @@ public class ExtractMethodHelper {
     try {
       return ProgressManager.getInstance().runProcessWithProgressSynchronously(
         (ThrowableComputable<List<SimpleMatch>, RuntimeException>)() -> {
+          ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
           return ReadAction.compute(() -> finder.findDuplicates(searchScopes, generatedMethod));
         }, RefactoringBundle.message("searching.for.duplicates"), true, project);
     }
index baf3b12715a598451f6031d2549175d67df500d8..ae4df40b7f02297679a27c3fe3ca876c666626be 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.notification.NotificationAction;
 import com.intellij.notification.NotificationType;
 import com.intellij.notification.impl.NotificationsManagerImpl;
 import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.Balloon;
 import com.intellij.openapi.util.Ref;
@@ -52,12 +53,11 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
 
   private IdeErrorsDialog myDialog;
   private boolean myOpeningInProgress;
+  private final IdeFrame myFrame;
   private final MessagePool myMessagePool;
   private boolean myNotificationPopupAlreadyShown = false;
 
-  private boolean myDisposed;
-
-  public IdeMessagePanel(@NotNull MessagePool messagePool) {
+  public IdeMessagePanel(@NotNull IdeFrame frame, @NotNull MessagePool messagePool) {
     super(new BorderLayout());
     myIdeFatal = new IdeFatalErrorsIcon(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
@@ -69,6 +69,8 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
 
     add(myIdeFatal, BorderLayout.CENTER);
 
+    myFrame = frame;
+
     myMessagePool = messagePool;
     messagePool.addListener(this);
 
@@ -87,7 +89,6 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
   }
 
   public void dispose() {
-    myDisposed = true;
     myMessagePool.removeListener(this);
   }
 
@@ -221,7 +222,7 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
       myNotificationPopupAlreadyShown = false;
     }
     else if (state == IdeFatalErrorsIcon.State.UnreadErrors && !myNotificationPopupAlreadyShown) {
-      SwingUtilities.invokeLater(() -> {
+      ApplicationManager.getApplication().invokeLater(() -> {
         String notificationText = tryGetFromMessages(myMessagePool.getFatalErrors(false, false));
         if (NotificationsManagerImpl.newEnabled()) {
           showErrorNotification(notificationText);
@@ -232,7 +233,7 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
         }
         final JLabel label = new JLabel(notificationText);
         label.setIcon(AllIcons.Ide.FatalError);
-        new NotificationPopup(IdeMessagePanel.this, label, LightColors.RED, false, new ActionListener() {
+        new NotificationPopup(this, label, LightColors.RED, false, new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             _openFatals(null);
           }
@@ -259,11 +260,7 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
       });
     }
 
-    Window window = SwingUtilities.getWindowAncestor(this);
-    assert window instanceof IdeFrame : "Show error for " + window + " window, dispose state:" + myDisposed;
-
-    IdeFrame frame = (IdeFrame)window;
-    BalloonLayout layout = frame.getBalloonLayout();
+    BalloonLayout layout = myFrame.getBalloonLayout();
     assert layout != null;
 
     BalloonLayoutData layoutData = new BalloonLayoutData();
@@ -273,10 +270,10 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Icon
     layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
     layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
 
-    Project project = frame.getProject();
+    Project project = myFrame.getProject();
     assert project != null;
 
-    Balloon balloon = NotificationsManagerImpl.createBalloon(frame, notification, false, false, new Ref<>(layoutData), project);
+    Balloon balloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
     layout.add(balloon);
 }
 
index f8fe765970b5f49511189e50c041460ba6123e2f..0bda535d9986d0ef5c5df5f88d287ef505b86c15 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.TransactionGuard;
+import com.intellij.openapi.application.ex.ApplicationEx;
 import com.intellij.openapi.application.ex.ApplicationManagerEx;
 import com.intellij.openapi.components.ApplicationComponent;
 import com.intellij.openapi.diagnostic.Logger;
@@ -129,22 +130,25 @@ public class MacOSApplicationProvider implements ApplicationComponent {
 
         @Override
         public void handlePreferences(ApplicationEvent applicationEvent) {
-          Project project = getProject();
-
-          if (project == null) {
-            project = ProjectManager.getInstance().getDefaultProject();
-          }
-
-          Project finalProject = project;
-          if (!((ShowSettingsUtilImpl)ShowSettingsUtil.getInstance()).isAlreadyShown()) {
-            TransactionGuard.submitTransaction(project, () -> ShowSettingsUtil.getInstance().showSettingsDialog(finalProject, ShowSettingsUtilImpl.getConfigurableGroups(finalProject, true)));
+          Project project = getNotNullProject();
+          ShowSettingsUtilImpl showSettingsUtil = (ShowSettingsUtilImpl)ShowSettingsUtil.getInstance();
+          if (!showSettingsUtil.isAlreadyShown()) {
+            TransactionGuard.submitTransaction(project, () ->
+              showSettingsUtil.showSettingsDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true)));
           }
           applicationEvent.setHandled(true);
         }
 
+        @NotNull
+        private Project getNotNullProject() {
+          Project project = getProject();
+          return project == null ? ProjectManager.getInstance().getDefaultProject() : project;
+        }
+
         @Override
         public void handleQuit(ApplicationEvent applicationEvent) {
-          ApplicationManagerEx.getApplicationEx().exit();
+          ApplicationEx app = ApplicationManagerEx.getApplicationEx();
+          TransactionGuard.submitTransaction(app, app::exit);
         }
 
         @Override
@@ -153,15 +157,17 @@ public class MacOSApplicationProvider implements ApplicationComponent {
           String filename = applicationEvent.getFilename();
           if (filename == null) return;
 
-          File file = new File(filename);
-          if (ProjectUtil.openOrImport(file.getAbsolutePath(), project, true) != null) {
-            IdeaApplication.getInstance().setPerformProjectLoad(false);
-            return;
-          }
-          if (project != null && file.exists()) {
-            OpenFileAction.openFile(filename, project);
-            applicationEvent.setHandled(true);
-          }
+          TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> {
+            File file = new File(filename);
+            if (ProjectUtil.openOrImport(file.getAbsolutePath(), project, true) != null) {
+              IdeaApplication.getInstance().setPerformProjectLoad(false);
+              return;
+            }
+            if (project != null && file.exists()) {
+              OpenFileAction.openFile(filename, project);
+              applicationEvent.setHandled(true);
+            }
+          });
         }
       });
 
index 22df477709eae2ff94c4368434dc5a079eb4c494..b50d4e3e0fc12fb62a0c29cc7ffe1946b0ffcd2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
  */
 package com.intellij.ide.ui.laf.darcula.ui;
 
+import com.intellij.util.ui.JBUI;
+
 import javax.swing.*;
 import javax.swing.border.Border;
-import javax.swing.plaf.InsetsUIResource;
 import javax.swing.plaf.UIResource;
 import java.awt.*;
 
@@ -39,7 +40,7 @@ public class DarculaMenuBarBorder implements Border, UIResource {
 
   @Override
   public Insets getBorderInsets(Component c) {
-    return new InsetsUIResource(0, 0, 2, 0);
+    return JBUI.insetsBottom(2).asUIResource();
   }
 
   @Override
index 9d4dc06c80d61177294e1627f2ed6d2166599d92..dbb8ba56388a88bfb41dfa257bc3e86e7e217ca6 100644 (file)
@@ -1,12 +1,40 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.intellij.ide.ui.laf.darcula.ui;
 
-import javax.swing.plaf.BorderUIResource;
+import com.intellij.util.ui.JBUI;
+
+import javax.swing.border.Border;
+import javax.swing.plaf.UIResource;
+import java.awt.*;
 
 /**
  * @author Konstantin Bulenkov
  */
-public class DarculaMenuItemBorder extends BorderUIResource.EmptyBorderUIResource {
-  public DarculaMenuItemBorder() {
-    super(2, 2, 2, 2);
+public class DarculaMenuItemBorder implements Border, UIResource {
+  @Override
+  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {}
+
+  @Override
+  public Insets getBorderInsets(Component c) {
+    return JBUI.insets(2).asUIResource();
+  }
+
+  @Override
+  public boolean isBorderOpaque() {
+    return false;
   }
 }
index 79ecdc35b4e48a047aebc69dd80b1cd35e33f56a..e1a9788d3029ca564f971d5f4cf49b9b4d0e5981 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
  */
 package com.intellij.ide.ui.laf.darcula.ui;
 
+import com.intellij.util.ui.JBUI;
+
 import javax.swing.*;
 import javax.swing.border.AbstractBorder;
-import javax.swing.plaf.InsetsUIResource;
 import javax.swing.plaf.UIResource;
 import java.awt.*;
 
@@ -33,6 +34,6 @@ public class DarculaPopupMenuBorder extends AbstractBorder implements UIResource
 
   @Override
   public Insets getBorderInsets(Component c) {
-    return new InsetsUIResource(1,1,1,1);
+    return JBUI.insets(1).asUIResource();
   }
 }
index 7f0f7d8e5c6d707e016b77da44ee526e63a7c143..6d8691e7d235ab073a3aa1cd1f7859cef39587d0 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.diagnostic.PerformanceWatcher;
 import com.intellij.diagnostic.ThreadDumper;
 import com.intellij.execution.CommandLineUtil;
 import com.intellij.ide.*;
-import com.intellij.ide.plugins.IdeaPluginDescriptor;
 import com.intellij.idea.IdeaApplication;
 import com.intellij.idea.Main;
 import com.intellij.idea.StartupUtil;
@@ -33,7 +32,6 @@ import com.intellij.openapi.actionSystem.ex.ActionUtil;
 import com.intellij.openapi.application.*;
 import com.intellij.openapi.application.ex.ApplicationEx;
 import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.components.ComponentConfig;
 import com.intellij.openapi.components.ServiceKt;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.components.impl.PlatformComponentManagerImpl;
@@ -489,6 +487,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
       //noinspection TestOnlyProblems
       LOG.info(writeActionStatistics());
       LOG.info(ActionUtil.ACTION_UPDATE_PAUSES.statistics());
+      //noinspection TestOnlyProblems
       LOG.info(((AppScheduledExecutorService)AppExecutorUtil.getAppScheduledExecutorService()).statistics());
     }
   }
@@ -498,12 +497,6 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
     return writePauses.statistics();
   }
 
-  @NotNull
-  @Override
-  public ComponentConfig[] getMyComponentConfigsFromDescriptor(@NotNull IdeaPluginDescriptor plugin) {
-    return plugin.getAppComponents();
-  }
-
   @Override
   public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process,
                                                      @NotNull String progressTitle,
index a91cd4b63b0f3af10105f72d4af1826ddb6afc42..4b20c39e25e1dc42e0ae31851d5614e626947ca5 100644 (file)
@@ -67,6 +67,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
    */
   private JComponent myToolbar;
   private IdeStatusBarImpl myStatusBar;
+  private boolean myStatusBarDisposed;
 
   private final Box myNorthPanel = Box.createVerticalBox();
   private final List<IdeRootPaneNorthExtension> myNorthComponents = new ArrayList<IdeRootPaneNorthExtension>();
@@ -156,6 +157,10 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
    */
   public final void removeNotify(){
     if (ScreenUtil.isStandardAddRemoveNotify(this)) {
+      if (!myStatusBarDisposed) {
+        myStatusBarDisposed = true;
+        Disposer.dispose(myStatusBar);
+      }
       removeToolbar();
     }
     super.removeNotify();
@@ -275,7 +280,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
     }
 
     myStatusBar.addWidget(myMemoryWidget);
-    myStatusBar.addWidget(new IdeMessagePanel(MessagePool.getInstance()), "before " + MemoryUsagePanel.WIDGET_ID);
+    myStatusBar.addWidget(new IdeMessagePanel(frame, MessagePool.getInstance()), "before " + MemoryUsagePanel.WIDGET_ID);
 
     setMemoryIndicatorVisible(UISettings.getInstance().SHOW_MEMORY_INDICATOR);
   }
index 621f286ee6de15abf2363d4002c61a722414e4b9..16668a45650bbbe20f248c1ee342290998ff0be1 100644 (file)
@@ -166,10 +166,6 @@ public class IdeStatusBarImpl extends JComponent implements Accessible, StatusBa
     setOpaque(true);
     updateUI();
 
-    if (master == null) {
-      Disposer.register(Disposer.get("ui"), this);
-    }
-
     if (master == null) {
       addWidget(new ToolWindowsWidget(this), Position.LEFT);
     }
index 1be13e6b0093d1f4393fd7ded8cc8a311a9bff0b..8ca103ce0a7b8f3210c26fd3c373c0aa71edbfbe 100644 (file)
@@ -531,26 +531,30 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
       final Container parent = getParent();
       if (parent instanceof JTable || parent instanceof CellRendererPane) return;
 
-      if (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
-        editor.setBorder(UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF() ?  new DarculaEditorTextFieldBorder() : new MacUIUtil.EditorTextFieldBorder(this));
-        editor.addFocusListener(new FocusChangeListener() {
-          @Override
-          public void focusGained(Editor editor) {
-            repaint();
-          }
-
-          @Override
-          public void focusLost(Editor editor) {
-            repaint();
-          }
-        });
-      }
-      else if (UIUtil.isUnderAlloyLookAndFeel() || UIUtil.isUnderJGoodiesLookAndFeel()) {
-        editor.setBorder(BorderFactory.createCompoundBorder(UIUtil.getTextFieldBorder(), BorderFactory.createEmptyBorder(1, 1, 1, 1)));
-      }
-      else {
-        editor.setBorder(BorderFactory.createCompoundBorder(UIUtil.getTextFieldBorder(), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
-      }
+      setupBorder(editor);
+    }
+  }
+
+  protected void setupBorder(@NotNull EditorEx editor) {
+    if (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
+      editor.setBorder(UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF() ? new DarculaEditorTextFieldBorder() : new MacUIUtil.EditorTextFieldBorder(this));
+      editor.addFocusListener(new FocusChangeListener() {
+        @Override
+        public void focusGained(Editor editor) {
+          repaint();
+        }
+
+        @Override
+        public void focusLost(Editor editor) {
+          repaint();
+        }
+      });
+    }
+    else if (UIUtil.isUnderAlloyLookAndFeel() || UIUtil.isUnderJGoodiesLookAndFeel()) {
+      editor.setBorder(BorderFactory.createCompoundBorder(UIUtil.getTextFieldBorder(), BorderFactory.createEmptyBorder(1, 1, 1, 1)));
+    }
+    else {
+      editor.setBorder(BorderFactory.createCompoundBorder(UIUtil.getTextFieldBorder(), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
     }
   }
 
index 3a8861789b775a15c86c2f419d792809e22af0b3..78f1d0772b6ee797d255681b459c767c6afacb67 100644 (file)
@@ -58,15 +58,15 @@ public class MacGestureSupportForEditor {
                                                             0);
               action.beforeActionPerformedUpdate(actionEvent);
 
-              //if (presentation.isEnabled()) {
-              actionManager.fireBeforeActionPerformed(action, dataContext, actionEvent);
-              final Component context = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
+              if (presentation.isEnabled()) {
+                actionManager.fireBeforeActionPerformed(action, dataContext, actionEvent);
+                final Component context = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
 
-              //  if (context != null && !context.isShowing()) continue;
+                if (context != null && !context.isShowing()) continue;
 
-              action.actionPerformed(actionEvent);
+                action.actionPerformed(actionEvent);
 
-              // }
+              }
             }
           }
           e.consume();
index aaa4ae68e4e527f394e8dc72b570ba55f6b50664..610384e4c55380207d3f2c861bd704bde35f42cf 100644 (file)
@@ -38,7 +38,7 @@ public class IdeEventQueueTest extends PlatformTestCase {
       }
       UIUtil.dispatchAllInvocationEvents();
       assertEquals(N, count.get());
-    }).assertTiming();
+    }).cpuBound().assertTiming();
   }
 
   public void testKeyboardEventsAreDetected() throws InterruptedException {
index c99fe769a89b9cf9a7ec6b4785de3edd9e30a093..63783c86ddf564532a3c35ce9ff4c97eeb83b981 100644 (file)
@@ -72,6 +72,6 @@ public class LowLevelSearchUtilTest extends TestCase {
         assertTrue(success);
         assertEquals(startOffset+","+endOffset, 1, found.size());
       }
-    }).assertTiming();
+    }).cpuBound().assertTiming();
   }
 }
index ef279c6cbd3b9299b29b9d2a7a212d8736a351ed..72d48a1c14606e6970d558f7677a6f27c62cc806 100644 (file)
@@ -441,7 +441,15 @@ public class SMTestProxy extends AbstractTestProxy {
 
   public void setTestFailed(@NotNull String localizedMessage, @Nullable String stackTrace, boolean testError) {
     setStacktraceIfNotSet(stackTrace);
-    if (myState instanceof TestFailedState) {
+    if (myState instanceof TestComparisionFailedState) {
+      CompoundTestFailedState states = new CompoundTestFailedState(localizedMessage, stackTrace);
+      states.addFailure((TestFailedState)myState);
+      final TestFailedState failedState = new TestFailedState(localizedMessage, stackTrace);
+      states.addFailure(failedState);
+      fireOnNewPrintable(failedState);
+      myState = states;
+    }
+    else if (myState instanceof TestFailedState) {
       ((TestFailedState)myState).addError(localizedMessage, stackTrace, myPrinter);
     }
     else {
@@ -473,14 +481,14 @@ public class SMTestProxy extends AbstractTestProxy {
                                       @Nullable final String actualFilePath) {
     setStacktraceIfNotSet(stackTrace);
     final TestComparisionFailedState comparisionFailedState = new TestComparisionFailedState(localizedMessage, stackTrace, actualText, expectedText, expectedFilePath, actualFilePath);
-    if (myState instanceof TestComparisionFailedState) {
-      final TestComparisonFailedStates states = new TestComparisonFailedStates(localizedMessage, stackTrace);
-      states.addComparisonFailure((TestComparisionFailedState)myState);
-      states.addComparisonFailure(comparisionFailedState);
-      myState = states;
+    if (myState instanceof CompoundTestFailedState) {
+      ((CompoundTestFailedState)myState).addFailure(comparisionFailedState);
     }
-    else if (myState instanceof TestComparisonFailedStates) {
-      ((TestComparisonFailedStates)myState).addComparisonFailure(comparisionFailedState);
+    else if (myState instanceof TestFailedState) {
+      final CompoundTestFailedState states = new CompoundTestFailedState(localizedMessage, stackTrace);
+      states.addFailure((TestFailedState)myState);
+      states.addFailure(comparisionFailedState);
+      myState = states;
     }
     else {
       myState = comparisionFailedState;
@@ -648,8 +656,8 @@ public class SMTestProxy extends AbstractTestProxy {
       return ((TestComparisionFailedState)myState).getHyperlink();
     }
 
-    if (myState instanceof TestComparisonFailedStates) {
-      return ((TestComparisonFailedStates)myState).getHyperlinks().get(0);
+    if (myState instanceof CompoundTestFailedState) {
+      return ((CompoundTestFailedState)myState).getHyperlinks().get(0);
     }
 
     if (myChildren != null) {
@@ -667,8 +675,8 @@ public class SMTestProxy extends AbstractTestProxy {
   @NotNull
   @Override
   public List<DiffHyperlink> getDiffViewerProviders() {
-    if (myState instanceof TestComparisonFailedStates) {
-      return ((TestComparisonFailedStates)myState).getHyperlinks();
+    if (myState instanceof CompoundTestFailedState) {
+      return ((CompoundTestFailedState)myState).getHyperlinks();
     }
     return super.getDiffViewerProviders();
   }
similarity index 69%
rename from platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisonFailedStates.java
rename to platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/CompoundTestFailedState.java
index d94c64cccedfb4463f52ab983f8e510c459486b3..f7153352e3203173b217d6c155dd3b45fe05e256 100644 (file)
@@ -26,28 +26,29 @@ import org.jetbrains.annotations.Nullable;
 import java.util.ArrayList;
 import java.util.List;
 
-public class TestComparisonFailedStates extends TestFailedState {
+public class CompoundTestFailedState extends TestFailedState {
   
-  final List<TestComparisionFailedState> myStates = new ArrayList<TestComparisionFailedState>();
+  final List<TestFailedState> myStates = new ArrayList<TestFailedState>();
 
-  public TestComparisonFailedStates(@Nullable String localizedMessage, @Nullable String stackTrace) {
+  public CompoundTestFailedState(@Nullable String localizedMessage, @Nullable String stackTrace) {
     super(localizedMessage, stackTrace);
   }
 
-  public void addComparisonFailure(TestComparisionFailedState state) {
+  public void addFailure(TestFailedState state) {
     myStates.add(state);
   }
 
   @Override
   public void printOn(Printer printer) {
  
-    for (TestComparisionFailedState state : myStates) {
+    for (TestFailedState state : myStates) {
       state.printOn(printer);
     }
   }
 
   @NotNull
   public List<DiffHyperlink> getHyperlinks() {
-    return ContainerUtil.map(myStates, state -> state.getHyperlink());
+    return ContainerUtil.map(ContainerUtil.filter(myStates, state -> state instanceof TestComparisionFailedState),
+                             state -> ((TestComparisionFailedState)state).getHyperlink());
   }
 }
index bf4754a4970a9f7223e504bb58d8a31ddbea1c97..7b30bf33436ba0dbc2bdab130cc6bf2437445d47 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.execution.testframework.sm.runner.states;
 import com.intellij.execution.process.ProcessOutputTypes;
 import com.intellij.execution.testframework.CompositePrintable;
 import com.intellij.execution.testframework.Printer;
-import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
 import com.intellij.execution.testframework.stacktrace.DiffHyperlink;
 import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.openapi.util.text.StringUtil;
@@ -68,14 +67,14 @@ public class TestComparisionFailedState extends TestFailedState {
     printer.mark();
 
     // Error msg
-    TestsPresentationUtil.printWithAnsiColoring(printer, myErrorMsgPresentation, ProcessOutputTypes.STDERR);
+    printer.printWithAnsiColoring(myErrorMsgPresentation, ProcessOutputTypes.STDERR);
 
     // Diff link
     myHyperlink.printOn(printer);
 
     // Stacktrace
     printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
-    TestsPresentationUtil.printWithAnsiColoring(printer, myStacktracePresentation, ProcessOutputTypes.STDERR);
+    printer.printWithAnsiColoring(myStacktracePresentation, ProcessOutputTypes.STDERR);
     printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
   }
 
index 16e703c72d46cbde15757de226a3f6644dcf702c..a8ba9a6d884cccc2d187ffa1832ac78c243221fb 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.execution.testframework.sm.runner.states;
 import com.intellij.execution.process.ProcessOutputTypes;
 import com.intellij.execution.testframework.CompositePrintable;
 import com.intellij.execution.testframework.Printer;
-import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
 import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.util.containers.ContainerUtil;
@@ -79,7 +78,7 @@ public class TestFailedState extends AbstractState {
           printer.mark();
           addMark = false;
         }
-        TestsPresentationUtil.printWithAnsiColoring(printer, errorText, ProcessOutputTypes.STDERR);
+        printer.printWithAnsiColoring(errorText, ProcessOutputTypes.STDERR);
       }
     }
   }
index b5779548acf3c8bef606c932ea30ac37d2795ecf..b1dab502cdb4aea910f41e73d87c690d33aa13e0 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
 import com.intellij.execution.TestStateStorage;
 import com.intellij.execution.configurations.RunConfiguration;
 import com.intellij.execution.configurations.RunProfile;
-import com.intellij.execution.process.ProcessHandler;
 import com.intellij.execution.testframework.*;
 import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
 import com.intellij.execution.testframework.export.TestResultsXmlFormatter;
@@ -46,7 +45,6 @@ import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Pass;
 import com.intellij.openapi.util.io.FileUtilRt;
-import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.pom.Navigatable;
@@ -70,8 +68,6 @@ import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 import java.awt.*;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
 import java.io.File;
 import java.io.FileWriter;
 import java.text.SimpleDateFormat;
@@ -801,11 +797,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
         for (SMTestProxy proxy : tests) {
           String url = proxy instanceof SMTestProxy.SMRootTestProxy ? ((SMTestProxy.SMRootTestProxy)proxy).getRootLocation() : proxy.getLocationUrl();
           if (url != null) {
-            ProcessHandler handler = myRoot.getHandler();
-            String configurationName = null;
-            if (handler != null) {
-              configurationName = handler.getUserData(TestStateStorage.RUN_CONFIGURATION_NAME_KEY);    
-            }
+            String configurationName = myConfiguration != null ? myConfiguration.getName() : null;
             storage.writeState(url, new TestStateStorage.Record(proxy.getMagnitude(), new Date(), 
                                                                 configurationName == null ? 0 : configurationName.hashCode()));
           }
index c64e6fae9ef30c5e573e75eeef36f58cd6b4783e..46f03703154dcabe1806421cd1c533b602f88e2b 100644 (file)
@@ -472,18 +472,4 @@ public class TestsPresentationUtil {
         break;
     }
   }
-
-  public static void printWithAnsiColoring(@NotNull final Printer printer, @NotNull String text, @NotNull final Key processOutputType) {
-    AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
-    decoder.escapeText(text, ProcessOutputTypes.STDOUT, new AnsiEscapeDecoder.ColoredTextAcceptor() {
-      @Override
-      public void coloredTextAvailable(String text, Key attributes) {
-        ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(attributes);
-        if (contentType == null || contentType == ConsoleViewContentType.NORMAL_OUTPUT) {
-          contentType = ConsoleViewContentType.getConsoleViewType(processOutputType);
-        }
-        printer.print(text, contentType);
-      }
-    });
-  }
 }
index fc0760797667915d4f502ccd9505f715092a9f96..9bf62c47e999928371ae1c5abf3256cece9cd110 100644 (file)
@@ -356,7 +356,7 @@ public class CompositePrintable implements Printable, Disposable {
               for (ConsoleViewContentType contentType : ConsoleViewContentType.OUTPUT_TYPES) {
                 final String prefix = contentType.toString();
                 if (line.startsWith(prefix)) {
-                  printer.print(line.substring(prefix.length()), contentType);
+                  printer.printWithAnsiColoring(line.substring(prefix.length()), contentType);
                   myLastSelected = contentType;
                   printed = true;
                   break;
@@ -368,7 +368,7 @@ public class CompositePrintable implements Printable, Disposable {
                     .printOn(printer);
                 }
                 else {
-                  printer.print(line, myLastSelected != null ? myLastSelected : ConsoleViewContentType.NORMAL_OUTPUT);
+                  printer.printWithAnsiColoring(line, myLastSelected != null ? myLastSelected : ConsoleViewContentType.NORMAL_OUTPUT);
                 }
               }
               lineNum++;
index e147c63e3280ea43044b219dc1b9eb42a23e5ca7..84810739f1272ee52451b62683484e0f3f049084 100644 (file)
 package com.intellij.execution.testframework;
 
 import com.intellij.execution.filters.HyperlinkInfo;
+import com.intellij.execution.process.AnsiEscapeDecoder;
+import com.intellij.execution.process.ProcessOutputTypes;
 import com.intellij.execution.ui.ConsoleViewContentType;
+import com.intellij.openapi.util.Key;
 import org.jetbrains.annotations.NotNull;
 
 public interface Printer {
@@ -24,4 +27,32 @@ public interface Printer {
   void onNewAvailable(@NotNull Printable printable);
   void printHyperlink(String text, HyperlinkInfo info);
   void mark();
+
+  default void printWithAnsiColoring(@NotNull String text, @NotNull Key processOutputType) {
+    AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+    decoder.escapeText(text, ProcessOutputTypes.STDOUT, new AnsiEscapeDecoder.ColoredTextAcceptor() {
+      @Override
+      public void coloredTextAvailable(String text, Key attributes) {
+        ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(attributes);
+        if (contentType == null || contentType == ConsoleViewContentType.NORMAL_OUTPUT) {
+          contentType = ConsoleViewContentType.getConsoleViewType(processOutputType);
+        }
+        print(text, contentType);
+      }
+    });
+  }
+
+  default void printWithAnsiColoring(@NotNull String text, @NotNull ConsoleViewContentType contentType) {
+    AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+    decoder.escapeText(text, ProcessOutputTypes.STDOUT, new AnsiEscapeDecoder.ColoredTextAcceptor() {
+      @Override
+      public void coloredTextAvailable(String text, Key attributes) {
+        ConsoleViewContentType viewContentType = ConsoleViewContentType.getConsoleViewType(attributes);
+        if (viewContentType == null) {
+          viewContentType = contentType;
+        }
+        print(text, viewContentType);
+      }
+    });
+  }
 }
index b4e29cb0b2a5b59c8bebaa8a922a0803b7dd44fb..d4c9046f575523a4a00e4ae5b99a3bd69bd7dfc2 100644 (file)
@@ -22,17 +22,13 @@ import com.intellij.execution.configurations.RunConfiguration;
 import com.intellij.execution.filters.*;
 import com.intellij.execution.filters.Filter;
 import com.intellij.execution.impl.ConsoleBuffer;
-import com.intellij.execution.impl.RunManagerImpl;
-import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
 import com.intellij.execution.testframework.*;
 import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.openapi.application.ApplicationNamesInfo;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
 import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Ref;
-import com.intellij.openapi.util.UserDataHolder;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.util.text.StringUtil;
 import org.jdom.Attribute;
index 6e8441d0312a32771d6140e575c27938c1b78268..5db2d43b5ce0756713ba979f286bf9924c6347b3 100644 (file)
@@ -78,7 +78,7 @@ public class Restarter {
     if (beforeRestart.length == 0) return;
 
     File restartDir = new File(getRestarterDir());
-    String systemPath = System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/system/restart";
+    String systemPath = (System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/system/restart").replace("//", "/");
     if (! systemPath.equals(restartDir.getPath())){
       throw new IOException("idea.system.path was changed. Restart is not supported.");
     }
index 7c069524f83ee5ae875018d3cc1d66a4bd1f15b6..97c795786528d34779f02156fc766a71686ebc1c 100644 (file)
@@ -17,6 +17,8 @@ package git4idea.reset;
 
 import com.intellij.dvcs.DvcsUtil;
 import com.intellij.openapi.application.AccessToken;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.progress.ProgressIndicator;
@@ -31,7 +33,6 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.MultiMap;
-import com.intellij.util.ui.UIUtil;
 import com.intellij.vcs.log.VcsFullCommitDetails;
 import git4idea.GitUtil;
 import git4idea.branch.GitBranchUiHandlerImpl;
@@ -183,12 +184,8 @@ public class GitResetOperation {
   }
 
   private static void saveAllDocuments() {
-    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
-      @Override
-      public void run() {
-        FileDocumentManager.getInstance().saveAllDocuments();
-      }
-    });
+    ApplicationManager.getApplication().invokeAndWait(() -> FileDocumentManager.getInstance().saveAllDocuments(),
+                                                      ModalityState.defaultModalityState());
   }
 
 }
index fd630b9a5a5bb0e11c4c7376a36e7f480de22e19..7c87fb9758ad786b2069e75e8f98e7db0d4bd4d5 100644 (file)
@@ -16,9 +16,7 @@
 package org.jetbrains.plugins.javaFX.fxml.refs;
 
 import com.intellij.openapi.util.TextRange;
-import com.intellij.patterns.PlatformPatterns;
-import com.intellij.patterns.XmlAttributeValuePattern;
-import com.intellij.patterns.XmlPatterns;
+import com.intellij.patterns.*;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider;
 import com.intellij.psi.xml.XmlAttribute;
@@ -90,7 +88,9 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
                                           .and(attributeValueInFxml),
                                         new JavaFxEventHandlerReferenceProvider());
 
-    registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("@")).and(attributeValueInFxml),
+    registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("@"))
+                                          .withParent(StandardPatterns.not(XmlPatterns.xmlAttribute().withName(FxmlConstants.STYLESHEETS)))
+                                          .and(attributeValueInFxml),
                                         new JavaFxLocationReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
 
     registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("$"))
@@ -124,7 +124,7 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
                                           .withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_VALUE)
                                                         .withParent(XmlPatterns.xmlTag().withParent(XmlPatterns.xmlTag().withName(FxmlConstants.STYLESHEETS))))
                                           .and(attributeValueInFxml),
-                                        new JavaFxLocationReferenceProvider(true, "css"));
+                                        new JavaFxLocationReferenceProvider(false, "css"));
 
     registrar.registerReferenceProvider(XmlPatterns.xmlAttribute().withLocalName(string().contains("."))
                                           .inVirtualFile(virtualFile().withExtension(JavaFxFileTypeFactory.FXML_EXTENSION)),
index c7b8bbcbb462834fea39795e143d21341eccf3b3..267e2a6df22f9e4ca70ad7367553735e9c66be30 100644 (file)
@@ -23,32 +23,30 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
 import com.intellij.psi.xml.XmlAttributeValue;
-import com.intellij.util.ArrayUtilRt;
 import com.intellij.util.ProcessingContext;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 
 /**
  * User: anna
  */
 class JavaFxLocationReferenceProvider extends PsiReferenceProvider {
   private boolean mySupportCommaInValue = false;
-  private final FileType[] myAcceptedFileTypes;
+  private final Set<FileType> myAcceptedFileTypes;
 
   JavaFxLocationReferenceProvider() {
     this(false);
   }
 
-  JavaFxLocationReferenceProvider(boolean supportCommaInValue, String... acceptedFileTypes) {
+  JavaFxLocationReferenceProvider(boolean supportCommaInValue, String... acceptedFileExtensions) {
     mySupportCommaInValue = supportCommaInValue;
-    myAcceptedFileTypes = new FileType[acceptedFileTypes.length];
     final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
-    for (int i = 0; i < acceptedFileTypes.length; i++) {
-      myAcceptedFileTypes[i] = fileTypeManager.getFileTypeByExtension(acceptedFileTypes[i]);
-    }
+    myAcceptedFileTypes = ContainerUtil.map2Set(acceptedFileExtensions, fileTypeManager::getFileTypeByExtension);
   }
 
   @NotNull
@@ -89,7 +87,7 @@ class JavaFxLocationReferenceProvider extends PsiReferenceProvider {
           final VirtualFile virtualFile = item.getVirtualFile();
           if (virtualFile == null) return false;
           final FileType fileType = virtualFile.getFileType();
-          return ArrayUtilRt.find(myAcceptedFileTypes, fileType) >= 0;
+          return myAcceptedFileTypes.contains(fileType);
         };
       }
     };
index 95d6d09ae84d4c907b66b3868f06ac13f68a93a1..42a7425c23069499cfa657d3786aab31e32a59bb 100644 (file)
@@ -11,11 +11,6 @@ import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
 public abstract class JavaFxPropertyReference<T extends PsiElement> extends PsiReferenceBase<T> {
   protected final PsiClass myPsiClass;
 
-  public JavaFxPropertyReference(@NotNull T element, PsiClass aClass, boolean soft) {
-    super(element, soft);
-    myPsiClass = aClass;
-  }
-
   public JavaFxPropertyReference(@NotNull T element, PsiClass aClass) {
     super(element);
     myPsiClass = aClass;
index 63f420bf8d014ee9b69f5a9f89735fe83e2dac60..862013be0ea5abe473ed6035bd8baa113287883e 100644 (file)
@@ -46,7 +46,6 @@ import gnu.trove.THashMap;
 import gnu.trove.THashSet;
 import javafx.application.Platform;
 import javafx.beans.value.ChangeListener;
-import javafx.beans.value.ObservableValue;
 import javafx.embed.swing.JFXPanel;
 import javafx.fxml.FXMLLoader;
 import javafx.geometry.Orientation;
@@ -105,14 +104,14 @@ public class SceneBuilderImpl implements SceneBuilder {
     if (myProject.isDisposed()) {
       return;
     }
-    FXMLLoader.setDefaultClassLoader(SceneBuilderImpl.class.getClassLoader());
 
     final Collection<CustomComponent> customComponents = DumbService.getInstance(myProject)
       .runReadActionInSmartMode(this::collectCustomComponents);
+    myClassLoader = createProjectContentClassLoader(myProject);
+    FXMLLoader.setDefaultClassLoader(myClassLoader);
 
     myEditorController = new EditorController();
     if (!customComponents.isEmpty()) {
-      myClassLoader = createCustomComponentClassLoader(myProject);
       myEditorController.setLibrary(new CustomLibrary(myClassLoader, customComponents));
     }
     HierarchyTreeViewController componentTree = new HierarchyTreeViewController(myEditorController);
@@ -260,7 +259,7 @@ public class SceneBuilderImpl implements SceneBuilder {
   }
 
   @NotNull
-  private static URLClassLoader createCustomComponentClassLoader(Project project) {
+  private static URLClassLoader createProjectContentClassLoader(Project project) {
     final List<String> pathList = ApplicationManager.getApplication().runReadAction((Computable<List<String>>)() ->
       OrderEnumerator.orderEntries(project).productionOnly().withoutSdk().recursively().getPathsList().getPathList());
 
@@ -319,6 +318,7 @@ public class SceneBuilderImpl implements SceneBuilder {
     }
     try {
       if (myClassLoader != null) {
+        FXMLLoader.setDefaultClassLoader(SceneBuilderImpl.class.getClassLoader());
         myClassLoader.close();
         myClassLoader = null;
       }
index d288aa4cb6ebe7bd0f7232a92bd2379643811f0c..aa3aa51e2a214e2878c905c1d44843dbbbd31951 100644 (file)
@@ -34,6 +34,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
   @Test
   public void testEmptySuite() throws Exception {
     doTest(Description.createSuiteDescription("empty suite"), "##teamcity[enteredTheMatrix]\n" +
+                                                              "##teamcity[suiteTreeNode name='empty suite' locationHint='java:test://empty suite.empty suite']\n" +
                                                               "##teamcity[treeEnded]\n");
   }
 
@@ -569,6 +570,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
     final Description rootDescription = Description.createTestDescription("TestA", "testName");
     doTest(rootDescription, Collections.singletonList(rootDescription),
            "##teamcity[enteredTheMatrix]\n" +
+           "##teamcity[suiteTreeNode name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
            "##teamcity[treeEnded]\n",
            "##teamcity[rootName name = 'TestA' location = 'java:suite://TestA']\n" +
            "\n" +
index d5fdf6247d2a15f1e6db192940d5bb651c61ba12..0f668d99287d845573b4f39abe660bbd372a3707 100644 (file)
@@ -464,9 +464,8 @@ public class JUnit4TestListener extends RunListener {
     String className = JUnit4ReflectionUtil.getClassName(description);
     if (description.isTest()) {
       final String methodName = getFullMethodName((Description)description, parent);
-      if (methodName != null && parent != null) {
-
-        if (isWarning(methodName, className)) {
+      if (methodName != null ) {
+        if (isWarning(methodName, className) && parent != null) {
           className = JUnit4ReflectionUtil.getClassName(parent);
         }
         myPrintStream.println("##teamcity[suiteTreeNode name=\'" + escapeName(methodName) + "\' " + getTestMethodLocation(methodName, className) + "]");
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java
new file mode 100644 (file)
index 0000000..61630b3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.maven.utils.library;
+
+import com.intellij.openapi.extensions.AbstractExtensionPointBean;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.util.xmlb.annotations.Attribute;
+import com.intellij.util.xmlb.annotations.Tag;
+
+public class RepositoryLibraryBean extends AbstractExtensionPointBean {
+  protected static final ExtensionPointName<RepositoryLibraryBean> EP_NAME
+    = ExtensionPointName.create("org.jetbrains.idea.maven.mavenCoordinates");
+
+  @Attribute("name")
+  public String name;
+
+  @Tag("groupId")
+  public String groupId;
+
+  @Tag("artifactId")
+  public String artifactId;
+}
index 72a6395755541f88b139023bf56ee1193f37e1ae..5d3fcfcfebe9bf47148254410bc647dace0bcad5 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.jetbrains.idea.maven.utils.library;
 
-import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.roots.DependencyScope;
 import com.intellij.util.containers.HashMap;
 import icons.MavenIcons;
@@ -29,8 +28,6 @@ import java.util.List;
 import java.util.Map;
 
 public class RepositoryLibraryDescription {
-  protected static final ExtensionPointName<RepositoryLibraryDescription> EP_NAME
-    = ExtensionPointName.create("org.jetbrains.idea.maven.repositoryLibrary");
   protected static final MavenRepositoryInfo mavenCentralRepository = new MavenRepositoryInfo(
     "central",
     "Maven Central repository",
@@ -52,20 +49,16 @@ public class RepositoryLibraryDescription {
     this.libraryName = libraryName;
   }
 
-  public static <C extends RepositoryLibraryDescription> C ofClass(Class<C> clazz) {
-    return EP_NAME.findExtension(clazz);
-  }
-
   @NotNull
   public static synchronized RepositoryLibraryDescription findDescription(@NotNull final String groupId, @NotNull final String artifactId) {
     if (registeredLibraries == null) {
       registeredLibraries = new HashMap<String, RepositoryLibraryDescription>();
-      for (RepositoryLibraryDescription description : EP_NAME.getExtensions()) {
-        String id = description.getGroupId() + ":" + description.getArtifactId();
-        RepositoryLibraryDescription existDescription = registeredLibraries.get(id);
-        if (existDescription == null || existDescription.getWeight() >= description.getWeight()) {
-          registeredLibraries.put(id, description);
-        }
+      for (RepositoryLibraryBean bean : RepositoryLibraryBean.EP_NAME.getExtensions()) {
+        String id = bean.groupId + ":" + bean.artifactId;
+        registeredLibraries.put(id, new RepositoryLibraryDescription(
+          bean.groupId,
+          bean.artifactId,
+          bean.name));
       }
     }
     final String id = groupId + ":" + artifactId;
index 15e0a5ce57035ed1d1a38c67cea5d210de09774d..1390b0efbad7560c875e035298f7416b481ed69c 100644 (file)
@@ -28,7 +28,7 @@
     <extensionPoint name="pluginDescriptor" beanClass="org.jetbrains.idea.maven.plugins.api.MavenPluginDescriptor" />
 
     <extensionPoint name="repositoryProvider" interface="org.jetbrains.idea.maven.indices.MavenRepositoryProvider"/>
-    <extensionPoint name="repositoryLibrary" interface="org.jetbrains.idea.maven.utils.library.RepositoryLibraryDescription"/>
+    <extensionPoint name="mavenCoordinates" beanClass="org.jetbrains.idea.maven.utils.library.RepositoryLibraryBean"/>
   </extensionPoints>
 
   <depends>com.intellij.properties</depends>
index 918439ebb4b9f19a90b85bbebcc856104960aac5..57e3673ee31217c231c6fc4833ccf56ffc970a6d 100644 (file)
@@ -36,14 +36,14 @@ public abstract class LibraryContributingFacet<T extends FacetConfiguration> ext
     connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {
       @Override
       public void beforeFacetRemoved(@NotNull Facet facet) {
-        if (facet instanceof LibraryContributingFacet) {
+        if (facet == LibraryContributingFacet.this) {
           ((LibraryContributingFacet) facet).removeLibrary();
         }
       }
 
       @Override
       public void facetConfigurationChanged(@NotNull Facet facet) {
-        if (facet instanceof LibraryContributingFacet) {
+        if (facet == LibraryContributingFacet.this) {
           ((LibraryContributingFacet) facet).updateLibrary();
         }
       }
index c4bb228000616324da9d69f95ea9dc39beb59844..98e4dea498901613471db38f12e45684c2be015a 100644 (file)
     <projectService serviceInterface="com.intellij.codeInsight.NullableNotNullManager"
                     serviceImplementation="com.intellij.codeInsight.NullableNotNullManagerImpl"/>
 
+    <lang.psiTypeAnnotationModifier implementation="com.intellij.codeInsight.NullityAnnotationModifier"/>
+
     <projectService serviceInterface="com.intellij.codeInsight.ConcurrencyAnnotationsManager"
                     serviceImplementation="com.intellij.codeInsight.ConcurrencyAnnotationsManager"/>
 
index 609d42bf3e4b5bd78f9fa95c317003e07a2da402..e39461807944dc594651a72dac63deb8684e27fa 100644 (file)
@@ -212,6 +212,7 @@ hamcrest
 hardcoded
 hardlink
 hardlinks
+hashbang
 hashcode
 hateoas
 haxe