Merge remote-tracking branch 'origin/master' into amakeev/cmake-configs
authorAnton Makeev <Anton.Makeev@jetbrains.com>
Tue, 27 Sep 2016 14:07:43 +0000 (16:07 +0200)
committerAnton Makeev <Anton.Makeev@jetbrains.com>
Tue, 27 Sep 2016 14:07:43 +0000 (16:07 +0200)
565 files changed:
.idea/inspectionProfiles/idea_default.xml
.idea/modules.xml
bin/linux/restart.py [new file with mode: 0755]
bin/scripts/unix/idea.sh
build/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy
build/groovy/org/jetbrains/intellij/build/impl/CrossPlatformDistributionBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy
build/scripts/download_kotlin.gant
build/scripts/utils.gant
build/update.sh
java/compiler/javac2/src/com/intellij/ant/Javac2.java
java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java
java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java
java/debugger/impl/src/com/intellij/debugger/engine/ContextUtil.java
java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
java/debugger/impl/src/com/intellij/debugger/engine/evaluation/CodeFragmentFactoryContextWrapper.java
java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java
java/debugger/impl/src/com/intellij/debugger/impl/ReloadClassesWorker.java
java/debugger/impl/src/com/intellij/debugger/ui/HotSwapProgressImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/ValueHint.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/EvaluationDescriptor.java
java/debugger/impl/src/com/intellij/debugger/ui/tree/render/CachedEvaluator.java
java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java
java/debugger/openapi/src/com/intellij/debugger/engine/DebugProcess.java
java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java
java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfiguration.java
java/execution/impl/src/com/intellij/execution/testframework/JavaTestLocator.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathTableModel.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ModuleHighlightUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/PostHighlightingVisitor.java
java/java-analysis-impl/src/com/intellij/codeInspection/OptionalIsPresentInspection.java
java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaPsiUtil.java
java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java
java/java-analysis-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerBase.java
java/java-analysis-impl/src/com/intellij/codeInspection/java18api/Java8CollectionsApiInspection.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/MigrateToStreamFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/ReplaceWithCollectFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/ReplaceWithCountFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/ReplaceWithFindFirstFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/ReplaceWithForeachCallFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/ReplaceWithMatchFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/ReplaceWithSumFix.java
java/java-analysis-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java
java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingOptionsProvider.java
java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingSettingsPanel.form [deleted file]
java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingSettingsPanel.java [deleted file]
java/java-impl/src/com/intellij/codeInsight/JavaTargetElementEvaluator.java
java/java-impl/src/com/intellij/codeInsight/completion/StaticMemberProcessor.java
java/java-impl/src/com/intellij/codeInsight/daemon/JavaProblemHighlightFilter.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/ParameterHintsPassFactory.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/ParameterHintsPresentationManager.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/ParameterNameHintsManager.java [moved from java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/ParameterNameHintsManager.java with 90% similarity]
java/java-impl/src/com/intellij/codeInsight/daemon/impl/ParameterNameInlays.kt [moved from java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/ParameterNameInlays.kt with 100% similarity]
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExternalLibraryToDependenciesQuickFix.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddLibraryToDependenciesFix.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddOrderEntryFix.java [moved from platform/lang-impl/src/com/intellij/ide/util/gotoByName/EdtSortingModel.java with 61% similarity]
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageBaseFix.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMemberFix.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticMembersProcessor.java
java/java-impl/src/com/intellij/codeInsight/generation/GenerateDelegateHandler.java
java/java-impl/src/com/intellij/codeInspection/RemoveInitializerFix.java
java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java
java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
java/java-impl/src/com/intellij/ide/scopeView/nodes/ClassNode.java
java/java-impl/src/com/intellij/ide/scopeView/nodes/FieldNode.java
java/java-impl/src/com/intellij/ide/scopeView/nodes/MemberNode.java [new file with mode: 0644]
java/java-impl/src/com/intellij/ide/scopeView/nodes/MethodNode.java
java/java-impl/src/com/intellij/openapi/vfs/impl/jrt/JrtFileSystem.java
java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiPackageReference.java
java/java-impl/src/com/intellij/psi/util/proximity/ExplicitlyImportedWeigher.java
java/java-impl/src/com/intellij/refactoring/extractInterface/ExtractClassUtil.java
java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/introduceField/ElementToWorkOn.java
java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceConstantPopup.java
java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java
java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java
java/java-impl/src/com/intellij/refactoring/introduceParameter/Util.java
java/java-impl/src/com/intellij/refactoring/migration/MigrationMapSet.java
java/java-impl/src/com/intellij/reporting/ReportMissingOrExcessiveInlineHint.kt
java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaNullMethodArgumentIndex.java
java/java-psi-api/src/com/intellij/codeInsight/folding/JavaCodeFoldingSettings.java
java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaCodeFoldingSettingsBase.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/file/impl/JavaFileManager.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaModuleReference.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution3.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/afterReturnTypeChanged.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/beforeReturnTypeChanged.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalIsPresent/afterAssignmentMap.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalIsPresent/afterReturnComments.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalIsPresent/beforeAssignmentMap.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalIsPresent/beforeReturnNonFinalUsed.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAllMatchContinue.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnyMatchAssignment.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnyMatchAssignmentBoolean.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnyMatchAssignmentBooleanInverted.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnyMatchAssignmentNonTrivial.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnyMatchMethodCall.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAnyMatchPrimitive.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectBoxed.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectToObj.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCountPrimitiveArray.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterFindFirstAssignmentCast.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterFindFirstBoolean.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterFindFirstCast.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterFindFirstPrimitive.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterFindFirstTernary.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterFlatten2DArrayPrimitive.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMissedBraces.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNoneMatchContinue.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterSumPrimitive.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterSumPromotion.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAllMatchContinue.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchAssignment.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchAssignmentBoolean.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchAssignmentBooleanInverted.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchAssignmentNonTrivial.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchFloat.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchMethodCall.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeAnyMatchPrimitive.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectBoxed.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectToObj.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCountPrimitiveArray.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCountShortArray.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFindFirstAssignmentCast.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFindFirstBoolean.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFindFirstCast.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFindFirstPrimitive.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFindFirstPrimitiveNonTrivial.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFindFirstTernary.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeFlatten2DArrayPrimitive.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMissedBraces.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNoneMatchContinue.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeSumPrimitive.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeSumPromotion.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/delegateMethods/afterInsideLambdaWithNonInferredTypeParameters.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/delegateMethods/beforeInsideLambdaWithNonInferredTypeParameters.java [new file with mode: 0644]
java/java-tests/testData/inspection/dataFlow/fixture/ParanoidMode.java
java/java-tests/testData/inspection/java8CollectionsApi/afterIteratorRemoveFor.java [new file with mode: 0644]
java/java-tests/testData/inspection/java8CollectionsApi/afterIteratorRemoveWhile.java [new file with mode: 0644]
java/java-tests/testData/inspection/java8CollectionsApi/beforeIteratorRemoveFor.java [new file with mode: 0644]
java/java-tests/testData/inspection/java8CollectionsApi/beforeIteratorRemoveWhile.java [new file with mode: 0644]
java/java-tests/testData/inspection/java8CollectionsApi/beforeIteratorRemoveWhileReused.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/NormalExitIf.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/NormalExitIf_after.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/NormalExitTry.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/NormalExitTry_after.java [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceFunctionalParameter/afterUsedParametersOutsideSelectedFragment.java [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceFunctionalParameter/beforeUsedParametersOutsideSelectedFragment.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/DelegateMethodsTest.java
java/java-tests/testSrc/com/intellij/codeInsight/completion/ModuleCompletionTest.kt
java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.kt
java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleRenameTest.kt [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/InlayParameterHintsTest.kt
java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StaticImportMethodWithCommonNameTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionSchemeTest.kt
java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt
java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
java/java-tests/testSrc/com/intellij/refactoring/IntroduceFunctionalParameterTest.java
java/java-tests/testSrc/com/intellij/testFramework/fixtures/LightJava9ModulesCodeInsightFixtureTestCase.kt [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/testFramework/fixtures/MultiModuleJava9ProjectDescriptor.kt
java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java
java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ReadPredicate.java
java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/WritePredicate.java
java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java
java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToAtomicIntention.java
java/typeMigration/src/com/intellij/refactoring/typeMigration/rules/AtomicConversionRule.java
java/typeMigration/testData/intentions/atomic/afterAssignmentOp.java [new file with mode: 0644]
java/typeMigration/testData/intentions/atomic/beforeAssignmentOp.java [new file with mode: 0644]
java/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.items
java/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.java
jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java
jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleIndexImpl.java
platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java
platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java
platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java
platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/IntentionActionFilter.java [new file with mode: 0644]
platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingLevelManager.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java
platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
platform/analysis-impl/src/com/intellij/profile/codeInspection/BaseInspectionProfileManager.kt
platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java
platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java
platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt
platform/analysis-impl/src/com/intellij/psi/IntentionFilterOwnerActionFilter.java [new file with mode: 0644]
platform/bootstrap/src/com/intellij/idea/Main.java
platform/configuration-store-impl/configuration-store-impl.iml
platform/configuration-store-impl/src/ComponentStoreImpl.kt
platform/configuration-store-impl/src/ExportSettingsAction.kt
platform/configuration-store-impl/src/FileBasedStorage.kt
platform/configuration-store-impl/src/ProjectStoreImpl.kt
platform/configuration-store-impl/src/SchemeManagerImpl.kt
platform/configuration-store-impl/src/schemeLoader.kt [new file with mode: 0644]
platform/configuration-store-impl/src/vcs/StoreIgnoredFileProvider.kt [new file with mode: 0644]
platform/configuration-store-impl/testSrc/ApplicationStoreTest.kt
platform/configuration-store-impl/testSrc/SchemeManagerTest.kt
platform/core-api/src/com/intellij/openapi/fileTypes/PeripheralFileType.java [new file with mode: 0644]
platform/core-api/src/com/intellij/psi/PsiReferenceBase.java
platform/core-api/src/com/intellij/ui/LayeredIcon.java
platform/core-api/src/com/intellij/ui/RowIcon.java
platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java
platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
platform/core-impl/src/com/intellij/openapi/editor/impl/FrozenDocument.java
platform/core-impl/src/com/intellij/openapi/editor/impl/event/DocumentEventImpl.java
platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/diff-impl/diff-impl.iml
platform/diff-impl/src/com/intellij/diff/contents/DiffPsiFileType.java [new file with mode: 0644]
platform/diff-impl/src/com/intellij/diff/contents/FileAwareDocumentContent.java
platform/diff-impl/src/com/intellij/diff/tools/util/side/TwosideTextDiffViewer.java
platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java
platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java
platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsStatusWidget.java
platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindnessSupport.java [new file with mode: 0644]
platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalProjectsManager.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalSystemTaskActivator.java
platform/icons/src/debugger/question_badge.png [new file with mode: 0644]
platform/icons/src/debugger/question_badge@2x.png [new file with mode: 0644]
platform/icons/src/debugger/question_badge@2x_dark.png [new file with mode: 0644]
platform/icons/src/debugger/question_badge_dark.png [new file with mode: 0644]
platform/lang-api/src/com/intellij/codeInsight/daemon/impl/analysis/DefaultHighlightingSettingProvider.java [moved from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/DefaultHighlightingSettingProvider.java with 100% similarity]
platform/lang-api/src/com/intellij/codeInsight/daemon/impl/analysis/FileHighlightingSetting.java [moved from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/FileHighlightingSetting.java with 100% similarity]
platform/lang-api/src/com/intellij/execution/configurations/ModuleRunProfile.java
platform/lang-api/src/com/intellij/execution/configurations/SearchScopeProvider.java
platform/lang-api/src/com/intellij/execution/configurations/SearchScopeProvidingRunProfile.java
platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java
platform/lang-impl/src/com/intellij/application/options/colors/ConsoleFontOptions.java
platform/lang-impl/src/com/intellij/application/options/colors/FontOptions.java
platform/lang-impl/src/com/intellij/application/options/colors/ScopeColorsPageFactory.java
platform/lang-impl/src/com/intellij/application/options/editor/EditorAppearanceConfigurable.form
platform/lang-impl/src/com/intellij/application/options/editor/EditorAppearanceConfigurable.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ChameleonSyntaxHighlightingPass.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java
platform/lang-impl/src/com/intellij/codeInspection/InspectionApplication.java
platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java
platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java
platform/lang-impl/src/com/intellij/execution/filters/AbstractFileHyperlinkFilter.java
platform/lang-impl/src/com/intellij/execution/filters/PatternBasedFileHyperlinkRawDataFinder.java
platform/lang-impl/src/com/intellij/ide/actions/GotoActionAction.java
platform/lang-impl/src/com/intellij/ide/actions/QuickChangeInspectionProfileAction.java
platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesPopupAction.java
platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileType.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionItemProvider.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java
platform/lang-impl/src/com/intellij/internal/statistic/editor/EditorSettingsStatisticsCollector.java
platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeRenderer.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ThreeStateCheckBoxRenderer.java
platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemesImpl.java
platform/lang-impl/src/com/intellij/refactoring/actions/RefactoringQuickListPopupAction.java
platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
platform/lang-impl/src/com/intellij/refactoring/rename/inplace/MemberInplaceRenamer.java
platform/lang-impl/src/com/intellij/ui/ShowSplashAction.java
platform/platform-api/src/com/intellij/ide/actions/QuickSwitchSchemeAction.java
platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java
platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java
platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java
platform/platform-api/src/com/intellij/ui/BooleanTableCellRenderer.java
platform/platform-api/src/com/intellij/util/io/HttpRequests.java
platform/platform-impl/src/com/intellij/diagnostic/errordialog/DetailsTabForm.form
platform/platform-impl/src/com/intellij/diagnostic/errordialog/PluginConflictDialog.form
platform/platform-impl/src/com/intellij/diagnostic/errordialog/PluginConflictDialog.java
platform/platform-impl/src/com/intellij/help/impl/ShowProductVersion.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/SystemHealthMonitor.java
platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java
platform/platform-impl/src/com/intellij/ide/actions/OpenFileAction.java
platform/platform-impl/src/com/intellij/ide/actions/QuickChangeSchemesAction.java
platform/platform-impl/src/com/intellij/ide/actions/SaveAllAction.java
platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java
platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java
platform/platform-impl/src/com/intellij/ide/plugins/PluginTable.java
platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java
platform/platform-impl/src/com/intellij/ide/ui/ColorBlindnessPanel.java
platform/platform-impl/src/com/intellij/ide/ui/customization/CustomizableActionsPanel.java
platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaComboBoxUI.java
platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
platform/platform-impl/src/com/intellij/idea/SocketLock.java
platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java
platform/platform-impl/src/com/intellij/internal/statistic/ScaleInfoUsageCollector.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickList.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java [deleted file]
platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java
platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/KeyboardInternationalizationNotificationManager.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/TrailingSpacesStripper.java
platform/platform-impl/src/com/intellij/openapi/fileChooser/actions/VirtualFileDeleteProvider.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsUi.java
platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java
platform/platform-impl/src/com/intellij/openapi/project/impl/JBProtocolOpenProjectCommand.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java
platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
platform/platform-impl/src/com/intellij/ssh/SSHUtil.java
platform/platform-impl/src/com/intellij/ui/ComboboxEditorTextField.java
platform/platform-impl/src/com/intellij/ui/EditorTextField.java
platform/platform-impl/src/com/intellij/ui/Splash.java
platform/platform-impl/src/com/intellij/util/Restarter.java
platform/platform-impl/src/com/intellij/util/ui/SwingHelper.java
platform/platform-resources-en/src/messages/DiagnosticBundle.properties
platform/platform-resources-en/src/messages/ExecutionBundle.properties
platform/platform-resources-en/src/messages/IdeBundle.properties
platform/platform-resources-en/src/messages/UIBundle.properties
platform/platform-resources-en/src/messages/XDebuggerBundle.properties
platform/platform-resources/src/META-INF/LangExtensionPoints.xml
platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
platform/platform-resources/src/META-INF/PlatformExtensions.xml
platform/platform-resources/src/META-INF/VcsExtensionPoints.xml
platform/platform-resources/src/META-INF/VcsExtensions.xml
platform/platform-resources/src/launcher.py
platform/platform-tests/testSrc/com/intellij/openapi/application/impl/PerProjectLaterInvocatorTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/DocumentMarkupModelTest.java
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/TrailingSpacesStripperTest.java
platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/IdeaWin32PerformanceTest.java
platform/projectModel-api/src/org/jetbrains/concurrency/Promise.java
platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt
platform/projectModel-impl/src/com/intellij/configurationStore/scheme-impl.kt
platform/projectModel-impl/src/com/intellij/openapi/options/EmptySchemesManager.java [moved from platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java with 100% similarity]
platform/projectModel-impl/src/com/intellij/openapi/options/ExternalizableSchemeAdapter.kt
platform/projectModel-impl/src/com/intellij/openapi/options/SchemeManager.java [moved from platform/core-api/src/com/intellij/openapi/options/SchemeManager.java with 94% similarity]
platform/projectModel-impl/src/com/intellij/openapi/options/scheme.kt [moved from platform/projectModel-api/src/com/intellij/openapi/options/scheme.kt with 100% similarity]
platform/projectModel-impl/src/com/intellij/project/project.kt
platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/DefaultServersToolWindowManager.java
platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowFactory.java
platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowManager.java
platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServersTreeAction.java
platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java
platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java
platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java
platform/testRunner/src/com/intellij/execution/testframework/TestSearchScope.java
platform/util/resources/misc/registry.properties
platform/util/src/com/intellij/icons/AllIcons.java
platform/util/src/com/intellij/openapi/util/IconLoader.java
platform/util/src/com/intellij/openapi/util/NotNullLazyValue.java
platform/util/src/com/intellij/openapi/util/VolatileNotNullLazyValue.java
platform/util/src/com/intellij/util/containers/OrderedSet.java
platform/util/src/com/intellij/util/diff/Diff.java
platform/util/src/com/intellij/util/graph/CachingSemiGraph.java
platform/util/src/com/intellij/util/graph/Graph.java
platform/util/src/com/intellij/util/graph/GraphGenerator.java
platform/util/src/com/intellij/util/text/StringFactory.java
platform/util/src/com/intellij/util/ui/JBUI.java
platform/util/src/com/intellij/util/ui/UIUtil.java
platform/util/testSrc/com/intellij/util/graph/DFSTBuilderTest.java
platform/util/testSrc/com/intellij/util/graph/GraphGeneratorTest.java
platform/util/testSrc/com/intellij/util/graph/GraphTestUtil.java
platform/util/testSrc/com/intellij/util/graph/TestNode.java
platform/vcs-api/src/com/intellij/openapi/vcs/changes/FilePathsHelper.java
platform/vcs-api/src/com/intellij/openapi/vcs/changes/IgnoredFileProvider.java [moved from platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/BundledColorSchemeEP.java with 56% similarity]
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickListPopupAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdatingChangeListBuilder.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentI.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/DummyChangesViewContentManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/NewEditChangelistPanel.java
platform/vcs-impl/testSrc/com/intellij/openapi/vcs/changes/ConvertExcludedToIgnoredTest.java
platform/vcs-log/impl/src/com/intellij/vcs/log/VcsLogRootFilterImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogData.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilterImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogProgress.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogRefresherImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStructureFilterImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VisiblePackBuilder.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java
platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogFilterCollectionImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogHashFilterImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogTextFilterImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogUserFilterImpl.java
platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java
platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogRefresherTest.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/SetValueInplaceEditor.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/TreeInplaceEditor.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/TooBroadScopeInspectionBase.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/EqualsReplaceableByObjectsCallInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryCallToStringValueOfInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/junit/BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection.java
plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/TooBroadScope.java
plugins/InspectionGadgets/test/com/siyeh/igtest/migration/equals_replaceable_by_objects_call/EqualsReplaceableByObjectsCall.java
plugins/InspectionGadgets/test/com/siyeh/igtest/migration/equals_replaceable_by_objects_call/EqualsReplaceableByObjectsCallCheckNull.java
plugins/copyright/src/CopyrightManager.kt
plugins/devkit/resources/fileTemplates/j2ee/plugin.xml.ft
plugins/devkit/src/inspections/DescriptionCheckerUtil.java
plugins/devkit/src/inspections/DescriptionNotFoundInspectionBase.java
plugins/devkit/src/inspections/InspectionDescriptionInfo.java
plugins/devkit/src/inspections/InspectionDescriptionNotFoundInspection.java
plugins/devkit/src/run/PluginRunConfiguration.java
plugins/devkit/testSources/inspections/InspectionDescriptionNotFoundInspectionTest.java
plugins/git4idea/src/META-INF/plugin.xml
plugins/git4idea/src/git4idea/GitUtil.java
plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java
plugins/git4idea/src/git4idea/branch/GitBranchUtil.java
plugins/git4idea/src/git4idea/commands/Git.java
plugins/git4idea/src/git4idea/commands/GitImpl.java
plugins/git4idea/src/git4idea/push/GitPushTargetPanel.java
plugins/git4idea/src/git4idea/remote/GitConfigureRemotesAction.kt [new file with mode: 0644]
plugins/git4idea/src/git4idea/remote/GitConfigureRemotesDialog.kt [new file with mode: 0644]
plugins/git4idea/src/git4idea/remote/GitDefineRemoteDialog.java [moved from plugins/git4idea/src/git4idea/push/GitDefineRemoteDialog.java with 59% similarity]
plugins/git4idea/src/git4idea/repo/GitRemote.java
plugins/git4idea/src/git4idea/ui/branch/GitBranchWidget.java
plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParser.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/modifiers/Modifiers.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java
plugins/groovy/src/META-INF/groovy-copyright.xml
plugins/groovy/src/org/jetbrains/plugins/groovy/copyright/GroovyCopyrightVariablesProvider.kt [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java
plugins/groovy/testdata/parsing/groovy/expressions/references/ref9.test
plugins/groovy/testdata/parsing/groovy/statements/vardef/vardef4.test
plugins/hg4idea/src/org/zmlx/hg4idea/HgContentRevision.java
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgActionUtil.java
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgProcessStateAction.java
plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java
plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
plugins/java-i18n/src/com/intellij/lang/properties/PropertiesReferenceContributor.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilder.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderEditor.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderImpl.java
plugins/junit/src/com/intellij/execution/ConfigurationUtil.java
plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java
plugins/junit/src/com/intellij/execution/junit/TestPackage.java
plugins/junit/test/com/intellij/execution/junit/JUnitRerunFailedTestsTest.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java
plugins/settings-repository/src/IcsManager.kt
plugins/settings-repository/src/IcsUrlBuilder.kt
plugins/settings-repository/src/git/GitRepositoryManager.kt
plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskManagerImpl.java
plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepository.java
plugins/testng/src/com/theoryinpractice/testng/inspection/UndeclaredTestInspection.java
python/build/groovy/org/jetbrains/intellij/build/pycharm/PyCharmMacDistributionCustomizer.groovy
python/build/groovy/org/jetbrains/intellij/build/pycharm/PyCharmPropertiesBase.groovy
python/build/groovy/org/jetbrains/intellij/build/pycharm/PyCharmWindowsDistributionCustomizer.groovy
python/helpers/pydev/_pydev_bundle/_pydev_completer.py
python/helpers/pydev/_pydev_bundle/pydev_console_utils.py
python/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py
python/helpers/pydev/_pydevd_bundle/pydevd_comm.py
python/helpers/pydev/_pydevd_bundle/pydevd_console.py
python/helpers/pydev/_pydevd_bundle/pydevd_constants.py
python/helpers/pydev/_pydevd_bundle/pydevd_custom_frames.py
python/helpers/pydev/_pydevd_bundle/pydevd_referrers.py
python/helpers/pydev/_pydevd_bundle/pydevd_traceproperty.py
python/helpers/pydev/_pydevd_bundle/pydevd_tracing.py
python/helpers/pydev/_pydevd_bundle/pydevd_vars.py
python/helpers/pydev/_pydevd_bundle/pydevd_xml.py
python/helpers/pydev/pydev_run_in_console.py
python/helpers/pydev/pydevconsole.py
python/helpers/pydev/pydevd_file_utils.py
python/helpers/pydev/tests_pydevd_python/test_pydev_monkey.py
python/helpers/python-skeletons/__builtin__.py
python/helpers/python-skeletons/builtins.py
python/ide/src/com/jetbrains/python/newProject/PythonBaseProjectGenerator.java
python/openapi/src/com/jetbrains/python/packaging/requirement/PyRequirementVersionSpec.java
python/src/META-INF/python-core-common.xml
python/src/com/jetbrains/python/codeInsight/PyFStringsInjector.java [deleted file]
python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java
python/src/com/jetbrains/python/codeInsight/fstrings/FStringParser.java [new file with mode: 0644]
python/src/com/jetbrains/python/codeInsight/fstrings/PyFStringsInjector.java [new file with mode: 0644]
python/src/com/jetbrains/python/documentation/doctest/PyDocReference.java
python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java
python/src/com/jetbrains/python/psi/PyUtil.java
python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
python/src/com/jetbrains/python/validation/CompatibilityVisitor.java
python/src/com/jetbrains/python/validation/FStringsAnnotator.java [new file with mode: 0644]
python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java
python/src/com/jetbrains/python/validation/UnsupportedFeatures.java
python/testData/codeInsight/controlflow/variableannotations.py [new file with mode: 0644]
python/testData/codeInsight/controlflow/variableannotations.txt [new file with mode: 0644]
python/testData/debug/test_resume.py [moved from python/testData/debug/Test_Resume.py with 100% similarity]
python/testData/debug/test_runtoline.py
python/testData/debug/test_two_threads.py
python/testData/highlighting/fStringBackslashes.py [new file with mode: 0644]
python/testData/highlighting/fStringEmptyExpressions.py [new file with mode: 0644]
python/testData/highlighting/fStringHashSigns.py [new file with mode: 0644]
python/testData/highlighting/fStringIllegalConversionCharacter.py [new file with mode: 0644]
python/testData/highlighting/fStringMissingRightBrace.py [new file with mode: 0644]
python/testData/inspections/PyCompatibilityInspection/exceptBlock.py
python/testData/inspections/PyTypeCheckerInspection/BytesGetItemWithSlice.py [new file with mode: 0644]
python/testData/inspections/PyTypeCheckerInspection/StringGetItemWithSlice.py [new file with mode: 0644]
python/testData/inspections/PyTypeCheckerInspection/UnicodeGetItemWithSlice.py [new file with mode: 0644]
python/testData/resolve/FStringFunctionParameter.py [new file with mode: 0644]
python/testData/resolve/FStringLocalVariable.py [new file with mode: 0644]
python/testData/resolve/FStringLocalVariableUnresolved.py [new file with mode: 0644]
python/testData/resolve/FStringNestedScopes.py [new file with mode: 0644]
python/testData/resolve/LocalVariableAnnotationWithInnerClass.py [new file with mode: 0644]
python/testData/resolve/QuotedTypeReferenceInsideClass.py [new file with mode: 0644]
python/testData/resolve/QuotedTypeReferenceInsideFunction.py [new file with mode: 0644]
python/testData/resolve/QuotedTypeReferenceTopLevel.py [new file with mode: 0644]
python/testData/resolve/TopLevelVariableAnnotationFromTyping.py [new file with mode: 0644]
python/testData/resolve/TypeCommentReference.py [new file with mode: 0644]
python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java
python/testSrc/com/jetbrains/env/python/debug/PyDebuggerTask.java
python/testSrc/com/jetbrains/python/Py3ResolveTest.java
python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java
python/testSrc/com/jetbrains/python/PyFStringTest.java
python/testSrc/com/jetbrains/python/PyInjectionResolveTest.java [new file with mode: 0644]
python/testSrc/com/jetbrains/python/PythonHighlightingTest.java
python/testSrc/com/jetbrains/python/fixtures/PyResolveTestCase.java
python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java
python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java
python/testSrc/com/jetbrains/python/packaging/PyRequirementTest.java
resources-en/src/inspectionDescriptions/ClassHasNoToStringMethod.html [moved from plugins/generate-tostring/resources/inspectionDescriptions/ClassHasNoToStringMethod.html with 100% similarity]
resources-en/src/inspectionDescriptions/FieldNotUsedInToString.html [moved from plugins/generate-tostring/resources/inspectionDescriptions/FieldNotUsedInToString.html with 100% similarity]
resources-en/src/inspectionDescriptions/Java8CollectionsApi.html
resources-en/src/messages/QuickFixBundle.properties
resources/src/META-INF/IdeaPlugin.xml
spellchecker/src/com/intellij/spellchecker/jetbrains.dic
update-server-mock/.editorconfig [new file with mode: 0644]
update-server-mock/.gitignore [new file with mode: 0644]
update-server-mock/build.gradle [new file with mode: 0644]
update-server-mock/lib/log4j-api-2.6.2.jar [new file with mode: 0644]
update-server-mock/lib/log4j-core-2.6.2.jar [new file with mode: 0644]
update-server-mock/log4j.xml [new file with mode: 0644]
update-server-mock/settings.gradle [new file with mode: 0644]
update-server-mock/src/main/java/com/intellij/updater/mock/Generator.kt [new file with mode: 0644]
update-server-mock/src/main/java/com/intellij/updater/mock/Server.kt [new file with mode: 0644]
update-server-mock/src/main/java/com/intellij/updater/mock/main.kt [new file with mode: 0644]
update-server-mock/src/main/resources/patch/patch.jar [new file with mode: 0644]
update-server-mock/src/test/java/com/intellij/updater/mock/GeneratorTest.kt [new file with mode: 0644]
update-server-mock/update-server-mock.iml [new file with mode: 0644]

index a2b24426ab894f35a3518ae579115e5721486014..0ce93dbd0261b45f3cc8a644c85e8b4998bbd9d7 100644 (file)
       <option name="m_minLength" value="8" />
       <option name="m_maxLength" value="64" />
     </inspection_tool>
+    <inspection_tool class="Java8CollectionsApi" enabled="true" level="INFORMATION" enabled_by_default="true" />
     <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="false">
       <scope name="Tests" level="WARNING" enabled="false">
         <option name="TOP_LEVEL_CLASS_OPTIONS">
index 5fbe4581a9198ddb871a08a140f22a02fb4a6c86..b724cbc1c2856d1dc7df395a2a91cb21bc466756 100644 (file)
       <module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/ui-designer.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/ui-designer.iml" group="plugins" />
       <module fileurl="file://$PROJECT_DIR$/plugins/ui-designer-core/ui-designer-core.iml" filepath="$PROJECT_DIR$/plugins/ui-designer-core/ui-designer-core.iml" group="plugins" />
       <module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/jps-plugin/ui-designer-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/jps-plugin/ui-designer-jps-plugin.iml" group="plugins" />
+      <module fileurl="file://$PROJECT_DIR$/update-server-mock/update-server-mock.iml" filepath="$PROJECT_DIR$/update-server-mock/update-server-mock.iml" group="platform" />
       <module fileurl="file://$PROJECT_DIR$/updater/updater.iml" filepath="$PROJECT_DIR$/updater/updater.iml" group="platform" />
       <module fileurl="file://$PROJECT_DIR$/platform/usageView/usageView.iml" filepath="$PROJECT_DIR$/platform/usageView/usageView.iml" group="platform" />
       <module fileurl="file://$PROJECT_DIR$/platform/util/util.iml" filepath="$PROJECT_DIR$/platform/util/util.iml" group="platform" />
diff --git a/bin/linux/restart.py b/bin/linux/restart.py
new file mode 100755 (executable)
index 0000000..93bf229
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+# Waits for the parent process to terminate, then executes specified commands.
+
+import os
+import sys
+import time
+
+if len(sys.argv) < 2:
+    raise Exception('At least one argument expected')
+
+pid = os.getppid()
+while os.getppid() == pid:
+    time.sleep(0.5)
+
+if len(sys.argv) > 2:
+    os.spawnv(os.P_WAIT, sys.argv[2], sys.argv[2:])
+
+to_launch = sys.argv[1]
+if sys.platform == 'darwin':
+    os.execv('/usr/bin/open', ['/usr/bin/open', to_launch])
+else:
+    os.execv(to_launch, [to_launch])
index 786a99486585ec0951ff14c863cb786f3dc1e39a..38487a589aa4edee7a6af1a3658957941306d55e 100755 (executable)
@@ -184,23 +184,11 @@ LD_LIBRARY_PATH="$IDE_BIN_HOME:$LD_LIBRARY_PATH" "$JAVA_BIN" \
   "-Xbootclasspath/a:$IDE_HOME/lib/boot.jar" \
   -classpath "$CLASSPATH" \
   ${VM_OPTIONS} \
-  "-Djb.vmOptionsFile=$VM_OPTIONS_FILE" \
   "-XX:ErrorFile=$HOME/java_error_in_@@product_uc@@_%p.log" \
   "-XX:HeapDumpPath=$HOME/java_error_in_@@product_uc@@.hprof" \
-  -Djb.restart.code=88 -Didea.paths.selector=@@system_selector@@ \
+  -Didea.paths.selector=@@system_selector@@ \
+  "-Djb.vmOptionsFile=$VM_OPTIONS_FILE" \
   ${IDE_PROPERTIES_PROPERTY} \
   @@ide_jvm_args@@ \
   com.intellij.idea.Main \
   "$@"
-EC=$?
-unset IFS
-
-test ${EC} -ne 88 && exit ${EC}
-
-RESTARTER="$HOME/.@@system_selector@@/system/restart/restarter.sh"
-if [ -x "$RESTARTER" ]; then
-  "$RESTARTER"
-  "$RM" -f "$RESTARTER"
-fi
-
-exec "$0"
index 849376703e0988c86c9e75b6774631cc95a9f31e..f724395a2c75215d05b9f434cd149e0aa5744a85 100644 (file)
@@ -258,6 +258,8 @@ class CommunityLibraryLicenses {
                        licenseUrl: "http://www.miglayout.com/mavensite/license.html"),
     new LibraryLicense(name: "minlog", libraryName: "minlog-1.2.jar", version: "1.2", license: "BSD",
                        url: "https://github.com/EsotericSoftware/minlog", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause"),
+    new LibraryLicense(name: "mockito", libraryName: "mockito-all-1.9.5.jar", version: "1.9.5", license: "MIT",
+                       url: "http://mockito.org", licenseUrl: "https://github.com/mockito/mockito/blob/master/LICENSE"),
     new LibraryLicense(name: "NanoXML", version: "2.2.3", license: "zlib/libpng",
                        url: "http://mvnrepository.com/artifact/be.cyberelf.nanoxml/nanoxml/2.2.3",
                        licenseUrl: "http://www.opensource.org/licenses/zlib-license.html"),
index 15dc7526f2932be86ae5ab75db126ce4599b1e9f..348293b3bf365c3528b020c028d8318843807379 100644 (file)
@@ -200,12 +200,17 @@ idea.fatal.error.notification=disabled
   void layoutShared() {
     buildContext.messages.block("Copy files shared among all distributions") {
       new File(buildContext.paths.distAll, "build.txt").text = buildContext.fullBuildNumber
+
       buildContext.ant.copy(todir: "$buildContext.paths.distAll/bin") {
         fileset(dir: "$buildContext.paths.communityHome/bin") {
           include(name: "*.*")
           exclude(name: "idea.properties")
+          exclude(name: "log.xml")
         }
       }
+
+      copyLogXml()
+
       buildContext.ant.copy(todir: "$buildContext.paths.distAll/license") {
         fileset(dir: "$buildContext.paths.communityHome/license")
         buildContext.productProperties.additionalDirectoriesWithLicenses.each {
@@ -217,6 +222,13 @@ idea.fatal.error.notification=disabled
     }
   }
 
+  private void copyLogXml() {
+    def src = new File("$buildContext.paths.communityHome/bin/log.xml")
+    def dst = new File("$buildContext.paths.distAll/bin/log.xml")
+    dst.parentFile.mkdirs()
+    src.filterLine { String it -> !it.contains('appender-ref ref="CONSOLE-WARN"') }.writeTo(dst.newWriter()).close()
+  }
+
   @Override
   void buildDistributions() {
     layoutShared()
@@ -495,4 +507,4 @@ idea.fatal.error.notification=disabled
 
     abstract V run(BuildContext context)
   }
-}
+}
\ No newline at end of file
index 1f2b603a71ee7faaaa667ec73082f1fd27dfdea0..6d2cbd5861cb13781dcace41314ddcc429b336d5 100644 (file)
@@ -78,11 +78,13 @@ class CrossPlatformDistributionBuilder {
           exclude(name: "bin/fsnotifier*")
           exclude(name: "bin/*.vmoptions")
           exclude(name: "bin/*.sh")
+          exclude(name: "bin/*.py")
           exclude(name: "bin/idea.properties")
           exclude(name: "help/**")
         }
-        zipfileset(dir: "$linuxDistPath/bin", filemode: "775", prefix: "bin") {
+        zipfileset(dir: "$linuxDistPath/bin", prefix: "bin", filemode: "775") {
           include(name: "*.sh")
+          include(name: "*.py")
         }
         zipfileset(dir: "$linuxDistPath/bin", prefix: "bin/linux", filemode: "775") {
           include(name: "fsnotifier*")
@@ -97,7 +99,7 @@ class CrossPlatformDistributionBuilder {
           exclude(name: "bin/idea.properties")
           exclude(name: "bin/*.vmoptions")
         }
-        zipfileset(dir: "$macDistPath/bin", filemode: "775", prefix: "bin") {
+        zipfileset(dir: "$macDistPath/bin", prefix: "bin", filemode: "775") {
           include(name: "restarter*")
           include(name: "*.py")
         }
index a80bd98e956b20d2ec1e47da26e0e86ecbf41246..df30239efe1355b87d039d184f0f94762186ea06 100644 (file)
@@ -157,6 +157,7 @@ class LinuxDistributionBuilder extends OsSpecificDistributionBuilder {
         paths.each {
           tarfileset(dir: it, prefix: tarRoot) {
             exclude(name: "bin/*.sh")
+            exclude(name: "bin/*.py")
             exclude(name: "bin/fsnotifier*")
             extraBins.each {
               exclude(name: it)
@@ -166,8 +167,9 @@ class LinuxDistributionBuilder extends OsSpecificDistributionBuilder {
         }
 
         paths.each {
-          tarfileset(dir: it, filemode: "755", prefix: tarRoot) {
+          tarfileset(dir: it, prefix: tarRoot, filemode: "755") {
             include(name: "bin/*.sh")
+            include(name: "bin/*.py")
             include(name: "bin/fsnotifier*")
             extraBins.each {
               include(name: it)
index a32ece984b5f8059cee0c338bb25d91cd0e8fe19..afe1859f78775a6bf5756cee95d22dc43a1cdaec 100644 (file)
@@ -27,7 +27,7 @@ import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
 
 includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
 
-String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_103_Idea145branch160versionNoTests"
+String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_104_Idea145branch160versionNoTests"
 
 target('default': 'Ensures that build/kotlinc directory contains JARs from Kotlin plugin compatible with current IDEA sources. These JARs are used by build scripts.') {
   def communityHome = guessHome(this)
index e6b010a1cb9375145e846703176b8a265a6fcc24..5bc2b23fb9ce4db1a5b6a40e4fc0c5732353bc79 100644 (file)
@@ -1006,10 +1006,12 @@ binding.setVariable("buildCrossPlatformZip", { String zipPath, String sandbox, L
       exclude(name: "bin/fsnotifier*")
       exclude(name: "bin/*.vmoptions")
       exclude(name: "bin/*.sh")
+      exclude(name: "bin/*.py")
       exclude(name: "help/**")
     }
-    zipfileset(dir: "$distUnix/bin", filemode: "775", prefix: "bin") {
+    zipfileset(dir: "$distUnix/bin", prefix: "bin", filemode: "775") {
       include(name: "*.sh")
+      include(name: "*.py")
     }
     zipfileset(dir: "$distUnix/bin", prefix: "bin/linux", filemode: "775") {
       include(name: "fsnotifier*")
@@ -1024,7 +1026,7 @@ binding.setVariable("buildCrossPlatformZip", { String zipPath, String sandbox, L
       exclude(name: "bin/idea.properties")
       exclude(name: "bin/*.vmoptions")
     }
-    zipfileset(dir: "$distMac/bin", filemode: "775", prefix: "bin") {
+    zipfileset(dir: "$distMac/bin", prefix: "bin", filemode: "775") {
       include(name: "restarter*")
       include(name: "*.py")
     }
@@ -1058,7 +1060,7 @@ binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths,
     }
 
     allPaths.each {
-      zipfileset(dir: it, filemode: "755", prefix: zipRoot) {
+      zipfileset(dir: it, prefix: zipRoot, filemode: "755") {
         include(name: "bin/*.sh")
         include(name: "bin/*.py")
         include(name: "bin/fsnotifier")
@@ -1090,6 +1092,7 @@ binding.setVariable("buildTarGz", { String tarRoot, String tarPath, List paths,
     paths.each {
       tarfileset(dir: it, prefix: tarRoot) {
         exclude(name: "bin/*.sh")
+        exclude(name: "bin/*.py")
         exclude(name: "bin/fsnotifier*")
         extraBins.each {
           exclude(name: it)
@@ -1099,8 +1102,9 @@ binding.setVariable("buildTarGz", { String tarRoot, String tarPath, List paths,
     }
 
     paths.each {
-      tarfileset(dir: it, filemode: "755", prefix: tarRoot) {
+      tarfileset(dir: it, prefix: tarRoot, filemode: "755") {
         include(name: "bin/*.sh")
+        include(name: "bin/*.py")
         include(name: "bin/fsnotifier*")
         extraBins.each {
           include(name: it)
index 0c00c97d44edf29bd5ba2939c974d98f13c75379..099b6332f180834de6679828aecf88b290ad48ef 100755 (executable)
@@ -36,7 +36,7 @@ echo "Updating $WORK_IDEA_HOME from compiled classes in $DEV_IDEA_HOME"
 ANT_HOME="$DEV_IDEA_HOME/lib/ant"
 ANT_CLASSPATH="$DEV_IDEA_HOME/build/lib/gant/lib/jps.jar"
 "$JAVA_BIN" -Xms64m -Xmx512m -Dant.home="$ANT_HOME" -classpath "$ANT_HOME/lib/ant-launcher.jar" org.apache.tools.ant.launch.Launcher \
- -lib "$ANT_CLASSPATH" -f "$DEV_IDEA_HOME/build/update.xml" -Dwork.idea.home="$WORK_IDEA_HOME" $TARGET
+ -lib "$ANT_CLASSPATH" -f "$DEV_IDEA_HOME/build/update.xml" -Dwork.idea.home="$WORK_IDEA_HOME" ${TARGET}
 
 if [ "$?" != "0" ]; then
   echo "Update failed; work IDEA build not modified."
@@ -51,8 +51,9 @@ cp -R "$DEV_IDEA_HOME/out/deploy/"* "$WORK_IDEA_HOME"
 
 OS_TYPE=`uname -s`
 if [ "$OS_TYPE" = "Linux" ]; then
-  cp -a $DEV_IDEA_HOME/bin/linux/*.so $WORK_IDEA_HOME/bin
-  cp -a $DEV_IDEA_HOME/bin/linux/fsnotifier* $WORK_IDEA_HOME/bin
+  cp -a "$DEV_IDEA_HOME/bin/linux/"*.so "$WORK_IDEA_HOME/bin"
+  cp -a "$DEV_IDEA_HOME/bin/linux/"fsnotifier* "$WORK_IDEA_HOME/bin"
+  cp -a "$DEV_IDEA_HOME/bin/linux/"*.py "$WORK_IDEA_HOME/bin"
 elif [ "$OS_TYPE" = "Darwin" ]; then
   cp -a "$DEV_IDEA_HOME/bin/mac/"*.jnilib "$WORK_IDEA_HOME/bin"
   cp -a "$DEV_IDEA_HOME/bin/mac/fsnotifier" "$WORK_IDEA_HOME/bin"
index 239fe3f3873ab1b7a536a94f3982efaed3d80f71..d0856381565db40fbe7b6236b37fdad8308051d1 100644 (file)
@@ -39,7 +39,7 @@ public class Javac2 extends Javac {
   private ArrayList myFormFiles;
   private List myNestedFormPathList;
   private boolean instrumentNotNull = true;
-  private String myNotNullAnnotations;
+  private String myNotNullAnnotations = "org.jetbrains.annotations.NotNull";
   private List<Regexp> myClassFilterAnnotationRegexpList = new ArrayList<Regexp>(0);
 
   public Javac2() {
index 2c09c96dffbcb4ff624ada8760af686872077e2f..6c8eb7a228e6f7e3d3dfcc9d0409869dfaecf290 100644 (file)
@@ -27,13 +27,16 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import com.intellij.ui.components.JBList;
 import com.intellij.ui.popup.list.ListPopupImpl;
+import com.intellij.util.ui.UIUtil;
 import com.intellij.xdebugger.impl.actions.XDebuggerActions;
 import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
+import java.awt.event.KeyEvent;
 import java.util.Collections;
 import java.util.List;
 
@@ -77,6 +80,10 @@ public abstract class JvmSmartStepIntoHandler {
         DebuggerUIUtil.registerExtraHandleShortcuts(popup, XDebuggerActions.STEP_INTO, XDebuggerActions.SMART_STEP_INTO);
         popup.setAdText(DebuggerUIUtil.getSelectionShortcutsAdText(XDebuggerActions.STEP_INTO, XDebuggerActions.SMART_STEP_INTO));
 
+        UIUtil.maybeInstall(popup.getList().getInputMap(JComponent.WHEN_FOCUSED),
+                            "selectNextRow",
+                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
+
         popup.addListSelectionListener(new ListSelectionListener() {
           public void valueChanged(ListSelectionEvent e) {
             popupStep.getScopeHighlighter().dropHighlight();
index c66c4ecb56a258a4f30df7b9269d1273f79d9672..3f869c7dd24b86abe6f5b46deeaaf256edc44786 100644 (file)
@@ -44,6 +44,8 @@ import java.util.*;
 public class CompoundPositionManager extends PositionManagerEx implements MultiRequestPositionManager{
   private static final Logger LOG = Logger.getInstance(CompoundPositionManager.class);
 
+  public static final CompoundPositionManager EMPTY = new CompoundPositionManager();
+
   private final ArrayList<PositionManager> myPositionManagers = new ArrayList<>();
 
   @SuppressWarnings("UnusedDeclaration")
index 9b486ab8db0cb633122f14695b3f0843de74ba74..63d5f4844985cd958820570374bf9351cfab5858 100644 (file)
@@ -60,11 +60,7 @@ public class ContextUtil {
     if (location == null) {
       return null;
     }
-    CompoundPositionManager positionManager = debugProcess.getPositionManager();
-    if (positionManager == null) { // process already closed
-      return null;
-    }
-    return positionManager.getSourcePosition(location);
+    return debugProcess.getPositionManager().getSourcePosition(location);
   }
 
   @Nullable
index 209b43bfe7dad987e0c95097234fd5a0cf5b4029..f8f8c4a3b0265b2896789efbf0dc8310be071310 100644 (file)
@@ -129,7 +129,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
   private final Map<Type, NodeRenderer> myNodeRenderersMap = new HashMap<>();
 
   private final SuspendManagerImpl mySuspendManager = new SuspendManagerImpl(this);
-  protected CompoundPositionManager myPositionManager = null;
+  protected CompoundPositionManager myPositionManager = CompoundPositionManager.EMPTY;
   private final DebuggerManagerThreadImpl myDebuggerManagerThread;
 
   private final Semaphore myWaitFor = new Semaphore();
@@ -777,7 +777,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
       finally {
         final VirtualMachineProxyImpl vm = myVirtualMachineProxy;
         myVirtualMachineProxy = null;
-        myPositionManager = null;
+        myPositionManager = CompoundPositionManager.EMPTY;
         myReturnValueWatcher = null;
         myNodeRenderersMap.clear();
         myRenderers.clear();
@@ -1453,6 +1453,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
     return mySuspendManager;
   }
 
+  @NotNull
   @Override
   public CompoundPositionManager getPositionManager() {
     return myPositionManager;
index dd9ef47020ab43a31e0784b1e7bd75cb569ffd8a..48974dc1b5bb4558bd35f2f2695f3ba17e338b7b 100644 (file)
@@ -226,7 +226,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
     }
   }
 
-  private static String truncateToMaxLength(String value) {
+  private static String truncateToMaxLength(@NotNull String value) {
     return value.substring(0, Math.min(value.length(), XValueNode.MAX_VALUE_LENGTH));
   }
 
@@ -306,9 +306,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
           lastRenderer = ((CompoundTypeRenderer)lastRenderer).getLabelRenderer();
         }
         if (lastRenderer instanceof ToStringRenderer) {
-          if (!StringUtil.isEmpty(value)) {
-            value = StringUtil.wrapWithDoubleQuote(value);
-          }
+          value = StringUtil.wrapWithDoubleQuote(value);
         }
         renderer.renderValue(value);
       }
index 3cc157092ea1006958dc5382531dc7697a46de7a..fc09b147c279738c5b61b4d59f2a402139177eea 100644 (file)
@@ -109,9 +109,7 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
             classPattern = parentQName + "*";
             prepareRequestor = new ClassPrepareRequestor() {
               public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
-                final CompoundPositionManager positionManager = ((DebugProcessImpl)debuggerProcess).getPositionManager();
-                final List<ReferenceType> positionClasses = positionManager.getAllClasses(position);
-                if (positionClasses.contains(referenceType)) {
+                if (((DebugProcessImpl)debuggerProcess).getPositionManager().getAllClasses(position).contains(referenceType)) {
                   requestor.processClassPrepare(debuggerProcess, referenceType);
                 }
               }
index 6183d59f03c4e29dd8d27af5ffbf5c96779066a6..277a037b19e8845cc0e98212941adf4eda925803 100644 (file)
@@ -21,10 +21,13 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.JavaCodeFragment;
 import com.intellij.psi.JavaRecursiveElementVisitor;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiLocalVariable;
+import com.intellij.psi.search.DelegatingGlobalSearchScope;
+import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.util.StringBuilderSpinAllocator;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.xdebugger.XDebugSession;
@@ -37,6 +40,7 @@ import com.sun.jdi.ObjectReference;
 import com.sun.jdi.Value;
 import org.jetbrains.annotations.NotNull;
 
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -55,11 +59,11 @@ public class CodeFragmentFactoryContextWrapper extends CodeFragmentFactory {
   }
 
   public JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, Project project) {
-    return myDelegate.createCodeFragment(item, wrapContext(project, context), project);
+    return prepareResolveScope(myDelegate.createCodeFragment(item, wrapContext(project, context), project));
   }
 
   public JavaCodeFragment createPresentationCodeFragment(TextWithImports item, PsiElement context, Project project) {
-    return myDelegate.createPresentationCodeFragment(item, wrapContext(project, context), project);
+    return prepareResolveScope(myDelegate.createPresentationCodeFragment(item, wrapContext(project, context), project));
   }
 
   public boolean isContextAccepted(PsiElement contextElement) {
@@ -75,6 +79,20 @@ public class CodeFragmentFactoryContextWrapper extends CodeFragmentFactory {
   public EvaluatorBuilder getEvaluatorBuilder() {
     return myDelegate.getEvaluatorBuilder();
   }
+
+  private static JavaCodeFragment prepareResolveScope(JavaCodeFragment codeFragment) {
+    GlobalSearchScope originalResolveScope = codeFragment.getResolveScope();
+    codeFragment.forceResolveScope(new DelegatingGlobalSearchScope(GlobalSearchScope.allScope(codeFragment.getProject())) {
+      final Comparator<VirtualFile> myScopeComparator = Comparator.comparing(originalResolveScope::contains);
+      @Override
+      public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
+        // prefer files from the original resolve scope
+        int res = myScopeComparator.compare(file1, file2);
+        return res != 0 ? res : super.compare(file1, file2);
+      }
+    });
+    return codeFragment;
+  }
   
   private PsiElement wrapContext(Project project, final PsiElement originalContext) {
     if (project.isDefault()) return originalContext;
index 749f0e1944af02bcdab5ab05b1c5af44dfef7cb1..977bfe7a54a4270bf59038ec4c1d3c295e4ebde3 100644 (file)
@@ -36,7 +36,6 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiTypesUtil;
@@ -69,7 +68,6 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
     if (codeFragment == null) {
       throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", text.getText()));
     }
-    codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
     DebuggerUtils.checkSyntax(codeFragment);
 
     return factory.getEvaluatorBuilder().build(codeFragment, position);
index 04088e5947ffabcb4492f4f9c5243b5b4a49d58e..0553ff977fc662be731b9b03e7880caef8deede9 100644 (file)
@@ -165,10 +165,7 @@ class ReloadClassesWorker {
       processException(e);
     }
 
-    CompoundPositionManager positionManager = debugProcess.getPositionManager();
-    if (positionManager != null) {
-      positionManager.clearCache();
-    }
+    debugProcess.getPositionManager().clearCache();
 
     DebuggerContextImpl context = myDebuggerSession.getContextManager().getContext();
     SuspendContextImpl suspendContext = context.getSuspendContext();
index 44d22be63b77723dad97077942f0dfc07686c288..db616503e565c3f5cf78cc544d3f05d4a01011f5 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.progress.util.ProgressWindow;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.ToolWindowId;
+import com.intellij.reference.SoftReference;
 import com.intellij.util.SmartList;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.ui.MessageCategory;
@@ -45,6 +46,7 @@ import one.util.streamex.StreamEx;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.event.HyperlinkEvent;
+import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -55,7 +57,7 @@ public class HotSwapProgressImpl extends HotSwapProgress{
   private final ProgressWindow myProgressWindow;
   private String myTitle = DebuggerBundle.message("progress.hot.swap.title");
   private final MergingUpdateQueue myUpdateQueue;
-  private XDebugSession mySession;
+  private WeakReference<XDebugSession> mySessionRef = null;
 
   public HotSwapProgressImpl(Project project) {
     super(project);
@@ -101,29 +103,34 @@ public class HotSwapProgressImpl extends HotSwapProgress{
 
   private void notifyUser(String title, String message, NotificationType type) {
     NotificationListener notificationListener = null;
-    if (mySession != null) {
+    if (SoftReference.dereference(mySessionRef) != null) {
       notificationListener = (notification, event) -> {
-        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && mySession != null) {
-          notification.expire();
-          switch (event.getDescription()) {
-            case "stop":
-              mySession.stop();
-              break;
-            case "restart":
-              ExecutionEnvironment environment = ((XDebugSessionImpl)mySession).getExecutionEnvironment();
-              if (environment != null) {
-                ExecutionUtil.restart(environment);
-              }
-              break;
-          }
+        if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
+          return;
+        }
+        XDebugSession session = SoftReference.dereference(mySessionRef);
+        if (session == null) {
+          return;
+        }
+        notification.expire();
+        switch (event.getDescription()) {
+          case "stop":
+            session.stop();
+            break;
+          case "restart":
+            ExecutionEnvironment environment = ((XDebugSessionImpl)session).getExecutionEnvironment();
+            if (environment != null) {
+              ExecutionUtil.restart(environment);
+            }
+            break;
         }
       };
     }
     NOTIFICATION_GROUP.createNotification(title, message, type, notificationListener).setImportant(false).notify(getProject());
   }
 
-  public void setSession(@NotNull DebuggerSession session) {
-    mySession = session.getXDebugSession();
+  public void setSessionForActions(@NotNull DebuggerSession session) {
+    mySessionRef = new WeakReference<>(session.getXDebugSession());
   }
 
   private List<String> getMessages(int category) {
@@ -132,7 +139,7 @@ public class HotSwapProgressImpl extends HotSwapProgress{
 
   private String buildMessage(List<String> messages, boolean withRestart) {
     StringBuilder res = new StringBuilder(StreamEx.of(messages).map(m -> StringUtil.trimEnd(m, ';')).joining("\n"));
-    if (mySession != null) {
+    if (SoftReference.dereference(mySessionRef) != null) {
       res.append("\n").append(DebuggerBundle.message("status.hot.swap.completed.stop"));
       if (withRestart) {
         res.append("&nbsp;&nbsp;&nbsp;&nbsp;").append(DebuggerBundle.message("status.hot.swap.completed.restart"));
index bded769165bbe5d236b11ef952ba92b2f2414fea..e5e1a0c2b6ee4520d29c9fcef53495f145e799ea 100644 (file)
@@ -234,7 +234,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
           final HotSwapProgressImpl progress = new HotSwapProgressImpl(myProject);
           if (modifiedClasses.keySet().size() == 1) {
             //noinspection ConstantConditions
-            progress.setSession(ContainerUtil.getFirstItem(modifiedClasses.keySet()));
+            progress.setSessionForActions(ContainerUtil.getFirstItem(modifiedClasses.keySet()));
           }
           application.executeOnPooledThread(() -> reloadModifiedClasses(modifiedClasses, progress));
         }
index ebac8ed495657c024c5735aafdfe66d464d5fe01..5e2bdc5aa8624e9846a28ee8e1bdfb5ecd6fbfed 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.
@@ -46,7 +46,6 @@ import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.*;
 import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.ui.SimpleColoredText;
 import com.intellij.ui.SimpleTextAttributes;
 import com.intellij.util.IncorrectOperationException;
@@ -97,7 +96,6 @@ public class ValueHint extends AbstractValueHint {
     TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myCurrentExpression.getText());
     CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(textWithImports, myCurrentExpression);
     JavaCodeFragment codeFragment = factory.createCodeFragment(textWithImports, myCurrentExpression.getContext(), getProject());
-    codeFragment.forceResolveScope(GlobalSearchScope.allScope(getProject()));
     return factory.getEvaluatorBuilder().build(codeFragment, debuggerContext.getSourcePosition());
   }
 
index 36ecdd9aac9b2f8f76070cb72be4d711cdf239dc..daef7fbb4cadd7d10dfa865f0164920c3e4fecb8 100644 (file)
@@ -178,7 +178,7 @@ public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase<JavaLineB
     private final PsiElement myElement;
     private final Integer myLambdaOrdinal;
 
-    public ExactJavaBreakpointVariant(@NotNull XSourcePosition position, PsiElement element, Integer lambdaOrdinal) {
+    public ExactJavaBreakpointVariant(@NotNull XSourcePosition position, @NotNull PsiElement element, Integer lambdaOrdinal) {
       super(position);
       myElement = element;
       myLambdaOrdinal = lambdaOrdinal;
index 7c461e1008cafb71099f8db301431ba35a989d9d..05464f5e77dcfc4ac231cce83d020b08006f055b 100644 (file)
@@ -33,7 +33,6 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.extractMethod.PrepareFailedException;
 import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
 import com.intellij.xdebugger.frame.XValueModifier;
@@ -65,10 +64,7 @@ public abstract class EvaluationDescriptor extends ValueDescriptorImpl{
 
   public PsiCodeFragment createCodeFragment(PsiElement context) {
     TextWithImports text = getEvaluationText();
-    final PsiCodeFragment fragment =
-      DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context).createCodeFragment(text, context, myProject);
-    fragment.forceResolveScope(GlobalSearchScope.allScope(myProject));
-    return fragment;
+    return DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context).createCodeFragment(text, context, myProject);
   }
 
   public final Value calcValue(final EvaluationContextImpl evaluationContext) throws EvaluateException {
index afbaf03bb741fde99c66759b58a75c2bd9f16667..131d22e633d07b405163549b97aca279c1e1d0ad 100644 (file)
@@ -22,7 +22,6 @@ import com.intellij.debugger.impl.DebuggerUtilsImpl;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
 import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.reference.SoftReference;
 import org.jetbrains.annotations.Nullable;
 
@@ -73,7 +72,6 @@ public abstract class CachedEvaluator {
       }
       cache.myPsiChildrenExpression = null;
       JavaCodeFragment codeFragment = myDefaultFragmentFactory.createCodeFragment(myReferenceExpression, psiClassAndType.first, project);
-      codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
       codeFragment.setThisType(psiClassAndType.second);
       DebuggerUtils.checkSyntax(codeFragment);
       cache.myPsiChildrenExpression = codeFragment instanceof PsiExpressionCodeFragment ? ((PsiExpressionCodeFragment)codeFragment).getExpression() : null;
index 2af4c3caef600ab1b4fb0e71fdd7a413efd83b02..447f83dbb91c30bbed5e2d56d2dd52630ca4ea28 100644 (file)
@@ -27,7 +27,6 @@ import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.xdebugger.XExpression;
 import com.intellij.xdebugger.XSourcePosition;
@@ -92,7 +91,6 @@ public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase {
     if (text != null) {
       CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context);
       JavaCodeFragment codeFragment = factory.createPresentationCodeFragment(text, context, project);
-      codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
 
       if (context != null) {
         PsiType contextType = context.getUserData(DebuggerUtilsImpl.PSI_TYPE_KEY);
index c672028b6db4ae5b4347858bf4efc0b3f6dc196d..a914699da20515c3c1492bc6d8234dfb9d01b02c 100644 (file)
@@ -45,6 +45,7 @@ public interface DebugProcess {
 
   RequestManager getRequestsManager();
 
+  @NotNull
   PositionManager getPositionManager();
 
   VirtualMachineProxy getVirtualMachineProxy();
index f46e857e71b4b4616e09255e4490f0a4ef8ec496..3bfc53a282bc91340e0f3c75197e67455c6179c9 100644 (file)
@@ -161,6 +161,7 @@ public abstract class JavaTestFrameworkRunnableState<T extends
       @Override
       public void processTerminated(ProcessEvent event) {
         Runnable runnable = () -> {
+          root.flushOutputFile();
           deleteTempFiles();
           clear();
         };
index dde84b00d2d7cf6e457805cce6304659bade087e..1780232751bb0268a1e22cb366f5701e7eaf5da7 100644 (file)
@@ -123,7 +123,7 @@ public class JarApplicationConfiguration extends LocatableConfigurationBase impl
 
   @Nullable
   @Override
-  public GlobalSearchScope getScope() {
+  public GlobalSearchScope getSearchScope() {
     return SearchScopeProvider.createSearchScope(getModules());
   }
 
index 775a5e6cf40e254a10d27c97e158e3ed209afce6..3159a8ac56bbc821175ec50220c4788db84538e8 100644 (file)
@@ -56,8 +56,7 @@ public class JavaTestLocator implements SMTestLocator {
       PsiClass aClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), path, null, true, scope);
       if (aClass != null) {
         results = ContainerUtil.newSmartList();
-        results.add(paramName != null ? PsiMemberParameterizedLocation.getParameterizedLocation(aClass, paramName)
-                                      : new PsiLocation<>(project, aClass));
+        results.add(createClassNavigatable(paramName, aClass));
       }
     }
     else if (TEST_PROTOCOL.equals(protocol)) {
@@ -67,11 +66,16 @@ public class JavaTestLocator implements SMTestLocator {
         PsiClass aClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), className, null, true, scope);
         if (aClass != null) {
           results = ContainerUtil.newSmartList();
-          PsiMethod[] methods = aClass.findMethodsByName(methodName.trim(), true);
-          if (methods.length > 0) {
-            for (PsiMethod method : methods) {
-              results.add(paramName != null ? new PsiMemberParameterizedLocation(project, method, aClass, paramName)
-                                            : MethodLocation.elementInClass(method, aClass));
+          if (methodName.trim().equals(aClass.getName())) {
+            results.add(createClassNavigatable(paramName, aClass));
+          }
+          else {
+            PsiMethod[] methods = aClass.findMethodsByName(methodName.trim(), true);
+            if (methods.length > 0) {
+              for (PsiMethod method : methods) {
+                results.add(paramName != null ? new PsiMemberParameterizedLocation(project, method, aClass, paramName)
+                                              : MethodLocation.elementInClass(method, aClass));
+              }
             }
           }
         }
@@ -80,4 +84,9 @@ public class JavaTestLocator implements SMTestLocator {
 
     return results;
   }
+
+  private Location createClassNavigatable(String paramName, @NotNull PsiClass aClass) {
+    return paramName != null ? PsiMemberParameterizedLocation.getParameterizedLocation(aClass, paramName)
+                             : new PsiLocation<>(aClass.getProject(), aClass);
+  }
 }
index 8d6609299bfc3908fa773b2b23ce08d194770a8a..711e1d1bc4ebd8a64cfe448db4b56aa8545b6d45 100644 (file)
@@ -194,8 +194,8 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
         }
       }
     };
-    setFixedColumnWidth(ClasspathTableModel.EXPORT_COLUMN);
-    setFixedColumnWidth(ClasspathTableModel.SCOPE_COLUMN);  // leave space for combobox border
+    setFixedColumnWidth(ClasspathTableModel.EXPORT_COLUMN, ClasspathTableModel.EXPORT_COLUMN_NAME);
+    setFixedColumnWidth(ClasspathTableModel.SCOPE_COLUMN, DependencyScope.COMPILE.toString() + "     ");  // leave space for combobox border
 
     myEntryTable.registerKeyboardAction(
       new ActionListener() {
@@ -320,10 +320,14 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
     return getItemAt(myEntryTable.getSelectedRow());
   }
 
-  private void setFixedColumnWidth(final int columnIndex) {
+  private void setFixedColumnWidth(final int columnIndex, String sampleText) {
     final TableColumn column = myEntryTable.getTableHeader().getColumnModel().getColumn(columnIndex);
+    final FontMetrics fontMetrics = myEntryTable.getFontMetrics(myEntryTable.getFont());
+    final int width = fontMetrics.stringWidth(" " + sampleText + " ") + 4;
+    column.setPreferredWidth(width);
+    column.setMaxWidth(width);
+
     column.setResizable(false);
-    column.setMaxWidth(column.getPreferredWidth());
   }
 
   @Override
index b0ab1c5e9654254c69c2933a7cd927952d193624..40cafb7161cb11ac5cabad8ff85d53b016120e67 100644 (file)
@@ -38,7 +38,7 @@ import java.util.List;
 * @author nik
 */
 class ClasspathTableModel extends ListTableModel<ClasspathTableItem<?>> implements ItemRemovable {
-  private static final String EXPORT_COLUMN_NAME = ProjectBundle.message("modules.order.export.export.column");
+  static final String EXPORT_COLUMN_NAME = ProjectBundle.message("modules.order.export.export.column");
   private static final ColumnInfo<ClasspathTableItem<?>, Boolean> EXPORT_COLUMN_INFO = new ColumnInfo<ClasspathTableItem<?>, Boolean>(EXPORT_COLUMN_NAME) {
     @Nullable
     @Override
index 5c56af03204beb7d17d12903c0daa0dc526a227c..fc968cca6cdab448d811fd4d0b975218ef184b52 100644 (file)
@@ -213,6 +213,10 @@ public class HighlightMethodUtil {
       description).create();
     QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodReturnFix(method, substitutedSuperReturnType, false));
     QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createSuperMethodReturnFix(superMethod, returnType));
+    final PsiClass returnClass = PsiUtil.resolveClassInClassTypeOnly(returnType);
+    if (returnClass != null && substitutedSuperReturnType instanceof PsiClassType) {
+      QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createChangeParameterClassFix(returnClass, (PsiClassType)substitutedSuperReturnType));
+    }
 
     return errorResult;
   }
@@ -1560,9 +1564,11 @@ public class HighlightMethodUtil {
         name += buildArgTypesList(list);
         String description = JavaErrorMessages.message("cannot.resolve.constructor", name);
         HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).navigationShift(+1).create();
-        WrapExpressionFix.registerWrapAction(results, list.getExpressions(), info);
-        registerFixesOnInvalidConstructorCall(constructorCall, classReference, list, aClass, constructors, results, infoElement, info);
-        holder.add(info);
+        if (info != null) {
+          WrapExpressionFix.registerWrapAction(results, list.getExpressions(), info);
+          registerFixesOnInvalidConstructorCall(constructorCall, classReference, list, aClass, constructors, results, infoElement, info);
+          holder.add(info);
+        }
       }
       else {
         if (classReference != null && (!result.isAccessible() ||
@@ -1634,7 +1640,8 @@ public class HighlightMethodUtil {
                                                             PsiExpressionList list,
                                                             PsiClass aClass,
                                                             PsiMethod[] constructors,
-                                                            JavaResolveResult[] results, PsiElement infoElement, HighlightInfo info) {
+                                                            JavaResolveResult[] results, PsiElement infoElement,
+                                                            @NotNull final HighlightInfo info) {
     QuickFixAction
       .registerQuickFixAction(info, constructorCall.getTextRange(), QUICK_FIX_FACTORY.createCreateConstructorFromCallFix(constructorCall));
     if (classReference != null) {
index ef69a97471044d6853dca312e45be8ec547a0420..f8100e070e4f512f44f5a6fb26d62057192f0977 100644 (file)
@@ -114,6 +114,22 @@ public class ModuleHighlightUtil {
     return results;
   }
 
+  private static <T extends PsiElement> void checkDuplicateRefs(Iterable<T> statements,
+                                                                Function<T, Optional<String>> ref,
+                                                                @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String key,
+                                                                List<HighlightInfo> results) {
+    Set<String> filter = ContainerUtil.newTroveSet();
+    for (T statement : statements) {
+      String refText = ref.apply(statement).orElse(null);
+      if (refText != null && !filter.add(refText)) {
+        String message = JavaErrorMessages.message(key, refText);
+        HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).description(message).create();
+        QuickFixAction.registerQuickFixAction(info, new DeleteElementFix(statement));
+        results.add(info);
+      }
+    }
+  }
+
   @NotNull
   static List<HighlightInfo> checkUnusedServices(@NotNull PsiJavaModule module) {
     List<HighlightInfo> results = ContainerUtil.newSmartList();
@@ -148,22 +164,6 @@ public class ModuleHighlightUtil {
     return results;
   }
 
-  private static <T extends PsiElement> void checkDuplicateRefs(Iterable<T> statements,
-                                                                Function<T, Optional<String>> ref,
-                                                                @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String key,
-                                                                List<HighlightInfo> results) {
-    Set<String> filter = ContainerUtil.newTroveSet();
-    for (T statement : statements) {
-      String refText = ref.apply(statement).orElse(null);
-      if (refText != null && !filter.add(refText)) {
-        String message = JavaErrorMessages.message(key, refText);
-        HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).description(message).create();
-        QuickFixAction.registerQuickFixAction(info, new DeleteElementFix(statement));
-        results.add(info);
-      }
-    }
-  }
-
   private static String refText(PsiJavaCodeReferenceElement ref) {
     return PsiNameHelper.getQualifiedClassName(ref.getText(), true);
   }
index b449a9be74233e4a742272f192d107040cb8e597..56c1fceee21fdb2c9c262e4dee7a219e0560c0d6 100644 (file)
@@ -154,7 +154,7 @@ class PostHighlightingVisitor {
       for (Language language : relevantLanguages) {
         progress.checkCanceled();
         PsiElement psiRoot = viewProvider.getPsi(language);
-        if (!HighlightingLevelManager.getInstance(myProject).shouldHighlight(psiRoot)) continue;
+        if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot)) continue;
         List<PsiElement> elements = CollectHighlightsUtil.getElementsInRange(psiRoot, 0, myFile.getTextLength());
         for (PsiElement element : elements) {
           progress.checkCanceled();
@@ -197,7 +197,7 @@ class PostHighlightingVisitor {
     InspectionProfile profile = InspectionProjectProfileManager.getInstance(myProject).getCurrentProfile();
     if (profile.isToolEnabled(unusedImportKey, myFile) &&
         myFile instanceof PsiJavaFile &&
-        HighlightingLevelManager.getInstance(myProject).shouldHighlight(myFile)) {
+        HighlightingLevelManager.getInstance(myProject).shouldInspect(myFile)) {
       return true;
     }
     final ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
index 7798a123b128c56f694315b9e089773eb65ff1bd..d483d57ff252d3b36bf45a2f2249468fc8b0ed2f 100644 (file)
@@ -37,6 +37,8 @@ import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.Collection;
+
 /**
  * @author Tagir Valeev
  */
@@ -84,14 +86,7 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
 
   private static boolean isRaw(PsiVariable variable) {
     PsiType type = variable.getType();
-    if(type instanceof PsiClassType) {
-      PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)type).resolveGenerics();
-      PsiClass element = resolveResult.getElement();
-      if(element != null) {
-        return PsiUtil.isRawSubstitutor(element, resolveResult.getSubstitutor());
-      }
-    }
-    return false;
+    return type instanceof PsiClassType && ((PsiClassType)type).isRaw();
   }
 
   @Nullable
@@ -148,28 +143,18 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
     if(lambdaCandidate == null) return false;
     if(!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[] {lambdaCandidate}).isEmpty()) return false;
     return PsiTreeUtil.processElements(lambdaCandidate, e -> {
-      if(e instanceof PsiReferenceExpression) {
-        PsiElement element = ((PsiReferenceExpression)e).resolve();
-        if(element == optionalVariable) {
-          return e.getParent() instanceof PsiReferenceExpression && e.getParent().getParent() instanceof PsiMethodCallExpression;
-        }
-        return !(element instanceof PsiVariable) ||
-               HighlightControlFlowUtil.isEffectivelyFinal((PsiVariable)element, lambdaCandidate, null);
-      }
-      if(e instanceof PsiMethodCallExpression) {
-        PsiMethodCallExpression methodCall = (PsiMethodCallExpression)e;
-        PsiExpression qualifier = methodCall.getMethodExpression().getQualifierExpression();
-        if(qualifier instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifier).resolve() == optionalVariable) {
-          return methodCall.getArgumentList().getExpressions().length == 0 &&
-                 "get".equals(methodCall.getMethodExpression().getReferenceName());
-        }
-      }
-      return true;
+      if (!(e instanceof PsiReferenceExpression)) return true;
+      PsiElement element = ((PsiReferenceExpression)e).resolve();
+      if(!(element instanceof PsiVariable)) return true;
+      // Check that Optional variable is referenced only in context of get() call and other variables are effectively final
+      return element == optionalVariable
+             ? isOptionalGetCall(e.getParent().getParent(), optionalVariable)
+             : HighlightControlFlowUtil.isEffectivelyFinal((PsiVariable)element, lambdaCandidate, null);
     });
   }
 
   @Contract("null -> false")
-  static boolean isVoidLambdaCandidate(PsiExpression lambdaCandidate) {
+  public static boolean isVoidLambdaCandidate(PsiExpression lambdaCandidate) {
     if(lambdaCandidate == null) return false;
     if(!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[] {lambdaCandidate}).isEmpty()) return false;
     return PsiTreeUtil.processElements(lambdaCandidate, e -> {
@@ -181,7 +166,14 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
   }
 
   static String getComments(PsiStatement statement) {
-    return StreamEx.of(statement.getChildren()).select(PsiComment.class).map(PsiElement::getText).joining(" ");
+    Collection<PsiComment> comments = PsiTreeUtil.collectElementsOfType(statement, PsiComment.class);
+    return StreamEx.of(comments)
+      .filter(c -> c.getParent() == statement ||
+                   (statement instanceof PsiExpressionStatement && c.getParent() == ((PsiExpressionStatement)statement).getExpression()))
+      .flatMap(c -> StreamEx.of(c.getPrevSibling(), c, c.getNextSibling())) // add both siblings for every comment
+      .filter(e -> e instanceof PsiComment || e instanceof PsiWhiteSpace) // select only comments and whitespace
+      .distinct()
+      .map(PsiElement::getText).joining("");
   }
 
   @NotNull
index 2522ce7cd82c3d95b89165dcae13a3653c394698..b5876ba159224c87afaef2c7466b4f55c9e0d902 100644 (file)
@@ -89,7 +89,7 @@ public class DfaPsiUtil {
     if (owner instanceof PsiEnumConstant || PsiUtil.isAnnotationMethod(owner)) {
       return Nullness.NOT_NULL;
     }
-    if (owner instanceof PsiMethod && isEnumValueOf((PsiMethod)owner)) {
+    if (owner instanceof PsiMethod && isEnumPredefinedMethod((PsiMethod)owner)) {
       return Nullness.NOT_NULL;
     }
 
@@ -169,14 +169,14 @@ public class DfaPsiUtil {
     return AnnotationUtil.findAnnotation(owner, anno.getQualifiedName()) == anno;
   }
 
-  private static boolean isEnumValueOf(PsiMethod method) {
-    if ("valueOf".equals(method.getName()) && method.hasModifierProperty(PsiModifier.STATIC)) {
+  private static boolean isEnumPredefinedMethod(PsiMethod method) {
+    String methodName = method.getName();
+    if (("valueOf".equals(methodName) || "values".equals(methodName)) && method.hasModifierProperty(PsiModifier.STATIC)) {
       PsiClass containingClass = method.getContainingClass();
       if (containingClass != null && containingClass.isEnum()) {
         PsiParameter[] parameters = method.getParameterList().getParameters();
-        if (parameters.length == 1 && parameters[0].getType().equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
-          return true;
-        }
+        if ("values".equals(methodName)) return parameters.length == 0;
+        return parameters.length == 1 && parameters[0].getType().equalsToText(CommonClassNames.JAVA_LANG_STRING);
       }
     }
     return false;
index ffcac0a2d3041b3243e47bfe0906d5c9e9432ad9..480ae3e497d0a7681a4e09864f2e2b3ab42137cb 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.
@@ -59,6 +59,7 @@ public class DummyEntryPointsTool extends UnusedDeclarationInspectionBase {
   @Override
   @NotNull
   public String getShortName() {
+    //noinspection InspectionDescriptionNotFoundInspection
     return "";
   }
 }
index 65e7029c1b8e3eb3088464e4a599517aff8671b5..c56feb5040bd33b7287d7e5718b09cf516b2ecdf 100644 (file)
@@ -185,16 +185,19 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
 
   @SuppressWarnings({"HardCodedStringLiteral"})
   public static void writeExternal(final Element element,
-                            final Map<String, SmartRefElementPointer> persistentEntryPoints,
-                            final JDOMExternalizableStringList additional_annotations) {
-    Element entryPointsElement = new Element("entry_points");
-    entryPointsElement.setAttribute(VERSION_ATTR, VERSION);
-    for (SmartRefElementPointer entryPoint : persistentEntryPoints.values()) {
-      assert entryPoint.isPersistent();
-      entryPoint.writeExternal(entryPointsElement);
+                                   final Map<String, SmartRefElementPointer> persistentEntryPoints,
+                                   final JDOMExternalizableStringList additional_annotations) {
+    Collection<SmartRefElementPointer> elementPointers = persistentEntryPoints.values();
+    if (!elementPointers.isEmpty()) {
+      Element entryPointsElement = new Element("entry_points");
+      entryPointsElement.setAttribute(VERSION_ATTR, VERSION);
+      for (SmartRefElementPointer entryPoint : elementPointers) {
+        assert entryPoint.isPersistent();
+        entryPoint.writeExternal(entryPointsElement);
+      }
+      element.addContent(entryPointsElement);
     }
 
-    element.addContent(entryPointsElement);
     if (!additional_annotations.isEmpty()) {
       additional_annotations.writeExternal(element);
     }
index f9a2e8ff514198f58f3be68b2e6448076d0f117f..b23316268de0ec118a1f7d7ca20210445e97720e 100644 (file)
@@ -19,16 +19,16 @@ import com.intellij.codeInsight.ExceptionUtil;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
-import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+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.util.containers.ContainerUtil;
@@ -85,6 +85,51 @@ public class Java8CollectionsApiInspection extends BaseJavaBatchLocalInspectionT
         }
       }
 
+      void handleIteratorLoop(PsiLoopStatement statement, PsiJavaToken endToken, IteratorDeclaration declaration) {
+        if(endToken == null) return;
+        PsiStatement body = statement.getBody();
+        if(!(body instanceof PsiBlockStatement)) return;
+        PsiStatement[] statements = ((PsiBlockStatement)body).getCodeBlock().getStatements();
+        if(statements.length != 2 || !(statements[1] instanceof PsiIfStatement)) return;
+        PsiVariable element = declaration.getNextElementVariable(statements[0]);
+        if(element == null) return;
+        PsiIfStatement ifStatement = (PsiIfStatement)statements[1];
+        PsiExpression condition = ifStatement.getCondition();
+        if(condition == null || ifStatement.getElseBranch() != null) return;
+        PsiStatement thenStatement = ControlFlowUtils.stripBraces(ifStatement.getThenBranch());
+        if(!(thenStatement instanceof PsiExpressionStatement)) return;
+        if(!declaration.isIteratorMethodCall(((PsiExpressionStatement)thenStatement).getExpression(), "remove")) return;
+        if(!OptionalIsPresentInspection.isVoidLambdaCandidate(condition)) return;
+        //noinspection DialogTitleCapitalization
+        holder.registerProblem(statement, new TextRange(0, endToken.getTextOffset() - statement.getTextOffset() + 1),
+                               QuickFixBundle.message("java.8.collections.api.inspection.remove.description"),
+                               new ReplaceWithRemoveIfQuickFix());
+      }
+
+      @Override
+      public void visitForStatement(PsiForStatement statement) {
+        super.visitForStatement(statement);
+        PsiStatement initialization = statement.getInitialization();
+        IteratorDeclaration declaration = IteratorDeclaration.extract(initialization);
+        if(declaration == null) return;
+        if(statement.getUpdate() != null) return;
+        if(!declaration.isHasNextCall(statement.getCondition())) return;
+        handleIteratorLoop(statement, statement.getRParenth(), declaration);
+      }
+
+      @Override
+      public void visitWhileStatement(PsiWhileStatement statement) {
+        super.visitWhileStatement(statement);
+        PsiElement previous = PsiTreeUtil.skipSiblingsBackward(statement, PsiComment.class, PsiWhiteSpace.class);
+        if(!(previous instanceof PsiDeclarationStatement)) return;
+        IteratorDeclaration declaration = IteratorDeclaration.extract((PsiStatement)previous);
+        if(declaration == null || !declaration.isHasNextCall(statement.getCondition())) return;
+        if(!ReferencesSearch.search(declaration.myIterator, declaration.myIterator.getUseScope()).forEach(ref -> {
+          return PsiTreeUtil.isAncestor(statement, ref.getElement(), true);
+        })) return;
+        handleIteratorLoop(statement, statement.getRParenth(), declaration);
+      }
+
       @Override
       public void visitConditionalExpression(PsiConditionalExpression expression) {
         final ConditionInfo conditionInfo = extractConditionInfo(expression.getCondition());
@@ -500,7 +545,7 @@ public class Java8CollectionsApiInspection extends BaseJavaBatchLocalInspectionT
         if (!(expression instanceof PsiAssignmentExpression)) return;
         PsiExpression defaultValue = ((PsiAssignmentExpression)expression).getRExpression();
         if (!ExpressionUtils.isSimpleExpression(defaultValue)) return;
-        if (!FileModificationService.getInstance().preparePsiElementForWrite(element.getContainingFile())) return;
+        if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
         nameElement.replace(factory.createIdentifier("getOrDefault"));
         getCall.getArgumentList().add(defaultValue);
       } else if(thenBranch instanceof PsiBlockStatement) {
@@ -510,7 +555,7 @@ public class Java8CollectionsApiInspection extends BaseJavaBatchLocalInspectionT
         if(assignment == null) return;
         PsiExpression lambdaCandidate = assignment.getRExpression();
         if(lambdaCandidate == null) return;
-        if (!FileModificationService.getInstance().preparePsiElementForWrite(element.getContainingFile())) return;
+        if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
         nameElement.replace(factory.createIdentifier("computeIfAbsent"));
         String varName = JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName("k", lambdaCandidate, true);
         PsiExpression lambda = factory.createExpressionFromText(varName + " -> " + lambdaCandidate.getText(), lambdaCandidate);
@@ -521,4 +566,114 @@ public class Java8CollectionsApiInspection extends BaseJavaBatchLocalInspectionT
       comments.forEach(comment -> statement.getParent().addBefore(comment, statement));
     }
   }
+
+  private static class ReplaceWithRemoveIfQuickFix implements LocalQuickFix {
+    @Nls
+    @NotNull
+    @Override
+    public String getName() {
+      return QuickFixBundle.message("java.8.collections.api.inspection.remove.fix.name");
+    }
+
+    @Nls
+    @NotNull
+    @Override
+    public String getFamilyName() {
+      return getName();
+    }
+
+    @Override
+    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+      PsiElement element = descriptor.getStartElement();
+      if(!(element instanceof PsiLoopStatement)) return;
+      PsiLoopStatement loop = (PsiLoopStatement)element;
+      IteratorDeclaration declaration;
+      PsiElement previous = null;
+      if(loop instanceof PsiForStatement) {
+        declaration = IteratorDeclaration.extract(((PsiForStatement)loop).getInitialization());
+      } else if(loop instanceof PsiWhileStatement) {
+        previous = PsiTreeUtil.skipSiblingsBackward(loop, PsiComment.class, PsiWhiteSpace.class);
+        if(!(previous instanceof PsiDeclarationStatement)) return;
+        declaration = IteratorDeclaration.extract((PsiStatement)previous);
+      } else return;
+      if(declaration == null) return;
+      PsiStatement body = loop.getBody();
+      if(!(body instanceof PsiBlockStatement)) return;
+      PsiStatement[] statements = ((PsiBlockStatement)body).getCodeBlock().getStatements();
+      if(statements.length != 2 || !(statements[1] instanceof PsiIfStatement)) return;
+      PsiVariable variable = declaration.getNextElementVariable(statements[0]);
+      if(variable == null) return;
+      PsiExpression condition = ((PsiIfStatement)statements[1]).getCondition();
+      if(condition == null) return;
+      if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
+      String replacement = (declaration.myCollection == null ? "" : declaration.myCollection.getText() + ".") +
+                           "removeIf(" +
+                           LambdaUtil.createLambda(variable, condition) +
+                           ");";
+      Collection<PsiComment> comments = ContainerUtil.map(PsiTreeUtil.findChildrenOfType(loop, PsiComment.class),
+                                                          comment -> (PsiComment)comment.copy());
+      PsiElement result = loop.replace(JavaPsiFacade.getElementFactory(project).createStatementFromText(replacement, loop));
+      if(previous != null) previous.delete();
+      LambdaCanBeMethodReferenceInspection.replaceAllLambdasWithMethodReferences(result);
+      CodeStyleManager.getInstance(project).reformat(result);
+      comments.forEach(comment -> result.getParent().addBefore(comment, result));
+    }
+  }
+
+  static class IteratorDeclaration {
+    private final @NotNull PsiVariable myIterator;
+    private final @Nullable PsiExpression myCollection;
+
+    private IteratorDeclaration(@NotNull PsiVariable iterator, @Nullable PsiExpression collection) {
+      myIterator = iterator;
+      myCollection = collection;
+    }
+
+    public boolean isHasNextCall(PsiExpression condition) {
+      return isIteratorMethodCall(condition, "hasNext");
+    }
+
+    boolean isIteratorMethodCall(PsiExpression candidate, String method) {
+      if(!(candidate instanceof PsiMethodCallExpression)) return false;
+      PsiMethodCallExpression call = (PsiMethodCallExpression)candidate;
+      if(call.getArgumentList().getExpressions().length != 0) return false;
+      PsiReferenceExpression expression = call.getMethodExpression();
+      if(!method.equals(expression.getReferenceName())) return false;
+      PsiExpression qualifier = expression.getQualifierExpression();
+      if(!(qualifier instanceof PsiReferenceExpression)) return false;
+      return ((PsiReferenceExpression)qualifier).resolve() == myIterator;
+    }
+
+    public PsiVariable getNextElementVariable(PsiStatement statement) {
+      if(!(statement instanceof PsiDeclarationStatement)) return null;
+      PsiDeclarationStatement declaration = (PsiDeclarationStatement)statement;
+      if(declaration.getDeclaredElements().length != 1) return null;
+      PsiElement element = declaration.getDeclaredElements()[0];
+      if(!(element instanceof PsiVariable)) return null;
+      PsiVariable var = (PsiVariable)element;
+      if(!isIteratorMethodCall(var.getInitializer(), "next")) return null;
+      return var;
+    }
+
+    @Contract("null -> null")
+    static IteratorDeclaration extract(PsiStatement statement) {
+      if(!(statement instanceof PsiDeclarationStatement)) return null;
+      PsiDeclarationStatement declaration = (PsiDeclarationStatement)statement;
+      if(declaration.getDeclaredElements().length != 1) return null;
+      PsiElement element = declaration.getDeclaredElements()[0];
+      if(!(element instanceof PsiVariable)) return null;
+      PsiVariable variable = (PsiVariable)element;
+      PsiExpression initializer = variable.getInitializer();
+      if(!(initializer instanceof PsiMethodCallExpression)) return null;
+      PsiMethodCallExpression call = (PsiMethodCallExpression)initializer;
+      if(call.getArgumentList().getExpressions().length != 0) return null;
+      PsiReferenceExpression methodExpression = call.getMethodExpression();
+      if(!"iterator".equals(methodExpression.getReferenceName())) return null;
+      PsiMethod method = call.resolveMethod();
+      if(method == null || !InheritanceUtil.isInheritor(method.getContainingClass(), CommonClassNames.JAVA_UTIL_COLLECTION)) return null;
+      PsiType type = variable.getType();
+      if(!(type instanceof PsiClassType) || !((PsiClassType)type).rawType().equalsToText(CommonClassNames.JAVA_UTIL_ITERATOR)) return null;
+      return new IteratorDeclaration(variable, methodExpression.getQualifierExpression());
+    }
+  }
 }
\ No newline at end of file
index fa3b1b76570214dbc235ed6353d0f120199b5f22..4dd254602a3ee17db8c33ed2a72aee13f37c5882 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInspection.LambdaCanBeMethodReferenceInspection;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
@@ -50,9 +51,8 @@ abstract class MigrateToStreamFix implements LocalQuickFix {
         final PsiParameter parameter = foreachStatement.getIterationParameter();
         StreamApiMigrationInspection.TerminalBlock tb = StreamApiMigrationInspection.TerminalBlock.from(parameter, body);
         if (!FileModificationService.getInstance().preparePsiElementForWrite(foreachStatement)) return;
-        PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
-        List<String> replacements = tb.extractOperationReplacements(factory);
-        migrate(project, descriptor, foreachStatement, iteratedValue, body, tb, replacements);
+        List<Operation> operations = tb.extractOperations();
+        migrate(project, descriptor, foreachStatement, iteratedValue, body, tb, operations);
       }
     }
   }
@@ -63,20 +63,20 @@ abstract class MigrateToStreamFix implements LocalQuickFix {
                         @NotNull PsiExpression iteratedValue,
                         @NotNull PsiStatement body,
                         @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-                        @NotNull List<String> replacements);
+                        @NotNull List<Operation> operations);
 
   static void replaceWithNumericAddition(@NotNull Project project,
                                          PsiForeachStatement foreachStatement,
                                          PsiVariable var,
                                          StringBuilder builder,
-                                         String expressionType) {
+                                         PsiType expressionType) {
     PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
     restoreComments(foreachStatement, foreachStatement.getBody());
     if (StreamApiMigrationInspection.isDeclarationJustBefore(var, foreachStatement)) {
       PsiExpression initializer = var.getInitializer();
       if (ExpressionUtils.isZero(initializer)) {
-        String typeStr = var.getType().getCanonicalText();
-        String replacement = (typeStr.equals(expressionType) ? "" : "(" + typeStr + ") ") + builder;
+        PsiType type = var.getType();
+        String replacement = (type.equals(expressionType) ? "" : "(" + type.getCanonicalText() + ") ") + builder;
         initializer.replace(elementFactory.createExpressionFromText(replacement, foreachStatement));
         removeLoop(foreachStatement);
         simplifyAndFormat(project, var);
@@ -102,7 +102,12 @@ abstract class MigrateToStreamFix implements LocalQuickFix {
   }
 
   @NotNull
-  static StringBuilder generateStream(PsiExpression iteratedValue, List<String> intermediateOps) {
+  static StringBuilder generateStream(PsiExpression iteratedValue, List<Operation> intermediateOps) {
+    return generateStream(iteratedValue, intermediateOps, false);
+  }
+
+  @NotNull
+  static StringBuilder generateStream(PsiExpression iteratedValue, List<Operation> intermediateOps, boolean noStreamForEmpty) {
     StringBuilder buffer = new StringBuilder();
     final PsiType iteratedValueType = iteratedValue.getType();
     if (iteratedValueType instanceof PsiArrayType) {
@@ -110,11 +115,12 @@ abstract class MigrateToStreamFix implements LocalQuickFix {
     }
     else {
       buffer.append(getIteratedValueText(iteratedValue));
-      if (!intermediateOps.isEmpty()) {
+      if (!(noStreamForEmpty && intermediateOps.isEmpty())) {
         buffer.append(".stream()");
       }
     }
-    intermediateOps.forEach(buffer::append);
+    PsiElementFactory factory = JavaPsiFacade.getElementFactory(iteratedValue.getProject());
+    intermediateOps.stream().map(op -> op.createReplacement(factory)).forEach(buffer::append);
     return buffer;
   }
 
index 6735ab979e76de1b12946ad4f01bd4e4c8203971..ba04d8dc5f903f7336e626d279126e1ec0c6de6a 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.codeInspection.streamMigration;
 
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
@@ -23,6 +24,7 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.codeStyle.SuggestedNameInfo;
 import com.intellij.psi.codeStyle.VariableKind;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.util.List;
 
@@ -42,6 +44,16 @@ class ReplaceWithCollectFix extends MigrateToStreamFix {
     return "Replace with " + myMethodName;
   }
 
+  @Nullable
+  PsiType getAddedElementType(PsiMethodCallExpression call) {
+    JavaResolveResult resolveResult = call.resolveMethodGenerics();
+    PsiMethod method = call.resolveMethod();
+    if(method == null) return null;
+    PsiParameter[] parameters = method.getParameterList().getParameters();
+    if(parameters.length != 1) return null;
+    return resolveResult.getSubstitutor().substitute(parameters[0].getType());
+  }
+
   @Override
   void migrate(@NotNull Project project,
                @NotNull ProblemDescriptor descriptor,
@@ -49,7 +61,7 @@ class ReplaceWithCollectFix extends MigrateToStreamFix {
                @NotNull PsiExpression iteratedValue,
                @NotNull PsiStatement body,
                @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-               @NotNull List<String> intermediateOps) {
+               @NotNull List<Operation> operations) {
     final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
     final PsiType iteratedValueType = iteratedValue.getType();
     final PsiMethodCallExpression methodCallExpression = tb.getSingleMethodCall();
@@ -57,7 +69,7 @@ class ReplaceWithCollectFix extends MigrateToStreamFix {
     if (methodCallExpression == null) return;
 
     restoreComments(foreachStatement, body);
-    if (intermediateOps.isEmpty() && StreamApiMigrationInspection.isAddAllCall(tb)) {
+    if (operations.isEmpty() && StreamApiMigrationInspection.isAddAllCall(tb)) {
       final PsiExpression qualifierExpression = methodCallExpression.getMethodExpression().getQualifierExpression();
       final String qualifierText = qualifierExpression != null ? qualifierExpression.getText() : "";
       final String collectionText =
@@ -69,8 +81,10 @@ class ReplaceWithCollectFix extends MigrateToStreamFix {
       return;
     }
     PsiExpression itemToAdd = methodCallExpression.getArgumentList().getExpressions()[0];
-    intermediateOps.add(createMapperFunctionalExpressionText(tb.getVariable(), itemToAdd));
-    final StringBuilder builder = generateStream(iteratedValue, intermediateOps);
+    PsiType addedType = getAddedElementType(methodCallExpression);
+    if (addedType == null) addedType = itemToAdd.getType();
+    operations.add(new StreamApiMigrationInspection.MapOp(itemToAdd, tb.getVariable(), addedType));
+    final StringBuilder builder = generateStream(iteratedValue, operations);
 
     final PsiExpression qualifierExpression = methodCallExpression.getMethodExpression().getQualifierExpression();
     final PsiExpression initializer = StreamApiMigrationInspection
@@ -88,7 +102,7 @@ class ReplaceWithCollectFix extends MigrateToStreamFix {
 
     JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
     SuggestedNameInfo suggestedNameInfo =
-      codeStyleManager.suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, itemToAdd.getType(), false);
+      codeStyleManager.suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, addedType, false);
     if (suggestedNameInfo.names.length == 0) {
       suggestedNameInfo = codeStyleManager.suggestVariableName(VariableKind.LOCAL_VARIABLE, "item", null, itemToAdd.getType(), false);
     }
@@ -124,11 +138,4 @@ class ReplaceWithCollectFix extends MigrateToStreamFix {
       return "toCollection(() -> " + initializer.getText() + ")";
     }
   }
-
-  private static String createMapperFunctionalExpressionText(PsiVariable variable, PsiExpression expression) {
-    if (!StreamApiMigrationInspection.isIdentityMapping(variable, expression)) {
-      return new StreamApiMigrationInspection.MapOp(expression, variable).createReplacement(null);
-    }
-    return "";
-  }
 }
index f2a5367499e766c22da55c2569b974f7138a34cc..119c7a892ddf9bca32ef4175e842e1afd0d22712 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.codeInspection.streamMigration;
 
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import org.jetbrains.annotations.NotNull;
@@ -40,14 +41,14 @@ class ReplaceWithCountFix extends MigrateToStreamFix {
                @NotNull PsiExpression iteratedValue,
                @NotNull PsiStatement body,
                @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-               @NotNull List<String> intermediateOps) {
+               @NotNull List<Operation> operations) {
     PsiExpression operand = StreamApiMigrationInspection.extractIncrementedLValue(tb.getSingleExpression(PsiExpression.class));
     if (!(operand instanceof PsiReferenceExpression)) return;
     PsiElement element = ((PsiReferenceExpression)operand).resolve();
     if (!(element instanceof PsiLocalVariable)) return;
     PsiLocalVariable var = (PsiLocalVariable)element;
-    final StringBuilder builder = generateStream(iteratedValue, intermediateOps);
+    final StringBuilder builder = generateStream(iteratedValue, operations);
     builder.append(".count()");
-    replaceWithNumericAddition(project, foreachStatement, var, builder, "long");
+    replaceWithNumericAddition(project, foreachStatement, var, builder, PsiType.LONG);
   }
 }
index a08fb2c51fd1b59e7a5fe8a9ac34d8c7b11c1ac4..0579ba2557b1b20df3c43165e06b7b445911450d 100644 (file)
 package com.intellij.codeInspection.streamMigration;
 
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
+import com.siyeh.ig.psiutils.EquivalenceChecker;
 import com.siyeh.ig.psiutils.ExpressionUtils;
 import org.jetbrains.annotations.NotNull;
 
@@ -40,10 +42,10 @@ class ReplaceWithFindFirstFix extends MigrateToStreamFix {
                @NotNull PsiExpression iteratedValue,
                @NotNull PsiStatement body,
                @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-               @NotNull List<String> intermediateOps) {
+               @NotNull List<Operation> operations) {
     PsiStatement statement = tb.getSingleStatement();
     PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
-    intermediateOps.add("");
+    String stream = generateStream(iteratedValue, operations).append(".findFirst()").toString();
     if (statement instanceof PsiReturnStatement) {
       PsiReturnStatement returnStatement = (PsiReturnStatement)statement;
       PsiExpression value = returnStatement.getReturnValue();
@@ -52,14 +54,10 @@ class ReplaceWithFindFirstFix extends MigrateToStreamFix {
       if (nextReturnStatement == null) return;
       PsiExpression orElseExpression = nextReturnStatement.getReturnValue();
       if (!ExpressionUtils.isSimpleExpression(orElseExpression)) return;
-      StringBuilder builder = generateStream(iteratedValue, intermediateOps).append(".findFirst()");
-      if (!(value instanceof PsiReferenceExpression) || ((PsiReferenceExpression)value).resolve() != tb.getVariable()) {
-        builder.append(".map(").append(tb.getVariable().getName()).append(" -> ").append(value.getText()).append(")");
-      }
-      builder.append(".orElse(").append(orElseExpression.getText()).append(")");
+      stream = generateOptionalUnwrap(stream, tb, value, orElseExpression);
       restoreComments(foreachStatement, body);
       boolean siblings = nextReturnStatement.getParent() == foreachStatement.getParent();
-      PsiElement result = foreachStatement.replace(elementFactory.createStatementFromText("return " + builder + ";", foreachStatement));
+      PsiElement result = foreachStatement.replace(elementFactory.createStatementFromText("return " + stream + ";", foreachStatement));
       if (siblings) {
         nextReturnStatement.delete();
       }
@@ -77,24 +75,49 @@ class ReplaceWithFindFirstFix extends MigrateToStreamFix {
       PsiVariable var = (PsiVariable)element;
       PsiExpression value = assignment.getRExpression();
       if (value == null) return;
-      StringBuilder builder = generateStream(iteratedValue, intermediateOps).append(".findFirst()");
-      if (!(value instanceof PsiReferenceExpression) || ((PsiReferenceExpression)value).resolve() != tb.getVariable()) {
-        builder.append(".map(").append(tb.getVariable().getName()).append(" -> ").append(value.getText()).append(")");
-      }
       restoreComments(foreachStatement, body);
       if (StreamApiMigrationInspection.isDeclarationJustBefore(var, foreachStatement)) {
         PsiExpression initializer = var.getInitializer();
         if (initializer != null) {
           PsiElement result =
-            initializer.replace(elementFactory.createExpressionFromText(builder + ".orElse(" + initializer.getText() + ")", initializer));
+            initializer.replace(elementFactory.createExpressionFromText(generateOptionalUnwrap(stream, tb, value, initializer), initializer));
           removeLoop(foreachStatement);
           simplifyAndFormat(project, result);
           return;
         }
       }
-      PsiElement result = foreachStatement.replace(
-        elementFactory.createStatementFromText(var.getName() + " = " + builder + ".orElse(" + var.getName() + ");", foreachStatement));
+      PsiElement result = foreachStatement.replace(elementFactory.createStatementFromText(
+        var.getName() + " = " + generateOptionalUnwrap(stream, tb, value, lValue) + ";", foreachStatement));
       simplifyAndFormat(project, result);
     }
   }
+
+  private static String generateOptionalUnwrap(String stream, @NotNull StreamApiMigrationInspection.TerminalBlock tb,
+                                               PsiExpression trueExpression, PsiExpression falseExpression) {
+    PsiVariable var = tb.getVariable();
+    if (!StreamApiMigrationInspection.isIdentityMapping(var, trueExpression)) {
+      if(trueExpression instanceof PsiTypeCastExpression && ExpressionUtils.isNullLiteral(falseExpression)) {
+        PsiTypeCastExpression castExpression = (PsiTypeCastExpression)trueExpression;
+        PsiTypeElement castType = castExpression.getCastType();
+        // pull cast outside to avoid the .map() step
+        if(castType != null && StreamApiMigrationInspection.isIdentityMapping(var, castExpression.getOperand())) {
+          return "(" + castType.getText() + ")" + stream + ".orElse(null)";
+        }
+      }
+      if(ExpressionUtils.isLiteral(falseExpression, Boolean.FALSE) && PsiType.BOOLEAN.equals(trueExpression.getType())) {
+        return stream + ".filter(" + LambdaUtil.createLambda(var, trueExpression) + ").isPresent()";
+      }
+      if(trueExpression instanceof PsiConditionalExpression) {
+        PsiConditionalExpression condition = (PsiConditionalExpression)trueExpression;
+        if(EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(falseExpression, condition.getElseExpression())) {
+          return generateOptionalUnwrap(
+            stream + ".filter(" + LambdaUtil.createLambda(var, condition.getCondition()) + ")", tb,
+            condition.getThenExpression(), falseExpression);
+        }
+      }
+      stream += ".map(" + LambdaUtil.createLambda(var, trueExpression) + ")";
+    }
+    stream += ".orElse(" + falseExpression.getText() + ")";
+    return stream;
+  }
 }
index ac21d3a20f1760346c3303d368316be75afb1790..632aec68f97fb2578969cc4751eda5347405d3d3 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.codeInspection.streamMigration;
 
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
@@ -48,12 +49,12 @@ class ReplaceWithForeachCallFix extends MigrateToStreamFix {
                @NotNull PsiExpression iteratedValue,
                @NotNull PsiStatement body,
                @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-               @NotNull List<String> intermediateOps) {
+               @NotNull List<Operation> operations) {
     restoreComments(foreachStatement, body);
 
     final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
 
-    StringBuilder buffer = generateStream(iteratedValue, intermediateOps);
+    StringBuilder buffer = generateStream(iteratedValue, operations, true);
     PsiElement block = tb.convertToElement(elementFactory);
 
     buffer.append(".").append(myForEachMethodName).append("(");
index 87248f6f06e0a06f9fa72dbe904800bcb456dddd..0488e0e14cfd74da9548237b3d4677a260309406 100644 (file)
 package com.intellij.codeInspection.streamMigration;
 
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.siyeh.ig.psiutils.BoolUtils;
+import com.siyeh.ig.psiutils.ExpressionUtils;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.List;
@@ -49,33 +51,67 @@ class ReplaceWithMatchFix extends MigrateToStreamFix {
                @NotNull PsiExpression iteratedValue,
                @NotNull PsiStatement body,
                @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-               @NotNull List<String> intermediateOps) {
-    PsiReturnStatement returnStatement = (PsiReturnStatement)tb.getSingleStatement();
-    PsiExpression value = returnStatement.getReturnValue();
+               @NotNull List<Operation> operations) {
     PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
-    intermediateOps.add("");
-    restoreComments(foreachStatement, body);
-    if (StreamApiMigrationInspection.isLiteral(value, Boolean.TRUE) || StreamApiMigrationInspection.isLiteral(value, Boolean.FALSE)) {
-      boolean foundResult = (boolean)((PsiLiteralExpression)value).getValue();
-      PsiReturnStatement nextReturnStatement = StreamApiMigrationInspection.getNextReturnStatement(foreachStatement);
-      if (nextReturnStatement != null && StreamApiMigrationInspection.isLiteral(nextReturnStatement.getReturnValue(), !foundResult)) {
-        String methodName = foundResult ? "anyMatch" : "noneMatch";
-        String streamText = generateStream(iteratedValue, intermediateOps).toString();
-        streamText = addTerminalOperation(streamText, methodName, foreachStatement, tb);
-        boolean siblings = nextReturnStatement.getParent() == foreachStatement.getParent();
-        PsiElement result =
-          foreachStatement.replace(elementFactory.createStatementFromText("return " + streamText + ";", foreachStatement));
-        if (siblings) {
-          nextReturnStatement.delete();
+    if(tb.getSingleStatement() instanceof PsiReturnStatement) {
+      PsiReturnStatement returnStatement = (PsiReturnStatement)tb.getSingleStatement();
+      PsiExpression value = returnStatement.getReturnValue();
+      if (ExpressionUtils.isLiteral(value, Boolean.TRUE) || ExpressionUtils.isLiteral(value, Boolean.FALSE)) {
+        boolean foundResult = (boolean)((PsiLiteralExpression)value).getValue();
+        PsiReturnStatement nextReturnStatement = StreamApiMigrationInspection.getNextReturnStatement(foreachStatement);
+        if (nextReturnStatement != null && ExpressionUtils.isLiteral(nextReturnStatement.getReturnValue(), !foundResult)) {
+          String methodName = foundResult ? "anyMatch" : "noneMatch";
+          String streamText = generateStream(iteratedValue, operations).toString();
+          streamText = addTerminalOperation(streamText, methodName, foreachStatement, tb);
+          restoreComments(foreachStatement, body);
+          boolean siblings = nextReturnStatement.getParent() == foreachStatement.getParent();
+          PsiElement result =
+            foreachStatement.replace(elementFactory.createStatementFromText("return " + streamText + ";", foreachStatement));
+          if (siblings) {
+            nextReturnStatement.delete();
+          }
+          simplifyAndFormat(project, result);
+          return;
         }
-        simplifyAndFormat(project, result);
-        return;
       }
     }
-    if (!StreamApiMigrationInspection.isVariableReferenced(tb.getVariable(), value)) {
-      String streamText = generateStream(iteratedValue, intermediateOps).toString();
+    PsiStatement[] statements = tb.getStatements();
+    if(statements.length == 1 || (statements.length == 2 && statements[1] instanceof PsiBreakStatement)) {
+      restoreComments(foreachStatement, body);
+      String streamText = generateStream(iteratedValue, operations).toString();
       streamText = addTerminalOperation(streamText, "anyMatch", foreachStatement, tb);
-      String replacement = "if(" + streamText + "){" + returnStatement.getText() + "}";
+      PsiStatement statement = statements[0];
+      PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(statement);
+      if(assignment != null) {
+        PsiExpression lValue = assignment.getLExpression();
+        PsiExpression rValue = assignment.getRExpression();
+        if (!(lValue instanceof PsiReferenceExpression) || rValue == null) return;
+        PsiElement maybeVar = ((PsiReferenceExpression)lValue).resolve();
+        if(maybeVar instanceof PsiVariable) {
+          // Simplify single assignments like this:
+          // boolean flag = false;
+          // for(....) if(...) {flag = true; break;}
+          PsiVariable var = (PsiVariable)maybeVar;
+          PsiExpression initializer = var.getInitializer();
+          if(initializer != null && StreamApiMigrationInspection.isDeclarationJustBefore(var, foreachStatement)) {
+            String replacement;
+            if(ExpressionUtils.isLiteral(initializer, Boolean.FALSE) &&
+               ExpressionUtils.isLiteral(rValue, Boolean.TRUE)) {
+              replacement = streamText;
+            } else if(ExpressionUtils.isLiteral(initializer, Boolean.TRUE) &&
+                      ExpressionUtils.isLiteral(rValue, Boolean.FALSE)) {
+              replacement = "!"+streamText;
+            } else {
+              replacement = streamText + "?" + rValue.getText() + ":" + initializer.getText();
+            }
+            PsiElement result = initializer.replace(elementFactory.createExpressionFromText(replacement, initializer));
+            removeLoop(foreachStatement);
+            simplifyAndFormat(project, result);
+            return;
+          }
+        }
+      }
+      String replacement = "if(" + streamText + "){" + statement.getText() + "}";
       PsiElement result = foreachStatement.replace(elementFactory.createStatementFromText(replacement, foreachStatement));
       simplifyAndFormat(project, result);
     }
index 94cd6663c9d6e98f31457ee583394c2ffc189429..918f0ed6049df35d8b8daec6ba7415de6445f788 100644 (file)
 package com.intellij.codeInspection.streamMigration;
 
 import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.Operation;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.List;
-import java.util.Locale;
 
 /**
  * @author Tagir Valeev
@@ -41,7 +41,7 @@ class ReplaceWithSumFix extends MigrateToStreamFix {
                @NotNull PsiExpression iteratedValue,
                @NotNull PsiStatement body,
                @NotNull StreamApiMigrationInspection.TerminalBlock tb,
-               @NotNull List<String> intermediateOps) {
+               @NotNull List<Operation> operations) {
     PsiAssignmentExpression assignment = tb.getSingleExpression(PsiAssignmentExpression.class);
     if (assignment == null) return;
     PsiVariable var = StreamApiMigrationInspection.extractAccumulator(assignment);
@@ -50,22 +50,13 @@ class ReplaceWithSumFix extends MigrateToStreamFix {
     PsiExpression addend = StreamApiMigrationInspection.extractAddend(assignment);
     if (addend == null) return;
     PsiType type = var.getType();
-    if (!(type instanceof PsiPrimitiveType)) return;
-    PsiPrimitiveType primitiveType = (PsiPrimitiveType)type;
-    if (primitiveType.equalsToText("float")) return;
-    String typeName;
-    if (primitiveType.equalsToText("double")) {
-      typeName = "Double";
+    if (!(type instanceof PsiPrimitiveType) || type.equals(PsiType.FLOAT)) return;
+    if (!type.equals(PsiType.DOUBLE) && !type.equals(PsiType.LONG)) {
+      type = PsiType.INT;
     }
-    else if (primitiveType.equalsToText("long")) {
-      typeName = "Long";
-    }
-    else {
-      typeName = "Int";
-    }
-    intermediateOps.add(".mapTo" + typeName + "(" + StreamApiMigrationInspection.createLambda(tb.getVariable(), addend) + ")");
-    final StringBuilder builder = generateStream(iteratedValue, intermediateOps);
+    operations.add(new StreamApiMigrationInspection.MapOp(addend, tb.getVariable(), type));
+    final StringBuilder builder = generateStream(iteratedValue, operations);
     builder.append(".sum()");
-    replaceWithNumericAddition(project, foreachStatement, var, builder, typeName.toLowerCase(Locale.ENGLISH));
+    replaceWithNumericAddition(project, foreachStatement, var, builder, type);
   }
 }
index a1b841123c9f97295b50a3cd02379a8a3c0ab1e2..aad571a9b6fa1c838444550bd575ba5d8178d2df 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
-import com.intellij.pom.java.LanguageLevel;
 import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.*;
 import com.intellij.psi.controlFlow.*;
@@ -98,164 +97,15 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
   @NotNull
   @Override
   public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override
-      public void visitForeachStatement(PsiForeachStatement statement) {
-        super.visitForeachStatement(statement);
-        if (PsiUtil.getLanguageLevel(statement).isAtLeast(LanguageLevel.JDK_1_8)) {
-          final PsiExpression iteratedValue = statement.getIteratedValue();
-          final PsiStatement body = statement.getBody();
-          if (iteratedValue != null && body != null) {
-            final PsiType iteratedValueType = iteratedValue.getType();
-            final PsiClass iteratorClass = PsiUtil.resolveClassInClassTypeOnly(iteratedValueType);
-            PsiClass collectionClass = null;
-            final boolean isArray;
-            if(iteratedValueType instanceof PsiArrayType) {
-              // Do not handle primitive types now
-              if(((PsiArrayType)iteratedValueType).getComponentType() instanceof PsiPrimitiveType) return;
-              isArray = true;
-            } else {
-              collectionClass = JavaPsiFacade.getInstance(body.getProject()).findClass(CommonClassNames.JAVA_UTIL_COLLECTION, statement.getResolveScope());
-              if (collectionClass != null && InheritanceUtil.isInheritorOrSelf(iteratorClass, collectionClass, true)) {
-                isArray = false;
-              } else return;
-            }
-            try {
-              if (ExceptionUtil.getThrownCheckedExceptions(new PsiElement[]{body}).isEmpty()) {
-                TerminalBlock tb = TerminalBlock.from(statement.getIterationParameter(), body);
-                List<Operation> operations = tb.extractOperations();
-
-                if(tb.isEmpty()) return;
-
-                final ControlFlow controlFlow = ControlFlowFactory.getInstance(holder.getProject())
-                  .getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance());
-                final Collection<PsiStatement> exitPoints = ControlFlowUtil
-                  .findExitPointsAndStatements(controlFlow, tb.getStartOffset(controlFlow), tb.getEndOffset(controlFlow),
-                                               new IntArrayList(), PsiContinueStatement.class,
-                                               PsiBreakStatement.class, PsiReturnStatement.class, PsiThrowStatement.class);
-                int startOffset = controlFlow.getStartOffset(body);
-                int endOffset = controlFlow.getEndOffset(body);
-                final List<PsiVariable> nonFinalVariables = StreamEx
-                  .of(ControlFlowUtil.getUsedVariables(controlFlow, startOffset, endOffset))
-                  .remove(variable -> HighlightControlFlowUtil.isEffectivelyFinal(variable, body, null))
-                  .toList();
-
-                if (exitPoints.isEmpty()) {
-                  if(getIncrementedVariable(tb, operations, nonFinalVariables) != null) {
-                    registerProblem(holder, isOnTheFly, statement, "count", new ReplaceWithCountFix());
-                  }
-                  if(getAccumulatedVariable(tb, operations, nonFinalVariables) != null) {
-                    registerProblem(holder, isOnTheFly, statement, "sum", new ReplaceWithSumFix());
-                  }
-                  if(!nonFinalVariables.isEmpty()) {
-                    return;
-                  }
-                  if ((isArray || !isRawSubstitution(iteratedValueType, collectionClass)) && isCollectCall(tb, operations)) {
-                    boolean addAll = operations.isEmpty() && isAddAllCall(tb);
-                    String methodName;
-                    if(addAll) {
-                      methodName = "addAll";
-                    } else {
-                      PsiMethodCallExpression methodCallExpression = tb.getSingleMethodCall();
-                      if(methodCallExpression != null && extractReplaceableCollectionInitializer(
-                        methodCallExpression.getMethodExpression().getQualifierExpression(), statement) != null) {
-                        methodName = "collect";
-                      } else {
-                        if (!SUGGEST_FOREACH) return;
-                        methodName = "forEach";
-                      }
-                    }
-                    registerProblem(holder, isOnTheFly, statement, methodName, new ReplaceWithCollectFix(methodName));
-                  }
-                  // do not replace for(T e : arr) {} with Arrays.stream(arr).forEach(e -> {}) even if flag is set
-                  else if (SUGGEST_FOREACH && (!operations.isEmpty() ||
-                           (!isArray && (REPLACE_TRIVIAL_FOREACH || !isTrivial(body, statement.getIterationParameter()))))) {
-                    final List<LocalQuickFix> fixes = new ArrayList<>();
-                    fixes.add(new ReplaceWithForeachCallFix("forEach"));
-                    if (!operations.isEmpty()) {
-                      //for .stream()
-                      fixes.add(new ReplaceWithForeachCallFix("forEachOrdered"));
-                    }
-                    registerProblem(holder, isOnTheFly, statement, "forEach", fixes.toArray(new LocalQuickFix[fixes.size()]));
-                  }
-                } else {
-                  if (operations.isEmpty() && !REPLACE_TRIVIAL_FOREACH) return;
-                  if (nonFinalVariables.isEmpty() && tb.getSingleStatement() instanceof PsiReturnStatement) {
-                    handleSingleReturn(statement, tb, operations);
-                  }
-                  if (nonFinalVariables.size() == 1) {
-                    PsiStatement[] statements = tb.getStatements();
-                    if (statements.length == 2) {
-                      PsiStatement breakStatement = statements[1];
-                      if (!(breakStatement instanceof PsiBreakStatement) ||
-                          ((PsiBreakStatement)breakStatement).findExitedStatement() != statement) {
-                        return;
-                      }
-                      PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(statements[0]);
-                      if(assignment == null) return;
-                      PsiExpression lValue = assignment.getLExpression();
-                      if (!(lValue instanceof PsiReferenceExpression)) return;
-                      PsiElement var = ((PsiReferenceExpression)lValue).resolve();
-                      if(!(var instanceof PsiVariable) || !nonFinalVariables.contains(var)) return;
-                      PsiExpression rValue = assignment.getRExpression();
-                      if(rValue == null || isVariableReferenced((PsiVariable)var, rValue)) return;
-                      registerProblem(holder, isOnTheFly, statement, "findFirst", new ReplaceWithFindFirstFix());
-                    }
-                  }
-                }
-              }
-            }
-            catch (AnalysisCanceledException ignored) {
-            }
-          }
-        }
-      }
-
-      void handleSingleReturn(PsiForeachStatement statement,
-                              TerminalBlock tb,
-                              List<Operation> operations) {
-        PsiReturnStatement returnStatement = (PsiReturnStatement)tb.getSingleStatement();
-        PsiExpression value = returnStatement.getReturnValue();
-        PsiReturnStatement nextReturnStatement = getNextReturnStatement(statement);
-        if(nextReturnStatement != null && (isLiteral(value, Boolean.TRUE) || isLiteral(value, Boolean.FALSE))) {
-          boolean foundResult = (boolean)((PsiLiteralExpression)value).getValue();
-          if(isLiteral(nextReturnStatement.getReturnValue(), !foundResult)) {
-            String methodName;
-            if (foundResult) {
-              methodName = "anyMatch";
-            }
-            else {
-              methodName = "noneMatch";
-              if(!operations.isEmpty()) {
-                Operation lastOp = operations.get(operations.size() - 1);
-                if(lastOp instanceof FilterOp && BoolUtils.isNegation(lastOp.getExpression())) {
-                  methodName = "allMatch";
-                }
-              }
-            }
-            registerProblem(holder, isOnTheFly, statement, methodName, new ReplaceWithMatchFix(methodName));
-            return;
-          }
-        }
-        if (!isVariableReferenced(tb.getVariable(), value)) {
-          registerProblem(holder, isOnTheFly, statement, "anyMatch", new ReplaceWithMatchFix("anyMatch"));
-        }
-        if(nextReturnStatement != null && ExpressionUtils.isSimpleExpression(nextReturnStatement.getReturnValue())) {
-          registerProblem(holder, isOnTheFly, statement, "findFirst", new ReplaceWithFindFirstFix());
-        }
-      }
-
-      private boolean isRawSubstitution(PsiType iteratedValueType, PsiClass collectionClass) {
-        return iteratedValueType instanceof PsiClassType && PsiUtil
-          .isRawSubstitutor(collectionClass, TypeConversionUtil.getSuperClassSubstitutor(collectionClass, (PsiClassType)iteratedValueType));
-      }
-    };
+    if (!PsiUtil.isLanguageLevel8OrHigher(holder.getFile())) {
+      return PsiElementVisitor.EMPTY_VISITOR;
+    }
+    return new StreamApiMigrationVisitor(holder, isOnTheFly);
   }
 
   @Contract("_, null -> false")
   static boolean isVariableReferenced(PsiVariable variable, PsiExpression value) {
-    return !PsiTreeUtil
-      .processElements(value, e -> !(e instanceof PsiReferenceExpression) || ((PsiReferenceExpression)e).resolve() != variable);
+    return value != null && ReferencesSearch.search(variable, new LocalSearchScope(value)).findFirst() != null;
   }
 
   @Nullable
@@ -274,44 +124,6 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
     return null;
   }
 
-  @NotNull
-  private TextRange getRange(PsiForeachStatement statement, boolean isOnTheFly) {
-    boolean wholeStatement = false;
-    if(isOnTheFly) {
-      if (myKey == null) {
-        myKey = HighlightDisplayKey.find(getShortName());
-      }
-      if (myKey != null) {
-        InspectionProfile profile = InspectionProjectProfileManager.getInstance(statement.getProject()).getCurrentProfile();
-        HighlightDisplayLevel level = profile.getErrorLevel(myKey, statement);
-        wholeStatement = HighlightDisplayLevel.DO_NOT_SHOW.equals(level);
-      }
-    }
-    PsiExpression iteratedValue = statement.getIteratedValue();
-    LOG.assertTrue(iteratedValue != null);
-    PsiJavaToken rParenth = statement.getRParenth();
-    if(wholeStatement && rParenth != null) {
-      return new TextRange(statement.getTextOffset(), rParenth.getTextOffset() + 1);
-    }
-    return iteratedValue.getTextRange();
-  }
-
-  private void registerProblem(ProblemsHolder holder,
-                               boolean isOnTheFly,
-                               PsiForeachStatement statement,
-                               String methodName,
-                               LocalQuickFix... fixes) {
-    PsiExpression iteratedValue = statement.getIteratedValue();
-    LOG.assertTrue(iteratedValue != null);
-    holder.registerProblem(statement, getRange(statement, isOnTheFly).shiftRight(-statement.getTextOffset()),
-                           "Can be replaced with '" + methodName + "' call", fixes);
-  }
-
-  @Contract("null, _ -> false")
-  static boolean isLiteral(PsiElement element, Object value) {
-    return element instanceof PsiLiteralExpression && value.equals(((PsiLiteralExpression)element).getValue());
-  }
-
   @Contract("null, null -> true; null, !null -> false")
   private static boolean sameReference(PsiExpression expr1, PsiExpression expr2) {
     if(expr1 == null && expr2 == null) return true;
@@ -378,7 +190,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
       }
     } else if(expression instanceof PsiAssignmentExpression) {
       PsiAssignmentExpression assignment = (PsiAssignmentExpression)expression;
-      if(isLiteral(extractAddend(assignment), 1)) {
+      if(ExpressionUtils.isLiteral(extractAddend(assignment), 1)) {
         return assignment.getLExpression();
       }
     }
@@ -542,6 +354,13 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
     return method != null && isThrowsCompatible(method);
   }
 
+  static boolean isSupported(PsiType type) {
+    if(type instanceof PsiPrimitiveType) {
+      return type.equals(PsiType.INT) || type.equals(PsiType.LONG) || type.equals(PsiType.DOUBLE);
+    }
+    return true;
+  }
+
   private static boolean isThrowsCompatible(PsiMethod method) {
     return ContainerUtil.find(method.getThrowsList().getReferencedTypes(), type -> !ExceptionUtil.isUncheckedException(type)) != null;
   }
@@ -551,10 +370,6 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
     return mapperCall instanceof PsiReferenceExpression && ((PsiReferenceExpression)mapperCall).resolve() == variable;
   }
 
-  static String createLambda(PsiVariable variable, PsiExpression expression) {
-    return variable.getName() + " -> " + expression.getText();
-  }
-
   @Nullable
   private static PsiClassType createDefaultConsumerType(Project project, PsiVariable variable) {
     final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
@@ -598,6 +413,201 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
     return false;
   }
 
+  private class StreamApiMigrationVisitor extends JavaElementVisitor {
+    private final ProblemsHolder myHolder;
+    private final boolean myIsOnTheFly;
+
+    public StreamApiMigrationVisitor(ProblemsHolder holder, boolean isOnTheFly) {
+      myHolder = holder;
+      myIsOnTheFly = isOnTheFly;
+    }
+
+    @Override
+    public void visitForeachStatement(PsiForeachStatement statement) {
+      super.visitForeachStatement(statement);
+      final PsiExpression iteratedValue = statement.getIteratedValue();
+      final PsiStatement body = statement.getBody();
+      if (iteratedValue == null || body == null) return;
+
+      final PsiType iteratedValueType = iteratedValue.getType();
+      final PsiClass iteratorClass = PsiUtil.resolveClassInClassTypeOnly(iteratedValueType);
+      PsiClass collectionClass = null;
+      final boolean isArray;
+      if(iteratedValueType instanceof PsiArrayType) {
+        if(!isSupported(((PsiArrayType)iteratedValueType).getComponentType())) return;
+        isArray = true;
+      } else {
+        collectionClass = JavaPsiFacade.getInstance(body.getProject()).findClass(CommonClassNames.JAVA_UTIL_COLLECTION, statement.getResolveScope());
+        if (collectionClass != null && InheritanceUtil.isInheritorOrSelf(iteratorClass, collectionClass, true)) {
+          isArray = false;
+        } else return;
+      }
+      if (!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[]{body}).isEmpty()) return;
+
+      TerminalBlock tb = TerminalBlock.from(statement.getIterationParameter(), body);
+      List<Operation> operations = tb.extractOperations();
+      if(tb.isEmpty()) return;
+
+      final ControlFlow controlFlow;
+      try {
+        controlFlow = ControlFlowFactory.getInstance(myHolder.getProject())
+          .getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance());
+      }
+      catch (AnalysisCanceledException ignored) {
+        return;
+      }
+      final Collection<PsiStatement> exitPoints = ControlFlowUtil
+        .findExitPointsAndStatements(controlFlow, tb.getStartOffset(controlFlow), tb.getEndOffset(controlFlow),
+                                     new IntArrayList(), PsiContinueStatement.class,
+                                     PsiBreakStatement.class, PsiReturnStatement.class, PsiThrowStatement.class);
+      int startOffset = controlFlow.getStartOffset(body);
+      int endOffset = controlFlow.getEndOffset(body);
+      final List<PsiVariable> nonFinalVariables = StreamEx.of(ControlFlowUtil.getUsedVariables(controlFlow, startOffset, endOffset))
+        .remove(variable -> HighlightControlFlowUtil.isEffectivelyFinal(variable, body, null)).toList();
+
+      if (exitPoints.isEmpty()) {
+        if(getIncrementedVariable(tb, operations, nonFinalVariables) != null) {
+          registerProblem(statement, "count", new ReplaceWithCountFix());
+        }
+        if(getAccumulatedVariable(tb, operations, nonFinalVariables) != null) {
+          registerProblem(statement, "sum", new ReplaceWithSumFix());
+        }
+        if(!nonFinalVariables.isEmpty()) {
+          return;
+        }
+        if ((isArray || !isRawSubstitution(iteratedValueType, collectionClass)) && isCollectCall(tb, operations)) {
+          boolean addAll = operations.isEmpty() && isAddAllCall(tb);
+          String methodName;
+          if(addAll) {
+            methodName = "addAll";
+          } else {
+            PsiMethodCallExpression methodCallExpression = tb.getSingleMethodCall();
+            if(methodCallExpression != null && extractReplaceableCollectionInitializer(
+              methodCallExpression.getMethodExpression().getQualifierExpression(), statement) != null) {
+              methodName = "collect";
+            } else {
+              if (!SUGGEST_FOREACH) return;
+              methodName = "forEach";
+            }
+          }
+          registerProblem(statement, methodName, new ReplaceWithCollectFix(methodName));
+        }
+        // do not replace for(T e : arr) {} with Arrays.stream(arr).forEach(e -> {}) even if flag is set
+        else if (SUGGEST_FOREACH && (!operations.isEmpty() ||
+                                     (!isArray && (REPLACE_TRIVIAL_FOREACH || !isTrivial(body, statement.getIterationParameter()))))) {
+          ReplaceWithForeachCallFix forEachFix = new ReplaceWithForeachCallFix("forEach");
+          LocalQuickFix[] fixes = {forEachFix};
+          if (!operations.isEmpty()) { //for .stream()
+            fixes = new LocalQuickFix[] {forEachFix, new ReplaceWithForeachCallFix("forEachOrdered")};
+          }
+          registerProblem(statement, "forEach", fixes);
+        }
+      } else {
+        if (operations.isEmpty() && !REPLACE_TRIVIAL_FOREACH) return;
+        if (nonFinalVariables.isEmpty() && tb.getSingleStatement() instanceof PsiReturnStatement) {
+          handleSingleReturn(statement, tb, operations);
+        }
+        PsiStatement[] statements = tb.getStatements();
+        if (statements.length == 2) {
+          PsiStatement breakStatement = statements[1];
+          if (!(breakStatement instanceof PsiBreakStatement) ||
+              ((PsiBreakStatement)breakStatement).findExitedStatement() != statement) {
+            return;
+          }
+          if (ReferencesSearch.search(tb.getVariable(), new LocalSearchScope(statements)).findFirst() == null
+            && exitPoints.size() == 1 && exitPoints.contains(breakStatement)) {
+            registerProblem(statement, "anyMatch", new ReplaceWithMatchFix("anyMatch"));
+            return;
+          }
+          if (nonFinalVariables.size() == 1) {
+            PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(statements[0]);
+            if(assignment == null) return;
+            PsiExpression lValue = assignment.getLExpression();
+            if (!(lValue instanceof PsiReferenceExpression)) return;
+            PsiElement var = ((PsiReferenceExpression)lValue).resolve();
+            if(!(var instanceof PsiVariable) || !nonFinalVariables.contains(var)) return;
+            PsiExpression rValue = assignment.getRExpression();
+            if(rValue == null || isVariableReferenced((PsiVariable)var, rValue)) return;
+            if(tb.getVariable() instanceof PsiPrimitiveType && !isIdentityMapping(tb.getVariable(), rValue)) return;
+            registerProblem(statement, "findFirst", new ReplaceWithFindFirstFix());
+          }
+        }
+      }
+    }
+
+    void handleSingleReturn(PsiForeachStatement statement,
+                            TerminalBlock tb,
+                            List<Operation> operations) {
+      PsiReturnStatement returnStatement = (PsiReturnStatement)tb.getSingleStatement();
+      PsiExpression value = returnStatement.getReturnValue();
+      PsiReturnStatement nextReturnStatement = getNextReturnStatement(statement);
+      if(nextReturnStatement != null && (ExpressionUtils.isLiteral(value, Boolean.TRUE) || ExpressionUtils.isLiteral(value, Boolean.FALSE))) {
+        boolean foundResult = (boolean)((PsiLiteralExpression)value).getValue();
+        if(ExpressionUtils.isLiteral(nextReturnStatement.getReturnValue(), !foundResult)) {
+          String methodName;
+          if (foundResult) {
+            methodName = "anyMatch";
+          }
+          else {
+            methodName = "noneMatch";
+            if(!operations.isEmpty()) {
+              Operation lastOp = operations.get(operations.size() - 1);
+              if(lastOp instanceof FilterOp && (((FilterOp)lastOp).isNegated() ^ BoolUtils.isNegation(lastOp.getExpression()))) {
+                methodName = "allMatch";
+              }
+            }
+          }
+          registerProblem(statement, methodName, new ReplaceWithMatchFix(methodName));
+          return;
+        }
+      }
+      if (!isVariableReferenced(tb.getVariable(), value)) {
+        if(!REPLACE_TRIVIAL_FOREACH && operations.isEmpty() || (operations.size() == 1 && operations.get(0) instanceof FilterOp)) {
+          return;
+        }
+        registerProblem(statement, "anyMatch", new ReplaceWithMatchFix("anyMatch"));
+      }
+      if(nextReturnStatement != null && ExpressionUtils.isSimpleExpression(nextReturnStatement.getReturnValue())
+         && (!(tb.getVariable().getType() instanceof PsiPrimitiveType) || isIdentityMapping(tb.getVariable(), value))) {
+        registerProblem(statement, "findFirst", new ReplaceWithFindFirstFix());
+      }
+    }
+
+    private boolean isRawSubstitution(PsiType iteratedValueType, PsiClass collectionClass) {
+      return iteratedValueType instanceof PsiClassType && PsiUtil
+        .isRawSubstitutor(collectionClass, TypeConversionUtil.getSuperClassSubstitutor(collectionClass, (PsiClassType)iteratedValueType));
+    }
+
+    @NotNull
+    private TextRange getRange(PsiForeachStatement statement) {
+      boolean wholeStatement = false;
+      if(myIsOnTheFly) {
+        if (myKey == null) {
+          myKey = HighlightDisplayKey.find(getShortName());
+        }
+        if (myKey != null) {
+          InspectionProfile profile = InspectionProjectProfileManager.getInstance(statement.getProject()).getCurrentProfile();
+          HighlightDisplayLevel level = profile.getErrorLevel(myKey, statement);
+          wholeStatement = HighlightDisplayLevel.DO_NOT_SHOW.equals(level);
+        }
+      }
+      PsiExpression iteratedValue = statement.getIteratedValue();
+      LOG.assertTrue(iteratedValue != null);
+      PsiJavaToken rParenth = statement.getRParenth();
+      if(wholeStatement && rParenth != null) {
+        return new TextRange(statement.getTextOffset(), rParenth.getTextOffset() + 1);
+      }
+      return iteratedValue.getTextRange();
+    }
+
+    private void registerProblem(PsiForeachStatement statement, String methodName, LocalQuickFix... fixes) {
+      PsiExpression iteratedValue = statement.getIteratedValue();
+      LOG.assertTrue(iteratedValue != null);
+      myHolder.registerProblem(statement, getRange(statement).shiftRight(-statement.getTextOffset()),
+                               "Can be replaced with '" + methodName + "' call", fixes);
+    }
+  }
+
   /**
    * Intermediate stream operation representation
    */
@@ -625,22 +635,57 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
       myNegated = negated;
     }
 
+    public boolean isNegated() {
+      return myNegated;
+    }
+
     @Override
     public String createReplacement(PsiElementFactory factory) {
       PsiExpression expression =
         myNegated ? factory.createExpressionFromText(BoolUtils.getNegatedExpressionText(myExpression), myExpression) : myExpression;
-      return ".filter(" + createLambda(myVariable, expression) + ")";
+      return ".filter(" + LambdaUtil.createLambda(myVariable, expression) + ")";
     }
   }
 
   static class MapOp extends Operation {
-    MapOp(PsiExpression expression, PsiVariable variable) {
+    private final @Nullable PsiType myType;
+
+    MapOp(PsiExpression expression, PsiVariable variable, @Nullable PsiType targetType) {
       super(expression, variable);
+      myType = targetType;
     }
 
     @Override
     public String createReplacement(PsiElementFactory factory) {
-      return ".map(" + createLambda(myVariable, myExpression) + ")";
+      if (isIdentityMapping(myVariable, myExpression)) {
+        if (!(myType instanceof PsiPrimitiveType)) {
+          return myVariable.getType() instanceof PsiPrimitiveType ? ".boxed()" : "";
+        }
+        if(myType.equals(myVariable.getType())) {
+          return "";
+        }
+        if (PsiType.LONG.equals(myType) && PsiType.INT.equals(myVariable.getType())) {
+          return ".asLongStream()";
+        }
+        if (PsiType.DOUBLE.equals(myType) && (PsiType.LONG.equals(myVariable.getType()) || PsiType.INT.equals(myVariable.getType()))) {
+          return ".asDoubleStream()";
+        }
+      }
+      String operationName = "map";
+      if(myType instanceof PsiPrimitiveType) {
+        if(!myType.equals(myVariable.getType())) {
+          if(PsiType.INT.equals(myType)) {
+            operationName = "mapToInt";
+          } else if(PsiType.LONG.equals(myType)) {
+            operationName = "mapToLong";
+          } else if(PsiType.DOUBLE.equals(myType)) {
+            operationName = "mapToDouble";
+          }
+        }
+      } else if(myVariable.getType() instanceof PsiPrimitiveType) {
+        operationName = "mapToObj";
+      }
+      return "." + operationName + "(" + LambdaUtil.createLambda(myVariable, myExpression) + ")";
     }
   }
 
@@ -652,7 +697,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
     @Override
     public String createReplacement(PsiElementFactory factory) {
       PsiExpression replacement = factory.createExpressionFromText(myExpression.getText() + ".stream()", myExpression);
-      return ".flatMap(" + createLambda(myVariable, replacement) + ")";
+      return ".flatMap(" + LambdaUtil.createLambda(myVariable, replacement) + ")";
     }
   }
 
@@ -664,7 +709,21 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
     @Override
     public String createReplacement(PsiElementFactory factory) {
       PsiExpression replacement = factory.createExpressionFromText("java.util.Arrays.stream("+myExpression.getText() + ")", myExpression);
-      return ".flatMap(" + createLambda(myVariable, replacement) + ")";
+      String operation = "flatMap";
+      PsiType type = myExpression.getType();
+      if(type instanceof PsiArrayType) {
+        PsiType componentType = ((PsiArrayType)type).getComponentType();
+        if(componentType instanceof PsiPrimitiveType) {
+          if(componentType.equals(PsiType.INT)) {
+            operation = "flatMapToInt";
+          } else if(componentType.equals(PsiType.LONG)) {
+            operation = "flatMapToLong";
+          } else if(componentType.equals(PsiType.DOUBLE)) {
+            operation = "flatMapToDouble";
+          }
+        }
+      }
+      return "." + operation + "(" + LambdaUtil.createLambda(myVariable, replacement) + ")";
     }
   }
 
@@ -741,6 +800,8 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
       }
       // extract flatMap
       if(getSingleStatement() instanceof PsiForeachStatement) {
+        // flatMapping of primitive variable is not supported yet
+        if(myVariable.getType() instanceof PsiPrimitiveType) return null;
         PsiForeachStatement foreachStatement = (PsiForeachStatement)getSingleStatement();
         final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
         final PsiStatement body = foreachStatement.getBody();
@@ -748,9 +809,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
           final PsiType iteratedValueType = iteratedValue.getType();
           Operation op = null;
           if(iteratedValueType instanceof PsiArrayType) {
-            // do not handle flatMapToPrimitive
-            if (((PsiArrayType)iteratedValueType).getComponentType() instanceof PsiPrimitiveType)
-              return null;
+            if (!isSupported(((PsiArrayType)iteratedValueType).getComponentType())) return null;
             op = new ArrayFlatMapOp(iteratedValue, myVariable);
           } else {
             final PsiClass iteratorClass = PsiUtil.resolveClassInClassTypeOnly(iteratedValueType);
@@ -778,14 +837,13 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
             PsiElement element = elements[0];
             if(element instanceof PsiLocalVariable) {
               PsiLocalVariable declaredVar = (PsiLocalVariable)element;
-              // do not handle mapToPrimitive
-              if(!(declaredVar.getType() instanceof PsiPrimitiveType)) {
+              if(isSupported(declaredVar.getType())) {
                 PsiExpression initializer = declaredVar.getInitializer();
                 PsiStatement[] leftOver = Arrays.copyOfRange(myStatements, 1, myStatements.length);
                 if (initializer != null &&
                     ReferencesSearch.search(myVariable, new LocalSearchScope(leftOver))
                       .findFirst() == null) {
-                  MapOp op = new MapOp(initializer, myVariable);
+                  MapOp op = new MapOp(initializer, myVariable, declaredVar.getType());
                   myVariable = declaredVar;
                   myStatements = leftOver;
                   flatten();
@@ -846,18 +904,6 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
       return new TerminalBlock(variable, new PsiStatement[] {statement});
     }
 
-    @NotNull
-    List<String> extractOperationReplacements(PsiElementFactory factory) {
-      List<String> intermediateOps = new ArrayList<>();
-      while(true) {
-        Operation operation = extractOperation();
-        if(operation == null)
-          break;
-        intermediateOps.add(operation.createReplacement(factory));
-      }
-      return intermediateOps;
-    }
-
     /**
      * Converts this TerminalBlock to PsiElement (either PsiStatement or PsiCodeBlock)
      *
index 0c78591db4ea3eaa1549ec05d77c45c32d313f30..b7c1fa91e2bd4e756f19f3e08061545cad9a77c7 100644 (file)
@@ -28,28 +28,7 @@ public class JavaCodeFoldingOptionsProvider extends BeanConfigurable<JavaCodeFol
   public JavaCodeFoldingOptionsProvider() {
     super(JavaCodeFoldingSettings.getInstance());
     JavaCodeFoldingSettings settings = getInstance();
-    checkBox(ApplicationBundle.message("checkbox.collapse.boolean.parameters"), settings::isInlineParameterNamesForLiteralCallArguments, settings::setInlineParameterNamesForLiteralCallArguments);
-    JavaCodeFoldingSettingsPanel panel = new JavaCodeFoldingSettingsPanel();
-
-    component(panel.getRow0(),
-              () -> null,
-              pair -> {},
-              () -> null,
-              pair -> {}
-              );
-    component(panel.getRow1(),
-              settings::getInlineLiteralParameterMinNameLength,
-              settings::setInlineLiteralParameterMinNameLength,
-              panel::getMinNameLengthThresholdText,
-              panel::setMinNameLengthThresholdText
-              );
-    component(panel.getRow2(),
-              settings::getInlineLiteralParameterMinArgumentsToFold,
-              settings::setInlineLiteralParameterMinArgumentsToFold,
-              panel::getMinArgumentsToFoldText,
-              panel::setMinArgumentsToFoldText
-              );
-
+    
     checkBox(ApplicationBundle.message("checkbox.collapse.one.line.methods"), settings::isCollapseOneLineMethods, settings::setCollapseOneLineMethods);
 
     checkBox(ApplicationBundle.message("checkbox.collapse.simple.property.accessors"), settings::isCollapseAccessors, settings::setCollapseAccessors);
diff --git a/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingSettingsPanel.form b/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingSettingsPanel.form
deleted file mode 100644 (file)
index 1f6df57..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.editor.JavaCodeFoldingSettingsPanel">
-  <grid id="27dc6" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-    <margin top="0" left="0" bottom="0" right="0"/>
-    <constraints>
-      <xy x="20" y="20" width="852" height="97"/>
-    </constraints>
-    <properties/>
-    <border type="none"/>
-    <children>
-      <grid id="bc2a4" binding="row1" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children>
-          <component id="a067a" class="javax.swing.JTextField" binding="minNameLengthThresholdText">
-            <constraints>
-              <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
-                <preferred-size width="150" height="-1"/>
-              </grid>
-            </constraints>
-            <properties/>
-          </component>
-          <component id="2746f" class="javax.swing.JLabel">
-            <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="5" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <text value="Minimum Parameter Name Length:"/>
-            </properties>
-          </component>
-        </children>
-      </grid>
-      <grid id="8e464" binding="row2" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children>
-          <component id="11578" class="javax.swing.JLabel">
-            <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="5" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <text value="Minimum Number of Arguments To Fold:"/>
-            </properties>
-          </component>
-          <component id="dc29a" class="javax.swing.JTextField" binding="minArgumentsToFoldText">
-            <constraints>
-              <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
-                <preferred-size width="150" height="-1"/>
-              </grid>
-            </constraints>
-            <properties/>
-          </component>
-        </children>
-      </grid>
-      <grid id="72ed7" binding="row0" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children>
-          <component id="c0ee0" class="com.intellij.ui.TitledSeparator">
-            <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <text value="Literal Arguments Options"/>
-            </properties>
-          </component>
-        </children>
-      </grid>
-    </children>
-  </grid>
-</form>
diff --git a/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingSettingsPanel.java b/java/java-impl/src/com/intellij/application/options/editor/JavaCodeFoldingSettingsPanel.java
deleted file mode 100644 (file)
index 802a174..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.application.options.editor;
-
-import javax.swing.*;
-
-public class JavaCodeFoldingSettingsPanel {
-  private JTextField minNameLengthThresholdText;
-  private JTextField minArgumentsToFoldText;
-  private JPanel row0;
-  private JPanel row1;
-  private JPanel row2;
-
-  int getMinNameLengthThresholdText() {
-    try {
-      return Integer.parseInt(minNameLengthThresholdText.getText());
-    }
-    catch (NumberFormatException e) {
-      return 3;
-    }
-  }
-
-  void setMinNameLengthThresholdText(int value) {
-    minNameLengthThresholdText.setText(String.valueOf(value));
-  }
-
-  int getMinArgumentsToFoldText() {
-    try {
-      return Integer.parseInt(minArgumentsToFoldText.getText());
-    }
-    catch (NumberFormatException e) {
-      return 2;
-    }
-  }
-
-  void setMinArgumentsToFoldText(int value) {
-    minArgumentsToFoldText.setText(String.valueOf(value));
-  }
-
-  JComponent getRow0() {
-    return row0;
-  }
-
-  JPanel getRow1() {
-    return row1;
-  }
-
-  JPanel getRow2() {
-    return row2;
-  }
-}
index 07d0424651c98e0decedbd29b0f0caebac021a20..9f0356289781dfdc2faba334f8113f2a042b5519 100644 (file)
@@ -295,7 +295,7 @@ public class JavaTargetElementEvaluator extends TargetElementEvaluatorEx2 implem
         } else {
           if (element instanceof PsiClass) {
             psiClass = (PsiClass)element;
-            final PsiElement resolve = reference.resolve();
+            final PsiElement resolve = ((PsiReferenceExpression)reference).advancedResolve(true).getElement();
             if (resolve instanceof PsiClass) {