Merge branch 'master' of git.labs.intellij.net:idea/community
authorIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Fri, 4 Mar 2016 16:45:47 +0000 (19:45 +0300)
committerIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Fri, 4 Mar 2016 16:45:47 +0000 (19:45 +0300)
421 files changed:
build/conf/classVersions.txt
java/debugger/impl/src/com/intellij/debugger/impl/JavaEditorTextProviderImpl.java
java/idea-ui/src/com/intellij/ide/actions/TemplateProjectSettingsGroup.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/SurroundAutoCloseableAction.java
java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java
java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassHandler.java
java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringDialog.java
java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringHandler.java
java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java
java/java-impl/src/com/intellij/refactoring/inlineSuperClass/usageInfo/ReplaceConstructorUsageInfo.java
java/java-impl/src/com/intellij/refactoring/invertBoolean/JavaInvertBooleanDelegate.java
java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/PsiJavaFileStub.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiJavaFileStubImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSessionContainer.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/CheckedExceptionCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java
java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/ExceptionConstraintsWithProperAndNonProperThrows.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/expressions/CacheUnresolvedMethods4.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/expressions/CacheUnresolvedMethods5.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ChainedInference.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/UnrelatedDefaultsOverriddenWithConcreteMethodNonEmptySubstitutor.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IncludeConstraintsWhenParentMethodIsDuringCalculation.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/NestedLambdaExpressionsNoFormalParams.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA148841.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/redundantCast/AnotherInterfaceMethodIsPointed.java
java/java-tests/testData/codeInsight/surroundAutoCloseable/Expression.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/surroundAutoCloseable/ExpressionIncomplete.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/surroundAutoCloseable/ExpressionIncomplete_after.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/surroundAutoCloseable/Expression_after.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/surroundAutoCloseable/SimplePast.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/surroundAutoCloseable/SimplePast_after.java [new file with mode: 0644]
java/java-tests/testData/projectView/noDuplicateModules/src/com/package1/Test.java [new file with mode: 0644]
java/java-tests/testData/projectView/noDuplicateModules/src/com/package1/p2/p3/Test1.java [new file with mode: 0644]
java/java-tests/testData/psi/cls/mirror/MemberAnnotations.txt [new file with mode: 0644]
java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class [new file with mode: 0644]
java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class [new file with mode: 0644]
java/java-tests/testData/psi/cls/mirror/src/pkg/MemberAnnotations.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/after/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/before/Super.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/before/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/after/Super.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/after/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/before/Super.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/before/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineSuperClass/superConstructorWithFieldInitialization/after/Test.java
java/java-tests/testData/refactoring/invertBoolean/FinalBooleanFieldWithoutInitializer.java [new file with mode: 0644]
java/java-tests/testData/refactoring/invertBoolean/FinalBooleanFieldWithoutInitializer_after.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8ExpressionsCheckTest.java
java/java-tests/testSrc/com/intellij/codeInsight/intention/SurroundAutoCloseableActionTest.java
java/java-tests/testSrc/com/intellij/codeInsight/template/SurroundWithTemplateTest.groovy [deleted file]
java/java-tests/testSrc/com/intellij/projectView/ProjectTreeStructureTest.java
java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java
java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
java/java-tests/testSrc/com/intellij/psi/impl/JavaElementFactoryTest.java
java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineToAnonymousClassTest.java
java/typeMigration/src/com/intellij/refactoring/typeMigration/inspections/GuavaInspection.java
java/typeMigration/src/com/intellij/refactoring/typeMigration/rules/guava/GuavaConversionUtil.java
jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java
platform/bootstrap/src/com/intellij/idea/Main.java
platform/core-api/src/com/intellij/openapi/application/TransactionGuard.java
platform/core-api/src/com/intellij/openapi/application/TransactionKind.java [new file with mode: 0644]
platform/core-api/src/com/intellij/openapi/application/WrapInTransaction.java [new file with mode: 0644]
platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
platform/core-impl/src/com/intellij/openapi/application/TransactionGuardImpl.java
platform/diff-api/src/com/intellij/diff/util/Side.java
platform/diff-api/src/com/intellij/diff/util/ThreeSide.java
platform/diff-impl/src/com/intellij/diff/merge/TextMergeChange.java
platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java
platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java
platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffChange.java
platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java
platform/diff-impl/src/com/intellij/diff/tools/simple/ThreesideDiffChangeBase.java
platform/diff-impl/src/com/intellij/diff/tools/simple/ThreesideTextDiffViewerEx.java
platform/diff-impl/src/com/intellij/diff/tools/util/FoldingModelSupport.java
platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java
platform/diff-impl/src/com/intellij/diff/tools/util/side/ThreesideContentPanel.java
platform/diff-impl/src/com/intellij/diff/tools/util/side/TwosideTextDiffViewer.java
platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java
platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java
platform/diff-impl/src/com/intellij/diff/util/DiffLineMarkerRenderer.java
platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java
platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java
platform/dvcs-impl/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractModuleDataService.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java
platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/NavigationUtil.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java
platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionAction.java
platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java
platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionRootNode.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionToolPresentation.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeUpdater.java
platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixToolbar.java
platform/lang-impl/src/com/intellij/codeInspection/ui/RefElementNode.java
platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java
platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java
platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesUtil.java
platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ProjectViewDirectoryHelper.java
platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java
platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsDialog.java
platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsWithSearchSettingsDialog.java
platform/lang-impl/src/com/intellij/refactoring/memberPushDown/AbstractPushDownProcessor.java
platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessorDelegateBase.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
platform/platform-api/src/com/intellij/ide/presentation/Presentation.java
platform/platform-api/src/com/intellij/notification/Notification.java
platform/platform-api/src/com/intellij/notification/NotificationAction.java [new file with mode: 0644]
platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionUtil.java
platform/platform-api/src/com/intellij/openapi/ui/DialogEarthquakeShaker.java
platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java
platform/platform-impl/src/com/intellij/diagnostic/AbstractMessage.java
platform/platform-impl/src/com/intellij/diagnostic/GroupedLogMessage.java
platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.java
platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java
platform/platform-impl/src/com/intellij/diagnostic/LogMessage.java
platform/platform-impl/src/com/intellij/diagnostic/LogMessageEx.java
platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java
platform/platform-impl/src/com/intellij/ide/plugins/InstallPluginAction.java
platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
platform/platform-impl/src/com/intellij/idea/StartupUtil.java
platform/platform-impl/src/com/intellij/notification/EventLog.java
platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutDialog.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginUpdateInfoDialog.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiserDialog.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeBackgroundUtil.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/PaintersHelper.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
platform/platform-impl/src/com/intellij/ui/BalloonLayoutImpl.java
platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java
platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java
platform/platform-resources-en/src/messages/CodeInsightBundle.properties
platform/platform-resources-en/src/tips/ChangesView.html
platform/platform-resources-en/src/tips/FindInPath.html [new file with mode: 0644]
platform/platform-resources-en/src/tips/GoToFile.html [new file with mode: 0644]
platform/platform-resources-en/src/tips/GoToSymbol.html
platform/platform-resources-en/src/tips/GotoLineInFile.html
platform/platform-resources-en/src/tips/HippieCompletion.html [new file with mode: 0644]
platform/platform-resources-en/src/tips/RemoveToolWindowButton.html [new file with mode: 0644]
platform/platform-resources-en/src/tips/SpecialCharacters.html [new file with mode: 0644]
platform/platform-resources-en/src/tips/WildcardsInNavigationPopups.html
platform/platform-resources-en/src/tips/images/goto_file.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/goto_file@2x.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/goto_file@2x_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/goto_file_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/hippie.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/hippie@2x.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/hippie@2x_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/hippie_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/remove_from_sidebar.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/remove_from_sidebar@2x.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/remove_from_sidebar@2x_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/remove_from_sidebar_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/wildcard_goto.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/wildcard_goto@2x.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/wildcard_goto@2x_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/images/wildcard_goto_dark.png [new file with mode: 0644]
platform/platform-resources-en/src/tips/moveFileToChangelist.html
platform/platform-resources/src/PrivacyPolicy.html [new file with mode: 0644]
platform/remote-servers/impl/resources/tips/UploadSshKey.html [new file with mode: 0644]
platform/remote-servers/impl/resources/tips/images/SSHKeyUpload.png [new file with mode: 0644]
platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt
platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java
platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java
platform/util/src/com/intellij/Patches.java
platform/util/src/com/intellij/util/containers/RecentStringInterner.java
platform/util/src/com/intellij/util/io/CachingEnumerator.java
platform/util/src/com/intellij/util/io/PagedFileStorage.java
platform/vcs-api/src/com/intellij/openapi/vcs/CheckinProjectPanel.java
platform/vcs-api/src/com/intellij/openapi/vcs/impl/VcsDescriptor.java
platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java
platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/LocalFilePath.java
platform/vcs-impl/src/com/intellij/openapi/vcs/RemoteFilePath.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java
platform/vcs-log/impl/src/META-INF/vcs-log.xml
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogUserFilterImpl.java
plugins/devkit/src/inspections/PluginXmlDomInspection.java
plugins/devkit/src/references/IconsReferencesContributor.java
plugins/devkit/testData/codeInsight/iconAttribute.xml
plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.groovy
plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/data/GradleSourceSetDataService.java
plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/DependencyResolverImpl.groovy
plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java
plugins/java-decompiler/engine/build.xml
plugins/java-decompiler/engine/java-decompiler-engine.iml
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/extern/IFernflowerPreferences.java
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java
plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java
plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations$A.class [new file with mode: 0644]
plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations.class [new file with mode: 0644]
plugins/java-decompiler/engine/testData/results/TestMemberAnnotations.dec [new file with mode: 0644]
plugins/java-decompiler/engine/testData/src/pkg/TestMemberAnnotations.java [new file with mode: 0644]
plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxGenerateDefaultPropertyValuesScript.java
plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxRedundantPropertyValueInspectionTest.java [moved from plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxRedundantValueTest.java with 94% similarity]
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxRedundantPropertyValueInspection.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxRedundantPropertyValueInspection8.txt
plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java
plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml
plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml
plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyWorkspaceReader.java
plugins/maven/artifact-resolver-m31/maven-artifact-resolver-m31.iml
plugins/maven/artifact-resolver-m31/src/org/jetbrains/idea/maven/artifactResolver/IntelliJWorkspaceReaderM31.java
plugins/maven/artifact-resolver/common/maven-artifact-resolver-common.iml
plugins/maven/artifact-resolver/common/src/org/jetbrains/idea/maven/artifactResolver/common/MavenModuleMap.java
plugins/maven/maven-server-api/maven-server-api.iml
plugins/maven/maven2-server-impl/maven2-server-impl.iml
plugins/maven/maven3-server-common/maven3-server-common.iml
plugins/maven/maven30-server-impl/maven30-server-impl.iml
plugins/maven/maven32-server-impl/maven32-server-impl.iml
plugins/maven/maven32-server-impl/src/org/jetbrains/idea/maven/server/Maven32ServerEmbedderImpl.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsStructure.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/InvalidProjectImportingTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MiscImportingTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/ReimportingTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java
plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ShareDialog.java
plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCheckinHandlerFactory.java
python/educational-core/course-creator/resources/META-INF/plugin.xml
python/educational-core/src/com/jetbrains/edu/courseFormat/Course.java
python/educational-core/student/resources/META-INF/plugin.xml
python/educational-core/student/resources/code-mirror/clike.js [deleted file]
python/educational-core/student/resources/code-mirror/template.html
python/educational-core/student/src/com/jetbrains/edu/learning/StudyToolWindowConfigurator.java
python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyBrowserWindow.java
python/educational-python/student-python/resources/python.js [moved from python/educational-core/student/resources/code-mirror/python.js with 100% similarity]
python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyToolWindowConfigurator.java
python/ipnb/resources/fileTemplates/internal/Jupyter Notebook.ipynb.ft [moved from python/ipnb/resources/fileTemplates/internal/IPython Notebook.ipynb.ft with 100% similarity]
python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java
python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java
python/ipnb/src/org/jetbrains/plugins/ipnb/protocol/IpnbConnection.java
python/ipnb/src/org/jetbrains/plugins/ipnb/psi/IpnbPyFragment.java
python/psi-api/src/com/jetbrains/python/psi/LanguageLevel.java
python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml
python/resources/pycharm_core_about.png
python/resources/pycharm_core_about@2x.png
python/resources/pycharm_core_logo.png
python/resources/pycharm_core_logo@2x.png
python/src/META-INF/python-core-common.xml
python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java
python/src/com/jetbrains/python/console/PydevConsoleCommunication.java
python/src/com/jetbrains/python/debugger/PySignatureCacheManagerImpl.java
python/src/com/jetbrains/python/findUsages/PyClassFindUsagesHandler.java
python/src/com/jetbrains/python/findUsages/PyFunctionFindUsagesHandler.java
python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java
python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiser.java [new file with mode: 0644]
python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiserSettings.java [new file with mode: 0644]
python/testSrc/com/jetbrains/env/python/console/PyConsoleTask.java
python/testSrc/com/jetbrains/python/PyTypingTest.java
resources-en/src/tips/ChangeSignatureAfterMovingParameters.html [new file with mode: 0644]
resources-en/src/tips/CopyPasteReference.html
resources-en/src/tips/FileStructurePopup.html [new file with mode: 0644]
resources-en/src/tips/FinishByExclamation.html
resources-en/src/tips/GoToAction.html [new file with mode: 0644]
resources-en/src/tips/GoToInspection.html [new file with mode: 0644]
resources-en/src/tips/QuickDocOnMouseMove.html [new file with mode: 0644]
resources-en/src/tips/SearchEverywhere.html [new file with mode: 0644]
resources-en/src/tips/SmartTypeCompletion.html
resources-en/src/tips/WildcardsInNavigationPopups.html [new file with mode: 0644]
resources-en/src/tips/images/ant_target_intention.png
resources-en/src/tips/images/ant_target_intention@2x.png [new file with mode: 0644]
resources-en/src/tips/images/ant_target_intention@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/ant_target_intention_dark.png [new file with mode: 0644]
resources-en/src/tips/images/apply_signature_change.png [new file with mode: 0644]
resources-en/src/tips/images/apply_signature_change@2x.png [new file with mode: 0644]
resources-en/src/tips/images/apply_signature_change@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/apply_signature_change_dark.png [new file with mode: 0644]
resources-en/src/tips/images/arrayMember.png
resources-en/src/tips/images/arrayMember@2x.png [new file with mode: 0644]
resources-en/src/tips/images/arrayMember@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/arrayMember_dark.png [new file with mode: 0644]
resources-en/src/tips/images/aslist_after.png
resources-en/src/tips/images/aslist_after@2x.png [new file with mode: 0644]
resources-en/src/tips/images/aslist_after@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/aslist_after_dark.png [new file with mode: 0644]
resources-en/src/tips/images/aslist_before.png
resources-en/src/tips/images/aslist_before@2x.png [new file with mode: 0644]
resources-en/src/tips/images/aslist_before@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/aslist_before_dark.png [new file with mode: 0644]
resources-en/src/tips/images/completionImportStatic.png
resources-en/src/tips/images/completionImportStatic@2x.png [new file with mode: 0644]
resources-en/src/tips/images/completionImportStatic@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/completionImportStatic_dark.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_after.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_after@2x.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_after@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_after_dark.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_before.png
resources-en/src/tips/images/exclamationFinish_before@2x.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_before@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/exclamationFinish_before_dark.png [new file with mode: 0644]
resources-en/src/tips/images/exlamationFinish_after.png [deleted file]
resources-en/src/tips/images/file_structure_popup.png [new file with mode: 0644]
resources-en/src/tips/images/file_structure_popup@2x.png [new file with mode: 0644]
resources-en/src/tips/images/file_structure_popup@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/file_structure_popup_dark.png [new file with mode: 0644]
resources-en/src/tips/images/find_action.png [new file with mode: 0644]
resources-en/src/tips/images/find_action@2x.png [new file with mode: 0644]
resources-en/src/tips/images/find_action@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/find_action_dark.png [new file with mode: 0644]
resources-en/src/tips/images/fix_doc_comment@2x.png [new file with mode: 0644]
resources-en/src/tips/images/fix_doc_comment@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/fix_doc_comment_dark.png [new file with mode: 0644]
resources-en/src/tips/images/highlightImplemented@2x.png [new file with mode: 0644]
resources-en/src/tips/images/highlightImplemented@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/inspection_by_name.png [new file with mode: 0644]
resources-en/src/tips/images/inspection_by_name@2x.png [new file with mode: 0644]
resources-en/src/tips/images/inspection_by_name@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/inspection_by_name_dark.png [new file with mode: 0644]
resources-en/src/tips/images/line_separator@2x.png [new file with mode: 0644]
resources-en/src/tips/images/line_separator@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/line_separator_dark.png [new file with mode: 0644]
resources-en/src/tips/images/line_separator_folder.png
resources-en/src/tips/images/line_separator_folder@2x.png [new file with mode: 0644]
resources-en/src/tips/images/line_separator_folder@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/line_separator_folder_dark.png [new file with mode: 0644]
resources-en/src/tips/images/live_templates_1.png
resources-en/src/tips/images/live_templates_1@2x.png
resources-en/src/tips/images/live_templates_1@2x_dark.png
resources-en/src/tips/images/live_templates_1_dark.png
resources-en/src/tips/images/live_templates_2.png
resources-en/src/tips/images/live_templates_2@2x.png
resources-en/src/tips/images/live_templates_2@2x_dark.png
resources-en/src/tips/images/live_templates_2_dark.png
resources-en/src/tips/images/methodExitPoints@2x.png [new file with mode: 0644]
resources-en/src/tips/images/methodExitPoints@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_down.png
resources-en/src/tips/images/move_up_down_witharrows_down@2x.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_down@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_down_dark.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_initial.png
resources-en/src/tips/images/move_up_down_witharrows_initial@2x.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_initial@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_initial_dark.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_up.png
resources-en/src/tips/images/move_up_down_witharrows_up@2x.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_up@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/move_up_down_witharrows_up_dark.png [new file with mode: 0644]
resources-en/src/tips/images/refactor_this@2x.png [new file with mode: 0644]
resources-en/src/tips/images/refactor_this@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/refactor_this_dark.png [new file with mode: 0644]
resources-en/src/tips/images/reference_copied.png
resources-en/src/tips/images/reference_copied@2x.png [new file with mode: 0644]
resources-en/src/tips/images/reference_copied@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/reference_copied_dark.png [new file with mode: 0644]
resources-en/src/tips/images/reference_pasted.png
resources-en/src/tips/images/reference_pasted@2x.png [new file with mode: 0644]
resources-en/src/tips/images/reference_pasted@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/reference_pasted_dark.png [new file with mode: 0644]
resources-en/src/tips/images/rename.png [new file with mode: 0644]
resources-en/src/tips/images/rename@2x.png [new file with mode: 0644]
resources-en/src/tips/images/rename@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/rename_dark.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere@2x.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere_dark.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere_lense.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere_lense@2x.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere_lense@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/searchEverywhere_lense_dark.png [new file with mode: 0644]
resources-en/src/tips/images/second_code_completion.png
resources-en/src/tips/images/second_code_completion@2x.png [new file with mode: 0644]
resources-en/src/tips/images/second_code_completion@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/second_code_completion_dark.png [new file with mode: 0644]
resources-en/src/tips/images/wildcard_goto.gif [deleted file]
resources-en/src/tips/images/wildcard_goto.png [new file with mode: 0644]
resources-en/src/tips/images/wildcard_goto@2x.png [new file with mode: 0644]
resources-en/src/tips/images/wildcard_goto@2x_dark.png [new file with mode: 0644]
resources-en/src/tips/images/wildcard_goto_dark.png [new file with mode: 0644]
resources/src/META-INF/IdeTipsAndTricks.xml
resources/src/liveTemplates/surround.xml
spellchecker/src/com/intellij/spellchecker/jetbrains.dic
xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java
xml/dom-openapi/src/com/intellij/util/xml/reflect/DomCollectionChildDescription.java
xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java
xml/impl/src/com/intellij/psi/formatter/xml/HtmlPolicy.java
xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java

index aef87f308a55cd2fc95e34e3dc4dc0d271428d9e..0efe3d31cc1f61b44f913094ffaa7e8f913766e7 100644 (file)
 1.6 => plugins/gradle/lib/gradle-tooling-extension-api.jar
 1.6 => plugins/gradle/lib/gradle-tooling-extension-impl.jar
 
+1.6 => plugins/maven/lib/maven-server-api.jar
+1.6 => plugins/maven/lib/maven2-server-impl.jar
+1.6 => plugins/maven/lib/maven3-server-common.jar
+1.6 => plugins/maven/lib/maven30-server-impl.jar
+1.6 => plugins/maven/lib/maven32-server-impl.jar
+1.6 => plugins/maven/lib/artifact-resolver-m2.jar
+1.6 => plugins/maven/lib/artifact-resolver-m3.jar
+1.6 => plugins/maven/lib/artifact-resolver-m31.jar
+
 1.4 => plugins/xpath/lib/rt/xslt-rt.jar
 1.5 => plugins/xslt-debugger/lib/xslt-debugger-engine.jar
 1.5 => plugins/xslt-debugger/lib/rt/xslt-debugger-engine-impl.jar
index 2835de5b97a5e0da1a472c1192f77e7debb1c5ad..d245a8c0d3e8545bc3b73980ee4b9f75a10dd7b4 100644 (file)
@@ -95,7 +95,8 @@ public class JavaEditorTextProviderImpl implements EditorTextProvider {
     }
     else if (parent instanceof PsiReferenceExpression) {
       final PsiElement pparent = parent.getParent();
-      if (parent instanceof PsiMethodReferenceExpression || pparent instanceof PsiCallExpression) {
+      if (parent instanceof PsiMethodReferenceExpression ||
+          (pparent instanceof PsiCallExpression && ((PsiCallExpression)pparent).getArgumentList() != null)) { // skip arrays
         parent = pparent;
       }
       else if (pparent instanceof PsiReferenceExpression) {
index 13cd06844bcacbe58d4dbd592eb71f50a423bb9d..43a25fe4700519706ded6dd3f1355ef7a7c233ee 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.
@@ -21,33 +21,29 @@ package com.intellij.ide.actions;
 
 import com.intellij.execution.actions.EditRunConfigurationsAction;
 import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.DefaultActionGroup;
 import com.intellij.openapi.actionSystem.Presentation;
 
+import javax.swing.*;
+
 public class TemplateProjectSettingsGroup extends DefaultActionGroup {
   public TemplateProjectSettingsGroup() {
     setPopup(true);
-    Presentation presentation = getTemplatePresentation();
 
+    Presentation presentation = getTemplatePresentation();
     presentation.setText("Project Defaults");
     presentation.setIcon(AllIcons.General.TemplateProjectSettings);
 
-    add(new TemplateProjectPropertiesAction() {{
-      Presentation p = getTemplatePresentation();
-      p.setText("Settings");
-      p.setIcon(AllIcons.General.TemplateProjectSettings);
-    }});
-
-    add(new TemplateProjectStructureAction(){{
-      Presentation p = getTemplatePresentation();
-      p.setText("Project Structure");
-      p.setIcon(AllIcons.General.TemplateProjectStructure);
-    }});
+    add(withTextAndIcon(new TemplateProjectPropertiesAction(), "Settings", AllIcons.General.TemplateProjectSettings));
+    add(withTextAndIcon(new TemplateProjectStructureAction(), "Project Structure", AllIcons.General.TemplateProjectStructure));
+    add(withTextAndIcon(new EditRunConfigurationsAction(), "Run Configurations", AllIcons.General.CreateNewProjectfromExistingFiles));
+  }
 
-    add(new EditRunConfigurationsAction() {{
-      Presentation p = getTemplatePresentation();
-      p.setText("Run Configurations");
-      p.setIcon(AllIcons.General.CreateNewProjectfromExistingFiles);
-    }});
+  private static AnAction withTextAndIcon(AnAction action, String text, Icon icon) {
+    Presentation presentation = action.getTemplatePresentation();
+    presentation.setText(text);
+    presentation.setIcon(icon);
+    return action;
   }
-}
+}
\ No newline at end of file
index f678d46a98957a0c1fbb3f075bafec96f8697722..916e7de7097f677d36f0706272dc9d9d5bd14bc9 100644 (file)
@@ -441,7 +441,6 @@ public class GenericsHighlightUtil {
   }
 
   static HighlightInfo checkUnrelatedDefaultMethods(@NotNull PsiClass aClass,
-                                                    @NotNull Collection<HierarchicalMethodSignature> signaturesWithSupers,
                                                     @NotNull PsiIdentifier classIdentifier) {
     final Map<MethodSignature, Set<PsiMethod>> overrideEquivalent =
       new THashMap<MethodSignature, Set<PsiMethod>>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
@@ -454,9 +453,10 @@ public class GenericsHighlightUtil {
         subType |= supers[j].isInheritor(supers[i], true);
       }
       if (subType) continue;
+      final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY);
       for (HierarchicalMethodSignature hms : superClass.getVisibleSignatures()) {
         final PsiMethod method = hms.getMethod();
-        if (aClass.findMethodsBySignature(method, false).length > 0) continue;
+        if (MethodSignatureUtil.findMethodBySignature(aClass, method.getSignature(superClassSubstitutor), false) != null) continue;
         final PsiClass containingClass = method.getContainingClass();
         if (containingClass == null) continue;
         final PsiSubstitutor containingClassSubstitutor = TypeConversionUtil.getClassSubstitutor(containingClass, aClass, PsiSubstitutor.EMPTY);
index c99c7dd4ad6e2eb6cd27122ad6a8fd92736a81c5..21f40b8af7081c82f0fba5a2d4dcc09672f2510c 100644 (file)
@@ -636,7 +636,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
         myHolder.add(HighlightNamesUtil.highlightClassName(aClass, identifier, colorsScheme));
       }
       if (!myHolder.hasErrorResults() && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
-        myHolder.add(GenericsHighlightUtil.checkUnrelatedDefaultMethods(aClass, aClass.getVisibleSignatures(), identifier));
+        myHolder.add(GenericsHighlightUtil.checkUnrelatedDefaultMethods(aClass, identifier));
       }
 
       if (!myHolder.hasErrorResults()) {
index 6ede7a3b710d387f8b828543b92eee1d75594b69..542119679ec6b4cfe531cb2acd918bccf8d28d34 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.codeInsight.intention.impl;
 
 import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.codeInsight.CodeInsightUtilCore;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.lookup.LookupElementBuilder;
+import com.intellij.codeInsight.template.*;
 import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -29,12 +33,16 @@ import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
+import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
+import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
+import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.Processor;
+import com.intellij.util.ObjectUtils;
 import com.intellij.util.SmartList;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.List;
+import java.util.stream.Stream;
 
 public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
   @Override
@@ -42,16 +50,20 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
     if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return false;
     if (!PsiUtil.getLanguageLevel(element).isAtLeast(LanguageLevel.JDK_1_7)) return false;
 
-    final PsiLocalVariable variable = PsiTreeUtil.getParentOfType(element, PsiLocalVariable.class);
-    if (variable == null) return false;
-    final PsiExpression initializer = variable.getInitializer();
-    if (initializer == null) return false;
-    final PsiElement declaration = variable.getParent();
-    if (!(declaration instanceof PsiDeclarationStatement)) return false;
-    final PsiElement codeBlock = declaration.getParent();
-    if (!(codeBlock instanceof PsiCodeBlock)) return false;
+    PsiType type = null;
 
-    return InheritanceUtil.isInheritor(variable.getType(), CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE);
+    PsiLocalVariable variable = findVariable(element);
+    if (variable != null) {
+      type = variable.getType();
+    }
+    else {
+      PsiExpression expression = findExpression(element);
+      if (expression != null) {
+        type = expression.getType();
+      }
+    }
+
+    return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE);
   }
 
   @Override
@@ -60,35 +72,85 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
       return;
     }
 
-    final PsiLocalVariable variable = PsiTreeUtil.getParentOfType(element, PsiLocalVariable.class);
-    if (variable == null) return;
-    final PsiExpression initializer = variable.getInitializer();
-    if (initializer == null) return;
-    final PsiElement declaration = variable.getParent();
-    if (!(declaration instanceof PsiDeclarationStatement)) return;
-    final PsiElement codeBlock = declaration.getParent();
-    if (!(codeBlock instanceof PsiCodeBlock)) return;
+    PsiLocalVariable variable = findVariable(element);
+    if (variable != null) {
+      processVariable(project, editor, variable);
+    }
+    else {
+      PsiExpression expression = findExpression(element);
+      if (expression != null) {
+        processExpression(project, editor, expression);
+      }
+    }
+  }
+
+  private static PsiLocalVariable findVariable(PsiElement element) {
+    PsiLocalVariable variable = PsiTreeUtil.getParentOfType(element, PsiLocalVariable.class);
+
+    if (variable != null &&
+        variable.getInitializer() != null &&
+        variable.getParent() instanceof PsiDeclarationStatement &&
+        variable.getParent().getParent() instanceof PsiCodeBlock) {
+      return variable;
+    }
+
+    if (variable == null && element instanceof PsiWhiteSpace) {
+      PsiElement sibling = element.getPrevSibling();
+      if (sibling instanceof PsiDeclarationStatement) {
+        PsiElement lastVar = ArrayUtil.getLastElement(((PsiDeclarationStatement)sibling).getDeclaredElements());
+        if (lastVar instanceof PsiLocalVariable) {
+          return (PsiLocalVariable)lastVar;
+        }
+      }
+    }
+
+    return null;
+  }
+
+  private static PsiExpression findExpression(PsiElement element) {
+    PsiExpression expression = PsiTreeUtil.getParentOfType(element, PsiExpression.class);
+
+    if (expression != null &&
+        expression.getParent() instanceof PsiExpressionStatement &&
+        expression.getParent().getParent() instanceof PsiCodeBlock) {
+      return expression;
+    }
+
+    if (expression == null && element instanceof PsiWhiteSpace) {
+      PsiElement sibling = element.getPrevSibling();
+      if (sibling instanceof PsiExpressionStatement) {
+        return ((PsiExpressionStatement)sibling).getExpression();
+      }
+    }
 
-    final LocalSearchScope scope = new LocalSearchScope(codeBlock);
+    return null;
+  }
+
+  private static void processVariable(Project project, Editor editor, PsiLocalVariable variable) {
+    PsiExpression initializer = ObjectUtils.assertNotNull(variable.getInitializer());
+    PsiElement declaration = variable.getParent();
+    PsiElement codeBlock = declaration.getParent();
+
+    LocalSearchScope scope = new LocalSearchScope(codeBlock);
     PsiElement last = null;
     for (PsiReference reference : ReferencesSearch.search(variable, scope).findAll()) {
-      final PsiElement usage = PsiTreeUtil.findPrevParent(codeBlock, reference.getElement());
+      PsiElement usage = PsiTreeUtil.findPrevParent(codeBlock, reference.getElement());
       if ((last == null || usage.getTextOffset() > last.getTextOffset())) {
         last = usage;
       }
     }
 
-    final String text = "try (" + variable.getTypeElement().getText() + " " + variable.getName() + " = " + initializer.getText() + ") {}";
-    final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
-    final PsiTryStatement armStatement = (PsiTryStatement)declaration.replace(factory.createStatementFromText(text, codeBlock));
+    String text = "try (" + variable.getTypeElement().getText() + " " + variable.getName() + " = " + initializer.getText() + ") {}";
+    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
+    PsiTryStatement armStatement = (PsiTryStatement)declaration.replace(factory.createStatementFromText(text, codeBlock));
 
     List<PsiElement> toFormat = null;
     if (last != null) {
       toFormat = moveStatements(last, armStatement);
     }
 
-    final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
-    final PsiElement formattedElement = codeStyleManager.reformat(armStatement);
+    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
+    PsiElement formattedElement = codeStyleManager.reformat(armStatement);
     if (toFormat != null) {
       for (PsiElement psiElement : toFormat) {
         codeStyleManager.reformat(psiElement);
@@ -96,9 +158,9 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
     }
 
     if (last == null) {
-      final PsiCodeBlock tryBlock = ((PsiTryStatement)formattedElement).getTryBlock();
+      PsiCodeBlock tryBlock = ((PsiTryStatement)formattedElement).getTryBlock();
       if (tryBlock != null) {
-        final PsiJavaToken brace = tryBlock.getLBrace();
+        PsiJavaToken brace = tryBlock.getLBrace();
         if (brace != null) {
           editor.getCaretModel().moveToOffset(brace.getTextOffset() + 1);
         }
@@ -110,8 +172,9 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
     PsiCodeBlock tryBlock = statement.getTryBlock();
     assert tryBlock != null : statement.getText();
     PsiElement parent = statement.getParent();
+    LocalSearchScope scope = new LocalSearchScope(parent);
 
-    List<PsiElement> toFormat = new SmartList<PsiElement>();
+    List<PsiElement> toFormat = new SmartList<>();
     PsiElement stopAt = last.getNextSibling();
 
     PsiElement i = statement.getNextSibling();
@@ -125,13 +188,8 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
       for (PsiElement declared : ((PsiDeclarationStatement)child).getDeclaredElements()) {
         if (!(declared instanceof PsiLocalVariable)) continue;
 
-        final int endOffset = last.getTextRange().getEndOffset();
-        boolean contained = ReferencesSearch.search(declared, new LocalSearchScope(parent)).forEach(new Processor<PsiReference>() {
-          @Override
-          public boolean process(PsiReference ref) {
-            return ref.getElement().getTextOffset() <= endOffset;
-          }
-        });
+        int endOffset = last.getTextRange().getEndOffset();
+        boolean contained = ReferencesSearch.search(declared, scope).forEach(ref -> ref.getElement().getTextOffset() <= endOffset);
 
         if (!contained) {
           PsiLocalVariable var = (PsiLocalVariable)declared;
@@ -163,6 +221,38 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
     return toFormat;
   }
 
+  private static void processExpression(Project project, Editor editor, PsiExpression expression) {
+    PsiType type = ObjectUtils.assertNotNull(expression.getType());
+    PsiElement statement = expression.getParent();
+    PsiElement codeBlock = statement.getParent();
+
+    String text = "try (" + type.getCanonicalText(true) + " r = " + expression.getText() + ") {}";
+    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
+    PsiTryStatement tryStatement = (PsiTryStatement)statement.replace(factory.createStatementFromText(text, codeBlock));
+
+    tryStatement = (PsiTryStatement)CodeStyleManager.getInstance(project).reformat(tryStatement);
+
+    tryStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(tryStatement);
+
+    PsiResourceList resourceList = tryStatement.getResourceList();
+    if (resourceList != null) {
+      PsiResourceVariable var = (PsiResourceVariable)resourceList.iterator().next();
+      PsiIdentifier id = var.getNameIdentifier();
+      PsiExpression initializer = var.getInitializer();
+      if (id != null && initializer != null) {
+        type = initializer.getType();
+        String[] names = IntroduceVariableBase.getSuggestedName(type, initializer).names;
+        PsiType[] types = Stream.of(new TypeSelectorManagerImpl(project, type, initializer, PsiExpression.EMPTY_ARRAY).getTypesForAll())
+            .filter(t -> InheritanceUtil.isInheritor(t, CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE))
+            .toArray(PsiType[]::new);
+        TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(var);
+        builder.replaceElement(id, new NamesExpression(names));
+        builder.replaceElement(var.getTypeElement(), new TypeExpression(project, types));
+        builder.run(editor, true);
+      }
+    }
+  }
+
   @NotNull
   @Override
   public String getFamilyName() {
@@ -174,4 +264,27 @@ public class SurroundAutoCloseableAction extends PsiElementBaseIntentionAction {
   public String getText() {
     return getFamilyName();
   }
-}
+
+  private static class NamesExpression extends Expression {
+    private final String[] myNames;
+
+    public NamesExpression(String[] names) {
+      myNames = names;
+    }
+
+    @Override
+    public Result calculateResult(ExpressionContext context) {
+      return calculateQuickResult(context);
+    }
+
+    @Override
+    public Result calculateQuickResult(ExpressionContext context) {
+      return new TextResult(myNames[0]);
+    }
+
+    @Override
+    public LookupElement[] calculateLookupItems(ExpressionContext context) {
+      return Stream.of(myNames).map(LookupElementBuilder::create).toArray(LookupElement[]::new);
+    }
+  }
+}
\ No newline at end of file
index ad13714f3cc78070dda3ef0b0eed5d0f9a8a0f6e..963d55c6d342c666b2c1bd4dec04881825d97c95 100644 (file)
@@ -43,6 +43,7 @@ import com.intellij.util.containers.HashMap;
 import com.intellij.util.containers.HashSet;
 import com.intellij.util.text.CharArrayUtil;
 import com.intellij.util.text.DateFormatUtil;
+import com.intellij.util.ui.UIUtil;
 import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -107,7 +108,9 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
   }
 
   @Override
-  public void exportResults(@NotNull final Element parentNode, @NotNull RefEntity refEntity) {
+  public void exportResults(@NotNull final Element parentNode,
+                            @NotNull RefEntity refEntity,
+                            Set<CommonProblemDescriptor> excludedDescriptions) {
     if (!(refEntity instanceof RefJavaElement)) return;
     final RefFilter filter = getFilter();
     if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
@@ -517,4 +520,16 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
       return true;
     }
   }
+
+  @Override
+  public JComponent getCustomPreviewPanel(RefEntity entity) {
+    JEditorPane htmlView = new JEditorPane();
+    htmlView.setContentType(UIUtil.HTML_MIME);
+    htmlView.setEditable(false);
+    htmlView.setOpaque(false);
+    final StringBuffer buf = new StringBuffer();
+    getComposer().compose(buf, entity);
+    htmlView.setText(buf.toString());
+    return htmlView;
+  }
 }
index 3172e68918a958a9ced7b10085d7609be9226214..be3122d57e7db7092ed1b47e36cb54abe5fd6c35 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.
@@ -223,7 +223,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{
   }
 
   @Override
-  protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) {
+  protected boolean isSearchForTextOccurrencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) {
     return !isSingleFile &&
            new JavaNonCodeSearchElementDescriptionProvider().getElementDescription(psiElement, NonCodeSearchDescriptionLocation.NON_JAVA) != null;
   }
index 4baf63c4a3e813835a5490012e48d7f165e82753..d79c018139d5ead200c2ca38f2705b94d6b26683 100644 (file)
@@ -71,7 +71,7 @@ public class JDComment {
 
     if (!isNull(myDescription)) {
       sb.append(prefix);
-      sb.append(myFormatter.getParser().formatJDTagDescription(myDescription, prefix));
+      sb.append(myFormatter.getParser().formatJDTagDescription(myDescription, prefix, false));
 
       if (myFormatter.getSettings().JD_ADD_BLANK_AFTER_DESCRIPTION) {
         sb.append(prefix);
index cf4a353ce049041fcca0caad6dde149b124097bc..7afafddf810184f999636db4545ea22b0d0ed89b 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.codeStyle.javadoc;
 import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleSettings;
 import com.intellij.psi.javadoc.PsiDocComment;
@@ -280,6 +279,18 @@ public class JDParser {
     return removeWhiteSpacesFrom(token).toLowerCase().equals(SELF_CLOSED_P_TAG);
   }
   
+  private static boolean hasLineLongerThan(String str, int maxLength) {
+    if (str == null) return false;
+
+    for (String s : str.split("\n")) {
+      if (s.length() > maxLength) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+  
 
   @NotNull
   private static String removeWhiteSpacesFrom(@NotNull final String token) {
@@ -520,13 +531,15 @@ public class JDParser {
     },
   };
 
-  /**
-   * @see JDParser#formatJDTagDescription(String, CharSequence, boolean, int)
-   */
   @NotNull
   protected StringBuilder formatJDTagDescription(@Nullable String s, @NotNull CharSequence prefix) {
     return formatJDTagDescription(s, prefix, false, 0);
   }
+  
+  @NotNull
+  protected StringBuilder formatJDTagDescription(@Nullable String s, @NotNull CharSequence prefix, boolean wrapLinesShorterRightMargin) {
+    return formatJDTagDescription(s, prefix, false, 0, wrapLinesShorterRightMargin);
+  }
 
   private static boolean lineHasUnclosedPreTag(@NotNull String line) {
     return StringUtil.getOccurrenceCount(line, PRE_TAG_START) > StringUtil.getOccurrenceCount(line, PRE_TAG_END);
@@ -536,6 +549,14 @@ public class JDParser {
     return StringUtil.getOccurrenceCount(line, PRE_TAG_END) > StringUtil.getOccurrenceCount(line, PRE_TAG_START);
   }
 
+  @NotNull
+  protected StringBuilder formatJDTagDescription(@Nullable String str,
+                                                 @NotNull CharSequence prefix,
+                                                 boolean firstLineShorter,
+                                                 int firstLinePrefixLength) {
+    return formatJDTagDescription(str, prefix, firstLineShorter, firstLinePrefixLength, true);
+  }
+  
   /**
    * Returns formatted JavaDoc tag description, according to selected configuration
    * @param str JavaDoc tag description
@@ -548,15 +569,20 @@ public class JDParser {
   protected StringBuilder formatJDTagDescription(@Nullable String str,
                                                  @NotNull CharSequence prefix,
                                                  boolean firstLineShorter,
-                                                 int firstLinePrefixLength)
+                                                 int firstLinePrefixLength,
+                                                 boolean isWrapLinesShorterRightMargin)
   {
-    int rightMargin = mySettings.getRightMargin(JavaLanguage.INSTANCE);
+    final int rightMargin = mySettings.getRightMargin(JavaLanguage.INSTANCE);
+    final int maxCommentLength = rightMargin - prefix.length();
+    
     StringBuilder sb = new StringBuilder();
     List<String> list;
-
+    
+    boolean canWrap = isWrapLinesShorterRightMargin || hasLineLongerThan(str, maxCommentLength);
+    
     //If wrap comments selected, comments should be wrapped by the right margin
-    if (mySettings.WRAP_COMMENTS) {
-      list = toArrayWrapping(str, rightMargin - prefix.length());
+    if (mySettings.WRAP_COMMENTS && canWrap) {
+      list = toArrayWrapping(str, maxCommentLength);
 
       if (firstLineShorter
           && list != null && !list.isEmpty()
@@ -575,7 +601,7 @@ public class JDParser {
         }
 
         //getting all another lines according to their prefix
-        List<String> subList = toArrayWrapping(str, rightMargin - prefix.length());
+        List<String> subList = toArrayWrapping(str, maxCommentLength);
 
         //removing pre tag
         if (unclosedPreTag && subList != null && !subList.isEmpty()) {
index 34ce8e6f4bb6976038b77d503897deb8f74c7270..cd0f28c6aa4d3f72774bcbf751477899ff658591 100644 (file)
@@ -32,7 +32,6 @@ import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.wm.WindowManager;
 import com.intellij.psi.*;
 import com.intellij.psi.controlFlow.DefUseUtil;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -78,7 +77,7 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
 
     final String localName = local.getName();
 
-    final Query<PsiReference> query = ReferencesSearch.search(local, GlobalSearchScope.allScope(project), false);
+    final Query<PsiReference> query = ReferencesSearch.search(local, local.getUseScope());
     if (query.findFirst() == null){
       LOG.assertTrue(refExpr == null);
       String message = RefactoringBundle.message("variable.is.never.used", localName);
index cb211400ab4748603f018f8265dfad0f009b91cb..09d597e0a05ad8fcfa4ba71b7f542a5b3993faa1 100644 (file)
@@ -256,7 +256,7 @@ public class InlineToAnonymousClassHandler extends JavaInlineActionHandler {
       }
       else if (method.findSuperMethods().length == 0) {
         if (!ReferencesSearch.search(method).forEach(new AllowedUsagesProcessor(psiClass))) {
-          return "Class cannot be inlined because it has usages of methods not inherited from its superclass or interface";
+          return "Class cannot be inlined because there are usages of its methods not inherited from its superclass or interface";
         }
       }
       if (method.hasModifierProperty(PsiModifier.STATIC)) {
index 081ca8ce3750eca65ec0385f6a0eac20e06d96f0..6809c9779a8168c24731ac29b375f4dd0e639626 100644 (file)
 package com.intellij.refactoring.inlineSuperClass;
 
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.PsiClass;
 import com.intellij.refactoring.JavaRefactoringSettings;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.inline.InlineOptionsDialog;
 import com.intellij.refactoring.ui.DocCommentPanel;
-import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.util.Function;
-import com.intellij.util.ui.JBDimension;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -40,15 +35,13 @@ import java.awt.*;
 public class InlineSuperClassRefactoringDialog extends InlineOptionsDialog {
   private final PsiClass mySuperClass;
   private final PsiClass myCurrentInheritor;
-  private final PsiClass[] myTargetClasses;
   private final DocCommentPanel myDocPanel;
 
-  protected InlineSuperClassRefactoringDialog(@NotNull Project project, PsiClass superClass, PsiClass currentInheritor, final PsiClass... targetClasses) {
+  protected InlineSuperClassRefactoringDialog(@NotNull Project project, PsiClass superClass, PsiClass currentInheritor) {
     super(project, false, superClass);
     mySuperClass = superClass;
     myCurrentInheritor = currentInheritor;
     myInvokedOnReference = currentInheritor != null;
-    myTargetClasses = targetClasses;
     myDocPanel = new DocCommentPanel("JavaDoc for inlined members");
     myDocPanel.setPolicy(JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC);
     init();
@@ -60,7 +53,7 @@ public class InlineSuperClassRefactoringDialog extends InlineOptionsDialog {
     if(myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
       settings.INLINE_SUPER_CLASS_THIS = isInlineThisOnly();
     }
-    invokeRefactoring(new InlineSuperClassRefactoringProcessor(getProject(), isInlineThisOnly() ? myCurrentInheritor : null, mySuperClass, myDocPanel.getPolicy(), myTargetClasses));
+    invokeRefactoring(new InlineSuperClassRefactoringProcessor(getProject(), isInlineThisOnly() ? myCurrentInheritor : null, mySuperClass, myDocPanel.getPolicy()));
   }
 
   @Override
@@ -74,30 +67,17 @@ public class InlineSuperClassRefactoringDialog extends InlineOptionsDialog {
     return "Inline_Super_Class";
   }
 
+  @NotNull
   protected JComponent createCenterPanel() {
-    final JLabel label = new JLabel("<html>Super class \'" +
-                                     mySuperClass.getQualifiedName() +
-                                     "\' inheritors: " +
-                                     (myTargetClasses.length > 1 ? " <br>&nbsp;&nbsp;&nbsp;\'" : "\'") +
-                                     StringUtil.join(myTargetClasses, new Function<PsiClass, String>() {
-                                       public String fun(final PsiClass psiClass) {
-                                         return psiClass.getQualifiedName();
-                                       }
-                                     }, "\',<br>&nbsp;&nbsp;&nbsp;\'") +
-                                     "\'</html>");
     final JPanel panel = new JPanel(new GridBagLayout());
     final GridBagConstraints gc =
       new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
                              new Insets(0, 0, 0, 0), 0, 0);
     panel.add(myDocPanel, gc);
-    JScrollPane pane = ScrollPaneFactory.createScrollPane(label);
-    pane.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
-    pane.setMinimumSize(JBDimension.create(new Dimension(-1, 100)));
-    pane.setMaximumSize(JBDimension.create(new Dimension(-1, 400)));
-    panel.add(pane, gc);
+    panel.add(super.createCenterPanel(), gc);
     gc.weighty = 1;
     gc.fill = GridBagConstraints.BOTH;
-    panel.add(super.createCenterPanel(), gc);
+    panel.add(Box.createVerticalGlue(), gc);
     return panel;
   }
 
index a42cd4c72c551003acd8a1e959c5ea28c3a53a39..cd89b1aab2b8680dc8717bea40018d6857a349a6 100644 (file)
@@ -24,9 +24,11 @@ import com.intellij.codeInsight.TargetElementUtil;
 import com.intellij.lang.StdLanguages;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiReference;
+import com.intellij.psi.PsiReferenceList;
 import com.intellij.psi.search.searches.DirectClassInheritorsSearch;
-import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.refactoring.inline.JavaInlineActionHandler;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 
@@ -49,23 +51,11 @@ public class InlineSuperClassRefactoringHandler extends JavaInlineActionHandler
 
   public void inlineElement(final Project project, final Editor editor, final PsiElement element) {
     PsiClass superClass = (PsiClass) element;
-    Collection<PsiClass> inheritors = DirectClassInheritorsSearch.search((PsiClass)element).findAll();
     if (!superClass.getManager().isInProject(superClass)) {
       CommonRefactoringUtil.showErrorHint(project, editor, "Cannot inline non-project class", REFACTORING_NAME, null);
       return;
     }
 
-    for (PsiClass inheritor : inheritors) {
-      if (PsiTreeUtil.isAncestor(superClass, inheritor, false)) {
-        CommonRefactoringUtil.showErrorHint(project, editor, "Cannot inline into the inner class. Move \'" + inheritor.getName() + "\' to upper level", REFACTORING_NAME, null);
-        return;
-      }
-      if (inheritor instanceof PsiAnonymousClass) {
-        CommonRefactoringUtil.showErrorHint(project, editor, "Cannot inline into anonymous class.", REFACTORING_NAME, null);
-        return;
-      }
-    }
-
     PsiClass chosen = null;
     PsiReference reference = editor != null ? TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset()) : null;
     if (reference != null) {
@@ -76,13 +66,13 @@ public class InlineSuperClassRefactoringHandler extends JavaInlineActionHandler
           final PsiElement parent = referenceElement.getParent();
           if (parent instanceof PsiReferenceList) {
             final PsiElement gParent = parent.getParent();
-            if (gParent instanceof PsiClass && inheritors.contains(gParent)) {
+            if (gParent instanceof PsiClass) {
               chosen = (PsiClass)gParent;
             }
           }
         }
       }
     }
-    new InlineSuperClassRefactoringDialog(project, superClass, chosen, inheritors.toArray(new PsiClass[inheritors.size()])).show();
+    new InlineSuperClassRefactoringDialog(project, superClass, chosen).show();
   }
 }
\ No newline at end of file
index ad9f122daca0bc1a1904960ba69287e2052877d1..c34ebd62233a6c141bcb0ea742f17d417f335fca 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
+import com.intellij.psi.search.searches.DirectClassInheritorsSearch;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiTypesUtil;
@@ -42,13 +43,16 @@ import com.intellij.refactoring.util.classMembers.MemberInfoStorage;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
 import com.intellij.util.ArrayUtilRt;
+import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.Processor;
+import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
 import com.intellij.util.containers.MultiMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -58,15 +62,14 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
   private final PsiClass myCurrentInheritor;
   private final PsiClass mySuperClass;
   private final int myPolicy;
-  private final PsiClass[] myTargetClasses;
+  private PsiClass[] myTargetClasses;
   private final MemberInfo[] myMemberInfos;
 
-  public InlineSuperClassRefactoringProcessor(Project project, PsiClass currentInheritor, PsiClass superClass, int policy, final PsiClass... targetClasses) {
+  public InlineSuperClassRefactoringProcessor(Project project, PsiClass currentInheritor, PsiClass superClass, int policy) {
     super(project);
     myCurrentInheritor = currentInheritor;
     mySuperClass = superClass;
     myPolicy = policy;
-    myTargetClasses = currentInheritor != null ? new PsiClass[] {currentInheritor} : targetClasses;
     MemberInfoStorage memberInfoStorage = new MemberInfoStorage(mySuperClass, new MemberInfo.Filter<PsiMember>() {
       public boolean includeMember(PsiMember element) {
         return !(element instanceof PsiClass) || PsiTreeUtil.isAncestor(mySuperClass, element, true);
@@ -90,71 +93,74 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
     final PsiElementFactory elementFactory = facade.getElementFactory();
     final PsiResolveHelper resolveHelper = facade.getResolveHelper();
 
-    ReferencesSearch.search(mySuperClass).forEach(new Processor<PsiReference>() {
-      public boolean process(final PsiReference reference) {
-        final PsiElement element = reference.getElement();
-        if (element instanceof PsiJavaCodeReferenceElement) {
-          if (myCurrentInheritor != null) {
-            final PsiElement parent = element.getParent();
-            if (parent instanceof PsiReferenceList) {
-              final PsiElement pparent = parent.getParent();
-              if (pparent instanceof PsiClass) {
-                final PsiClass inheritor = (PsiClass)pparent;
-                if (parent.equals(inheritor.getExtendsList()) || parent.equals(inheritor.getImplementsList())) {
-                  if (myCurrentInheritor.equals(inheritor)) {
-                    usages.add(new ReplaceExtendsListUsageInfo((PsiJavaCodeReferenceElement)element, mySuperClass, inheritor));
-                  }
-                }
+    if (myCurrentInheritor != null) {
+      myTargetClasses = new PsiClass[] {myCurrentInheritor};
+    }
+    else {
+      Collection<PsiClass> inheritors = DirectClassInheritorsSearch.search(mySuperClass).findAll();
+      myTargetClasses = inheritors.toArray(new PsiClass[inheritors.size()]);
+    }
+
+    if (myCurrentInheritor != null) {
+      findUsagesInExtendsList(usages, myCurrentInheritor.getExtendsList());
+      findUsagesInExtendsList(usages, myCurrentInheritor.getImplementsList());
+    }
+    else {
+      ReferencesSearch.search(mySuperClass).forEach(new Processor<PsiReference>() {
+        public boolean process(final PsiReference reference) {
+          final PsiElement element = reference.getElement();
+          if (element instanceof PsiJavaCodeReferenceElement) {
+            final PsiImportStaticStatement staticImportStatement = PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class);
+            if (staticImportStatement != null) {
+              usages.add(new ReplaceStaticImportUsageInfo(staticImportStatement, myTargetClasses));
+            } else {
+              final PsiImportStatement importStatement = PsiTreeUtil.getParentOfType(element, PsiImportStatement.class);
+              if (importStatement != null) {
+                usages.add(new RemoveImportUsageInfo(importStatement));
               }
-            }
-            return true;
-          }
-          final PsiImportStaticStatement staticImportStatement = PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class);
-          if (staticImportStatement != null) {
-            usages.add(new ReplaceStaticImportUsageInfo(staticImportStatement, myTargetClasses));
-          } else {
-            final PsiImportStatement importStatement = PsiTreeUtil.getParentOfType(element, PsiImportStatement.class);
-            if (importStatement != null) {
-              usages.add(new RemoveImportUsageInfo(importStatement));
-            }
-            else {
-              final PsiElement parent = element.getParent();
-              if (parent instanceof PsiReferenceList) {
-                final PsiElement pparent = parent.getParent();
-                if (pparent instanceof PsiClass) {
-                  final PsiClass inheritor = (PsiClass)pparent;
-                  if (parent.equals(inheritor.getExtendsList()) || parent.equals(inheritor.getImplementsList())) {
-                    usages.add(new ReplaceExtendsListUsageInfo((PsiJavaCodeReferenceElement)element, mySuperClass, inheritor));
+              else {
+                final PsiElement parent = element.getParent();
+                if (parent instanceof PsiReferenceList) {
+                  final PsiElement pparent = parent.getParent();
+                  if (pparent instanceof PsiClass) {
+                    final PsiClass inheritor = (PsiClass)pparent;
+                    if (parent.equals(inheritor.getExtendsList()) || parent.equals(inheritor.getImplementsList())) {
+                      usages.add(new ReplaceExtendsListUsageInfo((PsiJavaCodeReferenceElement)element, mySuperClass, inheritor));
+                    }
+                  }
+                } else {
+                  final PsiClass targetClass = myTargetClasses[0];
+                  final PsiClassType targetClassType = elementFactory
+                    .createType(targetClass, TypeConversionUtil.getSuperClassSubstitutor(mySuperClass, targetClass, PsiSubstitutor.EMPTY));
+
+                  if (parent instanceof PsiTypeElement) {
+                    final PsiType superClassType = ((PsiTypeElement)parent).getType();
+                    PsiSubstitutor subst = getSuperClassSubstitutor(superClassType, targetClassType, resolveHelper, targetClass);
+                    usages.add(new ReplaceWithSubtypeUsageInfo(((PsiTypeElement)parent), elementFactory.createType(targetClass, subst), myTargetClasses));
+                  }
+                  else if (parent instanceof PsiNewExpression) {
+                    final PsiClassType newType = elementFactory.createType(targetClass,
+                                                                           getSuperClassSubstitutor(((PsiNewExpression)parent).getType(),
+                                                                                                    targetClassType, resolveHelper,
+                                                                                                    targetClass));
+                    usages.add(new ReplaceConstructorUsageInfo(((PsiNewExpression)parent), newType, myTargetClasses));
+                  }
+                  else if (parent instanceof PsiJavaCodeReferenceElement) {
+                    usages.add(new ReplaceReferenceUsageInfo(((PsiJavaCodeReferenceElement)parent).getQualifier(), myTargetClasses));
                   }
-                }
-              } else {
-                final PsiClass targetClass = myTargetClasses[0];
-                final PsiClassType targetClassType = elementFactory
-                  .createType(targetClass, TypeConversionUtil.getSuperClassSubstitutor(mySuperClass, targetClass, PsiSubstitutor.EMPTY));
-
-                if (parent instanceof PsiTypeElement) {
-                  final PsiType superClassType = ((PsiTypeElement)parent).getType();
-                  PsiSubstitutor subst = getSuperClassSubstitutor(superClassType, targetClassType, resolveHelper, targetClass);
-                  usages.add(new ReplaceWithSubtypeUsageInfo(((PsiTypeElement)parent), elementFactory.createType(targetClass, subst), myTargetClasses));
-                }
-                else if (parent instanceof PsiNewExpression) {
-                  final PsiClassType newType = elementFactory.createType(targetClass,
-                                                                         getSuperClassSubstitutor(((PsiNewExpression)parent).getType(),
-                                                                                                  targetClassType, resolveHelper,
-                                                                                                  targetClass));
-                  usages.add(new ReplaceConstructorUsageInfo(((PsiNewExpression)parent), newType, myTargetClasses));
-                }
-                else if (parent instanceof PsiJavaCodeReferenceElement) {
-                  usages.add(new ReplaceReferenceUsageInfo(((PsiJavaCodeReferenceElement)parent).getQualifier(), myTargetClasses));
                 }
               }
             }
           }
+          return true;
         }
-        return true;
-      }
-    });
+      });
+    }
     for (PsiClass targetClass : myTargetClasses) {
+      if (skipTargetClass(targetClass)) {
+        continue;
+      }
+
       for (MemberInfo memberInfo : myMemberInfos) {
         final PsiMember member = memberInfo.getMember();
         for (PsiReference reference : ReferencesSearch.search(member, member.getUseScope(), true)) {
@@ -167,44 +173,58 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
         }
       }
 
-      final PsiMethod[] superConstructors = mySuperClass.getConstructors();
-      for (PsiMethod constructor : targetClass.getConstructors()) {
-        final PsiCodeBlock constrBody = constructor.getBody();
-        LOG.assertTrue(constrBody != null);
-        final PsiStatement[] statements = constrBody.getStatements();
-        if (statements.length > 0) {
-          final PsiStatement firstConstrStatement = statements[0];
-          if (firstConstrStatement instanceof PsiExpressionStatement) {
-            final PsiExpression expression = ((PsiExpressionStatement)firstConstrStatement).getExpression();
-            if (expression instanceof PsiMethodCallExpression) {
-              final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)expression).getMethodExpression();
-              if (methodExpression.getText().equals(PsiKeyword.SUPER)) {
-                final PsiMethod superConstructor = ((PsiMethodCallExpression)expression).resolveMethod();
-                if (superConstructor != null && superConstructor.getBody() != null) {
-                  usages.add(new InlineSuperCallUsageInfo((PsiMethodCallExpression)expression));
-                  continue;
+      if (!mySuperClass.isInterface()) {
+        final PsiMethod[] superConstructors = mySuperClass.getConstructors();
+        for (PsiMethod constructor : targetClass.getConstructors()) {
+          final PsiCodeBlock constrBody = constructor.getBody();
+          if (constrBody != null) {
+            final PsiStatement[] statements = constrBody.getStatements();
+            if (statements.length > 0) {
+              final PsiStatement firstConstrStatement = statements[0];
+              if (firstConstrStatement instanceof PsiExpressionStatement) {
+                final PsiExpression expression = ((PsiExpressionStatement)firstConstrStatement).getExpression();
+                if (expression instanceof PsiMethodCallExpression) {
+                  final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)expression).getMethodExpression();
+                  if (methodExpression.getText().equals(PsiKeyword.SUPER)) {
+                    final PsiMethod superConstructor = ((PsiMethodCallExpression)expression).resolveMethod();
+                    if (superConstructor != null && superConstructor.getBody() != null) {
+                      usages.add(new InlineSuperCallUsageInfo((PsiMethodCallExpression)expression));
+                      continue;
+                    }
+                  }
                 }
               }
             }
           }
+
+          //insert implicit call to super
+          for (PsiMethod superConstructor : superConstructors) {
+            if (superConstructor.getParameterList().getParametersCount() == 0) {
+              final PsiExpression expression = JavaPsiFacade.getElementFactory(myProject).createExpressionFromText("super()", constructor);
+              usages.add(new InlineSuperCallUsageInfo((PsiMethodCallExpression)expression, constrBody));
+            }
+          }
         }
 
-        //insert implicit call to super
-        for (PsiMethod superConstructor : superConstructors) {
-          if (superConstructor.getParameterList().getParametersCount() == 0) {
-            final PsiExpression expression = JavaPsiFacade.getElementFactory(myProject).createExpressionFromText("super()", constructor);
-            usages.add(new InlineSuperCallUsageInfo((PsiMethodCallExpression)expression, constrBody));
+        if (targetClass.getConstructors().length == 0) {
+          //copy default constructor
+          for (PsiMethod superConstructor : superConstructors) {
+            if (superConstructor.getParameterList().getParametersCount() == 0) {
+              usages.add(new CopyDefaultConstructorUsageInfo(targetClass, superConstructor));
+              break;
+            }
           }
         }
       }
+    }
+  }
 
-      if (targetClass.getConstructors().length == 0) {
-        //copy default constructor
-        for (PsiMethod superConstructor : superConstructors) {
-          if (superConstructor.getParameterList().getParametersCount() == 0) {
-            usages.add(new CopyDefaultConstructorUsageInfo(targetClass, superConstructor));
-            break;
-          }
+  private void findUsagesInExtendsList(@NotNull List<FixableUsageInfo> usages, PsiReferenceList extendsList) {
+    final PsiJavaCodeReferenceElement[] referenceExtendsElements = extendsList != null ? extendsList.getReferenceElements() : null;
+    if (referenceExtendsElements != null) {
+      for (PsiJavaCodeReferenceElement element : referenceExtendsElements) {
+        if (mySuperClass.equals(element.resolve())) {
+          usages.add(new ReplaceExtendsListUsageInfo(element, mySuperClass, myCurrentInheritor));
         }
       }
     }
@@ -215,11 +235,19 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
     final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
     final PushDownConflicts pushDownConflicts = new PushDownConflicts(mySuperClass, myMemberInfos, conflicts);
     for (PsiClass targetClass : myTargetClasses) {
-      for (MemberInfo info : myMemberInfos) {
-        final PsiMember member = info.getMember();
-        pushDownConflicts.checkMemberPlacementInTargetClassConflict(targetClass, member);
+      if (targetClass instanceof PsiAnonymousClass) {
+        conflicts.putValue(targetClass, "Cannot inline into anonymous class.");
       }
+      else if (PsiTreeUtil.isAncestor(mySuperClass, targetClass, false)) {
+        conflicts.putValue(targetClass, "Cannot inline into the inner class. Move \'" + targetClass.getName() + "\' to upper level");
+      }
+      else {
+        for (MemberInfo info : myMemberInfos) {
+          final PsiMember member = info.getMember();
+          pushDownConflicts.checkMemberPlacementInTargetClassConflict(targetClass, member);
+        }
         //todo check accessibility conflicts
+      }
     }
     if (myCurrentInheritor != null) {
       ReferencesSearch.search(myCurrentInheritor).forEach(new Processor<PsiReference>() {
@@ -244,9 +272,14 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
     return showConflicts(conflicts, refUsages.get());
   }
 
+  private boolean skipTargetClass(PsiClass targetClass) {
+    return targetClass instanceof PsiAnonymousClass || 
+           PsiTreeUtil.isAncestor(mySuperClass, targetClass, false);
+  }
+
   @Nullable
   private static PsiType getPlaceExpectedType(PsiElement parent) {
-    PsiType type = PsiTypesUtil.getExpectedTypeByParent((PsiExpression)parent);
+    PsiType type = PsiTypesUtil.getExpectedTypeByParent(parent);
     if (type == null) {
       final PsiElement arg = PsiUtil.skipParenthesizedExprUp(parent);
       final PsiElement gParent = arg.getParent();
@@ -272,50 +305,44 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
   }
 
   protected void performRefactoring(@NotNull final UsageInfo[] usages) {
-    final DocCommentPolicy docPolicy = new DocCommentPolicy(myPolicy);
-    new PushDownProcessor(mySuperClass, myMemberInfos, docPolicy) {
-      //push down conflicts are already collected
-      @Override
-      protected boolean showConflicts(@NotNull MultiMap<PsiElement, String> conflicts, UsageInfo[] usages) {
-        return true;
-      }
-
-      @Override
-      protected void performRefactoring(@NotNull UsageInfo[] pushDownUsages) {
-        if (myCurrentInheritor != null) {
-          pushDownToDedicatedClass(myCurrentInheritor);
-        } else {
-          super.performRefactoring(pushDownUsages);
-        }
-        CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
-        for (UsageInfo usageInfo : usages) {
-          if (!(usageInfo instanceof ReplaceExtendsListUsageInfo || usageInfo instanceof RemoveImportUsageInfo)) {
-            try {
-              ((FixableUsageInfo)usageInfo).fixUsage();
-            }
-            catch (IncorrectOperationException e) {
-              LOG.info(e);
-            }
-          }
+    try {
+      final UsageInfo[] infos = ContainerUtil.map2Array(myTargetClasses, UsageInfo.class, new Function<PsiClass, UsageInfo>() {
+        @Override
+        public UsageInfo fun(PsiClass psiClass) {
+          return new UsageInfo(psiClass);
         }
-        replaceInnerTypeUsages();
+      });
+      new PushDownProcessor(mySuperClass, myMemberInfos, new DocCommentPolicy(myPolicy)).pushDownToClasses(infos);
 
-        //postpone broken hierarchy
-        for (UsageInfo usage : usages) {
-          if (usage instanceof ReplaceExtendsListUsageInfo || usage instanceof RemoveImportUsageInfo) {
-            ((FixableUsageInfo)usage).fixUsage();
-          }
-        }
-        if (myCurrentInheritor == null) {
+      CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
+      for (UsageInfo usageInfo : usages) {
+        if (!(usageInfo instanceof ReplaceExtendsListUsageInfo || usageInfo instanceof RemoveImportUsageInfo)) {
           try {
-            mySuperClass.delete();
+            ((FixableUsageInfo)usageInfo).fixUsage();
           }
           catch (IncorrectOperationException e) {
-            LOG.error(e);
+            LOG.info(e);
           }
         }
       }
-    }.run();
+
+      replaceInnerTypeUsages();
+
+      //postpone broken hierarchy
+      for (UsageInfo usage : usages) {
+        if (usage instanceof ReplaceExtendsListUsageInfo || usage instanceof RemoveImportUsageInfo) {
+          ((FixableUsageInfo)usage).fixUsage();
+        }
+      }
+
+      //delete the class if all refs replaced
+      if (myCurrentInheritor == null) {
+        mySuperClass.delete();
+      }
+    }
+    catch (IncorrectOperationException e) {
+      LOG.error(e);
+    }
   }
 
   @Nullable
@@ -347,6 +374,7 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
     final PsiResolveHelper resolveHelper = facade.getResolveHelper();
     final Map<UsageInfo, PsiElement> replacementMap = new HashMap<UsageInfo, PsiElement>();
     for (final PsiClass targetClass : myTargetClasses) {
+      if (skipTargetClass(targetClass)) continue;
       final PsiSubstitutor superClassSubstitutor =
         TypeConversionUtil.getSuperClassSubstitutor(mySuperClass, targetClass, PsiSubstitutor.EMPTY);
       final PsiClassType targetClassType = elementFactory.createType(targetClass, superClassSubstitutor);
@@ -355,7 +383,7 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
         public void visitTypeElement(final PsiTypeElement typeElement) {
           super.visitTypeElement(typeElement);
           final PsiType superClassType = typeElement.getType();
-          if (PsiUtil.resolveClassInType(superClassType) == mySuperClass) {
+          if (PsiUtil.resolveClassInClassTypeOnly(superClassType) == mySuperClass) {
             PsiSubstitutor subst = getSuperClassSubstitutor(superClassType, targetClassType, resolveHelper, targetClass);
             replacementMap.put(new UsageInfo(typeElement), elementFactory.createTypeElement(elementFactory.createType(targetClass, subst)));
           }
@@ -368,8 +396,11 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
           if (PsiUtil.resolveClassInType(superClassType) == mySuperClass) {
             PsiSubstitutor subst = getSuperClassSubstitutor(superClassType, targetClassType, resolveHelper, targetClass);
             try {
-              replacementMap.put(new UsageInfo(expression), elementFactory.createExpressionFromText("new " + elementFactory.createType(
-                targetClass, subst).getCanonicalText() + expression.getArgumentList().getText(), expression));
+              final String typeCanonicalText = elementFactory.createType(targetClass, subst).getCanonicalText();
+              final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
+              if (classReference != null) {
+                replacementMap.put(new UsageInfo(classReference), elementFactory.createReferenceFromText(typeCanonicalText, expression));
+              }
             }
             catch (IncorrectOperationException e) {
               LOG.error(e);
index ada7a7222c79b7922f845cebeaa06fe178e22f61..96e8909051e06305fec77a6d9759686181cad748 100644 (file)
@@ -38,8 +38,10 @@ public class ReplaceConstructorUsageInfo extends FixableUsageInfo{
     final PsiMethod[] constructors = targetClasses[0].getConstructors();
     final PsiMethod constructor = element.resolveConstructor();
     if (constructor == null) {
-      if (constructors.length == 1 && constructors[0].getParameterList().getParametersCount() > 0 || constructors.length > 1) {
-        myConflict = CONSTRUCTOR_MATCHING_SUPER_NOT_FOUND;
+      if (element.getArgumentList() != null) {
+        if (constructors.length == 1 && constructors[0].getParameterList().getParametersCount() > 0 || constructors.length > 1) {
+          myConflict = CONSTRUCTOR_MATCHING_SUPER_NOT_FOUND;
+        }
       }
     } else {
       final PsiParameter[] superParameters = constructor.getParameterList().getParameters();
index 695c8366f498d5e5c1f11d00319cc7decf5d5c2b..bfce10125b1f5125b4c78f378273e02ab14ec76d 100644 (file)
@@ -182,7 +182,7 @@ public class JavaInvertBooleanDelegate extends InvertBooleanDelegate {
 
   @Override
   public void invertElementInitializer(final PsiElement element) {
-    if (element instanceof PsiField && ((PsiField)element).getInitializer() == null) {
+    if (element instanceof PsiField && ((PsiField)element).getInitializer() == null && !((PsiField)element).hasModifierProperty(PsiModifier.FINAL)) {
       ((PsiField)element).setInitializer(JavaPsiFacade.getElementFactory(element.getProject()).createExpressionFromText("true", element));
     } else if (element instanceof PsiVariable) {
       final PsiExpression initializer = ((PsiVariable)element).getInitializer();
index b7bd9384442aadb3217e4d1d3165acd734fccb4f..1dcf6ba48d2db8fdaaf1ea0998842b3398f1e709 100644 (file)
@@ -256,6 +256,27 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
     return null;
   }
 
+  @Override
+  public Collection<String> findConflicts(PsiElement element, PsiElement[] elements, UsageInfo[] usages) {
+    String methodRefFound = null;
+    if (!ApplicationManager.getApplication().isUnitTestMode() && (element instanceof PsiMethod || element instanceof PsiParameter)) {
+      for (UsageInfo usage : usages) {
+        final PsiElement refElement = usage.getElement();
+        if (refElement instanceof PsiMethodReferenceExpression) {
+          methodRefFound = RefactoringBundle.message("expand.method.reference.warning");
+          break;
+        }
+      }
+    }
+    if (methodRefFound != null) {
+      Collection<String> result = new ArrayList<>();
+      result.add(methodRefFound);
+      result.addAll(super.findConflicts(element, elements, usages));
+      return result;
+    }
+    return super.findConflicts(element, elements, usages);
+  }
+
   public Collection<String> findConflicts(@NotNull final PsiElement element, @NotNull final PsiElement[] allElementsToDelete) {
     if (element instanceof PsiMethod) {
       final PsiClass containingClass = ((PsiMethod)element).getContainingClass();
index e6b846f3364401c7cf6498470a7de0b3d3fdfad2..3aa98a200e69740f5e37c0f5efc27f8e76a28356 100644 (file)
@@ -17,6 +17,8 @@ package com.intellij.psi;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.RecursionGuard;
+import com.intellij.openapi.util.RecursionManager;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.infos.MethodCandidateInfo;
@@ -35,6 +37,7 @@ import java.util.*;
  * Date: 7/17/12
  */
 public class LambdaUtil {
+  public static final RecursionGuard ourParameterGuard = RecursionManager.createGuard("lambdaParameterGuard");
   public static ThreadLocal<Map<PsiElement, PsiType>> ourFunctionTypes = new ThreadLocal<Map<PsiElement, PsiType>>();
   private static final Logger LOG = Logger.getInstance("#" + LambdaUtil.class.getName());
 
@@ -667,6 +670,10 @@ public class LambdaUtil {
     return null;
   }
 
+  public static boolean isLambdaParameterCheck() {
+    return !ourParameterGuard.currentStack().isEmpty();
+  }
+
   public static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
     private PsiMethod myMethod;
     private final PsiClass myClass;
index eb5a29993e4e8f86c44641f0d3ca1f8338935788..195a064cce28ef2f1eee24508d6659d638e0c41d 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi;
 
+import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.util.*;
@@ -122,7 +123,7 @@ public class PsiMethodReferenceUtil {
         }
       }
       else if (resolve instanceof PsiClass) {
-        if (resolve == JavaPsiFacade.getElementFactory(expression.getProject()).getArrayClass(PsiUtil.getLanguageLevel(resolve))) {
+        if (PsiEquivalenceUtil.areElementsEquivalent(resolve, JavaPsiFacade.getElementFactory(expression.getProject()).getArrayClass(PsiUtil.getLanguageLevel(expression)))) {
           final PsiTypeParameter[] typeParameters = ((PsiClass)resolve).getTypeParameters();
           if (typeParameters.length == 1) {
             final PsiType arrayComponentType = subst.substitute(typeParameters[0]);
index 5a896d6d12459112796cf6bdf78bba46e0205b5e..2d1ef7b4f8cd636ade7b6b38be687a99f0588e66 100644 (file)
@@ -294,7 +294,9 @@ public class MethodCandidateInfo extends CandidateInfo{
          if (!stackStamp.mayCacheNow() ||
              isOverloadCheck() ||
              !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ||
-             getMarkerList() != null && PsiResolveHelper.ourGraphGuard.currentStack().contains(getMarkerList().getParent())) {
+             getMarkerList() != null && PsiResolveHelper.ourGraphGuard.currentStack().contains(getMarkerList().getParent()) ||
+             LambdaUtil.isLambdaParameterCheck()
+           ) {
           return inferredSubstitutor;
         }
 
index 470b48033987d5e824178c92efcfe8d7568be37d..346465171177849f2a1e31698e8ca17ffe3044e1 100644 (file)
@@ -435,7 +435,7 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
       public PsiType[] getArgumentTypes() {
         if (myExpressionTypes == null) {
           final PsiType[] expressionTypes = argumentList.getExpressionTypes();
-          if (MethodCandidateInfo.isOverloadCheck()) {
+          if (MethodCandidateInfo.isOverloadCheck() || LambdaUtil.isLambdaParameterCheck()) {
             return expressionTypes;
           }
           myExpressionTypes = expressionTypes;
index 58169e20f1935d651f33ea2409e1eba86a15f966..cbcc13b8cba4c166f311e280c26c4b7a59ce107c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.lang.java.parser.JavaParser;
 import com.intellij.lang.java.parser.JavaParserUtil;
 import com.intellij.lexer.Lexer;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.NotNullLazyValue;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
@@ -48,10 +49,23 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentMap;
 
 public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements PsiElementFactory {
-  private PsiClass myArrayClass;
-  private PsiClass myArrayClass15;
-  private final ConcurrentMap<GlobalSearchScope, PsiClassType> myCachedObjectType =
-    ContainerUtil.newConcurrentMap();
+  private final NotNullLazyValue<PsiClass> myArrayClass = new NotNullLazyValue<PsiClass>() {
+    @NotNull
+    @Override
+    protected PsiClass compute() {
+      return createArrayClass("public class __Array__{\n public final int length;\n public Object clone() {}\n}", LanguageLevel.JDK_1_3);
+    }
+  };
+
+  private final NotNullLazyValue<PsiClass> myArrayClass15 = new NotNullLazyValue<PsiClass>() {
+    @NotNull
+    @Override
+    protected PsiClass compute() {
+      return createArrayClass("public class __Array__<T> {\n public final int length;\n public T[] clone() {}\n}", LanguageLevel.JDK_1_5);
+    }
+  };
+
+  private final ConcurrentMap<GlobalSearchScope, PsiClassType> myCachedObjectType = ContainerUtil.newConcurrentMap();
 
   public PsiElementFactoryImpl(final PsiManagerEx manager) {
     super(manager);
@@ -65,23 +79,17 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
 
   @NotNull
   @Override
-  public PsiClass getArrayClass(@NotNull final LanguageLevel languageLevel) {
-    if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) {
-      if (myArrayClass == null) {
-        @NonNls final String body = "public class __Array__{\n public final int length;\n public Object clone() {}\n}";
-        myArrayClass = ((PsiExtensibleClass)createClassFromText(body, null)).getOwnInnerClasses().get(0);
-        ensureNonWritable(myArrayClass);
-      }
-      return myArrayClass;
-    }
-    else {
-      if (myArrayClass15 == null) {
-        @NonNls final String body = "public class __Array__<T>{\n public final int length;\n public T[] clone() {}\n}";
-        myArrayClass15 = ((PsiExtensibleClass)createClassFromText(body, null)).getOwnInnerClasses().get(0);
-        ensureNonWritable(myArrayClass15);
-      }
-      return myArrayClass15;
-    }
+  public PsiClass getArrayClass(@NotNull LanguageLevel languageLevel) {
+    return (languageLevel.isAtLeast(LanguageLevel.JDK_1_5) ? myArrayClass15 : myArrayClass).getValue();
+  }
+
+  private PsiClass createArrayClass(String text, LanguageLevel level) {
+    PsiClass psiClass = ((PsiExtensibleClass)createClassFromText(text, null)).getOwnInnerClasses().get(0);
+    ensureNonWritable(psiClass);
+    PsiFile file = psiClass.getContainingFile();
+    ((PsiJavaFileBaseImpl)file).clearCaches();
+    PsiUtil.FILE_LANGUAGE_LEVEL_KEY.set(file, level);
+    return psiClass;
   }
 
   private static void ensureNonWritable(PsiClass arrayClass) {
@@ -438,6 +446,9 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
     else {
       text = aClass.getName();
     }
+    if (text == null) {
+      throw new IncorrectOperationException("Invalid class: " + aClass);
+    }
     return new LightClassReference(myManager, text, aClass);
   }
 
@@ -815,4 +826,4 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
   private boolean isIdentifier(@NotNull String name) {
     return PsiNameHelper.getInstance(myManager.getProject()).isIdentifier(name);
   }
-}
+}
\ No newline at end of file
index 5a151e6c0895362de3e6e6daa808aae0491520e3..b8d2babbd836fb9b097deb172ec056bb8e3a4dc2 100644 (file)
@@ -63,6 +63,7 @@ import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.reference.SoftReference;
 import com.intellij.util.ArrayUtil;
+import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.cls.ClsFormatException;
 import org.jetbrains.annotations.NonNls;
@@ -582,6 +583,18 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
 
   @Nullable
   public static PsiJavaFileStub buildFileStub(@NotNull VirtualFile file, @NotNull byte[] bytes) throws ClsFormatException {
+    return buildFileStub(file, bytes, new Function<String, PsiJavaFileStub>() {
+      @Override
+      public PsiJavaFileStub fun(String packageName) {
+        return new PsiJavaFileStubImpl(packageName, true);
+      }
+    });
+  }
+
+  @Nullable
+  public static PsiJavaFileStub buildFileStub(@NotNull VirtualFile file,
+                                              @NotNull byte[] bytes,
+                                              @NotNull Function<String, PsiJavaFileStub> stubBuilder) throws ClsFormatException {
     try {
       if (ClassFileViewProvider.isInnerClass(file, bytes)) {
         return null;
@@ -590,7 +603,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
       ClassReader reader = new ClassReader(bytes);
       String className = file.getNameWithoutExtension();
       String packageName = getPackageName(reader.getClassName());
-      PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl(packageName, true);
+      PsiJavaFileStub stub = stubBuilder.fun(packageName);
 
       try {
         StubBuildingVisitor<VirtualFile> visitor = new StubBuildingVisitor<VirtualFile>(file, STRATEGY, stub, 0, className);
index 56de53194ae37dacb405a64093d3362d3f1078ab..112b75a7bf120d66f0fde33c8a3e71772db2d991 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.
@@ -23,6 +23,8 @@ import com.intellij.psi.*;
 import com.intellij.psi.impl.compiled.*;
 
 public class ClsStubPsiFactory extends StubPsiFactory {
+  public static final ClsStubPsiFactory INSTANCE = new ClsStubPsiFactory();
+
   @Override
   public PsiClass createClass(PsiClassStub stub) {
     return new ClsClassImpl(stub);
@@ -97,4 +99,4 @@ public class ClsStubPsiFactory extends StubPsiFactory {
   public PsiNameValuePair createNameValuePair(PsiNameValuePairStub stub) {
     return null; // todo
   }
-}
+}
\ No newline at end of file
index d4788c7248a70b1c45281461b98bdf9cd964a157..d1b8242dd53708de6e663390683fb76fd3c0c907 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.
@@ -26,5 +26,8 @@ public interface PsiJavaFileStub extends PsiClassHolderFileStub<PsiJavaFile> {
   String getPackageName();
   boolean isCompiled();
   StubPsiFactory getPsiFactory();
+
+  /** @deprecated override {@link #getPsiFactory()} instead (to be removed in IDEA 17) */
+  @SuppressWarnings("unused")
   void setPsiFactory(StubPsiFactory factory);
-}
+}
\ No newline at end of file
index fb19641e438b0104d94c35615208a0591ac3e43d..945f1360a5d5e289c7491d3124443fd52b2b2a39 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.
@@ -24,6 +24,8 @@ import com.intellij.psi.impl.source.*;
 import com.intellij.psi.impl.source.tree.java.*;
 
 public class SourceStubPsiFactory extends StubPsiFactory {
+  public static final SourceStubPsiFactory INSTANCE = new SourceStubPsiFactory();
+
   @Override
   public PsiClass createClass(PsiClassStub stub) {
     if (stub.isEnumConstantInitializer()) {
@@ -109,4 +111,4 @@ public class SourceStubPsiFactory extends StubPsiFactory {
   public PsiNameValuePair createNameValuePair(PsiNameValuePairStub stub) {
     return new PsiNameValuePairImpl(stub);
   }
-}
+}
\ No newline at end of file
index f3973031c18fd38ba175f9e7cef06d6ae987eb46..e7c83d772607523f3d25f418c79bfc031c7f3262 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.
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiJavaFile;
 import com.intellij.psi.impl.java.stubs.*;
 import com.intellij.psi.stubs.PsiFileStubImpl;
 import com.intellij.psi.tree.IStubFileElementType;
-import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.io.StringRef;
 
 /**
@@ -35,7 +34,7 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
     super(file);
     myPackageName = packageName;
     myCompiled = compiled;
-    myFactory = compiled ? new ClsStubPsiFactory() : new SourceStubPsiFactory();
+    myFactory = compiled ? ClsStubPsiFactory.INSTANCE : SourceStubPsiFactory.INSTANCE;
   }
 
   public PsiJavaFileStubImpl(String packageName, boolean compiled) {
@@ -72,14 +71,8 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
     myFactory = factory;
   }
 
-  /** @deprecated use constructors (to be removed in IDEA 16) */
-  @SuppressWarnings("unused")
-  public void setPackageName(String packageName) {
-    throw new IncorrectOperationException();
-  }
-
   @Override
   public String toString() {
     return "PsiJavaFileStub [" + myPackageName + "]";
   }
-}
+}
\ No newline at end of file
index 08018fa46594453961f84b699890177348c39801..ee6c93bb41e05e73a2e3d44b22b9c65cb8239a76 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
 import com.intellij.navigation.ItemPresentation;
 import com.intellij.navigation.ItemPresentationProviders;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Computable;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.CheckUtil;
 import com.intellij.psi.impl.ElementPresentationUtil;
@@ -67,8 +68,14 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
       if (parameterIndex > -1) {
         final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class);
         if (lambdaExpression != null) {
-
-          PsiType type = FunctionalInterfaceParameterizationUtil.getGroundTargetType(LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true), lambdaExpression);
+          final PsiType functionalInterfaceType = LambdaUtil.ourParameterGuard.doPreventingRecursion(param, false,
+                                                                                                     new Computable<PsiType>() {
+                                                                                                         @Override
+                                                                                                         public PsiType compute() {
+                                                                                                           return LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true);
+                                                                                                         }
+                                                                                                       });
+          PsiType type = FunctionalInterfaceParameterizationUtil.getGroundTargetType(functionalInterfaceType, lambdaExpression);
           if (type instanceof PsiIntersectionType) {
             final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
             for (PsiType conjunct : conjuncts) {
index 003b8e9a96b2ea10e2aa83ff0000ff9104d81fa5..e521f36e145dc88ff8e5c8eca642d4be78454ec3 100644 (file)
@@ -90,7 +90,7 @@ public class JavaResolveCache {
       }
 
       //cache standalone expression types as they do not depend on the context
-      final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck();
+      final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck()  || LambdaUtil.isLambdaParameterCheck();
       if (isOverloadCheck && PsiPolyExpressionUtil.isPolyExpression(expr)) {
         return type;
       }
index da0367913aa190247ce723bbaab488c8d225ff7a..b19f433b1c0f65e75834e371593fe1483e8055fc 100644 (file)
@@ -361,11 +361,13 @@ public class InferenceSession {
 
       if (parameters != null && args != null && !isOverloadCheck()) {
         final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
+        final HashSet<ConstraintFormula> ignoredConstraints = new HashSet<ConstraintFormula>();
         if (parameters.length > 0) {
-          collectAdditionalConstraints(parameters, args, properties.getMethod(), mySiteSubstitutor, additionalConstraints, properties.isVarargs(), initialSubstitutor);
+          collectAdditionalConstraints(parameters, args, properties.getMethod(), mySiteSubstitutor, additionalConstraints,
+                                       ignoredConstraints, properties.isVarargs(), initialSubstitutor);
         }
 
-        if (!additionalConstraints.isEmpty() && !proceedWithAdditionalConstraints(additionalConstraints)) {
+        if (!additionalConstraints.isEmpty() && !proceedWithAdditionalConstraints(additionalConstraints, ignoredConstraints)) {
           return;
         }
       }
@@ -416,21 +418,29 @@ public class InferenceSession {
                                             PsiMethod parentMethod,
                                             PsiSubstitutor siteSubstitutor,
                                             Set<ConstraintFormula> additionalConstraints,
+                                            Set<ConstraintFormula> ignoredConstraints,
                                             boolean varargs,
                                             PsiSubstitutor initialSubstitutor) {
     for (int i = 0; i < args.length; i++) {
       final PsiExpression arg = PsiUtil.skipParenthesizedExprDown(args[i]);
       if (arg != null) {
-        if (MethodCandidateInfo.isOverloadCheck() && arg instanceof PsiLambdaExpression) {
-          for (Object expr : MethodCandidateInfo.ourOverloadGuard.currentStack()) {
-            if (PsiTreeUtil.getParentOfType((PsiElement)expr, PsiLambdaExpression.class) == arg) {
-              return;
-            }
-          }
-        }
         final PsiSubstitutor nestedSubstitutor = myInferenceSessionContainer.findNestedSubstitutor(arg, myInferenceSubstitution);
         final PsiType parameterType = nestedSubstitutor.substitute(getParameterType(parameters, i, siteSubstitutor, varargs));
         if (!isPertinentToApplicability(arg, parentMethod)) {
+          if (arg instanceof PsiLambdaExpression) {
+            for (Object expr : MethodCandidateInfo.ourOverloadGuard.currentStack()) {
+              if (PsiTreeUtil.getParentOfType((PsiElement)expr, PsiLambdaExpression.class) == arg) {
+                return;
+              }
+            }
+
+            for (Object expr : LambdaUtil.ourParameterGuard.currentStack()) {
+              if (expr instanceof PsiParameter && ((PsiParameter)expr).getDeclarationScope() == arg) {
+                ignoredConstraints.add(new ExpressionCompatibilityConstraint(arg, parameterType));
+                return;
+              }
+            }
+          }
           additionalConstraints.add(new ExpressionCompatibilityConstraint(arg, parameterType));
         }
         additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(arg, parameterType));
@@ -439,12 +449,12 @@ public class InferenceSession {
           //the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
           final PsiMethod calledMethod = getCalledMethod((PsiCall)arg);
           if (calledMethod != null && PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
-            collectAdditionalConstraints(additionalConstraints, (PsiCall)arg, initialSubstitutor);
+            collectAdditionalConstraints(additionalConstraints, ignoredConstraints, (PsiCall)arg, initialSubstitutor);
           }
         }
         else if (arg instanceof PsiLambdaExpression &&
                  isPertinentToApplicability(arg, parentMethod)) {
-          collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)arg, parameterType,
+          collectLambdaReturnExpression(additionalConstraints, ignoredConstraints, (PsiLambdaExpression)arg, parameterType,
                                         !isProperType(initialSubstitutor.substitute(parameterType)),
                                         initialSubstitutor);
         }
@@ -472,19 +482,22 @@ public class InferenceSession {
   }
 
   private void collectLambdaReturnExpression(Set<ConstraintFormula> additionalConstraints,
+                                             Set<ConstraintFormula> ignoredConstraints, 
                                              PsiLambdaExpression lambdaExpression,
                                              PsiType parameterType,
-                                             boolean addConstraint, PsiSubstitutor initialSubstitutor) {
+                                             boolean addConstraint,
+                                             PsiSubstitutor initialSubstitutor) {
     final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(parameterType);
     if (interfaceReturnType != null) {
       final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions(lambdaExpression);
       for (PsiExpression returnExpression : returnExpressions) {
-        processReturnExpression(additionalConstraints, returnExpression, interfaceReturnType, addConstraint, initialSubstitutor);
+        processReturnExpression(additionalConstraints, ignoredConstraints, returnExpression, interfaceReturnType, addConstraint, initialSubstitutor);
       }
     }
   }
 
   private void processReturnExpression(Set<ConstraintFormula> additionalConstraints,
+                                       Set<ConstraintFormula> ignoredConstraints,
                                        PsiExpression returnExpression,
                                        PsiType functionalType,
                                        boolean addConstraint,
@@ -493,7 +506,7 @@ public class InferenceSession {
       if (addConstraint) {
         final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)returnExpression);
         if (calledMethod != null && PsiPolyExpressionUtil.isMethodCallPolyExpression(returnExpression, calledMethod)) {
-          collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)returnExpression, initialSubstitutor);
+          collectAdditionalConstraints(additionalConstraints, ignoredConstraints, (PsiCallExpression)returnExpression, initialSubstitutor);
         }
       }
       else {
@@ -501,19 +514,20 @@ public class InferenceSession {
       }
     }
     else if (returnExpression instanceof PsiParenthesizedExpression) {
-      processReturnExpression(additionalConstraints, ((PsiParenthesizedExpression)returnExpression).getExpression(), functionalType, addConstraint, initialSubstitutor);
+      processReturnExpression(additionalConstraints, ignoredConstraints, ((PsiParenthesizedExpression)returnExpression).getExpression(), functionalType, addConstraint, initialSubstitutor);
     }
     else if (returnExpression instanceof PsiConditionalExpression) {
-      processReturnExpression(additionalConstraints, ((PsiConditionalExpression)returnExpression).getThenExpression(), functionalType, addConstraint, initialSubstitutor);
-      processReturnExpression(additionalConstraints, ((PsiConditionalExpression)returnExpression).getElseExpression(), functionalType, addConstraint, initialSubstitutor);
+      processReturnExpression(additionalConstraints, ignoredConstraints, ((PsiConditionalExpression)returnExpression).getThenExpression(), functionalType, addConstraint, initialSubstitutor);
+      processReturnExpression(additionalConstraints, ignoredConstraints, ((PsiConditionalExpression)returnExpression).getElseExpression(), functionalType, addConstraint, initialSubstitutor);
     }
     else if (returnExpression instanceof PsiLambdaExpression) {
-      collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)returnExpression, functionalType, myErased, initialSubstitutor);
+      collectLambdaReturnExpression(additionalConstraints, ignoredConstraints, (PsiLambdaExpression)returnExpression, functionalType, myErased, initialSubstitutor);
     }
   }
 
   private void collectAdditionalConstraints(final Set<ConstraintFormula> additionalConstraints,
-                                            final PsiCall callExpression, 
+                                            final Set<ConstraintFormula> ignoredConstraints, 
+                                            final PsiCall callExpression,
                                             PsiSubstitutor initialSubstitutor) {
     PsiExpressionList argumentList = callExpression.getArgumentList();
     if (argumentList != null) {
@@ -524,7 +538,8 @@ public class InferenceSession {
         final PsiExpression[] newArgs = argumentList.getExpressions();
         final PsiParameter[] newParams = method.getParameterList().getParameters();
         if (newParams.length > 0) {
-          collectAdditionalConstraints(newParams, newArgs, method, chooseSiteSubstitutor(properties, result, method), additionalConstraints, chooseVarargsMode(properties, result), initialSubstitutor);
+          collectAdditionalConstraints(newParams, newArgs, method, chooseSiteSubstitutor(properties, result, method), additionalConstraints,
+                                       ignoredConstraints, chooseVarargsMode(properties, result), initialSubstitutor);
         }
       }
     }
@@ -587,6 +602,7 @@ public class InferenceSession {
   }
   
   PsiSubstitutor prepareSubstitution() {
+    boolean foundErrorMessage = false;
     Iterator<List<InferenceVariable>> iterator = InferenceVariablesOrder.resolveOrderIterator(myInferenceVariables, this);
     while (iterator.hasNext()) {
       final List<InferenceVariable> variables = iterator.next();
@@ -595,7 +611,9 @@ public class InferenceSession {
         PsiType instantiation = inferenceVariable.getInstantiation();
         //failed inference
         if (instantiation == PsiType.NULL) {
-          checkBoundsConsistency(mySiteSubstitutor, inferenceVariable);
+          if (!foundErrorMessage) {
+            foundErrorMessage = checkBoundsConsistency(mySiteSubstitutor, inferenceVariable) == PsiType.NULL;
+          }
           mySiteSubstitutor = mySiteSubstitutor
             .put(typeParameter, JavaPsiFacade.getInstance(typeParameter.getProject()).getElementFactory().createType(typeParameter));
         }
@@ -1290,7 +1308,7 @@ public class InferenceSession {
       }
   }
 
-  private boolean proceedWithAdditionalConstraints(Set<ConstraintFormula> additionalConstraints) {
+  private boolean proceedWithAdditionalConstraints(Set<ConstraintFormula> additionalConstraints, Set<ConstraintFormula> ignoredConstraints) {
     //empty substitutor should be used to resolve input variables:
     //all types in additional constraints are already substituted during collecting phase, 
     //recursive site substitutors (T -> List<T>) would make additional constraints work with multiple times substituted types, which is incorrect.
@@ -1300,7 +1318,7 @@ public class InferenceSession {
 
     while (!additionalConstraints.isEmpty()) {
       //extract subset of constraints
-      final Set<ConstraintFormula> subset = buildSubset(additionalConstraints);
+      final Set<ConstraintFormula> subset = buildSubset(additionalConstraints, ignoredConstraints);
 
       //collect all input variables of selection
       final Set<InferenceVariable> varsToResolve = new LinkedHashSet<InferenceVariable>();
@@ -1312,7 +1330,7 @@ public class InferenceSession {
 
       final PsiSubstitutor substitutor = resolveSubsetOrdered(varsToResolve, siteSubstitutor);
       for (ConstraintFormula formula : subset) {
-        if (!processOneConstraint(formula, additionalConstraints, substitutor)) return false;
+        if (!processOneConstraint(formula, additionalConstraints, substitutor, ignoredConstraints)) return false;
       }
     }
     return true;
@@ -1329,8 +1347,9 @@ public class InferenceSession {
   }
 
   private boolean processOneConstraint(ConstraintFormula formula,
-                                       Set<ConstraintFormula> additionalConstraints, 
-                                       PsiSubstitutor substitutor) {
+                                       Set<ConstraintFormula> additionalConstraints,
+                                       PsiSubstitutor substitutor, 
+                                       Set<ConstraintFormula> ignoredConstraints) {
 
     if (myContext instanceof PsiCall) {
       PsiExpressionList argumentList = ((PsiCall)myContext).getArgumentList();
@@ -1348,27 +1367,20 @@ public class InferenceSession {
     if (formula instanceof ExpressionCompatibilityConstraint) {
       PsiExpression expression = ((ExpressionCompatibilityConstraint)formula).getExpression();
       if (expression instanceof PsiLambdaExpression) {
-        PsiType parameterType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(((ExpressionCompatibilityConstraint)formula).getT(),
-                                                                                            (PsiLambdaExpression)expression);
-        collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)expression, parameterType, !isProperType(parameterType), substitutor);
+        PsiType parameterType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(((ExpressionCompatibilityConstraint)formula).getT(), (PsiLambdaExpression)expression);
+        collectLambdaReturnExpression(additionalConstraints, ignoredConstraints, (PsiLambdaExpression)expression, parameterType, !isProperType(parameterType), substitutor);
       }
     }
     return true;
   }
 
-  private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints) {
+  private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints,
+                                             final Set<ConstraintFormula> ignoredConstraints) {
+
+    final Set<InferenceVariable> outputVariables = getOutputVariables(additionalConstraints);
+    final Set<InferenceVariable> ignoredOutputVariables = getOutputVariables(ignoredConstraints);
 
     Set<ConstraintFormula> subset = new LinkedHashSet<ConstraintFormula>();
-    final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
-    for (ConstraintFormula constraint : additionalConstraints) {
-      if (constraint instanceof InputOutputConstraintFormula) {
-        final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
-        final Set<InferenceVariable> outputVars = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this);
-        if (outputVars != null) {
-          outputVariables.addAll(outputVars);
-        }
-      }
-    }
 
     Set<ConstraintFormula> noInputVariables = new LinkedHashSet<ConstraintFormula>();
     for (ConstraintFormula constraint : additionalConstraints) {
@@ -1382,11 +1394,13 @@ public class InferenceSession {
             final Set<InferenceVariable> dependencies = inputVariable.getDependencies(this);
             dependencies.add(inputVariable);
             if (!hasCapture(inputVariable)) {
-              for (InferenceVariable outputVariable : outputVariables) {
-                if (ContainerUtil.intersects(outputVariable.getDependencies(this), dependencies)) {
-                  dependsOnOutput = true;
-                  break;
-                }
+              if (dependsOnOutput(ignoredOutputVariables, dependencies)) {
+                dependsOnOutput = true;
+                ignoredConstraints.add(constraint);
+                break;
+              }
+              else {
+                dependsOnOutput = dependsOnOutput(outputVariables, dependencies);
               }
             }
 
@@ -1414,7 +1428,10 @@ public class InferenceSession {
       }
     }
     if (subset.isEmpty()) {
-      subset.add(additionalConstraints.iterator().next()); //todo choose one constraint
+      additionalConstraints.removeAll(ignoredConstraints);
+      if (!additionalConstraints.isEmpty()) {
+        subset.add(additionalConstraints.iterator().next()); //todo choose one constraint
+      }
     }
     
     if (!noInputVariables.isEmpty()) {
@@ -1425,6 +1442,30 @@ public class InferenceSession {
     return subset;
   }
 
+  private boolean dependsOnOutput(Set<InferenceVariable> outputVariables, Set<InferenceVariable> dependencies) {
+    for (InferenceVariable outputVariable : outputVariables) {
+      if (ContainerUtil.intersects(outputVariable.getDependencies(this), dependencies)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @NotNull
+  private Set<InferenceVariable> getOutputVariables(Set<ConstraintFormula> constraintFormulas) {
+    final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
+    for (ConstraintFormula constraint : constraintFormulas) {
+      if (constraint instanceof InputOutputConstraintFormula) {
+        final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
+        final Set<InferenceVariable> outputVars = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this);
+        if (outputVars != null) {
+          outputVariables.addAll(outputVars);
+        }
+      }
+    }
+    return outputVariables;
+  }
+
   public PsiSubstitutor collectApplicabilityConstraints(final PsiMethodReferenceExpression reference, 
                                                         final MethodCandidateInfo candidateInfo,
                                                         final PsiType functionalInterfaceType) {
index 86b9e490ccde9cac22685d7678b76ab9eb8c1661..eed5d51b7bf565a1fd2b9a4e5fd8ee7f735028c5 100644 (file)
@@ -81,7 +81,7 @@ public class InferenceSessionContainer {
         if (topLevelCall != null) {
 
           final InferenceSession session;
-          if (MethodCandidateInfo.isOverloadCheck() || !PsiDiamondType.ourDiamondGuard.currentStack().isEmpty()) {
+          if (MethodCandidateInfo.isOverloadCheck() || !PsiDiamondType.ourDiamondGuard.currentStack().isEmpty() || LambdaUtil.isLambdaParameterCheck()) {
             session = startTopLevelInference(topLevelCall);
           }
           else {
index 750a2220ef5325512e5d955a337c3b63a2e91c9e..62f3efc3a0f2a0e023fcffd0083db4df0c3bb04c 100644 (file)
@@ -161,7 +161,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
 
   private static boolean isAddressed(List<PsiType> expectedThrownTypes, PsiType thrownType) {
     for (PsiType expectedThrownType : expectedThrownTypes) {
-      if (TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(thrownType), expectedThrownType)) {
+      if (TypeConversionUtil.isAssignable(expectedThrownType, thrownType)) {
         return true;
       }
     }
index 94e4f6b6eb96d08e86addebf322a10b780386745..cae20db0f0c5265fb147f213df1e0a5e69eebed2 100644 (file)
@@ -134,9 +134,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
 
       if (method != null && !method.isConstructor()) {
         returnType = method.getReturnType();
-        if (returnType != null) {
-          typeParams = method.getTypeParameters();
-        }
+        typeParams = method.getTypeParameters();
       }
       else if (resolveResult != null) {
         final PsiClass psiClass = method != null ? method.getContainingClass() : (PsiClass)resolveResult.getElement();
@@ -162,7 +160,9 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
             return callSession;
           }
 
-          callSession.registerReturnTypeConstraints(siteSubstitutor.substitute(returnType), targetType);
+          if (returnType != null) {
+            callSession.registerReturnTypeConstraints(siteSubstitutor.substitute(returnType), targetType);
+          }
           if (callSession.repeatInferencePhases()) {
             return callSession;
           }
@@ -175,8 +175,8 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
             session.registerIncompatibleErrorMessage(message);
           }
         }
-        return null;
       }
+      return null;
     }
     return session;
   }
index 37c5090dbcf88a4d2d6f5467277d5d5fb26d3339..785cb7e57d4db6c35c5e32c4fb5838ef36e1430c 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi.impl.source.tree.java;
 
+import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy;
@@ -72,7 +73,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
             }
           }
           ClassCandidateInfo candidateInfo = null;
-          final boolean isArray = containingClass == JavaPsiFacade.getElementFactory(reference.getProject()).getArrayClass(PsiUtil.getLanguageLevel(containingClass));
+          final boolean isArray = PsiEquivalenceUtil.areElementsEquivalent(containingClass, JavaPsiFacade.getElementFactory(reference.getProject()).getArrayClass(PsiUtil.getLanguageLevel(reference)));
           if (signature == null ||
               !isArray && (containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass, reference)) && signature.getParameterTypes().length == 0 ||
               isArray && arrayCreationSignature(signature)) {
index c391fdc713824cb40dae393bbaa828ce28989651..b64e4594a1249537b260a21c2695990723d7c1d1 100644 (file)
@@ -80,7 +80,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
                 myArgumentsList.getText() + "; " +
                 "file=" + (method == null ? "<unknown>" : method.getContainingFile()));
     }
-    return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, true, new Computable<CandidateInfo>() {
+    return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, false, new Computable<CandidateInfo>() {
       @Override
       public CandidateInfo compute() {
         return guardedOverloadResolution(conflicts);
index ab8cf74dd1b15706ec1908d29c940d74fd7673e0..78b8a42dad26a24097373416a34dd2a15c544e74 100644 (file)
@@ -104,7 +104,7 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
       public PsiType[] getArgumentTypes() {
         if (myExpressionTypes == null && argumentList != null) {
           final PsiType[] expressionTypes = getExpressionTypes(argumentList);
-          if (MethodCandidateInfo.isOverloadCheck()) {
+          if (MethodCandidateInfo.isOverloadCheck() || LambdaUtil.isLambdaParameterCheck()) {
             return expressionTypes;
           }
           myExpressionTypes = expressionTypes;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/ExceptionConstraintsWithProperAndNonProperThrows.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/ExceptionConstraintsWithProperAndNonProperThrows.java
new file mode 100644 (file)
index 0000000..684844b
--- /dev/null
@@ -0,0 +1,17 @@
+import java.io.IOException;
+
+class GenericException {
+  {
+    applyFunc(t -> throwsException());
+  }
+
+  private static <T, E extends Exception> void applyFunc(CheckedFunction<T, E> function) {}
+
+
+  private static void throwsException() throws Exception {}
+
+  interface CheckedFunction<T, E extends Exception> {
+    void apply(T t) throws E, IOException;
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/expressions/CacheUnresolvedMethods4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/expressions/CacheUnresolvedMethods4.java
new file mode 100644 (file)
index 0000000..0691aa0
--- /dev/null
@@ -0,0 +1,14 @@
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+class Test {
+  <K> void foo(Function<String, K> f1) {}
+
+  <T> Stream<T> bar(T ts) {
+    return null;
+  }
+
+  void f(){
+    foo(y -> bar(y.to<caret>String()).map(a -> a.length()));
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/expressions/CacheUnresolvedMethods5.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/expressions/CacheUnresolvedMethods5.java
new file mode 100644 (file)
index 0000000..17a1cc1
--- /dev/null
@@ -0,0 +1,10 @@
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+class StreamMainSimplified {
+  public static void main(Optional<Map.Entry<Integer, String>> first) {
+    String s1 = first.map((e) -> e.getV<caret>alue()).orElse("").substring(9);
+  }
+
+}
\ No newline at end of file
index 49c813e2a87827657aae6b85823c71d892e86c57..4525426bf58e51b13f0a632ea589262bb23f62d9 100644 (file)
@@ -3,8 +3,8 @@ import java.util.*;
 class Main {
 
     void foo(List<Integer> list) {
-        bar(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
-        bar1(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
+        bar(list, i -> <error descr="Bad return type in lambda expression: int cannot be converted to S_OUT">i.intValue()</error>, i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
+        bar1(list, i -> <error descr="Bad return type in lambda expression: int cannot be converted to S_OUT">i.intValue()</error>, i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
     }
 
     <U, S_IN, S_OUT, R> R bar(List<S_IN> list,
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/UnrelatedDefaultsOverriddenWithConcreteMethodNonEmptySubstitutor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/UnrelatedDefaultsOverriddenWithConcreteMethodNonEmptySubstitutor.java
new file mode 100644 (file)
index 0000000..d21f45c
--- /dev/null
@@ -0,0 +1,16 @@
+interface A<K> {
+  default void replace(K v) {}
+}
+
+interface B<K> extends A<K> {
+  void replace(K k);
+}
+
+abstract class AC<K> implements A<K> {}
+
+class C<K> extends AC<K> implements B<K> {
+  @Override
+  public void replace(K k) {}
+}
+
+<error descr="Class 'D' must either be declared abstract or implement abstract method 'replace(K)' in 'B'">class <error descr="Class 'D' must either be declared abstract or implement abstract method 'replace(K)' in 'B'">D</error><K> extends AC<K> implements B<K></error> {}
\ No newline at end of file
index 8869943add57d191935b73afdaf25cedb802d35a..7d5c0557acf7d0c6fb3867a6685bb8fc98fa54cb 100644 (file)
@@ -12,10 +12,7 @@ class Test {
     SuperFoo<String> ls = foo(<error descr="no instance(s) of type variable(s)  exist so that String conforms to Number
 inference variable R has incompatible bounds:
  equality constraints: String
-upper bounds: Object, Number
-inference variable X has incompatible bounds:
- equality constraints: R
-upper bounds: Number">() -> new Foo<>()</error>);
+upper bounds: Object, Number">() -> new Foo<>()</error>);
     SuperFoo<Integer> li = foo(() -> new Foo<>());
     SuperFoo<?> lw = foo(() -> new Foo<>());
 }
\ No newline at end of file
index 58dff582cc2c2883d9e28ce97009717cf96c786c..ce91ef6d55e1ab8f3a76b85dfdcf9bbe6de2eb0c 100644 (file)
@@ -29,10 +29,7 @@ abstract class NoFormalParamTypeInferenceNeeded {
     Integer zip = zip(a -> zip(<error descr="no instance(s) of type variable(s)  exist so that Object conforms to Integer
 inference variable R has incompatible bounds:
  lower bounds: Object
-upper bounds: Object, Integer
-inference variable R has incompatible bounds:
- lower bounds: Object
-upper bounds: Object, R, Integer">text -> text</error>));
+upper bounds: Object, Integer">text -> text</error>));
   }
 
 }
index 6b12c71ed73ef5396aaca86f7830b1db3b9b9d41..bdfe3324957bda9148f87939985e78be92ffbcde 100644 (file)
@@ -36,3 +36,12 @@ final class Collectors {
                         downstream.characteristics().toArray(new Collector.Characteristics[downstream.characteristics().size()]));
   }
 }
+
+class SimplifiedTest {
+
+  public static void a(Stream<Integer> classifier) {
+    flatMapping(classifier.map(k -> new AbstractMap.SimpleEntry<Integer, String>(k,k.toString())), Map.Entry::getKey);
+  }
+
+  public static <U, R> void flatMapping(Stream<U> stream, Function<U, R> downstream) {}
+}
index 1ae6cf53b38be30ee0f253184cbc6e290d714339..f9246c9b0ff309fc41f3f0450973415305c62210 100644 (file)
@@ -22,5 +22,6 @@ class Test {
     strings.forEach((IoFunction<String>) arg -> {throw new IOException();});
     strings.forEach((IFunction<String>) arg -> {});
     strings.forEach((IIFunction<String>) arg -> {});
+    strings.forEach((<warning descr="Casting 'arg -> {}' to 'Consumer<String>' is redundant">Consumer<String></warning>) arg -> {});
   }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/surroundAutoCloseable/Expression.java b/java/java-tests/testData/codeInsight/surroundAutoCloseable/Expression.java
new file mode 100644 (file)
index 0000000..977f25d
--- /dev/null
@@ -0,0 +1,7 @@
+import java.io.*;
+
+class C {
+    void m(File file) throws IOException {
+        <caret>new FileInputStream(file);
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/surroundAutoCloseable/ExpressionIncomplete.java b/java/java-tests/testData/codeInsight/surroundAutoCloseable/ExpressionIncomplete.java
new file mode 100644 (file)
index 0000000..554e8b4
--- /dev/null
@@ -0,0 +1,7 @@
+import java.io.*;
+
+class C {
+    void m(File file) throws IOException {
+        new FileInputStream(file)<caret>
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/surroundAutoCloseable/ExpressionIncomplete_after.java b/java/java-tests/testData/codeInsight/surroundAutoCloseable/ExpressionIncomplete_after.java
new file mode 100644 (file)
index 0000000..cca3b0a
--- /dev/null
@@ -0,0 +1,8 @@
+import java.io.*;
+
+class C {
+    void m(File file) throws IOException {
+        try (FileInputStream fileInputStream = new FileInputStream(file)) {
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/surroundAutoCloseable/Expression_after.java b/java/java-tests/testData/codeInsight/surroundAutoCloseable/Expression_after.java
new file mode 100644 (file)
index 0000000..cca3b0a
--- /dev/null
@@ -0,0 +1,8 @@
+import java.io.*;
+
+class C {
+    void m(File file) throws IOException {
+        try (FileInputStream fileInputStream = new FileInputStream(file)) {
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/surroundAutoCloseable/SimplePast.java b/java/java-tests/testData/codeInsight/surroundAutoCloseable/SimplePast.java
new file mode 100644 (file)
index 0000000..70667bd
--- /dev/null
@@ -0,0 +1,8 @@
+import java.io.*;
+import java.net.*;
+
+class C {
+    public void read(URLConnection connection) {
+        InputStream stream = connection.getInputStream();<caret>
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/surroundAutoCloseable/SimplePast_after.java b/java/java-tests/testData/codeInsight/surroundAutoCloseable/SimplePast_after.java
new file mode 100644 (file)
index 0000000..5e61534
--- /dev/null
@@ -0,0 +1,9 @@
+import java.io.*;
+import java.net.*;
+
+class C {
+    public void read(URLConnection connection) {
+        try (InputStream stream = connection.getInputStream()) {<caret>
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/projectView/noDuplicateModules/src/com/package1/Test.java b/java/java-tests/testData/projectView/noDuplicateModules/src/com/package1/Test.java
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/java/java-tests/testData/projectView/noDuplicateModules/src/com/package1/p2/p3/Test1.java b/java/java-tests/testData/projectView/noDuplicateModules/src/com/package1/p2/p3/Test1.java
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/java/java-tests/testData/psi/cls/mirror/MemberAnnotations.txt b/java/java-tests/testData/psi/cls/mirror/MemberAnnotations.txt
new file mode 100644 (file)
index 0000000..f7f1b70
--- /dev/null
@@ -0,0 +1,22 @@
+
+  // IntelliJ API Decompiler stub source generated from a class file
+  // Implementation of methods is not available
+
+package pkg;
+
+class MemberAnnotations {
+    @pkg.MemberAnnotations.A("const")
+    public static final int CONST = 42;
+    @pkg.MemberAnnotations.A("field")
+    private int f;
+
+    MemberAnnotations() { /* compiled code */ }
+
+    @pkg.MemberAnnotations.A("return")
+    private int f(@pkg.MemberAnnotations.A("arg") int i) { /* compiled code */ }
+
+    @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+    static @interface A {
+        java.lang.String value() default "";
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class
new file mode 100644 (file)
index 0000000..e2bd13c
Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class differ
diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class
new file mode 100644 (file)
index 0000000..3752465
Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class differ
diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/MemberAnnotations.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/MemberAnnotations.java
new file mode 100644 (file)
index 0000000..e980db8
--- /dev/null
@@ -0,0 +1,13 @@
+package pkg;
+
+import java.lang.annotation.*;
+
+class MemberAnnotations {
+  @Retention(RetentionPolicy.RUNTIME)
+  @interface A { String value() default ""; }
+
+  @A("const") public static final int CONST = 42;
+  @A("field") private int f;
+
+  @A("return") private int f(@A("arg") int i) { return i + f + CONST; }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/after/Test.java
new file mode 100644 (file)
index 0000000..3ca94f5
--- /dev/null
@@ -0,0 +1,12 @@
+class Test {
+  public Test() {
+  }
+
+    public static Test[] getArray() {
+      return new Test[0];
+    }
+
+    public static Test[] getArrayWithInitializer() {
+      return new Test[]{};
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/before/Super.java
new file mode 100644 (file)
index 0000000..f7d708e
--- /dev/null
@@ -0,0 +1,13 @@
+class Super {
+  public Super(String s) {
+  }
+
+  public static Super[] getArray() {
+    return new Super[0];
+  }
+  
+  public static Super[] getArrayWithInitializer() {
+    return new Super[]{};
+  }
+  
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/arrayTypeElements/before/Test.java
new file mode 100644 (file)
index 0000000..8b00c86
--- /dev/null
@@ -0,0 +1,5 @@
+class Test extends Super {
+  public Test() {
+    super("");
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/after/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/after/Super.java
new file mode 100644 (file)
index 0000000..ce73a29
--- /dev/null
@@ -0,0 +1,6 @@
+class A implements I {
+  A(int i) {
+    System.out.println(i);
+  }
+}
+
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/after/Test.java
new file mode 100644 (file)
index 0000000..43149f4
--- /dev/null
@@ -0,0 +1,5 @@
+abstract class Test extends A {
+  public Test(boolean mode) {
+    super(mode? 1: 0);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/before/Super.java
new file mode 100644 (file)
index 0000000..a777205
--- /dev/null
@@ -0,0 +1,7 @@
+class A implements I {
+  A(int i) {
+    System.out.println(i);
+  }
+}
+
+interface Super {}
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/inlineInterfaceDoNotChangeConstructor/before/Test.java
new file mode 100644 (file)
index 0000000..5a4c669
--- /dev/null
@@ -0,0 +1,5 @@
+abstract class Test extends A implements Super {
+  public Test(boolean mode) {
+    super(mode? 1: 0);
+  }
+}
\ No newline at end of file
index f95077f47cb69e277a348dfa21b266cc4470ccd0..a9952f3f94a8c7ef5f34b4a36f64cc29e0e543b1 100644 (file)
@@ -2,6 +2,6 @@ class Test {
     private final String field;
 
     Test(){
-        field = "text";
+        this.field = "text";
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/invertBoolean/FinalBooleanFieldWithoutInitializer.java b/java/java-tests/testData/refactoring/invertBoolean/FinalBooleanFieldWithoutInitializer.java
new file mode 100644 (file)
index 0000000..4dffe6c
--- /dev/null
@@ -0,0 +1,8 @@
+class Test {
+  private final boolean notInitial<caret>ized;
+
+  public Test() {
+      notInitialized = true;
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/invertBoolean/FinalBooleanFieldWithoutInitializer_after.java b/java/java-tests/testData/refactoring/invertBoolean/FinalBooleanFieldWithoutInitializer_after.java
new file mode 100644 (file)
index 0000000..1898a41
--- /dev/null
@@ -0,0 +1,8 @@
+class Test {
+  private final boolean notInitializedInverted;
+
+  public Test() {
+      notInitializedInverted = false;
+  }
+
+}
\ No newline at end of file
index 6580f2bb942fb355f9bcb8a52e897b9c5b372735..acacc42803d51ee30f295fa568a505c5417d3a51 100644 (file)
@@ -63,6 +63,10 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
     doTest(false);
   }
 
+  public void testExceptionConstraintsWithProperAndNonProperThrows() throws Exception {
+    doTest(false);
+  }
+
   private void doTest(final boolean checkWarnings) {
     doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
   }
index 06eed02912de8fb0145df97dbd7d208288e1c1a9..9729078a1f073494e4809fd7b0415e8bbf33f2b2 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo;
 import com.intellij.lang.annotation.HighlightSeverity;
 import com.intellij.openapi.projectRoots.JavaSdkVersion;
 import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.testFramework.IdeaTestUtil;
 import org.jetbrains.annotations.NonNls;
 
@@ -419,18 +420,17 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
       }
     }
 
-    assertTrue(tooltips.contains("<html><body><table border=0><tr><td>" +
-                                     "<b>identity(&nbsp;)&nbsp;</b></td><td colspan=1>in <b>Function</b>&nbsp;cannot be applied</td></tr><tr><td>to</td><td><b>()</b>&nbsp;" +
-                                     
-                           "</td></tr></table><br/>" +
-                           "reason: no instance(s) of type variable(s) K, U exist so that Map&lt;K, U&gt; conforms to Function&lt;U, V&gt;" +
-                           "</body></html>"));
-    assertTrue(tooltips.contains(
-                           "<html><body><table border=0><tr><td>" +
-                                    "<b>identity(&nbsp;)&nbsp;</b></td><td colspan=1>in <b>Function</b>&nbsp;cannot be applied</td></tr><tr><td>to</td><td><b>()</b>&nbsp;" +
-                           "</td></tr></table><br/>" +
-                           "reason: no instance(s) of type variable(s) K, U exist so that Map&lt;K, U&gt; conforms to Function&lt;U, V&gt;" +
-                           "</body></html>"));
+    boolean found = false;
+    for (String tooltip : tooltips) {
+      if (tooltip.contains("reason: no instance(s) of type variable(s) K, U exist so that Map&lt;K, U&gt; conforms to Function&lt;U, V&gt;")) {
+        found = true;
+        break;
+      }
+    }
+
+    if (!found) {
+      fail(StringUtil.join(tooltips, ", "));
+    }
   }
 
   private void doTest() throws Exception {
index e249848ffaeaab337ef81535315212041156cb7c..2f7494e0f1d9e55ecba39b050039bf5009e0493a 100644 (file)
@@ -58,6 +58,10 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
     doTest();
   }
 
+  public void testUnrelatedDefaultsOverriddenWithConcreteMethodNonEmptySubstitutor() throws Exception {
+    doTest(false, false);
+  }
+
   public void testStaticMethodAccessibleBothThroughStaticImportAndInheritance() throws Exception {
     myFixture.addClass("package p; public interface Foo {" +
                        "    static void foo() {}" +
index 5ff44e47aa19427f815e1dbf9e2163272c0a4a04..57d8965d132e784bda4a5efd211795225482b2ad 100644 (file)
@@ -63,6 +63,14 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
     doTestCachedUnresolved();
   }
 
+  public void testCacheUnresolvedMethods4() throws Exception {
+    doTestCachedUnresolved();
+  }
+
+  public void testCacheUnresolvedMethods5() throws Exception {
+    doTestCachedUnresolved();
+  }
+
   public void testMethodOverloadsInsideLambdaHierarchy() throws Exception {
     doTestAllMethodCallExpressions();
   }
index 5ac7938680721ef02bbc9209d32acae4c5a55ecb..cb36749e17841a95dd1569e37def5797fcfbb6b0 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.
@@ -27,14 +27,17 @@ public class SurroundAutoCloseableActionTest extends LightCodeInsightFixtureTest
   }
 
   public void testSimple() { doTest(); }
+  public void testSimplePast() { doTest(); }
   public void testUsage() { doTest(); }
   public void testMixedUsages() { doTest(); }
   public void testLastDeclaration() { doTest(); }
   public void testSplitVar() { doTest(); }
+  public void testExpression() { doTest(); }
+  public void testExpressionIncomplete() { doTest(); }
 
   private void doTest() {
     String name = getTestName(false);
     String intention = CodeInsightBundle.message("intention.surround.resource.with.ARM.block");
     CodeInsightTestUtil.doIntentionTest(myFixture, intention, name + ".java", name + "_after.java");
   }
-}
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/SurroundWithTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/SurroundWithTemplateTest.groovy
deleted file mode 100644 (file)
index e8c5154..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2000-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.template
-
-import com.intellij.codeInsight.template.impl.InvokeTemplateAction
-import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler
-import com.intellij.openapi.actionSystem.DefaultActionGroup
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
-
-class SurroundWithTemplateTest extends LightCodeInsightFixtureTestCase {
-  public void testSurroundWithTryWithResources() {
-    myFixture.configureByText "C.java", """\
-      import java.io.*;
-      class C {
-          void m() {
-              new FileReader("/dev/null")<caret>
-          }
-      }""".stripIndent()
-
-    invokeTemplate("TR")
-
-    myFixture.checkResult """\
-      import java.io.*;
-      class C {
-          void m() {
-              try (FileReader fileReader = new FileReader("/dev/null")) {
-                  <caret>
-              }
-
-          }
-      }""".stripIndent()
-  }
-
-  private void invokeTemplate(String template) {
-    DefaultActionGroup group = SurroundWithTemplateHandler.createActionGroup(project, editor, file)
-    assertNotNull(group)
-    InvokeTemplateAction action = group.childActionsOrStubs.find {
-      it instanceof InvokeTemplateAction && (it as InvokeTemplateAction).template.key == template
-    } as InvokeTemplateAction
-    assertNotNull(action)
-    action.perform()
-  }
-}
index 71817ea528c8db5c0979ed1c064e3c733783d3b6..017f1d310ba15b1f488bcdf44c26a84d0e579502 100644 (file)
@@ -1,6 +1,13 @@
 package com.intellij.projectView;
 
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.impl.ModuleManagerImpl;
+import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.ui.Queryable;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.testFramework.PsiTestUtil;
+import org.junit.Assert;
 
 public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
 
@@ -110,4 +117,30 @@ public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
 
     checkContainsMethod(myStructure.getRootElement(), myStructure);
   }
+
+  public void testNoDuplicateModules() {
+    VirtualFile mainModuleRoot = ModuleRootManager.getInstance(myModule).getContentRoots()[0];
+
+    PsiTestUtil.addExcludedRoot(myModule, mainModuleRoot.findFileByRelativePath("src/com/package1/p2"));
+
+    Module module = createModule("nested_module");
+    ModuleManagerImpl.getInstanceImpl(myProject).setModuleGroupPath(module, new String[]{"modules"});
+    PsiTestUtil.addContentRoot(module, mainModuleRoot.findFileByRelativePath("src/com/package1/p2/p3"));
+
+    TestProjectTreeStructure structure = new TestProjectTreeStructure(myProject, myTestRootDisposable);
+    structure.setShowLibraryContents(false);
+
+    String structureContent = PlatformTestUtil.print(structure, structure.getRootElement(), 0, null, 10, ' ', myPrintInfo).toString();
+
+    Assert.assertFalse(structureContent.contains("modules"));
+    assertEquals("Project\n" +
+                 " noDuplicateModules\n" +
+                 "  src\n" +
+                 "   com\n" +
+                 "    package1\n" +
+                 "     Test.java\n" +
+                 " nested_module.iml\n" +
+                 " testNoDuplicateModules.iml\n",
+                 structureContent);
+  }
 }
index 9069a30bf2c6c20b440b43be917d1825ba024cf7..479bbb67b358e6ea67092f8e50a404db26a49489 100644 (file)
@@ -45,6 +45,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
   public void testDeprecated() { doTest(); }
   public void testAnnotations() { doTest(); }
   public void testMoreAnnotations() { doTest(); }
+  public void testMemberAnnotations() { doTest(); }
   public void testParameterNames() { doTest(); }
   public void testEmptyEnum() { doTest(); }
   public void test$BuckClass() { doTest(); }
index ee8b628cd4783e4502b51e52e094b7ff941bf717..ae4d0e7c960f9612517564b4c0086f4f2f39949a 100644 (file)
@@ -527,6 +527,30 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
     doClassTest(before, after);
   }
 
+  public void testDoNotMergeCommentLines() {
+    getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+    getSettings().getRootSettings().WRAP_COMMENTS = true;
+
+    doClassTest(
+      "/**\n" +
+      " * Some comment\n" +
+      " * 2016\n" +
+      " * Date: Mar 03, 2016\n" +
+      " *\n" +
+      " */\n" +
+      "     public class TestCase {\n" +
+      "}",
+      
+      "/**\n" +
+      " * Some comment\n" +
+      " * 2016\n" +
+      " * Date: Mar 03, 2016\n" +
+      " */\n" +
+      "public class TestCase {\n" +
+      "}"
+    );
+  }
+
   public void testSeeTagAlignment() throws Exception {
     getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
     getSettings().RIGHT_MARGIN = 80;
index 5947eb9367d088f525aee4ecc2d78f09d86d86a2..9a32349175efebd6981a7c4a1d11e2593b110e15 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.psi.impl;
 
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElementFactory;
-import com.intellij.testFramework.LightIdeaTestCase;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
 import com.intellij.util.IncorrectOperationException;
 
-public class JavaElementFactoryTest extends LightIdeaTestCase {
+import static com.intellij.testFramework.LightCodeInsightTestCase.getJavaFacade;
+
+public class JavaElementFactoryTest extends LightCodeInsightFixtureTestCase {
   private PsiElementFactory myFactory;
 
   @Override
@@ -39,4 +44,11 @@ public class JavaElementFactoryTest extends LightIdeaTestCase {
     }
     catch (IncorrectOperationException ignored) { }
   }
-}
+
+  public void testArrayClassLanguageLevel() {
+    PsiClass arrayClass3 = myFactory.getArrayClass(LanguageLevel.JDK_1_4);
+    PsiClass arrayClass5 = myFactory.getArrayClass(LanguageLevel.HIGHEST);
+    assertEquals(LanguageLevel.JDK_1_3, PsiUtil.getLanguageLevel(arrayClass3));
+    assertEquals(LanguageLevel.JDK_1_5, PsiUtil.getLanguageLevel(arrayClass5));
+  }
+}
\ No newline at end of file
index 043874000c2b05518440444e0e328984145f9185..59b8ca4a981d59f579df1616cb8c187d8f8c5bb7 100644 (file)
@@ -70,6 +70,8 @@ public class InlineSuperClassTest extends MultiFileTestCase {
   public void testInlineSuperclassExtendsList() { doTest(); }
   public void testInterfaceHierarchyWithSubstitution() { doTest(); }
   public void testTypeParameterBound() { doTest();}
+  public void testInlineInterfaceDoNotChangeConstructor() { doTest(); }
+  public void testArrayTypeElements() { doTest(); }
 
   private void doTest() {
     doTest(false, false);
@@ -85,7 +87,7 @@ public class InlineSuperClassTest extends MultiFileTestCase {
         PsiClass superClass = myJavaFacade.findClass("Super", scope);
         if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", scope);
         assertNotNull("Class Super not found", superClass);
-        new InlineSuperClassRefactoringProcessor(myProject, inlineOne ? aClass : null, superClass, DocCommentPolicy.ASIS, aClass).run();
+        new InlineSuperClassRefactoringProcessor(myProject, inlineOne ? aClass : null, superClass, DocCommentPolicy.ASIS).run();
       });
     }
     catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
@@ -107,9 +109,7 @@ public class InlineSuperClassTest extends MultiFileTestCase {
       PsiClass superClass = myJavaFacade.findClass("Super", scope);
       if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", scope);
       assertNotNull("Class Super not found", superClass);
-      PsiClass target1 = myJavaFacade.findClass("Test", scope);
-      PsiClass target2 = myJavaFacade.findClass("Test1", scope);
-      new InlineSuperClassRefactoringProcessor(myProject, null, superClass, DocCommentPolicy.ASIS, target1, target2).run();
+      new InlineSuperClassRefactoringProcessor(myProject, null, superClass, DocCommentPolicy.ASIS).run();
     });
   }
 }
index 2511fcee81da99bc3deb0c0b9f4b066c22d7cb7a..249d799ab8d8cb74435b17c9685073b3ddd0aa9e 100644 (file)
@@ -261,7 +261,7 @@ public class InlineToAnonymousClassTest extends LightRefactoringTestCase {
   }
 
   public void testNoInlineMethodUsage() throws Exception {
-    doTestNoInline("Class cannot be inlined because it has usages of methods not inherited from its superclass or interface");
+    doTestNoInline("Class cannot be inlined because there are usages of its methods not inherited from its superclass or interface");
   }
 
   public void testNoInlineFieldUsage() throws Exception {
index f1d4635a8c0e597183d85c21c14d5cd526df4761..8150a1e8720fbf68f30fa5ea99528b4093fd29df 100644 (file)
@@ -25,6 +25,8 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.AtomicNotNullLazyValue;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.GlobalSearchScopes;
+import com.intellij.psi.search.GlobalSearchScopesCore;
 import com.intellij.psi.search.SearchScope;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiTypesUtil;
@@ -218,7 +220,8 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
           return false;
         }
         PsiClass aClass = method.getContainingClass();
-        return aClass != null && GuavaFluentIterableConversionRule.FLUENT_ITERABLE.equals(aClass.getQualifiedName());
+        return aClass != null && (GuavaOptionalConversionRule.GUAVA_OPTIONAL.equals(aClass.getQualifiedName()) ||
+                                  GuavaFluentIterableConversionRule.FLUENT_ITERABLE.equals(aClass.getQualifiedName()));
       }
 
       private PsiMethodCallExpression findGuavaMethodChain(PsiMethodCallExpression expression) {
@@ -352,7 +355,6 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
 
     private static boolean performTypeMigration(List<PsiElement> elements, List<PsiType> types) {
       PsiFile containingFile = null;
-      SearchScope typeMigrationScope = GlobalSearchScope.EMPTY_SCOPE;
       for (PsiElement element : elements) {
         final PsiFile currentContainingFile = element.getContainingFile();
         if (containingFile == null) {
@@ -361,13 +363,13 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
         else {
           LOG.assertTrue(containingFile.isEquivalentTo(currentContainingFile));
         }
-        typeMigrationScope = typeMigrationScope.union(element.getUseScope());
       }
       LOG.assertTrue(containingFile != null);
       if (!FileModificationService.getInstance().prepareFileForWrite(containingFile)) return false;
       try {
         final TypeMigrationRules rules = new TypeMigrationRules();
-        rules.setBoundScope(typeMigrationScope);
+        rules.setBoundScope(GlobalSearchScopesCore.projectProductionScope(containingFile.getProject())
+                              .union(GlobalSearchScopesCore.projectTestScope(containingFile.getProject())));
         TypeMigrationProcessor.runHighlightingTypeMigration(containingFile.getProject(),
                                                             null,
                                                             rules,
index cb714ba10b9f558e929302a29600a7b3d0a5832d..608ba2b4b46f315f767b62a880a7edb620690e14 100644 (file)
@@ -98,8 +98,17 @@ public class GuavaConversionUtil {
       }
       else {
         final GuavaLambda lambda = GuavaLambda.findFor(evaluator.evaluateType(expression));
-        return lambda == null ? expression
-                              : addMethodReference(expression, lambda);
+        if (lambda == null) {
+          return expression;
+        }
+        else {
+          final PsiExpression expressionWithMethodReference = addMethodReference(expression, lambda);
+          if (insertTypeCase) {
+            return adjustLambdaContainingExpression(expressionWithMethodReference, true, targetType, evaluator);
+          } else {
+            return expressionWithMethodReference;
+          }
+        }
       }
     }
     if (expression instanceof PsiMethodReferenceExpression) {
index 9c387f11e865b7e152e195b26a002141dab2abcc..bb4ce3509247894788e618b9e18edd8266e876fd 100644 (file)
@@ -26,7 +26,6 @@ import com.intellij.util.SystemProperties;
 import com.intellij.util.containers.ContainerUtil;
 import com.jgoodies.forms.layout.CellConstraints;
 import io.netty.util.NetUtil;
-import jsr166e.extra.SequenceLock;
 import net.n3.nanoxml.IXMLBuilder;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.builders.impl.java.EclipseCompilerTool;
@@ -144,7 +143,6 @@ public class ClasspathBootstrap {
     cp.add(getResourcePath(CellConstraints.class));  // jGoodies-forms
     cp.add(getResourcePath(NotNullVerifyingInstrumenter.class));  // not-null
     cp.add(getResourcePath(IXMLBuilder.class));  // nano-xml
-    cp.add(getResourcePath(SequenceLock.class));  // jsr166
     cp.add(getJpsPluginSystemClassesPath().getAbsolutePath().replace('\\', '/'));
     
     //don't forget to update layoutCommunityJps() in layouts.gant accordingly
index 5758f2c4db87b6e69de5f058e09dc6c2879f43be..56378e622628e07dd88b9472fa1c105ff9030323 100644 (file)
@@ -49,6 +49,7 @@ public class Main {
   public static final int PLUGIN_ERROR = 8;
   public static final int OUT_OF_MEMORY = 9;
   public static final int UNSUPPORTED_JAVA_VERSION = 10;
+  public static final int PRIVACY_POLICY_REJECTION = 11;
 
   private static final String AWT_HEADLESS = "java.awt.headless";
   private static final String PLATFORM_PREFIX_PROPERTY = "idea.platform.prefix";
index a206e8310e23972575187bd6773ec56620cdacee..54841737ca3f4b9c5f0b5dce66c9c6cfcf996b86 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.openapi.application;
 
 import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.progress.ProcessCanceledException;
 import org.jetbrains.annotations.NotNull;
 
@@ -29,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
  * and process UI events in other ways: it's guaranteed that no one will be able to sneak in with an unexpected model change using
  * {@link javax.swing.SwingUtilities#invokeLater(Runnable)} or analogs.<p/>
  *
- * Transactions are run on UI thread. They have read access by default.<p/>
+ * Transactions are run on UI thread. They have read access by default. All write actions should be performed inside a transaction.<p/>
  *
  * The recommended way to perform a transaction is to invoke {@link #submitTransaction(Runnable)}. It either runs the transaction immediately
  * (if on UI thread and there's no other transaction running) or queues it to invoke at some later moment, when it becomes possible.<p/>
@@ -40,31 +39,43 @@ import org.jetbrains.annotations.NotNull;
  * the main transaction and executed immediately. Use {@link #acceptNestedTransactions(TransactionKind...)} for that. Inner transactions
  * should be given some kind in such circumstances: {@link #submitMergeableTransaction(TransactionKind, Runnable)}.
  *
+ * <p><h1>FAQ</h1></p>
+ *
+ * Q: I've got <b>"Write access is allowed from model transactions only"</b> exception, what do I do?<br/>
+ * A: Add a transaction somewhere into the call stack, to the outermost callee where having read/write model consistency is needed.
+ * If it's a user action, transaction should be synchronous (see {@link #startSynchronousTransaction(TransactionKind)}. For AnAction
+ * inheritors, {@link WrapInTransaction} annotation might be handy. Note that not all actions need to be wrapped into transactions, only
+ * those that require the model to be consistent. For example, actions that display settings dialogs or VCS actions are most likely exempt.
+ * <p/>
+ *
+ * If the exception occurs not inside a user action, it's probably from some kind of "invokeLater".
+ * Then, replace "invokeLater" with {@link #submitTransaction(Runnable)} or
+ * {@link #submitMergeableTransaction(TransactionKind, Runnable)} call.<p/>
+ *
+ * Q: I've got <b>"Nested transactions are not allowed"</b> exception, what do I do?<br/>
+ * A: First, find the place in the stack where the outer transaction is started. Then, see if there is any Swing event pumping
+ * in between two transactions (e.g. a dialog is shown). If not, one of two transactions is superfluous, remove it. If there
+ * is event pumping, check if the client code (e.g. the one showing the dialog) is prepared to the nested model modifications
+ * of the specified kinds. For example, refactoring dialogs might be prepared to {@link TransactionKind#TEXT_EDITING} kind
+ * (for text field editing inside the dialogs) but not
+ * other model changes, e.g. root changes. The outer transaction code might then specify which kinds it's prepared to (by using
+ * {@link #acceptNestedTransactions(TransactionKind...)}), and the inner transaction code should have the very same transaction kind
+ * (by using {@link #submitMergeableTransaction(TransactionKind, Runnable)} or {@link #startSynchronousTransaction(TransactionKind)}).
+ * If the nested transaction is not expected by the outer code, it must be made asynchronous by using either {@link #submitTransaction(Runnable)}
+ * or {@link #submitMergeableTransaction(TransactionKind, Runnable)}.
+ * <p/>
+ *
+ * Q: What's the difference between transactions and read/write actions and commands ({@link com.intellij.openapi.command.CommandProcessor})?<br/>
+ * A: Transactions are more abstract and can contain several write actions and even commands inside. Read/write actions guarantee that no
+ * one else will modify the model, while transactions allow for some modification, but in a way controlled by transaction kinds. Commands
+ * are used for tracking document changes for undo/redo functionality, so they're orthogonal to transactions.
+ *
  * @see Application#runReadAction(Runnable)
  * @see Application#runWriteAction(Runnable)
  * @since 146.*
  * @author peter
  */
 public abstract class TransactionGuard {
-  /**
-   * This kind represents document modifications via editor actions, code completion and document->PSI commit.
-   * @see com.intellij.psi.PsiDocumentManager#commitDocument(Document)
-   */
-  public static final TransactionKind TEXT_EDITING = new TransactionKind("TEXT_EDITING");
-  /**
-   * This kind represents any model modifications:
-   * <li>PSI or document changes
-   * <li>Virtual file system changes, e.g. files created/deleted/renamed/content-changed,
-   * caused by refresh process or explicit operations.
-   * <li>Project root set change
-   * <li>Dumb mode (reindexing) start/finish, (see {@link com.intellij.openapi.project.DumbService}).
-   */
-  public static final TransactionKind ANY_CHANGE = new TransactionKind("ANY_CHANGE");
-
-  /**
-   * Transactions of this kind won't be merged into other transactions
-   */
-  public static final TransactionKind NO_MERGE = new TransactionKind("NO_MERGE");
 
   public static TransactionGuard getInstance() {
     return ServiceManager.getService(TransactionGuard.class);
@@ -75,12 +86,12 @@ public abstract class TransactionGuard {
    * The code will be run on Swing thread immediately or after all other queued transactions (if any) have been completed.<p/>
    *
    * For more advanced version, see {@link #submitMergeableTransaction(TransactionKind, Runnable)}.
-   * Transactions submitted via this method use {@link #NO_MERGE} kind.
+   * Transactions submitted via this method use {@link TransactionKind#NO_MERGE} kind.
    *
    * @param transaction code to execute inside a transaction.
    */
   public static void submitTransaction(@NotNull Runnable transaction) {
-    getInstance().submitMergeableTransaction(NO_MERGE, transaction);
+    getInstance().submitMergeableTransaction(TransactionKind.NO_MERGE, transaction);
   }
 
   /**
@@ -110,7 +121,7 @@ public abstract class TransactionGuard {
    * and executes the provided code immediately. Otherwise
    * adds the runnable to a queue. When all transactions scheduled before this one are finished, executes the given
    * runnable under a transaction.
-   * @param kind a kind object to enable transaction merging or {@link #NO_MERGE}, if no merging is required.
+   * @param kind a kind object to enable transaction merging or {@link TransactionKind#NO_MERGE}, if no merging is required.
    * @param transaction code to execute inside a transaction.
    */
   public abstract void submitMergeableTransaction(@NotNull TransactionKind kind, @NotNull Runnable transaction);
@@ -126,20 +137,4 @@ public abstract class TransactionGuard {
    */
   @NotNull
   public abstract AccessToken acceptNestedTransactions(TransactionKind... kinds);
-
-  /**
-   * A kind of transaction used in {@link #acceptNestedTransactions(TransactionKind...)}
-   */
-  public static final class TransactionKind {
-    private final String myName;
-
-    public TransactionKind(@NotNull String name) {
-      myName = name;
-    }
-
-    @Override
-    public String toString() {
-      return myName;
-    }
-  }
 }
diff --git a/platform/core-api/src/com/intellij/openapi/application/TransactionKind.java b/platform/core-api/src/com/intellij/openapi/application/TransactionKind.java
new file mode 100644 (file)
index 0000000..bc7d3be
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.application;
+
+import com.intellij.openapi.editor.Document;
+
+/**
+ * A kind of transaction used in {@link TransactionGuard#submitMergeableTransaction(TransactionKind, Runnable)}
+ * and {@link TransactionGuard#acceptNestedTransactions(TransactionKind...)}.
+ */
+public interface TransactionKind {
+  /**
+   * Same as {@link Common#TEXT_EDITING}
+   */
+  TransactionKind TEXT_EDITING = Common.TEXT_EDITING;
+
+  /**
+   * Same as {@link Common#NO_MERGE}
+   */
+  TransactionKind NO_MERGE = Common.NO_MERGE;
+
+  /**
+   * Same as {@link Common#ANY_CHANGE}
+   */
+  TransactionKind ANY_CHANGE = Common.ANY_CHANGE;
+
+  /**
+   * An auxiliary enum to make it possible to use transaction kinds in annotations
+   */
+  enum Common implements TransactionKind {
+
+    /**
+     * This kind represents document modifications via editor actions, code completion and document->PSI commit.
+     * @see com.intellij.psi.PsiDocumentManager#commitDocument(Document)
+     */
+    TEXT_EDITING,
+
+    /**
+     * This kind represents any model modifications:
+     * <li>PSI or document changes
+     * <li>Virtual file system changes, e.g. files created/deleted/renamed/content-changed,
+     * caused by refresh process or explicit operations.
+     * <li>Project root set change
+     * <li>Dumb mode (reindexing) start/finish, (see {@link com.intellij.openapi.project.DumbService}).
+     */
+    ANY_CHANGE,
+
+    /**
+     * Transactions of this kind won't be merged into other transactions
+     */
+    NO_MERGE
+  }
+}
diff --git a/platform/core-api/src/com/intellij/openapi/application/WrapInTransaction.java b/platform/core-api/src/com/intellij/openapi/application/WrapInTransaction.java
new file mode 100644 (file)
index 0000000..711dc54
--- /dev/null
@@ -0,0 +1,22 @@
+package com.intellij.openapi.application;
+
+import java.lang.annotation.*;
+
+/**
+ * Add this annotation to actions (AnAction inheritors) to make them run inside a transaction.
+ *
+ * @see TransactionGuard
+ * @since 146.*
+ * @author peter
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface WrapInTransaction {
+
+  /**
+   * @return the kind of transaction to wrap the action into. By default, it's {@link TransactionKind#NO_MERGE}.
+   */
+  TransactionKind.Common value() default TransactionKind.Common.NO_MERGE;
+}
index a1d6a2b93426f4158b111d5b08981e837157fd79..2ef795bcc7f750da940e9803f53d352b0846a5bf 100644 (file)
@@ -596,7 +596,11 @@ public class PluginManagerCore {
           // check for missing optional dependency
           IdeaPluginDescriptor dep = idToDescriptorMap.get(dependentPluginId);
           if (dep != null) {
-            plugins.add(dep.getPluginId());
+            //if 'dep' refers to a module we need to add the real plugin containing this module only if it's still enabled, otherwise the graph will be inconsistent
+            PluginId realPluginId = dep.getPluginId();
+            if (idToDescriptorMap.containsKey(realPluginId)) {
+              plugins.add(realPluginId);
+            }
           }
         }
         return plugins.iterator();
index 71ca6baf3aca2c39b0e31f25359396312493506f..3d627e9956f0f7924f5d9a644ca59e63c2f23da3 100644 (file)
@@ -39,7 +39,7 @@ public class TransactionGuardImpl extends TransactionGuard {
   @NotNull
   public AccessToken startSynchronousTransaction(@NotNull TransactionKind kind) throws IllegalStateException {
     ApplicationManager.getApplication().assertIsDispatchThread();
-    if (kind != NO_MERGE && myMergeableKinds.contains(kind)) {
+    if (kind != TransactionKind.NO_MERGE && myMergeableKinds.contains(kind)) {
       return AccessToken.EMPTY_ACCESS_TOKEN;
     }
     if (myInsideTransaction) {
@@ -68,7 +68,7 @@ public class TransactionGuardImpl extends TransactionGuard {
 
         Runnable next = myQueue.poll();
         if (next != null) {
-          runSyncTransaction(NO_MERGE, next);
+          runSyncTransaction(TransactionKind.NO_MERGE, next);
         }
       }
     }, app.getDisposed());
@@ -95,7 +95,7 @@ public class TransactionGuardImpl extends TransactionGuard {
     Runnable runnable = new Runnable() {
       @Override
       public void run() {
-        if (!myInsideTransaction || kind != NO_MERGE && myMergeableKinds.contains(kind)) {
+        if (!myInsideTransaction || kind != TransactionKind.NO_MERGE && myMergeableKinds.contains(kind)) {
           runSyncTransaction(kind, transaction);
         }
         else {
index c783e893bc71fac5980047d7c7dd341bef3d4218..9f05ccca431c4cdfe1e042ede704d61896afd364 100644 (file)
@@ -129,6 +129,13 @@ public enum Side {
     return isLeft() ? region.first : region.second;
   }
 
+  @Nullable
+  public static <T> Side fromValue(@NotNull List<? extends T> list, @Nullable T value) {
+    assert list.size() == 2;
+    int index = list.indexOf(value);
+    return index != -1 ? fromIndex(index) : null;
+  }
+
   //
   // Fragments
   //
index 3042b3dc14f722fe9fc3765e141a14fca34accd9..246a5412407531fe85180b0bea2c891ecbaaa980 100644 (file)
@@ -92,4 +92,11 @@ public enum ThreeSide {
     assert list.size() == 3;
     return list.get(myIndex);
   }
+
+  @Nullable
+  public static <T> ThreeSide fromValue(@NotNull List<? extends T> list, @Nullable T value) {
+    assert list.size() == 3;
+    int index = list.indexOf(value);
+    return index != -1 ? fromIndex(index) : null;
+  }
 }
index dd87bc97c4de94e6377dcc4c4e7e3b68beba9d88..ab74baa42318573d8798b2f240bc4e6f41a28df0 100644 (file)
@@ -46,8 +46,6 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
 
   @NotNull private final TextMergeViewer myMergeViewer;
   @NotNull private final TextMergeViewer.MyThreesideViewer myViewer;
-  @NotNull private final List<RangeHighlighter> myHighlighters = new ArrayList<RangeHighlighter>();
-  @NotNull private final List<RangeHighlighter> myInnerHighlighters = new ArrayList<RangeHighlighter>();
 
   @NotNull private final List<MyGutterOperation> myOperations = new ArrayList<MyGutterOperation>();
 
@@ -59,8 +57,7 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
   private final boolean[] myResolved = new boolean[2];
   private boolean myOnesideAppliedConflict;
 
-  @Nullable private List<MergeWordFragment> myInnerFragments;
-  private boolean myInnerFragmentsDamaged;
+  @Nullable private List<MergeWordFragment> myInnerFragments; // warning: might be out of date
 
   @CalledInAwt
   public TextMergeChange(@NotNull MergeLineFragment fragment, int index, @NotNull TextMergeViewer viewer) {
@@ -73,95 +70,27 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
     myStartLine = myFragment.getStartLine(ThreeSide.BASE);
     myEndLine = myFragment.getEndLine(ThreeSide.BASE);
 
-    installHighlighter();
+    reinstallHighlighters();
   }
 
   @CalledInAwt
   public void destroy() {
-    destroyHighlighter();
-    destroyInnerHighlighter();
+    destroyHighlighters();
+    destroyOperations();
+    destroyInnerHighlighters();
   }
 
   @CalledInAwt
-  private void installHighlighter() {
-    assert myHighlighters.isEmpty();
+  public void reinstallHighlighters() {
+    destroyHighlighters();
+    installHighlighters();
 
-    createHighlighter(ThreeSide.BASE);
-    if (getType().isLeftChange()) createHighlighter(ThreeSide.LEFT);
-    if (getType().isRightChange()) createHighlighter(ThreeSide.RIGHT);
-
-    doInstallActionHighlighters();
-  }
-
-  @CalledInAwt
-  private void installInnerHighlighter() {
-    assert myInnerHighlighters.isEmpty();
-
-    createInnerHighlighter(ThreeSide.BASE);
-    if (getType().isLeftChange()) createInnerHighlighter(ThreeSide.LEFT);
-    if (getType().isRightChange()) createInnerHighlighter(ThreeSide.RIGHT);
-  }
-
-  @CalledInAwt
-  private void destroyHighlighter() {
-    for (RangeHighlighter highlighter : myHighlighters) {
-      highlighter.dispose();
-    }
-    myHighlighters.clear();
-
-    for (MyGutterOperation operation : myOperations) {
-      operation.dispose();
-    }
-    myOperations.clear();
-  }
-
-  @CalledInAwt
-  private void destroyInnerHighlighter() {
-    for (RangeHighlighter highlighter : myInnerHighlighters) {
-      highlighter.dispose();
-    }
-    myInnerHighlighters.clear();
-  }
-
-  @CalledInAwt
-  public void doReinstallHighlighter() {
-    destroyHighlighter();
-    installHighlighter();
-
-    if (!myInnerFragmentsDamaged) {
-      destroyInnerHighlighter();
-      installInnerHighlighter();
-    }
+    destroyOperations();
+    installOperations();
 
     myViewer.repaintDividers();
   }
 
-  private void createHighlighter(@NotNull ThreeSide side) {
-    Editor editor = side.select(myViewer.getEditors());
-
-    TextDiffType type = getDiffType();
-    boolean resolved = isResolved(side);
-    int startLine = getStartLine(side);
-    int endLine = getEndLine(side);
-
-    boolean ignored = !resolved && myInnerFragments != null;
-    myHighlighters.addAll(DiffDrawUtil.createHighlighter(editor, startLine, endLine, type, ignored, resolved));
-    myHighlighters.addAll(DiffDrawUtil.createLineMarker(editor, startLine, endLine, type, resolved));
-  }
-
-  private void createInnerHighlighter(@NotNull ThreeSide side) {
-    if (isResolved(side)) return;
-    if (myInnerFragments == null) return;
-
-    Editor editor = myViewer.getEditor(side);
-    int start = DiffUtil.getLinesRange(editor.getDocument(), getStartLine(side), getEndLine(side)).getStartOffset();
-    for (MergeWordFragment fragment : myInnerFragments) {
-      int innerStart = start + fragment.getStartOffset(side);
-      int innerEnd = start + fragment.getEndOffset(side);
-      myInnerHighlighters.addAll(DiffDrawUtil.createInlineHighlighter(editor, innerStart, innerEnd, getDiffType()));
-    }
-  }
-
   //
   // Getters
   //
@@ -174,9 +103,8 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
   void setResolved(@NotNull Side side, boolean value) {
     myResolved[side.getIndex()] = value;
 
-    markInnerFragmentsDamaged();
     if (isResolved()) {
-      destroyInnerHighlighter();
+      destroyInnerHighlighters();
     }
     else {
       // Destroy only resolved side to reduce blinking
@@ -205,6 +133,7 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
     myOnesideAppliedConflict = true;
   }
 
+  @Override
   public boolean isResolved(@NotNull ThreeSide side) {
     switch (side) {
       case LEFT:
@@ -246,16 +175,27 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
     myEndLine = value;
   }
 
-  public void markInnerFragmentsDamaged() {
-    myInnerFragmentsDamaged = true;
+  @NotNull
+  @Override
+  protected Editor getEditor(@NotNull ThreeSide side) {
+    return myViewer.getEditor(side);
+  }
+
+  @Nullable
+  @Override
+  protected List<MergeWordFragment> getInnerFragments() {
+    return myInnerFragments;
   }
 
   @CalledInAwt
   public void setInnerFragments(@Nullable List<MergeWordFragment> innerFragments) {
-    myInnerFragmentsDamaged = false;
     if (myInnerFragments == null && innerFragments == null) return;
     myInnerFragments = innerFragments;
-    doReinstallHighlighter();
+
+    reinstallHighlighters();
+
+    destroyInnerHighlighters();
+    installInnerHighlighters();
   }
 
   //
@@ -288,13 +228,22 @@ public class TextMergeChange extends ThreesideDiffChangeBase {
   // Gutter actions
   //
 
-  private void doInstallActionHighlighters() {
+  @CalledInAwt
+  private void installOperations() {
     ContainerUtil.addIfNotNull(myOperations, createOperation(ThreeSide.LEFT, OperationType.APPLY));
     ContainerUtil.addIfNotNull(myOperations, createOperation(ThreeSide.LEFT, OperationType.IGNORE));
     ContainerUtil.addIfNotNull(myOperations, createOperation(ThreeSide.RIGHT, OperationType.APPLY));
     ContainerUtil.addIfNotNull(myOperations, createOperation(ThreeSide.RIGHT, OperationType.IGNORE));
   }
 
+  @CalledInAwt
+  private void destroyOperations() {
+    for (MyGutterOperation operation : myOperations) {
+      operation.dispose();
+    }
+    myOperations.clear();
+  }
+
   @Nullable
   private MyGutterOperation createOperation(@NotNull ThreeSide side, @NotNull OperationType type) {
     if (isResolved(side)) return null;
index 2253abf942b151011bdb6083ac628131cf43b5d3..504c0502e01276d5f33e60106cccf6b35c44c68e 100644 (file)
@@ -439,6 +439,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
     }
 
     @Override
+    @CalledInAwt
     protected void destroyChangedBlocks() {
       super.destroyChangedBlocks();
       myInnerDiffWorker.stop();
@@ -496,6 +497,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
         }
       }
 
+      @CalledInAwt
       public void stop() {
         if (myProgress != null) myProgress.cancel();
         myProgress = null;
@@ -503,6 +505,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
         myAlarm.cancelAllRequests();
       }
 
+      @CalledInAwt
       private void putChanges(@NotNull Collection<TextMergeChange> changes) {
         for (TextMergeChange change : changes) {
           if (change.isResolved()) continue;
@@ -594,10 +597,8 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
       enterBulkChangeUpdateBlock();
       if (myAllMergeChanges.isEmpty()) return;
 
-      ThreeSide side = null;
-      if (e.getDocument() == getEditor(ThreeSide.LEFT).getDocument()) side = ThreeSide.LEFT;
-      if (e.getDocument() == getEditor(ThreeSide.RIGHT).getDocument()) side = ThreeSide.RIGHT;
-      if (e.getDocument() == getEditor(ThreeSide.BASE).getDocument()) side = ThreeSide.BASE;
+      List<Document> documents = ContainerUtil.map(getEditors(), Editor::getDocument);
+      ThreeSide side = ThreeSide.fromValue(documents, e.getDocument());
       if (side == null) {
         LOG.warn("Unknown document changed");
         return;
@@ -649,8 +650,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
         myChangesToUpdate.add(change);
       }
       else {
-        change.markInnerFragmentsDamaged();
-        change.doReinstallHighlighter();
+        change.reinstallHighlighters();
         myInnerDiffWorker.scheduleRediff(change);
       }
     }
@@ -667,8 +667,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
 
       if (myBulkChangeUpdateDepth == 0) {
         for (TextMergeChange change : myChangesToUpdate) {
-          change.markInnerFragmentsDamaged();
-          change.doReinstallHighlighter();
+          change.reinstallHighlighters();
         }
         myInnerDiffWorker.scheduleRediff(myChangesToUpdate);
         myChangesToUpdate.clear();
index 5c866d44c81efbab3a4f018e32c0c3758d85420c..850947431cfcea6651f983e6c8e2dd610b1b4e0d 100644 (file)
@@ -47,6 +47,7 @@ import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.UserDataHolder;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.*;
 
 import javax.swing.*;
@@ -57,6 +58,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import static com.intellij.diff.util.DiffUtil.getLineCount;
+import static com.intellij.util.ObjectUtils.assertNotNull;
 
 public class SimpleDiffViewer extends TwosideTextDiffViewer {
   public static final Logger LOG = Logger.getInstance(SimpleDiffViewer.class);
@@ -309,9 +311,8 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
     super.onBeforeDocumentChange(e);
     if (myDiffChanges.isEmpty()) return;
 
-    Side side = null;
-    if (e.getDocument() == getEditor(Side.LEFT).getDocument()) side = Side.LEFT;
-    if (e.getDocument() == getEditor(Side.RIGHT).getDocument()) side = Side.RIGHT;
+    List<Document> documents = ContainerUtil.map(getEditors(), Editor::getDocument);
+    Side side = Side.fromValue(documents, e.getDocument());
     if (side == null) {
       LOG.warn("Unknown document changed");
       return;
@@ -525,13 +526,8 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
       }
 
       Editor editor = e.getData(CommonDataKeys.EDITOR);
-      if (editor != getEditor1() && editor != getEditor2()) {
-        e.getPresentation().setEnabledAndVisible(false);
-        return;
-      }
-
-      Side side = Side.fromLeft(editor == getEditor(Side.LEFT));
-      if (!isVisible(side)) {
+      Side side = Side.fromValue(getEditors(), editor);
+      if (side == null || !isVisible(side)) {
         e.getPresentation().setEnabledAndVisible(false);
         return;
       }
@@ -551,9 +547,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
     @Override
     public void actionPerformed(@NotNull final AnActionEvent e) {
       Editor editor = e.getData(CommonDataKeys.EDITOR);
-      if (editor != getEditor1() && editor != getEditor2()) return;
-
-      final Side side = Side.fromLeft(editor == getEditor(Side.LEFT));
+      final Side side = assertNotNull(Side.fromValue(getEditors(), editor));
       final List<SimpleDiffChange> selectedChanges = getSelectedChanges(side);
       if (selectedChanges.isEmpty()) return;
 
index 88d2eb1fbd919dda8e89d91f52adb37cf4b3c8a9..a50348720b6590607dd00188ed2b10de908b87bc 100644 (file)
@@ -18,24 +18,20 @@ package com.intellij.diff.tools.simple;
 import com.intellij.diff.comparison.ComparisonPolicy;
 import com.intellij.diff.fragments.MergeLineFragment;
 import com.intellij.diff.fragments.MergeWordFragment;
-import com.intellij.diff.util.DiffDrawUtil;
 import com.intellij.diff.util.DiffUtil;
-import com.intellij.diff.util.TextDiffType;
 import com.intellij.diff.util.ThreeSide;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.ex.EditorEx;
-import com.intellij.openapi.editor.markup.RangeHighlighter;
+import org.jetbrains.annotations.CalledInAwt;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-import java.util.ArrayList;
 import java.util.List;
 
 public class SimpleThreesideDiffChange extends ThreesideDiffChangeBase {
   @NotNull private final List<? extends EditorEx> myEditors;
   @NotNull private final MergeLineFragment myFragment;
 
-  @NotNull private final List<RangeHighlighter> myHighlighters = new ArrayList<RangeHighlighter>();
-
   private int[] myLineStartShifts = new int[3];
   private int[] myLineEndShifts = new int[3];
 
@@ -46,48 +42,22 @@ public class SimpleThreesideDiffChange extends ThreesideDiffChangeBase {
     myEditors = editors;
     myFragment = fragment;
 
-    installHighlighter();
+    reinstallHighlighters();
   }
 
-  public void installHighlighter() {
-    assert myHighlighters.isEmpty();
-
-    createHighlighter(ThreeSide.BASE);
-    if (getType().isLeftChange()) createHighlighter(ThreeSide.LEFT);
-    if (getType().isRightChange()) createHighlighter(ThreeSide.RIGHT);
+  @CalledInAwt
+  public void destroy() {
+    destroyHighlighters();
+    destroyInnerHighlighters();
   }
 
-  public void destroyHighlighter() {
-    for (RangeHighlighter highlighter : myHighlighters) {
-      highlighter.dispose();
-    }
-    myHighlighters.clear();
-  }
-
-  //
-  // Highlighting
-  //
-
-  private void createHighlighter(@NotNull ThreeSide side) {
-    Editor editor = side.select(myEditors);
-
-    TextDiffType type = getDiffType();
-    int startLine = myFragment.getStartLine(side);
-    int endLine = myFragment.getEndLine(side);
-    boolean hasInner = myFragment.getInnerFragments() != null;
-
-    int start = DiffUtil.getLinesRange(editor.getDocument(), startLine, endLine).getStartOffset();
-
-    myHighlighters.addAll(DiffDrawUtil.createHighlighter(editor, startLine, endLine, type, hasInner));
-    myHighlighters.addAll(DiffDrawUtil.createLineMarker(editor, startLine, endLine, type, false));
+  @CalledInAwt
+  public void reinstallHighlighters() {
+    destroyHighlighters();
+    installHighlighters();
 
-    if (hasInner) {
-      for (MergeWordFragment innerFragment : myFragment.getInnerFragments()) {
-        int startOffset = innerFragment.getStartOffset(side);
-        int endOffset = innerFragment.getEndOffset(side);
-        myHighlighters.addAll(DiffDrawUtil.createInlineHighlighter(editor, start + startOffset, start + endOffset, type));
-      }
-    }