Merge remote-tracking branch 'origin/master'
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Mon, 17 Oct 2016 16:14:28 +0000 (19:14 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Mon, 17 Oct 2016 16:14:28 +0000 (19:14 +0300)
176 files changed:
build/groovy/org/jetbrains/intellij/build/BuildTasks.groovy
build/groovy/org/jetbrains/intellij/build/IdeaCommunityBuilder.groovy
build/groovy/org/jetbrains/intellij/build/ProductProperties.groovy
build/groovy/org/jetbrains/intellij/build/impl/BuildContextImpl.groovy
build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy
build/groovy/org/jetbrains/intellij/build/impl/CrossPlatformDistributionBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy
build/scripts/layouts.gant
java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousHasLambdaAlternativeInspection.java
java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/NullParameterConstraintChecker.java
java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java
java/java-analysis-impl/src/com/intellij/codeInspection/java18api/Java8CollectionsApiInspection.java
java/java-analysis-impl/src/com/intellij/codeInspection/java18api/ReplaceConditionalMapPutFix.java [moved from java/java-analysis-impl/src/com/intellij/codeInspection/java18api/ReplaceWithMapPutIfAbsentFix.java with 92% similarity]
java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java [new file with mode: 0644]
java/java-impl/src/com/intellij/ide/actions/JavaQualifiedNameProvider.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterAsLongStreamMap.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterBoxedForEach.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapBoxed.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapForEach.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMap.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapExpr.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapMR.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapToInt.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapToIntAsLongStream.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapToIntFlatMap.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeAsLongStreamMap.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeBoxedForEach.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeFlatMapForEach.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapBoxed.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapForEach.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMap.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapExpr.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapMR.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapToInt.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapTwoExpr.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapToIntAsLongStream.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapToIntFlatMap.java [new file with mode: 0644]
java/java-tests/testData/inspection/dataFlow/fixture/NullLiteralArgumentDoesntReportedWhenMethodOnlyThrowAnException.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inplaceIntroduceVariable/brokenFormattingWithInValidation.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inplaceIntroduceVariable/brokenFormattingWithInValidation_after.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/intention/InlineStreamMapActionTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionSchemeTest.kt
java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceVariableTest.java
java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java
java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/QuickFixTestCase.java
platform/analysis-api/src/com/intellij/profile/Profile.java
platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt
platform/configuration-store-impl/src/SchemeManagerImpl.kt
platform/core-api/src/com/intellij/openapi/util/Iconable.java
platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
platform/core-api/src/com/intellij/openapi/vfs/DeprecatedVirtualFileSystem.java
platform/core-api/src/com/intellij/psi/CommonClassNames.java
platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java
platform/diff-impl/src/com/intellij/diff/comparison/ComparisonMergeUtil.java
platform/diff-impl/src/com/intellij/diff/comparison/MergeResolveUtil.kt
platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java
platform/diff-impl/tests/com/intellij/diff/comparison/MergeResolveUtilTest.kt
platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt
platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryEditor.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java
platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureProcessorBase.java
platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java
platform/lang-impl/src/com/intellij/util/indexing/ValueContainerMap.java
platform/lvcs-impl/src/com/intellij/history/integration/IdeaGateway.java
platform/platform-api/src/com/intellij/credentialStore/CredentialAttributes.kt
platform/platform-api/src/com/intellij/openapi/MnemonicWrapper.java
platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java
platform/platform-api/src/com/intellij/ui/content/ContentManager.java
platform/platform-impl/src/com/intellij/codeInsight/hint/HintUtil.java
platform/platform-impl/src/com/intellij/diagnostic/JetBrainsAccountDialog.kt
platform/platform-impl/src/com/intellij/ide/dnd/TransferableList.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/AsyncEditorLoader.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/StripeButtonUI.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java
platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuItemUI.java
platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkMenuUI.java
platform/platform-impl/src/com/intellij/ui/plaf/gtk/GtkPaintingUtil.java
platform/platform-impl/src/com/intellij/ui/plaf/gtk/IconWrapper.java
platform/platform-impl/src/com/intellij/ui/popup/MovablePopup.java
platform/platform-resources-en/src/messages/CodeInsightBundle.properties
platform/projectModel-impl/src/com/intellij/configurationStore/scheme-impl.kt
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java
platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
platform/testFramework/src/com/intellij/testFramework/inspections.kt
platform/testFramework/testFramework.iml
platform/testFramework/testSrc/com/intellij/testFramework/assertJEx.kt
platform/util/resources/misc/registry.properties
platform/util/src/com/intellij/Patches.java
platform/util/src/com/intellij/util/io/CompressedAppendableFile.java
platform/util/src/com/intellij/util/ui/EmptyIcon.java
platform/vcs-api/src/com/intellij/openapi/localVcs/UpToDateLineNumberProvider.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateDiffViewerAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationPresentation.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AspectAnnotationFieldGutter.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CurrentRevisionAnnotationFieldGutter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ExtraFieldGutter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/HighlightedAdditionalColumn.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/HistoryIdColumn.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/MergeSourceAvailableMarkerGutter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShortNameType.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowShortenNames.java
platform/vcs-impl/src/com/intellij/openapi/vcs/annotate/TextAnnotationPresentation.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/InMemoryStorage.java
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/ShowGraphHistoryAction.java
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/AtomicFieldUpdaterIssuesInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/style/MethodRefCanBeReplacedWithLambdaInspection.java
plugins/copyright/src/com/maddyhome/idea/copyright/CopyrightProfile.java
plugins/eclipse/testData/iml/allProps/expected/expected.iml
plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseIml2ModulesTest.java
plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java
plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java
plugins/github/test/org/jetbrains/plugins/github/GithubRequestQueringTest.java [moved from plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java with 63% similarity]
plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt
plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/LegalNoticeDialog.java [deleted file]
plugins/settings-repository/src/IcsManager.kt
plugins/settings-repository/src/sync.kt
plugins/testng/src/com/theoryinpractice/testng/configuration/AbstractTestNGInClassConfigurationProducer.java
plugins/testng/src/com/theoryinpractice/testng/util/TestNGUtil.java
plugins/testng/testData/inspection/dependsOn/Dependencies.java
python/helpers/pydev/_pydevd_bundle/pydevd_signature.py
python/src/com/jetbrains/python/codeInsight/PySubstitutionChunkReference.java
python/src/com/jetbrains/python/codeInsight/PythonFormattedStringReferenceProvider.java
python/src/com/jetbrains/python/codeInsight/completion/PyDocstringCompletionContributor.java
python/src/com/jetbrains/python/codeInsight/completion/PyKeywordCompletionContributor.java
python/src/com/jetbrains/python/codeInsight/completion/PyStringFormatCompletionContributor.java
python/src/com/jetbrains/python/console/PyConsoleEnterHandler.kt
python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java
python/testData/completion/formatStringWithFormatModifier.after.py [new file with mode: 0644]
python/testData/completion/formatStringWithFormatModifier.py [new file with mode: 0644]
python/testData/completion/percentStringDictCallStringKey.after.py [new file with mode: 0644]
python/testData/completion/percentStringDictCallStringKey.py [new file with mode: 0644]
python/testData/completion/percentStringDictFuncKeys.py [new file with mode: 0644]
python/testData/completion/percentStringDictLiteralArgument.after.py [new file with mode: 0644]
python/testData/completion/percentStringDictLiteralArgument.py [new file with mode: 0644]
python/testData/completion/percentStringDictLiteralStringKey.after.py [new file with mode: 0644]
python/testData/completion/percentStringDictLiteralStringKey.py [new file with mode: 0644]
python/testData/completion/percentStringDictRefKeys.py [new file with mode: 0644]
python/testData/completion/percentStringDictWithDictLiteralArg.py [new file with mode: 0644]
python/testData/completion/percentStringDictWithListArg.py [new file with mode: 0644]
python/testData/completion/percentStringDictWithPackedDictLiteralArg.py [new file with mode: 0644]
python/testData/completion/percentStringDictWithZipCall.py [new file with mode: 0644]
python/testData/completion/percentStringWithDictCallArg.after.py [new file with mode: 0644]
python/testData/completion/percentStringWithDictCallArg.py [new file with mode: 0644]
python/testData/completion/percentStringWithDictLiteralArg.after.py [new file with mode: 0644]
python/testData/completion/percentStringWithDictLiteralArg.py [new file with mode: 0644]
python/testData/completion/percentStringWithModifiers.after.py [new file with mode: 0644]
python/testData/completion/percentStringWithModifiers.py [new file with mode: 0644]
python/testData/completion/percentStringWithParenDictCallArg.after.py [new file with mode: 0644]
python/testData/completion/percentStringWithParenDictCallArg.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/PyConsoleEnterHandlerTest.kt
python/testSrc/com/jetbrains/python/PythonCompletionTest.java
resources-en/src/intentionDescriptions/InlineStreamMapAction/after.java.template [new file with mode: 0644]
resources-en/src/intentionDescriptions/InlineStreamMapAction/before.java.template [new file with mode: 0644]
resources-en/src/intentionDescriptions/InlineStreamMapAction/description.html [new file with mode: 0644]
resources/src/META-INF/IdeaPlugin.xml

index 2f5bf5c79effae9e801b878adf01bb873c2c5f03..dc56e6436be0d7fbcdd61b1e474967e6cb2e5cad 100644 (file)
@@ -38,33 +38,11 @@ abstract class BuildTasks {
    */
   abstract void zipSourcesOfModules(Collection<String> modules, String targetFilePath)
 
-  /**
-   * Updates search/searchableOptions.xml file in {@code targetModuleName} module output directory
-   * <br>
-   * todo[nik] this is temporary solution until code from layouts.gant files moved to the new builders. After that this method will
-   * be called inside {@link #buildDistributions()}
-   */
-  abstract void buildSearchableOptions(String targetModuleName, List<String> modulesToIndex, List<String> pathsToLicenses)
-
-  /**
-   * Creates a copy of *ApplicationInfo.xml file with substituted __BUILD_NUMBER__ and __BUILD_DATE__ placeholders
-   * <br>
-   * todo[nik] this is temporary solution until code from layouts.gant files moved to the new builders. After that this method will
-   * be called inside {@link #buildDistributions()}
-   * @return path to the copied file
-   */
-  abstract File patchApplicationInfo()
-
-  /**
-   * Creates distribution for all operating systems from JAR files located at {@link BuildPaths#distAll}
-   */
-  abstract void buildDistributions()
-
   /**
    * Produces distributions for all operating systems from sources. This includes compiling required modules, packing their output into JAR
    * files accordingly to {@link ProductProperties#productLayout}, and creating distributions and installers for all OS.
    */
-  abstract void compileModulesAndBuildDistributions()
+  abstract void buildDistributions()
 
   abstract void compileProjectAndTests(List<String> includingTestsInModules)
 
@@ -97,6 +75,6 @@ abstract class BuildTasks {
     ProductProperties productProperties = (ProductProperties) Class.forName(productPropertiesClassName).constructors[0].newInstance(projectHome)
     def context = BuildContext.createContext(binding.ant, binding.projectBuilder, binding.project, binding.global,
                                              "$projectHome/$communityHomeRelativePath", projectHome, productProperties, proprietaryBuildTools)
-    create(context).compileModulesAndBuildDistributions()
+    create(context).buildDistributions()
   }
 }
\ No newline at end of file
index 3e4038b752e7b853c15b08cadc080fc36d90c311..c08dceb9ac7e1e7c0b111b3bf2be2194898e856e 100644 (file)
@@ -41,13 +41,13 @@ class IdeaCommunityBuilder {
   }
 
   void buildDistJars() {
-    BuildTasks.create(buildContext).compileModulesAndBuildDistributions()
+    BuildTasks.create(buildContext).buildDistributions()
     layoutAdditionalArtifacts()
   }
 
   void buildDistributions() {
     def tasks = BuildTasks.create(buildContext)
-    tasks.compileModulesAndBuildDistributions()
+    tasks.buildDistributions()
     layoutAdditionalArtifacts(true)
     tasks.buildUpdaterJar()
   }
index 78d246f8b6b081a2bcbc0e69d898f90fede250ac..a31b68493867b747c78f924342176c066f74d7fa 100644 (file)
@@ -164,8 +164,6 @@ abstract class ProductProperties {
    */
   boolean enableYourkitAgentInEAP = false
 
-  List<String> excludedPlugins = []
-
   /**
    * Specified additional modules (not included into the product layout) which need to be compiled when product is built.
    * todo[nik] get rid of this
index 6238cc0a438c1c840f766d29f88b4028543de17a..369ea2a8095164d3c75151f89243e549f2bbcd3c 100644 (file)
@@ -311,9 +311,7 @@ class BuildContextImpl extends BuildContext {
 
   private boolean isJavaSupportedInProduct() {
     def productLayout = productProperties.productLayout
-    return productLayout.mainJarName == null ||
-           //todo[nik] remove this condition later; currently build scripts for IDEA don't fully migrated to the new scheme
-           productLayout.includedPlatformModules.contains("execution-impl")
+    return productLayout.includedPlatformModules.contains("execution-impl")
   }
 
   @CompileDynamic
index 9d5fcfb40b60ad13b89fec64ac84044bb170cc59..31c0f15ec0e354860a377d324e6aee3c570fcb97 100644 (file)
@@ -91,12 +91,6 @@ class BuildTasksImpl extends BuildTasks {
     }
   }
 
-  @Override
-  void buildSearchableOptions(String targetModuleName, List<String> modulesToIndex, List<String> pathsToLicenses) {
-    buildSearchableOptions(new File(buildContext.projectBuilder.moduleOutput(buildContext.findRequiredModule(targetModuleName))), modulesToIndex, pathsToLicenses)
-  }
-
-//todo[nik] do we need 'cp' and 'jvmArgs' parameters?
   void buildSearchableOptions(File targetDirectory, List<String> modulesToIndex, List<String> pathsToLicenses) {
     buildContext.executeStep("Build searchable options index", BuildOptions.SEARCHABLE_OPTIONS_INDEX_STEP, {
       def javaRuntimeClasses = "${buildContext.projectBuilder.moduleOutput(buildContext.findModule("java-runtime"))}"
@@ -187,7 +181,6 @@ idea.fatal.error.notification=disabled
     return propertiesFile
   }
 
-  @Override
   File patchApplicationInfo() {
     def sourceFile = buildContext.findApplicationInfoInSources()
     def targetFile = new File(buildContext.paths.temp, sourceFile.name)
@@ -229,24 +222,55 @@ idea.fatal.error.notification=disabled
     src.filterLine { String it -> !it.contains('appender-ref ref="CONSOLE-WARN"') }.writeTo(dst.newWriter()).close()
   }
 
+  private static BuildTaskRunnable<String> createDistributionForOsTask(String taskName, Function<BuildContext, OsSpecificDistributionBuilder> factory) {
+    new BuildTaskRunnable<String>(taskName) {
+      @Override
+      String run(BuildContext context) {
+        def builder = factory.apply(context)
+        if (builder != null && context.shouldBuildDistributionForOS(builder.osTargetId)) {
+          return context.messages.block("Build $builder.osName Distribution") {
+            def distDirectory = builder.copyFilesForOsDistribution()
+            builder.buildArtifacts(distDirectory)
+            distDirectory
+          }
+        }
+        return null
+      }
+    }
+  }
+
   @Override
   void buildDistributions() {
+    checkProductProperties()
+
+    def patchedApplicationInfo = patchApplicationInfo()
+    def distributionJARsBuilder = new DistributionJARsBuilder(buildContext, patchedApplicationInfo)
+    compileModules(buildContext.productProperties.productLayout.includedPluginModules + distributionJARsBuilder.platformModules +
+                   buildContext.productProperties.additionalModulesToCompile, buildContext.productProperties.modulesToCompileTests)
+    buildContext.messages.block("Build platform and plugin JARs") {
+      distributionJARsBuilder.buildJARs()
+      distributionJARsBuilder.buildAdditionalArtifacts()
+    }
+    if (buildContext.productProperties.scrambleMainJar) {
+      scramble()
+    }
+
     layoutShared()
 
     def propertiesFile = patchIdeaPropertiesFile()
     List<BuildTaskRunnable<String>> tasks = [
       createDistributionForOsTask("win", { BuildContext context ->
-        context.windowsDistributionCustomizer?.with {new WindowsDistributionBuilder(context, it, propertiesFile)}
+        context.windowsDistributionCustomizer?.with { new WindowsDistributionBuilder(context, it, propertiesFile, patchedApplicationInfo) }
       }),
       createDistributionForOsTask("linux", { BuildContext context ->
-        context.linuxDistributionCustomizer?.with {new LinuxDistributionBuilder(context, it, propertiesFile)}
+        context.linuxDistributionCustomizer?.with { new LinuxDistributionBuilder(context, it, propertiesFile) }
       }),
       createDistributionForOsTask("mac", { BuildContext context ->
-        context.macDistributionCustomizer?.with {new MacDistributionBuilder(context, it, propertiesFile)}
+        context.macDistributionCustomizer?.with { new MacDistributionBuilder(context, it, propertiesFile) }
       })
     ]
 
-    List<String> paths = runInParallel(tasks).findAll {it != null}
+    List<String> paths = runInParallel(tasks).findAll { it != null }
 
     if (buildContext.productProperties.buildCrossPlatformDistribution) {
       if (paths.size() == 3) {
@@ -261,52 +285,23 @@ idea.fatal.error.notification=disabled
     }
   }
 
-  private static BuildTaskRunnable<String> createDistributionForOsTask(String taskName, Function<BuildContext, OsSpecificDistributionBuilder> factory) {
-    new BuildTaskRunnable<String>(taskName) {
-      @Override
-      String run(BuildContext context) {
-        def builder = factory.apply(context)
-        if (builder != null && context.shouldBuildDistributionForOS(builder.osTargetId)) {
-          return context.messages.block("Build $builder.osName Distribution") {
-            def distDirectory = builder.copyFilesForOsDistribution()
-            builder.buildArtifacts(distDirectory)
-            distDirectory
-          }
-        }
-        return null
-      }
+  private void scramble() {
+    if (buildContext.proprietaryBuildTools.scrambleTool != null) {
+      buildContext.proprietaryBuildTools.scrambleTool.scramble(buildContext.productProperties.productLayout.mainJarName, buildContext)
     }
-  }
-
-  @Override
-  void compileModulesAndBuildDistributions() {
-    checkProductProperties()
-    def distributionJARsBuilder = new DistributionJARsBuilder(buildContext)
-    compileModules(buildContext.productProperties.productLayout.includedPluginModules + distributionJARsBuilder.platformModules +
-                   buildContext.productProperties.additionalModulesToCompile, buildContext.productProperties.modulesToCompileTests)
-    buildContext.messages.block("Build platform and plugin JARs") {
-      distributionJARsBuilder.buildJARs()
-      distributionJARsBuilder.buildAdditionalArtifacts()
+    else {
+      buildContext.messages.warning("Scrambling skipped: 'scrambleTool' isn't defined")
     }
-    if (buildContext.productProperties.scrambleMainJar) {
-      if (buildContext.proprietaryBuildTools.scrambleTool != null) {
-        buildContext.proprietaryBuildTools.scrambleTool.scramble(buildContext.productProperties.productLayout.mainJarName, buildContext)
+    buildContext.ant.zip(destfile: "$buildContext.paths.artifacts/internalUtilities.zip") {
+      fileset(file: "$buildContext.paths.buildOutputRoot/internal/internalUtilities.jar")
+      fileset(dir: "$buildContext.paths.communityHome/lib") {
+        include(name: "junit-4*.jar")
+        include(name: "hamcrest-core-*.jar")
       }
-      else {
-        buildContext.messages.warning("Scrambling skipped: 'scrambleTool' isn't defined")
-      }
-      buildContext.ant.zip(destfile: "$buildContext.paths.artifacts/internalUtilities.zip") {
-        fileset(file: "$buildContext.paths.buildOutputRoot/internal/internalUtilities.jar")
-        fileset(dir: "$buildContext.paths.communityHome/lib") {
-          include(name: "junit-4*.jar")
-          include(name: "hamcrest-core-*.jar")
-        }
-        zipfileset(src: "$buildContext.paths.buildOutputRoot/internal/internalUtilities.jar") {
-          include(name: "*.xml")
-        }
+      zipfileset(src: "$buildContext.paths.buildOutputRoot/internal/internalUtilities.jar") {
+        include(name: "*.xml")
       }
     }
-    buildDistributions()
   }
 
   private void checkProductProperties() {
@@ -478,7 +473,7 @@ idea.fatal.error.notification=disabled
 
   @Override
   void buildUnpackedDistribution(String targetDirectory) {
-    def jarsBuilder = new DistributionJARsBuilder(buildContext)
+    def jarsBuilder = new DistributionJARsBuilder(buildContext, patchApplicationInfo())
     jarsBuilder.buildJARs()
     layoutShared()
 
index 88a4085198170592fabce4345745e49093822c95..ba9494402aa42bd6ee1bd2989b4b6c6bfee6383f 100644 (file)
@@ -59,7 +59,6 @@ class CrossPlatformDistributionBuilder {
       buildContext.ant.zip(zipfile: targetPath, duplicate: "fail") {
         fileset(dir: buildContext.paths.distAll) {
           exclude(name: "bin/idea.properties")
-          exclude(name: "lib/libpty/**") //todo[nik] this is temporary workaround until IDEA fully migrates to the new scheme
         }
         fileset(dir: zipDir)
 
index 6175bb62da9591cd5514dc80599d1af74d16757b..212a9f4541ea260305ccafc33733b2f9ed79d252 100644 (file)
@@ -39,8 +39,10 @@ class DistributionJARsBuilder {
   private final BuildContext buildContext
   private final Set<String> usedModules = new LinkedHashSet<>()
   private final PlatformLayout platform
+  private final File patchedApplicationInfo
 
-  DistributionJARsBuilder(BuildContext buildContext) {
+  DistributionJARsBuilder(BuildContext buildContext, File patchedApplicationInfo) {
+    this.patchedApplicationInfo = patchedApplicationInfo
     this.buildContext = buildContext
     buildContext.ant.patternset(id: RESOURCES_INCLUDED) {
       include(name: "**/*Bundle*.properties")
@@ -205,7 +207,7 @@ class DistributionJARsBuilder {
       layoutBuilder.patchModuleOutput(productLayout.searchableOptionsModule, FileUtil.toSystemIndependentName(searchableOptionsDir.absolutePath))
     }
 
-    def applicationInfoFile = FileUtil.toSystemIndependentName(buildTasks.patchApplicationInfo().absolutePath)
+    def applicationInfoFile = FileUtil.toSystemIndependentName(patchedApplicationInfo.absolutePath)
     def applicationInfoDir = "$buildContext.paths.temp/applicationInfo"
     ant.copy(file: applicationInfoFile, todir: "$applicationInfoDir/idea")
     layoutBuilder.patchModuleOutput(buildContext.productProperties.applicationInfoModule, applicationInfoDir)
index d2e245facb845a0407a789e1a8798029ed304b18..efc5f29bd1607bc1690c629f381660844b910afc 100644 (file)
@@ -28,9 +28,11 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRoot
 class WindowsDistributionBuilder extends OsSpecificDistributionBuilder {
   private final WindowsDistributionCustomizer customizer
   private final File ideaProperties
+  private final File patchedApplicationInfo
 
-  WindowsDistributionBuilder(BuildContext buildContext, WindowsDistributionCustomizer customizer, File ideaProperties) {
+  WindowsDistributionBuilder(BuildContext buildContext, WindowsDistributionCustomizer customizer, File ideaProperties, File patchedApplicationInfo) {
     super(BuildOptions.OS_WINDOWS, "Windows", buildContext)
+    this.patchedApplicationInfo = patchedApplicationInfo
     this.customizer = customizer
     this.ideaProperties = ideaProperties
   }
@@ -101,7 +103,6 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder {
 
   private void generateScripts(String winDistPath) {
     String fullName = buildContext.applicationInfo.productName
-    //todo[nik] looks like names without .exe were also supported, do we need this?
     String vmOptionsFileName = "${buildContext.productProperties.baseFileName}%BITS%.exe"
 
     String classPath = "SET CLASS_PATH=%IDE_HOME%\\lib\\${buildContext.bootClassPathJarNames[0]}\n"
@@ -185,7 +186,7 @@ IDS_VM_OPTIONS=$vmOptions
       buildContext.ant.java(classname: "com.pme.launcher.LauncherGeneratorMain", fork: "true", failonerror: "true") {
         sysproperty(key: "java.awt.headless", value: "true")
         arg(value: inputPath)
-        arg(value: buildContext.findApplicationInfoInSources().absolutePath)
+        arg(value: patchedApplicationInfo.absolutePath)
         arg(value: "$communityHome/native/WinLauncher/WinLauncher/resource.h")
         arg(value: launcherPropertiesPath)
         arg(value: outputPath)
index c1a30023bf3a32e94340434950bed0700c2d5f39..2315313db58a081261fa1c4ff0b988979b158041 100644 (file)
@@ -16,6 +16,7 @@
 
 
 import org.jetbrains.intellij.build.*
+import org.jetbrains.intellij.build.impl.BuildTasksImpl
 import org.jetbrains.jps.util.JpsPathUtil
 
 import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
@@ -41,7 +42,7 @@ boolean setPluginAndIDEVersionInPluginXml() {
 }
 
 List<String> getExcludedPlugins() {
-  return isDefined("productProperties") ? productProperties.excludedPlugins : []
+  return []
 }
 
 /**
@@ -51,7 +52,7 @@ def layoutFull(BuildContext context) {
   binding.setVariable("productProperties", context.productProperties)
   String home = context.paths.communityHome
   String targetDirectory = context.paths.distAll
-  File patchedApplicationInfo = BuildTasks.create(context).patchApplicationInfo()
+  File patchedApplicationInfo = ((BuildTasksImpl)BuildTasks.create(context)).patchApplicationInfo()
   projectBuilder.stage("layout to $targetDirectory")
 
   List<String> jpsCommonModules = ["jps-model-impl", "jps-model-serialization"]
index 3c8cc9e04919909e3e9c64705a054cf1788836b5..0379bfaa299070b34922250331bb6e40453316b2 100644 (file)
@@ -195,9 +195,10 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
     return canBeConvertedToLambda(aClass, acceptParameterizedFunctionTypes, true, ignoredRuntimeAnnotations);
   }
 
-  public static boolean isClassAndMethodSuitableForConversion(PsiAnonymousClass aClass,
-                                                              PsiMethod method,
-                                                              Set<String> ignoredRuntimeAnnotations) {
+  public static boolean isLambdaForm(PsiAnonymousClass aClass, Set<String> ignoredRuntimeAnnotations) {
+    PsiMethod[] methods = aClass.getMethods();
+    if(methods.length != 1) return false;
+    PsiMethod method = methods[0];
     return aClass.getFields().length == 0 &&
            aClass.getInnerClasses().length == 0 &&
            aClass.getInitializers().length == 0 &&
@@ -222,16 +223,9 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
       }
       final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
       if (interfaceMethod != null && (acceptParameterizedFunctionTypes || !interfaceMethod.hasTypeParameters())) {
-        final PsiMethod[] methods = aClass.getMethods();
-        if (methods.length == 1) {
-          final PsiMethod method = methods[0];
-          if (isClassAndMethodSuitableForConversion(aClass, method, ignoredRuntimeAnnotations)) {
-            final PsiType inferredType = getInferredType(aClass, method);
-            if (inferredType == null) {
-              return false;
-            }
-            return true;
-          }
+        if (isLambdaForm(aClass, ignoredRuntimeAnnotations)) {
+          final PsiMethod method = aClass.getMethods()[0];
+          return getInferredType(aClass, method) != null;
         }
       }
     }
index b259c5dc956de1f3f484aea0bb20a8c4727f59a6..ef5ad5741e6f567b877818e73aafe2649f0afd08 100644 (file)
@@ -66,21 +66,19 @@ public class AnonymousHasLambdaAlternativeInspection extends BaseJavaBatchLocalI
       @Override
       public void visitAnonymousClass(final PsiAnonymousClass aClass) {
         super.visitAnonymousClass(aClass);
-        PsiMethod[] methods = aClass.getMethods();
-        if(methods.length == 1) {
-          PsiMethod method = methods[0];
-          PsiExpressionList argumentList = aClass.getArgumentList();
-          if (AnonymousCanBeLambdaInspection.isClassAndMethodSuitableForConversion(aClass, method, Collections.emptySet()) &&
-              argumentList != null && argumentList.getExpressions().length == 0) {
-            PsiClassType type = aClass.getBaseClassType();
-            AnonymousLambdaAlternative alternative = getAlternative(type.resolve(), method);
-            if(alternative != null) {
-              final PsiElement lBrace = aClass.getLBrace();
-              LOG.assertTrue(lBrace != null);
-              final TextRange rangeInElement = new TextRange(0, lBrace.getStartOffsetInParent() + aClass.getStartOffsetInParent() - 1);
-              holder.registerProblem(aClass.getParent(), "Anonymous #ref #loc can be replaced with "+alternative.myReplacementMessage,
-                                     ProblemHighlightType.LIKE_UNUSED_SYMBOL, rangeInElement, new ReplaceWithLambdaAlternativeFix(alternative));
-            }
+        PsiExpressionList argumentList = aClass.getArgumentList();
+        if (AnonymousCanBeLambdaInspection.isLambdaForm(aClass, Collections.emptySet()) &&
+            argumentList != null &&
+            argumentList.getExpressions().length == 0) {
+          PsiMethod method = aClass.getMethods()[0];
+          PsiClassType type = aClass.getBaseClassType();
+          AnonymousLambdaAlternative alternative = getAlternative(type.resolve(), method);
+          if(alternative != null) {
+            final PsiElement lBrace = aClass.getLBrace();
+            LOG.assertTrue(lBrace != null);
+            final TextRange rangeInElement = new TextRange(0, lBrace.getStartOffsetInParent() + aClass.getStartOffsetInParent() - 1);
+            holder.registerProblem(aClass.getParent(), "Anonymous #ref #loc can be replaced with "+alternative.myReplacementMessage,
+                                   ProblemHighlightType.LIKE_UNUSED_SYMBOL, rangeInElement, new ReplaceWithLambdaAlternativeFix(alternative));
           }
         }
       }
index 218656cfb91d7a69bd65e0021086421ed7b7737c..39ba4a0e1475928f958af6fbd56ee2aebd5894de 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.codeInspection.dataFlow;
 import com.intellij.codeInsight.NullableNotNullManager;
 import com.intellij.codeInspection.dataFlow.instructions.AssignInstruction;
 import com.intellij.codeInspection.dataFlow.instructions.Instruction;
+import com.intellij.codeInspection.dataFlow.instructions.PushInstruction;
 import com.intellij.codeInspection.dataFlow.instructions.ReturnInstruction;
 import com.intellij.codeInspection.dataFlow.value.DfaValue;
 import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
@@ -47,10 +48,12 @@ import java.util.Set;
  */
 class NullParameterConstraintChecker extends DataFlowRunner {
   private final Set<PsiParameter> myPossiblyViolatedParameters;
+  private final Set<PsiParameter> myUsedParameters;
 
   private NullParameterConstraintChecker(Collection<PsiParameter> parameters, boolean isOnTheFly) {
     super(false, true, isOnTheFly);
     myPossiblyViolatedParameters = new THashSet<>(parameters);
+    myUsedParameters = new THashSet<>();
   }
 
   @NotNull
@@ -73,7 +76,7 @@ class NullParameterConstraintChecker extends DataFlowRunner {
     final NullParameterConstraintChecker checker = new NullParameterConstraintChecker(nullableParameters, true);
     checker.analyzeMethod(method.getBody(), new StandardInstructionVisitor());
 
-    return checker.myPossiblyViolatedParameters.toArray(new PsiParameter[checker.myPossiblyViolatedParameters.size()]);
+    return checker.myPossiblyViolatedParameters.stream().filter(checker.myUsedParameters::contains).toArray(PsiParameter[]::new);
   }
 
   @NotNull
@@ -81,6 +84,16 @@ class NullParameterConstraintChecker extends DataFlowRunner {
   protected DfaInstructionState[] acceptInstruction(@NotNull InstructionVisitor visitor, @NotNull DfaInstructionState instructionState) {
     Instruction instruction = instructionState.getInstruction();
 
+    if (instruction instanceof PushInstruction) {
+      final DfaValue var = ((PushInstruction)instruction).getValue();
+      if (var instanceof DfaVariableValue) {
+        final PsiModifierListOwner psiVar = ((DfaVariableValue)var).getPsiVariable();
+        if (psiVar instanceof PsiParameter) {
+          myUsedParameters.add((PsiParameter)psiVar);
+        }
+      }
+    }
+
     if (instruction instanceof AssignInstruction) {
       final DfaValue value = ((AssignInstruction)instruction).getAssignedValue();
       if (value instanceof DfaVariableValue) {
index c9f5d45057091b79d3858072102f1da0e3acfcbb..a19e953e64378fadb6a89720cfdb364acbcf86bb 100644 (file)
@@ -110,7 +110,7 @@ public class StringExpressionHelper {
 
     Collection<? extends PsiElement> elements = DfaUtil.getPossibleInitializationElements(expression);
     for (PsiElement element : elements) {
-      Pair<PsiElement, String> expr = evaluateExpression(element);
+      Pair<PsiElement, String> expr = evaluateExpression(element, visited);
       if (expr != null) return expr;
     }
 
index 4a9a02fe601bb3fa5b085c655df7c25382a04dcc..55008d12b5301befd4810ab197c97b80d3918a7f 100644 (file)
@@ -239,14 +239,14 @@ public class Java8CollectionsApiInspection extends BaseJavaBatchLocalInspectionT
             (getArgument == null || EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(getArgument, putKeyArgument))) {
           LocalQuickFix fix = null;
           if (ExpressionUtils.isSimpleExpression(putValueArgument)) {
-            fix = new ReplaceWithMapPutIfAbsentFix(putMethodCall, "putIfAbsent");
+            fix = new ReplaceConditionalMapPutFix(putMethodCall, false);
           }
           else if ((maybePutMethodCall.getParent() instanceof PsiExpressionStatement) && // only if result of put is not used
                    LambdaGenerationUtil.canBeUncheckedLambda(putValueArgument)) {
-            fix = new ReplaceWithMapPutIfAbsentFix(putMethodCall, "computeIfAbsent");
+            fix = new ReplaceConditionalMapPutFix(putMethodCall, true);
           }
           else if (mySuggestPutIfAbsentForComplexExpression) {
-            fix = new ReplaceWithMapPutIfAbsentFix(putMethodCall, "putIfAbsent");
+            fix = new ReplaceConditionalMapPutFix(putMethodCall, false);
           }
           if(fix != null) {
             holder.registerProblem(context, QuickFixBundle.message("java.8.collections.api.inspection.description"), fix);
similarity index 92%
rename from java/java-analysis-impl/src/com/intellij/codeInspection/java18api/ReplaceWithMapPutIfAbsentFix.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java18api/ReplaceConditionalMapPutFix.java
index 2d74c1f5aa7aaf9763bce3cf52bdefb011b85575..693906636de14cf3234f480af3b97216cfbb7817 100644 (file)
@@ -32,14 +32,17 @@ import org.jetbrains.annotations.NotNull;
 /**
  * @author Dmitry Batkovich
  */
-public class ReplaceWithMapPutIfAbsentFix implements LocalQuickFix {
+public class ReplaceConditionalMapPutFix implements LocalQuickFix {
+  private static final String COMPUTE_IF_ABSENT_METHOD = "computeIfAbsent";
+  private static final String PUT_IF_ABSENT_METHOD = "putIfAbsent";
+
   private final SmartPsiElementPointer<PsiMethodCallExpression> myPutExpressionPointer;
   private final String myMethodName;
 
-  public ReplaceWithMapPutIfAbsentFix(PsiMethodCallExpression putExpression, String methodName) {
+  public ReplaceConditionalMapPutFix(PsiMethodCallExpression putExpression, boolean useComputeIfAbsent) {
     final SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(putExpression.getProject());
     myPutExpressionPointer = smartPointerManager.createSmartPsiElementPointer(putExpression);
-    myMethodName = methodName; // either "putIfAbsent" or "computeIfAbsent"
+    myMethodName = useComputeIfAbsent ? COMPUTE_IF_ABSENT_METHOD : PUT_IF_ABSENT_METHOD;
   }
 
   @Override
@@ -74,7 +77,7 @@ public class ReplaceWithMapPutIfAbsentFix implements LocalQuickFix {
     final Couple<String> boundText = getBoundText(putContainingElement, putExpression);
 
     String valueArgument = putExpression.getArgumentList().getExpressions()[1].getText();
-    if(myMethodName.equals("computeIfAbsent")) {
+    if(myMethodName.equals(COMPUTE_IF_ABSENT_METHOD)) {
       String varName = JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName("k", putExpression, true);
       valueArgument = varName + " -> " + valueArgument;
     }
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java
new file mode 100644 (file)
index 0000000..7dbb7f3
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.intention.impl;
+
+import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.search.LocalSearchScope;
+import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.refactoring.util.LambdaRefactoringUtil;
+import com.intellij.util.IncorrectOperationException;
+import com.siyeh.ig.psiutils.ParenthesesUtils;
+import com.siyeh.ig.style.MethodRefCanBeReplacedWithLambdaInspection;
+import one.util.streamex.StreamEx;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Set;
+
+public class InlineStreamMapAction extends PsiElementBaseIntentionAction {
+  private static final Logger LOG = Logger.getInstance(InlineStreamMapAction.class.getName());
+
+  private static final Set<String> MAP_METHODS =
+    StreamEx.of("map", "mapToInt", "mapToLong", "mapToDouble", "mapToObj", "boxed", "asLongStream", "asDoubleStream").toSet();
+
+  private static final Set<String> NEXT_METHODS = StreamEx
+    .of("flatMap", "flatMapToInt", "flatMapToLong", "flatMapToDouble", "forEach", "forEachOrdered", "anyMatch", "noneMatch", "allMatch")
+    .append(MAP_METHODS).toSet();
+
+  @Override
+  public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull final PsiElement element) {
+    if (!(element instanceof PsiIdentifier)) return false;
+    final PsiElement parent = element.getParent();
+    if (!(parent instanceof PsiReferenceExpression)) return false;
+    final PsiElement gParent = parent.getParent();
+    if (!(gParent instanceof PsiMethodCallExpression)) return false;
+    PsiMethodCallExpression curCall = (PsiMethodCallExpression)gParent;
+    if (!isMapCall(curCall)) return false;
+    PsiMethodCallExpression nextCall = getNextExpressionToMerge(curCall);
+    if(nextCall == null) return false;
+    String key = curCall.getArgumentList().getExpressions().length == 0 || nextCall.getArgumentList().getExpressions().length == 0 ?
+                 "intention.inline.map.merge.text" : "intention.inline.map.inline.text";
+    setText(CodeInsightBundle.message(key, element.getText(), nextCall.getMethodExpression().getReferenceName()));
+    return true;
+  }
+
+  private static boolean isMapCall(@NotNull PsiMethodCallExpression methodCallExpression) {
+    String name = methodCallExpression.getMethodExpression().getReferenceName();
+    if (name == null || !MAP_METHODS.contains(name)) return false;
+
+    final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
+    final PsiExpression[] expressions = argumentList.getExpressions();
+    if (!name.startsWith("map") && expressions.length == 0) return true;
+    if (expressions.length != 1) return false;
+    if (!isSupportedForConversion(expressions[0], true)) return false;
+
+    final PsiMethod method = methodCallExpression.resolveMethod();
+    if (method == null) return false;
+    final PsiClass containingClass = method.getContainingClass();
+    return InheritanceUtil.isInheritor(containingClass, CommonClassNames.JAVA_UTIL_STREAM_BASE_STREAM);
+  }
+
+  private static boolean isSupportedForConversion(PsiExpression expression, boolean requireExpressionLambda) {
+    if(expression instanceof PsiLambdaExpression) {
+      PsiLambdaExpression lambdaExpression = (PsiLambdaExpression)expression;
+      return lambdaExpression.getParameterList().getParametersCount() == 1 &&
+             (!requireExpressionLambda || LambdaUtil.extractSingleExpressionFromBody(lambdaExpression.getBody()) != null);
+    } else if(expression instanceof PsiMethodReferenceExpression) {
+      PsiMethodReferenceExpression methodReference = (PsiMethodReferenceExpression)expression;
+      return !MethodRefCanBeReplacedWithLambdaInspection.isWithSideEffects(methodReference);
+    }
+    return false;
+  }
+
+  @Nullable
+  private static PsiMethodCallExpression getNextExpressionToMerge(PsiMethodCallExpression methodCallExpression) {
+    PsiElement parent = methodCallExpression.getParent();
+    if(!(parent instanceof PsiReferenceExpression)) return null;
+    PsiElement gParent = parent.getParent();
+    if(!(gParent instanceof PsiMethodCallExpression)) return null;
+    String nextName = ((PsiReferenceExpression)parent).getReferenceName();
+    PsiMethodCallExpression nextCall = (PsiMethodCallExpression)gParent;
+    if(nextName == null || !NEXT_METHODS.contains(nextName) || translateName(methodCallExpression, nextCall) == null) return null;
+    PsiExpressionList argumentList = (nextCall).getArgumentList();
+    PsiExpression[] expressions = argumentList.getExpressions();
+    if(expressions.length == 0) {
+      if (!nextName.equals("boxed") && !nextName.equals("asLongStream") && !nextName.equals("asDoubleStream")) return null;
+      return nextCall;
+    }
+    if (expressions.length != 1 || !isSupportedForConversion(expressions[0], false)) return null;
+
+    return nextCall;
+  }
+
+  /**
+   * Generate name of joint method call which combines two given calls
+   *
+   * @param prevCall previous call (assumed to be in MAP_METHODS)
+   * @param nextCall next call (assumed to be in NEXT_METHODS)
+   * @return a name of the resulting method
+   */
+  @Nullable
+  private static String translateName(@NotNull PsiMethodCallExpression prevCall, @NotNull PsiMethodCallExpression nextCall) {
+    PsiMethod nextMethod = nextCall.resolveMethod();
+    if (nextMethod == null) return null;
+    String nextName = nextMethod.getName();
+    PsiMethod method = prevCall.resolveMethod();
+    if (method == null) return null;
+    PsiClass prevClass = method.getContainingClass();
+    if (prevClass == null) return null;
+    String prevClassName = prevClass.getQualifiedName();
+    if (prevClassName == null) return null;
+    String prevName = method.getName();
+    if (nextName.endsWith("Match") || nextName.startsWith("forEach")) return nextName;
+    if (nextName.equals("map")) {
+      return translateMap(prevName);
+    }
+    if (prevName.equals("map")) {
+      return translateMap(nextName);
+    }
+    if(MAP_METHODS.contains(nextName)) {
+      PsiType type = nextMethod.getReturnType();
+      if(!(type instanceof PsiClassType)) return null;
+      PsiClass nextClass = ((PsiClassType)type).resolve();
+      if(nextClass == null) return null;
+      String nextClassName = nextClass.getQualifiedName();
+      if(nextClassName == null) return null;
+      if(prevClassName.equals(nextClassName)) return "map";
+      switch(nextClassName) {
+        case CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM:
+          return "mapToInt";
+        case CommonClassNames.JAVA_UTIL_STREAM_LONG_STREAM:
+          return "mapToLong";
+        case CommonClassNames.JAVA_UTIL_STREAM_DOUBLE_STREAM:
+          return "mapToDouble";
+        case CommonClassNames.JAVA_UTIL_STREAM_STREAM:
+          return "mapToObj";
+        default:
+          return null;
+      }
+    }
+    if(nextName.equals("flatMap") && prevClassName.equals(CommonClassNames.JAVA_UTIL_STREAM_STREAM)) {
+      String mapMethod = translateMap(prevName);
+      return "flatM"+mapMethod.substring(1);
+    }
+    return null;
+  }
+
+  @NotNull
+  private static String translateMap(String nextMethod) {
+    switch (nextMethod) {
+      case "boxed":
+        return "mapToObj";
+      case "asLongStream":
+        return "mapToLong";
+      case "asDoubleStream":
+        return "mapToDouble";
+      default:
+        return nextMethod;
+    }
+  }
+
+  @Override
+  @NotNull
+  public String getFamilyName() {
+    return CodeInsightBundle.message("intention.inline.map.family");
+  }
+
+  @Override
+  public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
+    PsiMethodCallExpression mapCall = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
+    if(mapCall == null) return;
+
+    PsiMethodCallExpression nextCall = getNextExpressionToMerge(mapCall);
+    if(nextCall == null) return;
+
+    PsiExpression nextQualifier = nextCall.getMethodExpression().getQualifierExpression();
+    if(nextQualifier == null) return;
+
+    String newName = translateName(mapCall, nextCall);
+    if(newName == null) return;
+
+    if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
+
+    PsiLambdaExpression previousLambda = getLambda(mapCall);
+
+    LOG.assertTrue(previousLambda != null);
+    PsiExpression previousBody = LambdaUtil.extractSingleExpressionFromBody(previousLambda.getBody());
+    LOG.assertTrue(previousBody != null);
+
+    PsiLambdaExpression lambda = getLambda(nextCall);
+    LOG.assertTrue(lambda != null);
+
+    if(!lambda.isPhysical()) {
+      lambda = (PsiLambdaExpression)nextCall.getArgumentList().add(lambda);
+    }
+    PsiElement body = lambda.getBody();
+    LOG.assertTrue(body != null);
+
+    PsiParameter[] nextParameters = lambda.getParameterList().getParameters();
+    LOG.assertTrue(nextParameters.length == 1);
+    PsiParameter[] prevParameters = previousLambda.getParameterList().getParameters();
+    LOG.assertTrue(prevParameters.length == 1);
+    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
+    for(PsiReference ref : ReferencesSearch.search(nextParameters[0], new LocalSearchScope(body)).findAll()) {
+      PsiElement e = ref.getElement();
+      PsiExpression replacement = previousBody;
+      if (e.getParent() instanceof PsiExpression &&
+          ParenthesesUtils.areParenthesesNeeded(previousBody, (PsiExpression)e.getParent(), false)) {
+        replacement = factory.createExpressionFromText("(a)", e);
+        PsiExpression parenthesized = ((PsiParenthesizedExpression)replacement).getExpression();
+        LOG.assertTrue(parenthesized != null);
+        parenthesized.replace(previousBody);
+      }
+      e.replace(replacement);
+    }
+    nextParameters[0].replace(prevParameters[0]);
+    PsiElement nameElement = nextCall.getMethodExpression().getReferenceNameElement();
+    if(nameElement != null && !nameElement.getText().equals(newName)) {
+      nameElement.replace(factory.createIdentifier(newName));
+    }
+    PsiExpression prevQualifier = mapCall.getMethodExpression().getQualifierExpression();
+    if(prevQualifier == null) {
+      nextQualifier.delete();
+    } else {
+      nextQualifier.replace(prevQualifier);
+    }
+    CodeStyleManager.getInstance(project).reformat(lambda);
+  }
+
+  @Nullable
+  private static PsiLambdaExpression getLambda(PsiMethodCallExpression call) {
+    PsiExpression[] expressions = call.getArgumentList().getExpressions();
+    if(expressions.length == 1) {
+      PsiExpression expression = expressions[0];
+      if(expression instanceof PsiLambdaExpression) return (PsiLambdaExpression)expression;
+      if(expression instanceof PsiMethodReferenceExpression) {
+        return LambdaRefactoringUtil.convertMethodReferenceToLambda((PsiMethodReferenceExpression)expression, false, true);
+      }
+      return null;
+    }
+    if(expressions.length != 0) return null;
+    PsiMethod method = call.resolveMethod();
+    if(method == null) return null;
+    PsiClass containingClass = method.getContainingClass();
+    if(containingClass == null) return null;
+    String className = containingClass.getQualifiedName();
+    if(className == null) return null;
+    String varName;
+    String type;
+    switch (className) {
+      case CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM:
+        varName = "i";
+        type = CommonClassNames.JAVA_LANG_INTEGER;
+        break;
+      case CommonClassNames.JAVA_UTIL_STREAM_LONG_STREAM:
+        varName = "l";
+        type = CommonClassNames.JAVA_LANG_LONG;
+        break;
+      case CommonClassNames.JAVA_UTIL_STREAM_DOUBLE_STREAM:
+        varName = "d";
+        type = CommonClassNames.JAVA_LANG_DOUBLE;
+        break;
+      default:
+        return null;
+    }
+    varName = JavaCodeStyleManager.getInstance(call.getProject()).suggestUniqueVariableName(varName, call, true);
+    String expression;
+    if("boxed".equals(method.getName())) {
+      expression = varName+" -> ("+type+")"+varName;
+    } else if("asLongStream".equals(method.getName())) {
+      expression = varName+" -> (long)"+varName;
+    } else if("asDoubleStream".equals(method.getName())) {
+      expression = varName+" -> (double)"+varName;
+    } else return null;
+    PsiElementFactory factory = JavaPsiFacade.getElementFactory(call.getProject());
+    return (PsiLambdaExpression)factory.createExpressionFromText(expression, call);
+  }
+}
index 67c09e9cf4c13f7b8bec0fc0b9e9a4489987166d..d0e9d102cbd1497ef1c4a7cbb17453da1f44ac3e 100644 (file)
@@ -219,30 +219,27 @@ public class JavaQualifiedNameProvider implements QualifiedNameProvider {
       final PsiExpression expression;
       try {
         expression = factory.createExpressionFromText(toInsert + suffix, elementAtCaret);
-      }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
-        return;
-      }
-      final PsiReferenceExpression referenceExpression = expression instanceof PsiMethodCallExpression
-                                                         ? ((PsiMethodCallExpression)expression).getMethodExpression()
-                                                         : expression instanceof PsiReferenceExpression
-                                                           ? (PsiReferenceExpression)expression
-                                                           : null;
-      if (referenceExpression == null || !referenceExpression.isValid()) {
-        toInsert = fqn;
-      }
-      else if (!isReferencedTo(referenceExpression, targetElement)) {
-        try {
-          referenceExpression.bindToElement(targetElement);
-        }
-        catch (IncorrectOperationException e) {
-          // failed to bind
-        }
-        if (!referenceExpression.isValid() || !isReferencedTo(referenceExpression, targetElement)) {
+        final PsiReferenceExpression referenceExpression = expression instanceof PsiMethodCallExpression
+                                                           ? ((PsiMethodCallExpression)expression).getMethodExpression()
+                                                           : expression instanceof PsiReferenceExpression
+                                                             ? (PsiReferenceExpression)expression
+                                                             : null;
+        if (referenceExpression == null || !referenceExpression.isValid()) {
           toInsert = fqn;
         }
+        else if (!isReferencedTo(referenceExpression, targetElement)) {
+          try {
+            referenceExpression.bindToElement(targetElement);
+          }
+          catch (IncorrectOperationException e) {
+            // failed to bind
+          }
+          if (!referenceExpression.isValid() || !isReferencedTo(referenceExpression, targetElement)) {
+            toInsert = fqn;
+          }
+        }
       }
+      catch (IncorrectOperationException ignored) {}
     }
     if (toInsert == null) toInsert = "";
 
index 614f204c6a956dd9b3c3bd8cead8497c4c5cca10..fa92d548a366892d3e54664ec47f45e45418ae99 100644 (file)
@@ -699,8 +699,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
               final PsiElement chosenAnchor =
                 chooseAnchor(settings.isReplaceAllOccurrences(), hasWriteAccess, nonWrite, anchorStatementIfAll, anchorStatement);
 
-              variable = ApplicationManager.getApplication().runWriteAction(
-                introduce(project, expr, topLevelEditor, chosenAnchor, occurrences, settings));
+              variable = introduce(project, expr, topLevelEditor, chosenAnchor, occurrences, settings);
             }
             finally {
               final RefactoringEventData afterData = new RefactoringEventData();
@@ -794,12 +793,12 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
     return parent3 instanceof JspHolderMethod;
   }
 
-  public static Computable<PsiVariable> introduce(final Project project,
-                                                  final PsiExpression expr,
-                                                  final Editor editor,
-                                                  final PsiElement anchorStatement,
-                                                  final PsiExpression[] occurrences,
-                                                  final IntroduceVariableSettings settings) {
+  public static PsiVariable introduce(final Project project,
+                                      final PsiExpression expr,
+                                      final Editor editor,
+                                      final PsiElement anchorStatement,
+                                      final PsiExpression[] occurrences,
+                                      final IntroduceVariableSettings settings) {
     final PsiElement container = anchorStatement.getParent();
     PsiElement child = anchorStatement;
     final boolean isInsideLoop = RefactoringUtil.isLoopOrIf(container);
@@ -841,9 +840,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
 
     final PsiCodeBlock newDeclarationScope = PsiTreeUtil.getParentOfType(container, PsiCodeBlock.class, false);
     final FieldConflictsResolver fieldConflictsResolver = new FieldConflictsResolver(settings.getEnteredName(), newDeclarationScope);
-    return new Computable<PsiVariable>() {
+    SmartPsiElementPointer<PsiVariable> pointer = ApplicationManager.getApplication().runWriteAction(new Computable<SmartPsiElementPointer<PsiVariable>> () {
       @Override
-      public PsiVariable compute() {
+      public SmartPsiElementPointer<PsiVariable> compute() {
         try {
           PsiStatement statement = null;
           if (!isInsideLoop && deleteSelf) {
@@ -913,7 +912,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
           PsiVariable var = (PsiVariable) declaration.getDeclaredElements()[0];
           PsiUtil.setModifierProperty(var, PsiModifier.FINAL, settings.isDeclareFinal());
           fieldConflictsResolver.fix();
-          return var;
+          return SmartPointerManager.getInstance(project).createSmartPsiElementPointer(var);
         } catch (IncorrectOperationException e) {
           LOG.error(e);
         }
@@ -945,7 +944,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
         }
         return  (PsiDeclarationStatement) container.addBefore(declaration, anchor);
       }
-    };
+    });
+    return pointer != null ? pointer.getElement() : null;
   }
 
   private static PsiType stripNullabilityAnnotationsFromTargetType(SmartTypePointer selectedType, final Project project) {
index c6ad929835b049ce94db78e9c482aab3390a3efa..a53c51acc6c82add4719e27f809bdd3a71d38dc3 100644 (file)
@@ -395,10 +395,19 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
 
   @Override
   protected PsiVariable createFieldToStartTemplateOn(String[] names, PsiType psiType) {
-    final PsiVariable variable = ApplicationManager.getApplication().runWriteAction(
-      IntroduceVariableBase.introduce(myProject, myExpr, myEditor, myChosenAnchor.getElement(), getOccurrences(), mySettings));
+    PsiVariable variable = IntroduceVariableBase.introduce(myProject, myExpr, myEditor, myChosenAnchor.getElement(), getOccurrences(), mySettings);
+    final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(variable, PsiDeclarationStatement.class);
+    myPointer = declarationStatement != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(declarationStatement) : null;
+    myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
+    setAdvertisementText(getAdvertisementText(declarationStatement, variable.getType(), myHasTypeSuggestion));
+
     PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(myEditor.getDocument());
 
+    final PsiVariable restoredVar = getVariable();
+    if (restoredVar != null) {
+      variable = restoredVar;
+    }
+
     if (isReplaceAllOccurrences()) {
       List<RangeMarker> occurrences = new ArrayList<>();
       ReferencesSearch.search(variable).forEach(reference -> {
@@ -407,10 +416,6 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
       setOccurrenceMarkers(occurrences);
     }
 
-    final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(variable, PsiDeclarationStatement.class);
-    myPointer = declarationStatement != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(declarationStatement) : null;
-    myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
-    setAdvertisementText(getAdvertisementText(declarationStatement, variable.getType(), myHasTypeSuggestion));
     final PsiIdentifier identifier = variable.getNameIdentifier();
     if (identifier != null) {
       myEditor.getCaretModel().moveToOffset(identifier.getTextOffset());
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterAsLongStreamMap.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterAsLongStreamMap.java
new file mode 100644 (file)
index 0000000..54ce38e
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'asLongStream' call and 'map' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).mapToLong(i -> (long) i * 2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterBoxedForEach.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterBoxedForEach.java
new file mode 100644 (file)
index 0000000..d2d8a82
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'boxed' call and 'forEach' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).asLongStream().map(x -> x*2).forEach((l) -> System.out.println((Long) l));
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapBoxed.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapBoxed.java
new file mode 100644 (file)
index 0000000..6f11313
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'map' call and 'boxed' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).asLongStream().mapToObj(x -> (Long) (x * 2)).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapForEach.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapForEach.java
new file mode 100644 (file)
index 0000000..26e0d0f
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'forEach' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> cs.subSequence(1, 5)).forEach((charSequence) -> System.out.println(charSequence.length()));
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMap.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMap.java
new file mode 100644 (file)
index 0000000..b8d02f2
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'map' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> cs.subSequence(1, 5).length()).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapExpr.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapExpr.java
new file mode 100644 (file)
index 0000000..b8d02f2
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'map' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> cs.subSequence(1, 5).length()).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapMR.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapMR.java
new file mode 100644 (file)
index 0000000..c0fd798
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'map' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map((cs) -> cs.subSequence(1, 5).length()).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapToInt.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapMapToInt.java
new file mode 100644 (file)
index 0000000..51f09eb
--- /dev/null
@@ -0,0 +1,9 @@
+// "Inline 'map' body into the next 'mapToInt' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().mapToInt((cs) -> ((String) cs).length()).asLongStream().map(x -> x*2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapToIntAsLongStream.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapToIntAsLongStream.java
new file mode 100644 (file)
index 0000000..386a1c9
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'mapToInt' call and 'asLongStream' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToLong(s -> (long) s.length()).map(x -> x*2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapToIntFlatMap.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterMapToIntFlatMap.java
new file mode 100644 (file)
index 0000000..84a406f
--- /dev/null
@@ -0,0 +1,9 @@
+// "Inline 'mapToInt' body into the next 'flatMap' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).flatMapToInt(s1 -> IntStream.range(0, s1.length())).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeAsLongStreamMap.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeAsLongStreamMap.java
new file mode 100644 (file)
index 0000000..b4da3d8
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'asLongStream' call and 'map' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).asLon<caret>gStream().map(x -> x*2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeBoxedForEach.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeBoxedForEach.java
new file mode 100644 (file)
index 0000000..236777c
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'boxed' call and 'forEach' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).asLongStream().map(x -> x*2).bo<caret>xed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeFlatMapForEach.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeFlatMapForEach.java
new file mode 100644 (file)
index 0000000..bcfaff7
--- /dev/null
@@ -0,0 +1,9 @@
+// "Inline 'flatMap' body into the next 'forEach' call" "false"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).fl<caret>atMap(s -> IntStream.range(0, s)).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapBoxed.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapBoxed.java
new file mode 100644 (file)
index 0000000..abe11d4
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'map' call and 'boxed' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).mapToInt(String::length).asLongStream().ma<caret>p(x -> x*2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapForEach.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapForEach.java
new file mode 100644 (file)
index 0000000..1f91589
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'forEach' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> cs.subSequence(1, 5)).ma<caret>p(CharSequence::length).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMap.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMap.java
new file mode 100644 (file)
index 0000000..231cc07
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'map' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().m<caret>ap(cs -> cs.subSequence(1, 5)).map(cs -> cs.length()).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapExpr.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapExpr.java
new file mode 100644 (file)
index 0000000..c85780d
--- /dev/null
@@ -0,0 +1,10 @@
+// "Inline 'map' body into the next 'map' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().m<caret>ap(cs -> {
+      return cs.subSequence(1, 5);
+    }).map(cs -> cs.length()).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapMR.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapMR.java
new file mode 100644 (file)
index 0000000..a5651a4
--- /dev/null
@@ -0,0 +1,8 @@
+// "Inline 'map' body into the next 'map' call" "true"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().m<caret>ap(cs -> cs.subSequence(1, 5)).map(CharSequence::length).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapToInt.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapToInt.java
new file mode 100644 (file)
index 0000000..62f1697
--- /dev/null
@@ -0,0 +1,9 @@
+// "Inline 'map' body into the next 'mapToInt' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().m<caret>ap(cs -> (String)cs).mapToInt(String::length).asLongStream().map(x -> x*2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapTwoExpr.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapMapTwoExpr.java
new file mode 100644 (file)
index 0000000..ef277ee
--- /dev/null
@@ -0,0 +1,11 @@
+// "Inline 'map' body into the next 'map' call" "false"
+import java.util.List;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().m<caret>ap(cs -> {
+      cs = cs.subSequence(0, 10);
+      return cs.subSequence(1, 5);
+    }).map(cs -> cs.length()).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapToIntAsLongStream.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapToIntAsLongStream.java
new file mode 100644 (file)
index 0000000..a95324d
--- /dev/null
@@ -0,0 +1,9 @@
+// "Merge 'mapToInt' call and 'asLongStream' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).ma<caret>pToInt(String::length).asLongStream().map(x -> x*2).boxed().forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapToIntFlatMap.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeMapToIntFlatMap.java
new file mode 100644 (file)
index 0000000..3bd66dd
--- /dev/null
@@ -0,0 +1,9 @@
+// "Inline 'mapToInt' body into the next 'flatMap' call" "true"
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Main {
+  public static void test(List<CharSequence> list) {
+    list.stream().map(cs -> (String)cs).ma<caret>pToInt(String::length).flatMap(s -> IntStream.range(0, s)).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullLiteralArgumentDoesntReportedWhenMethodOnlyThrowAnException.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullLiteralArgumentDoesntReportedWhenMethodOnlyThrowAnException.java
new file mode 100644 (file)
index 0000000..aff8882
--- /dev/null
@@ -0,0 +1,10 @@
+class Test {
+
+  void m() {
+    throwAnException(<warning descr="Passing 'null' argument to non annotated parameter">null</warning>);
+  }
+
+  static void throwAnException(String arg) {
+    throw new RuntimeException();
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/brokenFormattingWithInValidation.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/brokenFormattingWithInValidation.java
new file mode 100644 (file)
index 0000000..06b06cb
--- /dev/null
@@ -0,0 +1,10 @@
+class C {
+    void sort(int[] array) {
+        int j;
+        for (int i = 0; i < array.length; i++) {
+            j = 0;
+            while (j<i)&&(array[j]<caret>>array[i])
+
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/brokenFormattingWithInValidation_after.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/brokenFormattingWithInValidation_after.java
new file mode 100644 (file)
index 0000000..b36d036
--- /dev/null
@@ -0,0 +1,10 @@
+class C {
+    void sort(int[] array) {
+        int j;
+        for (int i = 0; i < array.length; i++) {
+            j = 0;
+            while (j<i) boolean bool = array[j] > array[i];&&(array[j] > array[i])
+
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/InlineStreamMapActionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/InlineStreamMapActionTest.java
new file mode 100644 (file)
index 0000000..a96409e
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.intention;
+
+import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
+
+public class InlineStreamMapActionTest extends LightIntentionActionTestCase {
+
+  public void test() throws Exception { doAllTests(); }
+
+  @Override
+  protected String getBasePath() {
+    return "/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap";
+  }
+}
index 8d3e4c50b620504ba20b60a49fd33386c1993ec6..eb2a56ad9d22805c5f8f20a7379f9004dc019494 100644 (file)
@@ -405,4 +405,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
   public void testNullLiteralAndInferredMethodContract() {
     doTest();
   }
+  public void testNullLiteralArgumentDoesntReportedWhenMethodOnlyThrowAnException() { doTest(); }
 }
index 1600bfa069f4eb509af135dbbbf925e2f99663c1..975f15ccfe43242b7e379b29af3f55ae52170ecb 100644 (file)
@@ -27,7 +27,6 @@ import com.intellij.openapi.util.JDOMUtil;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.profile.Profile;
 import com.intellij.profile.codeInspection.InspectionProfileManager;
-import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
 import com.intellij.profile.codeInspection.ui.header.InspectionToolsConfigurable;
 import com.intellij.psi.PsiModifier;
@@ -43,8 +42,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import static com.intellij.profile.ProfileEx.serializeProfile;
-import static com.intellij.testFramework.PlatformTestUtil.assertElementsEqual;
+import static com.intellij.testFramework.Assertions.assertThat;
 
 /**
  * @author Anna.Kozlova
@@ -80,11 +78,11 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     profile.readExternal(element);
     final ModifiableModel model = profile.getModifiableModel();
     model.commit();
-    assertElementsEqual(element, serializeProfile(profile));
+    assertThat(profile.writeScheme()).isEqualTo(element);
   }
 
   private static InspectionProfileImpl createProfile() {
-    return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile(), null);
+    return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getBaseProfile(), null);
   }
   private static InspectionProfileImpl createProfile(@NotNull InspectionProfileImpl base) {
     return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), base, null);
@@ -100,7 +98,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
       //normally on open project profile wrappers are init for both managers
       profileManager.updateProfile(localProfile);
       InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager,
-                                                                InspectionProfileImpl.getDefaultProfile(), null);
+                                                                InspectionProfileImpl.getBaseProfile(), null);
       projectProfileManager.updateProfile(profile);
       projectProfileManager.setRootProfile(profile.getName());
 
@@ -150,7 +148,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     ModifiableModel model = profile.getModifiableModel();
     model.commit();
 
-    assertElementsEqual(loadProfile(), serializeProfile(profile));
+    assertThat(profile.writeScheme()).isEqualTo(loadProfile());
   }
 
   private static Element loadProfile() throws IOException, JDOMException {
@@ -206,7 +204,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     profile.readExternal(element);
     final ModifiableModel model = profile.getModifiableModel();
     model.commit();
-    assertElementsEqual(element, serializeProfile(profile));
+    assertThat(profile.writeScheme()).isEqualTo(element);
   }
 
   public void testMergeUnusedDeclarationAndUnusedSymbol() throws Exception {
@@ -218,7 +216,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     profile.readExternal(element);
     ModifiableModel model = profile.getModifiableModel();
     model.commit();
-    assertElementsEqual(element, serializeProfile(profile));
+    assertThat(profile.writeScheme()).isEqualTo(element);
 
 
     //settings to merge
@@ -290,7 +288,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
                         "</profile>";
     assertEquals(mergedText, serialize(profile));
 
-    Element toImportElement = serializeProfile(profile);
+    Element toImportElement = profile.writeScheme();
     final InspectionProfileImpl importedProfile =
       InspectionToolsConfigurable.importInspectionProfile(toImportElement, InspectionProfileManager.getInstance(), getProject(), null);
 
@@ -300,9 +298,9 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     profile.readExternal(mergedElement);
     model = profile.getModifiableModel();
     model.commit();
-    assertElementsEqual(mergedElement, serializeProfile(profile));
+    assertThat(profile.writeScheme()).isEqualTo(mergedElement);
 
-    assertElementsEqual(mergedElement, serializeProfile(importedProfile));
+    assertThat(importedProfile.writeScheme()).isEqualTo(mergedElement);
   }
 
   public void testStoredMemberVisibility() throws Exception {
@@ -510,7 +508,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
                  "</profile>",
                  serialize(profile));
 
-    Element element = serializeProfile(profile);
+    Element element = profile.writeScheme();
 
     list.add(createTool("bar", true));
     list.add(createTool("disabled", false));
@@ -537,7 +535,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
   }
 
   private static String serialize(InspectionProfileImpl profile) throws WriteExternalException {
-    return JDOMUtil.writeElement(serializeProfile(profile));
+    return JDOMUtil.writeElement(profile.writeScheme());
   }
 
   private static InspectionProfileImpl createProfile(@NotNull InspectionToolRegistrar registrar) {
@@ -581,7 +579,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
   }
 
   public void testDoNotInstantiateOnSave() throws Exception {
-    InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile(), null);
+    InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getBaseProfile(), null);
     assertEquals(0, countInitializedTools(profile));
     InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
     assertTrue(toolWrappers.length > 0);
@@ -596,7 +594,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
       profile.enableTool(id, getProject());
     }
     assertEquals(0, countInitializedTools(profile));
-    serializeProfile(profile);
+    profile.writeScheme();
     List<InspectionToolWrapper> initializedTools = getInitializedTools(profile);
     if (initializedTools.size() > 0) {
       for (InspectionToolWrapper initializedTool : initializedTools) {
@@ -619,20 +617,6 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     assertEquals(1, countInitializedTools(foo));
   }
 
-  public void testPreserveCompatibility() throws Exception {
-    InspectionProfileImpl foo = new InspectionProfileImpl("foo", InspectionToolRegistrar.getInstance(), InspectionProjectProfileManager.getInstance(getProject()));
-    String test = "<profile version=\"1.0\" is_locked=\"false\">\n" +
-                 "  <option name=\"myName\" value=\"idea.default\" />\n" +
-                 "  <inspection_tool class=\"AbstractMethodCallInConstructor\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" />\n" +
-                 "  <inspection_tool class=\"AssignmentToForLoopParameter\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\">\n" +
-                 "    <option name=\"m_checkForeachParameters\" value=\"false\" />\n" +
-                 "  </inspection_tool>\n" +
-                 "</profile>";
-    foo.readExternal(JDOMUtil.loadDocument(test).getRootElement());
-    foo.initInspectionTools(getProject());
-    assertEquals(test, JDOMUtil.writeElement(serializeProfile(foo)));
-  }
-
   public static int countInitializedTools(@NotNull Profile foo) {
     return getInitializedTools((InspectionProfileImpl)foo).size();
   }
index 8709ee796ef38c060ac4778a1f17b7eb423b900e..58880e3e19fcba6fb7674f1e0f8e0e0da0205ac5 100644 (file)
@@ -41,7 +41,7 @@ class InspectionSchemeTest {
   @Test fun loadSchemes() {
     val schemeFile = fsRule.fs.getPath("inspection/Bar.xml")
     val schemeData = """
-    <inspections profile_name="Bar" version="1.0">
+    <inspections version="1.0">
       <option name="myName" value="Bar" />
       <inspection_tool class="Since15" enabled="true" level="ERROR" enabled_by_default="true" />
     "</inspections>""".trimIndent()
@@ -51,7 +51,7 @@ class InspectionSchemeTest {
     profileManager.forceInitProfiles(true)
     profileManager.initProfiles()
 
-    assertThat(profileManager.profiles).hasSize(2)
+    assertThat(profileManager.profiles).hasSize(1)
     val scheme = profileManager.profiles.first() as InspectionProfileImpl
     assertThat(scheme.name).isEqualTo("Bar")
 
@@ -61,5 +61,11 @@ class InspectionSchemeTest {
 
     assertThat(schemeFile.readText()).isEqualTo(schemeData)
     profileManager.profiles
+
+    schemeManagerFactory.process {
+      it.reload()
+    }
+
+    assertThat(profileManager.profiles).hasSize(1)
   }
 }
index 5e9ca964059ce8c6c30c55b388464f64b4930a6a..44a86d4a238820d893d593ee9efe8d16dd0b9511 100644 (file)
@@ -205,6 +205,15 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
     doTestReplaceChoice(OccurrencesChooser.ReplaceChoice.ALL);
   }
 
+  public void testBrokenFormattingWithInValidation() throws Exception {
+    doTest(new Pass<AbstractInplaceIntroducer>() {
+      @Override
+      public void pass(AbstractInplaceIntroducer introducer) {
+        type("bool");
+      }
+    });
+  }
+
   public void testStopEditing() {
     doTestStopEditing(new Pass<AbstractInplaceIntroducer>() {
       @Override
index 8c9619b112b56f31be40966cf60dde2be5c4006b..19ec879a4f3585bf685186df6be29246d5b5c39c 100644 (file)
@@ -60,7 +60,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
     return ActionHint.parse(file, contents);
   }
 
-  private static void doTestFor(final String testName, final QuickFixTestCase quickFixTestCase) {
+  private static void doTestFor(@NotNull String testName, @NotNull QuickFixTestCase quickFixTestCase) {
     final String relativePath = ObjectUtils.notNull(quickFixTestCase.getBasePath(), "") + "/" + BEFORE_PREFIX + testName;
     final String testFullPath = quickFixTestCase.getTestDataPath().replace(File.separatorChar, '/') + relativePath;
     final File testFile = new File(testFullPath);
@@ -204,7 +204,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
     return files;
   }
 
-  protected void doSingleTest(String fileSuffix) {
+  protected void doSingleTest(@NotNull String fileSuffix) {
     doTestFor(fileSuffix, createWrapper());
   }
 
@@ -212,10 +212,12 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
     doTestFor(fileSuffix, createWrapper(testDataPath));
   }
 
+  @NotNull
   protected QuickFixTestCase createWrapper() {
     return createWrapper(null);
   }
 
+  @NotNull
   protected QuickFixTestCase createWrapper(final String testDataPath) {
     return new QuickFixTestCase() {
       public String myTestDataPath = testDataPath;
@@ -225,6 +227,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
         return LightQuickFixTestCase.this.getBasePath();
       }
 
+      @NotNull
       @Override
       public String getTestDataPath() {
         if (myTestDataPath == null) {
@@ -240,27 +243,27 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
       }
 
       @Override
-      public void beforeActionStarted(String testName, String contents) {
+      public void beforeActionStarted(@NotNull String testName, @NotNull String contents) {
         LightQuickFixTestCase.this.beforeActionStarted(testName, contents);
       }
 
       @Override
-      public void afterActionCompleted(String testName, String contents) {
+      public void afterActionCompleted(@NotNull String testName, @NotNull String contents) {
         LightQuickFixTestCase.this.afterActionCompleted(testName, contents);
       }
 
       @Override
-      public void doAction(ActionHint actionHint, String testFullPath, String testName) throws Exception {
+      public void doAction(@NotNull ActionHint actionHint, @NotNull String testFullPath, @NotNull String testName) throws Exception {
         LightQuickFixTestCase.this.doAction(actionHint, testFullPath, testName);
       }
 
       @Override
-      public void checkResultByFile(String s, @NotNull String expectedFilePath, boolean b) throws Exception {
-        LightQuickFixTestCase.this.checkResultByFile(s, expectedFilePath, b);
+      public void checkResultByFile(@NotNull String message, @NotNull String expectedFilePath, boolean ignoreTrailingSpaces) throws Exception {
+        LightQuickFixTestCase.this.checkResultByFile(message, expectedFilePath, ignoreTrailingSpaces);
       }
 
       @Override
-      public IntentionAction findActionWithText(String text) {
+      public IntentionAction findActionWithText(@NotNull String text) {
         return LightQuickFixTestCase.this.findActionWithText(text);
       }
 
@@ -270,7 +273,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
       }
 
       @Override
-      public void invoke(IntentionAction action) {
+      public void invoke(@NotNull IntentionAction action) {
         LightQuickFixTestCase.invoke(action);
       }
 
@@ -287,7 +290,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
       }
 
       @Override
-      public void configureFromFileText(String name, String contents) throws IOException {
+      public void configureFromFileText(@NotNull String name, @NotNull String contents) throws IOException {
         LightPlatformCodeInsightTestCase.configureFromFileText(name, contents, true);
       }
 
@@ -313,6 +316,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
     return getAvailableActions(getEditor(), getFile());
   }
 
+  @NotNull
   public static List<IntentionAction> getAvailableActions(@NotNull Editor editor, @NotNull PsiFile file) {
     return CodeInsightTestFixtureImpl.getAvailableIntentions(editor, file);
   }
index 8c00ae4149dceeaad70fb35de1f7abeb3d4783dd..e69b636fecd618a7bd19a62068fb3a133921541e 100644 (file)
@@ -31,24 +31,25 @@ import java.util.List;
 public interface QuickFixTestCase {
   String getBasePath();
 
+  @NotNull
   String getTestDataPath();
 
   @NotNull
   ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents);
 
-  void beforeActionStarted(String testName, String contents);
+  void beforeActionStarted(@NotNull String testName, @NotNull String contents);
 
-  void afterActionCompleted(String testName, String contents);
+  void afterActionCompleted(@NotNull String testName, @NotNull String contents);
 
-  void doAction(ActionHint actionHint, String testFullPath, String testName) throws Exception;
+  void doAction(@NotNull ActionHint actionHint, @NotNull String testFullPath, @NotNull String testName) throws Exception;
 
-  void checkResultByFile(String s, @NotNull String expectedFilePath, boolean b) throws Exception;
+  void checkResultByFile(@NotNull String message, @NotNull String expectedFilePath, boolean ignoreTrailingSpaces) throws Exception;
 
-  IntentionAction findActionWithText(String text);
+  IntentionAction findActionWithText(@NotNull String text);
 
   boolean shouldBeAvailableAfterExecution();
 
-  void invoke(IntentionAction action);
+  void invoke(@NotNull IntentionAction action);
 
   @NotNull
   List<HighlightInfo> doHighlighting();
@@ -58,7 +59,7 @@ public interface QuickFixTestCase {
 
   void bringRealEditorBack();
 
-  void configureFromFileText(String name, String contents) throws Throwable;
+  void configureFromFileText(@NotNull String name, @NotNull String contents) throws Throwable;
 
   PsiFile getFile();
 
index 08e65fc15cc34eab0c0e22bede34f952634e692a..163875cb8423495d380059a2d7fc1afbd2ccd384 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.profile;
 
 import com.intellij.openapi.options.Scheme;
 import com.intellij.util.xmlb.annotations.Transient;
-import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
 
 /**
@@ -25,8 +24,6 @@ import org.jetbrains.annotations.NotNull;
  * Date: 20-Nov-2005
  */
 public interface Profile extends Comparable, Scheme {
-  void copyFrom(@NotNull Profile profile);
-
   @Transient
   boolean isProjectLevel();
 
@@ -42,8 +39,4 @@ public interface Profile extends Comparable, Scheme {
 
   @NotNull
   ProfileManager getProfileManager();
-
-  void readExternal(Element element);
-
-  void writeExternal(Element element);
 }
index f45ffc640444820373a3e64efc02dcc8dadbafac..63fadcb0afa5135a793df9d993cd4aa641994963 100644 (file)
@@ -26,13 +26,13 @@ import com.intellij.openapi.util.JDOMUtil;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.profile.codeInspection.InspectionProfileManager;
 import com.intellij.profile.codeInspection.SeverityProvider;
-import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -50,7 +50,6 @@ public class InspectionProfileConvertor {
 
   @NonNls private static final String NAME_ATT = "name";
   @NonNls private static final String VERSION_ATT = "version";
-  @NonNls private static final String PROFILE_NAME_ATT = "profile_name";
   @NonNls private static final String OPTION_TAG = "option";
   @NonNls private static final String DISPLAY_LEVEL_MAP_OPTION = "DISPLAY_LEVEL_MAP";
   @NonNls protected static final String VALUE_ATT = "value";
@@ -110,11 +109,9 @@ public class InspectionProfileConvertor {
       return;
     }
     try {
-      Document doc = JDOMUtil.loadDocument(files[0]);
-      Element root = doc.getRootElement();
+      Element root = JDOMUtil.load(files[0]);
       if (root.getAttributeValue(VERSION_ATT) == null){
-        root.setAttribute(PROFILE_NAME_ATT, OLD_DEFAUL_PROFILE);
-        JDOMUtil.writeDocument(doc, new File(profileDirectory, OLD_DEFAUL_PROFILE + XML_EXTENSION), "\n");
+        JDOMUtil.writeParent(root, new FileOutputStream(new File(profileDirectory, OLD_DEFAUL_PROFILE + XML_EXTENSION)), "\n");
         FileUtil.delete(files[0]);
       }
     }
index ac90288376788a8df4be23fd5752159a05bc81ed..0556319665dd08f20da9340df29d189de4aaf06d 100644 (file)
@@ -33,10 +33,7 @@ import com.intellij.openapi.util.*;
 import com.intellij.profile.ProfileEx;
 import com.intellij.profile.ProfileManager;
 import com.intellij.profile.codeInspection.InspectionProfileManager;
-import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
-import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerKt;
 import com.intellij.profile.codeInspection.SeverityProvider;
-import com.intellij.project.ProjectKt;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.search.scope.packageSet.NamedScope;
 import com.intellij.util.ArrayUtil;
@@ -104,7 +101,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
   public InspectionProfileImpl(@NotNull String profileName,
                                @NotNull InspectionToolRegistrar registrar,
                                @NotNull ProfileManager profileManager) {
-    this(profileName, registrar, profileManager, getDefaultProfile(), null);
+    this(profileName, registrar, profileManager, getBaseProfile(), null);
   }
 
   public InspectionProfileImpl(@NotNull @NonNls String profileName) {
@@ -128,7 +125,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
                                @NotNull InspectionToolRegistrar registrar,
                                @NotNull ProfileManager profileManager,
                                @Nullable SchemeDataHolder<? super InspectionProfileImpl> dataHolder) {
-    this(profileName, registrar, profileManager, getDefaultProfile(), dataHolder);
+    this(profileName, registrar, profileManager, getBaseProfile(), dataHolder);
   }
 
   @NotNull
@@ -166,7 +163,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
   }
 
   @NotNull
-  public static InspectionProfileImpl getDefaultProfile() {
+  public static InspectionProfileImpl getBaseProfile() {
     return InspectionProfileImplHolder.DEFAULT_PROFILE;
   }
 
@@ -281,26 +278,15 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
 
   @NotNull
   public Element writeScheme() {
-    if (myDataHolder != null) {
-      return myDataHolder.read();
-    }
-
-    Element element = new Element("profile");
-    Element result = isProjectLevel() ? element.setAttribute("version", "1.0") : element.setAttribute("profile_name", getName());
-    serializeInto(result, false);
-
-    if (isProjectLevel() && ProjectKt.isDirectoryBased(((ProjectInspectionProfileManager)myProfileManager).getProject())) {
-      return new Element("component").setAttribute("name", "InspectionProjectProfileManager").addContent(result);
-    }
-    return result;
+    return myDataHolder == null ? super.writeScheme() : myDataHolder.read();
   }
 
   @Override
-  public void serializeInto(@NotNull Element element, boolean preserveCompatibility) {
+  public void writeExternal(@NotNull Element element) {
     // must be first - compatibility
     element.setAttribute(VERSION_TAG, VALID_VERSION);
 
-    super.serializeInto(element, preserveCompatibility);
+    super.writeExternal(element);
 
     synchronized (myLock) {
       if (!myInitialized) {
@@ -857,24 +843,23 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
     initInspectionTools(project);
 
     for (Element scopeElement : scopes.getChildren(SCOPE)) {
-      final String profile = scopeElement.getAttributeValue(ProjectInspectionProfileManagerKt.PROFILE);
-      if (profile != null) {
-        final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)getProfileManager().getProfile(profile);
-        if (inspectionProfile != null) {
-          final NamedScope scope = getProfileManager().getScopesManager().getScope(scopeElement.getAttributeValue(NAME));
-          if (scope != null) {
-            for (InspectionToolWrapper toolWrapper : inspectionProfile.getInspectionTools(null)) {
-              final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
-              try {
-                InspectionToolWrapper toolWrapperCopy = copyToolSettings(toolWrapper);
-                HighlightDisplayLevel errorLevel = inspectionProfile.getErrorLevel(key, null, project);
-                getTools(toolWrapper.getShortName(), project).addTool(scope, toolWrapperCopy, inspectionProfile.isToolEnabled(key), errorLevel);
-              }
-              catch (Exception e) {
-                LOG.error(e);
-              }
-            }
-          }
+      final String profile = scopeElement.getAttributeValue(PROFILE);
+      InspectionProfileImpl inspectionProfile = profile == null ? null : (InspectionProfileImpl)getProfileManager().getProfile(profile);
+      NamedScope scope = inspectionProfile == null ? null : getProfileManager().getScopesManager().getScope(scopeElement.getAttributeValue(NAME));
+      if (scope == null) {
+        continue;
+      }
+
+      for (InspectionToolWrapper toolWrapper : inspectionProfile.getInspectionTools(null)) {
+        final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
+        try {
+          InspectionToolWrapper toolWrapperCopy = copyToolSettings(toolWrapper);
+          HighlightDisplayLevel errorLevel = inspectionProfile.getErrorLevel(key, null, project);
+          getTools(toolWrapper.getShortName(), project)
+            .addTool(scope, toolWrapperCopy, inspectionProfile.isToolEnabled(key), errorLevel);
+        }
+        catch (Exception e) {
+          LOG.error(e);
         }
       }
     }
index 9ff4b6785519d0f4e54cb8be0f342ce852467a1a..6060227b2c09fc2685c5aae6d3a2f201c697f292 100644 (file)
@@ -15,7 +15,8 @@
  */
 package com.intellij.profile;
 
-import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerKt;
+import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
+import com.intellij.project.ProjectKt;
 import com.intellij.util.xmlb.SmartSerializer;
 import com.intellij.util.xmlb.annotations.OptionTag;
 import com.intellij.util.xmlb.annotations.Transient;
@@ -29,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
 public abstract class ProfileEx implements Profile {
   public static final String SCOPE = "scope";
   public static final String NAME = "name";
+  public static final String PROFILE = "profile";
 
   private final SmartSerializer mySerializer;
 
@@ -84,18 +86,12 @@ public abstract class ProfileEx implements Profile {
     myProfileManager = profileManager;
   }
 
-  @Override
   public void readExternal(Element element) {
     mySerializer.readExternal(this, element);
   }
 
-  public void serializeInto(@NotNull Element element, boolean preserveCompatibility) {
-    mySerializer.writeExternal(this, element, preserveCompatibility);
-  }
-
-  @Override
-  public final void writeExternal(Element element) {
-    serializeInto(element, true);
+  public void writeExternal(@NotNull Element element) {
+    mySerializer.writeExternal(this, element, false);
   }
 
   public boolean equals(Object o) {
@@ -114,15 +110,21 @@ public abstract class ProfileEx implements Profile {
     return 0;
   }
 
-  @Override
-  public final void copyFrom(@NotNull Profile profile) {
-    readExternal(serializeProfile(profile));
+  public final void copyFrom(@NotNull ProfileEx profile) {
+    readExternal(profile.writeScheme());
   }
 
   @NotNull
-  public static Element serializeProfile(@NotNull Profile profile) {
-    Element result = new Element(ProjectInspectionProfileManagerKt.PROFILE);
-    profile.writeExternal(result);
-    return result;
+  public Element writeScheme() {
+    Element element = new Element(PROFILE);
+    if (isProjectLevel()) {
+      element.setAttribute("version", "1.0");
+    }
+    writeExternal(element);
+
+    if (isProjectLevel() && ProjectKt.isDirectoryBased(((ProjectInspectionProfileManager)myProfileManager).getProject())) {
+      return new Element("component").setAttribute("name", "InspectionProjectProfileManager").addContent(element);
+    }
+    return element;
   }
 }
index d0593856fc8aad129fbe468b60f3819e39fe8b2a..f6a759bfbe13cfa014a37d99ccfca326a1a3f874 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.util.Disposer
 import com.intellij.openapi.util.text.StringUtil
 import com.intellij.packageDependencies.DependencyValidationManager
 import com.intellij.profile.Profile
+import com.intellij.profile.ProfileEx
 import com.intellij.project.isDirectoryBased
 import com.intellij.psi.search.scope.packageSet.NamedScopeManager
 import com.intellij.psi.search.scope.packageSet.NamedScopesHolder
@@ -50,8 +51,6 @@ import org.jetbrains.concurrency.runAsync
 import java.util.*
 import java.util.function.Function
 
-const val PROFILE = "profile"
-
 private const val VERSION = "1.0"
 private const val SCOPE = "scope"
 private const val NAME = "name"
@@ -99,7 +98,7 @@ class ProjectInspectionProfileManager(val project: Project,
                               attributeProvider: Function<String, String?>,
                               isBundled: Boolean): InspectionProfileImpl {
       val profile = InspectionProfileImpl(name, InspectionToolRegistrar.getInstance(), this@ProjectInspectionProfileManager,
-                                          InspectionProfileImpl.getDefaultProfile(), dataHolder)
+                                          InspectionProfileImpl.getBaseProfile(), dataHolder)
       profile.isProjectLevel = true
       return profile
     }
@@ -307,8 +306,8 @@ class ProjectInspectionProfileManager(val project: Project,
       currentScheme = schemeManager.allSchemes.firstOrNull()
       if (currentScheme == null) {
         currentScheme = InspectionProfileImpl(PROJECT_DEFAULT_PROFILE_NAME, InspectionToolRegistrar.getInstance(), this,
-                                              InspectionProfileImpl.getDefaultProfile(), null)
-        currentScheme.copyFrom(applicationProfileManager.currentProfile)
+                                              InspectionProfileImpl.getBaseProfile(), null)
+        currentScheme.copyFrom(applicationProfileManager.currentProfile as ProfileEx)
         currentScheme.isProjectLevel = true
         currentScheme.name = PROJECT_DEFAULT_PROFILE_NAME
         schemeManager.addScheme(currentScheme)
index eb9b341f43160bb9ee1d0f72a7880e9b157471d5..a210200778f680d5cd36eda29e0284e8831e068f 100644 (file)
@@ -233,11 +233,11 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
       val bytes = URLUtil.openStream(url).readBytes()
       lazyPreloadScheme(bytes, isUseOldFileNameSanitize) { name, parser ->
         val attributeProvider = Function<String, String?> { parser.getAttributeValue(null, it) }
-        val schemeName = name ?: (processor as LazySchemeProcessor).getName(attributeProvider)
-
         val fileName = PathUtilRt.getFileName(url.path)
         val extension = getFileExtension(fileName, true)
         val externalInfo = ExternalInfo(fileName.substring(0, fileName.length - extension.length), extension)
+
+        val schemeName = name ?: (processor as LazySchemeProcessor).getName(attributeProvider, externalInfo.fileNameWithoutExtension)
         externalInfo.schemeName = schemeName
 
         val scheme = (processor as LazySchemeProcessor).createScheme(SchemeDataHolderImpl(bytes, externalInfo), schemeName, attributeProvider, true)
@@ -316,7 +316,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
         processPendingCurrentSchemeName(scheme)
       }
 
-      messageBus?.let { it.connect().subscribe(VirtualFileManager.VFS_CHANGES, SchemeFileTracker()) }
+      messageBus?.connect()?.subscribe(VirtualFileManager.VFS_CHANGES, SchemeFileTracker())
 
       return schemes.subList(newSchemesOffset, schemes.size)
     }
@@ -438,7 +438,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
       val bytes = input.readBytes()
       lazyPreloadScheme(bytes, isUseOldFileNameSanitize) { name, parser ->
         val attributeProvider = Function<String, String?> { parser.getAttributeValue(null, it) }
-        val schemeName = name ?: processor.getName(attributeProvider)
+        val schemeName = name ?: processor.getName(attributeProvider, fileNameWithoutExtension)
         if (!checkExisting(schemeName)) {
           return null
         }
@@ -573,7 +573,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
     var externalInfo: ExternalInfo? = schemeToInfo.get(scheme)
     val currentFileNameWithoutExtension = externalInfo?.fileNameWithoutExtension
     val parent = processor.writeScheme(scheme)
-    val element = if (parent is Element) parent else (parent as Document).detachRootElement()
+    val element = parent as? Element ?: (parent as Document).detachRootElement()
     if (element.isEmpty()) {
       externalInfo?.scheduleDelete()
       return
@@ -685,7 +685,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
 
     val bundledScheme = readOnlyExternalizableSchemes.get(scheme.name)
     if (bundledScheme == null) {
-      if ((processor as? LazySchemeProcessor)?.let { it.isSchemeEqualToBundled(scheme) } ?: false) {
+      if ((processor as? LazySchemeProcessor)?.isSchemeEqualToBundled(scheme) ?: false) {
         externalInfo?.scheduleDelete()
         return true
       }
@@ -875,9 +875,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
 
   private fun collectExistingNames(schemes: Collection<T>): Collection<String> {
     val result = THashSet<String>(schemes.size)
-    for (scheme in schemes) {
-      result.add(scheme.name)
-    }
+    schemes.mapTo(result) { it.name }
     return result
   }
 
index 643223564c8d6e3904eab3cc527b9301fa908e1c..b2de180119b029fec75e8993196bf5267878899c 100644 (file)
@@ -15,7 +15,8 @@
  */
 package com.intellij.openapi.util;
 
-import gnu.trove.TIntObjectHashMap;
+import com.intellij.util.containers.ConcurrentIntObjectMap;
+import com.intellij.util.containers.ContainerUtil;
 import org.intellij.lang.annotations.MagicConstant;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -28,24 +29,24 @@ public interface Iconable {
   @Deprecated int ICON_FLAG_OPEN = 0x0004;
   @Deprecated int ICON_FLAG_CLOSED = 0x0008;
 
-  @MagicConstant(flags = {ICON_FLAG_VISIBILITY, ICON_FLAG_OPEN, ICON_FLAG_CLOSED, ICON_FLAG_READ_STATUS})
+  @MagicConstant(flags = {ICON_FLAG_VISIBILITY, ICON_FLAG_READ_STATUS})
   @interface IconFlags {}
 
   Icon getIcon(@IconFlags int flags);
 
   class LastComputedIcon {
-    private static final Key<TIntObjectHashMap<Icon>> LAST_COMPUTED_ICON = Key.create("lastComputedIcon");
+    private static final Key<ConcurrentIntObjectMap<Icon>> LAST_COMPUTED_ICON = Key.create("lastComputedIcon");
 
     @Nullable
     public static Icon get(@NotNull UserDataHolder holder, int flags) {
-      TIntObjectHashMap<Icon> map = holder.getUserData(LAST_COMPUTED_ICON);
+      ConcurrentIntObjectMap<Icon> map = holder.getUserData(LAST_COMPUTED_ICON);
       return map == null ? null : map.get(flags);
     }
 
     public static void put(@NotNull UserDataHolder holder, Icon icon, int flags) {
-      TIntObjectHashMap<Icon> map = holder.getUserData(LAST_COMPUTED_ICON);
+      ConcurrentIntObjectMap<Icon> map = holder.getUserData(LAST_COMPUTED_ICON);
       if (map == null) {
-        map = ((UserDataHolderEx)holder).putUserDataIfAbsent(LAST_COMPUTED_ICON, new TIntObjectHashMap<Icon>());
+        map = ((UserDataHolderEx)holder).putUserDataIfAbsent(LAST_COMPUTED_ICON, ContainerUtil.<Icon>createConcurrentIntObjectMap());
       }
       map.put(flags, icon);
     }
index 91a9339090665cddd98d3fc6989a35ca8b2425ca..b83dc9cfe765aa15850e9ebaa779d60eb3df5f32 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.openapi.util;
 
-import com.intellij.Patches;
 import com.intellij.util.xmlb.annotations.Transient;
 
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@@ -26,15 +25,11 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
  */
 @Transient
 public class SimpleModificationTracker implements ModificationTracker {
-  static {
-    //noinspection ConstantConditions
-    assert Patches.JDK_BUG_ID_7103570;
-  }
-
   private static final AtomicIntegerFieldUpdater<SimpleModificationTracker> UPDATER =
     AtomicIntegerFieldUpdater.newUpdater(SimpleModificationTracker.class, "myCounter");
 
-  public volatile int myCounter;  // is public to work around JDK-7103570
+  @SuppressWarnings("unused")
+  private volatile int myCounter;
 
   @Override
   public long getModificationCount() {
@@ -42,6 +37,10 @@ public class SimpleModificationTracker implements ModificationTracker {
   }
 
   public void incModificationCount() {
-    UPDATER.incrementAndGet(this);
+    incAndGetModificationCount();
+  }
+
+  public long incAndGetModificationCount() {
+    return UPDATER.incrementAndGet(this);
   }
 }
\ No newline at end of file
index d206dd51cf4a5ebf4af7aa282d5e664fdf1b4289..f33c224d7b44aa781d482bc1585f03158c65e5cd 100644 (file)
@@ -49,7 +49,6 @@ public abstract class DeprecatedVirtualFileSystem extends VirtualFileSystem {
     myEventDispatcher.removeListener(listener);
   }
 
-  @SuppressWarnings("unused")
   protected void firePropertyChanged(Object requestor,
                                      @NotNull VirtualFile file,
                                      @NotNull String propertyName,
@@ -60,42 +59,36 @@ public abstract class DeprecatedVirtualFileSystem extends VirtualFileSystem {
     myEventDispatcher.getMulticaster().propertyChanged(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireContentsChanged(Object requestor, @NotNull VirtualFile file, long oldModificationStamp) {
     assertWriteAccessAllowed();
     VirtualFileEvent event = new VirtualFileEvent(requestor, file, file.getParent(), oldModificationStamp, file.getModificationStamp());
     myEventDispatcher.getMulticaster().contentsChanged(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireFileCreated(@Nullable Object requestor, @NotNull VirtualFile file) {
     assertWriteAccessAllowed();
     VirtualFileEvent event = new VirtualFileEvent(requestor, file, file.getName(), file.getParent());
     myEventDispatcher.getMulticaster().fileCreated(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireFileDeleted(Object requestor, @NotNull VirtualFile file, @NotNull String fileName, VirtualFile parent) {
     assertWriteAccessAllowed();
     VirtualFileEvent event = new VirtualFileEvent(requestor, file, fileName, parent);
     myEventDispatcher.getMulticaster().fileDeleted(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireFileMoved(Object requestor, @NotNull VirtualFile file, VirtualFile oldParent) {
     assertWriteAccessAllowed();
     VirtualFileMoveEvent event = new VirtualFileMoveEvent(requestor, file, oldParent, file.getParent());
     myEventDispatcher.getMulticaster().fileMoved(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireFileCopied(@Nullable Object requestor, @NotNull VirtualFile originalFile, @NotNull VirtualFile createdFile) {
     assertWriteAccessAllowed();
     VirtualFileCopyEvent event = new VirtualFileCopyEvent(requestor, originalFile, createdFile);
     myEventDispatcher.getMulticaster().fileCopied(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireBeforePropertyChange(Object requestor,
                                           @NotNull VirtualFile file,
                                           @NotNull String propertyName,
@@ -106,21 +99,18 @@ public abstract class DeprecatedVirtualFileSystem extends VirtualFileSystem {
     myEventDispatcher.getMulticaster().beforePropertyChange(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireBeforeContentsChange(Object requestor, @NotNull VirtualFile file) {
     assertWriteAccessAllowed();
     VirtualFileEvent event = new VirtualFileEvent(requestor, file, file.getName(), file.getParent());
     myEventDispatcher.getMulticaster().beforeContentsChange(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireBeforeFileDeletion(Object requestor, @NotNull VirtualFile file) {
     assertWriteAccessAllowed();
     VirtualFileEvent event = new VirtualFileEvent(requestor, file, file.getName(), file.getParent());
     myEventDispatcher.getMulticaster().beforeFileDeletion(event);
   }
 
-  @SuppressWarnings("unused")
   protected void fireBeforeFileMovement(Object requestor, @NotNull VirtualFile file, VirtualFile newParent) {
     assertWriteAccessAllowed();
     VirtualFileMoveEvent event = new VirtualFileMoveEvent(requestor, file, file.getParent(), newParent);
@@ -166,7 +156,7 @@ public abstract class DeprecatedVirtualFileSystem extends VirtualFileSystem {
   @NotNull
   @Override
   public VirtualFile copyFile(Object requestor, @NotNull VirtualFile vFile, @NotNull VirtualFile newParent, @NotNull String copyName) throws IOException {
-    throw unsupported("copyFile() not supported", vFile);
+    throw unsupported("copyFile", vFile);
   }
 
   private UnsupportedOperationException unsupported(String op, VirtualFile vFile) {
index f2da8bc222e457ea815a6a15f8a57934d16834f3..f1ff9187bee8a7aea5f4f614f9bb725b5fdd061b 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.
@@ -105,6 +105,9 @@ public interface CommonClassNames {
 
   @NonNls String JAVA_UTIL_STREAM_BASE_STREAM = "java.util.stream.BaseStream";
   @NonNls String JAVA_UTIL_STREAM_STREAM = "java.util.stream.Stream";
+  @NonNls String JAVA_UTIL_STREAM_INT_STREAM = "java.util.stream.IntStream";
+  @NonNls String JAVA_UTIL_STREAM_LONG_STREAM = "java.util.stream.LongStream";
+  @NonNls String JAVA_UTIL_STREAM_DOUBLE_STREAM = "java.util.stream.DoubleStream";
   @NonNls String JAVA_UTIL_STREAM_COLLECTORS = "java.util.stream.Collectors";
   @NonNls String JAVA_UTIL_FUNCTION_PREDICATE = "java.util.function.Predicate";
 
index 3233e3359ea3036bed0ecf8984e660daaf13f9be..1ce0f42443a52554621f7b58df30f585a5b87e5b 100644 (file)
@@ -15,6 +15,8 @@
  */
 package com.intellij.openapi.editor.impl;
 
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.ex.MarkupIterator;
 import com.intellij.openapi.util.Getter;
 import com.intellij.util.IncorrectOperationException;
@@ -42,6 +44,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * User: cdr
  */
 abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBlackTree<T> implements IntervalTree<T> {
+  static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.RangeMarkerTree");
+  static final boolean DEBUG = LOG.isDebugEnabled() || ApplicationManager.getApplication() != null && (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isInternal());
   private int keySize; // number of all intervals, counting all duplicates, some of them maybe gced
   final ReadWriteLock l = new ReentrantReadWriteLock();
 
@@ -66,7 +70,7 @@ abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBlackTree<
     @NotNull
     private final IntervalTreeImpl<E> myIntervalTree;
 
-    public IntervalNode(@NotNull IntervalTreeImpl<E> intervalTree, @NotNull E key, int start, int end) {
+    IntervalNode(@NotNull IntervalTreeImpl<E> intervalTree, @NotNull E key, int start, int end) {
       // maxEnd == 0 so to not disrupt existing maxes
       myIntervalTree = intervalTree;
       myStart = start;
@@ -374,7 +378,9 @@ abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBlackTree<
   }
 
   private void assertUnderWriteLock() {
-    assert isAcquired(l.writeLock()) : l.writeLock();
+    if (DEBUG) {
+      assert isAcquired(l.writeLock()) : l.writeLock();
+    }
   }
   private static boolean isAcquired(@NotNull Lock l) {
     String s = l.toString();
index 14ef8ccc977e236a60bb5a4974e04895fc0a9602..e012f11af4971665ca3d97fc4ceccd3a9b33d471 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.openapi.editor.impl;
 
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.event.DocumentEvent;
 import com.intellij.openapi.editor.ex.PrioritizedDocumentListener;
@@ -38,9 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger;
  * User: cdr
  */
 public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.RangeMarkerTree");
-  private static final boolean DEBUG = LOG.isDebugEnabled() || ApplicationManager.getApplication() != null && (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isInternal());
-
   private final PrioritizedDocumentListener myListener;
   private final Document myDocument;
 
@@ -159,12 +155,12 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
     private static final byte EXPAND_TO_LEFT_FLAG = VALID_FLAG<<1;
     private static final byte EXPAND_TO_RIGHT_FLAG = EXPAND_TO_LEFT_FLAG<<1;
 
-    public RMNode(@NotNull RangeMarkerTree<T> rangeMarkerTree,
-                  @NotNull T key,
-                  int start,
-                  int end,
-                  boolean greedyToLeft,
-                  boolean greedyToRight) {
+    RMNode(@NotNull RangeMarkerTree<T> rangeMarkerTree,
+           @NotNull T key,
+           int start,
+           int end,
+           boolean greedyToLeft,
+           boolean greedyToRight) {
       super(rangeMarkerTree, key, start, end);
       setFlag(EXPAND_TO_LEFT_FLAG, greedyToLeft);
       setFlag(EXPAND_TO_RIGHT_FLAG, greedyToRight);
index 1b1b926d6f9de7a8217b3839ad975da0c201a1f6..7c8340f04f4593a31ecac8429c6f4d398751eb8b 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.diff.util.MergeRange;
 import com.intellij.diff.util.Range;
 import com.intellij.diff.util.Side;
 import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.util.registry.Registry;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -160,6 +161,11 @@ public class ComparisonMergeUtil {
   public static CharSequence tryResolveConflict(@NotNull CharSequence leftText,
                                                 @NotNull CharSequence baseText,
                                                 @NotNull CharSequence rightText) {
-    return MergeResolveUtil.tryResolveConflict(leftText, baseText, rightText);
+    if (Registry.is("diff.merge.resolve.conflict.action.use.greedy.approach")) {
+      return MergeResolveUtil.tryGreedyResolve(leftText, baseText, rightText);
+    }
+    else {
+      return MergeResolveUtil.tryResolve(leftText, baseText, rightText);
+    }
   }
 }
\ No newline at end of file
index 4096c79fc003afc6160c1fcd05ef2e8381658b88..df886328b8e6b7bd59a2f70a5146633bd95cb363 100644 (file)
 package com.intellij.diff.comparison
 
 import com.intellij.diff.fragments.DiffFragment
+import com.intellij.diff.util.DiffUtil
 import com.intellij.diff.util.Side
 import com.intellij.diff.util.Side.LEFT
 import com.intellij.diff.util.Side.RIGHT
+import com.intellij.diff.util.TextDiffType
+import com.intellij.diff.util.ThreeSide
 import com.intellij.openapi.progress.DumbProgressIndicator
 import com.intellij.util.text.MergingCharSequence
 
 object MergeResolveUtil {
+  @JvmStatic
+  fun tryResolve(leftText: CharSequence, baseText: CharSequence, rightText: CharSequence): CharSequence? {
+    try {
+      val resolved = tryResolve(leftText, baseText, rightText, ComparisonPolicy.DEFAULT)
+      if (resolved != null) return resolved
+
+      return tryResolve(leftText, baseText, rightText, ComparisonPolicy.IGNORE_WHITESPACES)
+    }
+    catch (e: DiffTooBigException) {
+      return null
+    }
+  }
+
   /*
    * Here we assume, that resolve results are explicitly verified by user and can be safely undone.
    * Thus we trade higher chances of incorrect resolve for higher chances of correct resolve.
@@ -36,12 +52,12 @@ object MergeResolveUtil {
    * modifications can be considered as "insertion + deletion" and resolved accordingly.
    */
   @JvmStatic
-  fun tryResolveConflict(leftText: CharSequence, baseText: CharSequence, rightText: CharSequence): CharSequence? {
+  fun tryGreedyResolve(leftText: CharSequence, baseText: CharSequence, rightText: CharSequence): CharSequence? {
     try {
-      val resolved = Helper(leftText, baseText, rightText).execute(ComparisonPolicy.DEFAULT)
+      val resolved = tryGreedyResolve(leftText, baseText, rightText, ComparisonPolicy.DEFAULT)
       if (resolved != null) return resolved
 
-      return Helper(leftText, baseText, rightText).execute(ComparisonPolicy.IGNORE_WHITESPACES)
+      return tryGreedyResolve(leftText, baseText, rightText, ComparisonPolicy.IGNORE_WHITESPACES)
     }
     catch (e: DiffTooBigException) {
       return null
@@ -49,6 +65,46 @@ object MergeResolveUtil {
   }
 }
 
+private fun tryResolve(leftText: CharSequence, baseText: CharSequence, rightText: CharSequence,
+                       policy: ComparisonPolicy): CharSequence? {
+  val texts = listOf(leftText, baseText, rightText)
+
+  val changes = ByWord.compare(leftText, baseText, rightText, policy, DumbProgressIndicator.INSTANCE)
+
+  val newContent = StringBuilder()
+
+  var last = 0
+  for (fragment in changes) {
+    val type = DiffUtil.getWordMergeType(fragment, texts, policy)
+    if (type.diffType == TextDiffType.CONFLICT) return null;
+
+    val baseStart = fragment.getStartOffset(ThreeSide.BASE)
+    val baseEnd = fragment.getEndOffset(ThreeSide.BASE)
+
+    newContent.append(baseText, last, baseStart)
+
+    if (type.isChange(Side.LEFT)) {
+      val leftStart = fragment.getStartOffset(ThreeSide.LEFT)
+      val leftEnd = fragment.getEndOffset(ThreeSide.LEFT)
+      newContent.append(leftText, leftStart, leftEnd)
+    }
+    else {
+      val rightStart = fragment.getStartOffset(ThreeSide.RIGHT)
+      val rightEnd = fragment.getEndOffset(ThreeSide.RIGHT)
+      newContent.append(rightText, rightStart, rightEnd)
+    }
+    last = baseEnd
+  }
+
+  newContent.append(baseText, last, baseText.length)
+  return newContent.toString()
+}
+
+private fun tryGreedyResolve(leftText: CharSequence, baseText: CharSequence, rightText: CharSequence,
+                             policy: ComparisonPolicy): CharSequence? {
+  return Helper(leftText, baseText, rightText).execute(policy)
+}
+
 private class Helper(val leftText: CharSequence, val baseText: CharSequence, val rightText: CharSequence) {
   val newContent = StringBuilder()
 
index fc8d62f14922b139d2576933b0160602c893526e..3ade1e10cfd3f4fdbc53916d4c37e669ef573437 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.diff.SuppressiveDiffTool;
 import com.intellij.diff.comparison.ByWord;
 import com.intellij.diff.comparison.ComparisonManager;
 import com.intellij.diff.comparison.ComparisonPolicy;
+import com.intellij.diff.comparison.ComparisonUtil;
 import com.intellij.diff.contents.DiffContent;
 import com.intellij.diff.contents.DocumentContent;
 import com.intellij.diff.contents.EmptyContent;
@@ -30,6 +31,7 @@ import com.intellij.diff.contents.FileContent;
 import com.intellij.diff.fragments.DiffFragment;
 import com.intellij.diff.fragments.LineFragment;
 import com.intellij.diff.fragments.MergeLineFragment;
+import com.intellij.diff.fragments.MergeWordFragment;
 import com.intellij.diff.impl.DiffSettingsHolder;
 import com.intellij.diff.impl.DiffSettingsHolder.DiffSettings;
 import com.intellij.diff.requests.ContentDiffRequest;
@@ -1069,6 +1071,36 @@ public class DiffUtil {
     return fragment.getStartLine(side) == fragment.getEndLine(side);
   }
 
+  @NotNull
+  public static MergeConflictType getWordMergeType(@NotNull MergeWordFragment fragment,
+                                                   @NotNull List<? extends CharSequence> texts,
+                                                   @NotNull ComparisonPolicy policy) {
+    return getMergeType((side) -> isWordMergeIntervalEmpty(fragment, side),
+                        (side1, side2) -> compareWordMergeContents(fragment, texts, policy, side1, side2));
+  }
+
+  private static boolean compareWordMergeContents(@NotNull MergeWordFragment fragment,
+                                                  @NotNull List<? extends CharSequence> texts,
+                                                  @NotNull ComparisonPolicy policy,
+                                                  @NotNull ThreeSide side1,
+                                                  @NotNull ThreeSide side2) {
+    int start1 = fragment.getStartOffset(side1);
+    int end1 = fragment.getEndOffset(side1);
+    int start2 = fragment.getStartOffset(side2);
+    int end2 = fragment.getEndOffset(side2);
+
+    CharSequence document1 = side1.select(texts);
+    CharSequence document2 = side2.select(texts);
+
+    CharSequence content1 = document1.subSequence(start1, end1);
+    CharSequence content2 = document2.subSequence(start2, end2);
+    return ComparisonUtil.isEquals(content1, content2, policy);
+  }
+
+  private static boolean isWordMergeIntervalEmpty(@NotNull MergeWordFragment fragment, @NotNull ThreeSide side) {
+    return fragment.getStartOffset(side) == fragment.getEndOffset(side);
+  }
+
   //
   // Writable
   //
index 1283f7ed8f467579e3235e81df72d614569ebb4d..c5c299bd593a463d1e0c1f2970e95dd8779fa1c5 100644 (file)
@@ -118,35 +118,35 @@ class MergeResolveUtilTest : DiffTestCase() {
   }
 
   fun testNonFailureConflicts() {
-    test(
+    testGreedy(
         "x X x",
         "x x",
         "x X Y x",
         "x Y x"
     )
 
-    test(
+    testGreedy(
         "x X x",
         "x x",
         "x Y X x",
         "x Y x"
     )
 
-    test(
+    testGreedy(
         "x X Y x",
         "x X x",
         "x Y x",
         "x x"
     )
 
-    test(
+    testGreedy(
         "x X Y Z x",
         "x X x",
         "x Z x",
         "x x"
     )
 
-    test(
+    testGreedy(
         "x A B C D E F G H K x",
         "x C F K x",
         "x A D H x",
@@ -157,21 +157,21 @@ class MergeResolveUtilTest : DiffTestCase() {
   fun testConfusingConflicts() {
     // these cases might be a failure as well
 
-    test(
+    testGreedy(
         "x X x",
         "x x",
         "x Z x",
         "xZ x"
     )
 
-    test(
+    testGreedy(
         "x X X x",
         "x X Y X x",
         "x x",
         "x Y x"
     )
 
-    test(
+    testGreedy(
         "x X x",
         "x x",
         "x Y x",
@@ -179,7 +179,7 @@ class MergeResolveUtilTest : DiffTestCase() {
     )
 
 
-    test(
+    testGreedy(
         "x X X x",
         "x Y x",
         "x X Y x",
@@ -187,8 +187,25 @@ class MergeResolveUtilTest : DiffTestCase() {
     )
   }
 
-  private fun test(base: String, left: String, right: String, expected: String?) {
-    val actual = MergeResolveUtil.tryResolveConflict(left, base, right)
-    assertEquals(expected, actual?.toString())
+  private fun testGreedy(base: String, left: String, right: String, expected: String?) {
+    test(base, left, right, expected, true);
+  }
+
+  private fun test(base: String, left: String, right: String, expected: String?, isGreedy: Boolean = false) {
+    val simpleResult = MergeResolveUtil.tryResolve(left, base, right)
+    val magicResult = MergeResolveUtil.tryGreedyResolve(left, base, right);
+
+    if (expected == null) {
+      assertNull(simpleResult)
+      assertNull(magicResult)
+    }
+    else if (isGreedy) {
+      assertNull(simpleResult)
+      assertEquals(expected, magicResult)
+    }
+    else {
+      assertEquals(expected, simpleResult)
+      assertEquals(expected, magicResult)
+    }
   }
 }
index 95321651f57123039296bc20b589ee4bbf048788..c0c7055eddf6691776da6916fb83162a4452c897 100644 (file)
@@ -173,8 +173,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
     ColorBlindnessSupport support = ColorBlindnessSupport.get(COLOR_BLINDNESS);
     IconLoader.setFilter(support == null ? null : support.getFilter());
 
-    incModificationCount();
-    if (myCounter == 1) {
+    if (incAndGetModificationCount() == 1) {
       return;
     }
 
index b6e8057b2f99d269d84febaadc1919703579186b..e28ed40babb72e1960c11c4fcc9d61d5671a1840 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
 import com.intellij.openapi.actionSystem.CommonDataKeys
 import com.intellij.openapi.editor.Editor
 import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
+import com.intellij.openapi.editor.impl.InlayModelImpl
 import com.intellij.openapi.fileEditor.FileEditorManager
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.project.ProjectManager
@@ -116,7 +117,7 @@ class ToggleInlineHintsAction : AnAction() {
 
 private fun hasParameterHintAtOffset(editor: Editor): Boolean {
   val offset = editor.caretModel.offset
-  return editor.inlayModel
+  return editor.inlayModel is InlayModelImpl && editor.inlayModel
       .getInlineElementsInRange(offset, offset)
       .find { ParameterHintsPresentationManager.getInstance().isParameterHint(it) } != null
 }
index 93ec446cb6f5ace48abfbbc61a3de4f7c89dba70..cdb88bebf4aa099ad6c026d3eec15f9fd474aa2b 100644 (file)
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
 import com.intellij.codeInsight.daemon.impl.SeveritiesProvider;
 import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile;
-import com.intellij.codeInspection.InspectionProfile;
 import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.configurationStore.BundledSchemeEP;
 import com.intellij.configurationStore.SchemeDataHolder;
@@ -61,8 +60,6 @@ import java.util.Collections;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.Function;
 
-import static com.intellij.codeInspection.ex.InspectionProfileImpl.getDefaultProfile;
-
 @State(
   name = "InspectionProfileManager",
   storages = {
@@ -93,8 +90,8 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
     mySchemeManager = schemeManagerFactory.create(INSPECTION_DIR, new InspectionProfileProcessor() {
       @NotNull
       @Override
-      public String getName(@NotNull Function<String, String> attributeProvider) {
-        return "unnamed";
+      public String getName(@NotNull Function<String, String> attributeProvider, @NotNull String fileNameWithoutExtension) {
+        return fileNameWithoutExtension;
       }
 
       @NotNull
@@ -102,11 +99,7 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
                                                 @NotNull String name,
                                                 @NotNull Function<String, String> attributeProvider,
                                                 boolean isBundled) {
-        InspectionProfileImpl profile = new InspectionProfileImpl(name, myRegistrar, ApplicationInspectionProfileManager.this, dataHolder);
-        if (isBundled) {
-          profile.lockProfile(true);
-        }
-        return profile;
+        return new InspectionProfileImpl(name, myRegistrar, ApplicationInspectionProfileManager.this, dataHolder);
       }
 
       @Override
@@ -169,21 +162,15 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
   }
 
   public void initProfiles() {
-    if (!myProfilesAreInitialized.compareAndSet(false, true)) {
+    if (!myProfilesAreInitialized.compareAndSet(false, true) || !LOAD_PROFILES) {
       return;
     }
 
-    if (!LOAD_PROFILES) return;
-
     loadBundledSchemes();
     mySchemeManager.loadSchemes();
-    createDefaultProfile();
-  }
 
-  private void createDefaultProfile() {
-    final InspectionProfileImpl oldDefault = mySchemeManager.findSchemeByName(InspectionProfileImpl.DEFAULT_PROFILE_NAME);
-    if (oldDefault == null || !oldDefault.isProfileLocked()) {
-      getSchemeManager().addScheme(createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile()));
+    if (mySchemeManager.isEmpty()) {
+      mySchemeManager.addScheme(createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, InspectionProfileImpl.getBaseProfile()));
     }
   }
 
@@ -246,12 +233,6 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
     return new InspectionProfileConvertor(this);
   }
 
-  @SuppressWarnings("unused")
-  @Deprecated
-  public InspectionProfileImpl createProfile() {
-    return createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile());
-  }
-
   @Override
   public void setRootProfile(@Nullable String profileName) {
     mySchemeManager.setCurrentSchemeName(profileName);
@@ -270,12 +251,12 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
 
   @NotNull
   @Override
-  public InspectionProfile getCurrentProfile() {
+  public InspectionProfileImpl getCurrentProfile() {
     initProfiles();
 
-    Profile current = mySchemeManager.getCurrentScheme();
+    InspectionProfileImpl current = mySchemeManager.getCurrentScheme();
     if (current != null) {
-      return (InspectionProfile)current;
+      return current;
     }
 
     // use default as base, not random custom profile
index a9e9a497add104200f702d33f629b13a3168eb4b..00e499a6069977b81092dbbd1903c75bb2330412 100644 (file)
@@ -289,7 +289,10 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
 
   public boolean isExcludedOrUnderExcludedDirectory(@NotNull VirtualFile file) {
     ModifiableRootModel model = getModel();
-    Project project = model != null ? model.getProject() : null;
+    if (model == null) {
+      throw new AssertionError(getClass() + ".getModel() returned null unexpectedly");
+    }
+    Project project = model.getProject();
     ContentEntry contentEntry = getContentEntry();
     if (contentEntry == null) {
       return false;
index e2c8abe2e6c332c75d9424c53e47bb46ac7faa6f..b28890076aa89c9e741c3a9515369c19a4207007 100644 (file)
@@ -74,7 +74,6 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import javax.swing.FocusManager;
 import javax.swing.*;
 import javax.swing.event.TreeExpansionEvent;
 import javax.swing.event.TreeExpansionListener;
@@ -84,8 +83,6 @@ import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreePath;
 import java.awt.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.*;
@@ -1095,6 +1092,7 @@ public class SingleInspectionProfilePanel extends JPanel {
   }
 
   public boolean isModified() {
+    if (myTreeTable == null) return false;
     if (myModified) return true;
     if (myProfile.isChanged()) return true;
     if (myProfile.getParentProfile().isProjectLevel() != myProfile.isProjectLevel()) return true;
index fc8ff4abd3e9c22a0289aff7c477af2c15f6b550..9da66f7a13d827c5305c750e367b7287515585dd 100644 (file)
@@ -108,7 +108,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
   }
 
   @NotNull
-  private InspectionProfileImpl copyToNewProfile(ModifiableModel selectedProfile,
+  private InspectionProfileImpl copyToNewProfile(@NotNull InspectionProfileImpl selectedProfile,
                                                  @NotNull Project project,
                                                  boolean modifyName,
                                                  boolean modifyLevel) {
index b61abc436e2cac6d8a54fb4b5fb85b584272ab77..9cfba7716f3e67924798c5166b161dbef1a3f920 100644 (file)
@@ -93,7 +93,10 @@ public abstract class ChangeSignatureProcessorBase extends BaseRefactoringProces
     List<UsageInfo> infos = new ArrayList<>();
     final ChangeSignatureUsageProcessor[] processors = ChangeSignatureUsageProcessor.EP_NAME.getExtensions();
     for (ChangeSignatureUsageProcessor processor : processors) {
-      ContainerUtil.addAll(infos, processor.findUsages(changeInfo));
+      for (UsageInfo info : processor.findUsages(changeInfo)) {
+        LOG.assertTrue(info != null, processor);
+        infos.add(info);
+      }
     }
     infos = filterUsages(infos);
     return infos.toArray(new UsageInfo[infos.size()]);
index 3cd1af45f6b3e8c7ab5ee0ab2de1f32f7e27417f..f2b15f2d94eb59dd4f4f617475cb087f6171ee34 100644 (file)
@@ -36,6 +36,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
 import com.intellij.psi.util.PsiUtilCore;
@@ -101,7 +102,7 @@ public class VariableInplaceRenamer extends InplaceRefactoring {
   protected void collectAdditionalElementsToRename(final List<Pair<PsiElement, TextRange>> stringUsages) {
     final String stringToSearch = myElementToRename.getName();
     final PsiFile currentFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
-    if (stringToSearch != null) {
+    if (!StringUtil.isEmptyOrSpaces(stringToSearch)) {
       TextOccurrencesUtil
         .processUsagesInStringsAndComments(myElementToRename, stringToSearch, true, (psiElement, textRange) -> {
           if (psiElement.getContainingFile() == currentFile) {
index 7350f2bc7d80cfb2912473cea3a18529ce12867b..e6789513ee355c8d08feae589c7ad0089b69c3cf 100644 (file)
@@ -15,9 +15,7 @@
  */
 package com.intellij.util.indexing;
 
-import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
 import com.intellij.util.io.DataExternalizer;
-import com.intellij.util.io.DataOutputStream;
 import com.intellij.util.io.KeyDescriptor;
 import com.intellij.util.io.PersistentHashMap;
 import org.jetbrains.annotations.NotNull;
@@ -56,15 +54,10 @@ class ValueContainerMap<Key, Value> extends PersistentHashMap<Key, ValueContaine
       // note that keys unique for indexed file have their value calculated at once (e.g. key is file id, index calculates something for particular
       // file) and there is no benefit to accumulate values for particular key because only one value exists
       if (!valueContainer.needsCompacting() && !myKeyIsUniqueForIndexedFile) {
-        final BufferExposingByteArrayOutputStream bytes = new BufferExposingByteArrayOutputStream();
-        //noinspection IOResourceOpenedButNotSafelyClosed
-        final DataOutputStream _out = new DataOutputStream(bytes);
-        valueContainer.saveTo(_out, myValueExternalizer);
-
         appendData(key, new PersistentHashMap.ValueDataAppender() {
           @Override
           public void append(@NotNull final DataOutput out) throws IOException {
-            out.write(bytes.getInternalBuffer(), 0, bytes.size());
+            valueContainer.saveTo(out, myValueExternalizer);
           }
         });
       }
index 7733f00e1c2af8f9a94c1100f0589f72ef3ada3e..d22cf482d30bbe895e8de52812993de0d556c6c2 100644 (file)
@@ -32,7 +32,6 @@ import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.Clock;
-import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
@@ -69,19 +68,12 @@ public class IdeaGateway {
 
     LocalHistoryImpl.getInstanceImpl().dispatchPendingEvents();
 
-    VersionedFilterData versionedFilterData;
-    VfsEventDispatchContext vfsEventDispatchContext = ourCurrentEventDispatchContext.get();
-    if (vfsEventDispatchContext != null) {
-      versionedFilterData = vfsEventDispatchContext.myFilterData;
-      if (versionedFilterData == null) versionedFilterData = vfsEventDispatchContext.myFilterData = new VersionedFilterData();
-    } else {
-      versionedFilterData = new VersionedFilterData();
-    }
+    VersionedFilterData versionedFilterData = getVersionedFilterData();
 
     boolean isInContent = false;
     int numberOfOpenProjects = versionedFilterData.myOpenedProjects.size();
     for (int i = 0; i < numberOfOpenProjects; ++i) {
-      if (Comparing.equal(versionedFilterData.myWorkspaceFiles.get(i), f)) return false;
+      if (f.equals(versionedFilterData.myWorkspaceFiles.get(i))) return false;
       ProjectFileIndex index = versionedFilterData.myProjectFileIndices.get(i);
 
       if (index.isExcluded(f)) return false;
@@ -93,33 +85,49 @@ public class IdeaGateway {
     return numberOfOpenProjects != 0 || !FileTypeManager.getInstance().isFileIgnored(f);
   }
 
+  @NotNull
+  protected static VersionedFilterData getVersionedFilterData() {
+    VersionedFilterData versionedFilterData;
+    VfsEventDispatchContext vfsEventDispatchContext = ourCurrentEventDispatchContext.get();
+    if (vfsEventDispatchContext != null) {
+      versionedFilterData = vfsEventDispatchContext.myFilterData;
+      if (versionedFilterData == null) versionedFilterData = vfsEventDispatchContext.myFilterData = new VersionedFilterData();
+    } else {
+      versionedFilterData = new VersionedFilterData();
+    }
+    return versionedFilterData;
+  }
+
   private static final ThreadLocal<VfsEventDispatchContext> ourCurrentEventDispatchContext = new ThreadLocal<>();
 
-  private static class VfsEventDispatchContext {
+  private static class VfsEventDispatchContext implements AutoCloseable {
     final List<? extends VFileEvent> myEvents;
     final boolean myBeforeEvents;
     final VfsEventDispatchContext myPreviousContext;
 
     VersionedFilterData myFilterData;
 
-    VfsEventDispatchContext(List<? extends VFileEvent> events, boolean beforeEvents, VfsEventDispatchContext context) {
+    VfsEventDispatchContext(List<? extends VFileEvent> events, boolean beforeEvents) {
       myEvents = events;
       myBeforeEvents = beforeEvents;
-      myPreviousContext = context;
+      myPreviousContext = ourCurrentEventDispatchContext.get();
+      if (myPreviousContext != null) {
+        myFilterData = myPreviousContext.myFilterData;
+      }
+      ourCurrentEventDispatchContext.set(this);
     }
 
     public void close() {
       ourCurrentEventDispatchContext.set(myPreviousContext);
+      if (myPreviousContext != null && myPreviousContext.myFilterData == null && myFilterData != null) {
+        myPreviousContext.myFilterData = myFilterData;
+      }
     }
   }
 
   public void runWithVfsEventsDispatchContext(List<? extends VFileEvent> events, boolean beforeEvents, Runnable action) {
-    VfsEventDispatchContext vfsEventDispatchContext = new VfsEventDispatchContext(events, beforeEvents, ourCurrentEventDispatchContext.get());
-    ourCurrentEventDispatchContext.set(vfsEventDispatchContext);
-    try {
+    try (VfsEventDispatchContext ignored = new VfsEventDispatchContext(events, beforeEvents)) {
       action.run();
-    } finally {
-      vfsEventDispatchContext.close();
     }
   }
 
index 4498a7ea53c7736f36ab3e40a4cb490e16987941..c156af30d34099ff9650019c61664a99cde37add 100644 (file)
@@ -62,7 +62,7 @@ fun CredentialAttributes(requestor: Class<*>, userName: String?) = CredentialAtt
 fun Credentials?.isFulfilled() = this != null && userName != null && !password.isNullOrEmpty()
 fun Credentials?.hasOnlyUserName() = this != null && userName != null && password.isNullOrEmpty()
 
-fun Credentials?.isEmpty() = this == null || (userName == null && password == null)
+fun Credentials?.isEmpty() = this == null || (userName == null && password.isNullOrEmpty())
 
 // input will be cleared
 @JvmOverloads
index 2c78265d17264051a8886e6040df6d35cd773dbb..e1bb409c0904d54d3cfdad22793b4ada837c6c15 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.
  */
 package com.intellij.openapi;
 
-import com.intellij.Patches;
 import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.util.ui.UIUtil;
 
 import javax.swing.*;
-import java.awt.Component;
+import java.awt.*;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.lang.reflect.Method;
 
 /**
  * @author Sergey.Malenkov
@@ -136,7 +134,7 @@ abstract class MnemonicWrapper<T extends Component> implements Runnable, Propert
           sb.append(ch);
         }
         else if (i + 1 < length) {
-          code = getExtendedKeyCodeForChar(text.charAt(i + 1));
+          code = KeyEvent.getExtendedKeyCodeForChar((int)text.charAt(i + 1));
           index = sb.length();
         }
       }
@@ -200,26 +198,6 @@ abstract class MnemonicWrapper<T extends Component> implements Runnable, Propert
     return stroke;
   }
 
-  // TODO: HACK because of Java7 required:
-  // replace later with KeyEvent.getExtendedKeyCodeForChar(ch)
-  private static int getExtendedKeyCodeForChar(int ch) {
-    //noinspection ConstantConditions
-    assert Patches.USE_REFLECTION_TO_ACCESS_JDK7;
-    try {
-      Method method = KeyEvent.class.getMethod("getExtendedKeyCodeForChar", int.class);
-      if (!method.isAccessible()) {
-        method.setAccessible(true);
-      }
-      return (Integer)method.invoke(KeyEvent.class, ch);
-    }
-    catch (Exception exception) {
-      if (ch >= 'a' && ch <= 'z') {
-        ch -= ('a' - 'A');
-      }
-      return ch;
-    }
-  }
-
   private static class MenuWrapper extends ButtonWrapper {
     private MenuWrapper(AbstractButton component) {
       super(component);
index ecc24a8a557930c40f8701d9247ff361ba71f6c0..0791b837820ea20c743ac89accb430dfd17daca9 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.CachedSingletonsRegistry;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Getter;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.messages.Topic;
 import org.jetbrains.annotations.NonNls;
@@ -36,7 +35,7 @@ import java.util.List;
 
 public abstract class FileTypeManager extends FileTypeRegistry {
   static {
-    FileTypeRegistry.ourInstanceGetter = () -> FileTypeManager.getInstance();
+    FileTypeRegistry.ourInstanceGetter = () -> getInstance();
   }
 
   private static FileTypeManager ourInstance = CachedSingletonsRegistry.markCachedField(FileTypeManager.class);
@@ -59,7 +58,7 @@ public abstract class FileTypeManager extends FileTypeRegistry {
   }
 
   /**
-   * @deprecated use {@link com.intellij.openapi.fileTypes.FileTypeFactory} instead
+   * @deprecated use {@link FileTypeFactory} instead
    */
   public abstract void registerFileType(@NotNull FileType type, @NotNull List<FileNameMatcher> defaultAssociations);
 
@@ -69,7 +68,7 @@ public abstract class FileTypeManager extends FileTypeRegistry {
    * @param type                        The file type to register.
    * @param defaultAssociatedExtensions The list of extensions which cause the file to be
    *                                    treated as the specified file type. The extensions should not start with '.'.
-   * @deprecated use {@link com.intellij.openapi.fileTypes.FileTypeFactory} instead
+   * @deprecated use {@link FileTypeFactory} instead
    */
   public final void registerFileType(@NotNull FileType type, @NonNls @Nullable String... defaultAssociatedExtensions) {
     List<FileNameMatcher> matchers = new ArrayList<>();
index 4a6dcbcf1e8eda7ff6eb355728418fc6f4b83190..08386ba6c5b6051a26fdcf20b5726d3ccaaf3d0a 100644 (file)
@@ -34,6 +34,10 @@ public interface ContentManager extends Disposable, BusyObject {
 
   void addContent(@NotNull Content content);
   void addContent(@NotNull Content content, final int order);
+
+  /**
+   * @deprecated use {@link #addContent(Content)} instead, {@code constraints} parameter isn't used anyway
+   */
   void addContent(@NotNull Content content, Object constraints);
 
   boolean removeContent(@NotNull Content content, final boolean dispose);
index 48c1678bd249cc75ab256a126b525fe2ec6d2726..6aab28aa8d2017f9efdf9cbe57c483696fdb7cbd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import java.awt.*;
 import java.awt.event.MouseListener;
 
 public class HintUtil {
-  public static final Color INFORMATION_COLOR = new JBColor(new Color(253, 254, 226), new Color(0x4d4f51));
+  public static final Color INFORMATION_COLOR = new JBColor(new Color(0xf8f8f8), new Color(0x4d4f51));
   public static final Color QUESTION_COLOR = new JBColor(new Color(181, 208, 251), new Color(55, 108, 137));
   public static final Color ERROR_COLOR = new JBColor(new Color(255, 220, 220), new Color(0x781732));
 
index 99dbed90dab62b69e1ad8c79f1d45dcffa498c3f..cc009b7cd6f64c2e3e2315fc0d8e789c063f6834 100644 (file)
@@ -49,7 +49,7 @@ fun showJetBrainsAccountDialog(parent: Component, project: Project? = null): Dia
         link("Forgot password?") { BrowserUtil.browse("https://account.jetbrains.com/forgot-password?username=${userField.text.trim().encodeUrlQueryParameter()}") }
       }
     }
-    noteRow("""Do not have an account? <a href="https://account.jetbrains.com/login">Sign Up</a>""")
+    noteRow("""Do not have an account? <a href="https://account.jetbrains.com/login?signup">Sign Up</a>""")
   }
 
   return dialog(
index 1de9a4377ef75d41657e4b063af520b5348ad58a..e79b3f4469cade2d0f097c213f8f15160d1d4322 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.
@@ -15,7 +15,6 @@
  */
 package com.intellij.ide.dnd;
 
-import com.intellij.Patches;
 import org.jetbrains.annotations.NotNull;
 
 import java.awt.datatransfer.DataFlavor;
@@ -31,20 +30,8 @@ import java.util.List;
  */
 abstract public class TransferableList<T> implements Transferable {
   private static final DataFlavor LIST_DATA_FLAVOR = new DataFlavor(List.class, "Transferable List");
-  private static final DataFlavor ALL_HTML_DATA_FLAVOR = initHtmlDataFlavor("all"); // JDK7: DataFlavor.allHtmlFlavor
-  private static final DataFlavor PART_HTML_DATA_FLAVOR = initHtmlDataFlavor("fragment"); // JDK7: DataFlavor.fragmentHtmlFlavor
-
-  private static DataFlavor initHtmlDataFlavor(String type) {
-    // some constants were added in JDK 7 without @since 1.7 tag
-    // http://bugs.openjdk.java.net/browse/JDK-7075105
-    assert Patches.USE_REFLECTION_TO_ACCESS_JDK7;
-    try {
-      return new DataFlavor("text/html; class=java.lang.String;document=" + type + ";charset=Unicode");
-    }
-    catch (Exception exception) {
-      return null;
-    }
-  }
+  private static final DataFlavor ALL_HTML_DATA_FLAVOR = DataFlavor.allHtmlFlavor;
+  private static final DataFlavor PART_HTML_DATA_FLAVOR = DataFlavor.fragmentHtmlFlavor;
 
   private final List<T> myList;
 
index d7f172573af438ba86b922d83c5263e0126a525f..fc506a13dbe46fcd758b8c0dd2fda6c6e1093e29 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.
@@ -33,6 +33,7 @@ import com.intellij.ui.plaf.beg.IdeaMenuUI;
 import com.intellij.ui.plaf.gtk.GtkMenuUI;
 import com.intellij.util.ReflectionUtil;
 import com.intellij.util.SingleAlarm;
+import com.intellij.util.ui.JBUI;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 
@@ -40,6 +41,7 @@ import javax.swing.*;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 import javax.swing.plaf.MenuItemUI;
+import javax.swing.plaf.synth.SynthMenuUI;
 import java.awt.*;
 import java.awt.event.AWTEventListener;
 import java.awt.event.ComponentEvent;
@@ -164,12 +166,12 @@ public final class ActionMenu extends JBMenu {
 
     if (myTopLevel && UIUtil.isUnderGTKLookAndFeel()) {
       Insets insets = getInsets();
-      Insets newInsets = new Insets(insets.top, insets.left, insets.bottom, insets.right);
-      if (insets.top + insets.bottom < 6) {
-        newInsets.top = newInsets.bottom = 3;
+      @SuppressWarnings("UseDPIAwareInsets") Insets newInsets = new Insets(insets.top, insets.left, insets.bottom, insets.right);
+      if (insets.top + insets.bottom < JBUI.scale(6)) {
+        newInsets.top = newInsets.bottom = JBUI.scale(3);
       }
-      if (insets.left + insets.right < 12) {
-        newInsets.left = newInsets.right = 6;
+      if (insets.left + insets.right < JBUI.scale(12)) {
+        newInsets.left = newInsets.right = JBUI.scale(6);
       }
       if (!newInsets.equals(insets)) {
         setBorder(BorderFactory.createEmptyBorder(newInsets.top, newInsets.left, newInsets.bottom, newInsets.right));
@@ -178,8 +180,8 @@ public final class ActionMenu extends JBMenu {
   }
 
   @Override
-  public void setUI(final MenuItemUI ui) {
-    final MenuItemUI newUi = !myTopLevel && UIUtil.isUnderGTKLookAndFeel() && GtkMenuUI.isUiAcceptable(ui) ? new GtkMenuUI(ui) : ui;
+  public void setUI(MenuItemUI ui) {
+    MenuItemUI newUi = !myTopLevel && UIUtil.isUnderGTKLookAndFeel() && ui instanceof SynthMenuUI ? new GtkMenuUI((SynthMenuUI)ui) : ui;
     super.setUI(newUi);
   }
 
@@ -222,7 +224,8 @@ public final class ActionMenu extends JBMenu {
   }
 
   private void updateIcon() {
-    if (UISettings.getInstance().SHOW_ICONS_IN_MENUS) {
+    UISettings settings = UISettings.getInstance();
+    if (settings != null && settings.SHOW_ICONS_IN_MENUS) {
       final Presentation presentation = myPresentation;
       final Icon icon = presentation.getIcon();
       setIcon(icon);
@@ -242,9 +245,7 @@ public final class ActionMenu extends JBMenu {
   }
 
   public static void showDescriptionInStatusBar(boolean isIncluded, Component component, String description) {
-    IdeFrame frame = component instanceof IdeFrame
-                     ? (IdeFrame)component
-                     : (IdeFrame)SwingUtilities.getAncestorOfClass(IdeFrame.class, component);
+    IdeFrame frame = (IdeFrame)(component instanceof IdeFrame ? component : SwingUtilities.getAncestorOfClass(IdeFrame.class, component));
     StatusBar statusBar;
     if (frame != null && (statusBar = frame.getStatusBar()) != null) {
       statusBar.setInfo(isIncluded ? description : null);
@@ -448,4 +449,4 @@ public final class ActionMenu extends JBMenu {
       Toolkit.getDefaultToolkit().removeAWTEventListener(this);
     }
   }
-}
+}
\ No newline at end of file
index d3fb034d8f16ff5730eaf355e1b66fb8170b48ab..a50afb68e1b27bdbdf9d9f43d8119e74b37700b7 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.
@@ -41,6 +41,7 @@ import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import javax.swing.plaf.MenuItemUI;
+import javax.swing.plaf.synth.SynthMenuItemUI;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -187,8 +188,8 @@ public class ActionMenuItem extends JBCheckBoxMenuItem {
   }
 
   @Override
-  public void setUI(final MenuItemUI ui) {
-    final MenuItemUI newUi = UIUtil.isUnderGTKLookAndFeel() && GtkMenuItemUI.isUiAcceptable(ui) ? new GtkMenuItemUI(ui) : ui;
+  public void setUI(MenuItemUI ui) {
+    MenuItemUI newUi = UIUtil.isUnderGTKLookAndFeel() && ui instanceof SynthMenuItemUI ? new GtkMenuItemUI((SynthMenuItemUI)ui) : ui;
     super.setUI(newUi);
   }
 
index 92e3b69e2a0e7f7914201bae0ce6afa61b0377a4..609204ff194290c33f566653a5c72f2208c87d26 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.psi.PsiDocumentManager;
+import com.intellij.ui.EditorNotifications;
 import com.intellij.util.concurrency.AppExecutorUtil;
 import org.jetbrains.annotations.NotNull;
 
@@ -172,6 +173,7 @@ public class AsyncEditorLoader {
     if (FileEditorManager.getInstance(myProject).getSelectedTextEditor() == myEditor) {
       IdeFocusManager.getInstance(myProject).requestFocus(myTextEditor.getPreferredFocusedComponent(), true);
     }
+    EditorNotifications.getInstance(myProject).updateNotifications(myTextEditor.myFile);
   }
 
   public static void performWhenLoaded(@NotNull Editor editor, @NotNull Runnable runnable) {
index 2c8022e7b86428211cc57fc89f98a00ae46d8745..69766e3b01926f6dd43a263791898c470581a984 100644 (file)
@@ -37,11 +37,12 @@ public final class StripeButtonUI extends MetalToggleButtonUI{
   private static final Rectangle ourIconRect=new Rectangle();
   private static final Rectangle ourTextRect=new Rectangle();
   private static final Rectangle ourViewRect=new Rectangle();
-  private static Insets ourViewInsets=new Insets(0,0,0,0);
+  private static Insets ourViewInsets = JBUI.emptyInsets();
 
   private StripeButtonUI(){}
 
   /** Invoked by reflection */
+  @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "unused"})
   public static ComponentUI createUI(final JComponent c){
     return ourInstance;
   }
@@ -55,6 +56,7 @@ public final class StripeButtonUI extends MetalToggleButtonUI{
 
     final ToolWindowAnchor anchor=button.getAnchor();
     if(ToolWindowAnchor.LEFT==anchor||ToolWindowAnchor.RIGHT==anchor){
+      //noinspection SuspiciousNameCombination
       return new Dimension(dim.height,dim.width);
     } else{
       return dim;
@@ -127,12 +129,14 @@ public final class StripeButtonUI extends MetalToggleButtonUI{
       tr=g2.getTransform();
       if(ToolWindowAnchor.RIGHT==anchor){
         if(icon != null){ // do not rotate icon
+          //noinspection SuspiciousNameCombination
           icon.paintIcon(c, g2, ourIconRect.y, ourIconRect.x);
         }
         g2.rotate(Math.PI/2);
         g2.translate(0,-c.getWidth());
       } else {
         if(icon != null){ // do not rotate icon
+          //noinspection SuspiciousNameCombination
           icon.paintIcon(c, g2, ourIconRect.y, c.getHeight() - ourIconRect.x - icon.getIconHeight());
         }
         g2.rotate(-Math.PI/2);
index 5670ecc8410bcd65d938edd63fb0209ce43fd0db..2ef6de9cbb9036cefdc4a6e24e0f65b9c184780a 100644 (file)
@@ -451,13 +451,12 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
       toolWindow.setSplitMode(true, null);
     }
 
-    final ActionCallback activation = toolWindow.setActivation(new ActionCallback());
-
+    // ToolWindow activation is not needed anymore and should be removed in 2017
+    toolWindow.setActivation(new ActionCallback()).setDone();
     final DumbAwareRunnable runnable = () -> {
       if (toolWindow.isDisposed()) return;
 
       toolWindow.ensureContentInitialized();
-      activation.setDone();
     };
     if (visible || ApplicationManager.getApplication().isUnitTestMode()) {
       runnable.run();
index 020fb241b3efff19033eb94416cfa7ed08806137..cf607d56271a7c2238f1beffc1deb9ae8d1c6183 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.
@@ -15,7 +15,6 @@
  */
 package com.intellij.ui;
 
-import com.intellij.Patches;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.registry.Registry;
@@ -26,7 +25,6 @@ import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.util.Locale;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -116,7 +114,7 @@ public class KeyStrokeAdapter implements KeyListener {
           if (Registry.is("actionSystem.extendedKeyCode.disabled")) {
             return null;
           }
-          code = getExtendedKeyCode(event);
+          code = event.getExtendedKeyCode();
           if (code == event.getKeyCode()) {
             return null;
           }
@@ -146,23 +144,6 @@ public class KeyStrokeAdapter implements KeyListener {
     return KeyEvent.VK_UNDEFINED == code ? null : KeyStroke.getKeyStroke(code, modifiers, released);
   }
 
-  // TODO: HACK because of Java7 required:
-  // replace later with event.getExtendedKeyCode()
-  private static int getExtendedKeyCode(KeyEvent event) {
-    //noinspection ConstantConditions
-    assert Patches.USE_REFLECTION_TO_ACCESS_JDK7;
-    try {
-      Method method = KeyEvent.class.getMethod("getExtendedKeyCode");
-      if (!method.isAccessible()) {
-        method.setAccessible(true);
-      }
-      return (Integer)method.invoke(event);
-    }
-    catch (Exception exception) {
-      return event.getKeyCode();
-    }
-  }
-
   /**
    * Parses a string and returns the corresponding key stroke.
    * The string must have the following syntax:
index fd74d0e4863ba617854e766434981e51104c8985..e47797729099c253d817094943014dac81b0e4aa 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.
@@ -20,24 +20,20 @@ import com.intellij.util.ui.EmptyIcon;
 import com.intellij.util.ui.UIUtil;
 
 import javax.swing.*;
-import javax.swing.plaf.MenuItemUI;
 import javax.swing.plaf.basic.BasicMenuItemUI;
+import javax.swing.plaf.synth.ColorType;
 import javax.swing.plaf.synth.SynthContext;
+import javax.swing.plaf.synth.SynthMenuItemUI;
 import java.awt.*;
 
 public class GtkMenuItemUI extends BasicMenuItemUI {
   private static Icon myCachedCheckIcon = null;
 
-  private final BasicMenuItemUI myOriginalUI;
+  private final SynthMenuItemUI myOriginalUI;
   private JCheckBoxMenuItem myHiddenItem;
 
-  public GtkMenuItemUI(final MenuItemUI originalUI) {
-    assert isUiAcceptable(originalUI) : originalUI;
-    myOriginalUI = (BasicMenuItemUI)originalUI;
-  }
-
-  public static boolean isUiAcceptable(final MenuItemUI ui) {
-    return ui instanceof BasicMenuItemUI && GtkPaintingUtil.isSynthUI(ui);
+  public GtkMenuItemUI(SynthMenuItemUI originalUI) {
+    myOriginalUI = originalUI;
   }
 
   @Override
@@ -60,9 +56,9 @@ public class GtkMenuItemUI extends BasicMenuItemUI {
     resetCachedCheckIcon();
   }
 
-  private static Icon getCheckIconFromContext(final BasicMenuItemUI originalUI, final JCheckBoxMenuItem item) {
+  private static Icon getCheckIconFromContext(final SynthMenuItemUI ui, final JCheckBoxMenuItem item) {
     if (myCachedCheckIcon == null) {
-      final SynthContext context = GtkPaintingUtil.getSynthContext(originalUI, item);
+      SynthContext context = ui.getContext(item);
       myCachedCheckIcon = context.getStyle().getIcon(context, "CheckBoxMenuItem.checkIcon");
     }
     return myCachedCheckIcon;
@@ -82,10 +78,12 @@ public class GtkMenuItemUI extends BasicMenuItemUI {
 
     if (UIUtil.isMurrineBasedTheme()) {
       acceleratorFont = menuItem.getFont();
-      final Color fg = GtkPaintingUtil.getForeground(myOriginalUI, menuItem);
+      SynthContext context = myOriginalUI.getContext(menuItem);
+      Color fg = context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND);
       acceleratorForeground = UIUtil.mix(fg, menuItem.getBackground(), menuItem.isSelected() ? 0.4 : 0.2);
       disabledForeground = fg;
     }
+
     if (checkIcon != null && !(checkIcon instanceof IconWrapper) && !(checkIcon instanceof EmptyIcon)) {
       checkIcon = new IconWrapper(checkIcon, myOriginalUI);
     }
@@ -97,8 +95,9 @@ public class GtkMenuItemUI extends BasicMenuItemUI {
   protected void paintText(final Graphics g, final JMenuItem menuItem, final Rectangle textRect, final String text) {
     if (!menuItem.isEnabled() && UIUtil.isMurrineBasedTheme()) {
       GtkPaintingUtil.paintDisabledText(myOriginalUI, g, menuItem, textRect, text);
-      return;
     }
-    super.paintText(g, menuItem, textRect, text);
+    else {
+      super.paintText(g, menuItem, textRect, text);
+    }
   }
-}
+}
\ No newline at end of file
index 43ff684f408f4330db2bdbd1ef736496a776f405..d2f887d3e0f377c48a764063a0baa41db7d7d0a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 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,20 +18,15 @@ package com.intellij.ui.plaf.gtk;
 import com.intellij.util.ui.UIUtil;
 
 import javax.swing.*;
-import javax.swing.plaf.MenuItemUI;
 import javax.swing.plaf.basic.BasicMenuUI;
+import javax.swing.plaf.synth.SynthMenuUI;
 import java.awt.*;
 
 public class GtkMenuUI extends BasicMenuUI {
-  private final BasicMenuUI myOriginalUI;
+  private final SynthMenuUI myOriginalUI;
 
-  public GtkMenuUI(final MenuItemUI originalUI) {
-    assert isUiAcceptable(originalUI) : originalUI;
-    myOriginalUI = (BasicMenuUI)originalUI;
-  }
-
-  public static boolean isUiAcceptable(final MenuItemUI ui) {
-    return ui instanceof BasicMenuUI && GtkPaintingUtil.isSynthUI(ui);
+  public GtkMenuUI(SynthMenuUI originalUI) {
+    myOriginalUI = originalUI;
   }
 
   @Override
@@ -55,8 +50,9 @@ public class GtkMenuUI extends BasicMenuUI {
   protected void paintText(final Graphics g, final JMenuItem menuItem, final Rectangle textRect, final String text) {
     if (!menuItem.isEnabled() && UIUtil.isMurrineBasedTheme()) {
       GtkPaintingUtil.paintDisabledText(myOriginalUI, g, menuItem, textRect, text);
-      return;
     }
-    super.paintText(g, menuItem, textRect, text);
+    else {
+      super.paintText(g, menuItem, textRect, text);
+    }
   }
-}
+}
\ No newline at end of file
index 7da57c8509657c873ff7f65b4cf539ffe5e9c0eb..b5656f1671e821029fa9ca159696a867cf44ce03 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package com.intellij.ui.plaf.gtk;
 
-import com.intellij.Patches;
 import com.intellij.util.ui.UIUtil;
 import sun.swing.SwingUtilities2;
 
 import javax.swing.*;
 import javax.swing.plaf.MenuItemUI;
-import javax.swing.plaf.basic.BasicMenuItemUI;
 import javax.swing.plaf.synth.ColorType;
 import javax.swing.plaf.synth.SynthContext;
+import javax.swing.plaf.synth.SynthUI;
 import java.awt.*;
-import java.lang.reflect.Method;
 
-// todo[r.sh] get rid of SynthUI reflection after migration to JDK 7
 public class GtkPaintingUtil {
-  private static final String V6_SYNTH_UI_CLASS = "sun.swing.plaf.synth.SynthUI";
-  private static final String V7_SYNTH_UI_CLASS = "javax.swing.plaf.synth.SynthUI";
-
   private GtkPaintingUtil() { }
 
-  public static Color getForeground(final BasicMenuItemUI ui, final JMenuItem menuItem) {
-    final SynthContext context = getSynthContext(ui, menuItem);
-    return context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND);
-  }
-
-  public static void paintDisabledText(final BasicMenuItemUI originalUI,
+  public static void paintDisabledText(final SynthUI originalUI,
                                        final Graphics g,
                                        final JMenuItem menuItem,
                                        final Rectangle textRect,
@@ -47,7 +36,8 @@ public class GtkPaintingUtil {
     final FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
     final int index = menuItem.getDisplayedMnemonicIndex();
 
-    final Color fg = getForeground(originalUI, menuItem);
+    final SynthContext context = originalUI.getContext(menuItem);
+    final Color fg = context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND);
     final Color shadow = UIUtil.shade(menuItem.getBackground(), 1.24, 0.5);
 
     g.setColor(shadow);
@@ -56,32 +46,7 @@ public class GtkPaintingUtil {
     SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x, textRect.y + fm.getAscent());
   }
 
-  public static boolean isSynthUI(final MenuItemUI ui) {
-    Class<?> aClass = ui.getClass();
-
-    while (aClass != null && aClass.getSimpleName().contains("Synth")) {
-      final Class<?>[] interfaces = aClass.getInterfaces();
-      for (int i = 0, length = interfaces.length; i < length; i++) {
-        final Class<?> anInterface = interfaces[i];
-        if (V6_SYNTH_UI_CLASS.equals(anInterface.getName()) || V7_SYNTH_UI_CLASS.equals(anInterface.getName())) {
-          return true;
-        }
-      }
-      aClass = aClass.getSuperclass();
-    }
-
-    return false;
-  }
-
   public static SynthContext getSynthContext(final MenuItemUI ui, final JComponent item) {
-    assert Patches.USE_REFLECTION_TO_ACCESS_JDK7;
-    try {
-      final Method getContext = ui.getClass().getMethod("getContext", JComponent.class);
-      getContext.setAccessible(true);
-      return (SynthContext)getContext.invoke(ui, item);
-    }
-    catch (Exception e) {
-      throw new RuntimeException(e);
-    }
+    return ((SynthUI)ui).getContext(item);
   }
-}
+}
\ No newline at end of file
index 66bbdab856bc3c1cac74916905f415aab42bbeef..372a19f4a237e93fd576ce68686c7e6a6cc28b5f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 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,16 +18,16 @@ package com.intellij.ui.plaf.gtk;
 import com.intellij.Patches;
 
 import javax.swing.*;
-import javax.swing.plaf.MenuItemUI;
 import javax.swing.plaf.synth.SynthContext;
+import javax.swing.plaf.synth.SynthUI;
 import java.awt.*;
 import java.lang.reflect.Method;
 
 public class IconWrapper implements Icon {
   private final Icon myIcon;
-  private final MenuItemUI myOriginalUI;
+  private final SynthUI myOriginalUI;
 
-  public IconWrapper(final Icon icon, final MenuItemUI originalUI) {
+  public IconWrapper(final Icon icon, final SynthUI originalUI) {
     myIcon = icon;
     myOriginalUI = originalUI;
   }
@@ -36,10 +36,9 @@ public class IconWrapper implements Icon {
   public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
     if (Patches.USE_REFLECTION_TO_ACCESS_JDK7) {
       try {
-        final Method paintIcon = myIcon.getClass().getMethod("paintIcon", SynthContext.class, Graphics.class,
-                                                             int.class, int.class, int.class, int.class);
+        Method paintIcon = myIcon.getClass().getMethod("paintIcon", SynthContext.class, Graphics.class, int.class, int.class, int.class, int.class);
         paintIcon.setAccessible(true);
-        paintIcon.invoke(myIcon, GtkPaintingUtil.getSynthContext(myOriginalUI, (JComponent)c), g, x, y, getIconWidth(), getIconHeight());
+        paintIcon.invoke(myIcon, myOriginalUI.getContext((JComponent)c), g, x, y, getIconWidth(), getIconHeight());
         return;
       }
       catch (Exception ignore) { }
@@ -56,4 +55,4 @@ public class IconWrapper implements Icon {
   public int getIconHeight() {
     return myIcon.getIconHeight();
   }
-}
+}
\ No newline at end of file
index 9dea75d03470bfcfe323c8d499c5f03c242082f1..fb2ee27c02c002984da96e1d0096edac53174548 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.
@@ -22,8 +22,6 @@ import javax.swing.*;
 import java.awt.*;
 import java.util.ArrayDeque;
 
-import static com.intellij.Patches.USE_REFLECTION_TO_ACCESS_JDK7;
-
 /**
  * @author Sergey Malenkov
  */
@@ -166,7 +164,7 @@ public class MovablePopup {
           Window view = pop(owner);
           if (view == null) {
             view = new JWindow(owner);
-            setPopupType(view);
+            view.setType(Window.Type.POPUP);
           }
           setAlwaysOnTop(view, myAlwaysOnTop);
           setWindowFocusable(view, myWindowFocusable);
@@ -265,21 +263,6 @@ public class MovablePopup {
     }
   }
 
-  // TODO: HACK because of Java7 required:
-  // replace later with window.setType(Window.Type.POPUP)
-  private static void setPopupType(@NotNull Window window) {
-    //noinspection ConstantConditions,ConstantAssertCondition
-    assert USE_REFLECTION_TO_ACCESS_JDK7;
-    try {
-      @SuppressWarnings("unchecked")
-      Class<? extends Enum> type = (Class<? extends Enum>)Class.forName("java.awt.Window$Type");
-      Object value = Enum.valueOf(type, "POPUP");
-      Window.class.getMethod("setType", type).invoke(window, value);
-    }
-    catch (Exception ignored) {
-    }
-  }
-
   private static JRootPane getRootPane(Window window) {
     if (window instanceof RootPaneContainer) {
       RootPaneContainer container = (RootPaneContainer)window;
index af978ba4e90c6e5abe6042d91b29f1b2dd4e16b2..534ffab3da98124c82d1c7c9ff8f1fea9f599592 100644 (file)
@@ -174,6 +174,9 @@ intention.split.filter.text=Split into filter's chain
 intention.split.filter.family=Split filter
 intention.merge.filter.text=Merge filter's chain
 intention.merge.filter.family=Merge filters
+intention.inline.map.inline.text=Inline ''{0}'' body into the next ''{1}'' call
+intention.inline.map.merge.text=Merge ''{0}'' call and ''{1}'' call
+intention.inline.map.family=Inline stream mapping method
 intention.introduce.variable.text=Introduce local variable
 intention.encapsulate.field.text=Encapsulate field
 intention.implement.abstract.method.family=Implement Abstract Method
index cc6b497a61ce0e085c6e0f90ad17d51c9949aab2..d152cce895767e8e7eeec692ae18b3897de6baa6 100644 (file)
@@ -54,7 +54,7 @@ interface SchemeExtensionProvider {
 }
 
 abstract class LazySchemeProcessor<SCHEME : Scheme, MUTABLE_SCHEME : SCHEME>(private val nameAttribute: String = "name") : SchemeProcessor<SCHEME, MUTABLE_SCHEME>() {
-  open fun getName(attributeProvider: Function<String, String?>): String {
+  open fun getName(attributeProvider: Function<String, String?>, fileNameWithoutExtension: String): String {
     return attributeProvider.apply(nameAttribute) ?: throw IllegalStateException("name is missed in the scheme data")
   }
 
index ce2112e801704712b83ed22d84d953656651c36b..c15b0c7ce4455b1afcb2f72ac0991b799315c551 100644 (file)
@@ -244,7 +244,12 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
   }
 
   public void stopEventProcessing() {
-    UIUtil.invokeLaterIfNeeded(() -> myTransferToEDTQueue.drain());
+    UIUtil.invokeLaterIfNeeded(() -> {
+      if (myProject.isDisposed()) {
+        return;
+      }
+      myTransferToEDTQueue.drain();
+    });
   }
 
 
index 7a55ea8dde42a7f26eab770f3cd02381b0434538..7cfbe7b8c8c96f0c4ec5da5e02c4137bf3f7d23e 100644 (file)
@@ -846,7 +846,7 @@ public class PlatformTestUtil {
 
   public static void assertElementsEqual(final Element expected, final Element actual) throws IOException {
     if (!JDOMUtil.areElementsEqual(expected, actual)) {
-      Assert.assertEquals(printElement(expected), printElement(actual));
+      Assert.assertEquals(JDOMUtil.writeElement(expected), JDOMUtil.writeElement(actual));
     }
   }
 
@@ -859,12 +859,6 @@ public class PlatformTestUtil {
     }
   }
 
-  public static String printElement(final Element element) throws IOException {
-    final StringWriter writer = new StringWriter();
-    JDOMUtil.writeElement(element, writer, "\n");
-    return writer.getBuffer().toString();
-  }
-
   public static String getCommunityPath() {
     final String homePath = PathManager.getHomePath();
     if (new File(homePath, "community/.idea").isDirectory()) {
@@ -877,7 +871,6 @@ public class PlatformTestUtil {
     return getCommunityPath().replace(File.separatorChar, '/') + "/platform/platform-tests/testData/";
   }
 
-
   public static Comparator<AbstractTreeNode> createComparator(final Queryable.PrintInfo printInfo) {
     return (o1, o2) -> {
       String displayText1 = o1.toTestString(printInfo);
index f557aadd57204c1a68fdd912ac68ceff6fc3d848..d466de5c787114a06e59837ba00f54fd3c928ba0 100644 (file)
@@ -40,7 +40,7 @@ fun configureInspections(tools: Array<InspectionProfileEntry>,
     Disposer.register(parentDisposable, Disposable {
       profileManager.deleteProfile(profile)
       profileManager.setCurrentProfile(null)
-      clearAllToolsIn(InspectionProfileImpl.getDefaultProfile())
+      clearAllToolsIn(InspectionProfileImpl.getBaseProfile())
     })
 
     profileManager.addProfile(profile)
index a3d3621de9e78faa072049028863f917ad059b9d..1cd589c3830ec24b0c1bb870d5cc4c7741050d98 100644 (file)
@@ -25,7 +25,7 @@
     <orderEntry type="module" module-name="images" exported="" scope="RUNTIME" />
     <orderEntry type="module" module-name="RegExpSupport" exported="" scope="RUNTIME" />
     <orderEntry type="library" name="KotlinJavaRuntime" level="project" />
-    <orderEntry type="library" scope="TEST" name="assertJ" level="project" />
+    <orderEntry type="library" exported="" scope="TEST" name="assertJ" level="project" />
     <orderEntry type="library" scope="TEST" name="memoryfilesystem" level="project" />
     <orderEntry type="module" module-name="boot" />
   </component>
index 5d4ad07e94b620c4539abcbe33e709a777724ba5..455744a91dded93409df52a1e63d5084fe42312a 100644 (file)
@@ -24,6 +24,7 @@ import org.assertj.core.api.AbstractAssert
 import org.assertj.core.api.PathAssert
 import org.assertj.core.internal.Objects
 import org.jdom.Element
+import java.io.File
 import java.nio.file.Files
 import java.nio.file.LinkOption
 import java.nio.file.Path
@@ -39,10 +40,23 @@ class JdomAssert(actual: Element?) : AbstractAssert<JdomAssert, Element?>(actual
     return this
   }
 
+  fun isEqualTo(file: File): JdomAssert {
+    return isEqualTo(file.readText())
+  }
+
+  fun isEqualTo(element: Element): JdomAssert {
+    isNotNull
+
+    if (!JDOMUtil.areElementsEqual(actual, element)) {
+      isEqualTo(JDOMUtil.writeElement(element))
+    }
+    return this
+  }
+
   fun isEqualTo(expected: String): JdomAssert {
     isNotNull
 
-    Objects.instance().assertEqual(info, JDOMUtil.writeElement(actual!!), expected.trimIndent())
+    Objects.instance().assertEqual(info, JDOMUtil.writeElement(actual!!), expected.trimIndent().removePrefix("""<?xml version="1.0" encoding="UTF-8"?>""").trimStart())
     return this
   }
 }
index b87428ba92a030252f3e8c1249d5b34b6e678c6d..d54c2328536c62790cbfb9d9ab00e06f885cd77a 100644 (file)
@@ -491,6 +491,8 @@ diff.divider.repainting.disable.blitting=true
 diff.divider.repainting.disable.blitting.description=Fix painting glitch on scrolling in diff - disable BLIT_SCROLL_MODE to force repainting with RepaintManager
 diff.merge.resolve.conflict.action.visible=true
 diff.merge.resolve.conflict.action.visible.description=Allows to resolve some conflict in merge in one click (with a high probability of wrong result)
+diff.merge.resolve.conflict.action.use.greedy.approach=false
+diff.merge.resolve.conflict.action.use.greedy.approach.description=Use greedy heuristic in attempt to resolve conflict. This leads to higher amounts of false-positive and true-positive results.
 diff.enable.psi.highlighting=true
 diff.enable.psi.highlighting.description=Enable advanced highlighting and code navigation in VCS content in diff viewers.
 diff.pass.rich.editor.context=false
index ecb590c7b2073ac21efa68c236f159781c61694c..41dd4f41ba277266e096828c0d55a3e05d90e442 100644 (file)
@@ -71,12 +71,6 @@ public class Patches {
    */
   public static final boolean USE_REFLECTION_TO_ACCESS_JDK8 = Boolean.valueOf(true);
 
-  /**
-   * AtomicIntegerFieldUpdater does not work when SecurityManager is installed.
-   * See https://bugs.openjdk.java.net/browse/JDK-7103570.
-   */
-  public static final boolean JDK_BUG_ID_7103570 = true;
-
   /**
    * Support default methods in JDI
    * See <a href="https://bugs.openjdk.java.net/browse/JDK-8042123">JDK-8042123</a>
@@ -127,5 +121,5 @@ public class Patches {
   /**
    * Some HTTP connections lock the context class loader: https://bugs.openjdk.java.net/browse/JDK-8032832
    */
-  public static boolean JDK_BUG_ID_8032832 = SystemInfo.isJavaVersionAtLeast("1.8.0_20");
+  public static final boolean JDK_BUG_ID_8032832 = SystemInfo.isJavaVersionAtLeast("1.8.0_20");
 }
\ No newline at end of file
index 5dd7354583410633746a308c156a1c1698433b83..b9deac071df99106d141cd4efb63de9c373e70a2 100644 (file)
@@ -291,7 +291,7 @@ public class CompressedAppendableFile {
 
   private synchronized void loadAppendBuffer() throws IOException {
     if (myNextChunkBuffer != null) return;
-    myNextChunkBuffer = new byte[myAppendBufferLength];
+
     File tempAppendFile = getIncompleteChunkFile();
     if (tempAppendFile.exists()) {
       myBufferPosition = (int)tempAppendFile.length();
index 843eb9a08a05ef3b9976de4169c5c340b19aae5e..7b630b1068cb4b8e3e7f67aa3b9696470b27452c 100644 (file)
@@ -32,7 +32,7 @@ import java.util.Map;
  * @see ColorIcon
  */
 public class EmptyIcon implements Icon, ScalableIcon {
-  private static final Map<Integer, Icon> cache = new HashMap<Integer, Icon>();
+  private static final Map<Integer, EmptyIcon> cache = new HashMap<Integer, EmptyIcon>();
 
   public static final Icon ICON_16 = create(16);
   public static final Icon ICON_18 = create(18);
@@ -45,19 +45,25 @@ public class EmptyIcon implements Icon, ScalableIcon {
   private EmptyIcon myScaledCache;
 
   public static Icon create(int size) {
-    Icon icon = cache.get(size);
-    if (icon == null && size < 129) {
-      cache.put(size, icon = new EmptyIcon(size, size));
+    return create(size, size, true);
+  }
+
+  private static Icon create(int width, int height, boolean autoScale) {
+    int size = (width == height) ? width : -1;
+    EmptyIcon icon = cache.get(size);
+    if (icon == null) {
+      icon = new EmptyIcon(width, height);
+      if (size < JBUI.scale(129) && size > 0) cache.put(size, icon);
     }
-    return icon == null ? new EmptyIcon(size, size) : icon;
+    return autoScale ? icon.scale(JBUI.scale(1f)) : icon;
   }
 
   public static Icon create(int width, int height) {
-    return width == height ? create(width) : new EmptyIcon(width, height);
+    return create(width, height, true);
   }
 
   public static Icon create(@NotNull Icon base) {
-    return create(base.getIconWidth(), base.getIconHeight());
+    return create(base.getIconWidth(), base.getIconHeight(), false);
   }
 
   /**
index a10f34645ab65154a830110f7e8d8f370052419b..e367ad0ecf7b057d7a6eb3462f033e3d141d5aa0 100644 (file)
@@ -19,6 +19,7 @@ public interface UpToDateLineNumberProvider {
   int ABSENT_LINE_NUMBER = -1;
   int FAKE_LINE_NUMBER = -2;
 
+  int getLineCount();
   int getLineNumber(int currentNumber);
   boolean isLineChanged(int currentNumber);
   boolean isRangeChanged(final int start, final int end);
index c172a7dca544abdc0de518659af1c4b47d400bd5..9768edae6d927136fcd4817057a076e4cb26408a 100644 (file)
@@ -515,6 +515,11 @@ public class AnnotateDiffViewerAction extends ToggleAction implements DumbAware
       }
       return myLocalChangesProvider.isRangeChanged(line1, line2);
     }
+
+    @Override
+    public int getLineCount() {
+      return myLocalChangesProvider.getLineCount();
+    }
   }
 
   private static class ThreesideAnnotatorFactory extends ThreesideViewerAnnotatorFactory<ThreesideTextDiffViewerEx> {
index 005cd65127919653d652fce2fe7606a053abf3e1..4e9450b0305e0adf79c00255ae7b07ee8117be79 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.vcs.actions;
 
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.Separator;
 import com.intellij.openapi.actionSystem.ToggleAction;
@@ -27,12 +28,14 @@ import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Couple;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.vcs.AbstractVcs;
 import com.intellij.openapi.vcs.ProjectLevelVcsManager;
 import com.intellij.openapi.vcs.annotate.AnnotationGutterActionProvider;
 import com.intellij.openapi.vcs.annotate.AnnotationSourceSwitcher;
 import com.intellij.openapi.vcs.annotate.FileAnnotation;
 import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
+import com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener;
 import com.intellij.openapi.vcs.history.VcsFileRevision;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
 import com.intellij.openapi.vcs.impl.UpToDateLineNumberProviderImpl;
@@ -89,8 +92,23 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
                                 @NotNull final FileAnnotation fileAnnotation,
                                 @NotNull final AbstractVcs vcs,
                                 @Nullable final UpToDateLineNumberProvider upToDateLineNumberProvider) {
+    Disposable disposable = new Disposable() {
+      @Override
+      public void dispose() {
+        fileAnnotation.dispose();
+      }
+    };
+
     if (fileAnnotation.getFile() != null && fileAnnotation.getFile().isInLocalFileSystem()) {
-      ProjectLevelVcsManager.getInstance(project).getAnnotationLocalChangesListener().registerAnnotation(fileAnnotation.getFile(), fileAnnotation);
+      VcsAnnotationLocalChangesListener changesListener = ProjectLevelVcsManager.getInstance(project).getAnnotationLocalChangesListener();
+
+      changesListener.registerAnnotation(fileAnnotation.getFile(), fileAnnotation);
+      Disposer.register(disposable, new Disposable() {
+        @Override
+        public void dispose() {
+          changesListener.unregisterAnnotation(fileAnnotation.getFile(), fileAnnotation);
+        }
+      });
     }
 
     editor.getGutter().closeAllAnnotations();
@@ -116,7 +134,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
                                                        upToDateLineNumberProvider :
                                                        new UpToDateLineNumberProviderImpl(editor.getDocument(), project);
 
-    final AnnotationPresentation presentation = new AnnotationPresentation(fileAnnotation, getUpToDateLineNumber, switcher);
+    final AnnotationPresentation presentation = new AnnotationPresentation(fileAnnotation, getUpToDateLineNumber, switcher, disposable);
     if (currentFile != null && vcs.getCommittedChangesProvider() != null) {
       presentation.addAction(new ShowDiffFromAnnotation(fileAnnotation, vcs, currentFile));
     }
@@ -132,7 +150,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
       final CurrentRevisionAnnotationFieldGutter currentRevisionGutter =
         new CurrentRevisionAnnotationFieldGutter(fileAnnotation, revisionAspect, presentation, bgColorMap);
       final MergeSourceAvailableMarkerGutter mergeSourceGutter =
-        new MergeSourceAvailableMarkerGutter(fileAnnotation, null, presentation, bgColorMap);
+        new MergeSourceAvailableMarkerGutter(fileAnnotation, presentation, bgColorMap);
 
       SwitchAnnotationSourceAction switchAction = new SwitchAnnotationSourceAction(switcher, editorGutter);
       presentation.addAction(switchAction);
@@ -148,14 +166,14 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
 
     final LineAnnotationAspect[] aspects = fileAnnotation.getAspects();
     for (LineAnnotationAspect aspect : aspects) {
-      gutters.add(new AnnotationFieldGutter(fileAnnotation, aspect, presentation, bgColorMap));
+      gutters.add(new AspectAnnotationFieldGutter(fileAnnotation, aspect, presentation, bgColorMap));
     }
 
 
     if (historyIds != null) {
       gutters.add(new HistoryIdColumn(fileAnnotation, presentation, bgColorMap, historyIds));
     }
-    gutters.add(new HighlightedAdditionalColumn(fileAnnotation, null, presentation, bgColorMap));
+    gutters.add(new HighlightedAdditionalColumn(fileAnnotation, presentation, bgColorMap));
     final AnnotateActionGroup actionGroup = new AnnotateActionGroup(gutters, editorGutter, bgColorMap);
     presentation.addAction(actionGroup, 1);
     gutters.add(new ExtraFieldGutter(fileAnnotation, presentation, bgColorMap, actionGroup));
index 2ce48f59a1b57bcee0a3962b8e9e1051a0e7a190..cb7bd75d0cb1063191e39d085cc7aeab3b4e28f7 100644 (file)
@@ -17,18 +17,14 @@ package com.intellij.openapi.vcs.actions;
 
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.EditorGutterAction;
 import com.intellij.openapi.editor.colors.ColorKey;
 import com.intellij.openapi.editor.colors.EditorFontType;
 import com.intellij.openapi.util.Couple;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vcs.ProjectLevelVcsManager;
 import com.intellij.openapi.vcs.annotate.FileAnnotation;
-import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
 import com.intellij.openapi.vcs.annotate.TextAnnotationPresentation;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
 import com.intellij.vcsUtil.VcsUtil;
-import com.intellij.xml.util.XmlStringUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -40,103 +36,61 @@ import java.util.Map;
  * @author Irina Chernushina
  * @author Konstantin Bulenkov
  */
-public class AnnotationFieldGutter implements ActiveAnnotationGutter {
+public abstract class AnnotationFieldGutter implements ActiveAnnotationGutter {
   @NotNull protected final FileAnnotation myAnnotation;
-  protected final LineAnnotationAspect myAspect;
   @NotNull private final TextAnnotationPresentation myPresentation;
-  private final boolean myIsGutterAction;
   @Nullable private Couple<Map<VcsRevisionNumber, Color>> myColorScheme;
 
   AnnotationFieldGutter(@NotNull FileAnnotation annotation,
-                        LineAnnotationAspect aspect,
                         @NotNull TextAnnotationPresentation presentation,
                         @Nullable Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
     myAnnotation = annotation;
-    myAspect = aspect;
     myPresentation = presentation;
-    myIsGutterAction = myAspect instanceof EditorGutterAction;
     myColorScheme = colorScheme;
   }
 
   public boolean isGutterAction() {
-    return myIsGutterAction;
-  }
-
-  public String getLineText(int line, Editor editor) {
-    final String value = isAvailable() ? myAspect.getValue(line) : "";
-    if (myAspect.getId() == LineAnnotationAspect.AUTHOR && ShowShortenNames.isSet()) {
-      return shorten(value, ShowShortenNames.getType());
-    }
-    return value;
-  }
-
-  @Nullable
-  public static String shorten(String name, ShortNameType type) {
-    if (name != null) {
-      // Vasya Pupkin <vasya.pupkin@jetbrains.com> -> Vasya Pupkin
-      final int[] ind = {name.indexOf('<'), name.indexOf('@'), name.indexOf('>')};
-      if (0 < ind[0] && ind[0] < ind[1] && ind[1] < ind[2]) {
-        return shorten(name.substring(0, ind[0]).trim(), type);
-      }
-
-      // vasya.pupkin@email.com --> vasya pupkin
-      if (!name.contains(" ") && name.contains("@")) { //simple e-mail check. john@localhost
-        final String firstPart = name.substring(0, name.indexOf('@')).replace('.', ' ').replace('_', ' ').replace('-', ' ');
-        if (firstPart.length() < name.length()) {
-          return shorten(firstPart, type);
-        } else {
-          return firstPart;
-        }
-      }
-
-      final List<String> strings = StringUtil.split(name.replace('.', ' ').replace('_', ' ').replace('-', ' '), " ");
-      if (strings.size() > 1) {
-        //Middle name check: Vasya S. Pupkin
-        return StringUtil.capitalize(type == ShortNameType.FIRSTNAME ? strings.get(0) : strings.get(strings.size() - 1));
-      }
-    }
-    return name;
+    return false;
   }
 
   @Nullable
+  @Override
   public String getToolTip(final int line, final Editor editor) {
-    return isAvailable() ? XmlStringUtil.escapeString(myAnnotation.getToolTip(line)) : null;
+    return null;
   }
 
+  @Override
   public void doAction(int line) {
-    if (myIsGutterAction) {
-      ((EditorGutterAction)myAspect).doAction(line);
-    }
   }
 
+  @Override
   public Cursor getCursor(final int line) {
-    if (myIsGutterAction) {
-      return ((EditorGutterAction)myAspect).getCursor(line);
-    } else {
-      return Cursor.getDefaultCursor();
-    }
-
+    return Cursor.getDefaultCursor();
   }
 
+  @Override
   public EditorFontType getStyle(final int line, final Editor editor) {
     return myPresentation.getFontType(line);
   }
 
   @Nullable
+  @Override
   public ColorKey getColor(final int line, final Editor editor) {
     return myPresentation.getColor(line);
   }
 
+  @Override
   public List<AnAction> getPopupActions(int line, final Editor editor) {
     return myPresentation.getActions(line);
   }
 
+  @Override
   public void gutterClosed() {
-    ProjectLevelVcsManager.getInstance(myAnnotation.getProject()).getAnnotationLocalChangesListener().unregisterAnnotation(myAnnotation.getFile(), myAnnotation);
-    myAnnotation.dispose();
+    myPresentation.gutterClosed();
   }
 
   @Nullable
+  @Override
   public Color getBgColor(int line, Editor editor) {
     if (myColorScheme == null) return null;
     ColorMode type = ShowAnnotationColorsAction.getType();
@@ -147,23 +101,16 @@ public class AnnotationFieldGutter implements ActiveAnnotationGutter {
     return colorMap.get(number);
   }
 
+  public boolean isShowByDefault() {
+    return true;
+  }
+
   public boolean isAvailable() {
-    if (myAspect == null) return false;
-    return VcsUtil.isAspectAvailableByDefault(getID(), myAspect.isShowByDefault());
+    return VcsUtil.isAspectAvailableByDefault(getID(), isShowByDefault());
   }
 
   @Nullable
   public String getID() {
-    return myAspect == null ? null : myAspect.getId();
-  }
-
-
-  public static void main(String[] args) {
-    assert shorten("Vasya Pavlovich Pupkin <asdasd@localhost>", ShortNameType.FIRSTNAME).equals("Vasya");
-    assert shorten("Vasya Pavlovich Pupkin <asdasd@localhost>", ShortNameType.LASTNAME).equals("Pupkin");
-    assert shorten("Vasya Pavlovich Pupkin", ShortNameType.FIRSTNAME).equals("Vasya");
-    assert shorten("Vasya Pavlovich Pupkin", ShortNameType.LASTNAME).equals("Pupkin");
-    assert shorten("vasya.pupkin@localhost.com", ShortNameType.LASTNAME).equals("Pupkin");
-    assert shorten("vasya.pupkin@localhost.com", ShortNameType.FIRSTNAME).equals("Vasya");
+    return null;
   }
 }
index 08d7b20d012111a49844889a56e92f34f47f8be6..28bb81e686a7831fcb1c9fe6be80b5509465a41f 100644 (file)
  */
 package com.intellij.openapi.vcs.actions;
 
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.editor.colors.ColorKey;
 import com.intellij.openapi.editor.colors.EditorFontType;
 import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.vcs.annotate.*;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
-import com.intellij.util.Consumer;
 import com.intellij.util.ObjectUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -35,25 +36,33 @@ class AnnotationPresentation implements TextAnnotationPresentation {
   @Nullable private final AnnotationSourceSwitcher mySwitcher;
   private final ArrayList<AnAction> myActions = new ArrayList<>();
 
+  @NotNull private final Disposable myDisposable;
+  private boolean myDisposed = false;
+
   AnnotationPresentation(@NotNull FileAnnotation fileAnnotation,
                          @NotNull UpToDateLineNumberProvider upToDateLineNumberProvider,
-                         @Nullable final AnnotationSourceSwitcher switcher) {
+                         @Nullable AnnotationSourceSwitcher switcher,
+                         @NotNull Disposable disposable) {
     myUpToDateLineNumberProvider = upToDateLineNumberProvider;
     myFileAnnotation = fileAnnotation;
     mySwitcher = switcher;
+    myDisposable = disposable;
   }
 
+  @Override
   public EditorFontType getFontType(final int line) {
     VcsRevisionNumber revision = myFileAnnotation.originalRevision(line);
     VcsRevisionNumber currentRevision = myFileAnnotation.getCurrentRevision();
     return currentRevision != null && currentRevision.equals(revision) ? EditorFontType.BOLD : EditorFontType.PLAIN;
   }
 
+  @Override
   public ColorKey getColor(final int line) {
     if (mySwitcher == null) return AnnotationSource.LOCAL.getColor();
     return mySwitcher.getAnnotationSource(line).getColor();
   }
 
+  @Override
   public List<AnAction> getActions(int line) {
     int correctedNumber = myUpToDateLineNumberProvider.getLineNumber(line);
     for (AnAction action : myActions) {
@@ -79,4 +88,11 @@ class AnnotationPresentation implements TextAnnotationPresentation {
   public void addAction(AnAction action, int index) {
     myActions.add(index, action);
   }
+
+  @Override
+  public void gutterClosed() {
+    if (myDisposed) return;
+    myDisposed = true;
+    Disposer.dispose(myDisposable);
+  }
 }
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AspectAnnotationFieldGutter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AspectAnnotationFieldGutter.java
new file mode 100644 (file)
index 0000000..086d8e9
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.vcs.actions;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorGutterAction;
+import com.intellij.openapi.util.Couple;
+import com.intellij.openapi.vcs.annotate.FileAnnotation;
+import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
+import com.intellij.openapi.vcs.annotate.TextAnnotationPresentation;
+import com.intellij.openapi.vcs.history.VcsRevisionNumber;
+import com.intellij.xml.util.XmlStringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.util.Map;
+
+/**
+ * @author Irina Chernushina
+ * @author Konstantin Bulenkov
+ */
+public class AspectAnnotationFieldGutter extends AnnotationFieldGutter {
+  @NotNull protected final LineAnnotationAspect myAspect;
+  private final boolean myIsGutterAction;
+
+  public AspectAnnotationFieldGutter(@NotNull FileAnnotation annotation,
+                                     @NotNull LineAnnotationAspect aspect,
+                                     @NotNull TextAnnotationPresentation presentation,
+                                     @Nullable Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
+    super(annotation, presentation, colorScheme);
+    myAspect = aspect;
+    myIsGutterAction = myAspect instanceof EditorGutterAction;
+  }
+
+  @Override
+  public boolean isGutterAction() {
+    return myIsGutterAction;
+  }
+
+  @Override
+  public String getLineText(int line, Editor editor) {
+    final String value = isAvailable() ? myAspect.getValue(line) : "";
+    if (myAspect.getId() == LineAnnotationAspect.AUTHOR) {
+      return ShortNameType.shorten(value, ShowShortenNames.getType());
+    }
+    return value;
+  }
+
+  @Nullable
+  @Override
+  public String getToolTip(final int line, final Editor editor) {
+    return isAvailable() ? XmlStringUtil.escapeString(myAnnotation.getToolTip(line)) : null;
+  }
+
+  @Override
+  public void doAction(int line) {
+    if (myIsGutterAction) {
+      ((EditorGutterAction)myAspect).doAction(line);
+    }
+  }
+
+  @Override
+  public Cursor getCursor(final int line) {
+    if (myIsGutterAction) {
+      return ((EditorGutterAction)myAspect).getCursor(line);
+    }
+    return super.getCursor(line);
+  }
+
+  @Override
+  public boolean isShowByDefault() {
+    return myAspect.isShowByDefault();
+  }
+
+  @Nullable
+  @Override
+  public String getID() {
+    return myAspect.getId();
+  }
+}
index 78bbc5fdcbf99d5ac7a9b74ad173bdadbb2dc85d..8a64690392d9ad8a3cd3c1a43a83bacaf1d9d275 100644 (file)
@@ -34,7 +34,7 @@ import java.util.Map;
  *
  * @author Konstantin Bulenkov
  */
-class CurrentRevisionAnnotationFieldGutter extends AnnotationFieldGutter implements Consumer<AnnotationSource> {
+class CurrentRevisionAnnotationFieldGutter extends AspectAnnotationFieldGutter implements Consumer<AnnotationSource> {
   // merge source showing is turned on
   private boolean myTurnedOn;
 
index 77828f9fbd9a3f9631a19c3cf7615236d5c38330..dde2dd29a882111baaf43b5018dfb406586f7de9 100644 (file)
@@ -32,7 +32,7 @@ public class ExtraFieldGutter extends AnnotationFieldGutter  {
   public ExtraFieldGutter(FileAnnotation fileAnnotation,
                           AnnotationPresentation presentation,
                           Couple<Map<VcsRevisionNumber, Color>> bgColorMap, AnnotateActionGroup actionGroup) {
-    super(fileAnnotation, null, presentation, bgColorMap);
+    super(fileAnnotation, presentation, bgColorMap);
     myActionGroup = actionGroup;
   }
 
index ebc9ed5e86383a7980186dda3c2eea6e338defd6..56adfb62444ca13d050d853e81106799b03e4661 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.openapi.vcs.actions;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.util.Couple;
 import com.intellij.openapi.vcs.annotate.FileAnnotation;
-import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
 import com.intellij.openapi.vcs.annotate.TextAnnotationPresentation;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
 
@@ -28,10 +27,9 @@ import java.util.Map;
 class HighlightedAdditionalColumn extends AnnotationFieldGutter {
 
   HighlightedAdditionalColumn(FileAnnotation annotation,
-                              LineAnnotationAspect aspect,
                               TextAnnotationPresentation presentation,
                               Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
-    super(annotation, aspect, presentation, colorScheme);
+    super(annotation, presentation, colorScheme);
   }
 
   @Override
index 8fe73dc6f0bd357acc50aa6b117e90f2dd8c6409..f9013b0c5ba7dbf1ff4ad067aacc260f5e7bdb93 100644 (file)
@@ -21,7 +21,6 @@ import com.intellij.openapi.vcs.VcsBundle;
 import com.intellij.openapi.vcs.annotate.FileAnnotation;
 import com.intellij.openapi.vcs.annotate.TextAnnotationPresentation;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
-import com.intellij.vcsUtil.VcsUtil;
 
 import java.awt.*;
 import java.util.Map;
@@ -36,7 +35,7 @@ class HistoryIdColumn extends AnnotationFieldGutter {
                   final TextAnnotationPresentation presentation,
                   Couple<Map<VcsRevisionNumber, Color>> colorScheme,
                   Map<VcsRevisionNumber, Integer> ids) {
-    super(annotation, null, presentation, colorScheme);
+    super(annotation, presentation, colorScheme);
     myHistoryIds = ids;
   }
 
@@ -59,8 +58,8 @@ class HistoryIdColumn extends AnnotationFieldGutter {
   }
 
   @Override
-  public boolean isAvailable() {
-    return VcsUtil.isAspectAvailableByDefault(getID(), false);
+  public boolean isShowByDefault() {
+    return false;
   }
 
   @Override
index 6c2ef07295597b64e48bb7708c3d9b82e5cffdf7..375f1d110885069258f8e0f9497f7fb5c9101f19 100644 (file)
@@ -18,7 +18,10 @@ package com.intellij.openapi.vcs.actions;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.colors.ColorKey;
 import com.intellij.openapi.util.Couple;
-import com.intellij.openapi.vcs.annotate.*;
+import com.intellij.openapi.vcs.annotate.AnnotationSource;
+import com.intellij.openapi.vcs.annotate.AnnotationSourceSwitcher;
+import com.intellij.openapi.vcs.annotate.FileAnnotation;
+import com.intellij.openapi.vcs.annotate.TextAnnotationPresentation;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
 import com.intellij.util.Consumer;
 
@@ -33,10 +36,9 @@ class MergeSourceAvailableMarkerGutter extends AnnotationFieldGutter implements
   private boolean myTurnedOn;
 
   MergeSourceAvailableMarkerGutter(FileAnnotation annotation,
-                                   LineAnnotationAspect aspect,
                                    TextAnnotationPresentation highlighting,
                                    Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
-    super(annotation, aspect, highlighting, colorScheme);
+    super(annotation, highlighting, colorScheme);
   }
 
   @Override
index c6936797d08b7e722a63a59b06738d78e50224e1..e7cd4804df2e19b7eab83038cc7ba4937d874de7 100644 (file)
 package com.intellij.openapi.vcs.actions;
 
 import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
 
 /**
  * @author Konstantin Bulenkov
@@ -45,4 +50,34 @@ public enum ShortNameType {
   void set() {
     PropertiesComponent.getInstance().setValue(KEY, myId);
   }
+
+  @Nullable
+  public static String shorten(@Nullable String name, @NotNull ShortNameType type) {
+    if (name == null) return null;
+    if (type == NONE) return name;
+
+    // Vasya Pupkin <vasya.pupkin@jetbrains.com> -> Vasya Pupkin
+    final int[] ind = {name.indexOf('<'), name.indexOf('@'), name.indexOf('>')};
+    if (0 < ind[0] && ind[0] < ind[1] && ind[1] < ind[2]) {
+      name = name.substring(0, ind[0]).trim();
+    }
+
+    // vasya.pupkin@email.com --> vasya pupkin
+    if (!name.contains(" ") && name.contains("@")) { //simple e-mail check. john@localhost
+      name = name.substring(0, name.indexOf('@'));
+    }
+    name = name.replace('.', ' ').replace('_', ' ').replace('-', ' ');
+
+    final List<String> strings = StringUtil.split(name, " ");
+    if (strings.size() < 2) return name;
+
+    String shortName;
+    if (type == FIRSTNAME) {
+      shortName = strings.get(0);
+    }
+    else {
+      shortName = strings.get(strings.size() - 1);
+    }
+    return StringUtil.capitalize(shortName);
+  }
 }
index fe5af07d7279c1ffd129bdcb6fbbde42099ca71c..e10aa4ec1641cee938e37a808add427c8cfcc560 100644 (file)
@@ -47,10 +47,6 @@ public class ShowShortenNames extends ActionGroup {
     return myChildren;
   }
 
-  public static boolean isSet() {
-    return getType() != ShortNameType.NONE;
-  }
-
   public static ShortNameType getType() {
     for (ShortNameType type : ShortNameType.values()) {
       if (type.isSet()) {
index 1fca77641739db0acbda8c206f4f857dbad8648e..8d610295d65be93abb50f8b9b473bfde34edb5a2 100644 (file)
@@ -25,4 +25,5 @@ public interface TextAnnotationPresentation {
   EditorFontType getFontType(int line);
   ColorKey getColor(int line);
   List<AnAction> getActions(int line);
+  void gutterClosed();
 }
index 921d6432da7c1ef0457c2e2aee52afdbcfa8dde0..9cf5a451b54461cad79e627e7e68063593052a8b 100644 (file)
@@ -19,10 +19,8 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vcs.ex.LineStatusTracker;
+import org.jetbrains.annotations.Nullable;
 
-/**
- * author: lesya
- */
 public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvider {
   private final Document myDocument;
   private final LineStatusTrackerManagerI myLineStatusTrackerManagerI;
@@ -34,28 +32,51 @@ public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvide
 
   @Override
   public boolean isRangeChanged(final int start, final int end) {
-    LineStatusTracker tracker = myLineStatusTrackerManagerI.getLineStatusTracker(myDocument);
-    if (tracker == null || !tracker.isOperational()) {
+    LineStatusTracker tracker = getTracker();
+    if (tracker == null) {
       return false;
     }
-    return tracker.isRangeModified(start, end);
+    else {
+      return tracker.isRangeModified(start, end);
+    }
   }
 
   @Override
   public boolean isLineChanged(int currentNumber) {
-    LineStatusTracker tracker = myLineStatusTrackerManagerI.getLineStatusTracker(myDocument);
-    if (tracker == null || !tracker.isOperational()) {
+    LineStatusTracker tracker = getTracker();
+    if (tracker == null) {
       return false;
     }
-    return tracker.isLineModified(currentNumber);
+    else {
+      return tracker.isLineModified(currentNumber);
+    }
   }
 
   @Override
   public int getLineNumber(int currentNumber) {
-    LineStatusTracker tracker = myLineStatusTrackerManagerI.getLineStatusTracker(myDocument);
-    if (tracker == null || !tracker.isOperational()) {
+    LineStatusTracker tracker = getTracker();
+    if (tracker == null) {
       return currentNumber;
     }
-    return tracker.transferLineToVcs(currentNumber, false);
+    else {
+      return tracker.transferLineToVcs(currentNumber, false);
+    }
+  }
+
+  @Override
+  public int getLineCount() {
+    LineStatusTracker tracker = getTracker();
+    if (tracker == null) {
+      return myDocument.getLineCount();
+    }
+    else {
+      return tracker.getVcsDocument().getLineCount();
+    }
+  }
+
+  @Nullable
+  private LineStatusTracker getTracker() {
+    LineStatusTracker tracker = myLineStatusTrackerManagerI.getLineStatusTracker(myDocument);
+    return tracker != null && tracker.isOperational() ? tracker : null;
   }
 }
index 26e753e76861534e7b1e0808f4f290ea7ff793e1..cb7e15bc0e83de6016e54ad98a242a85508f71a0 100644 (file)
@@ -22,15 +22,14 @@ import com.intellij.vcs.log.CommitId;
 import com.intellij.vcs.log.Hash;
 import com.intellij.vcs.log.VcsLogStorage;
 import com.intellij.vcs.log.VcsRef;
-import gnu.trove.TObjectHashingStrategy;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import static com.intellij.util.containers.ContainerUtil.canonicalStrategy;
+
 public class InMemoryStorage implements VcsLogStorage {
-  @SuppressWarnings("unchecked") private final BiDirectionalEnumerator<CommitId> myCommitIdEnumerator =
-    new BiDirectionalEnumerator<>(1, TObjectHashingStrategy.CANONICAL);
-  @SuppressWarnings("unchecked") private final BiDirectionalEnumerator<VcsRef> myRefsEnumerator =
-    new BiDirectionalEnumerator<>(1, TObjectHashingStrategy.CANONICAL);
+  private final BiDirectionalEnumerator<CommitId> myCommitIdEnumerator = new BiDirectionalEnumerator<>(1, canonicalStrategy());
+  private final BiDirectionalEnumerator<VcsRef> myRefsEnumerator = new BiDirectionalEnumerator<>(1, canonicalStrategy());
 
   @Override
   public int getCommitIndex(@NotNull Hash hash, @NotNull VirtualFile root) {
index 967d4ff20326a7667d48c646ef518ca889d66cbd..fa8cdffcdc757304ab676caac2c652900aa3d62d 100644 (file)
@@ -64,7 +64,8 @@ public class ShowGraphHistoryAction extends DumbAwareAction {
           presentation.setEnabledAndVisible(false);
         }
         else {
-          presentation.setEnabledAndVisible(dataManager.getIndex().isIndexed(root));
+          presentation.setVisible(dataManager.getRoots().contains(root));
+          presentation.setEnabled(dataManager.getIndex().isIndexed(root));
         }
       }
     }
index eeac9e9bdd041b09e053bbdcbe8eded427c8ab37..698ebd3ec0f08edea8680f1e9a9a03b1e3e612a4 100644 (file)
@@ -186,7 +186,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
         for (int row = 0; row < maxRowsToCheck; row++) {
           String value = getModel().getValueAt(row, i).toString();
           Font font = tableFont;
-          VcsLogHighlighter.TextStyle style = getStyle(row, i, value, false, false).getTextStyle();
+          VcsLogHighlighter.TextStyle style = getStyle(row, i, false, false).getTextStyle();
           if (BOLD.equals(style)) {
             font = tableFont.deriveFont(Font.BOLD);
           }
@@ -336,13 +336,13 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
     myHighlighters.clear();
   }
 
+  @NotNull
   public SimpleTextAttributes applyHighlighters(@NotNull Component rendererComponent,
                                                 int row,
                                                 int column,
-                                                String text,
                                                 boolean hasFocus,
                                                 final boolean selected) {
-    VcsLogHighlighter.VcsCommitStyle style = getStyle(row, column, text, hasFocus, selected);
+    VcsLogHighlighter.VcsCommitStyle style = getStyle(row, column, hasFocus, selected);
 
     assert style.getBackground() != null && style.getForeground() != null && style.getTextStyle() != null;
 
@@ -359,14 +359,14 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
     return SimpleTextAttributes.REGULAR_ATTRIBUTES;
   }
 
-  public VcsLogHighlighter.VcsCommitStyle getBaseStyle(int row, int column, String text, boolean hasFocus, boolean selected) {
-    Component dummyRendererComponent = myDummyRenderer.getTableCellRendererComponent(this, text, selected, hasFocus, row, column);
+  public VcsLogHighlighter.VcsCommitStyle getBaseStyle(int row, int column, boolean hasFocus, boolean selected) {
+    Component dummyRendererComponent = myDummyRenderer.getTableCellRendererComponent(this, "", selected, hasFocus, row, column);
     return VcsCommitStyleFactory
       .createStyle(dummyRendererComponent.getForeground(), dummyRendererComponent.getBackground(), VcsLogHighlighter.TextStyle.NORMAL);
   }
 
-  private VcsLogHighlighter.VcsCommitStyle getStyle(int row, int column, String text, boolean hasFocus, boolean selected) {
-    VcsLogHighlighter.VcsCommitStyle baseStyle = getBaseStyle(row, column, text, hasFocus, selected);
+  private VcsLogHighlighter.VcsCommitStyle getStyle(int row, int column, boolean hasFocus, boolean selected) {
+    VcsLogHighlighter.VcsCommitStyle baseStyle = getBaseStyle(row, column, hasFocus, selected);
 
     VisibleGraph<Integer> visibleGraph = getVisibleGraph();
     if (row < 0 || row >= visibleGraph.getVisibleCommitCount()) {
@@ -549,7 +549,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
   protected void paintFooter(@NotNull Graphics g, int x, int y, int width, int height) {
     int lastRow = getRowCount() - 1;
     if (lastRow >= 0) {
-      g.setColor(getStyle(lastRow, GraphTableModel.COMMIT_COLUMN, "", hasFocus(), false).getBackground());
+      g.setColor(getStyle(lastRow, GraphTableModel.COMMIT_COLUMN, hasFocus(), false).getBackground());
       g.fillRect(x, y, width, height);
       if (myUi.isMultipleRoots()) {
         g.setColor(getRootBackgroundColor(getModel().getRoot(lastRow), myUi.getColorManager()));
@@ -561,7 +561,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
       }
     }
     else {
-      g.setColor(getBaseStyle(lastRow, GraphTableModel.COMMIT_COLUMN, "", hasFocus(), false).getBackground());
+      g.setColor(getBaseStyle(lastRow, GraphTableModel.COMMIT_COLUMN, hasFocus(), false).getBackground());
       g.fillRect(x, y, width, height);
     }
   }
@@ -626,7 +626,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
       }
 
       myColor = color;
-      Color background = ((VcsLogGraphTable)table).getStyle(row, column, text, hasFocus, isSelected).getBackground();
+      Color background = ((VcsLogGraphTable)table).getStyle(row, column, hasFocus, isSelected).getBackground();
       assert background != null;
       myBorderColor = background;
       setForeground(UIUtil.getTableForeground(false));
@@ -655,7 +655,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
       if (value == null) {
         return;
       }
-      append(value.toString(), applyHighlighters(this, row, column, value.toString(), hasFocus, selected));
+      append(value.toString(), applyHighlighters(this, row, column, hasFocus, selected));
     }
 
     public int getHorizontalTextPadding() {
index 0591dd7ac0bb3f56788244806f550c1244c62f0d..bf43444298f20c47bd38d493ada16fe6053f7c48 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.util.ui.UIUtil;
 import com.intellij.vcs.log.VcsRef;
 import com.intellij.vcs.log.VcsRefType;
 import com.intellij.vcs.log.data.VcsLogData;
+import com.intellij.vcs.log.graph.EdgePrintElement;
 import com.intellij.vcs.log.graph.PrintElement;
 import com.intellij.vcs.log.graph.VisibleGraph;
 import com.intellij.vcs.log.paint.GraphCellPainter;
@@ -135,10 +136,10 @@ public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
       graphPadding = 0;
     }
 
-    SimpleTextAttributes style = myGraphTable.applyHighlighters(this, row, column, "", hasFocus, isSelected);
+    SimpleTextAttributes style = myGraphTable.applyHighlighters(this, row, column, hasFocus, isSelected);
 
     Collection<VcsRef> refs = cell.getRefsToThisCommit();
-    Color foreground = ObjectUtils.assertNotNull(myGraphTable.getBaseStyle(row, column, "", hasFocus, isSelected).getForeground());
+    Color foreground = ObjectUtils.assertNotNull(myGraphTable.getBaseStyle(row, column, hasFocus, isSelected).getForeground());
     myExpanded = myGraphTable.getExpandableItemsHandler().getExpandedItems().contains(new TableCell(row, column));
     if (myFadeOutPainter != null) {
       myFadeOutPainter.customize(refs, row, column, table, foreground);
@@ -165,19 +166,24 @@ public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
   private PaintInfo getGraphImage(int row) {
     VisibleGraph<Integer> graph = myGraphTable.getVisibleGraph();
     Collection<? extends PrintElement> printElements = graph.getRowInfo(row).getPrintElements();
-    int maxIndex = 0;
+    double maxIndex = 0;
     for (PrintElement printElement : printElements) {
       maxIndex = Math.max(maxIndex, printElement.getPositionInCurrentRow());
+      if (printElement instanceof EdgePrintElement) {
+        maxIndex = Math.max(maxIndex,
+                            (printElement.getPositionInCurrentRow() + ((EdgePrintElement)printElement).getPositionInOtherRow()) / 2.0);
+      }
     }
     maxIndex++;
+
     maxIndex = Math.max(maxIndex, Math.min(MAX_GRAPH_WIDTH, graph.getRecommendedWidth()));
-    final BufferedImage image = UIUtil
-      .createImage(PaintParameters.getNodeWidth(myGraphTable.getRowHeight()) * (maxIndex + 4), myGraphTable.getRowHeight(),
-                   BufferedImage.TYPE_INT_ARGB);
+    BufferedImage image = UIUtil.createImage((int)(PaintParameters.getNodeWidth(myGraphTable.getRowHeight()) * (maxIndex + 2)),
+                                             myGraphTable.getRowHeight(),
+                                             BufferedImage.TYPE_INT_ARGB);
     Graphics2D g2 = image.createGraphics();
     myPainter.draw(g2, printElements);
 
-    int width = maxIndex * PaintParameters.getNodeWidth(myGraphTable.getRowHeight());
+    int width = (int)(maxIndex * PaintParameters.getNodeWidth(myGraphTable.getRowHeight()));
     return new PaintInfo(image, width);
   }
 
index c3739d4bf34babaa34c30ee29c2f2aee40b6f686..b72a0e62f2913886d3560c66b43f992e81739066 100644 (file)
@@ -129,7 +129,8 @@ public class AtomicFieldUpdaterIssuesInspection extends BaseInspection {
         }
         final PsiClassObjectAccessExpression objectAccessExpression = (PsiClassObjectAccessExpression)argument2;
         final PsiType type = objectAccessExpression.getOperand().getType();
-        if (!TypeUtils.areConvertible(type, field.getType())) {
+        final PsiType substFieldType = classType.resolveGenerics().getSubstitutor().substitute(field.getType());
+        if (!substFieldType.isAssignableFrom(type)) {
           registerError(lastArgument, InspectionGadgetsBundle.message("field.incorrect.type.problem.descriptor",
                                                                       fieldName, type.getPresentableText()));
           return;
index bb34d5cb9e9b3c48c188f0630adcbc1a69b682cb..4d755dcf77d18443e7bf58a614696d61864e9a62 100644 (file)
@@ -74,6 +74,16 @@ public class MethodRefCanBeReplacedWithLambdaInspection extends BaseInspection {
     return null;
   }
 
+  public static boolean isWithSideEffects(PsiMethodReferenceExpression methodReferenceExpression) {
+    final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();
+    if (qualifierExpression != null) {
+      final List<PsiElement> sideEffects = new ArrayList<>();
+      SideEffectChecker.checkSideEffects(qualifierExpression, sideEffects);
+      return !sideEffects.isEmpty();
+    }
+    return false;
+  }
+
   private static class MethodRefToLambdaVisitor extends BaseInspectionVisitor {
     @Override
     public void visitMethodReferenceExpression(PsiMethodReferenceExpression methodReferenceExpression) {
@@ -91,16 +101,6 @@ public class MethodRefCanBeReplacedWithLambdaInspection extends BaseInspection {
       if (onTheFly || ApplicationManager.getApplication().isUnitTestMode()) return SideEffectsMethodRefToLambdaFix::new;
       return null;
     }
-
-    private static boolean isWithSideEffects(PsiMethodReferenceExpression methodReferenceExpression) {
-      final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();
-      if (qualifierExpression != null) {
-        final List<PsiElement> sideEffects = new ArrayList<>();
-        SideEffectChecker.checkSideEffects(qualifierExpression, sideEffects);
-        return !sideEffects.isEmpty();
-      }
-      return false;
-    }
   }
 
   private static class MethodRefToLambdaFix extends InspectionGadgetsFix {
index b880fbad0ffaa33759c4b4807bde4fe69cfcd014..642f5e79ac6b70b0b2f236508e16191df00d287a 100644 (file)
@@ -34,7 +34,7 @@ public class CopyrightProfile extends ProfileEx {
 
   //read external
   public CopyrightProfile() {
-    super("", new SmartSerializer());
+    this("");
   }
 
   public CopyrightProfile(String profileName) {
index 73c02983b9bd1d0980522b0b69fe28a78f999635..dfd2fa8ea05d577623c6270f3eb7822d9c231f6b 100644 (file)
-<?xml version="1.0" encoding="UTF-8"?>
 <root inherit-compiler-output="false">
-    <output url="file://$MODULE_DIR$/bin" />
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src-props-1" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src-props-2" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
-    </content>
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="module-library" exported="">
-      <library name="lib-1">
-        <CLASSES>
-          <root url="file://$MODULE_DIR$/lib-1/copy-every/lib-1" />
-        </CLASSES>
-        <JAVADOC>
-          <root url="file://$MODULE_DIR$/lib-1/copy-every/doc/api" />
-        </JAVADOC>
-        <SOURCES>
-          <root url="file://$MODULE_DIR$/lib-1/copy-every/src" />
-        </SOURCES>
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library" exported="">
-      <library name="lib-2">
-        <CLASSES>
-          <root url="file://$MODULE_DIR$/../ws-internals/lib-2/copy-every/lib-2" />
-        </CLASSES>
-        <JAVADOC>
-          <root url="jar://$MODULE_DIR$/../ws-internals/lib-2/jar-all-2.zip!/" />
-        </JAVADOC>
-        <SOURCES>
-          <root url="file://$MODULE_DIR$/../ws-internals/lib-2/copy-every/src" />
-        </SOURCES>
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library" exported="">
-      <library name="lib-3">
-        <CLASSES>
-          <root url="file://$MODULE_DIR$/../../eclipse-externals/lib-3/copy-every/lib-3" />
-        </CLASSES>
-        <JAVADOC>
-          <root url="http://open-space.org" />
-        </JAVADOC>
-        <SOURCES>
-          <root url="file://$MODULE_DIR$/../../eclipse-externals/lib-3/copy-every/src" />
-        </SOURCES>
-      </library>
-    </orderEntry>