Merge remote-tracking branch 'origin/master' clion/144.2988 pycharm/144.2992
authorAlexey Utkin <alexey.utkin@jetbrains.com>
Wed, 13 Jan 2016 06:47:46 +0000 (09:47 +0300)
committerAlexey Utkin <alexey.utkin@jetbrains.com>
Wed, 13 Jan 2016 06:47:46 +0000 (09:47 +0300)
72 files changed:
.idea/modules.xml
build/scripts/layouts.gant
community-main.iml
java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java
java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java
java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/ExpandStaticImportAction.java
java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/afterAnonymousClass.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/afterPassArgs.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforeAnonymousClass.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforeAnonymousClassWithMultipleReturns.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforePassArgs.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveMembers/mixedStaticImportAndQualified/after/ImportingClass.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveMembers/mixedStaticImportAndQualified/before/ImportingClass.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
platform/built-in-server/client/node-rpc-client/package.json
platform/built-in-server/client/node-rpc-client/src/rpc.ts
platform/built-in-server/src/org/jetbrains/io/jsonRpc/JsonRpcServer.kt
platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java
platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
platform/lang-impl/src/com/intellij/execution/RunContentExecutor.java
platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopupAction.java
platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationsComboBoxAction.java
platform/lang-impl/src/com/intellij/execution/impl/ExecutionManagerImpl.java
platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java
platform/lang-impl/src/com/intellij/execution/ui/layout/actions/RestoreViewAction.java
platform/platform-api/src/com/intellij/openapi/options/SchemeImportException.java
platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java
platform/platform-api/src/com/intellij/ui/components/JBViewport.java
platform/platform-impl/src/com/intellij/ide/actions/AboutAction.java
platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java
platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeMouseEventDispatcher.java
platform/platform-tests/testData/editor/painting/foldedRegionShownOnlyWithBorder.png [new file with mode: 0644]
platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java
platform/script-debugger/backend/script-debugger-backend.iml
platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java [deleted file]
platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java
platform/testFramework/src/com/intellij/idea/Bombed.java
platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java
platform/util/resources/misc/registry.properties
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/MuteBreakpointAction.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/PauseAction.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/StepOverAction.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/XDebuggerActionBase.java
plugins/InspectionGadgets/src/com/intellij/codeInspection/TrivialFunctionalExpressionUsageInspection.java
plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java
plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java
plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java
plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarContentTest.java
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/YAMLMappingModificationTest.java
python/helpers/pycharm/behave_runner.py
python/src/com/jetbrains/python/codeInsight/testIntegration/CreateTestAction.java
python/src/com/jetbrains/python/codeInsight/testIntegration/PyTestCreator.java
python/src/com/jetbrains/python/psi/PyUtil.java
python/testData/create_tests/create_tst.expected.py [new file with mode: 0644]
python/testData/create_tests/create_tst.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/codeInsight/testIntegration/PyTestCreatorTest.java [new file with mode: 0644]
resources-en/src/inspectionDescriptions/FieldAccessNotGuarded.html
resources-en/src/inspectionDescriptions/InstanceGuardedByStatic.html
resources-en/src/inspectionDescriptions/NonFinalFieldInImmutable.html
resources-en/src/inspectionDescriptions/NonFinalGuard.html
resources-en/src/inspectionDescriptions/StaticGuardedByInstance.html
resources-en/src/inspectionDescriptions/UnknownGuard.html

index 44693dcf252df6fd6b6674b8ddfc082391e7c866..e9f02784d19ce757e5eaa9c1d862eef0d36fa1fc 100644 (file)
       <module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/xslt-debugger-engine.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/xslt-debugger-engine.iml" group="plugins" />
       <module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" group="plugins" />
       <module fileurl="file://$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" filepath="$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" group="plugins" />
+      <module fileurl="file://$PROJECT_DIR$/plugins/yaml/yaml.iml" filepath="$PROJECT_DIR$/plugins/yaml/yaml.iml" group="plugins" />
     </modules>
   </component>
 </project>
\ No newline at end of file
index 22b39bcc16de170ce803d938fd7ea6229fe5385b..06f69805397182ae39af182faf91682a12413966 100644 (file)
@@ -658,6 +658,17 @@ public def layoutCommunityPlugins(String home, boolean maySkipAndroidPlugin = fa
     layoutPlugin("settings-repository") {
       fileset(dir: "$home/plugins/settings-repository/lib", excludes: "**/*-sources.jar,**/*.xml,**/com/**,**/org/**,**/java/**,**/dev/**")
     }
+
+    pluginDir("yaml") {
+      dir("lib") {
+        jar("yaml.jar") {
+          noResources("yaml")
+          module("yaml")
+        }
+        resources("yaml")
+      }
+    }
+
   }
 }
 
index 1e6255f204a4074a6ccdd9c77302f51f104cba4d..ea35d365deeead9f629707bfeae1ad2f534f62a7 100644 (file)
@@ -92,6 +92,7 @@
     <orderEntry type="module" module-name="javaFX-jps-plugin" />
     <orderEntry type="module" module-name="IntelliLang-tests" />
     <orderEntry type="module" module-name="manifest" />
+    <orderEntry type="module" module-name="yaml" />
     <orderEntry type="module" module-name="xml-tests" scope="TEST" />
     <orderEntry type="module" module-name="devkit-jps-plugin" scope="TEST" />
     <orderEntry type="module" module-name="jps-model-tests" scope="TEST" />
index 6896dcdbea1f6fa2ba4caf5aebb9c02249dbd308..dcabedf4ca916b6dd94c19f56baef52bc30d0260 100644 (file)
@@ -39,4 +39,9 @@ public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
   protected Filter getFilter(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
     return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope));
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return false;
+  }
 }
index 118aca3ce6abe291fc93cc67a17846697299da21..3682b874d72af36962e845ee4e5211f4d1e0aced 100644 (file)
@@ -31,11 +31,15 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.*;
+import com.intellij.psi.util.ClassUtil;
+import com.intellij.psi.util.PsiClassUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtilCore;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -170,7 +174,7 @@ public class JavaExecutionUtil {
 
   @Nullable
   public static PsiClass findMainClass(final Project project, final String mainClassName, final GlobalSearchScope scope) {
-    if (project.isDefault() || DumbService.isDumb(project)) return null;
+    if (project.isDefault() || (DumbService.isDumb(project) && !Registry.is("dumb.aware.run.configurations"))) return null;
     final PsiManager psiManager = PsiManager.getInstance(project);
     final String shortName = StringUtil.getShortName(mainClassName);
     final String packageName = StringUtil.getPackageName(mainClassName);
index 4c676204b47ec48e0bcd25f4b6b31826e52ce810..808af618006b033bb9d7893c7f65f6acdb84ab68 100644 (file)
@@ -261,7 +261,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
       final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
 
       ReplaceWithLambdaFix
-        .giveUniqueNames(project, anonymousClass, elementFactory, body, conflictingLocals.toArray(new PsiVariable[conflictingLocals.size()]));
+        .giveUniqueNames(project, elementFactory, body, conflictingLocals.toArray(new PsiVariable[conflictingLocals.size()]));
 
       final String withoutTypesDeclared = ReplaceWithLambdaFix.composeLambdaText(method);
 
@@ -273,7 +273,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
       lambdaBody.replace(body);
 
       ReplaceWithLambdaFix
-        .giveUniqueNames(project, lambdaContext, elementFactory, lambdaExpression, lambdaExpression.getParameterList().getParameters());
+        .giveUniqueNames(project, elementFactory, lambdaExpression, lambdaExpression.getParameterList().getParameters());
 
       final PsiNewExpression newExpression = (PsiNewExpression)anonymousClass.getParent();
       lambdaExpression = (PsiLambdaExpression)newExpression.replace(lambdaExpression);
@@ -332,7 +332,6 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
     }
 
     private static void giveUniqueNames(Project project,
-                                        PsiElement lambdaContext,
                                         final PsiElementFactory elementFactory,
                                         PsiElement body,
                                         PsiVariable[] parameters) {
index 1663e76317fe91c77a87e4035a25a5a6cca6602a..73de7fc582341332e99fab8615041f35afd9c3b1 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
@@ -36,8 +35,7 @@ import java.util.List;
 import static com.intellij.psi.util.ImportsUtil.*;
 
 public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
-  private static final Logger LOG = Logger.getInstance("#" + ExpandStaticImportAction.class.getName());
-  private static final String REPLACE_THIS_OCCURRENCE = "Replace this occurrence and keep the method";
+  private static final String REPLACE_THIS_OCCURRENCE = "Replace this occurrence and keep the import";
   private static final String REPLACE_ALL_AND_DELETE_IMPORT = "Replace all and delete the import";
 
   @Override
@@ -81,8 +79,7 @@ public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
       }
       else {
         final BaseListPopupStep<String> step =
-          new BaseListPopupStep<String>("Multiple Similar Calls Found",
-                                        new String[]{REPLACE_THIS_OCCURRENCE, REPLACE_ALL_AND_DELETE_IMPORT}) {
+          new BaseListPopupStep<String>("Multiple Usages of the Static Import Found", REPLACE_THIS_OCCURRENCE, REPLACE_ALL_AND_DELETE_IMPORT) {
             @Override
             public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
               new WriteCommandAction(project, ExpandStaticImportAction.this.getText()) {
index 742f955d6dbfcbfbad534b954e9556a53302a70c..950532ebe61b8e802f2ebb89bf24431c2c3e385c 100644 (file)
@@ -207,7 +207,7 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
     if (RefactoringUtil.hasOnDemandStaticImport(refExpr, aClass) && !(refExpr instanceof PsiMethodReferenceExpression)) {
       refExpr.setQualifierExpression(null);
     }
-    else if (!ImportsUtil.hasStaticImportOn(refExpr, member, false)){
+    else if (!ImportsUtil.hasStaticImportOn(refExpr, member, false) || refExpr.getQualifierExpression() != null){
       PsiElementFactory factory = JavaPsiFacade.getInstance(refExpr.getProject()).getElementFactory();
       refExpr.setQualifierExpression(factory.createReferenceExpression(aClass));
     }
index 8800579563e2c922ce2c5d493a66e7493f08c046..802489dc09c3026618064d11b9edc370f597f0a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 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.
@@ -496,7 +496,10 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
       if (statements.length > 1) {
         final TextRange rangeToFold = getRangeToFold(importList);
         if (rangeToFold != null && rangeToFold.getLength() > 1) {
-          descriptors.add(new FoldingDescriptor(importList, rangeToFold));
+          FoldingDescriptor descriptor = new FoldingDescriptor(importList, rangeToFold);
+          // imports are often added/removed automatically, so we enable autoupdate of folded region for foldings even if it's collapsed
+          descriptor.setCanBeRemovedWhenCollapsed(true);
+          descriptors.add(descriptor);
         }
       }
     }
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/afterAnonymousClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/afterAnonymousClass.java
new file mode 100644 (file)
index 0000000..077d62f
--- /dev/null
@@ -0,0 +1,7 @@
+// "Replace call with method body" "true"
+
+class Test {
+  {
+    System.out.println();
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/afterPassArgs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/afterPassArgs.java
new file mode 100644 (file)
index 0000000..a10dfa6
--- /dev/null
@@ -0,0 +1,9 @@
+// "Replace method call on method reference with corresponding method call" "true"
+
+import java.util.function.ToIntFunction;
+
+class Test {
+  {
+    int i = Integer.parseInt("123");
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforeAnonymousClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforeAnonymousClass.java
new file mode 100644 (file)
index 0000000..5923030
--- /dev/null
@@ -0,0 +1,11 @@
+// "Replace call with method body" "true"
+
+class Test {
+  {
+    new Runnable() {
+      public void run() {
+        System.out.println();
+      }
+    }.ru<caret>n();
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforeAnonymousClassWithMultipleReturns.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforeAnonymousClassWithMultipleReturns.java
new file mode 100644 (file)
index 0000000..f27d654
--- /dev/null
@@ -0,0 +1,18 @@
+// "Replace call with method body" "false"
+
+class Test {
+  {
+    new Runnable() {
+      public void run() {
+        if (true) {
+          System.out.println();
+          return;
+        }
+        else {
+          System.out.println();
+          return;
+        }
+      }
+    }.ru<caret>n();
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforePassArgs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage/beforePassArgs.java
new file mode 100644 (file)
index 0000000..2d8702d
--- /dev/null
@@ -0,0 +1,9 @@
+// "Replace method call on method reference with corresponding method call" "true"
+
+import java.util.function.ToIntFunction;
+
+class Test {
+  {
+    int i = ((ToIntFunction<String>) Integer::parseInt).apply<caret>AsInt("123");
+  }
+}
diff --git a/java/java-tests/testData/refactoring/moveMembers/mixedStaticImportAndQualified/after/ImportingClass.java b/java/java-tests/testData/refactoring/moveMembers/mixedStaticImportAndQualified/after/ImportingClass.java
new file mode 100644 (file)
index 0000000..91205d7
--- /dev/null
@@ -0,0 +1,16 @@
+import static ImportingClass.ImportantConstants.ReallyImportantConstant;
+
+public class ImportingClass {
+
+    public static void main(String[] args) {
+        System.out.println(ReallyImportantConstant);
+        System.out.println(ImportantConstants.ReallyImportantConstant);
+    }
+
+    public static class Constants {
+    }
+
+    public static class ImportantConstants {
+        public static String ReallyImportantConstant = "important";
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/moveMembers/mixedStaticImportAndQualified/before/ImportingClass.java b/java/java-tests/testData/refactoring/moveMembers/mixedStaticImportAndQualified/before/ImportingClass.java
new file mode 100644 (file)
index 0000000..925e3d1
--- /dev/null
@@ -0,0 +1,16 @@
+import static ImportingClass.Constants.ReallyImportantConstant;
+
+public class ImportingClass {
+
+    public static void main(String[] args) {
+        System.out.println(ReallyImportantConstant);
+        System.out.println(Constants.ReallyImportantConstant);
+    }
+
+    public static class Constants {
+        public static String ReallyImportantConstant = "important";
+    }
+
+    public static class ImportantConstants {
+    }
+}
\ No newline at end of file
index 79435401350a2299391ecd4d3a3d5836d81500fd..8561f61120e7fb023fc580417bb9fe8a5dc66332 100644 (file)
@@ -190,6 +190,10 @@ public class MoveMembersTest extends MultiFileTestCase {
     doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
   }
 
+  public void testMixedStaticImportAndQualified() throws Exception {
+    doTest("ImportingClass.Constants", "ImportingClass.ImportantConstants", 0);
+  }
+
   public void testFromNestedToOuterMethodRef() throws Exception {
     final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject());
     final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
index 3aca753b69d2415a7ac0e1224df146d02512b40d..054e9913fa0fff410b186893c84f6bfeeb090931 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "ij-rpc-client",
-  "version": "0.0.1",
+  "version": "0.2.0",
   "description": "IntelliJ Platform RPC client",
   "license": "Apache-2.0",
   "main": "./out/rpc-node.js",
index 40f5fca7cc2e14c468f6ec0bfea2f2c2539fc71e..31170e8c0b2fb1456113f60be129800219c45fdd 100644 (file)
@@ -61,6 +61,10 @@ export class JsonRpc {
     this.domains.set(name, commands)
   }
 
+  public send(domain: string, command: string, ...params: any[]) {
+    this.transport.send(-1, domain, command, params)
+  }
+
   public call<T>(domain: string, command: string, ...params: any[]): Promise<T> {
     return new Promise((resolve: (value: T) => void, reject: (error?: any) => void) => {
       const id = this.messageIdCounter++
index d7d73f985a54a3566b766850979fe85c0d0ccf73..90873948a46550b4320a7fc4ecf97210b4aec5f7 100644 (file)
@@ -138,7 +138,7 @@ class JsonRpcServer(private val clientManager: ClientManager) : MessageServer {
             }
           }
           else {
-            client.send(encodeMessage(client.byteBufAllocator, messageId, params = arrayOf(result)))
+            client.send(encodeMessage(client.byteBufAllocator, messageId, params = if (result == null) ArrayUtil.EMPTY_OBJECT_ARRAY else arrayOf(result)))
           }
         }
         return
index 931d1c813f359e0bfd4a0f652ecb977b3f845eeb..6dc5d8a4c8266acce9be855f07bb490113fa7785 100644 (file)
@@ -35,7 +35,6 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.codeStyle.CodeStyleScheme;
 import com.intellij.psi.codeStyle.CodeStyleSchemes;
-import com.intellij.ui.awt.RelativePoint;
 import com.intellij.ui.table.JBTable;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -170,16 +169,19 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
             }
           }
           catch (SchemeImportException e) {
-            showStatus(myImportButton,
-                       ApplicationBundle.message("message.code.style.scheme.import.failure", selectedImporterName, e.getMessage()),
-                       MessageType.ERROR);
+            if (e.isWarning()) {
+              showStatus(myImportButton, e.getMessage(), MessageType.WARNING);
+              return;
+            }
+            final String message = ApplicationBundle.message("message.code.style.scheme.import.failure", selectedImporterName, e.getMessage());
+            showStatus(myImportButton, message, MessageType.ERROR);
           }
         }
       }
     }
   }
 
-  private static void showStatus(final Component component, final String message, MessageType messageType) {
+  private static void showStatus(final JComponent component, final String message, MessageType messageType) {
     BalloonBuilder balloonBuilder = JBPopupFactory.getInstance()
       .createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(),
                                     messageType.getPopupBackground(), null);
@@ -187,8 +189,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
     final Balloon balloon = balloonBuilder.createBalloon();
     final Rectangle rect = component.getBounds();
     final Point p = new Point(rect.x, rect.y + rect.height);
-    final RelativePoint point = new RelativePoint(component, p);
-    balloon.show(point, Balloon.Position.below);
+    balloon.showInCenterOf(component);
     Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon);
   }  
   
index 18df37d5a5672a2272b4d4b8042de98b30eb1fa0..8d04e27320b0001e2ef739d1e38ebe46b7301f67 100644 (file)
@@ -32,6 +32,7 @@ import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.*;
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Trinity;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.util.IconUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
@@ -215,7 +216,8 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
       final Presentation presentation = e.getPresentation();
       final Project project = e.getProject();
 
-      if (project == null || !project.isInitialized() || project.isDisposed() || DumbService.getInstance(project).isDumb()) {
+      if (project == null || !project.isInitialized() || project.isDisposed() ||
+          (DumbService.getInstance(project).isDumb() && !Registry.is("dumb.aware.run.configurations"))) {
         presentation.setEnabled(false);
         return;
       }
index b53660f89e562f1eda88c15465d50eef14a69f24..ecd3cfa9670edc565412335ce2b00fba02c1ae7b 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.wm.ToolWindowId;
 import com.intellij.openapi.wm.ToolWindowManager;
 import org.jetbrains.annotations.NotNull;
@@ -190,6 +191,11 @@ public class RunContentExecutor implements Disposable {
       e.getPresentation().setVisible(myRerunAction != null);
       e.getPresentation().setEnabled(myRerunAction != null);
     }
+
+    @Override
+    public boolean isDumbAware() {
+      return Registry.is("dumb.aware.run.configurations");
+    }
   }
 
   private class StopAction extends AnAction implements DumbAware {
index 9e33fc86551d01d2a895c77b86821b47c37a2753..93e3b0f826c072d00ded901afcf0b9ec9140072e 100644 (file)
@@ -32,6 +32,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.keymap.KeymapUtil;
+import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.ListPopupStep;
@@ -236,24 +237,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
   }
 
   private static Action createNumberAction(final int number, final ListPopupImpl listPopup, final Executor executor) {
-    return new AbstractAction() {
-      @Override
-      public void actionPerformed(ActionEvent e) {
-        if (listPopup.getSpeedSearch().isHoldingFilter())
-          return;
-        for (final Object item : listPopup.getListStep().getValues()) {
-          if (item instanceof ItemWrapper && ((ItemWrapper)item).getMnemonic() == number) {
-            listPopup.setFinalRunnable(new Runnable() {
-              @Override
-              public void run() {
-                execute((ItemWrapper)item, executor);
-              }
-            });
-            listPopup.closeOk(null);
-          }
-        }
-      }
-    };
+    return new MyAbstractAction(listPopup, number, executor);
   }
 
   private abstract static class Wrapper {
@@ -753,6 +737,35 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
     }
   }
 
+  private static class MyAbstractAction extends AbstractAction implements DumbAware {
+    private final ListPopupImpl myListPopup;
+    private final int myNumber;
+    private final Executor myExecutor;
+
+    public MyAbstractAction(ListPopupImpl listPopup, int number, Executor executor) {
+      myListPopup = listPopup;
+      myNumber = number;
+      myExecutor = executor;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+      if (myListPopup.getSpeedSearch().isHoldingFilter())
+        return;
+      for (final Object item : myListPopup.getListStep().getValues()) {
+        if (item instanceof ItemWrapper && ((ItemWrapper)item).getMnemonic() == myNumber) {
+          myListPopup.setFinalRunnable(new Runnable() {
+            @Override
+            public void run() {
+              execute((ItemWrapper)item, myExecutor);
+            }
+          });
+          myListPopup.closeOk(null);
+        }
+      }
+    }
+  }
+
   private class RunListPopup extends ListPopupImpl {
     public RunListPopup(ListPopupStep step) {
       super(step);
index 4fddeac44706ec83d57ed8c7aad56ff0e9fe5281..e6849d23578e92219739219ac3048e209e8e5a1a 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.wm.ToolWindowId;
 
 public class ChooseRunConfigurationPopupAction extends AnAction {
@@ -71,4 +72,9 @@ public class ChooseRunConfigurationPopupAction extends AnAction {
     presentation.setEnabled(true);
     presentation.setVisible(true);
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return Registry.is("dumb.aware.run.configurations");
+  }
 }
index fd1f2862f6ad42d1bcbf489961a68eed2703b0bc..0c9a5f545c06049173d212c05bd58f3154fb385f 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.wm.ex.WindowManagerEx;
 import com.intellij.openapi.wm.impl.IdeFrameImpl;
 import com.intellij.ui.IdeBorderFactory;
@@ -274,6 +275,11 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
                          myProject,
                          e.getPresentation());
     }
+
+    @Override
+    public boolean isDumbAware() {
+      return Registry.is("dumb.aware.run.configurations");
+    }
   }
 
   private static class SelectConfigAction extends DumbAwareAction {
index 8d0d64f332ad4fc2d8ef0b7c9605ff5cd176f5c2..329fb249b4a4638337006d0e22b9c5c16bec51d1 100644 (file)
@@ -47,6 +47,7 @@ import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Trinity;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.ui.docking.DockManager;
 import com.intellij.util.Alarm;
@@ -340,7 +341,11 @@ public class ExecutionManagerImpl extends ExecutionManager implements Disposable
         @Override
         public void run() {
           if (!myProject.isDisposed()) {
-            DumbService.getInstance(myProject).runWhenSmart(startRunnable);
+            if (!Registry.is("dumb.aware.run.configurations")) {
+              DumbService.getInstance(myProject).runWhenSmart(startRunnable);
+            } else {
+              startRunnable.run();
+            }
           }
         }
       });
@@ -488,7 +493,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements Disposable
     awaitingTerminationAlarm.addRequest(new Runnable() {
       @Override
       public void run() {
-        if (DumbService.getInstance(myProject).isDumb() || ExecutorRegistry.getInstance().isStarting(environment)) {
+        if ((DumbService.getInstance(myProject).isDumb() && !Registry.is("dumb.aware.run.configurations")) || ExecutorRegistry.getInstance().isStarting(environment)) {
           awaitingTerminationAlarm.addRequest(this, 100);
           return;
         }
index 568a8dbec1dbd351dd48a2b0080a674d2d399cab..c3d520cade0fd399bd47715e54a358dc6ae7bec4 100644 (file)
@@ -27,11 +27,13 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.progress.ProcessCanceledException;
 import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ModuleRootAdapter;
 import com.intellij.openapi.roots.ModuleRootEvent;
 import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeaturesCollector;
 import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.ui.IconDeferrer;
 import com.intellij.util.EventDispatcher;
 import com.intellij.util.Function;
@@ -1086,7 +1088,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
                                                   long startTime = System.currentTimeMillis();
 
                                                   Icon icon;
-                                                  if (DumbService.isDumb(myProject)) {
+                                                  if (DumbService.isDumb(myProject) && !Registry.is("dumb.aware.run.configurations")) {
                                                     icon =
                                                       IconLoader.getDisabledIcon(ProgramRunnerUtil.getRawIcon(settings));
                                                     if (settings.isTemporary()) {
@@ -1095,12 +1097,19 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
                                                   }
                                                   else {
                                                     try {
+                                                      DumbService.getInstance(myProject).setAlternativeResolveEnabled(true);
                                                       settings.checkSettings();
                                                       icon = ProgramRunnerUtil.getConfigurationIcon(settings, false);
                                                     }
+                                                    catch (IndexNotReadyException e) {
+                                                      icon = ProgramRunnerUtil.getConfigurationIcon(settings, !Registry.is("dumb.aware.run.configurations"));
+                                                    }
                                                     catch (RuntimeConfigurationException ignored) {
                                                       icon = ProgramRunnerUtil.getConfigurationIcon(settings, true);
                                                     }
+                                                    finally {
+                                                      DumbService.getInstance(myProject).setAlternativeResolveEnabled(false);
+                                                    }
                                                   }
                                                   myIconCalcTime.put(uniqueID, System.currentTimeMillis() - startTime);
                                                   return icon;
index 51b016427fa2bf3f19092bb173fc2725782469b5..c63712872bf380588246052bcdb64d85caeefe25 100644 (file)
@@ -28,6 +28,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.LangDataKeys;
 import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -85,4 +86,9 @@ class FakeRerunAction extends AnAction  {
            !ExecutorRegistry.getInstance().isStarting(environment) &&
            !(processHandler != null && processHandler.isProcessTerminating());
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return Registry.is("dumb.aware.run.configurations");
+  }
 }
index 61676bbc704443a5cc5a56d9277fa51496bae455..3d4220687e36957a069d9f169498fe10bce30652 100644 (file)
@@ -19,14 +19,14 @@ package com.intellij.execution.ui.layout.actions;
 import com.intellij.execution.ui.layout.CellTransform;
 import com.intellij.icons.AllIcons;
 import com.intellij.idea.ActionsBundle;
-import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.ui.content.Content;
 
 import javax.swing.*;
 
-public class RestoreViewAction extends AnAction {
+public class RestoreViewAction extends DumbAwareAction {
 
   private final Content myContent;
   private final CellTransform.Restore myRestoreAction;
index 96835f1c501afc29f245b20aa57c40b2ac3f0330..0582771f5a3bb56e5208baeb18bcb5b8e5b90f32 100644 (file)
@@ -22,6 +22,7 @@ package com.intellij.openapi.options;
  * @author Rustam Vishnyakov
  */
 public class SchemeImportException extends Exception {
+  boolean myIsWarning;
   public SchemeImportException(String message) {
     super(message);
   }
@@ -29,4 +30,13 @@ public class SchemeImportException extends Exception {
   public SchemeImportException(Throwable cause) {
     super(cause);
   }
+
+  public SchemeImportException setWarning() {
+    myIsWarning = true;
+    return this;
+  }
+
+  public boolean isWarning() {
+    return myIsWarning;
+  }
 }
index 644f3d3624e28f7b705ba0724e0d12b1a0edb372..be947ccc607eba7adefc3097edfbf7a062e1c89b 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.
@@ -16,6 +16,7 @@
 package com.intellij.openapi.ui;
 
 import com.intellij.icons.AllIcons;
+import com.intellij.util.ui.JBUI;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 
@@ -45,10 +46,10 @@ public class FixedSizeButton extends JButton {
     }
     mySize = size;
     myComponent = component;
-    setMargin(new Insets(0, 0, 0, 0));
+    setMargin(JBUI.emptyInsets());
     setDefaultCapable(false);
     setFocusable(false);
-    if (((UIUtil.isUnderAquaLookAndFeel()) && size == -1) || UIUtil.isUnderDarcula()) {
+    if (((UIUtil.isUnderAquaLookAndFeel()) && size == -1) || UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula()) {
       putClientProperty("JButton.buttonType", "square");
     }
   }
index c990d17bee2abe65ee12f31ce20d6f0f087ae9cc..4acfe5f38cd2a6757132173d2a9911b3b2c385a3 100644 (file)
@@ -16,6 +16,9 @@
 package com.intellij.ui.components;
 
 import com.intellij.openapi.ui.TypingTarget;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.registry.Registry;
+import com.intellij.ui.components.JBScrollPane.Alignment;
 import com.intellij.ui.table.JBTable;
 import com.intellij.util.ui.ComponentWithEmptyText;
 import com.intellij.util.ui.StatusText;
@@ -32,6 +35,20 @@ public class JBViewport extends JViewport implements ZoomableViewport {
 
     @Override
     public void layoutContainer(Container parent) {
+      if (parent instanceof JViewport && Registry.is("ide.scroll.new.layout")) {
+        JViewport viewport = (JViewport)parent;
+        Component view = viewport.getView();
+        if (view != null) {
+          JScrollPane pane = getScrollPane(viewport);
+          if (pane != null) {
+            doLayout(pane, viewport, view);
+          }
+          else {
+            super.layoutContainer(parent);
+          }
+        }
+        return;
+      }
       JBViewport viewport = (JBViewport)parent;
       Component view = viewport.getView();
       JBScrollPane scrollPane = UIUtil.getParentOfType(JBScrollPane.class, parent);
@@ -155,4 +172,120 @@ public class JBViewport extends JViewport implements ZoomableViewport {
   public boolean isPaintingNow() {
     return myPaintingNow;
   }
+
+  @Override
+  public Color getBackground() {
+    Component view = getView();
+    return view != null && view.isBackgroundSet()
+           ? view.getBackground()
+           : super.getBackground();
+  }
+
+  @Override
+  public Dimension getExtentSize() {
+    Dimension size = super.getExtentSize();
+    if (SystemInfo.isMac) return size;
+    JScrollPane pane = getScrollPane(this);
+    if (pane != null) {
+      JScrollBar vsb = pane.getVerticalScrollBar();
+      if (null != getAlignment(vsb)) {
+        int width = vsb.getWidth();
+        if (size.width > width) size.width -= width;
+      }
+      JScrollBar hsb = pane.getHorizontalScrollBar();
+      if (null != getAlignment(hsb)) {
+        int height = hsb.getHeight();
+        if (size.height > height) size.height -= height;
+      }
+    }
+    return size;
+  }
+
+  /**
+   * Returns the alignment of the specified scroll bar
+   * if and only if the specified scroll bar
+   * is located over the corresponding viewport.
+   *
+   * @param bar the scroll bar to process
+   * @return the scroll bar alignment or {@code null}
+   */
+  private static Alignment getAlignment(JScrollBar bar) {
+    if (bar != null && bar.isVisible() && !bar.isOpaque()) {
+      Object property = bar.getClientProperty(Alignment.class);
+      if (property instanceof Alignment) return (Alignment)property;
+    }
+    return null;
+  }
+
+  /**
+   * Returns the parent scroll pane of the specified viewport
+   * if and only if the specified viewport is a main viewport.
+   *
+   * @param viewport the viewport to process
+   * @return the parent scroll pane or {@code null}
+   */
+  private static JScrollPane getScrollPane(JViewport viewport) {
+    Container parent = viewport.getParent();
+    if (parent instanceof JScrollPane) {
+      JScrollPane pane = (JScrollPane)parent;
+      if (viewport == pane.getViewport()) return pane;
+    }
+    return null;
+  }
+
+  private static void doLayout(JScrollPane pane, JViewport viewport, Component view) {
+    Dimension actualSize = viewport.getSize();
+    Dimension extentSize = viewport.getExtentSize();
+    Dimension viewPreferredSize = view.getPreferredSize();
+    Dimension viewSize = new Dimension(viewPreferredSize);
+    Point viewPosition = viewport.getViewPosition();
+
+    Scrollable scrollable = null;
+    if (view instanceof Scrollable) {
+      scrollable = (Scrollable)view;
+      if (scrollable.getScrollableTracksViewportWidth()) viewSize.width = actualSize.width;
+      if (scrollable.getScrollableTracksViewportHeight()) viewSize.height = actualSize.height;
+    }
+    // If the new viewport size would leave empty space to the right of the view,
+    // right justify the view or left justify the view
+    // when the width of the view is smaller than the container.
+    int maxX = viewSize.width - extentSize.width;
+    if (scrollable == null || pane.getComponentOrientation().isLeftToRight()) {
+      if (viewPosition.x > maxX) {
+        viewPosition.x = Math.max(0, maxX);
+      }
+    }
+    else {
+      // NOT SUPPORTED YET
+      viewPosition.x = maxX < 0 ? maxX : Math.max(0, Math.min(maxX, viewPosition.x));
+    }
+    // If the new viewport size would leave empty space below the view,
+    // bottom justify the view or top justify the view
+    // when the height of the view is smaller than the container.
+    int maxY = viewSize.height - extentSize.height;
+    if (viewPosition.y > maxY) {
+      viewPosition.y = Math.max(0, maxY);
+    }
+    // If we haven't been advised about how the viewports size should change wrt to the viewport,
+    // i.e. if the view isn't an instance of Scrollable, then adjust the views size as follows.
+    if (scrollable == null) {
+      // If the origin of the view is showing and the viewport is bigger than the views preferred size,
+      // then make the view the same size as the viewport.
+      if (viewPosition.x == 0 && actualSize.width > viewPreferredSize.width) viewSize.width = actualSize.width;
+      if (viewPosition.y == 0 && actualSize.height > viewPreferredSize.height) viewSize.height = actualSize.height;
+    }
+    // do not force viewport size on editor component, e.g. EditorTextField and LanguageConsole
+    if (!(view instanceof TypingTarget)) {
+      if (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER == pane.getHorizontalScrollBarPolicy()) {
+        viewPosition.x = 0;
+        viewSize.width = actualSize.width;
+      }
+      if (ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER == pane.getVerticalScrollBarPolicy()) {
+        viewPosition.y = 0;
+        viewSize.height = actualSize.height;
+      }
+    }
+    viewport.setViewPosition(viewPosition);
+    viewport.setViewSize(viewSize);
+  }
 }
index 43cc4d0be9d89f5826ea89d30b37868a08c826fe..4508faf7f74156e8cedb8534ec13f5724a08ded7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 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.
@@ -50,6 +50,6 @@ public class AboutAction extends AnAction implements DumbAware {
   }
 
   private static void showAboutDialog(@Nullable Window window) {
-    new AboutPopup().show(window);
+    AboutPopup.show(window);
   }
 }
index f25c997b6848587d638771e8fd35dae455e4a31d..580d23109faedb41906ca76a3684310bfc5a8184 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.
@@ -18,6 +18,7 @@ package com.intellij.ide.actions;
 import com.intellij.ide.BrowserUtil;
 import com.intellij.ide.IdeBundle;
 import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CustomShortcutSet;
 import com.intellij.openapi.application.ApplicationInfo;
@@ -25,7 +26,10 @@ import com.intellij.openapi.application.ex.ApplicationInfoEx;
 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.ide.CopyPasteManager;
 import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.ui.GraphicsConfig;
+import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.registry.Registry;
@@ -35,7 +39,9 @@ import com.intellij.ui.JBColor;
 import com.intellij.ui.LicensingFacade;
 import com.intellij.ui.UI;
 import com.intellij.ui.awt.RelativePoint;
+import com.intellij.util.Alarm;
 import com.intellij.util.text.DateFormatUtil;
+import com.intellij.util.ui.GraphicsUtil;
 import com.intellij.util.ui.JBUI;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
@@ -55,7 +61,10 @@ import java.util.List;
  * @author Konstantin Bulenkov
  */
 public class AboutPopup {
-  public void show(@Nullable Window window) {
+  private static final String COPY_URL = "copy://";
+  private static JBPopup ourPopup;
+
+  public static void show(@Nullable Window window) {
     ApplicationInfoEx appInfo = (ApplicationInfoEx)ApplicationInfo.getInstance();
 
     final JPanel panel = new JPanel(new BorderLayout());
@@ -86,7 +95,7 @@ public class AboutPopup {
       location = new RelativePoint(new Point((r.width - image.getIconWidth()) / 2, (r.height - image.getIconHeight()) / 2));
     }
 
-    JBPopupFactory.getInstance().createComponentPopupBuilder(panel, panel)
+    ourPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, panel)
       .setRequestFocus(true)
       .setFocusable(true)
       .setResizable(false)
@@ -97,8 +106,16 @@ public class AboutPopup {
       .setCancelKeyEnabled(true)
       .setCancelOnClickOutside(true)
       .setCancelOnOtherWindowOpen(true)
-      .createPopup()
-      .show(location);
+      .createPopup();
+
+    Disposer.register(ourPopup, new Disposable() {
+      @Override
+      public void dispose() {
+        ourPopup = null;
+      }
+    });
+
+    ourPopup.show(location);
   }
 
   private static void copyInfoToClipboard(String text) {
@@ -118,6 +135,9 @@ public class AboutPopup {
     private StringBuilder myInfo = new StringBuilder();
     private final List<Link> myLinks = new ArrayList<Link>();
     private Link myActiveLink;
+    private boolean myShowCopy = false;
+    private float myShowCopyAlpha;
+    private Alarm myAlarm = new Alarm();
 
     public InfoSurface(Icon image) {
       ApplicationInfoImpl appInfo = (ApplicationInfoImpl)ApplicationInfoEx.getInstanceEx();
@@ -174,18 +194,62 @@ public class AboutPopup {
         myLines.add(new AboutBoxLine("Powered by ").keepWithNext());
         myLines.add(new AboutBoxLine("open-source software", false, thirdParty));
       }
-      
-      myLines.add(new AboutBoxLine(""));
-      myLines.add(new AboutBoxLine(IdeBundle.message("about.box.copy.prompt", SystemInfo.isMac ? "Cmd+C" : "Ctrl+C")));
 
       addMouseListener(new MouseAdapter() {
         @Override
         public void mousePressed(MouseEvent event) {
           if (myActiveLink != null) {
             event.consume();
+            if (COPY_URL.equals(myActiveLink.myUrl)) {
+              copyInfoToClipboard(myInfo.toString());
+              if (ourPopup != null) {
+                ourPopup.cancel();
+              }
+              return;
+            }
             BrowserUtil.browse(myActiveLink.myUrl);
           }
         }
+
+        final static double maxAlpha = 0.5;
+        final static double fadeStep = 0.05;
+        final static int animationDelay = 15;
+
+        @Override
+        public void mouseEntered(MouseEvent e) {
+          if (!myShowCopy) {
+            myShowCopy = true;
+            myAlarm.cancelAllRequests();
+            myAlarm.addRequest(new Runnable() {
+              @Override
+              public void run() {
+                if (myShowCopyAlpha < maxAlpha) {
+                  myShowCopyAlpha += fadeStep;
+                  repaint();
+                  myAlarm.addRequest(this, animationDelay);
+                }
+              }
+            }, animationDelay);
+          }
+        }
+
+        @Override
+        public void mouseExited(MouseEvent e) {
+          if (myShowCopy) {
+            myShowCopy = false;
+            myAlarm.cancelAllRequests();
+            myAlarm.addRequest(new Runnable() {
+              @Override
+              public void run() {
+                if (myShowCopyAlpha > 0) {
+                  myShowCopyAlpha -= fadeStep;
+                  repaint();
+                  myAlarm.addRequest(this, animationDelay);
+                }
+              }
+            }, animationDelay);
+          }
+        }
       });
 
       addMouseMotionListener(new MouseMotionAdapter() {
@@ -314,6 +378,7 @@ public class AboutPopup {
         x = indentX;
         y = indentY;
         ApplicationInfoEx appInfo = (ApplicationInfoEx)ApplicationInfo.getInstance();
+        boolean showCopyButton = myShowCopy || myShowCopyAlpha > 0;
         for (AboutBoxLine line : lines) {
           final String s = line.getText();
           setFont(line.isBold() ? myBoldFont : myFont);
@@ -326,6 +391,19 @@ public class AboutPopup {
             g2.setColor(Registry.is("ide.new.about") ? Gray.x33 : appInfo.getAboutForeground());
           }
           renderString(s, indentX);
+          if (showCopyButton) {
+            final FontMetrics metrics = g2.getFontMetrics(myFont);
+            String copyString = "Copy to Clipboard";
+            final int width = metrics.stringWidth(copyString);
+            g2.setFont(myFont);
+            g2.setColor(myLinkColor);
+            final int xOffset = myImage.getIconWidth() - width - 10;
+            final GraphicsConfig config = GraphicsUtil.paintWithAlpha(g2, myShowCopyAlpha);
+            g2.drawString(copyString, xOffset, yBase + y);
+            config.restore();
+            myLinks.add(new Link(new Rectangle(xOffset, yBase + y - fontAscent, width, fontHeight), COPY_URL));
+            showCopyButton = false;
+          }
           if (!line.isKeepWithNext() && !line.equals(lines.get(lines.size()-1))) {
             lineFeed(indentX, s);
           }
index 6829bd8a09a136548761d55425fda40c6afbedcb..427ab5871b1954325ca4ceba96648753f9449cf1 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.
@@ -822,7 +822,7 @@ public class EditorActionUtil {
     CaretModel caretModel = editor.getCaretModel();
     LogicalPosition blockSelectionStart = caretModel.getLogicalPosition();
     Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
-    int lineNumber = (visibleArea.y + visibleArea.height) / lineHeight - 1;
+    int lineNumber = Math.max(0, (visibleArea.y + visibleArea.height) / lineHeight - 1);
     VisualPosition pos = new VisualPosition(lineNumber, editor.getCaretModel().getVisualPosition().column);
     editor.getCaretModel().moveToVisualPosition(pos);
     setupSelection(editor, isWithSelection, selectionStart, blockSelectionStart);
index 058afb264cdf9f7010d1fc4600159bb0ab0c649f..4eb5383e9b988e7a11bd02a312534c40cbf84737 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.
@@ -374,8 +374,9 @@ class EditorPainter implements TextDrawingCallback {
             }
             paintWhitespace(g, text, xStart, y, start, end, whitespacePaintingStrategy, fragment);
           }
-          if (attributes != null && hasTextEffect(attributes.getEffectColor(), attributes.getEffectType())) {
-            paintTextEffect(g, xStart, xEnd, y, attributes.getEffectColor(), attributes.getEffectType());
+          boolean allowBorder = fragment.getCurrentFoldRegion() != null;
+          if (attributes != null && hasTextEffect(attributes.getEffectColor(), attributes.getEffectType(), allowBorder)) {
+            paintTextEffect(g, xStart, xEnd, y, attributes.getEffectColor(), attributes.getEffectType(), allowBorder);
           }
         }
 
@@ -405,21 +406,22 @@ class EditorPainter implements TextDrawingCallback {
       x = fragment.getEndX();
 
     }
-    if (hasTextEffect(effectColor, effectType)) {
-      paintTextEffect(g, initialX, x, (int)y, effectColor, effectType);
+    if (hasTextEffect(effectColor, effectType, false)) {
+      paintTextEffect(g, initialX, x, (int)y, effectColor, effectType, false);
     }
     return x;
   }
 
-  private static boolean hasTextEffect(@Nullable Color effectColor, @Nullable EffectType effectType) {
+  private static boolean hasTextEffect(@Nullable Color effectColor, @Nullable EffectType effectType, boolean allowBorder) {
     return effectColor != null && (effectType == EffectType.LINE_UNDERSCORE ||
                                    effectType == EffectType.BOLD_LINE_UNDERSCORE ||
                                    effectType == EffectType.BOLD_DOTTED_LINE ||
                                    effectType == EffectType.WAVE_UNDERSCORE ||
-                                   effectType == EffectType.STRIKEOUT);
+                                   effectType == EffectType.STRIKEOUT ||
+                                   allowBorder && (effectType == EffectType.BOXED || effectType == EffectType.ROUNDED_BOX));
   }
 
-  private void paintTextEffect(Graphics2D g, float xFrom, float xTo, int y, Color effectColor, EffectType effectType) {
+  private void paintTextEffect(Graphics2D g, float xFrom, float xTo, int y, Color effectColor, EffectType effectType, boolean allowBorder) {
     int xStart = (int)xFrom;
     int xEnd = (int)xTo;
     g.setColor(effectColor);
@@ -440,6 +442,9 @@ class EditorPainter implements TextDrawingCallback {
     else if (effectType == EffectType.BOLD_DOTTED_LINE) {
       UIUtil.drawBoldDottedLine(g, xStart, xEnd, SystemInfo.isMac ? y : y + 1, myEditor.getBackgroundColor(), g.getColor(), false);
     }
+    else if (allowBorder && (effectType == EffectType.BOXED || effectType == EffectType.ROUNDED_BOX)) {
+      drawSimpleBorder(g, xStart, xEnd - 1, y - myView.getAscent(), effectType == EffectType.ROUNDED_BOX);
+    }
   }
 
   private void paintWhitespace(Graphics2D g, CharSequence text, float x, int y, int start, int end,
@@ -525,9 +530,9 @@ class EditorPainter implements TextDrawingCallback {
     int y = lineEnd.y;
     TextAttributes attributes = highlighter.getTextAttributes();
     paintBackground(g, attributes, x, y, myView.getPlainSpaceWidth());
-    if (attributes != null && hasTextEffect(attributes.getEffectColor(), attributes.getEffectType())) {
+    if (attributes != null && hasTextEffect(attributes.getEffectColor(), attributes.getEffectType(), false)) {
       paintTextEffect(g, x, x + myView.getPlainSpaceWidth() - 1, y + myView.getAscent(), 
-                      attributes.getEffectColor(), attributes.getEffectType());
+                      attributes.getEffectColor(), attributes.getEffectType(), false);
     }
   }
 
@@ -585,7 +590,6 @@ class EditorPainter implements TextDrawingCallback {
     }
   
     boolean rounded = attributes.getEffectType() == EffectType.ROUNDED_BOX;
-    int lineHeight = myView.getLineHeight() - 1;
     g.setColor(attributes.getEffectColor());
     VisualPosition startPosition = myView.offsetToVisualPosition(startOffset, true, false);
     VisualPosition endPosition = myView.offsetToVisualPosition(endOffset, false, true);
@@ -595,12 +599,7 @@ class EditorPainter implements TextDrawingCallback {
       for (int i = 0; i < ranges.size() - 1; i+= 2) {
         int startX = (int)ranges.get(i);
         int endX = (int)ranges.get(i + 1);
-        if (rounded) {
-          UIUtil.drawRectPickedOut(g, startX, y, endX - startX, lineHeight);
-        } 
-        else {
-          g.drawRect(startX, y, endX - startX, lineHeight);
-        }
+        drawSimpleBorder(g, startX, endX, y, rounded);
       }
     }
     else {
@@ -612,6 +611,7 @@ class EditorPainter implements TextDrawingCallback {
         int maxWidth = Math.max(myView.getMaxWidthInLineRange(startPosition.line, endPosition.line - 1) - 1,
                                 (int)trailingRanges.get(trailingRanges.size() - 1));
         boolean containsInnerLines = endPosition.line > startPosition.line + 1;
+        int lineHeight = myView.getLineHeight() - 1;
         int leadingTopY = myView.visualLineToY(startPosition.line);
         int leadingBottomY = leadingTopY + lineHeight;
         int trailingTopY = myView.visualLineToY(endPosition.line);
@@ -673,6 +673,16 @@ class EditorPainter implements TextDrawingCallback {
     }
   }
   
+  private void drawSimpleBorder(Graphics2D g, int xStart, int xEnd, int y, boolean rounded) {
+    int height = myView.getLineHeight() - 1;
+    if (rounded) {
+      UIUtil.drawRectPickedOut(g, xStart, y, xEnd - xStart, height);
+    }
+    else {
+      g.drawRect(xStart, y, xEnd - xStart, height);
+    }
+  }
+  
   private static void drawLine(Graphics2D g, float x1, int y1, float x2, int y2, boolean rounded) {
     if (rounded) {
       UIUtil.drawLinePickedOut(g, (int) x1, y1, (int)x2, y2);
@@ -907,9 +917,18 @@ class EditorPainter implements TextDrawingCallback {
   }
 
   private TextAttributes getFoldRegionAttributes(FoldRegion foldRegion) {
-    TextAttributes foldAttributes = myEditor.getFoldingModel().getPlaceholderAttributes();
     TextAttributes selectionAttributes = isSelected(foldRegion) ? myEditor.getSelectionModel().getTextAttributes() : null;
-    return mergeAttributes(selectionAttributes, foldAttributes);
+    TextAttributes foldAttributes = myEditor.getFoldingModel().getPlaceholderAttributes();
+    TextAttributes defaultAttributes = getDefaultAttributes();
+    return mergeAttributes(mergeAttributes(selectionAttributes, foldAttributes), defaultAttributes);
+  }
+
+  @SuppressWarnings("UseJBColor")
+  private TextAttributes getDefaultAttributes() {
+    TextAttributes attributes = myEditor.getColorsScheme().getAttributes(HighlighterColors.TEXT);
+    if (attributes.getForegroundColor() == null) attributes.setForegroundColor(Color.black);
+    if (attributes.getBackgroundColor() == null) attributes.setBackgroundColor(Color.white);
+    return attributes;
   }
 
   private static boolean isSelected(FoldRegion foldRegion) {
index ebf050ed819c9354d9f89c9040d6f4ac87670ccb..c1bf68c84ad9d671154dcfb331ba4acee348a8ae 100644 (file)
@@ -314,7 +314,8 @@ public final class IdeMouseEventDispatcher {
   private static JScrollBar findHorizontalScrollBar(Component c) {
     if (c == null) return null;
     if (c instanceof JScrollPane) {
-      return ((JScrollPane)c).getHorizontalScrollBar();
+      JScrollBar scrollBar = ((JScrollPane)c).getHorizontalScrollBar();
+      return scrollBar != null && scrollBar.isVisible() ? scrollBar : null;
     }
 
     if (isDiagramViewComponent(c)) {
@@ -323,7 +324,7 @@ public final class IdeMouseEventDispatcher {
          if (view.getComponent(i) instanceof JScrollBar) {
            final JScrollBar scrollBar = (JScrollBar)view.getComponent(i);
            if (scrollBar.getOrientation() == Adjustable.HORIZONTAL) {
-            return scrollBar;
+             return scrollBar.isVisible() ? scrollBar : null;
            }
          }
       }
diff --git a/platform/platform-tests/testData/editor/painting/foldedRegionShownOnlyWithBorder.png b/platform/platform-tests/testData/editor/painting/foldedRegionShownOnlyWithBorder.png
new file mode 100644 (file)
index 0000000..f31eab5
Binary files /dev/null and b/platform/platform-tests/testData/editor/painting/foldedRegionShownOnlyWithBorder.png differ
index 43c0752075e4b91132fdee168ac2d100a2183aee..0a51ff26f3ba765a7b3b8ce7ff311b68480abdcb 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.openapi.editor;
 
 import com.intellij.openapi.application.ex.PathManagerEx;
+import com.intellij.openapi.editor.colors.EditorColors;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.event.DocumentEvent;
 import com.intellij.openapi.editor.ex.EditorEx;
@@ -92,6 +93,14 @@ public class EditorPaintingTest extends AbstractEditorTest {
     addBorderHighlighter(3, 4, HighlighterLayer.WARNING, Color.red);
     checkResult();
   }
+  
+  public void testFoldedRegionShownOnlyWithBorder() throws Exception {
+    initText("abc");
+    addCollapsedFoldRegion(0, 3, "...");
+    myEditor.getColorsScheme().setAttributes(EditorColors.FOLDED_TEXT_ATTRIBUTES, 
+                                             new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.PLAIN));
+    checkResult();
+  }
 
   private static void addRangeHighlighter(int startOffset, int endOffset, int layer, Color foregroundColor, Color backgroundColor) {
     addRangeHighlighter(startOffset, endOffset, layer, new TextAttributes(foregroundColor, backgroundColor, null, null, Font.PLAIN));
index 9c6e1e44d3e290ebacda4103594c12ffd33d8b0a..d7d58734a402f3b91b1d3361196bb18320c2ebb7 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
@@ -13,5 +13,4 @@
     <orderEntry type="module" module-name="platform-impl" />
     <orderEntry type="library" name="Netty" level="project" />
   </component>
-</module>
-
+</module>
\ No newline at end of file
diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventAdapter.java
deleted file mode 100644 (file)
index 072afcb..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2000-2015 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.debugger;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public abstract class DebugEventAdapter implements DebugEventListener {
-  @Override
-  public void suspended(@NotNull SuspendContext<?> context) {
-  }
-
-  @Override
-  public void resumed() {
-  }
-
-  @Override
-  public void disconnected() {
-  }
-
-  @Override
-  public void scriptAdded(@NotNull Script script, @Nullable String sourceMapUrl) {
-  }
-
-  @Override
-  public void scriptRemoved(@NotNull Script script) {
-  }
-
-  @Override
-  public void scriptContentChanged(@NotNull Script newScript) {
-  }
-
-  @Override
-  public void scriptsCleared() {
-  }
-
-  @Override
-  public void navigated(String newUrl) {
-  }
-
-  @Override
-  public void errorOccurred(@NotNull String errorMessage) {
-  }
-}
index aab1f3e36cb97dbc9d4f6aa7603ef151039b0429..f5387e4ab0b8ea306fb633762be4145c6ce7d8ad 100755 (executable)
@@ -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.
@@ -26,43 +26,52 @@ public interface DebugEventListener extends EventListener {
    * breakpoints or a step end). The {@code context} can be used to access the
    * current backtrace.
    */
-  void suspended(@NotNull SuspendContext<?> context);
+  default void suspended(@NotNull SuspendContext<?> context) {
+  }
 
   /**
    * Reports the virtual machine has resumed. This can happen
    * asynchronously, due to a user action in the browser (without explicitly resuming the VM through
    */
-  void resumed();
+  default void resumed() {
+  }
 
   /**
    * Reports the debug connection has terminated and {@link Vm} has stopped operating.
    * This event is not reported if connection was closed explicitly on our side
    */
-  void disconnected();
+  default void disconnected() {
+  }
 
   /**
    * Reports that a new script has been loaded.
    */
-  void scriptAdded(@NotNull Script script, @Nullable String sourceMapUrl);
+  default void scriptAdded(@NotNull Script script, @Nullable String sourceMapUrl) {
+  }
 
   /**
    * Reports that the script has been collected and is no longer used in VM.
    */
-  void scriptRemoved(@NotNull Script script);
+  default void scriptRemoved(@NotNull Script script) {
+  }
 
-  void scriptsCleared();
+  default void scriptsCleared() {
+  }
 
   /**
    * Reports that script source has been altered in remote VM.
    */
-  void scriptContentChanged(@NotNull Script newScript);
+  default void scriptContentChanged(@NotNull Script newScript) {
+  }
 
   /**
    * Reports a navigation event on the target.
    *
    * @param newUrl the new URL of the debugged target
    */
-  void navigated(String newUrl);
+  default void navigated(String newUrl) {
+  }
 
-  void errorOccurred(@NotNull String errorMessage);
+  default void errorOccurred(@NotNull String errorMessage) {
+  }
 }
\ No newline at end of file
index 062e321501dc7c99ac7006dc60971e34229e5c17..3b7f67887883d0b3620076bc52b27db9f55f95a7 100644 (file)
@@ -25,7 +25,7 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.TYPE, ElementType.METHOD})
 public @interface Bombed {
-  int year() default 2015;
+  int year() default 2016;
   @JdkConstants.CalendarMonth int month();
   int day();
   int time() default 0;
index 98c7cab7f948355445e689677a6a3a269989b98e..d64ec0f9eebbc4e98e0674457d03adc62821568c 100644 (file)
@@ -41,6 +41,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.Getter;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.ui.components.JBList;
 import com.intellij.util.ui.UIUtil;
@@ -335,4 +336,9 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
       return myConfiguration.getLogFiles();
     }
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return Registry.is("dumb.aware.run.configurations");
+  }
 }
index d7f87bf55f300894731f94e57874aab1a0784e13..dd451323226d9a4b67078e47d49d65ad67ac5546 100644 (file)
@@ -710,4 +710,7 @@ idea.regexp.search.uses.indices=true
 idea.regexp.search.uses.indices.description=Should Idea find in path use indices when searching with regular expression
 
 idea.io.safe.sync=true
-idea.io.safe.sync.description=When "Safe Write" is enabled, sync() is invoked after the last write to flush data to disk
\ No newline at end of file
+idea.io.safe.sync.description=When "Safe Write" is enabled, sync() is invoked after the last write to flush data to disk
+
+dumb.aware.run.configurations=false
+dumb.aware.run.configurations.description=Enable executing run configurations in dumb mode
index 7869ea026ab9cb21ae13936b7ad5ea2d4640398b..3ad8698f026f79b0d9a6aa4c5a972bceeb55d752 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.ToggleAction;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.xdebugger.impl.DebuggerSupport;
 import org.jetbrains.annotations.NotNull;
 
@@ -66,4 +67,9 @@ public class MuteBreakpointAction extends ToggleAction {
     }
     e.getPresentation().setEnabled(false);
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return Registry.is("dumb.aware.run.configurations");
+  }
 }
index acd90686701d0ec340f874fec5bc1d171b1de118..e8e4617011c2656654a6c30940ae8dabfd37525a 100644 (file)
@@ -15,8 +15,8 @@
  */
 package com.intellij.xdebugger.impl.actions;
 
-import org.jetbrains.annotations.NotNull;
 import com.intellij.xdebugger.impl.DebuggerSupport;
+import org.jetbrains.annotations.NotNull;
 
 /**
  * @author nik
index 461ce018cb00ba9bb55ee179895e0c95b1589694..c82edb45b1470adbcab01de6a4f348aad032ac92 100644 (file)
@@ -27,4 +27,9 @@ public class StepOverAction extends XDebuggerActionBase implements DumbAware {
   protected DebuggerActionHandler getHandler(@NotNull final DebuggerSupport debuggerSupport) {
     return debuggerSupport.getStepOverHandler();
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return true;
+  }
 }
index 8be7db3c59c68349f01c0649ca71ad2cff6a7c01..48b58386db1291698f709a5ba7e0a1aa2e24dfeb 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.xdebugger.impl.DebuggerSupport;
 import org.jetbrains.annotations.NotNull;
 
@@ -110,4 +111,9 @@ public abstract class XDebuggerActionBase extends AnAction implements AnAction.T
     }
     return true;
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return Registry.is("dumb.aware.run.configurations");
+  }
 }
index aff4c81c0b365d44dc0ca0be85592edd828809bb..9f2c09bb537c7fac237ddf13cd909a45fd09671e 100644 (file)
@@ -18,8 +18,11 @@ package com.intellij.codeInspection;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Condition;
 import com.intellij.psi.*;
+import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.psi.util.MethodSignatureUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
+import com.intellij.refactoring.util.InlineUtil;
 import com.intellij.refactoring.util.LambdaRefactoringUtil;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
@@ -60,25 +63,59 @@ public class TrivialFunctionalExpressionUsageInspection extends BaseJavaBatchLoc
         });
       }
 
-      private void doCheckMethodCallOnFunctionalExpression(PsiFunctionalExpression expression,
+      @Override
+      public void visitAnonymousClass(final PsiAnonymousClass aClass) {
+        if (AnonymousCanBeLambdaInspection.canBeConvertedToLambda(aClass, false)) {
+          final PsiElement newExpression = aClass.getParent();
+          doCheckMethodCallOnFunctionalExpression(new Condition<PsiElement>() {
+            @Override
+            public boolean value(PsiElement ggParent) {
+              final PsiMethod method = aClass.getMethods()[0];
+              final PsiCodeBlock body = method.getBody();
+              final PsiReturnStatement[] returnStatements = PsiUtil.findReturnStatements(body);
+              if (returnStatements.length > 1) {
+                return false;
+              }
+              final PsiElement callParent = ggParent.getParent();
+              return callParent instanceof PsiStatement ||
+                     callParent instanceof PsiLocalVariable;
+            }
+          }, newExpression, aClass.getBaseClassType(), "Replace call with method body");
+        }
+      }
+
+      private void doCheckMethodCallOnFunctionalExpression(PsiElement expression,
                                                            Condition<PsiElement> elementContainerCondition) {
         final PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
         if (parent instanceof PsiTypeCastExpression) {
-          final PsiElement gParent = PsiUtil.skipParenthesizedExprUp(parent.getParent());
-          if (gParent instanceof PsiReferenceExpression) {
-            final PsiElement ggParent = gParent.getParent();
-            if (ggParent instanceof PsiMethodCallExpression) {
-              final PsiMethod resolveMethod = ((PsiMethodCallExpression)ggParent).resolveMethod();
-              final PsiElement referenceNameElement = ((PsiMethodCallExpression)ggParent).getMethodExpression().getReferenceNameElement();
-              if (resolveMethod != null &&
-                  resolveMethod.getParameterList().getParametersCount() == 0 && //todo pass args as parameters
-                  resolveMethod == LambdaUtil.getFunctionalInterfaceMethod(((PsiTypeCastExpression)parent).getType()) &&
-                  referenceNameElement != null &&
-                  elementContainerCondition.value(ggParent)) {
+          final PsiType interfaceType = ((PsiTypeCastExpression)parent).getType();
+          doCheckMethodCallOnFunctionalExpression(elementContainerCondition, parent, interfaceType,
+                                                  "Replace method call " + 
+                                                  (expression instanceof PsiLambdaExpression ? "on lambda with lambda body"
+                                                                                             : "on method reference with corresponding method call"));
+        }
+      }
+
+      private void doCheckMethodCallOnFunctionalExpression(Condition<PsiElement> elementContainerCondition,
+                                                           PsiElement parent,
+                                                           PsiType interfaceType, 
+                                                           String quickFixName) {
+        final PsiElement gParent = PsiUtil.skipParenthesizedExprUp(parent.getParent());
+        if (gParent instanceof PsiReferenceExpression) {
+          final PsiElement ggParent = gParent.getParent();
+          if (ggParent instanceof PsiMethodCallExpression) {
+            final PsiMethod resolveMethod = ((PsiMethodCallExpression)ggParent).resolveMethod();
+            final PsiElement referenceNameElement = ((PsiMethodCallExpression)ggParent).getMethodExpression().getReferenceNameElement();
+            if (resolveMethod != null &&
+                !resolveMethod.isVarArgs() &&
+                ((PsiMethodCallExpression)ggParent).getArgumentList().getExpressions().length == resolveMethod.getParameterList().getParametersCount() &&
+                referenceNameElement != null &&
+                elementContainerCondition.value(ggParent)) {
+              final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(interfaceType);
+              if (resolveMethod == interfaceMethod || 
+                  interfaceMethod != null && MethodSignatureUtil.isSuperMethod(interfaceMethod, resolveMethod)) {
                 final ReplaceWithLambdaBodyFix fix = 
-                  new ReplaceWithLambdaBodyFix("Replace method call " +
-                                               (expression instanceof PsiLambdaExpression ? "on lambda with lambda body" 
-                                                                                          : "on method reference with corresponding method call"));
+                  new ReplaceWithLambdaBodyFix(quickFixName);
                 holder.registerProblem(referenceNameElement, "Method call can be simplified", fix);
               }
             }
@@ -125,10 +162,21 @@ public class TrivialFunctionalExpressionUsageInspection extends BaseJavaBatchLoc
             replaceWithLambdaBody(callExpression, lambdaExpression);
           }
         }
+        else if (qualifierExpression instanceof PsiNewExpression) {
+          final PsiExpression cast = AnonymousCanBeLambdaInspection.replacePsiElementWithLambda(qualifierExpression, true, false);
+          if (cast instanceof PsiTypeCastExpression) {
+            final PsiExpression lambdaExpression = ((PsiTypeCastExpression)cast).getOperand();
+            if (lambdaExpression instanceof PsiLambdaExpression) {
+              replaceWithLambdaBody(callExpression, (PsiLambdaExpression)lambdaExpression);
+            }
+          }
+        }
       }
     }
 
     private static void replaceWithLambdaBody(PsiMethodCallExpression callExpression, PsiLambdaExpression element) {
+      inlineCallArguments(callExpression, element);
+
       final PsiElement body = element.getBody();
       if (body instanceof PsiExpression) {
         callExpression.replace(body);
@@ -170,5 +218,20 @@ public class TrivialFunctionalExpressionUsageInspection extends BaseJavaBatchLoc
         }
       }
     }
+
+    private static void inlineCallArguments(PsiMethodCallExpression callExpression, PsiLambdaExpression element) {
+      final PsiExpression[] args = callExpression.getArgumentList().getExpressions();
+      final PsiParameter[] parameters = element.getParameterList().getParameters();
+      for (int i = 0; i < parameters.length; i++) {
+        final PsiParameter parameter = parameters[i];
+        final PsiExpression initializer = args[i];
+        for (PsiReference reference : ReferencesSearch.search(parameter)) {
+          final PsiElement referenceElement = reference.getElement();
+          if (referenceElement instanceof PsiJavaCodeReferenceElement) {
+            InlineUtil.inlineVariable(parameter, initializer, (PsiJavaCodeReferenceElement)referenceElement);
+          }
+        }
+      }
+    }
   }
 }
index a6ae84e1f536c3549c5d3a71847d647aa525ae04..396054aad72aaf9730a8435d0a76354e99ee4740 100644 (file)
@@ -22,7 +22,6 @@ import com.intellij.analysis.BaseAnalysisActionDialog;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.module.Module;
@@ -165,12 +164,7 @@ public class UpdateCopyrightAction extends BaseAnalysisAction {
             @Override
             public void run() {
               CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
-              ApplicationManager.getApplication().runWriteAction(new Runnable() {
-                @Override
-                public void run() {
-                  ProgressManager.getInstance().run(progressTask);
-                }
-              });
+              ProgressManager.getInstance().run(progressTask);
             }
           }, getTemplatePresentation().getText(), null);
         }
index c99257b150db421276763af3a73a8b41bf03dc3d..b158ab21b72c94cb01e46b4686cb0164b7cfd2a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 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.
@@ -210,7 +210,10 @@ public class GroovyFoldingBuilder extends CustomFoldingBuilder implements DumbAw
         int end = marker.getTextRange().getEndOffset();
         int tail = "import ".length();
         if (start + tail < end && !JavaFoldingBuilderBase.hasErrorElementsNearby(first.getContainingFile(), start, end)) {
-          descriptors.add(new FoldingDescriptor(first.getNode(), new TextRange(start + tail, end)));
+          FoldingDescriptor descriptor = new FoldingDescriptor(first.getNode(), new TextRange(start + tail, end));
+          // imports are often added/removed automatically, so we enable autoupdate of folded region for foldings even if it's collapsed
+          descriptor.setCanBeRemovedWhenCollapsed(true);
+          descriptors.add(descriptor);
         }
       }
       while (!(next instanceof GrImportStatement) && next != null) next = next.getNextSibling();
index 10648aae1a41036fa065c5abca009bc232e285c9..91b76b9a7a1445fdcd3c25b0e896c05820821076 100644 (file)
@@ -70,11 +70,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
            "##teamcity[testSuiteStarted name='TestA']\n" +
            "##teamcity[testSuiteStarted name='|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestA.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0|]']\n" +
            "##teamcity[testSuiteFinished name='|[0|]']\n" +
            "##teamcity[testSuiteStarted name='|[1|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[1|]' locationHint='java:test://a.TestA.testName|[1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[1|]']\n" +
@@ -82,11 +84,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[testSuiteFinished name='TestA']\n" +
            "##teamcity[testSuiteStarted name='TestB']\n" +
            "##teamcity[testSuiteStarted name='|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestB.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0|]']\n" +
            "##teamcity[testSuiteFinished name='|[0|]']\n" +
            "##teamcity[testSuiteStarted name='|[1|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[1|]' locationHint='java:test://a.TestB.testName|[1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[1|]']\n" +
@@ -116,9 +120,11 @@ public class JUnitTreeByDescriptionHierarchyTest {
     sender.testRunFinished(new Result());
     Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
                                           "##teamcity[testSuiteStarted name='ATest' locationHint='java:suite://ATest']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='ATest.test1' locationHint='java:test://ATest.test1']\n" +
                                           "\n" +
                                           "##teamcity[testFinished name='ATest.test1']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='ATest.test2' locationHint='java:test://ATest.test2']\n" +
                                           "\n" +
                                           "##teamcity[testFinished name='ATest.test2']\n" +
@@ -146,11 +152,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
                                    "##teamcity[treeEnded]\n",
            "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
            "##teamcity[testSuiteStarted name='MyTest']\n" +
+           "\n" +
            "##teamcity[testStarted name='MyTest.testMe' locationHint='java:test://a.MyTest.testMe']\n" +
            "\n" +
            "##teamcity[testFinished name='MyTest.testMe']\n" +
            "##teamcity[testSuiteFinished name='MyTest']\n" +
            "##teamcity[testSuiteStarted name='MyTest']\n" +
+           "\n" +
            "##teamcity[testStarted name='MyTest.testMe' locationHint='java:test://b.MyTest.testMe']\n" +
            "\n" +
            "##teamcity[testFinished name='MyTest.testMe']\n" +
@@ -177,11 +185,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
            //start
            "##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" +
            "##teamcity[testSuiteStarted name='|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestA.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0|]']\n" +
            "##teamcity[testSuiteFinished name='|[0|]']\n" +
            "##teamcity[testSuiteStarted name='|[1|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[1|]' locationHint='java:test://a.TestA.testName|[1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[1|]']\n" +
@@ -213,11 +223,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
            //start
            "##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" +
            "##teamcity[testSuiteStarted name='|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestA.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0|]']\n" +
            "##teamcity[testSuiteFinished name='|[0|]']\n" +
            "##teamcity[testSuiteStarted name='|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestA.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0|]']\n" +
@@ -249,11 +261,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
            //start
            "##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" +
            "##teamcity[testSuiteStarted name='|[0: with - 1.1|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0: with - 1.1|]' locationHint='java:test://a.TestA.testName|[0: with - 1.1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0: with - 1.1|]']\n" +
            "##teamcity[testSuiteFinished name='|[0: with - 1.1|]']\n" +
            "##teamcity[testSuiteStarted name='|[1: with - 2.1|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[1: with - 2.1|]' locationHint='java:test://a.TestA.testName|[1: with - 2.1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[1: with - 2.1|]']\n" +
@@ -295,6 +309,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
            "##teamcity[testSuiteStarted name='ASuite1']\n" +
            "##teamcity[testSuiteStarted name='ATest']\n" +
+           "\n" +
            "##teamcity[testStarted name='ATest.test1' locationHint='java:test://ATest.test1']\n" +
            "\n" +
            "##teamcity[testFinished name='ATest.test1']\n" +
@@ -302,6 +317,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[testSuiteFinished name='ASuite1']\n" +
            "##teamcity[testSuiteStarted name='ASuite2']\n" +
            "##teamcity[testSuiteStarted name='ATest']\n" +
+           "\n" +
            "##teamcity[testStarted name='ATest.test1' locationHint='java:test://ATest.test1']\n" +
            "\n" +
            "##teamcity[testFinished name='ATest.test1']\n" +
@@ -356,6 +372,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
 
     Assert.assertEquals("output: " + buf, "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
                                           "##teamcity[testSuiteStarted name='TestA']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
                                           "\n" +
                                           "##teamcity[testIgnored name='TestA.testName' details='java.lang.Exception|n' error='true' message='']\n" +
@@ -397,6 +414,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
                                           "\n" +
                                           "##teamcity[testFinished name='Class Configuration']\n" +
                                           "##teamcity[testSuiteStarted name='TestA']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
                                           "\n" +
                                           "##teamcity[testIgnored name='TestA.testName']\n" +
@@ -435,6 +453,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
 
     Assert.assertEquals("output: " + buf, "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
                                           "##teamcity[testSuiteStarted name='TestA']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
                                           "\n" +
                                           "##teamcity[testFinished name='TestA.testName']\n" +
@@ -479,6 +498,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
     Assert.assertEquals("output: " + buf, "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
                                           "##teamcity[testSuiteStarted name='TestA']\n" +
                                           "##teamcity[testSuiteStarted name='param']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
                                           "\n" +
                                           "##teamcity[testIgnored name='TestA.testName' details='java.lang.Exception|n' error='true' message='']\n" +
@@ -506,6 +526,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[enteredTheMatrix]\n" +
            "##teamcity[treeEnded]\n",
            "##teamcity[rootName name = 'TestA' location = 'java:suite://TestA']\n" +
+           "\n" +
            "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
            "\n" +
            "##teamcity[testFinished name='TestA.testName']\n");
@@ -535,11 +556,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
 
     Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
                                           "##teamcity[testSuiteStarted name='TestA' locationHint='java:suite://a.TestA']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='TestA.testName' locationHint='java:test://a.TestA.testName']\n" +
                                           "\n" +
                                           "##teamcity[testFinished name='TestA.testName']\n" +
                                           "##teamcity[testSuiteFinished name='TestA']\n" +
                                           "##teamcity[testSuiteStarted name='TestB' locationHint='java:suite://a.TestB']\n" +
+                                          "\n" +
                                           "##teamcity[testStarted name='TestB.testName' locationHint='java:test://a.TestB.testName']\n" +
                                           "\n" +
                                           "##teamcity[testFinished name='TestB.testName']\n" +
@@ -587,9 +610,11 @@ public class JUnitTreeByDescriptionHierarchyTest {
 
            "##teamcity[rootName name = 'ATest' location = 'java:suite://ATest']\n" +
            "##teamcity[testSuiteStarted name='testName']\n" +
+           "\n" +
            "##teamcity[testStarted name='ATest.testName|[0|]' locationHint='java:test://ATest.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='ATest.testName|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='ATest.testName|[1|]' locationHint='java:test://ATest.testName|[1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='ATest.testName|[1|]']\n" +
@@ -631,11 +656,13 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
            "##teamcity[testSuiteStarted name='ATest']\n" +
            "##teamcity[testSuiteStarted name='|[0|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://ATest.testName|[0|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[0|]']\n" +
            "##teamcity[testSuiteFinished name='|[0|]']\n" +
            "##teamcity[testSuiteStarted name='|[1|]']\n" +
+           "\n" +
            "##teamcity[testStarted name='testName|[1|]' locationHint='java:test://ATest.testName|[1|]']\n" +
            "\n" +
            "##teamcity[testFinished name='testName|[1|]']\n" +
@@ -643,6 +670,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[testSuiteFinished name='ATest']\n" +
            "##teamcity[testSuiteStarted name='suite']\n" +
            "##teamcity[testSuiteStarted name='ATest']\n" +
+           "\n" +
            "##teamcity[testStarted name='ATest.test' locationHint='java:test://ATest.test']\n" +
            "\n" +
            "##teamcity[testFinished name='ATest.test']\n" +
@@ -679,6 +707,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
            "##teamcity[treeEnded]\n",
 
            "##teamcity[rootName name = 'TestA' location = 'java:suite://TestA']\n" +
+           "\n" +
            "##teamcity[testStarted name='TestSuite$1.warning' locationHint='java:test://junit.framework.TestSuite$1.warning']\n" +
            "\n" +
            "##teamcity[testFinished name='TestSuite$1.warning']\n");
index ac1e31f3ba83c70285a908eb31500b4c2a8d0f87..bcb71b321c60227546230c9e8682429bcefc9828 100644 (file)
@@ -128,7 +128,7 @@ public class JUnit4TestListener extends RunListener {
       }
     }
 
-    myPrintStream.println("##teamcity[testStarted name=\'" + escapeName(methodName) + "\' " + 
+    myPrintStream.println("\n##teamcity[testStarted name=\'" + escapeName(methodName) + "\' " + 
                           getTestMethodLocation(methodName, classFQN) + "]");
     myCurrentTestStart = currentTime();
   }
index f55135f823e77e99223a0e7e22cb571ea2bfc037..c0dd43f396b25028895cd8691d60e5d76caa32fb 100644 (file)
@@ -1,7 +1,8 @@
 package org.jetbrains.yaml.lexer;
 
 import com.intellij.lexer.Lexer;
-import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.testFramework.LexerTestCase;
 
 public class YAMLLexerTest extends LexerTestCase {
@@ -12,7 +13,8 @@ public class YAMLLexerTest extends LexerTestCase {
 
   @Override
   protected String getDirPath() {
-    return PluginPathManager.getPluginHomePathRelative("yaml") + "/testSrc/org/jetbrains/yaml/lexer/data";
+    return (PathManagerEx.getCommunityHomePath() + "/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/")
+      .substring(PathManager.getHomePath().length());
   }
 
   public void test2docs() {
index 6c6973af024423705722a9f32698c01832f612ba..f38de53a2d6fe9ec257c48ca703b24c61465a3ea 100644 (file)
@@ -1,6 +1,6 @@
 package org.jetbrains.yaml.parser;
 
-import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.testFramework.ParsingTestCase;
 import org.jetbrains.yaml.YAMLParserDefinition;
 
@@ -16,7 +16,7 @@ public class YAMLParserTest extends ParsingTestCase {
   }
 
   protected String getTestDataPath() {
-    return PluginPathManager.getPluginHomePath("yaml") + "/testSrc/org/jetbrains/yaml/parser/data/";
+    return PathManagerEx.getCommunityHomePath() + "/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/";
   }
 
   public void test2docs() throws Throwable {
index ed173e7908128e08b70b75b36a53db9b16bbaf33..e3f18742529b81426e764eca9c0e0f05fced0c0b 100644 (file)
@@ -1,6 +1,6 @@
 package org.jetbrains.yaml.psi;
 
-import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
@@ -9,7 +9,7 @@ import org.jetbrains.yaml.YAMLParserDefinition;
 public class YAMLScalarContentTest extends LightPlatformCodeInsightFixtureTestCase {
   @Override
   protected String getTestDataPath() {
-    return PluginPathManager.getPluginHomePath("yaml") + "/testSrc/org/jetbrains/yaml/psi/data/";
+    return PathManagerEx.getCommunityHomePath() + "/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/";
   }
 
   @Override
index 497574aa0e0054288e8543f2761b44187a0c016f..7f6f663eb59b740faaf6e33d19e0da613b0a8da2 100644 (file)
@@ -1,6 +1,6 @@
 package org.jetbrains.yaml.psiModification;
 
-import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -14,7 +14,7 @@ import org.jetbrains.yaml.psi.YAMLMapping;
 public class YAMLMappingModificationTest extends LightPlatformCodeInsightFixtureTestCase {
   @Override
   protected String getTestDataPath() {
-    return PluginPathManager.getPluginHomePath("yaml") + "/testSrc/org/jetbrains/yaml/psiModification/data/";
+    return PathManagerEx.getCommunityHomePath() + "/plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/";
   }
 
   @Override
index 2df69b4351ded95db39bec6c4e3805c40e576136..ff4a79ec52ad37d86a46c5162f55a453b5223914 100644 (file)
@@ -232,6 +232,9 @@ if __name__ == "__main__":
 
     command_args = list(filter(None, sys.argv[1:]))
     if command_args:
+        if "--junit" in command_args:
+            raise Exception("--junit report type for Behave is unsupported in PyCharm. \n "
+            "See: https://youtrack.jetbrains.com/issue/PY-14219")
         _bdd_utils.fix_win_drive(command_args[0])
     (base_dir, scenario_names, what_to_run) = _bdd_utils.get_what_to_run_by_env(os.environ)
 
index c4eb05808086a341c8c9d5b7d27fb2d9cd0b40e1..d47a36060560985b71486416e747f2fd848b2a11 100644 (file)
@@ -109,7 +109,7 @@ public class CreateTestAction extends PsiElementBaseIntentionAction {
     CommandProcessor.getInstance().executeCommand(project, new Runnable() {
       @Override
       public void run() {
-        PsiFile e = PyTestCreator.generateTest(project, d);
+        PsiFile e = PyTestCreator.generateTestAndNavigate(project, d);
         final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
         documentManager.commitAllDocuments();
       }
index 2e1c623cc5686a86c520e677dfa2cefa98148d9c..331db84528cb32fd4a197e63086cac1a9e7efc26 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.util.IncorrectOperationException;
 import com.jetbrains.python.PythonFileType;
 import com.jetbrains.python.codeInsight.imports.AddImportHelper;
 import com.jetbrains.python.psi.*;
+import org.jetbrains.annotations.NotNull;
 
 import java.util.List;
 
@@ -43,11 +44,13 @@ public class PyTestCreator implements TestCreator {
   public boolean isAvailable(Project project, Editor editor, PsiFile file) {
     CreateTestAction action = new CreateTestAction();
     PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
-    if (element != null)
+    if (element != null) {
       return action.isAvailable(project, editor, element);
+    }
     return false;
   }
 
+  @Override
   public void createTest(Project project, Editor editor, PsiFile file) {
     try {
       CreateTestAction action = new CreateTestAction();
@@ -61,41 +64,20 @@ public class PyTestCreator implements TestCreator {
     }
   }
 
-  public static PsiFile generateTest(final Project project, final CreateTestDialog dialog) {
+  /**
+   * Generates test, puts it into file and navigates to newly created class
+   *
+   * @return file with test
+   */
+  static PsiFile generateTestAndNavigate(@NotNull final Project project, @NotNull final CreateTestDialog dialog) {
     return PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(new Computable<PsiFile>() {
       public PsiFile compute() {
         return ApplicationManager.getApplication().runWriteAction(new Computable<PsiFile>() {
           public PsiFile compute() {
             try {
-              IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();
-
-              String fileName = dialog.getFileName();
-              if (!fileName.endsWith(".py"))
-                fileName = fileName + "." + PythonFileType.INSTANCE.getDefaultExtension();
-
-              StringBuilder fileText = new StringBuilder();
-              fileText.append("class ").append(dialog.getClassName()).append("(TestCase):\n\t");
-              List<String> methods = dialog.getMethods();
-              if (methods.size() == 0)
-                fileText.append("pass\n");
-
-              for (String method : methods) {
-                fileText.append("def ").append(method).append("(self):\n\tself.fail()\n\n\t");
-              }
-
-              PsiFile psiFile = PyUtil.getOrCreateFile(
-                dialog.getTargetDir() + "/" + fileName, project);
-              AddImportHelper.addOrUpdateFromImportStatement(psiFile, "unittest", "TestCase", null, AddImportHelper.ImportPriority.BUILTIN,
-                                                             null);
-
-              PyElement createdClass = PyElementGenerator.getInstance(project).createFromText(
-                LanguageLevel.forElement(psiFile), PyClass.class, fileText.toString());
-              createdClass = (PyElement)psiFile.addAfter(createdClass, psiFile.getLastChild());
-
-              PostprocessReformattingAspect.getInstance(project).doPostponedFormatting(psiFile.getViewProvider());
-              CodeStyleManager.getInstance(project).reformat(psiFile);
-              createdClass.navigate(false);
-              return psiFile;
+              final PyElement testClass = generateTest(project, dialog);
+              testClass.navigate(false);
+              return testClass.getContainingFile();
             }
             catch (IncorrectOperationException e) {
               LOG.warn(e);
@@ -106,4 +88,43 @@ public class PyTestCreator implements TestCreator {
       }
     });
   }
+
+  /**
+   * Generates test, puts it into file and returns class element for test
+   *
+   * @return newly created test class
+   */
+  @NotNull
+  static PyElement generateTest(@NotNull final Project project, @NotNull final CreateTestDialog dialog) {
+    IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();
+
+    String fileName = dialog.getFileName();
+    if (!fileName.endsWith(".py")) {
+      fileName = fileName + "." + PythonFileType.INSTANCE.getDefaultExtension();
+    }
+
+    StringBuilder fileText = new StringBuilder();
+    fileText.append("class ").append(dialog.getClassName()).append("(TestCase):\n\t");
+    List<String> methods = dialog.getMethods();
+    if (methods.size() == 0) {
+      fileText.append("pass\n");
+    }
+
+    for (String method : methods) {
+      fileText.append("def ").append(method).append("(self):\n\tself.fail()\n\n\t");
+    }
+
+    PsiFile psiFile = PyUtil.getOrCreateFile(
+      dialog.getTargetDir() + "/" + fileName, project);
+    AddImportHelper.addOrUpdateFromImportStatement(psiFile, "unittest", "TestCase", null, AddImportHelper.ImportPriority.BUILTIN,
+                                                   null);
+
+    PyElement createdClass = PyElementGenerator.getInstance(project).createFromText(
+      LanguageLevel.forElement(psiFile), PyClass.class, fileText.toString());
+    createdClass = (PyElement)psiFile.addAfter(createdClass, psiFile.getLastChild());
+
+    PostprocessReformattingAspect.getInstance(project).doPostponedFormatting(psiFile.getViewProvider());
+    CodeStyleManager.getInstance(project).reformat(psiFile);
+    return createdClass;
+  }
 }
index bb2b0aebeadff1894f9937aea715f69ebb32e825..6fad5638e9d0353702599c8e14e11b02ff2d6fbd 100644 (file)
@@ -1310,7 +1310,7 @@ public class PyUtil {
         );
       }
       catch (IOException e) {
-        throw new IncorrectOperationException(String.format("Cannot create file '%s'", path));
+        throw new IncorrectOperationException(String.format("Cannot create file '%s'", path), (Throwable)e);
       }
     }
     else {
diff --git a/python/testData/create_tests/create_tst.expected.py b/python/testData/create_tests/create_tst.expected.py
new file mode 100644 (file)
index 0000000..b09ba84
--- /dev/null
@@ -0,0 +1,9 @@
+from unittest import TestCase
+
+
+class Spam(TestCase):
+    def eggs(self):
+        self.fail()
+
+    def eggs_and_ham(self):
+        self.fail()
diff --git a/python/testData/create_tests/create_tst.py b/python/testData/create_tests/create_tst.py
new file mode 100644 (file)
index 0000000..97ec6bd
--- /dev/null
@@ -0,0 +1,6 @@
+class Spam:
+    def eggs(self):
+        pass
+
+    def eggs_and_ham(self):
+        pass
\ No newline at end of file
diff --git a/python/testSrc/com/jetbrains/python/codeInsight/testIntegration/PyTestCreatorTest.java b/python/testSrc/com/jetbrains/python/codeInsight/testIntegration/PyTestCreatorTest.java
new file mode 100644 (file)
index 0000000..33fd657
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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.jetbrains.python.codeInsight.testIntegration;
+
+import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiFile;
+import com.jetbrains.python.fixtures.PyTestCase;
+import org.easymock.IMocksControl;
+
+import java.util.Arrays;
+
+import static org.easymock.classextension.EasyMock.createNiceControl;
+import static org.easymock.classextension.EasyMock.expect;
+
+/**
+ * Checks how test classes are created
+ * @author Ilya.Kazakevich
+ */
+public final class PyTestCreatorTest extends PyTestCase {
+  public void testCreateTest() throws Exception {
+
+    myFixture.configureByFile("/create_tests/create_tst.py");
+    final IMocksControl mockControl = createNiceControl();
+
+    final CreateTestDialog dialog = mockControl.createMock(CreateTestDialog.class);
+    expect(dialog.getFileName()).andReturn("tests.py").anyTimes();
+    expect(dialog.getClassName()).andReturn("Spam").anyTimes();
+    // Target dir is first module source
+    final VirtualFile root = ModuleRootManager.getInstance(myFixture.getModule()).getSourceRoots()[0];
+    expect(dialog.getTargetDir()).andReturn(root.getCanonicalPath()).anyTimes();
+    expect(dialog.getMethods()).andReturn(Arrays.asList("eggs", "eggs_and_ham")).anyTimes();
+    mockControl.replay();
+
+
+    WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
+      final PsiFile file = PyTestCreator.generateTest(myFixture.getProject(), dialog).getContainingFile();
+      myFixture.configureByText(file.getFileType(), file.getText());
+      myFixture.checkResultByFile("/create_tests/create_tst.expected.py");
+    });
+  }
+}
index cd726d57151fbf795e10b70ab9d50269b4d958ed..200cbcaa84fc8d385e7dfa16e9367c51a66e71ea 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 <body>
-               This inspection reports any accesses of fields declared as @net.jcip.annotations.GuardedBy
+               This inspection reports any accesses of fields declared as @GuardedBy (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation)
                 which are are not guarded by an appropriate synchronization structure.
 </body>
 </html>
\ No newline at end of file
index 565f32dfac3f06057d267e7c654f82afeb646fc6..1e20e035b3b944e0fc2c8931d235c93cd4c20f24 100644 (file)
@@ -1,10 +1,7 @@
 <html>
 <body>
-               This inspection reports any @net.jcip.annotations.GuardedBy annotations on instance fields or methods,
-                where
-                the guard is a static field. Guarding a non-static by a static may result in excessive lock contention,
-                as access to each locked field in any object instance will prevent simultaneous access to that field in
-                every object
-                instance.
+               This inspection reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) on instance fields or methods,
+                where the guard is a static field. Guarding a non-static by a static may result in excessive lock contention,
+                as access to each locked field in any object instance will prevent simultaneous access to that field in every object instance.
 </body>
 </html>
\ No newline at end of file
index a0b877f4f440b29057fb86d5eb46b228bd12fb93..d085c642f3d7da90441e379a64ccb83176b87b11 100644 (file)
@@ -1,7 +1,6 @@
 <html>
 <body>
-                This inspection reports any non-final field in a class with annotation
-                @net.jcip.annotations.Immutable. This violates the contract of the @Immutable
-                annotation.
+                This inspection reports any non-final field in a class with @Immutable annotation
+                (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation). This violates the contract of the @Immutable annotation.
 </body>
 </html>
\ No newline at end of file
index aa0e3e7c3cf252dbfe53467e6ccecb9e2473219d..3ed2b07ff6b0abd6bffcd1da5cc0d419f1729cc5 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 <body>
-               This inspection reports any @net.jcip.annotations.GuardedBy annotations where the guarding field
+               This inspection reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) annotations where the guarding field
                 is not final. Gaurding on a non-final field may result in unexpected race conditions, as locks will
                 be held on the value of the field (which may change), rather than the field itself.
 </body>
index d2efdbc2b6c9bb85202b59d4008fab050e2e1311..d714c93aecbd29bfe599ae79ba88e13c7e9a212d 100644 (file)
@@ -1,11 +1,7 @@
 <html>
 <body>
-                This inspection reports any @net.jcip.annotations.GuardedBy annotations on static fields or methods,
-                where
-                the guard is either a non-static field or 'this'. Guarding a static by a non-static may result in
-                excessive
-                concurrency, multiple threads may be able to access the guarded field simultaneously, by locking in
-                different
-                object contexts.
+                This inspection reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) on static fields or methods,
+                where the guard is either a non-static field or 'this'. Guarding a static by a non-static may result in
+                excessive concurrency, multiple threads may be able to access the guarded field simultaneously, by locking in different object contexts.
 </body>
 </html>
\ No newline at end of file
index fa76c83a3bff9021480c2a633992a62165f9e598..dff5e1388fe0bcc9b0fcbce69500b96b630a0086 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 <body>
-                This inspection reports any @net.jcip.annotations.GuardedBy annotations where the guarding field
+                This inspection reports any @GuardedBy annotations (net.jcip.annotations|javax.annotation.concurrent|org.apache.http.annotation) where the guarding field
                 is unknown.
 </body>
 </html>
\ No newline at end of file