Merge remote-tracking branch 'origin/master'
authorKonstantin Bulenkov <kb@jetbrains.com>
Fri, 3 Jul 2015 13:25:08 +0000 (15:25 +0200)
committerKonstantin Bulenkov <kb@jetbrains.com>
Fri, 3 Jul 2015 13:25:08 +0000 (15:25 +0200)
498 files changed:
RegExpSupport/src/META-INF/RegExpPlugin.xml
bin/scripts/unix/idea.sh
build/scripts/dist.gant
java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java
java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/UnusedSymbolUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java
java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddMethodQualifierFix.java
java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/IfStatementSelectioner.java
java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java
java/java-impl/src/com/intellij/codeInsight/navigation/JavaGotoSuperHandler.java
java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/FormatPostfixTemplate.java
java/java-impl/src/com/intellij/codeInspection/java18StreamApi/AddMethodsDialog.form
java/java-impl/src/com/intellij/codeInspection/java18StreamApi/AddMethodsDialog.java
java/java-impl/src/com/intellij/codeInspection/java18StreamApi/PseudoLambdaReplaceTemplate.java [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInspection/java18StreamApi/StaticPseudoFunctionalStyleMethodInspection.java
java/java-impl/src/com/intellij/codeInspection/java18StreamApi/StaticPseudoFunctionalStyleMethodOptions.java
java/java-impl/src/com/intellij/ide/JavaFilePasteProvider.java
java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
java/java-impl/src/com/intellij/ide/util/SuperMethodWarningUtil.java
java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java
java/java-impl/src/com/intellij/psi/formatter/java/wrap/JavaWrapManager.java
java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java
java/java-impl/src/com/intellij/refactoring/rename/JavaVetoRenameCondition.java
java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java
java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaAllOverridingMethodsSearcher.java
java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java
java/java-psi-api/src/com/intellij/codeInsight/AnnotationTargetUtil.java
java/java-psi-api/src/com/intellij/psi/PsiReceiverParameter.java
java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java
java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java
java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java
java/java-psi-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java
java/java-psi-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java [deleted file]
java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiReceiverParameterImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ParameterListElement.java
java/java-psi-impl/src/messages/JavaErrorMessages.properties
java/java-tests/testData/codeInsight/completion/normal/MethodCallBeforeAnnotation2.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/normal/MethodCallBeforeAnnotation2_After.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/InitializedBeforeUsed.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnsupportedFeatures7.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/package-info.java [moved from java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/invalidPackageAnnotationTarget/package-info.java with 100% similarity]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/packageAnnotationNotInPackageInfo.java [moved from java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/packageAnnotationNotInPackageInfo/notPackageInfo.java with 100% similarity]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/receiverParameters.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/typeAnnotations.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawClassTypeOnConstructorReference.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/gotosuper/SiblingInheritance.after.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/gotosuper/SiblingInheritance.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/diamondResolve/test.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/diamondResolve/test_after.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/lambdaIsVariable/test.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/lambdaIsVariable/test_after.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/lambdaIsntAnonymous/test_after.java
java/java-tests/testData/inspection/lambdaLibsStatic/lambdaIsntAnonymous2/test_after.java
java/java-tests/testData/inspection/lambdaLibsStatic/missingTypeParameters/test.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/missingTypeParameters/test_after.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/simpleFind/test.java
java/java-tests/testData/inspection/lambdaLibsStatic/simpleFind/test_after.java
java/java-tests/testData/inspection/lambdaLibsStatic/simpleTransform/test_after.java
java/java-tests/testData/inspection/lambdaLibsStatic/transformLambda/test.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/transformLambda/test_after.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/transformMethodCalling/test.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/transformMethodCalling/test_after.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/transformMethodRef/test.java [new file with mode: 0644]
java/java-tests/testData/inspection/lambdaLibsStatic/transformMethodRef/test_after.java [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/declarations/Receiver.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/AnnotatedRefExpr1.txt
java/java-tests/testData/refactoring/extractMethod/FromLambdaBodyToToplevelInsideCodeBlock.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/FromLambdaBodyToToplevelInsideCodeBlock_after.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/completion/TabCompletionTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/AnnotationsHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/JavaGotoSuperTest.java [moved from java/java-tests/testSrc/com/intellij/codeInsight/navigation/JavaGotoSuperTest.java with 51% similarity]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
java/java-tests/testSrc/com/intellij/codeInspection/StaticPseudoFunctionalStyleMethodTest.java
java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java
java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/AnnotationParserTest.java
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/FileParserTest.java
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ReferenceParserTest.java
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/StatementParserTest.java
java/java-tests/testSrc/com/intellij/psi/JavaStubBuilderTest.java
java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/IdCacheTest.java
java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
java/testFramework/src/com/intellij/codeInsight/completion/LightFixtureCompletionTestCase.java
java/typeMigration/src/META-INF/TypeMigration.xml
jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java
jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java
lib/org/hamcrest/annotations.xml [new file with mode: 0644]
platform/built-in-server/testSrc/BinaryRequestHandlerTest.kt
platform/built-in-server/testSrc/RestApiTest.kt
platform/built-in-server/testSrc/TestManager.kt
platform/core-api/src/com/intellij/lang/LighterLazyParseableNode.java
platform/core-api/src/com/intellij/lang/PsiBuilder.java
platform/core-api/src/com/intellij/lang/PsiParser.java
platform/core-api/src/com/intellij/lang/WhitespacesAndCommentsBinder.java
platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeRegistry.java
platform/core-api/src/com/intellij/openapi/options/SchemesManager.java
platform/core-api/src/com/intellij/psi/stubs/PsiFileStubImpl.java
platform/core-impl/core-impl.iml
platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java
platform/core-impl/src/com/intellij/diagnostic/PerformanceWatcher.java
platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
platform/core-impl/src/com/intellij/lang/TokenWrapper.java
platform/core-impl/src/com/intellij/lang/impl/DelegateMarker.java
platform/core-impl/src/com/intellij/lang/impl/PsiBuilderAdapter.java
platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java
platform/core-impl/src/com/intellij/openapi/application/actions.kt [new file with mode: 0644]
platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java [deleted file]
platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java
platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
platform/core-impl/src/com/intellij/psi/impl/SharedPsiElementImplUtil.java
platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/core-impl/src/com/intellij/psi/impl/source/tree/ASTStructure.java
platform/core-impl/src/com/intellij/psi/impl/source/tree/Factory.java
platform/core-impl/src/com/intellij/psi/impl/source/tree/SharedImplUtil.java
platform/diff-impl/src/com/intellij/diff/applications/DiffApplication.java
platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java
platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java
platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java
platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
platform/lang-api/src/com/intellij/codeInsight/daemon/MergeableLineMarkerInfo.java
platform/lang-api/src/com/intellij/codeInsight/daemon/NavigateAction.java
platform/lang-api/src/com/intellij/codeInsight/daemon/RelatedItemLineMarkerInfo.java
platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java
platform/lang-api/src/com/intellij/execution/runners/BaseProgramRunner.java
platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsCustomizable.java
platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.form
platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java
platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java
platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/BackgroundUpdaterTask.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateTree.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateSettings.java
platform/lang-impl/src/com/intellij/codeInsight/template/postfix/templates/StringBasedPostfixTemplate.java
platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java
platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java
platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java
platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java
platform/lang-impl/src/com/intellij/find/FindUtil.java
platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
platform/lang-impl/src/com/intellij/find/impl/ShowRecentFindUsagesGroup.java
platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java
platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java
platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/ExportableFileTemplateSettings.java
platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FTManager.java
platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java
platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeFactory.java
platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeManager.java
platform/lang-impl/src/com/intellij/openapi/file/exclude/PersistentFileSetManager.java
platform/lang-impl/src/com/intellij/openapi/file/exclude/ProjectPlainTextFileTypeManager.java
platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleFacadeImpl.java
platform/lang-impl/src/com/intellij/ui/ColorLineMarkerProvider.java
platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
platform/platform-api/src/com/intellij/codeStyle/CodeStyleFacade.java
platform/platform-api/src/com/intellij/openapi/fileTypes/MockFileTypeManager.java
platform/platform-api/src/com/intellij/ui/AbstractCollectionComboBoxModel.java
platform/platform-api/src/com/intellij/ui/TextFieldWithHistoryWithBrowseButton.java
platform/platform-impl/platform-impl.iml
platform/platform-impl/src/com/intellij/ide/actions/CloseAllUnpinnedEditorsAction.java
platform/platform-impl/src/com/intellij/ide/actions/CutAction.java
platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
platform/platform-impl/src/com/intellij/ide/actions/PasteAction.java
platform/platform-impl/src/com/intellij/ide/diff/VirtualFileDiffElement.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StreamProvider.java [deleted file]
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StreamProvider.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/PreciseMouseWheelScroller.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeyboardShortcutDialog.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.form
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsPanel.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsUi.java
platform/platform-impl/src/com/intellij/openapi/options/SchemeManagerImpl.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java
platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java [deleted file]
platform/platform-impl/src/com/intellij/openapi/options/ex/SingleConfigurableEditor.java
platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressDialog.java
platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java
platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/FileNameCache.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java
platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
platform/platform-impl/src/com/intellij/ui/messages/SheetController.java
platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java
platform/platform-impl/src/com/intellij/util/ui/CollectionModelEditor.java
platform/platform-impl/src/com/intellij/util/ui/ListModelEditor.java
platform/platform-impl/src/com/intellij/util/ui/ListModelEditorBase.java
platform/platform-impl/src/com/intellij/util/ui/SwingHelper.java
platform/platform-impl/src/com/intellij/util/ui/table/TableModelEditor.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources-en/src/messages/ApplicationBundle.properties
platform/platform-resources-en/src/messages/ExecutionBundle.properties
platform/platform-resources-en/src/messages/OptionsBundle.properties
platform/platform-resources-en/src/messages/VcsBundle.properties
platform/platform-resources/src/META-INF/LangExtensions.xml
platform/platform-resources/src/META-INF/XmlActions.xml
platform/platform-resources/src/checkedPlugins.txt
platform/platform-resources/src/idea/LangActions.xml
platform/platform-tests/platform-tests.iml
platform/platform-tests/testData/editor/multiCaret/EditorSwapSelectionBoundaries-after.txt
platform/platform-tests/testData/options/different-extensions/1.icls [new file with mode: 0644]
platform/platform-tests/testData/options/different-extensions/1.xml [new file with mode: 0644]
platform/platform-tests/testData/options/options/1.xml [new file with mode: 0644]
platform/platform-tests/testData/options/options1/1.xml [new file with mode: 0644]
platform/platform-tests/testData/options/options1/2.xml [new file with mode: 0644]
platform/platform-tests/testSrc/bundledSchemes/default.xml [new file with mode: 0644]
platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ApplicationStoreTest.java [deleted file]
platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ApplicationStoreTest.kt [new file with mode: 0644]
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/CharArrayTest.java [deleted file]
platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java
platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
platform/platform-tests/testSrc/com/intellij/options/MockStreamProvider.kt [new file with mode: 0644]
platform/platform-tests/testSrc/com/intellij/options/SchemeManagerTest.kt [new file with mode: 0644]
platform/script-debugger/protocol/protocol-model-generator/src/Generator.kt
platform/script-debugger/protocol/protocol-model-generator/src/NamePath.kt
platform/script-debugger/protocol/protocol-model-generator/src/TypeMap.kt
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/history/ImportedTestConsoleProperties.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/history/ImportedTestContentHandler.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/history/actions/AbstractImportTestsAction.java
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java
platform/testFramework/src/com/intellij/mock/MockFileTypeManager.java
platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java
platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
platform/testFramework/src/com/intellij/util/GCUtil.java
platform/testFramework/testSrc/com/intellij/testFramework/FixtureRule.kt [moved from platform/testFramework/testSrc/FixtureRule.kt with 69% similarity]
platform/testFramework/testSrc/com/intellij/testFramework/TemporaryDirectory.kt [new file with mode: 0644]
platform/testFramework/testSrc/com/intellij/testFramework/matchers.kt [new file with mode: 0644]
platform/testRunner/src/com/intellij/execution/testframework/Filter.java
platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java
platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java
platform/testRunner/src/com/intellij/execution/testframework/actions/TestFrameworkActions.java
platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java
platform/testRunner/src/com/intellij/execution/testframework/export/TestResultsXmlFormatter.java
platform/usageView/src/com/intellij/usages/actions/RemoveUsageAction.java [new file with mode: 0644]
platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
platform/util/resources/misc/registry.properties
platform/util/src/com/intellij/openapi/util/Ref.java
platform/util/src/com/intellij/openapi/util/io/FileUtil.java
platform/util/src/com/intellij/util/containers/LimitedPool.java
platform/util/src/com/intellij/util/containers/OrderedSet.java
platform/util/src/com/intellij/util/diff/DiffTree.java
platform/util/src/com/intellij/util/diff/FlyweightCapableTreeStructure.java
platform/util/src/com/intellij/util/io/Page.java
platform/util/src/com/intellij/util/text/ByteArrayCharSequence.java
platform/util/src/com/intellij/util/text/CharArrayUtil.java
platform/util/src/com/intellij/util/ui/ThreeStateCheckBox.java
platform/util/src/com/intellij/util/xmlb/SkipDefaultValuesSerializationFilters.java
platform/util/testSrc/com/intellij/openapi/util/io/FileUtilHeavyTest.java
platform/util/testSrc/com/intellij/util/diff/DiffTreeTest.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SessionDialog.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/abstraction/PublicMethodNotExposedInInterfaceInspectionBase.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classlayout/NoopMethodInAbstractClassInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/EqualityToEqualsFix.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryWithIdenticalCatchesInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CanBeStaticVisitor.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/DefiniteAssignmentUtil.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/FinalUtils.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/InstanceOfUtils.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/VariableAccessUtils.java
plugins/InspectionGadgets/test/com/siyeh/igfixes/bugs/castConflicts/replaceInstanceofInFront.after.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igfixes/bugs/castConflicts/replaceInstanceofInFront.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igfixes/migration/try_finally_can_be_try_with_resources/Dependents.after.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igfixes/migration/try_finally_can_be_try_with_resources/Dependents.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/andAnd/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/elseElse/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/elseElseOrOr/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/notOr/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/orInstanceofOrInstanceof/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/polyadic/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/simple/expected.xml [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/AndAnd.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/andAnd/AndAnd.java with 100% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/AssertCheckBefore.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/ElseElse.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/elseElse/ElseElse.java with 97% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/ElseElseOrOr.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/elseElseOrOr/ElseElse.java with 97% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/IfCheckBefore.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/IfElseCheckBefore.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/NotOr.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/notOr/NotOr.java with 100% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/OrInstanceofOrInstanceof.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/orInstanceofOrInstanceof/OrInstanceofOrInstanceof.java with 100% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/Polyadic.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/polyadic/ElseElse.java with 74% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/cast_conflicts_with_instanceof/Simple.java [moved from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/castConflictingInstanceof/simple/ElseElse.java with 86% similarity]
plugins/InspectionGadgets/test/com/siyeh/igtest/migration/try_finally_can_be_try_with_resources/TryFinallyCanBeTryWithResources.java
plugins/InspectionGadgets/test/com/siyeh/igtest/performance/field_may_be_static/FieldMayBeStatic.java
plugins/InspectionGadgets/test/com/siyeh/igtest/style/field_final/FieldMayBeFinal.java
plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/CastConflictsWithInstanceofInspectionTest.java
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/bugs/CastConflictsWithInstanceofFixesTest.java
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/TryFinallyCanBeTryWithResourcesFixTest.java
plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties
plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/AddFileOrDirectoryAction.java
plugins/devkit/resources/META-INF/plugin.xml
plugins/devkit/resources/fileTemplates/j2ee/Action.java.html
plugins/devkit/resources/fileTemplates/j2ee/ApplicationComponent.java.html
plugins/devkit/resources/fileTemplates/j2ee/InspectionDescription.html.html
plugins/devkit/resources/fileTemplates/j2ee/ModuleComponent.java.html
plugins/devkit/resources/fileTemplates/j2ee/ProjectComponent.java.html
plugins/devkit/resources/fileTemplates/j2ee/plugin.xml.html
plugins/editorconfig/src/org/editorconfig/plugincomponents/SettingsProviderComponent.java
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringAction.java
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java
plugins/git4idea/src/git4idea/stash/GitShelveUtils.java
plugins/google-app-engine/resources/fileTemplates/j2ee/AppEngineApplication.xml.html
plugins/google-app-engine/resources/fileTemplates/j2ee/AppEngineJdoConfig.xml.html
plugins/google-app-engine/resources/fileTemplates/j2ee/AppEngineJpaConfig.xml.html
plugins/google-app-engine/resources/fileTemplates/j2ee/AppEngineWeb.xml.html
plugins/google-app-engine/source/com/intellij/appengine/actions/UploadApplicationAction.java
plugins/groovy/groovy-psi/resources/fileTemplates/code/Groovy JUnit SetUp Method.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Groovy JUnit TearDown Method.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Groovy JUnit Test Case.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Groovy JUnit Test Method.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Groovy New Method Body.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Spock Test Method.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Spock cleanup Method.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/code/Spock_SetUp_Method.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GantScript.gant.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyAnnotation.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyClass.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyDslScript.gdsl.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyEnum.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyInterface.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyScript.groovy.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyServerPage.gsp.html
plugins/groovy/groovy-psi/resources/fileTemplates/j2ee/GroovyTrait.groovy.html
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInsight/GroovyClsCustomNavigationPolicy.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/AstTransformContributor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/AutoCloneContributor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/AutoExternalizeContributor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/ConstructorAnnotationsProcessor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/GrInheritConstructorContributor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ast/LoggingContributor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyLineMarkerProvider.java
plugins/java-i18n/src/META-INF/plugin.xml
plugins/javaFX/resources/fileTemplates/JavaFXApplication.java.html
plugins/junit/src/com/intellij/execution/junit2/ui/properties/JUnitConsoleProperties.java
plugins/junit/src/fileTemplates/code/JUnit3 SetUp Method.java.html
plugins/junit/src/fileTemplates/code/JUnit3 TearDown Method.java.html
plugins/junit/src/fileTemplates/code/JUnit3 Test Class.java.html
plugins/junit/src/fileTemplates/code/JUnit3 Test Method.java.html
plugins/junit/src/fileTemplates/code/JUnit4 Parameters Method.java.html
plugins/junit/src/fileTemplates/code/JUnit4 SetUp Method.java.html
plugins/junit/src/fileTemplates/code/JUnit4 TearDown Method.java.html
plugins/junit/src/fileTemplates/code/JUnit4 Test Class.java.html
plugins/junit/src/fileTemplates/code/JUnit4 Test Method.java.html
plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java
plugins/testng/src/com/theoryinpractice/testng/model/TestNGConsoleProperties.java
plugins/testng/src/fileTemplates/code/TestNG Parameters Method.java.html
plugins/testng/src/fileTemplates/code/TestNG SetUp Method.java.html
plugins/testng/src/fileTemplates/code/TestNG TearDown Method.java.html
plugins/testng/src/fileTemplates/code/TestNG Test Class.java.html
plugins/testng/src/fileTemplates/code/TestNG Test Method.java.html
plugins/testng/testSources/com/theoryinpractice/testng/configuration/TestNGTreeHierarchyTest.java
plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java
python/build/pycharm_community_build.gant
python/edu/build/pycharm_edu_build.gant
python/helpers/profiler/load_pstat.py
python/helpers/profiler/prof_io.py
python/pluginResources/META-INF/plugin.xml
python/pluginTestSrc/com/jetbrains/jython/PyJythonHighlightingTest.java
python/pluginTestSrc/com/jetbrains/jython/PyToJavaResolveTest.java
python/psi-api/src/com/jetbrains/python/psi/impl/PyPsiUtils.java
python/python-plugin-tests.iml
python/src/com/jetbrains/python/codeInsight/PyMethodNameTypedHandler.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyArgumentListFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyClassFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyConditionalStatementPartFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyExceptFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyForPartFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyFunctionFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyMissingBracesFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParameterListFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyUnconditionalStatementPartFixer.java
python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyWithFixer.java
python/src/com/jetbrains/python/codeInsight/intentions/PySplitIfIntention.java
python/src/com/jetbrains/python/documentation/DocStringUtil.java
python/src/com/jetbrains/python/inspections/quickfix/AddCallSuperQuickFix.java
python/src/com/jetbrains/python/psi/PyUtil.java
python/src/com/jetbrains/python/psi/impl/PyArgumentListImpl.java
python/src/com/jetbrains/python/psi/impl/PyAugAssignmentStatementImpl.java
python/src/com/jetbrains/python/psi/impl/PyElementGeneratorImpl.java
python/src/com/jetbrains/python/psi/impl/PyParameterListImpl.java
python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java
python/src/com/jetbrains/python/psi/types/PyImportedModuleType.java
python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodHandler.java
python/testData/inspections/AddCallSuper1_after.py
python/testData/inspections/AddCallSuperCommentAfterColonPreserved.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperCommentAfterColonPreserved_after.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperCommentsInFunctionBodyPreserved.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperCommentsInFunctionBodyPreserved_after.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperNoRequiredKeywordOnlyParamAfterSingleStarInSuperInit.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperNoRequiredKeywordOnlyParamAfterSingleStarInSuperInit_after.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperRequiredKeywordOnlyParamAfterSingleStarInSuperInitIsMerged.py [new file with mode: 0644]
python/testData/inspections/AddCallSuperRequiredKeywordOnlyParamAfterSingleStarInSuperInitIsMerged_after.py [new file with mode: 0644]
python/testData/inspections/AddCallSuper_after.py
python/testData/inspections/PyUnresolvedReferencesInspection/ImplicitlyImportedSubModule/a.py [new file with mode: 0644]
python/testData/inspections/PyUnresolvedReferencesInspection/ImplicitlyImportedSubModule/pkg1/__init__.py [new file with mode: 0644]
python/testData/inspections/PyUnresolvedReferencesInspection/ImplicitlyImportedSubModule/pkg1/m1.py [new file with mode: 0644]
python/testData/inspections/PyUnresolvedReferencesInspection/ImplicitlyImportedSubModule/pkg1/m2.py [new file with mode: 0644]
python/testData/inspections/PyUnresolvedReferencesInspection3K/NotImportedSubmodulesOfNamespacePackage/main.py [deleted file]
python/testData/inspections/PyUnresolvedReferencesInspection3K/NotImportedSubmodulesOfNamespacePackage/nspkg1/m2.py [deleted file]
python/testData/inspections/PyUnresolvedReferencesInspection3K/NotImportedSubmodulesOfNamespacePackage/nspkg1/m3.py [deleted file]
python/testData/inspections/PyUnresolvedReferencesInspection3K/NotImportedSubmodulesOfNamespacePackage/nspkg1/nssubpkg1/m1.py [deleted file]
python/testData/inspections/unusedImport/unusedSubmodule/p1/__init__.py [deleted file]
python/testData/inspections/unusedImport/unusedSubmodule/p1/m1.py [deleted file]
python/testData/inspections/unusedImport/unusedSubmodule/p1/m2.py [deleted file]
python/testData/inspections/unusedImport/unusedSubmodule/test1.py [deleted file]
python/testData/resolve/multiFile/fromImportSubModuleDunderAll/FromImportSubModuleDunderAll.py [new file with mode: 0644]
python/testData/resolve/multiFile/fromImportSubModuleDunderAll/pkg1/__init__.py [new file with mode: 0644]
python/testData/resolve/multiFile/fromImportSubModuleDunderAll/pkg1/m1.py [new file with mode: 0644]
python/testData/resolve/multiFile/importSubModuleDunderAll/ImportSubModuleDunderAll.py [new file with mode: 0644]
python/testData/resolve/multiFile/importSubModuleDunderAll/pkg1/__init__.py [new file with mode: 0644]
python/testData/resolve/multiFile/importSubModuleDunderAll/pkg1/m1.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/Py3QuickFixTest.java
python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java
python/testSrc/com/jetbrains/python/PyQuickFixTest.java
python/testSrc/com/jetbrains/python/PyWrapTest.java
python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
python/testSrc/com/jetbrains/python/inspections/PyUnusedImportTest.java
resources-en/src/fileTemplates/code/Catch Statement Body.java.html
resources-en/src/fileTemplates/code/I18nized Concatenation.java.html
resources-en/src/fileTemplates/code/I18nized Expression.java.html
resources-en/src/fileTemplates/code/I18nized JSP Expression.jsp.html
resources-en/src/fileTemplates/code/Implemented Method Body.java.html
resources-en/src/fileTemplates/code/New Method Body.java.html
resources-en/src/fileTemplates/code/Overridden Method Body.java.html
resources-en/src/fileTemplates/default.html
resources-en/src/fileTemplates/includes/File Header.java.html
resources-en/src/fileTemplates/includes/default.html
resources-en/src/fileTemplates/internal/AnnotationType.java.html
resources-en/src/fileTemplates/internal/Class.java.html
resources-en/src/fileTemplates/internal/Enum.java.html
resources-en/src/fileTemplates/internal/Interface.java.html
resources-en/src/fileTemplates/internal/package-info.java.html
resources-en/src/inspectionDescriptions/StaticPseudoFunctionalStyleMethod.html
resources/src/META-INF/IdeaPlugin.xml
xml/impl/src/com/intellij/application/options/HtmlLanguageCodeStyleSettings.java
xml/impl/src/com/intellij/application/options/XmlLanguageCodeStyleSettingsProvider.java
xml/tests/src/com/intellij/editor/XmlEditorTest.java
xml/xml-psi-impl/src/com/intellij/embedding/MasqueradingPsiBuilderAdapter.java

index 3e7ce6ac9352fe96683c206df5b92f41d06379e7..efb7cc1286380011cddd9ecd7cbdbf4aaf00055c 100644 (file)
@@ -21,7 +21,7 @@
 
     <intentionAction>
       <className>org.intellij.lang.regexp.intention.CheckRegExpIntentionAction</className>
-      <category>Declaration</category>
+      <category>RegExp/Declaration</category>
     </intentionAction>
   </extensions>
 </idea-plugin>
index ca721e9082fdda7c2019f134ee960f37312c4483..b08d1d94c241598611861c775d93b3b805699391 100755 (executable)
@@ -61,7 +61,7 @@ IDE_BIN_HOME=`dirname "$SCRIPT_LOCATION"`
 # ---------------------------------------------------------------------
 if [ -n "$@@product_uc@@_JDK" -a -x "$@@product_uc@@_JDK/bin/java" ]; then
   JDK="$@@product_uc@@_JDK"
-elif [ -x "$IDE_HOME/jre/bin/java" ] && "$IDE_HOME/jre/bin/java" -version > /dev/null 2>&1 ; then
+elif [ -x "$IDE_HOME/jre/jre/bin/java" ] && "$IDE_HOME/jre/jre/bin/java" -version > /dev/null 2>&1 ; then
   JDK="$IDE_HOME/jre"
 elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
   JDK="$JDK_HOME"
@@ -173,7 +173,7 @@ fi
 # ---------------------------------------------------------------------
 # Run the IDE.
 # ---------------------------------------------------------------------
-LD_LIBRARY_PATH="$IDE_BIN_HOME:$LD_LIBRARY_PATH" "$JDK/bin/java" \
+LD_LIBRARY_PATH="$IDE_BIN_HOME:$LD_LIBRARY_PATH" "$JDK/jre/bin/java" \
   $AGENT \
   "-Xbootclasspath/a:$IDE_HOME/lib/boot.jar" \
   -classpath "$CLASSPATH" \
index 373b1e6512aad8d4d689efd76095ddf5a5a0619f..dfe40cd923820f72258d950e3f79ed6570b6380b 100644 (file)
@@ -172,7 +172,7 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps =
 
   buildTarGz("idea-${args.buildNumber}", "$paths.artifacts/idea${args.buildNumber}.tar", [paths.distAll, paths.distUnix])
   if (p("jdk.bundled.linux") != "false") {
-    buildTarGz("idea-${args.buildNumber}", "$paths.artifacts/idea${args.buildNumber}-jdk-bundled.tar", [paths.distAll, paths.distUnix, "${paths.sandbox}/bundled.linux.jdk"], ["jre/bin/*"])
+    buildTarGz("idea-${args.buildNumber}", "$paths.artifacts/idea${args.buildNumber}-jdk-bundled.tar", [paths.distAll, paths.distUnix, "${paths.sandbox}/bundled.linux.jdk"], ["jre/jre/bin/*"])
   }
   return info
 }
index 709383481549f907cff0499865a859260aed7ee8..4c9e57aa13c7ac94ddef0eca6dae66cd8580a0cc 100644 (file)
@@ -45,7 +45,6 @@ public class ResumeThreadAction extends DebuggerAction{
         final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
         debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
           public void contextAction() throws Exception {
-            debugProcess.getSession().getXDebugSession().sessionResumed();
             debugProcess.createResumeThreadCommand(getSuspendContext(), thread).run();
             debuggerTreeNode.calcValue();
           }
index 43149c603d8f5e9b6b12a3a6cefea30adbfcd251..9da93a15cda67d2952f90290aa95d679a7cf56bc 100644 (file)
@@ -456,6 +456,8 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
         catch (IllegalThreadStateException e) {
           LOG.info(e); // undocumented by JDI: may be thrown when querying thread status
         }
+        catch (ObjectCollectedException ignored) {
+        }
       }
       requestManager.deleteEventRequests(toDelete);
     }
@@ -1694,6 +1696,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
       final Set<SuspendContextImpl> suspendingContexts = SuspendManagerUtil.getSuspendingContexts(getSuspendManager(), myThread);
       for (SuspendContextImpl suspendContext : suspendingContexts) {
         if (suspendContext.getThread() == myThread) {
+          getSession().getXDebugSession().sessionResumed();
           getManagerThread().invoke(createResumeCommand(suspendContext));
         }
         else {
index 77b1c44f093da7da2b94bbe0906f79f93796742f..6ec3eefddb170388acfb3cc5ab5e84c90a673ca2 100644 (file)
@@ -28,16 +28,14 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.NullableComputable;
-import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.search.FilenameIndex;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.DocumentUtil;
 import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.EmptyIterable;
@@ -285,13 +283,12 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
     if (document == null || lineNumber >= document.getLineCount()) {
       return EmptyIterable.getInstance();
     }
-    final int startOffset = document.getLineStartOffset(lineNumber);
-    final int endOffset = document.getLineEndOffset(lineNumber);
+    final TextRange lineRange = DocumentUtil.getLineTextRange(document, lineNumber);
     return new Iterable<PsiElement>() {
       @Override
       public Iterator<PsiElement> iterator() {
         return new Iterator<PsiElement>() {
-          PsiElement myElement = file.findElementAt(startOffset);
+          PsiElement myElement = DebuggerUtilsEx.findElementAt(file, lineRange.getStartOffset());
 
           @Override
           public boolean hasNext() {
@@ -303,7 +300,7 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
             PsiElement res = myElement;
             do {
               myElement = PsiTreeUtil.nextLeaf(myElement);
-              if (myElement == null || myElement.getTextOffset() > endOffset) {
+              if (myElement == null || myElement.getTextOffset() > lineRange.getEndOffset()) {
                 myElement = null;
                 break;
               }
index 04bf6d8aa30217919c2320d638eacb3481055de3..42d19808729e319c0a9ace54369f00a40f0cd29d 100644 (file)
@@ -589,7 +589,9 @@ public class DebuggerSession implements AbstractDebuggerSession {
 
     @Override
     public void resumed(final SuspendContextImpl suspendContext) {
-      final SuspendContextImpl currentContext = isSteppingThrough(suspendContext.getThread()) ? null : getProcess().getSuspendManager().getPausedContext();
+      final SuspendContextImpl currentContext = suspendContext != null && isSteppingThrough(suspendContext.getThread())
+                                                ? null
+                                                : getProcess().getSuspendManager().getPausedContext();
       DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
         @Override
         public void run() {
index a200ebd04f899007b25fc4a4139ea1e1eb55f946..b1c858b0d9bbd6021b139fcf5beb33a1d78a79a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.FindSuperElementsHelper;
 import com.intellij.psi.impl.source.PsiClassImpl;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.PsiSearchHelper;
@@ -135,14 +136,15 @@ public class UnusedSymbolUtil {
     }
     else {
       //class maybe used in some weird way, e.g. from XML, therefore the only constructor is used too
-      if (containingClass != null && method.isConstructor()
+      boolean isConstructor = method.isConstructor();
+      if (containingClass != null && isConstructor
           && containingClass.getConstructors().length == 1
           && isClassUsed(project, containingFile, containingClass, progress, helper)) {
         return true;
       }
       if (isImplicitUsage(project, method, progress)) return true;
 
-      if (method.findSuperMethods().length != 0) {
+      if (!isConstructor && FindSuperElementsHelper.findSuperElements(method).length != 0) {
         return true;
       }
       if (!weAreSureThereAreNoUsages(project, containingFile, method, progress, helper)) {
@@ -193,7 +195,7 @@ public class UnusedSymbolUtil {
                                       @NotNull PsiFile containingFile,
                                       @NotNull PsiMember member,
                                       @NotNull ProgressIndicator progress,
-                                      final PsiFile ignoreFile,
+                                      @Nullable PsiFile ignoreFile,
                                       @NotNull Processor<UsageInfo> usageInfoProcessor) {
     String name = member.getName();
     if (name == null) {
@@ -247,10 +249,8 @@ public class UnusedSymbolUtil {
     }
     else if (member instanceof PsiMethod) {
       PsiMethod method = (PsiMethod)member;
-      JavaMethodFindUsagesOptions o = new JavaMethodFindUsagesOptions(project);
-      //o.isIncludeOverloadUsages = true;
-      options = o;
-      options.isSearchForTextOccurrences = method.isConstructor();;
+      options = new JavaMethodFindUsagesOptions(project);
+      options.isSearchForTextOccurrences = method.isConstructor();
     }
     else if (member instanceof PsiVariable) {
       options = new JavaVariableFindUsagesOptions(project);
@@ -271,7 +271,7 @@ public class UnusedSymbolUtil {
                                                 @NotNull ProgressIndicator progress,
                                                 @NotNull GlobalUsageHelper helper) {
     final PsiClass containingClass = member.getContainingClass();
-    if (containingClass == null || !(containingClass instanceof PsiClassImpl)) return true;
+    if (!(containingClass instanceof PsiClassImpl)) return true;
     final PsiMethod valuesMethod = ((PsiClassImpl)containingClass).getValuesMethod();
     return valuesMethod == null || isMethodReferenced(project, containingFile, valuesMethod, progress, helper);
   }
index ad64ccac3f8e26bdd8e8b8f0807d00ff50b8c33a..5a3b720dc48e5a342b2a2567ea786650ffac4d9c 100644 (file)
@@ -36,6 +36,7 @@ import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.psi.util.TypeConversionUtil;
 import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ObjectUtils;
 import com.intellij.util.containers.HashSet;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -663,8 +664,7 @@ public class AnnotationsHighlightUtil {
     if (methods.length == 1) {
       PsiType expected = new PsiImmediateClassType((PsiClass)target, PsiSubstitutor.EMPTY).createArrayType();
       if (!expected.equals(methods[0].getReturnType())) {
-        return JavaErrorMessages.message("annotation.container.bad.type", container.getQualifiedName(), JavaHighlightUtil
-          .formatType(expected));
+        return JavaErrorMessages.message("annotation.container.bad.type", container.getQualifiedName(), JavaHighlightUtil.formatType(expected));
       }
     }
 
@@ -698,6 +698,64 @@ public class AnnotationsHighlightUtil {
     return container;
   }
 
+  @Nullable
+  static HighlightInfo checkReceiverPlacement(PsiReceiverParameter parameter) {
+    PsiElement owner = parameter.getParent().getParent();
+    if (owner == null) return null;
+
+    if (!(owner instanceof PsiMethod)) {
+      String text = JavaErrorMessages.message("receiver.wrong.context");
+      return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create();
+    }
+
+    PsiMethod method = (PsiMethod)owner;
+    if (isStatic(method) || (method).isConstructor() && isStatic(method.getContainingClass())) {
+      String text = JavaErrorMessages.message("receiver.static.context");
+      return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create();
+    }
+
+    PsiElement leftNeighbour = PsiTreeUtil.skipSiblingsBackward(parameter, PsiWhiteSpace.class);
+    if (leftNeighbour != null && !PsiUtil.isJavaToken(leftNeighbour, JavaTokenType.LPARENTH)) {
+      String text = JavaErrorMessages.message("receiver.wrong.position");
+      return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create();
+    }
+
+    return null;
+  }
+
+  @Nullable
+  static HighlightInfo checkReceiverType(PsiReceiverParameter parameter) {
+    PsiElement owner = parameter.getParent().getParent();
+    if (!(owner instanceof PsiMethod)) return null;
+
+    PsiMethod method = (PsiMethod)owner;
+    PsiClass enclosingClass = method.getContainingClass();
+    if (method.isConstructor() && enclosingClass != null) {
+      enclosingClass = enclosingClass.getContainingClass();
+    }
+
+    if (enclosingClass != null && !enclosingClass.equals(PsiUtil.resolveClassInType(parameter.getType()))) {
+      PsiElement range = ObjectUtils.notNull(parameter.getTypeElement(), parameter);
+      String text = JavaErrorMessages.message("receiver.type.mismatch");
+      return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(text).create();
+    }
+
+    PsiThisExpression identifier = parameter.getIdentifier();
+    if (enclosingClass != null && !enclosingClass.equals(PsiUtil.resolveClassInType(identifier.getType()))) {
+      String text = JavaErrorMessages.message("receiver.name.mismatch");
+      return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(text).create();
+    }
+
+    return null;
+  }
+
+  private static boolean isStatic(PsiModifierListOwner owner) {
+    if (owner == null) return false;
+    if (owner instanceof PsiClass && ((PsiClass)owner).getContainingClass() == null) return true;
+    PsiModifierList modifierList = owner.getModifierList();
+    return modifierList != null && modifierList.hasModifierProperty(PsiModifier.STATIC);
+  }
+
   @Nullable
   public static RetentionPolicy getRetentionPolicy(@NotNull PsiClass annotation) {
     PsiModifierList modifierList = annotation.getModifierList();
index 02e2b1bc58b79acb10895e488fabd5445712ee08..39ffd8c42e598944a2e77cba9f5910090ba2eeb5 100644 (file)
@@ -965,6 +965,9 @@ public class HighlightUtil extends HighlightUtilBase {
     else if (modifierOwner instanceof PsiLocalVariable || modifierOwner instanceof PsiParameter) {
       isAllowed = PsiModifier.FINAL.equals(modifier);
     }
+    else if (modifierOwner instanceof PsiReceiverParameter) {
+      isAllowed = false;
+    }
 
     isAllowed &= incompatibles != null;
     if (!isAllowed) {
@@ -2899,7 +2902,8 @@ public class HighlightUtil extends HighlightUtilBase {
     EXTENSION_METHODS(LanguageLevel.JDK_1_8, "feature.extension.methods"),
     METHOD_REFERENCES(LanguageLevel.JDK_1_8, "feature.method.references"),
     LAMBDA_EXPRESSIONS(LanguageLevel.JDK_1_8, "feature.lambda.expressions"),
-    TYPE_ANNOTATIONS(LanguageLevel.JDK_1_8, "feature.type.annotations");
+    TYPE_ANNOTATIONS(LanguageLevel.JDK_1_8, "feature.type.annotations"),
+    RECEIVERS(LanguageLevel.JDK_1_8, "feature.type.receivers");
 
     private final LanguageLevel level;
     private final String key;
index b6110bf5ee92da4fad2330bc6e0c4bf12e5d17a5..7012c7603aeccc8128353c3c0b533c3710d01b29 100644 (file)
@@ -1460,12 +1460,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
 
   @Override
   public void visitThisExpression(PsiThisExpression expr) {
-    myHolder.add(HighlightUtil.checkThisOrSuperExpressionInIllegalContext(expr, expr.getQualifier(), myLanguageLevel));
-    if (!myHolder.hasErrorResults()) {
-      myHolder.add(HighlightUtil.checkMemberReferencedBeforeConstructorCalled(expr, null, myFile));
-    }
-    if (!myHolder.hasErrorResults()) {
-      visitExpression(expr);
+    if (!(expr.getParent() instanceof PsiReceiverParameter)) {
+      myHolder.add(HighlightUtil.checkThisOrSuperExpressionInIllegalContext(expr, expr.getQualifier(), myLanguageLevel));
+      if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkMemberReferencedBeforeConstructorCalled(expr, null, myFile));
+      if (!myHolder.hasErrorResults()) visitExpression(expr);
     }
   }
 
@@ -1580,6 +1578,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
     }
   }
 
+  @Override
+  public void visitReceiverParameter(PsiReceiverParameter parameter) {
+    super.visitReceiverParameter(parameter);
+    if (!myHolder.hasErrorResults()) myHolder.add(checkFeature(parameter, Feature.RECEIVERS));
+    if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkReceiverPlacement(parameter));
+    if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkReceiverType(parameter));
+  }
+
   @Nullable
   private HighlightInfo checkFeature(@NotNull PsiElement element, @NotNull Feature feature) {
     return HighlightUtil.checkFeature(element, feature, myLanguageLevel, myFile);
index b0a80a0a7fa984dc1f669211559b81ce11bd7e99..7ee7ea1c245d7f091cdbf3cf640d812b618956ea 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.psi.util.TypeConversionUtil;
 import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 public class AddTypeArgumentsFix extends MethodArgumentFix {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.AddTypeArgumentsFix");
@@ -51,63 +52,67 @@ public class AddTypeArgumentsFix extends MethodArgumentFix {
 
     @Override
     protected PsiExpression getModifiedArgument(final PsiExpression expression, final PsiType toType) throws IncorrectOperationException {
-      if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return null;
+      return addTypeArguments(expression, toType);
+    }
 
-      if (expression instanceof PsiMethodCallExpression) {
-        final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)expression;
-        final PsiReferenceParameterList list = methodCall.getMethodExpression().getParameterList();
-        if (list == null || list.getTypeArguments().length > 0) return null;
-        final JavaResolveResult resolveResult = methodCall.resolveMethodGenerics();
-        final PsiElement element = resolveResult.getElement();
-        if (element instanceof PsiMethod) {
-          final PsiMethod method = (PsiMethod)element;
-          final PsiType returnType = method.getReturnType();
-          if (returnType == null) return null;
+    @Override
+    public boolean areTypesConvertible(final PsiType exprType, final PsiType parameterType, final PsiElement context) {
+      return !(exprType instanceof PsiPrimitiveType) && !(parameterType instanceof PsiPrimitiveType) || TypeConversionUtil.boxingConversionApplicable(exprType, parameterType);
+    }
+  }
 
-          final PsiTypeParameter[] typeParameters = method.getTypeParameters();
-          if (typeParameters.length > 0) {
-            PsiType[] mappings = PsiType.createArray(typeParameters.length);
-            PsiResolveHelper helper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper();
-            LanguageLevel level = PsiUtil.getLanguageLevel(expression);
-            for (int i = 0; i < typeParameters.length; i++) {
-              PsiTypeParameter typeParameter = typeParameters[i];
-              final PsiType substitution = helper.getSubstitutionForTypeParameter(typeParameter, returnType, toType, false, level);
-              if (substitution == null || PsiType.NULL.equals(substitution)) return null;
-              mappings[i] = GenericsUtil.eliminateWildcards(substitution, false);
-            }
+  @Nullable
+  public static PsiExpression addTypeArguments(PsiExpression expression, PsiType toType) {
+    if (!PsiUtil.isLanguageLevel5OrHigher(expression)) return null;
 
-            final PsiElementFactory factory = JavaPsiFacade.getInstance(expression.getProject()).getElementFactory();
-            PsiMethodCallExpression copy = (PsiMethodCallExpression)expression.copy();
-            final PsiReferenceExpression methodExpression = copy.getMethodExpression();
-            final PsiReferenceParameterList parameterList = methodExpression.getParameterList();
-            LOG.assertTrue(parameterList != null);
-            for (PsiType mapping : mappings) {
-              parameterList.add(factory.createTypeElement(mapping));
-            }
-            if (methodExpression.getQualifierExpression() == null) {
-              final PsiExpression qualifierExpression;
-              final PsiClass containingClass = method.getContainingClass();
-              LOG.assertTrue(containingClass != null);
-              if (method.hasModifierProperty(PsiModifier.STATIC)) {
-                qualifierExpression = factory.createReferenceExpression(containingClass);
-              } else {
-                qualifierExpression = RefactoringChangeUtil.createThisExpression(method.getManager(), null);
-              }
-              methodExpression.setQualifierExpression(qualifierExpression);
-            }
+    if (expression instanceof PsiMethodCallExpression) {
+      final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)expression;
+      final PsiReferenceParameterList list = methodCall.getMethodExpression().getParameterList();
+      if (list == null || list.getTypeArguments().length > 0) return null;
+      final JavaResolveResult resolveResult = methodCall.resolveMethodGenerics();
+      final PsiElement element = resolveResult.getElement();
+      if (element instanceof PsiMethod) {
+        final PsiMethod method = (PsiMethod)element;
+        final PsiType returnType = method.getReturnType();
+        if (returnType == null) return null;
 
-            return (PsiExpression)JavaCodeStyleManager.getInstance(copy.getProject()).shortenClassReferences(copy);
+        final PsiTypeParameter[] typeParameters = method.getTypeParameters();
+        if (typeParameters.length > 0) {
+          PsiType[] mappings = PsiType.createArray(typeParameters.length);
+          PsiResolveHelper helper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper();
+          LanguageLevel level = PsiUtil.getLanguageLevel(expression);
+          for (int i = 0; i < typeParameters.length; i++) {
+            PsiTypeParameter typeParameter = typeParameters[i];
+            final PsiType substitution = helper.getSubstitutionForTypeParameter(typeParameter, returnType, toType, false, level);
+            if (substitution == null || PsiType.NULL.equals(substitution)) return null;
+            mappings[i] = GenericsUtil.eliminateWildcards(substitution, false);
           }
-        }
-      }
 
-      return null;
-    }
+          final PsiElementFactory factory = JavaPsiFacade.getInstance(expression.getProject()).getElementFactory();
+          PsiMethodCallExpression copy = (PsiMethodCallExpression)expression.copy();
+          final PsiReferenceExpression methodExpression = copy.getMethodExpression();
+          final PsiReferenceParameterList parameterList = methodExpression.getParameterList();
+          LOG.assertTrue(parameterList != null);
+          for (PsiType mapping : mappings) {
+            parameterList.add(factory.createTypeElement(mapping));
+          }
+          if (methodExpression.getQualifierExpression() == null) {
+            final PsiExpression qualifierExpression;
+            final PsiClass containingClass = method.getContainingClass();
+            LOG.assertTrue(containingClass != null);
+            if (method.hasModifierProperty(PsiModifier.STATIC)) {
+              qualifierExpression = factory.createReferenceExpression(containingClass);
+            } else {
+              qualifierExpression = RefactoringChangeUtil.createThisExpression(method.getManager(), null);
+            }
+            methodExpression.setQualifierExpression(qualifierExpression);
+          }
 
-    @Override
-    public boolean areTypesConvertible(final PsiType exprType, final PsiType parameterType, final PsiElement context) {
-      return !(exprType instanceof PsiPrimitiveType) && !(parameterType instanceof PsiPrimitiveType) || TypeConversionUtil.boxingConversionApplicable(exprType, parameterType);
+          return (PsiExpression)JavaCodeStyleManager.getInstance(copy.getProject()).shortenClassReferences(copy);
+        }
+      }
     }
+    return null;
   }
 
   public static ArgumentFixerActionFactory REGISTRAR = new AddTypeArgumentsFix.MyFixerActionFactory();
diff --git a/java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java b/java/java-analysis-impl/src/com/intellij/psi/impl/FindSuperElementsHelper.java
new file mode 100644 (file)
index 0000000..f52bffd
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.psi.impl;
+
+import com.intellij.psi.*;
+import com.intellij.psi.search.searches.ClassInheritorsSearch;
+import com.intellij.psi.util.MethodSignature;
+import com.intellij.psi.util.MethodSignatureUtil;
+import com.intellij.psi.util.PsiSuperMethodUtil;
+import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.util.Processor;
+import com.intellij.util.containers.FactoryMap;
+import gnu.trove.THashSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.*;
+
+public class FindSuperElementsHelper {
+  @NotNull
+  public static PsiElement[] findSuperElements(@NotNull PsiElement element) {
+    if (element instanceof PsiClass) {
+      PsiClass aClass = (PsiClass) element;
+      List<PsiClass> allSupers = new ArrayList<PsiClass>(Arrays.asList(aClass.getSupers()));
+      for (Iterator<PsiClass> iterator = allSupers.iterator(); iterator.hasNext();) {
+        PsiClass superClass = iterator.next();
+        if (CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) iterator.remove();
+      }
+      return allSupers.toArray(new PsiClass[allSupers.size()]);
+    }
+    if (element instanceof PsiMethod) {
+      PsiMethod method = (PsiMethod) element;
+      if (method.isConstructor()) {
+        PsiMethod constructorInSuper = PsiSuperMethodUtil.findConstructorInSuper(method);
+        if (constructorInSuper != null) {
+          return new PsiMethod[]{constructorInSuper};
+        }
+      }
+      else {
+        PsiMethod[] superMethods = method.findSuperMethods(false);
+        if (superMethods.length == 0) {
+          PsiMethod superMethod = getSiblingInheritedViaSubClass(method);
+          if (superMethod != null) {
+            superMethods = new PsiMethod[]{superMethod};
+          }
+        }
+        return superMethods;
+      }
+    }
+    return PsiElement.EMPTY_ARRAY;
+  }
+
+  public static PsiMethod getSiblingInheritedViaSubClass(@NotNull PsiMethod method) {
+    return getSiblingInheritedViaSubClass(method, createSubClassCache());
+  }
+
+  public static PsiMethod getSiblingInheritedViaSubClass(@NotNull final PsiMethod method,
+                                                         @NotNull Map<PsiClass, PsiClass> subClassCache) {
+    if (!method.hasModifierProperty(PsiModifier.PUBLIC)) return null;
+    if (method.hasModifierProperty(PsiModifier.STATIC)) return null;
+    final PsiClass containingClass = method.getContainingClass();
+    boolean hasSubClass = containingClass != null && !containingClass.isInterface() && subClassCache.get(containingClass) != null;
+    if (!hasSubClass) {
+      return null;
+    }
+    final Collection<PsiClass> checkedInterfaces = new THashSet<PsiClass>();
+    final PsiMethod[] result = new PsiMethod[1];
+    ClassInheritorsSearch.search(containingClass, true).forEach(new Processor<PsiClass>() {
+      @Override
+      public boolean process(PsiClass inheritor) {
+        for (PsiClassType interfaceType : inheritor.getImplementsListTypes()) {
+          PsiClassType.ClassResolveResult resolved = interfaceType.resolveGenerics();
+          PsiClass anInterface = resolved.getElement();
+          if (anInterface == null || !checkedInterfaces.add(anInterface)) continue;
+          for (PsiMethod superMethod : anInterface.findMethodsByName(method.getName(), true)) {
+            PsiClass superInterface = superMethod.getContainingClass();
+            if (superInterface == null) {
+              continue;
+            }
+
+            // calculate substitutor of containingClass --> inheritor
+            PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(containingClass, inheritor, PsiSubstitutor.EMPTY);
+            // calculate substitutor of inheritor --> superInterface
+            substitutor = TypeConversionUtil.getSuperClassSubstitutor(superInterface, inheritor, substitutor);
+
+            final MethodSignature superSignature = superMethod.getSignature(substitutor);
+            final MethodSignature derivedSignature = method.getSignature(PsiSubstitutor.EMPTY);
+            boolean isOverridden = MethodSignatureUtil.isSubsignature(superSignature, derivedSignature);
+
+            if (isOverridden) {
+              result[0] = superMethod;
+              return false;
+            }
+          }
+        }
+        return true;
+      }
+    });
+    return result[0];
+  }
+
+  @NotNull
+  public static Map<PsiClass, PsiClass> createSubClassCache() {
+    return new FactoryMap<PsiClass, PsiClass>() {
+        @Nullable
+        @Override
+        protected PsiClass create(PsiClass aClass) {
+          return ClassInheritorsSearch.search(aClass, false).findFirst();
+        }
+      };
+  }
+}
index 4c705206a0a16544c45f10117dee95c537cb043d..4faf4245b8ba1113caaf853170504fad3cb1a0f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.FindSuperElementsHelper;
 import com.intellij.psi.search.searches.AllOverridingMethodsSearch;
-import com.intellij.psi.search.searches.ClassInheritorsSearch;
 import com.intellij.psi.search.searches.FunctionalExpressionSearch;
 import com.intellij.psi.search.searches.SuperMethodsSearch;
 import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
@@ -48,12 +48,12 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 public class JavaLineMarkerProvider implements LineMarkerProvider {
-
-  protected final DaemonCodeAnalyzerSettings myDaemonSettings;
-  protected final EditorColorsManager myColorsManager;
+  private final DaemonCodeAnalyzerSettings myDaemonSettings;
+  private final EditorColorsManager myColorsManager;
 
   public JavaLineMarkerProvider(DaemonCodeAnalyzerSettings daemonSettings, EditorColorsManager colorsManager) {
     myDaemonSettings = daemonSettings;
@@ -72,19 +72,14 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
           method.hasModifierProperty(PsiModifier.ABSTRACT) == superSignature.getMethod().hasModifierProperty(PsiModifier.ABSTRACT);
 
         final Icon icon = overrides ? AllIcons.Gutter.OverridingMethod : AllIcons.Gutter.ImplementingMethod;
-        final MarkerType type = MarkerType.OVERRIDING_METHOD;
-        ArrowUpLineMarkerInfo info = new ArrowUpLineMarkerInfo(element, icon, type);
-        return NavigateAction.setNavigateAction(info, "Go to super method", "GotoSuperMethod");
+        return createSuperMethodLineMarkerInfo(element, icon, Pass.UPDATE_ALL);
       }
     }
 
     final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(element);
     final PsiElement firstChild = element.getFirstChild();
     if (interfaceMethod != null && firstChild != null) {
-      final Icon icon = AllIcons.Gutter.ImplementingMethod;
-      final MarkerType type = MarkerType.OVERRIDING_METHOD;
-      ArrowUpLineMarkerInfo info = new ArrowUpLineMarkerInfo(firstChild, icon, type);
-      return NavigateAction.setNavigateAction(info, "Go to super method", "GotoSuperMethod");
+      return createSuperMethodLineMarkerInfo(firstChild, AllIcons.Gutter.ImplementingMethod, Pass.UPDATE_ALL);
     }
 
     if (myDaemonSettings.SHOW_METHOD_SEPARATORS && firstChild == null) {
@@ -128,6 +123,12 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
     return null;
   }
 
+  @NotNull
+  private static LineMarkerInfo createSuperMethodLineMarkerInfo(@NotNull PsiElement name, @NotNull Icon icon, int passId) {
+    ArrowUpLineMarkerInfo info = new ArrowUpLineMarkerInfo(name, icon, MarkerType.OVERRIDING_METHOD, passId);
+    return NavigateAction.setNavigateAction(info, "Go to super method", IdeActions.ACTION_GOTO_SUPER);
+  }
+
   private static int getCategory(@NotNull PsiElement element, @NotNull CharSequence documentChars) {
     if (element instanceof PsiField || element instanceof PsiTypeParameter) return 1;
     if (element instanceof PsiClass || element instanceof PsiClassInitializer) return 2;
@@ -147,37 +148,87 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
   @Override
   public void collectSlowLineMarkers(@NotNull final List<PsiElement> elements, @NotNull final Collection<LineMarkerInfo> result) {
     ApplicationManager.getApplication().assertReadAccessAllowed();
+    Map<PsiClass, PsiClass> subClassCache = FindSuperElementsHelper.createSubClassCache();
 
-    Set<PsiMethod> methods = new HashSet<PsiMethod>();
+    Collection<PsiMethod> methods = new THashSet<PsiMethod>();
     //noinspection ForLoopReplaceableByForEach
     for (int i = 0; i < elements.size(); i++) {
       PsiElement element = elements.get(i);
       ProgressManager.checkCanceled();
-      if (element instanceof PsiMethod) {
-        final PsiMethod method = (PsiMethod)element;
+      if (!(element instanceof PsiIdentifier)) continue;
+      PsiElement parent = element.getParent();
+      if (parent instanceof PsiMethod) {
+        final PsiMethod method = (PsiMethod)parent;
         if (PsiUtil.canBeOverriden(method)) {
           methods.add(method);
         }
       }
-      else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) {
-        collectInheritingClasses((PsiClass)element, result);
+      else if (parent instanceof PsiClass && !(parent instanceof PsiTypeParameter)) {
+        collectInheritingClasses((PsiClass)parent, result, subClassCache);
       }
     }
     if (!methods.isEmpty()) {
-      collectOverridingAccessors(methods, result);
+      collectOverridingMethods(methods, result);
+      collectSiblingInheritedMethods(methods, result, subClassCache);
+    }
+  }
+
+  private static void collectSiblingInheritedMethods(@NotNull final Collection<PsiMethod> methods,
+                                                     @NotNull Collection<LineMarkerInfo> result,
+                                                     @NotNull Map<PsiClass, PsiClass> subClassCache) {
+    for (PsiMethod method : methods) {
+      ProgressManager.checkCanceled();
+      PsiClass aClass = method.getContainingClass();
+      if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL) || aClass.isInterface()) continue;
+
+      boolean canHaveSiblingSuper = !method.hasModifierProperty(PsiModifier.ABSTRACT) && !method.hasModifierProperty(PsiModifier.STATIC) && method.hasModifierProperty(PsiModifier.PUBLIC)&& !method.hasModifierProperty(PsiModifier.FINAL)&& !method.hasModifierProperty(PsiModifier.NATIVE);
+      if (!canHaveSiblingSuper) continue;
+
+      PsiMethod siblingInheritedViaSubClass = FindSuperElementsHelper.getSiblingInheritedViaSubClass(method, subClassCache);
+      if (siblingInheritedViaSubClass == null) {
+        continue;
+      }
+      PsiElement range = getMethodRange(method);
+      LineMarkerInfo info = createSuperMethodLineMarkerInfo(range, AllIcons.Gutter.ImplementingMethod, Pass.UPDATE_OVERRIDEN_MARKERS);
+      result.add(info);
+      PsiClass sClass = siblingInheritedViaSubClass.getContainingClass();
+      String sName = sClass == null ? null : sClass.getQualifiedName();
     }
   }
 
-  public static void collectInheritingClasses(PsiClass aClass, Collection<LineMarkerInfo> result) {
+  @NotNull
+  private static PsiElement getMethodRange(@NotNull PsiMethod method) {
+    PsiElement range;
+    if (method.isPhysical()) {
+      range = method.getNameIdentifier();
+    }
+    else {
+      final PsiElement navigationElement = method.getNavigationElement();
+      range = navigationElement instanceof PsiNameIdentifierOwner
+              ? ((PsiNameIdentifierOwner)navigationElement).getNameIdentifier()
+              : navigationElement;
+    }
+    if (range == null) {
+      range = method;
+    }
+    return range;
+  }
+
+  public static void collectInheritingClasses(@NotNull PsiClass aClass,
+                                              @NotNull Collection<LineMarkerInfo> result,
+                                              @NotNull Map<PsiClass, PsiClass> subClassCache) {
     if (aClass.hasModifierProperty(PsiModifier.FINAL)) {
       return;
     }
     if (CommonClassNames.JAVA_LANG_OBJECT.equals(aClass.getQualifiedName())) return; // It's useless to have overridden markers for object.
 
-    if (ClassInheritorsSearch.search(aClass, false).findFirst() != null || FunctionalExpressionSearch.search(aClass).findFirst() != null) {
+    PsiClass subClass = subClassCache.get(aClass);
+    if (subClass != null || FunctionalExpressionSearch.search(aClass).findFirst() != null) {
       final Icon icon = aClass.isInterface() ? AllIcons.Gutter.ImplementedMethod : AllIcons.Gutter.OverridenMethod;
       PsiElement range = aClass.getNameIdentifier();
-      if (range == null) range = aClass;
+      if (range == null) {
+        range = aClass;
+      }
       MarkerType type = MarkerType.SUBCLASSED_CLASS;
       LineMarkerInfo info = new LineMarkerInfo<PsiElement>(range, range.getTextRange(),
                                                            icon, Pass.UPDATE_OVERRIDEN_MARKERS, type.getTooltip(),
@@ -188,7 +239,7 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
     }
   }
 
-  private static void collectOverridingAccessors(final Set<PsiMethod> methods, Collection<LineMarkerInfo> result) {
+  private static void collectOverridingMethods(@NotNull final Collection<PsiMethod> methods, @NotNull Collection<LineMarkerInfo> result) {
     final Set<PsiMethod> overridden = new HashSet<PsiMethod>();
     Set<PsiClass> classes = new THashSet<PsiClass>();
     for (PsiMethod method : methods) {
@@ -229,22 +280,9 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
       ProgressManager.checkCanceled();
       boolean overrides = !method.hasModifierProperty(PsiModifier.ABSTRACT);
 
-      final Icon icon = overrides ? AllIcons.Gutter.OverridenMethod : AllIcons.Gutter.ImplementedMethod;
-      PsiElement range;
-      if (method.isPhysical()) {
-        range = method.getNameIdentifier();
-      }
-      else {
-        final PsiElement navigationElement = method.getNavigationElement();
-        if (navigationElement instanceof PsiNameIdentifierOwner) {
-          range = ((PsiNameIdentifierOwner)navigationElement).getNameIdentifier();
-        }
-        else {
-          range = navigationElement;
-        }
-      }
-      if (range == null) range = method;
+      PsiElement range = getMethodRange(method);
       final MarkerType type = MarkerType.OVERRIDDEN_METHOD;
+      final Icon icon = overrides ? AllIcons.Gutter.OverridenMethod : AllIcons.Gutter.ImplementedMethod;
       LineMarkerInfo<PsiElement> info = new LineMarkerInfo<PsiElement>(range, range.getTextRange(),
                                                            icon, Pass.UPDATE_OVERRIDEN_MARKERS, type.getTooltip(),
                                                            type.getNavigationHandler(),
@@ -255,8 +293,8 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
   }
 
   private static class ArrowUpLineMarkerInfo extends MergeableLineMarkerInfo<PsiElement> {
-    private ArrowUpLineMarkerInfo(@NotNull PsiElement element, Icon icon, @NotNull MarkerType markerType) {
-      super(element, element.getTextRange(), icon, Pass.UPDATE_ALL, markerType.getTooltip(),
+    private ArrowUpLineMarkerInfo(@NotNull PsiElement element, @NotNull Icon icon, @NotNull MarkerType markerType, int passId) {
+      super(element, element.getTextRange(), icon, passId, markerType.getTooltip(),
             markerType.getNavigationHandler(), GutterIconRenderer.Alignment.LEFT);
     }
 
@@ -274,6 +312,7 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
       return myIcon;
     }
 
+    @NotNull
     @Override
     public Function<? super PsiElement, String> getCommonTooltip(@NotNull List<MergeableLineMarkerInfo> infos) {
       return new Function<PsiElement, String>() {
index 89785c572d84476603298854f1e10e58d452d00f..d956ddcc054dfed414a88ed15c3a0f2e8569cbec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.util.Computable;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.FindSuperElementsHelper;
 import com.intellij.psi.search.PsiElementProcessor;
 import com.intellij.psi.search.PsiElementProcessorAdapter;
 import com.intellij.psi.search.SearchScope;
@@ -45,6 +46,7 @@ import com.intellij.util.ArrayUtil;
 import com.intellij.util.CommonProcessors;
 import com.intellij.util.Function;
 import com.intellij.util.NullableFunction;
+import com.intellij.util.containers.ContainerUtil;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -105,9 +107,9 @@ public class MarkerType {
   });
 
   @Nullable
-  public static String calculateOverridingMethodTooltip(PsiMethod method, boolean acceptSelf) {
+  private static String calculateOverridingMethodTooltip(@NotNull PsiMethod method, boolean acceptSelf) {
     PsiMethod[] superMethods = composeSuperMethods(method, acceptSelf);
-    if (superMethods == null) return null;
+    if (superMethods.length == 0) return null;
 
     PsiMethod superMethod = superMethods[0];
     boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
@@ -121,10 +123,11 @@ public class MarkerType {
     else{
       key = sameSignature ? "method.overrides" : "method.overrides.in";
     }
-    return composeText(superMethods, "", DaemonBundle.message(key), "GotoSuperMethod");
+    return composeText(superMethods, "", DaemonBundle.message(key), IdeActions.ACTION_GOTO_SUPER);
   }
 
-  private static String composeText(PsiElement[] methods, String start, String pattern, String actionId) {
+  @NotNull
+  private static String composeText(@NotNull PsiElement[] methods, @NotNull String start, @NotNull String pattern, @NotNull String actionId) {
     Shortcut[] shortcuts = ActionManager.getInstance().getAction(actionId).getShortcutSet().getShortcuts();
     Shortcut shortcut = ArrayUtil.getFirstElement(shortcuts);
     String postfix = "<br><div style='margin-top: 5px'><font size='2'>Click";
@@ -133,9 +136,9 @@ public class MarkerType {
     return GutterIconTooltipHelper.composeText(Arrays.asList(methods), start, pattern, postfix);
   }
 
-  public static void navigateToOverridingMethod(MouseEvent e, PsiMethod method, boolean acceptSelf) {
+  private static void navigateToOverridingMethod(MouseEvent e, @NotNull PsiMethod method, boolean acceptSelf) {
     PsiMethod[] superMethods = composeSuperMethods(method, acceptSelf);
-    if (superMethods == null) return;
+    if (superMethods.length == 0) return;
     boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(superMethods);
     PsiElementListNavigator.openTargets(e, superMethods,
                                         DaemonBundle.message("navigation.title.super.method", method.getName()),
@@ -143,17 +146,23 @@ public class MarkerType {
                                         new MethodCellRenderer(showMethodNames));
   }
 
-  @Nullable
-  private static PsiMethod[] composeSuperMethods(PsiMethod method, boolean acceptSelf) {
-    PsiMethod[] superMethods = method.findSuperMethods(false);
+  @NotNull
+  private static PsiMethod[] composeSuperMethods(@NotNull PsiMethod method, boolean acceptSelf) {
+    PsiElement[] superElements = FindSuperElementsHelper.findSuperElements(method);
+
+    PsiMethod[] superMethods = ContainerUtil.map(superElements, new Function<PsiElement, PsiMethod>() {
+      @Override
+      public PsiMethod fun(PsiElement element) {
+        return (PsiMethod)element;
+      }
+    }, PsiMethod.EMPTY_ARRAY);
     if (acceptSelf) {
       superMethods = ArrayUtil.prepend(method, superMethods);
     }
-    if (superMethods.length == 0) return null;
     return superMethods;
   }
 
-  private static PsiElement getParentMethod(PsiElement element) {
+  private static PsiElement getParentMethod(@NotNull PsiElement element) {
     final PsiElement parent = element.getParent();
     final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(parent);
     return interfaceMethod != null ? interfaceMethod : parent;
@@ -179,7 +188,7 @@ public class MarkerType {
     }
   });
 
-  public static String getOverriddenMethodTooltip(final PsiMethod method) {
+  private static String getOverriddenMethodTooltip(@NotNull PsiMethod method) {
     PsiElementProcessor.CollectElementsWithLimit<PsiMethod> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(5);
     OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(processor));
 
@@ -206,7 +215,7 @@ public class MarkerType {
     return composeText(overridings, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION);
   }
 
-  public static void navigateToOverriddenMethod(MouseEvent e, final PsiMethod method) {
+  private static void navigateToOverriddenMethod(MouseEvent e, @NotNull final PsiMethod method) {
     if (DumbService.isDumb(method.getProject())) {
       DumbService.getInstance(method.getProject()).showDumbModeNotification(
         "Navigation to overriding classes is not possible during index update");
@@ -267,7 +276,7 @@ public class MarkerType {
     }
   });
 
-  public static String getSubclassedClassTooltip(PsiClass aClass) {
+  private static String getSubclassedClassTooltip(@NotNull PsiClass aClass) {
     PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(5, new THashSet<PsiClass>());
     ClassInheritorsSearch.search(aClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
 
@@ -298,7 +307,7 @@ public class MarkerType {
     return composeText(subclasses, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION);
   }
 
-  public static void navigateToSubclassedClass(MouseEvent e, final PsiClass aClass) {
+  private static void navigateToSubclassedClass(MouseEvent e, @NotNull final PsiClass aClass) {
     if (DumbService.isDumb(aClass.getProject())) {
       DumbService.getInstance(aClass.getProject()).showDumbModeNotification("Navigation to overriding methods is not possible during index update");
       return;
@@ -331,7 +340,7 @@ public class MarkerType {
     private final PsiClass myClass;
     private final PsiClassOrFunctionalExpressionListCellRenderer myRenderer;
 
-    public SubclassUpdater(PsiClass aClass, PsiClassOrFunctionalExpressionListCellRenderer renderer) {
+    private SubclassUpdater(@NotNull PsiClass aClass, @NotNull PsiClassOrFunctionalExpressionListCellRenderer renderer) {
       super(aClass.getProject(), SEARCHING_FOR_OVERRIDDEN_METHODS);
       myClass = aClass;
       myRenderer = renderer;
@@ -374,14 +383,13 @@ public class MarkerType {
         }
       });
     }
-
   }
 
   private static class OverridingMethodsUpdater extends ListBackgroundUpdaterTask {
     private final PsiMethod myMethod;
     private final PsiElementListCellRenderer myRenderer;
 
-    public OverridingMethodsUpdater(PsiMethod method, PsiElementListCellRenderer renderer) {
+    private OverridingMethodsUpdater(@NotNull PsiMethod method, @NotNull PsiElementListCellRenderer renderer) {
       super(method.getProject(), SEARCHING_FOR_OVERRIDING_METHODS);
       myMethod = method;
       myRenderer = renderer;
index 4ab9d43fbc1d92434e287678a2bdfb1b71846625..1c6fd53e460f1a1a81f802721b48b36f2d01d7a8 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.impl.quickfix;
 
+import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.application.ApplicationManager;
@@ -112,6 +113,9 @@ public class AddMethodQualifierFix implements IntentionAction {
 
   @Override
   public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
+    if (!FileModificationService.getInstance().preparePsiElementsForWrite(file)) {
+      return;
+    }
     if (myCandidates.size() == 1 || UNIT_TEST_MODE) {
       qualify(myCandidates.get(0), editor);
     }
index 2acc887e1678a6fb2398d59c074a0c00e65e0721..89cb30a2a3059a3657d7a4045be6f7d81133419e 100644 (file)
@@ -40,6 +40,14 @@ public class IfStatementSelectioner extends BasicSelectioner {
 
     final PsiKeyword elseKeyword = statement.getElseElement();
     if (elseKeyword != null) {
+      final PsiStatement then = statement.getThenBranch();
+      if (then != null) {
+        final TextRange thenRange = new TextRange(statement.getTextRange().getStartOffset(), then.getTextRange().getEndOffset());
+        if (thenRange.contains(cursorOffset)) {
+          result.addAll(expandToWholeLine(editorText, thenRange, false));
+        }
+      }
+
       result.addAll(expandToWholeLine(editorText,
                                       new TextRange(elseKeyword.getTextRange().getStartOffset(),
                                                     statement.getTextRange().getEndOffset()),
@@ -50,10 +58,13 @@ public class IfStatementSelectioner extends BasicSelectioner {
         PsiIfStatement elseIf = (PsiIfStatement)branch;
         final PsiKeyword element = elseIf.getElseElement();
         if (element != null) {
-          result.addAll(expandToWholeLine(editorText,
-                                          new TextRange(elseKeyword.getTextRange().getStartOffset(),
-                                                        elseIf.getThenBranch().getTextRange().getEndOffset()),
-                                          false));
+          final PsiStatement elseThen = elseIf.getThenBranch();
+          if (elseThen != null) {
+            result.addAll(expandToWholeLine(editorText,
+                                            new TextRange(elseKeyword.getTextRange().getStartOffset(),
+                                                          elseThen.getTextRange().getEndOffset()),
+                                            false));
+          }
         }
       }
     }
index 41aea6e9c181420c3291f3d261dd429fbd3ffd66..11a101da3edd8303edee625a503924b8f93c8442 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,15 +29,11 @@ import com.intellij.psi.impl.FindSuperElementsHelper;
 import com.intellij.psi.presentation.java.SymbolPresentationUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.Consumer;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
 
 public class ShowSiblingsAction extends ShowImplementationsAction {
-  public ShowSiblingsAction() {
-    super();
-  }
-
   @Override
-  public void performForContext(DataContext dataContext, final boolean invokedByShortcut) {
+  public void performForContext(@NotNull DataContext dataContext, final boolean invokedByShortcut) {
     final Project project = CommonDataKeys.PROJECT.getData(dataContext);
     final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
 
@@ -61,7 +57,7 @@ public class ShowSiblingsAction extends ShowImplementationsAction {
     }
 
     final NavigatablePsiElement[] superElements = (NavigatablePsiElement[])findSuperElements(element);
-    if (superElements == null || superElements.length == 0) return;
+    if (superElements.length == 0) return;
 
     final boolean isMethod = superElements[0] instanceof PsiMethod;
     final JBPopup popup = PsiElementListNavigator.navigateOrCreatePopup(superElements, "Choose super " + (isMethod ? "method" : "class or interface"), "Super " + (isMethod ? "methods" : "classes/interfaces"),
@@ -81,11 +77,11 @@ public class ShowSiblingsAction extends ShowImplementationsAction {
   }
 
   private void showSiblings(boolean invokedByShortcut,
-                            Project project,
+                            @NotNull Project project,
                             Editor editor,
                             PsiFile file,
                             boolean invokedFromEditor,
-                            PsiElement element) {
+                            @NotNull PsiElement element) {
     final PsiElement[] impls = getSelfAndImplementations(editor, element, createImplementationsSearcher(), false);
     final String text = SymbolPresentationUtil.getSymbolPresentableText(element);
     showImplementations(impls, project, text, editor, file, element, invokedFromEditor, invokedByShortcut);
@@ -96,11 +92,11 @@ public class ShowSiblingsAction extends ShowImplementationsAction {
     return false;
   }
 
-  @Nullable
+  @NotNull
   private static PsiElement[] findSuperElements(final PsiElement element) {
     PsiNameIdentifierOwner parent = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiClass.class);
     if (parent == null) {
-      return null;
+      return PsiElement.EMPTY_ARRAY;
     }
 
     return FindSuperElementsHelper.findSuperElements(parent);
index 95668b59fa69d16e9eae9d8f18abf566058e19ac..1663d31da4a8f2947f9e046ac6d30bb93de4400a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@ import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 public class JavaGotoSuperHandler implements CodeInsightActionHandler {
   @Override
@@ -41,7 +40,7 @@ public class JavaGotoSuperHandler implements CodeInsightActionHandler {
 
     int offset = editor.getCaretModel().getOffset();
     PsiElement[] superElements = findSuperElements(file, offset);
-    if (superElements == null || superElements.length == 0) return;
+    if (superElements.length == 0) return;
     if (superElements.length == 1) {
       PsiElement superElement = superElements[0].getNavigationElement();
       final PsiFile containingFile = superElement.getContainingFile();
@@ -50,24 +49,25 @@ public class JavaGotoSuperHandler implements CodeInsightActionHandler {
       if (virtualFile == null) return;
       OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile, superElement.getTextOffset());
       FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
-    } else {
-      if (superElements[0] instanceof PsiMethod) {
-        boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature((PsiMethod[])superElements);
-        PsiElementListNavigator.openTargets(editor, (PsiMethod[])superElements,
-                                            CodeInsightBundle.message("goto.super.method.chooser.title"),
-                                            CodeInsightBundle.message("goto.super.method.findUsages.title", ((PsiMethod)superElements[0]).getName()),
-                                            new MethodCellRenderer(showMethodNames));
-      }
-      else {
-        NavigationUtil.getPsiElementPopup(superElements, CodeInsightBundle.message("goto.super.class.chooser.title")).showInBestPositionFor(editor);
-      }
+    }
+    else if (superElements[0] instanceof PsiMethod) {
+      boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature((PsiMethod[])superElements);
+      PsiElementListNavigator.openTargets(editor, (PsiMethod[])superElements,
+                                          CodeInsightBundle.message("goto.super.method.chooser.title"),
+                                          CodeInsightBundle
+                                            .message("goto.super.method.findUsages.title", ((PsiMethod)superElements[0]).getName()),
+                                          new MethodCellRenderer(showMethodNames));
+    }
+    else {
+      NavigationUtil.getPsiElementPopup(superElements, CodeInsightBundle.message("goto.super.class.chooser.title"))
+        .showInBestPositionFor(editor);
     }
   }
 
-  @Nullable
-  private PsiElement[] findSuperElements(PsiFile file, int offset) {
+  @NotNull
+  private PsiElement[] findSuperElements(@NotNull PsiFile file, int offset) {
     PsiElement element = getElement(file, offset);
-    if (element == null) return null;
+    if (element == null) return PsiElement.EMPTY_ARRAY;
 
     final PsiElement psiElement = PsiTreeUtil.getParentOfType(element, PsiFunctionalExpression.class, PsiMember.class);
     if (psiElement instanceof PsiFunctionalExpression) {
@@ -79,13 +79,13 @@ public class JavaGotoSuperHandler implements CodeInsightActionHandler {
 
     final PsiNameIdentifierOwner parent = PsiTreeUtil.getNonStrictParentOfType(element, PsiMethod.class, PsiClass.class);
     if (parent == null) {
-      return null;
+      return PsiElement.EMPTY_ARRAY;
     }
 
     return FindSuperElementsHelper.findSuperElements(parent);
   }
 
-  protected PsiElement getElement(PsiFile file, int offset) {
+  protected PsiElement getElement(@NotNull PsiFile file, int offset) {
     return file.findElementAt(offset);
   }
 
index 5b88af016709cf5f2fbf468d54635cc84fb71738..9d90c20d2e5b5ae242c453bfb3f979fad072cafb 100644 (file)
@@ -50,7 +50,7 @@ public class FormatPostfixTemplate extends StringBasedPostfixTemplate {
   }
 
   @Override
-  protected boolean shouldRemoveParent() {
-    return false;
+  protected PsiElement getElementToRemove(PsiElement expr) {
+    return expr;
   }
 }
index 6c448f4a4e8da70cd10e60a7de805e1a5d3d97d2..fdd485c530367bbf61eb6d42d9e7feb772a75665 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInspection.java18StreamApi.AddMethodsDialog">
-  <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+  <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" 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>
       <xy x="20" y="20" width="500" height="400"/>
     <properties/>
     <border type="none"/>
     <children>
-      <component id="5c4b9" class="com.intellij.ui.components.JBLabel">
+      <grid id="8e5de" 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>
-          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties>
-          <text value="Fully qualified class name:"/>
-        </properties>
-      </component>
-      <vspacer id="c8137">
-        <constraints>
-          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
-        </constraints>
-      </vspacer>
-      <component id="c43e4" class="com.intellij.ui.components.JBLabel">
-        <constraints>
-          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties>
-          <text value="Method name:"/>
-        </properties>
-      </component>
-      <component id="f01fe" class="com.intellij.ui.components.JBLabel">
-        <constraints>
-          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties>
-          <text value="Stream API replacement:"/>
-        </properties>
-      </component>
-      <component id="1f7b6" class="com.intellij.openapi.ui.ComboBox" binding="myPatternsCombo">
-        <constraints>
-          <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-      </component>
-      <component id="7bc3f" class="com.intellij.refactoring.ui.ClassNameReferenceEditor" binding="myClassNameEditor" custom-create="true" default-binding="true">
-        <constraints>
-          <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
-      </component>
-      <component id="f7881" class="com.intellij.openapi.ui.ComboBox" binding="myMethodNameCombo">
+        <border type="none"/>
+        <children>
+          <component id="5c4b9" class="com.intellij.ui.components.JBLabel">
+            <constraints>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <text value="Fully qualified class name:"/>
+            </properties>
+          </component>
+          <component id="c43e4" class="com.intellij.ui.components.JBLabel">
+            <constraints>
+              <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <text value="Method name:"/>
+            </properties>
+          </component>
+          <component id="f01fe" class="com.intellij.ui.components.JBLabel">
+            <constraints>
+              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <text value="Stream API replacement:"/>
+            </properties>
+          </component>
+          <component id="1f7b6" class="com.intellij.openapi.ui.ComboBox" binding="myTemplatesCombo">
+            <constraints>
+              <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties/>
+          </component>
+          <component id="f7881" class="com.intellij.openapi.ui.ComboBox" binding="myMethodNameCombo">
+            <constraints>
+              <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false">
+                <minimum-size width="200" height="-1"/>
+              </grid>
+            </constraints>
+            <properties/>
+          </component>
+          <component id="9c747" class="com.intellij.refactoring.ui.ClassNameReferenceEditor" binding="myClassNameEditor" custom-create="true">
+            <constraints>
+              <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties/>
+          </component>
+        </children>
+      </grid>
+      <grid id="6dced" binding="myExamplePanel" layout-manager="GridLayoutManager" row-count="4" 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="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
-      </component>
+        <border type="none"/>
+        <children>
+          <component id="8c2dc" class="com.intellij.codeInsight.intention.impl.config.ActionUsagePanel" binding="myBeforeActionPanel">
+            <constraints>
+              <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
+                <minimum-size width="-1" height="50"/>
+              </grid>
+            </constraints>
+            <properties/>
+          </component>
+          <component id="e9aff" class="com.intellij.codeInsight.intention.impl.config.ActionUsagePanel" binding="myAfterActionPanel">
+            <constraints>
+              <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
+                <minimum-size width="-1" height="50"/>
+              </grid>
+            </constraints>
+            <properties/>
+          </component>
+          <component id="cc542" class="com.intellij.ui.TitledSeparator">
+            <constraints>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <text value="Before quick fix:"/>
+            </properties>
+          </component>
+          <component id="a9a06" class="com.intellij.ui.TitledSeparator">
+            <constraints>
+              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <opaque value="false"/>
+              <text value="After quick fix:"/>
+            </properties>
+          </component>
+        </children>
+      </grid>
     </children>
   </grid>
 </form>
index 8a8461045f36b2e9b53774acf3dbef49a0800d35..376d3a38b82a30ad28ac374fe524765d1403a479 100644 (file)
 package com.intellij.codeInspection.java18StreamApi;
 
 
+import com.intellij.codeInsight.intention.impl.config.ActionUsagePanel;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
+import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.ComboBox;
 import com.intellij.openapi.ui.DialogWrapper;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiModifier;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.ui.ClassNameReferenceEditor;
+import com.intellij.ui.CollectionComboBoxModel;
 import com.intellij.ui.ColoredListCellRenderer;
+import com.intellij.ui.ListCellRendererWrapper;
 import com.intellij.ui.SimpleTextAttributes;
 import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.LinkedMultiMap;
+import com.intellij.util.containers.MultiMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.*;
+import java.util.List;
 
 /**
  * @author Dmitry Batkovich
@@ -46,36 +56,94 @@ public class AddMethodsDialog extends DialogWrapper {
   @NotNull private final Project myProject;
 
   private JPanel myPanel;
-  private ComboBox myPatternsCombo;
+  private ComboBox myTemplatesCombo;
   private ClassNameReferenceEditor myClassNameEditor;
   private ComboBox myMethodNameCombo;
+  private ActionUsagePanel myBeforeActionPanel;
+  private ActionUsagePanel myAfterActionPanel;
+  private JPanel myExamplePanel;
 
   @SuppressWarnings("unchecked")
   protected AddMethodsDialog(@NotNull final Project project, @NotNull final Component parent, boolean canBeParent) {
     super(parent, canBeParent);
     myProject = project;
-    final DefaultComboBoxModel model = new DefaultComboBoxModel();
-    myPatternsCombo.setModel(model);
-    for (String methodName : StreamApiConstants.STREAM_STREAM_API_METHODS.getValue()) {
-      model.addElement(methodName);
-    }
-    model.addElement(StreamApiConstants.FAKE_FIND_MATCHED);
-    myPatternsCombo.setRenderer(new ColoredListCellRenderer<String>() {
+    myTemplatesCombo.setEnabled(false);
+    myTemplatesCombo.setRenderer(new ColoredListCellRenderer<PseudoLambdaReplaceTemplate>() {
       @Override
-      protected void customizeCellRenderer(JList list, String methodName, int index, boolean selected, boolean hasFocus) {
+      protected void customizeCellRenderer(JList list,
+                                           PseudoLambdaReplaceTemplate template,
+                                           int index,
+                                           boolean selected,
+                                           boolean hasFocus) {
+        if (template == null) {
+          return;
+        }
         append("stream.");
-        if (StreamApiConstants.STREAM_STREAM_API_METHODS.getValue().contains(methodName)) {
-          append(methodName + "()", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
+        final String streamApiMethodName = template.getStreamApiMethodName();
+        if (StreamApiConstants.STREAM_STREAM_API_METHODS.getValue().contains(streamApiMethodName)) {
+          append(streamApiMethodName + "()", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
         }
         else {
-          LOG.assertTrue(StreamApiConstants.FAKE_FIND_MATCHED.equals(methodName));
+          LOG.assertTrue(StreamApiConstants.FAKE_FIND_MATCHED.equals(streamApiMethodName));
           append(String.format(StreamApiConstants.FAKE_FIND_MATCHED_PATTERN, "condition"), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
           append(" or ");
-          append(String.format(StreamApiConstants.FAKE_FIND_MATCHED_WITH_DEFAULT_PATTERN, "condition", "defaultValue"), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
+          append(".orElseGet(() -> defaultValue)", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
+        }
+      }
+    });
+    myTemplatesCombo.addItemListener(new ItemListener() {
+      @Override
+      public void itemStateChanged(ItemEvent e) {
+        final PseudoLambdaReplaceTemplate template = (PseudoLambdaReplaceTemplate)e.getItem();
+        final Collection<PsiMethod> methods = (Collection<PsiMethod>)myMethodNameCombo.getSelectedItem();
+        if (methods == null) {
+          return;
+        }
+        for (PsiMethod method : methods) {
+          if (template.validate(method) != null) {
+            showTemplateExample(template, method);
+            break;
+          }
         }
       }
     });
     myMethodNameCombo.setModel(new DefaultComboBoxModel());
+    myMethodNameCombo.addItemListener(new ItemListener() {
+      @Override
+      public void itemStateChanged(ItemEvent e) {
+        if (!myExamplePanel.isEnabled()) {
+          myExamplePanel.setEnabled(true);
+        }
+        final Collection<PseudoLambdaReplaceTemplate> suitableTemplates = new LinkedHashSet<PseudoLambdaReplaceTemplate>();
+        final Collection<PsiMethod> methods = (Collection<PsiMethod>) e.getItem();
+        for (PseudoLambdaReplaceTemplate template : PseudoLambdaReplaceTemplate.getAllTemplates()) {
+          for (PsiMethod method : methods) {
+            if (template.validate(method) != null) {
+              if (suitableTemplates.isEmpty()) {
+                showTemplateExample(template, method);
+              }
+              suitableTemplates.add(template);
+            }
+          }
+        }
+        if (!myTemplatesCombo.isEnabled()) {
+          myTemplatesCombo.setEnabled(true);
+        }
+        LOG.assertTrue(!suitableTemplates.isEmpty());
+        final List<PseudoLambdaReplaceTemplate> templatesAsList = new ArrayList<PseudoLambdaReplaceTemplate>(suitableTemplates);
+        myTemplatesCombo.setModel(new CollectionComboBoxModel(templatesAsList));
+        myTemplatesCombo.setSelectedItem(templatesAsList.get(0));
+      }
+    });
+    myMethodNameCombo.setRenderer(new ListCellRendererWrapper<Collection<PsiMethod>>() {
+      @Override
+      public void customize(JList list, Collection<PsiMethod> methods, int index, boolean selected, boolean hasFocus) {
+        if (methods != null) {
+          LOG.assertTrue(!methods.isEmpty());
+          setText(ContainerUtil.getFirstItem(methods).getName());
+        }
+      }
+    });
     myClassNameEditor.addDocumentListener(new DocumentAdapter() {
       @Override
       public void documentChanged(DocumentEvent e) {
@@ -84,37 +152,94 @@ public class AddMethodsDialog extends DialogWrapper {
         final DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel)myMethodNameCombo.getModel();
         comboBoxModel.removeAllElements();
         if (aClass == null) {
-          myMethodNameCombo.setEnabled(false);
+          enable(false);
         }
         else {
-          for (String name : ContainerUtil.newTreeSet(ContainerUtil.mapNotNull(aClass.getMethods(), new Function<PsiMethod, String>() {
+          final List<PseudoLambdaReplaceTemplate> possibleTemplates = PseudoLambdaReplaceTemplate.getAllTemplates();
+          final LinkedMultiMap<String, PsiMethod> nameToMethod = new LinkedMultiMap<String, PsiMethod>();
+          for (PsiMethod m : ContainerUtil.filter(aClass.getMethods(), new Condition<PsiMethod>() {
             @Override
-            public String fun(PsiMethod method) {
+            public boolean value(PsiMethod method) {
               if (method.isConstructor() ||
                   !method.hasModifierProperty(PsiModifier.STATIC) ||
                   method.hasModifierProperty(PsiModifier.PRIVATE)) {
-                return null;
+                return false;
+              }
+              boolean templateFound = false;
+              for (PseudoLambdaReplaceTemplate template : possibleTemplates) {
+                if (template.validate(method) != null) {
+                  templateFound = true;
+                }
               }
-              return method.getName();
+              if (!templateFound) {
+                return false;
+              }
+              return true;
             }
-          }))) {
-            comboBoxModel.addElement(name);
+          })) {
+            nameToMethod.putValue(m.getName(), m);
+          }
+          for (Map.Entry<String, Collection<PsiMethod>> entry : nameToMethod.entrySet()) {
+            comboBoxModel.addElement(entry.getValue());
           }
-          myMethodNameCombo.setEnabled(true);
+          final boolean isSuitableMethodsFound = comboBoxModel.getSize() != 0;
+          enable(isSuitableMethodsFound);
         }
       }
     });
+
+    setOKActionEnabled(false);
     init();
   }
 
+  private void enable(boolean isEnabled) {
+    myMethodNameCombo.setEnabled(isEnabled);
+    myTemplatesCombo.setEnabled(isEnabled);
+    setOKActionEnabled(isEnabled);
+    myExamplePanel.setEnabled(isEnabled);
+    if (!isEnabled) {
+      myBeforeActionPanel.reset("", StdFileTypes.JAVA);
+      myAfterActionPanel.reset("", StdFileTypes.JAVA);
+    }
+  }
+
+  private void showTemplateExample(final PseudoLambdaReplaceTemplate template, final PsiMethod method) {
+    final PsiClass aClass = method.getContainingClass();
+    LOG.assertTrue(aClass != null);
+    final String fqn = aClass.getQualifiedName();
+    LOG.assertTrue(fqn != null);
+    final String parameters =
+      StringUtil.join(ContainerUtil.map(method.getParameterList().getParameters(), new Function<PsiParameter, String>() {
+        @Override
+        public String fun(PsiParameter parameter) {
+          return parameter.getName();
+        }
+      }), ", ");
+    final String expressionText = fqn + "." + method.getName() + "(" + parameters + ")";
+    final PsiExpression psiExpression = JavaPsiFacade.getElementFactory(method.getProject())
+      .createExpressionFromText(expressionText, null);
+    LOG.assertTrue(psiExpression instanceof PsiMethodCallExpression);
+    final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)psiExpression;
+    template.convertToStream(methodCallExpression, method, false);
+    myBeforeActionPanel.reset("void example() {\n  <spot>" + methodCallExpression.getText() + "</spot>;\n}", StdFileTypes.JAVA);
+    myAfterActionPanel.reset("void example() {\n  <spot>" + template.convertToStream(methodCallExpression, method, true).getText() + "</spot>\n}", StdFileTypes.JAVA);
+  }
+
+  @Override
+  protected void dispose() {
+    Disposer.dispose(myBeforeActionPanel);
+    Disposer.dispose(myAfterActionPanel);
+    super.dispose();
+  }
+
   private void createUIComponents() {
     myClassNameEditor = new ClassNameReferenceEditor(myProject, null);
   }
 
   public StaticPseudoFunctionalStyleMethodOptions.PipelineElement getSelectedElement() {
     return new StaticPseudoFunctionalStyleMethodOptions.PipelineElement(myClassNameEditor.getText(),
-                                                                        (String)myMethodNameCombo.getSelectedItem(),
-                                                                        (String)myPatternsCombo.getSelectedItem());
+                                                                        ContainerUtil.getFirstItem((Collection < PsiMethod >)myMethodNameCombo.getSelectedItem()).getName(),
+                                                                        (PseudoLambdaReplaceTemplate)myTemplatesCombo.getSelectedItem());
   }
 
   @Nullable
diff --git a/java/java-impl/src/com/intellij/codeInspection/java18StreamApi/PseudoLambdaReplaceTemplate.java b/java/java-impl/src/com/intellij/codeInspection/java18StreamApi/PseudoLambdaReplaceTemplate.java
new file mode 100644 (file)
index 0000000..425f142
--- /dev/null
@@ -0,0 +1,555 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection.java18StreamApi;
+
+import com.intellij.codeInsight.daemon.impl.quickfix.AddTypeArgumentsFix;
+import com.intellij.codeInspection.AnonymousCanBeLambdaInspection;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.impl.PsiDiamondTypeUtil;
+import com.intellij.psi.util.*;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.*;
+
+/**
+ * @author Dmitry Batkovich
+ */
+class PseudoLambdaReplaceTemplate {
+  private final static Logger LOG = Logger.getInstance(PseudoLambdaReplaceTemplate.class);
+
+  public enum LambdaRole {
+    PREDICATE,
+    FUNCTION
+  }
+
+  public static class ValidationInfo {
+    private final int myLambdaPosition;
+    private final int myIterablePosition;
+    private final int myDefaultValuePosition;
+
+    public ValidationInfo(int lambdaPosition, int iterablePosition, int defaultValuePosition) {
+      myLambdaPosition = lambdaPosition;
+      myIterablePosition = iterablePosition;
+      myDefaultValuePosition = defaultValuePosition;
+    }
+
+    public int getLambdaPosition() {
+      return myLambdaPosition;
+    }
+
+    public int getIterablePosition() {
+      return myIterablePosition;
+    }
+
+    public int getDefaultValuePosition() {
+      return myDefaultValuePosition;
+    }
+  }
+
+  static final PseudoLambdaReplaceTemplate MAP =
+    new PseudoLambdaReplaceTemplate(StreamApiConstants.MAP, LambdaRole.FUNCTION, false);
+  static final PseudoLambdaReplaceTemplate FILTER =
+    new PseudoLambdaReplaceTemplate(StreamApiConstants.FILTER, LambdaRole.PREDICATE, false);
+  static final PseudoLambdaReplaceTemplate FIND =
+    new PseudoLambdaReplaceTemplate(StreamApiConstants.FAKE_FIND_MATCHED, LambdaRole.PREDICATE, true);
+  static final PseudoLambdaReplaceTemplate ALL_MATCH =
+    new PseudoLambdaReplaceTemplate(StreamApiConstants.ALL_MATCH, LambdaRole.PREDICATE, false);
+  static final PseudoLambdaReplaceTemplate ANY_MATCH =
+    new PseudoLambdaReplaceTemplate(StreamApiConstants.ANY_MATCH, LambdaRole.PREDICATE, false);
+
+  private final String myStreamApiMethodName;
+  private final LambdaRole myLambdaRole;
+  private final boolean myAcceptDefaultValue;
+
+  public PseudoLambdaReplaceTemplate(String method,
+                                     LambdaRole type,
+                                     boolean acceptDefaultValue) {
+    myStreamApiMethodName = method;
+    myLambdaRole = type;
+    myAcceptDefaultValue = acceptDefaultValue;
+  }
+
+  public static List<PseudoLambdaReplaceTemplate> getAllTemplates() {
+    return ContainerUtil.newArrayList(MAP, FILTER, FIND, ALL_MATCH, ANY_MATCH);
+  }
+
+  public ValidationInfo validate(final PsiMethod method) {
+    final PsiParameter[] parameters = method.getParameterList().getParameters();
+    final PsiType[] parameterTypes =
+      ContainerUtil.map2Array(Arrays.asList(parameters), new PsiType[parameters.length], new Function<PsiParameter, PsiType>() {
+        @Override
+        public PsiType fun(PsiParameter parameter) {
+          return parameter.getType();
+        }
+      });
+    final PsiType returnType = method.getReturnType();
+
+    if (returnType instanceof PsiClassType) {
+      final PsiClass resolvedReturnTypeClass = ((PsiClassType)returnType).resolve();
+      if (!InheritanceUtil.isInheritor(resolvedReturnTypeClass, CommonClassNames.JAVA_LANG_ITERABLE)) {
+        return null;
+      }
+    } else if (!(returnType instanceof PsiArrayType)) {
+      return null;
+    }
+    return validate(parameterTypes, returnType, null, method);
+  }
+
+  @Nullable
+  public ValidationInfo validate(final PsiMethodCallExpression expression) {
+    final PsiType[] argumentTypes = expression.getArgumentList().getExpressionTypes();
+    final PsiType methodReturnType = expression.getType();
+    if (methodReturnType == null) {
+      return null;
+    }
+
+    final PsiMethod method = expression.resolveMethod();
+    if (method == null) {
+      return null;
+    }
+    final PsiParameter[] expectedParameters = method.getParameterList().getParameters();
+
+    if (argumentTypes.length != expectedParameters.length) {
+      return null;
+    }
+    final JavaResolveResult result = expression.getMethodExpression().advancedResolve(false);
+    final PsiSubstitutor methodSubstitutor = result.getSubstitutor();
+    return validate(argumentTypes, methodReturnType, methodSubstitutor, expression);
+  }
+
+  public String getStreamApiMethodName() {
+    return myStreamApiMethodName;
+  }
+
+  public LambdaRole getLambdaRole() {
+    return myLambdaRole;
+  }
+
+  public boolean isAcceptDefaultValue() {
+    return myAcceptDefaultValue;
+  }
+
+  private ValidationInfo validate(final PsiType[] arguments,
+                                  final PsiType methodReturnType,
+                                  final @Nullable PsiSubstitutor methodSubstitutor,
+                                  final PsiElement context) {
+    int lambdaPosition = -1;
+    int defaultValuePosition = -1;
+    int iterablePosition = -1;
+
+    if (!myAcceptDefaultValue) {
+      if (arguments.length != 2) {
+        return null;
+      }
+    } else {
+      if (arguments.length != 2 && arguments.length != 3) {
+        return null;
+      }
+    }
+
+    for (int i = 0; i < arguments.length; i++) {
+      PsiType type = arguments[i];
+      if (isFunction(type, methodReturnType, methodSubstitutor, context)) {
+        if (lambdaPosition == -1) {
+          lambdaPosition = i;
+          continue;
+        }
+        else {
+          return null;
+        }
+      }
+      if (isIterableOrArray(type)) {
+        if (iterablePosition == -1) {
+          iterablePosition = i;
+          continue;
+        }
+        else {
+          return null;
+        }
+      }
+      if (myAcceptDefaultValue && methodReturnType.isAssignableFrom(type)) {
+        if (defaultValuePosition == -1) {
+          defaultValuePosition = i;
+        }
+        else {
+          return null;
+        }
+      }
+    }
+
+    if (lambdaPosition == -1 || iterablePosition == -1) {
+      return null;
+    }
+    if (myAcceptDefaultValue) {
+      if (defaultValuePosition == -1 && arguments.length == 3) {
+        return null;
+      }
+    }
+    return new ValidationInfo(lambdaPosition, iterablePosition, defaultValuePosition);
+  }
+
+  private boolean isFunction(PsiType type, PsiType baseMethodReturnType, PsiSubstitutor methodSubstitutor, PsiElement context) {
+    if (type instanceof PsiMethodReferenceType) {
+      final PsiMethodReferenceExpression expression = ((PsiMethodReferenceType)type).getExpression();
+      final PsiMethod resolvedMethod = (PsiMethod)expression.resolve();
+      if (resolvedMethod == null) {
+        return false;
+      }
+      final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
+      if ((parameters.length != 1 && myLambdaRole == LambdaRole.FUNCTION) || (parameters.length != 0 && myLambdaRole == LambdaRole.PREDICATE)) {
+        return false;
+      }
+      final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(expression);
+      return isSuitableLambdaRole(returnType, baseMethodReturnType, methodSubstitutor, context);
+    } else if (type instanceof PsiLambdaExpressionType) {
+      final PsiLambdaExpression expression = ((PsiLambdaExpressionType)type).getExpression();
+      final PsiType psiType = LambdaUtil.getFunctionalInterfaceReturnType(expression.getFunctionalInterfaceType());
+      return isSuitableLambdaRole(psiType, baseMethodReturnType, methodSubstitutor, context);
+    } else if (isSuitableFunctionalType(type, baseMethodReturnType, methodSubstitutor, context)) {
+      return true;
+    }
+    return isJavaLangClassType(type) && myLambdaRole == LambdaRole.PREDICATE;
+  }
+
+  private boolean isSuitableLambdaRole(PsiType lambdaReturnType,
+                                       PsiType baseMethodReturnType,
+                                       PsiSubstitutor methodSubstitutor,
+                                       PsiElement context) {
+    if (lambdaReturnType == null) {
+      return false;
+    }
+    if (myLambdaRole == LambdaRole.PREDICATE) {
+      final PsiClassType boxedBoolean = PsiType.BOOLEAN.getBoxedType(context);
+      if (!(PsiType.BOOLEAN.equals(lambdaReturnType) || (boxedBoolean != null && boxedBoolean.equals(lambdaReturnType)))) {
+        return false;
+      }
+    }
+    else {
+      LOG.assertTrue(myLambdaRole == LambdaRole.FUNCTION);
+      if (methodSubstitutor != null) {
+        lambdaReturnType = methodSubstitutor.substitute(lambdaReturnType);
+      }
+      if (baseMethodReturnType instanceof PsiClassType) {
+        final PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)baseMethodReturnType).resolveGenerics();
+        final Map<PsiTypeParameter, PsiType> substitutionMap = resolveResult.getSubstitutor().getSubstitutionMap();
+        if (substitutionMap.size() != 1) {
+          return false;
+        }
+        final PsiType iterableParametrizedType = ContainerUtil.getFirstItem(substitutionMap.values());
+        if (!lambdaReturnType.equals(iterableParametrizedType)) {
+          return false;
+        }
+      }
+      else if (baseMethodReturnType instanceof PsiArrayType) {
+        if (!lambdaReturnType.equals(((PsiArrayType)baseMethodReturnType).getComponentType())) {
+          return false;
+        }
+      }
+    }
+    return true;
+  }
+
+  private static boolean isJavaLangClassType(PsiType type) {
+    if (type instanceof PsiClassType) {
+      final PsiClass resolvedClass = ((PsiClassType)type).resolve();
+      if (resolvedClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(resolvedClass.getQualifiedName())) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private boolean isSuitableFunctionalType(final PsiType type,
+                                           final PsiType baseMethodReturnType,
+                                           final @Nullable PsiSubstitutor methodSubstitutor,
+                                           final PsiElement context) {
+    if (type instanceof PsiClassType) {
+      final PsiClass resolvedClass = ((PsiClassType)type).resolve();
+      if (resolvedClass != null) {
+        if (resolvedClass instanceof PsiAnonymousClass) {
+          final PsiClass baseClass = ((PsiAnonymousClass)resolvedClass).getBaseClassType().resolve();
+          if (baseClass == null) {
+            return false;
+          }
+          if (!LambdaUtil.isFunctionalClass(baseClass)) {
+            return false;
+          }
+          PsiMethod superMethod = LambdaUtil.getFunctionalInterfaceMethod(baseClass);
+          if (superMethod == null) {
+            return false;
+          }
+          final PsiMethod[] methods = resolvedClass.findMethodsByName(superMethod.getName(), false);
+          PsiMethod method = null;
+          for (PsiMethod m : methods) {
+            if (PsiSuperMethodUtil.isSuperMethod(m, superMethod)) {
+              method = m;
+            }
+          }
+          if (method == null) {
+            return false;
+          }
+          final PsiType psiType = methodSubstitutor == null ? method.getReturnType() : methodSubstitutor.substitute(method.getReturnType());
+          return isSuitableLambdaRole(psiType, baseMethodReturnType, methodSubstitutor, context);
+        } else {
+          if (!LambdaUtil.isFunctionalClass(resolvedClass)) {
+            return false;
+          }
+          return isSuitableLambdaRole(LambdaUtil.getFunctionalInterfaceReturnType(type), baseMethodReturnType, methodSubstitutor, context);
+        }
+        }
+      return false;
+    } else {
+      return false;
+    }
+  }
+
+  @NotNull
+  public PsiExpression convertToStream(final PsiMethodCallExpression expression, PsiMethod method, boolean force) {
+    LOG.assertTrue(expression != null);
+    if (method == null) {
+      method = expression.resolveMethod();
+      if (method == null) {
+        return expression;
+      }
+    }
+    final ValidationInfo validationInfo = force ? validate(method) : validate(expression);
+    if (validationInfo == null) {
+      return expression;
+    }
+    final Project project = expression.getProject();
+    int lambdaIndex = validationInfo.getLambdaPosition();
+
+    final PsiExpression[] expressions = expression.getArgumentList().getExpressions();
+    final PsiExpression iterableExpression = expressions[validationInfo.getIterablePosition()];
+    final String pipelineHead = createPipelineHeadText(iterableExpression, force);
+    if (pipelineHead == null) {
+      return expression;
+    }
+
+    PsiExpression lambdaExpression = expressions[lambdaIndex];
+    if (!force) {
+      lambdaExpression = convertClassTypeExpression(lambdaExpression);
+      lambdaExpression = convertToJavaLambda(lambdaExpression);
+    }
+    LOG.assertTrue(lambdaExpression != null);
+
+    final String lambdaExpressionText;
+    final String elementText;
+    if (!StreamApiConstants.FAKE_FIND_MATCHED.equals(myStreamApiMethodName)) {
+      elementText = myStreamApiMethodName;
+      lambdaExpressionText = lambdaExpression.getText();
+    }
+    else {
+      elementText = validationInfo.getDefaultValuePosition() != -1
+                    ? String.format(StreamApiConstants.FAKE_FIND_MATCHED_WITH_DEFAULT_PATTERN, lambdaExpression.getText(),
+                                    expressions[validationInfo.getDefaultValuePosition()].getText())
+                    : String.format(StreamApiConstants.FAKE_FIND_MATCHED_PATTERN, lambdaExpression.getText());
+      lambdaExpressionText = null;
+    }
+    final String pipelineTail =
+      StreamApiConstants.STREAM_STREAM_API_METHODS.getValue().contains(myStreamApiMethodName)
+      ? findSuitableTailMethodForCollection(method)
+      : null;
+
+    final PsiElement replaced =
+      expression.replace(createPipelineExpression(pipelineHead, elementText, lambdaExpressionText, pipelineTail, project));
+    JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced.getParent());
+    return (PsiExpression)replaced;
+  }
+
+  private static PsiExpression createPipelineExpression(String pipelineHead,
+                                                        String elementText,
+                                                        String lambdaExpression,
+                                                        String pipelineTail,
+                                                        Project project) {
+    final StringBuilder sb = new StringBuilder();
+    sb.append(pipelineHead).append(".").append(elementText);
+    if (lambdaExpression != null) {
+      sb.append("(").append(lambdaExpression).append(")");
+    }
+    if (pipelineTail != null) {
+      sb.append(".").append(pipelineTail);
+    }
+    return JavaPsiFacade.getElementFactory(project).createExpressionFromText(sb.toString(), null);
+  }
+
+  @Nullable
+  private static String findSuitableTailMethodForCollection(PsiMethod lambdaHandler) {
+    final PsiType type = lambdaHandler.getReturnType();
+    if (type instanceof PsiArrayType) {
+      final PsiType arrayComponentType = ((PsiArrayType)type).getComponentType();
+      return "toArray(" + arrayComponentType.getCanonicalText() + "[]::new)";
+    }
+    else if (type instanceof PsiClassType) {
+      final PsiClass resolvedClass = ((PsiClassType)type).resolve();
+      if (resolvedClass == null) {
+        return null;
+      }
+      final String qName = resolvedClass.getQualifiedName();
+      if (qName == null) {
+        return null;
+      }
+      if (qName.equals(CommonClassNames.JAVA_UTIL_LIST)
+          || qName.equals(CommonClassNames.JAVA_UTIL_COLLECTION)
+          || qName.equals(CommonClassNames.JAVA_LANG_ITERABLE)) {
+        return "collect(" + StreamApiConstants.JAVA_UTIL_STREAM_COLLECTORS + ".toList())";
+      }
+      else if (qName.equals(CommonClassNames.JAVA_UTIL_SET)) {
+        return "collect(" + StreamApiConstants.JAVA_UTIL_STREAM_COLLECTORS + ".toSet())";
+      }
+      else if (qName.equals(CommonClassNames.JAVA_UTIL_ITERATOR)) {
+        return "iterator()";
+      }
+    }
+    return null;
+  }
+
+  private static PsiExpression convertToJavaLambda(PsiExpression expression) {
+    if (expression instanceof PsiMethodReferenceExpression) {
+      return expression;
+    }
+    if (expression instanceof PsiLambdaExpression) {
+      return expression;
+    }
+    if (expression instanceof PsiMethodCallExpression) {
+      final PsiMethod method = ((PsiMethodCallExpression)expression).resolveMethod();
+      if (method == null) {
+        return null;
+      }
+      final PsiType type = method.getReturnType();
+      if (!(type instanceof PsiClassType)) {
+        return null;
+      }
+      final PsiClassType.ClassResolveResult result = ((PsiClassType)type).resolveGenerics();
+      final PsiClass lambdaClass = result.getElement();
+      if (lambdaClass == null) {
+        return null;
+      }
+      final PsiMethod functionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(lambdaClass);
+      LOG.assertTrue(functionalInterfaceMethod != null);
+      final String methodName = functionalInterfaceMethod.getName();
+      return JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(expression.getText() + "::" + methodName, null);
+    }
+    if (expression instanceof PsiReferenceExpression) {
+      final PsiType expressionType = expression.getType();
+      final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(expressionType);
+      LOG.assertTrue(method != null);
+      return JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(expression.getText() + "::" + method.getName(), null);
+    }
+    return AnonymousCanBeLambdaInspection.replacePsiElementWithLambda(expression, true);
+  }
+
+  @NotNull
+  private static PsiExpression convertClassTypeExpression(PsiExpression expression) {
+    final PsiType type = expression.getType();
+    if (type instanceof PsiClassType) {
+      final PsiClass resolvedClass = ((PsiClassType)type).resolve();
+      if (resolvedClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(resolvedClass.getQualifiedName())) {
+        return JavaPsiFacade.getElementFactory(expression.getProject())
+          .createExpressionFromText("(" + expression.getText() + ")::isInstance", null);
+      }
+    }
+    return expression;
+  }
+
+  private static String createPipelineHeadText(PsiExpression collectionExpression, boolean force) {
+    if (collectionExpression instanceof PsiNewExpression) {
+      final PsiDiamondType.DiamondInferenceResult diamondResolveResult =
+        PsiDiamondTypeImpl.resolveInferredTypesNoCheck((PsiNewExpression)collectionExpression, collectionExpression);
+      if (!diamondResolveResult.getInferredTypes().isEmpty()) {
+        collectionExpression = PsiDiamondTypeUtil.expandTopLevelDiamondsInside(collectionExpression);
+      }
+    }
+    else if (collectionExpression instanceof PsiMethodCallExpression) {
+      final PsiType currentType = collectionExpression.getType();
+      if (currentType == null) {
+        return null;
+      }
+      final PsiExpression copiedExpression = (PsiExpression) collectionExpression.copy();
+      final PsiType newType = copiedExpression.getType();
+      if (!currentType.equals(newType)) {
+        collectionExpression = AddTypeArgumentsFix.addTypeArguments(copiedExpression, currentType);
+        if (collectionExpression == null) {
+          return null;
+        }
+      }
+    }
+    final PsiType type = collectionExpression.getType();
+    if (type instanceof PsiClassType) {
+      final PsiClass resolved = ((PsiClassType)type).resolve();
+      LOG.assertTrue(resolved != null && resolved.getQualifiedName() != null, type);
+      if (InheritanceUtil.isInheritor(resolved, CommonClassNames.JAVA_UTIL_COLLECTION)) {
+        return collectionExpression.getText() + ".stream()";
+      } else {
+        return "java.util.stream.StreamSupport.stream(" + collectionExpression.getText() + ".spliterator(), false)";
+      }
+    }
+    else if (type instanceof PsiArrayType) {
+      return CommonClassNames.JAVA_UTIL_ARRAYS + ".stream(" + collectionExpression.getText() + ")";
+    } else if (force) {
+      return collectionExpression.getText() + ".stream()";
+    }
+    throw new AssertionError("type: " + type + " is unexpected for expression: " + collectionExpression.getText());
+  }
+
+  private static boolean isIterableOrArray(final PsiType type) {
+    if (type instanceof PsiClassType) {
+      final PsiClass resolvedClass = ((PsiClassType)type).resolve();
+      if (resolvedClass != null) {
+        return InheritanceUtil.isInheritor(resolvedClass, CommonClassNames.JAVA_LANG_ITERABLE);
+      }
+    }
+    else if (type instanceof PsiArrayType) {
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    PseudoLambdaReplaceTemplate template = (PseudoLambdaReplaceTemplate)o;
+
+    if (myAcceptDefaultValue != template.myAcceptDefaultValue) return false;
+    if (!myStreamApiMethodName.equals(template.myStreamApiMethodName)) return false;
+    if (myLambdaRole != template.myLambdaRole) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = myStreamApiMethodName.hashCode();
+    result = 31 * result + myLambdaRole.hashCode();
+    result = 31 * result + (myAcceptDefaultValue ? 1 : 0);
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    return "PseudoLambdaReplaceTemplate{" +
+           "myStreamApiMethodName='" + myStreamApiMethodName + '\'' +
+           '}';
+  }
+}
index 47ff9eb5e6fa56ca76bf2d39362e3759fc16a0fa..398aabc0ff206ccbdd3fa3e0da69deccd0b4493f 100644 (file)
@@ -18,16 +18,12 @@ package com.intellij.codeInspection.java18StreamApi;
 import com.intellij.codeInspection.*;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.util.containers.ContainerUtil;
 import org.jdom.Element;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
@@ -35,7 +31,6 @@ import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.util.Collection;
-import java.util.List;
 
 /**
  * @author Dmitry Batkovich
@@ -102,10 +97,9 @@ public class StaticPseudoFunctionalStyleMethodInspection extends BaseJavaBatchLo
           if (suitableHandler == null) {
             return;
           }
-          final int lambdaIndex = validateMethodParameters(methodCallExpression, method, suitableHandler.getStreamApiMethodName() == StreamApiConstants.FAKE_FIND_MATCHED);
-          if (lambdaIndex != -1) {
-            holder.registerProblem(methodCallExpression.getMethodExpression(), "",
-                                   new ReplacePseudoLambdaWithLambda(lambdaIndex, methodCallExpression, method, suitableHandler));
+          final PseudoLambdaReplaceTemplate.ValidationInfo validationInfo = suitableHandler.getTemplate().validate(methodCallExpression);
+          if (validationInfo != null) {
+            holder.registerProblem(methodCallExpression.getMethodExpression(), "Pseudo functional style code", new ReplacePseudoLambdaWithLambda(suitableHandler));
           }
         }
       }
@@ -113,17 +107,10 @@ public class StaticPseudoFunctionalStyleMethodInspection extends BaseJavaBatchLo
   }
 
   public static class ReplacePseudoLambdaWithLambda implements LocalQuickFix {
-    private final int myLambdaIndex;
-    private final SmartPsiElementPointer<PsiMethod> myMethodPointer;
-    private final StaticPseudoFunctionalStyleMethodOptions.PipelineElement mySuitableHandler;
+    private final StaticPseudoFunctionalStyleMethodOptions.PipelineElement myHandler;
 
-    private ReplacePseudoLambdaWithLambda(int lambdaIndex,
-                                          @NotNull PsiMethodCallExpression expression,
-                                          @NotNull PsiMethod method,
-                                          @NotNull StaticPseudoFunctionalStyleMethodOptions.PipelineElement suitableHandler) {
-      myLambdaIndex = lambdaIndex;
-      myMethodPointer = SmartPointerManager.getInstance(expression.getProject()).createSmartPsiElementPointer(method);
-      mySuitableHandler = suitableHandler;
+    private ReplacePseudoLambdaWithLambda(StaticPseudoFunctionalStyleMethodOptions.PipelineElement handler) {
+      myHandler = handler;
     }
 
     @Nls
@@ -143,253 +130,7 @@ public class StaticPseudoFunctionalStyleMethodInspection extends BaseJavaBatchLo
     public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
       PsiMethodCallExpression expression = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethodCallExpression.class);
       LOG.assertTrue(expression != null);
-      final PsiExpression[] expressions = expression.getArgumentList().getExpressions();
-      PsiExpression lambdaExpression = expressions[myLambdaIndex];
-      lambdaExpression = convertClassTypeExpression(lambdaExpression);
-      lambdaExpression = convertToJavaLambda(lambdaExpression, mySuitableHandler.getStreamApiMethodName());
-      LOG.assertTrue(lambdaExpression != null);
-
-      final PsiExpression collectionExpression = expressions[(1 + myLambdaIndex) % 2];
-      final String pipelineHead = createPipelineHeadText(collectionExpression);
-
-
-      final String lambdaExpressionText;
-      final String elementText;
-      if (!StreamApiConstants.FAKE_FIND_MATCHED.equals(mySuitableHandler.getStreamApiMethodName())) {
-        elementText = mySuitableHandler.getStreamApiMethodName();
-        lambdaExpressionText = lambdaExpression.getText();
-      }
-      else {
-        elementText = expressions.length == 3
-                      ? String.format(StreamApiConstants.FAKE_FIND_MATCHED_WITH_DEFAULT_PATTERN, lambdaExpression.getText(), expressions[2].getText())
-                      : String.format(StreamApiConstants.FAKE_FIND_MATCHED_PATTERN, lambdaExpression.getText());
-        lambdaExpressionText = null;
-      }
-      final String pipelineTail =
-        StreamApiConstants.STREAM_STREAM_API_METHODS.getValue().contains(mySuitableHandler.getStreamApiMethodName())
-        ? findSuitableTailMethodForCollection(myMethodPointer.getElement())
-        : null;
-
-      final PsiElement replaced =
-        expression.replace(createPipelineExpression(pipelineHead, elementText, lambdaExpressionText, pipelineTail, project));
-      JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced.getParent());
-    }
-
-    @NotNull
-    private static PsiExpression convertClassTypeExpression(PsiExpression expression) {
-      final PsiType type = expression.getType();
-      if (type instanceof PsiClassType) {
-        final PsiClass resolvedClass = ((PsiClassType)type).resolve();
-        if (resolvedClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(resolvedClass.getQualifiedName())) {
-          return JavaPsiFacade.getElementFactory(expression.getProject())
-            .createExpressionFromText("(" + expression.getText() + ")::isInstance", null);
-        }
-      }
-      return expression;
-    }
-
-    private static String createPipelineHeadText(PsiExpression collectionExpression) {
-      final PsiType type = collectionExpression.getType();
-      if (type instanceof PsiClassType) {
-        final PsiClass resolved = ((PsiClassType)type).resolve();
-        LOG.assertTrue(resolved != null && resolved.getQualifiedName() != null, type);
-        return collectionExpression.getText() + ".stream()";
-      }
-      else if (type instanceof PsiArrayType) {
-        return CommonClassNames.JAVA_UTIL_ARRAYS + ".stream(" + collectionExpression.getText() + ")";
-      }
-      throw new AssertionError("type: " + type + " is unexpected");
-    }
-
-    private static PsiExpression createPipelineExpression(String pipelineHead,
-                                                          String elementText,
-                                                          String lambdaExpression,
-                                                          String pipelineTail,
-                                                          Project project) {
-      final StringBuilder sb = new StringBuilder();
-      sb.append(pipelineHead).append(".").append(elementText);
-      if (lambdaExpression != null) {
-        sb.append("(").append(lambdaExpression).append(")");
-      }
-      if (pipelineTail != null) {
-        sb.append(".").append(pipelineTail);
-      }
-      return JavaPsiFacade.getElementFactory(project).createExpressionFromText(sb.toString(), null);
-    }
-  }
-
-  private static int validateMethodParameters(final PsiMethodCallExpression methodCallExpression, final PsiMethod method, boolean canThirdParameterExist) {
-    final PsiType[] argumentTypes = methodCallExpression.getArgumentList().getExpressionTypes();
-    final PsiParameter[] expectedParameters = method.getParameterList().getParameters();
-
-    if (argumentTypes.length != expectedParameters.length) {
-      return -1;
-    }
-    if (expectedParameters.length == 2 || (canThirdParameterExist && expectedParameters.length == 3)) {
-      final int collectionOrArrayIndex = findCollectionOrArrayPlacement(expectedParameters);
-      if (collectionOrArrayIndex == -1) {
-        return -1;
-      }
-      return (1 + collectionOrArrayIndex) % 2;
-
-    }
-    return -1;
-  }
-
-  private static int findCollectionOrArrayPlacement(final PsiParameter[] parameters) {
-    for (int i = 0, length = parameters.length; i < length; i++) {
-      PsiParameter parameter = parameters[i];
-      final PsiType type = parameter.getType();
-      if (type instanceof PsiClassType || type instanceof PsiArrayType) {
-        return i;
-      }
-    }
-    return -1;
-  }
-
-  private static PsiExpression convertToJavaLambda(PsiExpression expression, String streamApiMethodName) {
-    if (streamApiMethodName.equals(StreamApiConstants.FAKE_FIND_MATCHED)) {
-      streamApiMethodName = StreamApiConstants.FILTER;
-    }
-    if (expression instanceof PsiMethodReferenceExpression) {
-      return expression;
-    }
-    if (expression instanceof PsiLambdaExpression) {
-      return expression;
-    }
-    if (expression instanceof PsiMethodCallExpression) {
-      final PsiMethod method = ((PsiMethodCallExpression)expression).resolveMethod();
-      if (method == null) {
-        return null;
-      }
-      final PsiType type = method.getReturnType();
-      if (!(type instanceof PsiClassType)) {
-        return null;
-      }
-      final PsiClass lambdaClass = ((PsiClassType)type).resolve();
-      if (lambdaClass == null) {
-        return null;
-      }
-      final String methodName = lambdaClass.getMethods()[0].getName();
-      if (tryConvertPseudoLambdaToStreamApi(method, resolveStreamApiLambdaClass(expression.getProject(), streamApiMethodName))) {
-        return expression;
-      }
-      else {
-        return JavaPsiFacade.getElementFactory(expression.getProject())
-          .createExpressionFromText(expression.getText() + "::" + methodName, null);
-      }
-    }
-    return AnonymousCanBeLambdaInspection.replacePsiElementWithLambda(expression, true);
-  }
-
-  @NotNull
-  private static PsiClass resolveStreamApiLambdaClass(Project project, String streamApiMethodName) {
-    final PsiClass javaUtilStream = JavaPsiFacade.getInstance(project)
-      .findClass(StreamApiConstants.JAVA_UTIL_STREAM_STREAM, GlobalSearchScope.notScope(GlobalSearchScope.projectScope(project)));
-    LOG.assertTrue(javaUtilStream != null);
-    final PsiMethod[] methods = javaUtilStream.findMethodsByName(streamApiMethodName, false);
-    LOG.assertTrue(methods.length == 1);
-    final PsiMethod method = methods[0];
-    final PsiParameter[] parameters = method.getParameterList().getParameters();
-    LOG.assertTrue(parameters.length == 1);
-    final PsiType type = parameters[0].getType();
-    LOG.assertTrue(type instanceof PsiClassType);
-    final PsiClass resolved = ((PsiClassType)type).resolve();
-    LOG.assertTrue(resolved != null);
-    return resolved;
-  }
-
-  private static boolean tryConvertPseudoLambdaToStreamApi(final @NotNull PsiMethod method, final @NotNull PsiClass expectedReturnClass) {
-    final PsiType currentReturnType = method.getReturnType();
-    if (!(currentReturnType instanceof PsiClassType)) {
-      LOG.error("pseudo-lambda return type must be class " + currentReturnType);
-      return true;
-    }
-    final PsiClass resolvedCurrentReturnType = ((PsiClassType)currentReturnType).resolve();
-    if (expectedReturnClass.getManager().areElementsEquivalent(expectedReturnClass, resolvedCurrentReturnType)) {
-      return true;
-    }
-    final PsiCodeBlock body = method.getBody();
-    Collection<PsiReturnStatement> returnStatements = PsiTreeUtil.findChildrenOfType(body, PsiReturnStatement.class);
-    returnStatements = ContainerUtil.filter(returnStatements, new Condition<PsiReturnStatement>() {
-      @Override
-      public boolean value(PsiReturnStatement statement) {
-        return PsiTreeUtil.getParentOfType(statement, PsiMethod.class) == method;
-      }
-    });
-    if (returnStatements.size() != 1) {
-      return false;
-    }
-    final PsiReturnStatement returnStatement = ContainerUtil.getFirstItem(returnStatements);
-    assert returnStatement != null;
-    final PsiExpression returnValue = returnStatement.getReturnValue();
-    if (returnValue instanceof PsiNewExpression) {
-      convertNewExpression(method, (PsiNewExpression)returnValue, expectedReturnClass);
-      return true;
-    }
-    else {
-      return false;
-    }
-  }
-
-  private static void convertNewExpression(PsiMethod containingMethod, PsiNewExpression newExpression, PsiClass expectedReturnClass) {
-    final String expectedReturnQName = expectedReturnClass.getQualifiedName();
-    LOG.assertTrue(expectedReturnQName != null);
-    final PsiElementFactory factory = JavaPsiFacade.getElementFactory(newExpression.getProject());
-    PsiAnonymousClass anonymousClass = PsiTreeUtil.findChildOfType(newExpression, PsiAnonymousClass.class);
-    LOG.assertTrue(anonymousClass != null);
-    PsiJavaCodeReferenceElement referenceElement = PsiTreeUtil.findChildOfType(anonymousClass, PsiJavaCodeReferenceElement.class);
-    LOG.assertTrue(referenceElement != null);
-    final PsiReferenceParameterList parameterList = PsiTreeUtil.findChildOfType(referenceElement, PsiReferenceParameterList.class);
-    final PsiJavaCodeReferenceElement newCodeReferenceElement = factory.createReferenceFromText(expectedReturnClass.getQualifiedName()
-                                                                                                +
-                                                                                                (parameterList == null
-                                                                                                 ? ""
-                                                                                                 : parameterList.getText()), null);
-    referenceElement.replace(newCodeReferenceElement);
-    final List<PsiMethod> methods = ContainerUtil.filter(anonymousClass.getMethods(), new Condition<PsiMethod>() {
-      @Override
-      public boolean value(PsiMethod method) {
-        return !"equals".equals(method.getName());
-      }
-    });
-    LOG.assertTrue(methods.size() == 1, methods);
-    final PsiMethod method = methods.get(0);
-    method.setName(expectedReturnClass.getMethods()[0].getName());
-    final PsiTypeElement element = containingMethod.getReturnTypeElement();
-    if (element != null) {
-      final PsiReferenceParameterList genericParameter = PsiTreeUtil.findChildOfType(element, PsiReferenceParameterList.class);
-      element.replace(factory.createTypeElementFromText(expectedReturnQName + (genericParameter == null ? "" : genericParameter.getText()), null));
-    }
-  }
-
-  @Nullable
-  private static String findSuitableTailMethodForCollection(PsiMethod lambdaHandler) {
-    final PsiType type = lambdaHandler.getReturnType();
-    if (type instanceof PsiArrayType) {
-      return "toArray(String[]::new)";
-    }
-    else if (type instanceof PsiClassType) {
-      final PsiClass resolvedClass = ((PsiClassType)type).resolve();
-      if (resolvedClass == null) {
-        return null;
-      }
-      final String qName = resolvedClass.getQualifiedName();
-      if (qName == null) {
-        return null;
-      }
-      if (qName.equals(CommonClassNames.JAVA_UTIL_LIST)
-          || qName.equals(CommonClassNames.JAVA_UTIL_COLLECTION)
-          || qName.equals(CommonClassNames.JAVA_LANG_ITERABLE)) {
-        return "collect(" + StreamApiConstants.JAVA_UTIL_STREAM_COLLECTORS + ".toList())";
-      }
-      else if (qName.equals(CommonClassNames.JAVA_UTIL_SET)) {
-        return "collect(" + StreamApiConstants.JAVA_UTIL_STREAM_COLLECTORS + ".toSet())";
-      }
-      else if (qName.equals(CommonClassNames.JAVA_UTIL_ITERATOR)) {
-        return "iterator()";
-      }
+      myHandler.getTemplate().convertToStream(expression, null, false);
     }
-    return null;
   }
 }
\ No newline at end of file
index 0fa7399ca3c8b62f438b815cf32e51788976cc63..9787c394b997896b74a89f02c6c952ed79a1b955 100644 (file)
 package com.intellij.codeInspection.java18StreamApi;
 
 import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Condition;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.ui.*;
 import com.intellij.ui.components.JBList;
 import com.intellij.util.containers.ContainerUtil;
@@ -32,7 +30,6 @@ import javax.swing.*;
 import javax.swing.event.ListDataListener;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -43,6 +40,8 @@ public class StaticPseudoFunctionalStyleMethodOptions {
   private static final String FQN_ATTR = "classFqn";
   private static final String METHOD_ATTR = "method";
   private static final String STREAM_API_METHOD_ATTR = "streamApiMethod";
+  private static final String LAMBDA_ROLE_ATTR = "lambdaRole";
+  private static final String ACCEPTS_DEFAULT_ATTR = "acceptsDefault";
   private static final String DELETE_ATTR = "toDelete";
   private final List<PipelineElement> myElements;
 
@@ -54,11 +53,11 @@ public class StaticPseudoFunctionalStyleMethodOptions {
   private static void restoreDefault(final List<PipelineElement> elements) {
     elements.clear();
     final String guavaIterables = "com.google.common.collect.Iterables";
-    elements.add(new PipelineElement(guavaIterables, "transform", StreamApiConstants.MAP));
-    elements.add(new PipelineElement(guavaIterables, "filter", StreamApiConstants.FILTER));
-    elements.add(new PipelineElement(guavaIterables, "find", StreamApiConstants.FAKE_FIND_MATCHED));
-    elements.add(new PipelineElement(guavaIterables, "all", StreamApiConstants.ALL_MATCH));
-    elements.add(new PipelineElement(guavaIterables, "any", StreamApiConstants.ANY_MATCH));
+    elements.add(new PipelineElement(guavaIterables, "transform", PseudoLambdaReplaceTemplate.MAP));
+    elements.add(new PipelineElement(guavaIterables, "filter", PseudoLambdaReplaceTemplate.FILTER));
+    elements.add(new PipelineElement(guavaIterables, "find", PseudoLambdaReplaceTemplate.FIND));
+    elements.add(new PipelineElement(guavaIterables, "all", PseudoLambdaReplaceTemplate.ALL_MATCH));
+    elements.add(new PipelineElement(guavaIterables, "any", PseudoLambdaReplaceTemplate.ANY_MATCH));
   }
 
   @NotNull
@@ -77,8 +76,11 @@ public class StaticPseudoFunctionalStyleMethodOptions {
       final String fqn = element.getAttributeValue(FQN_ATTR);
       final String method = element.getAttributeValue(METHOD_ATTR);
       final String streamApiMethod = element.getAttributeValue(STREAM_API_METHOD_ATTR);
+      final PseudoLambdaReplaceTemplate.LambdaRole lambdaRole =
+        PseudoLambdaReplaceTemplate.LambdaRole.valueOf(element.getAttributeValue(LAMBDA_ROLE_ATTR));
+      final boolean acceptsDefault = Boolean.valueOf(element.getAttributeValue(ACCEPTS_DEFAULT_ATTR));
       final boolean toDelete = element.getAttribute(DELETE_ATTR) != null;
-      final PipelineElement pipelineElement = new PipelineElement(fqn, method, streamApiMethod);
+      final PipelineElement pipelineElement = new PipelineElement(fqn, method, new PseudoLambdaReplaceTemplate(streamApiMethod, lambdaRole, acceptsDefault));
       if (toDelete) {
         myElements.remove(pipelineElement);
       }
@@ -107,10 +109,13 @@ public class StaticPseudoFunctionalStyleMethodOptions {
   }
 
   public Element createXmlElement(PipelineElement element) {
+    final PseudoLambdaReplaceTemplate template = element.getTemplate();
     return new Element(PIPELINE_ELEMENT_NAME)
       .setAttribute(FQN_ATTR, element.getHandlerClass())
       .setAttribute(METHOD_ATTR, element.getMethodName())
-      .setAttribute(STREAM_API_METHOD_ATTR, element.getStreamApiMethodName());
+      .setAttribute(STREAM_API_METHOD_ATTR, template.getStreamApiMethodName())
+      .setAttribute(LAMBDA_ROLE_ATTR, template.getLambdaRole().toString())
+      .setAttribute(ACCEPTS_DEFAULT_ATTR, String.valueOf(template.isAcceptDefaultValue()));
   }
 
   public JComponent createPanel() {
@@ -137,6 +142,9 @@ public class StaticPseudoFunctionalStyleMethodOptions {
         if (currentProject == null) {
           return;
         }
+        if (DumbService.isDumb(currentProject)) {
+          return;
+        }
         final AddMethodsDialog dlg = new AddMethodsDialog(currentProject, list, false);
         if (dlg.showAndGet()) {
           final PipelineElement newElement = dlg.getSelectedElement();
@@ -147,6 +155,7 @@ public class StaticPseudoFunctionalStyleMethodOptions {
           UIUtil.invokeLaterIfNeeded(new Runnable() {
             @Override
             public void run() {
+              list.revalidate();
               list.updateUI();
             }
           });
@@ -156,19 +165,28 @@ public class StaticPseudoFunctionalStyleMethodOptions {
       @Override
       public void run(AnActionButton button) {
         myElements.remove(list.getSelectedIndex());
+        UIUtil.invokeLaterIfNeeded(new Runnable() {
+          @Override
+          public void run() {
+            list.revalidate();
+            list.updateUI();
+          }
+        });
       }
     }).createPanel();
   }
 
-    public static class PipelineElement {
+  public static class PipelineElement {
     private final String myHandlerClass;
     private final String myMethodName;
-    private final String myStreamApiMethod;
+    private final PseudoLambdaReplaceTemplate myTemplate;
 
-    public PipelineElement(@NotNull String handlerClass, @NotNull String methodName, @NotNull String streamApiMethod) {
+    public PipelineElement(@NotNull String handlerClass,
+                           @NotNull String methodName,
+                           @NotNull PseudoLambdaReplaceTemplate template) {
       myHandlerClass = handlerClass;
       myMethodName = methodName;
-      myStreamApiMethod = streamApiMethod;
+      myTemplate = template;
     }
 
     public String getHandlerClass() {
@@ -179,8 +197,8 @@ public class StaticPseudoFunctionalStyleMethodOptions {
       return myMethodName;
     }
 
-    public String getStreamApiMethodName() {
-      return myStreamApiMethod;
+    public PseudoLambdaReplaceTemplate getTemplate() {
+      return myTemplate;
     }
 
     @Override
@@ -192,7 +210,7 @@ public class StaticPseudoFunctionalStyleMethodOptions {
 
       if (!myHandlerClass.equals(element.myHandlerClass)) return false;
       if (!myMethodName.equals(element.myMethodName)) return false;
-      if (!myStreamApiMethod.equals(element.myStreamApiMethod)) return false;
+      if (!myTemplate.equals(element.myTemplate)) return false;
 
       return true;
     }
@@ -201,7 +219,7 @@ public class StaticPseudoFunctionalStyleMethodOptions {
     public int hashCode() {
       int result = myHandlerClass.hashCode();
       result = 31 * result + myMethodName.hashCode();
-      result = 31 * result + myStreamApiMethod.hashCode();
+      result = 31 * result + myTemplate.hashCode();
       return result;
     }
   }
index a18ef1eb16320462ac653b0a3dbb578ce03ab513..20a0cb12bb4cda4414f3b92668e93feb201a15bd 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
 import com.intellij.openapi.ide.CopyPasteManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.util.IncorrectOperationException;
@@ -128,7 +129,8 @@ public class JavaFilePasteProvider implements PasteProvider {
   private static PsiJavaFile createJavaFileFromClipboardContent(final Project project) {
     String text = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
     if (text == null) return null;
-    PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("A.java", JavaLanguage.INSTANCE, text);
+    PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("A.java", JavaLanguage.INSTANCE, 
+                                                                             StringUtil.convertLineSeparators(text));
     return psiFile instanceof PsiJavaFile ? (PsiJavaFile)psiFile : null;
   }
 }
index ae858bb077f0bdb6e10ea299241740ddd41043e1..78c2b78ff8d64e02174d4e867e1ac1bd30f59fec 100644 (file)
@@ -72,7 +72,6 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
     }
     else if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
       consumer.showStandardOptions("RIGHT_MARGIN",
-                                   "WRAP_ON_TYPING",
                                    "KEEP_CONTROL_STATEMENT_IN_ONE_LINE",
                                    "LINE_COMMENT_AT_FIRST_COLUMN",
                                    "BLOCK_COMMENT_AT_FIRST_COLUMN",
index 5e3a2d10c36d14f31dbb31b8e65106591788cd0e..a1a22653a60ee839258b45d2def8bee14dbe71f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import com.intellij.psi.PsiModifier;
+import com.intellij.psi.impl.FindSuperElementsHelper;
 import com.intellij.psi.presentation.java.SymbolPresentationUtil;
 import com.intellij.psi.search.PsiElementProcessor;
 import com.intellij.psi.search.searches.DeepestSuperMethodsSearch;
@@ -34,6 +35,7 @@ import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -41,20 +43,24 @@ public class SuperMethodWarningUtil {
   private SuperMethodWarningUtil() {}
 
   @NotNull
-  public static PsiMethod[] checkSuperMethods(final PsiMethod method, String actionString) {
-    return checkSuperMethods(method, actionString, null);
+  public static PsiMethod[] checkSuperMethods(@NotNull PsiMethod method, @NotNull String actionString) {
+    return checkSuperMethods(method, actionString, Collections.<PsiElement>emptyList());
   }
 
   @NotNull
-  public static PsiMethod[] checkSuperMethods(final PsiMethod method, String actionString, Collection<PsiElement> ignore) {
+  public static PsiMethod[] checkSuperMethods(@NotNull PsiMethod method, @NotNull String actionString, @NotNull Collection<PsiElement> ignore) {
     PsiClass aClass = method.getContainingClass();
     if (aClass == null) return new PsiMethod[]{method};
 
     final Collection<PsiMethod> superMethods = DeepestSuperMethodsSearch.search(method).findAll();
-    if (ignore != null) {
-      superMethods.removeAll(ignore);
-    }
+    superMethods.removeAll(ignore);
 
+    if (superMethods.isEmpty()) {
+      PsiMethod siblingSuperMethod = FindSuperElementsHelper.getSiblingInheritedViaSubClass(method);
+      if (siblingSuperMethod != null) {
+        superMethods.add(siblingSuperMethod);
+      }
+    }
     if (superMethods.isEmpty()) return new PsiMethod[]{method};
 
 
@@ -85,7 +91,7 @@ public class SuperMethodWarningUtil {
   }
 
 
-  public static PsiMethod checkSuperMethod(final PsiMethod method, String actionString) {
+  public static PsiMethod checkSuperMethod(@NotNull PsiMethod method, @NotNull String actionString) {
     PsiClass aClass = method.getContainingClass();
     if (aClass == null) return method;
 
@@ -110,10 +116,10 @@ public class SuperMethodWarningUtil {
     return null;
   }
 
-  public static void checkSuperMethod(final PsiMethod method,
-                                      final String actionString,
-                                      final PsiElementProcessor<PsiMethod> processor,
-                                      final Editor editor) {
+  public static void checkSuperMethod(@NotNull PsiMethod method,
+                                      @NotNull String actionString,
+                                      @NotNull final PsiElementProcessor<PsiMethod> processor,
+                                      @NotNull Editor editor) {
     PsiClass aClass = method.getContainingClass();
     if (aClass == null) {
       processor.execute(method);
@@ -137,7 +143,7 @@ public class SuperMethodWarningUtil {
       return;
     }
 
-    final PsiMethod[] methods = new PsiMethod[]{superMethod, method};
+    final PsiMethod[] methods = {superMethod, method};
     final String renameBase = actionString + " base method";
     final String renameCurrent = actionString + " only current method";
     final JBList list = new JBList(renameBase, renameCurrent);
@@ -148,6 +154,7 @@ public class SuperMethodWarningUtil {
       .setResizable(false)
       .setRequestFocus(true)
       .setItemChoosenCallback(new Runnable() {
+        @Override
         public void run() {
           final Object value = list.getSelectedValue();
           if (value instanceof String) {
index fff50d1c41abb33ca25c2e84563fe66167acb907..6f74898b9a31984d76b58680dfb9807901ffa488 100644 (file)
@@ -816,7 +816,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
 
   @Nullable
   protected Wrap arrangeChildWrap(final ASTNode child, Wrap defaultWrap) {
-    return myWrapManager.arrangeChildWrap(child, myNode, getSettings(), defaultWrap, this);
+    return myWrapManager.arrangeChildWrap(child, myNode, mySettings, myJavaSettings, defaultWrap, this);
   }
 
   @NotNull
index 54965f9eca1ebf042c635f1d8a0195880a09e216..c607722df7019bc33d0ca3f3535a13ac5f92a526 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.formatting.Block;
 import com.intellij.formatting.Wrap;
 import com.intellij.lang.ASTNode;
 import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
 import com.intellij.psi.formatter.java.AbstractJavaBlock;
 import com.intellij.psi.formatter.java.wrap.impl.JavaChildBlockWrapFactory;
 import com.intellij.psi.formatter.java.wrap.impl.JavaChildWrapArranger;
@@ -78,10 +79,14 @@ public class JavaWrapManager {
    *                                <code>null</code> otherwise
    */
   @Nullable
-  public Wrap arrangeChildWrap(ASTNode child, ASTNode parent, CommonCodeStyleSettings settings, Wrap suggestedWrap,
+  public Wrap arrangeChildWrap(ASTNode child, 
+                               ASTNode parent, 
+                               CommonCodeStyleSettings settings,
+                               JavaCodeStyleSettings javaSettings,
+                               Wrap suggestedWrap,
                                AbstractJavaBlock reservedWrapsProvider)
   {
-    return myChildArranger.arrange(child, parent, settings, suggestedWrap, reservedWrapsProvider);
+    return myChildArranger.arrange(child, parent, settings, javaSettings, suggestedWrap, reservedWrapsProvider);
   }
 
   /**
index 23914cb5fce881dc88e3b89c5264dd3635781872..8516ba04c0679f2a7d585d79ded0c54e6b0a77c2 100644 (file)
@@ -72,9 +72,9 @@ public class JavaChildWrapArranger {
   public Wrap arrange(ASTNode child,
                       ASTNode parent,
                       CommonCodeStyleSettings settings,
+                      JavaCodeStyleSettings javaSettings,
                       Wrap suggestedWrap,
                       AbstractJavaBlock reservedWrapsProvider) {
-    final JavaCodeStyleSettings javaSettings = settings.getRootSettings().getCustomSettings(JavaCodeStyleSettings.class);
     ASTNode directParent = child.getTreeParent();
     int role = ((CompositeElement)directParent).getChildRole(child);
 
index 8bb1a8daa50121b7943c9c03225cc267e4b75fe6..e5cb7d55ed6119e74a0a82ef2f0ee2f3a7b8bc81 100644 (file)
@@ -412,7 +412,7 @@ public class ImportHelper{
         useOnDemand = false;
       }
       // name of class we try to import is the same as of the class defined in this file
-      if (curRefClass != null) {
+      if (containsInCurrentFile(file, curRefClass)) {
         useOnDemand = true;
       }
       // check conflicts
@@ -428,10 +428,9 @@ public class ImportHelper{
     }
 
     if (useOnDemand &&
-        curRefClass != null &&
         refClass.getContainingClass() != null &&
         mySettings.INSERT_INNER_CLASS_IMPORTS &&
-        "java.lang".equals(StringUtil.getPackageName(curRefClass.getQualifiedName()))) {
+        containsInCurrentFile(file, curRefClass)) {
       return false;
     }
 
@@ -465,6 +464,17 @@ public class ImportHelper{
     return true;
   }
 
+  private static boolean containsInCurrentFile(@NotNull PsiJavaFile file, PsiClass curRefClass) {
+    if (curRefClass != null) {
+      final String curRefClassQualifiedName = curRefClass.getQualifiedName();
+      if (curRefClassQualifiedName != null && 
+          ArrayUtil.find(file.getImplicitlyImportedPackages(), StringUtil.getPackageName(curRefClassQualifiedName)) < 0) {
+         return true;
+      }
+    }
+    return false;
+  }
+
   private static void calcClassesToReimport(PsiJavaFile file, JavaPsiFacade facade, PsiResolveHelper helper, String packageName, List<PsiClass> classesToReimport,
                                      Collection<String> onDemandRefs) {
     if (onDemandRefs.isEmpty()) {
index e0baa8787526679d630653d0953a1818fe90805c..2d20a2b0441d45db0ef0fec730c6debe547375ac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,11 +23,16 @@ import com.intellij.psi.util.FileTypeUtils;
 
 public class JavaVetoRenameCondition implements Condition<PsiElement> {
   @Override
-  public boolean value(final PsiElement element) {
+  public boolean value(PsiElement element) {
     if (element instanceof LightMethod) {
-      final PsiClass containingClass = ((LightMethod)element).getContainingClass();
+      PsiClass containingClass = ((LightMethod)element).getContainingClass();
       if (containingClass != null && containingClass.isEnum()) return true;
     }
+
+    if (element instanceof PsiReceiverParameter) {
+      return true;
+    }
+
     return element instanceof PsiJavaFile &&
            !FileTypeUtils.isInServerPageFile(element) &&
            !JavaProjectRootsUtil.isOutsideJavaSourceRoot((PsiFile)element) &&
index 966a7a3422ea6e39577bec2b2859ffede6d490bb..4be83981446ebb175051cb091133d51621a58947 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,13 +20,14 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.spi.psi.SPIClassProviderReferenceElement;
+import org.jetbrains.annotations.NotNull;
 
 /**
  * User: anna
  */
 public class SPIGotoSuperHandler extends JavaGotoSuperHandler {
   @Override
-  protected PsiElement getElement(PsiFile file, int offset) {
+  protected PsiElement getElement(@NotNull PsiFile file, int offset) {
     final SPIClassProviderReferenceElement
       providerElement = PsiTreeUtil.getParentOfType(super.getElement(file, offset), SPIClassProviderReferenceElement.class);
     if (providerElement != null) {
index 293d3350040bdca4a88145d069055e46ac8de8b6..067db93f8551a021bdd54450a5039536decfa77b 100644 (file)
@@ -81,7 +81,7 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
     final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
     for (final String name : names) {
       ProgressIndicatorProvider.checkCanceled();
-      final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass[]>() {
+      final PsiClass[] classes = MethodUsagesSearcher.resolveInReadAction(project, new Computable<PsiClass[]>() {
         @Override
         public PsiClass[] compute() {
           return cache.getClassesByName(name, scope);
@@ -97,21 +97,27 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
     return true;
   }
 
-  public static Project processClassNames(Project project, GlobalSearchScope scope, final Consumer<String> consumer) {
+  public static Project processClassNames(final Project project, final GlobalSearchScope scope, final Consumer<String> consumer) {
     final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
 
-    PsiShortNamesCache.getInstance(project).processAllClassNames(new Processor<String>() {
-      int i = 0;
-
+    MethodUsagesSearcher.resolveInReadAction(project, new Computable<Void>() {
       @Override
-      public boolean process(String s) {
-        if (indicator != null && i++ % 512 == 0) {
-          indicator.checkCanceled();
-        }
-        consumer.consume(s);
-        return true;
+      public Void compute() {
+        PsiShortNamesCache.getInstance(project).processAllClassNames(new Processor<String>() {
+          int i = 0;
+
+          @Override
+          public boolean process(String s) {
+            if (indicator != null && i++ % 512 == 0) {
+              indicator.checkCanceled();
+            }
+            consumer.consume(s);
+            return true;
+          }
+        }, scope, IdFilter.getProjectIdFilter(project, true));
+        return null;
       }
-    }, scope, IdFilter.getProjectIdFilter(project, true));
+    });
 
     if (indicator != null) {
       indicator.checkCanceled();
index a614854ba728fc6a7e57840a8db16a784a92bb94..797a22e8d68adaf0ead940b4199f0299c7ca3551 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class JavaAllOverridingMethodsSearcher implements QueryExecutor<Pair<PsiM
         PsiSubstitutor substitutor = null;
 
         for (String name : methods.keySet()) {
-          if (inheritor.findMethodsByName(name, false).length == 0) continue;
+          if (inheritor.findMethodsByName(name, true).length == 0) continue;
 
           for (PsiMethod method : methods.get(name)) {
             if (method.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) &&
index acbf022097328e45f8d80226637bfdb1a6848706..b24fcfc87c210bb4a12179d423bd9e5ef0e3572e 100644 (file)
@@ -101,12 +101,14 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
       return true;
     }
 
-    Collection<PsiReferenceList> candidates = ApplicationManager.getApplication().runReadAction(new Computable<Collection<PsiReferenceList>>() {
-      @Override
-      public Collection<PsiReferenceList> compute() {
-        return JavaSuperClassNameOccurenceIndex.getInstance().get(searchKey, project, scope);
-      }
-    });
+    Collection<PsiReferenceList> candidates = MethodUsagesSearcher.resolveInReadAction(project,
+                                                                                       new Computable<Collection<PsiReferenceList>>() {
+                                                                                         @Override
+                                                                                         public Collection<PsiReferenceList> compute() {
+                                                                                           return JavaSuperClassNameOccurenceIndex
+                                                                                             .getInstance().get(searchKey, project, scope);
+                                                                                         }
+                                                                                       });
 
     Map<String, List<PsiClass>> classes = new HashMap<String, List<PsiClass>>();
 
@@ -118,7 +120,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
           return referenceList.getParent();
         }
       });
-      if (!checkInheritance(p, aClass, candidate)) continue;
+      if (!checkInheritance(p, aClass, candidate, project)) continue;
 
       String fqn = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
         @Override
@@ -142,16 +144,19 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
     }
 
     if (p.includeAnonymous()) {
-      Collection<PsiAnonymousClass> anonymousCandidates = ApplicationManager.getApplication().runReadAction(new Computable<Collection<PsiAnonymousClass>>() {
-        @Override
-        public Collection<PsiAnonymousClass> compute() {
-          return JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(searchKey, project, scope);
-        }
-      });
+      Collection<PsiAnonymousClass> anonymousCandidates = MethodUsagesSearcher.resolveInReadAction(project,
+                                                                                                   new Computable<Collection<PsiAnonymousClass>>() {
+                                                                                                     @Override
+                                                                                                     public Collection<PsiAnonymousClass> compute() {
+                                                                                                       return JavaAnonymousClassBaseRefOccurenceIndex
+                                                                                                         .getInstance()
+                                                                                                         .get(searchKey, project, scope);
+                                                                                                     }
+                                                                                                   });
 
       for (PsiAnonymousClass candidate : anonymousCandidates) {
         ProgressIndicatorProvider.checkCanceled();
-        if (!checkInheritance(p, aClass, candidate)) continue;
+        if (!checkInheritance(p, aClass, candidate, project)) continue;
 
         if (!consumer.process(candidate)) return false;
       }
@@ -190,8 +195,8 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
     return true;
   }
 
-  private static boolean checkInheritance(final DirectClassInheritorsSearch.SearchParameters p, final PsiClass aClass, final PsiClass candidate) {
-    return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
+  private static boolean checkInheritance(final DirectClassInheritorsSearch.SearchParameters p, final PsiClass aClass, final PsiClass candidate, Project project) {
+    return MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
       @Override
       public Boolean compute() {
         return !p.isCheckInheritance() || candidate.isInheritor(aClass, false);
index c7d9e303aae3cea4afcb0d76f354c1d548fc9484..c1a747fb3b0323fb0f6df04316e0e7f473bef8cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.intellij.codeInsight;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
+import com.intellij.psi.PsiAnnotation.TargetType;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -28,28 +29,27 @@ import java.util.Set;
  * @author peter
  */
 public class AnnotationTargetUtil {
-  public static final Set<PsiAnnotation.TargetType> DEFAULT_TARGETS = Collections.unmodifiableSet(ContainerUtil.newHashSet(
-    PsiAnnotation.TargetType.PACKAGE, PsiAnnotation.TargetType.TYPE, PsiAnnotation.TargetType.ANNOTATION_TYPE,
-    PsiAnnotation.TargetType.FIELD, PsiAnnotation.TargetType.METHOD, PsiAnnotation.TargetType.CONSTRUCTOR,
-    PsiAnnotation.TargetType.PARAMETER, PsiAnnotation.TargetType.LOCAL_VARIABLE));
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.AnnotationUtil");
-  private static final PsiAnnotation.TargetType[] PACKAGE_TARGETS = {PsiAnnotation.TargetType.PACKAGE};
-  private static final PsiAnnotation.TargetType[] TYPE_USE_TARGETS = {PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] ANNOTATION_TARGETS = {PsiAnnotation.TargetType.ANNOTATION_TYPE, PsiAnnotation.TargetType.TYPE, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] TYPE_TARGETS = {PsiAnnotation.TargetType.TYPE, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] TYPE_PARAMETER_TARGETS = {
-    PsiAnnotation.TargetType.TYPE_PARAMETER, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] CONSTRUCTOR_TARGETS = {PsiAnnotation.TargetType.CONSTRUCTOR, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] METHOD_TARGETS = {PsiAnnotation.TargetType.METHOD, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] FIELD_TARGETS = {PsiAnnotation.TargetType.FIELD, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] PARAMETER_TARGETS = {PsiAnnotation.TargetType.PARAMETER, PsiAnnotation.TargetType.TYPE_USE};
-  private static final PsiAnnotation.TargetType[] LOCAL_VARIABLE_TARGETS ={
-    PsiAnnotation.TargetType.LOCAL_VARIABLE, PsiAnnotation.TargetType.TYPE_USE};
+
+  public static final Set<TargetType> DEFAULT_TARGETS = ContainerUtil.immutableSet(
+    TargetType.PACKAGE, TargetType.TYPE, TargetType.ANNOTATION_TYPE, TargetType.FIELD, TargetType.METHOD, TargetType.CONSTRUCTOR,
+    TargetType.PARAMETER, TargetType.LOCAL_VARIABLE);
+
+  private static final TargetType[] PACKAGE_TARGETS = {TargetType.PACKAGE};
+  private static final TargetType[] TYPE_USE_TARGETS = {TargetType.TYPE_USE};
+  private static final TargetType[] ANNOTATION_TARGETS = {TargetType.ANNOTATION_TYPE, TargetType.TYPE, TargetType.TYPE_USE};
+  private static final TargetType[] TYPE_TARGETS = {TargetType.TYPE, TargetType.TYPE_USE};
+  private static final TargetType[] TYPE_PARAMETER_TARGETS = {TargetType.TYPE_PARAMETER, TargetType.TYPE_USE};
+  private static final TargetType[] CONSTRUCTOR_TARGETS = {TargetType.CONSTRUCTOR, TargetType.TYPE_USE};
+  private static final TargetType[] METHOD_TARGETS = {TargetType.METHOD, TargetType.TYPE_USE};
+  private static final TargetType[] FIELD_TARGETS = {TargetType.FIELD, TargetType.TYPE_USE};
+  private static final TargetType[] PARAMETER_TARGETS = {TargetType.PARAMETER, TargetType.TYPE_USE};
+  private static final TargetType[] LOCAL_VARIABLE_TARGETS = {TargetType.LOCAL_VARIABLE, TargetType.TYPE_USE};
 
   @NotNull
-  public static PsiAnnotation.TargetType[] getTargetsForLocation(@Nullable PsiAnnotationOwner owner) {
+  public static TargetType[] getTargetsForLocation(@Nullable PsiAnnotationOwner owner) {
     if (owner == null) {
-      return PsiAnnotation.TargetType.EMPTY_ARRAY;
+      return TargetType.EMPTY_ARRAY;
     }
 
     if (owner instanceof PsiType || owner instanceof PsiTypeElement) {
@@ -90,24 +90,27 @@ public class AnnotationTargetUtil {
       if (element instanceof PsiLocalVariable) {
         return LOCAL_VARIABLE_TARGETS;
       }
+      if (element instanceof PsiReceiverParameter) {
+        return TYPE_USE_TARGETS;
+      }
     }
 
-    return PsiAnnotation.TargetType.EMPTY_ARRAY;
+    return TargetType.EMPTY_ARRAY;
   }
 
   @Nullable
-  public static Set<PsiAnnotation.TargetType> extractRequiredAnnotationTargets(@Nullable PsiAnnotationMemberValue value) {
+  public static Set<TargetType> extractRequiredAnnotationTargets(@Nullable PsiAnnotationMemberValue value) {
     if (value instanceof PsiReference) {
-      PsiAnnotation.TargetType targetType = translateTargetRef((PsiReference)value);
+      TargetType targetType = translateTargetRef((PsiReference)value);
       if (targetType != null) {
         return Collections.singleton(targetType);
       }
     }
     else if (value instanceof PsiArrayInitializerMemberValue) {
-      Set <PsiAnnotation.TargetType> targets = ContainerUtil.newHashSet();
+      Set <TargetType> targets = ContainerUtil.newHashSet();
       for (PsiAnnotationMemberValue initializer : ((PsiArrayInitializerMemberValue)value).getInitializers()) {
         if (initializer instanceof PsiReference) {
-          PsiAnnotation.TargetType targetType = translateTargetRef((PsiReference)initializer);
+          TargetType targetType = translateTargetRef((PsiReference)initializer);
           if (targetType != null) {
             targets.add(targetType);
           }
@@ -120,12 +123,12 @@ public class AnnotationTargetUtil {
   }
 
   @Nullable
-  private static PsiAnnotation.TargetType translateTargetRef(@NotNull PsiReference reference) {
+  private static TargetType translateTargetRef(@NotNull PsiReference reference) {
     PsiElement field = reference.resolve();
     if (field instanceof PsiEnumConstant) {
       String name = ((PsiEnumConstant)field).getName();
       try {
-        return PsiAnnotation.TargetType.valueOf(name);
+        return TargetType.valueOf(name);
       }
       catch (IllegalArgumentException e) {
         LOG.warn("Unknown target: " + name);
index eb93e359f57511eb32fd2f185e888e3e79d79976..abbbb4fbd52cd8d389e442b7e609d7dd9cf75681 100644 (file)
  */
 package com.intellij.psi;
 
+import org.jetbrains.annotations.NotNull;
+
 /**
  * Represents a receiver parameter of a Java method (Java 8).
  *
  * @since 12.1
  */
 public interface PsiReceiverParameter extends PsiVariable {
+  @NotNull
+  PsiThisExpression getIdentifier();
 }
index 5d11f1fb5005493933fb7ac1094b715a0038e00b..f0a0e0f6968d58afd8e3011a4d461aa04d75220f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package com.intellij.psi.util;
 
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
 import org.jetbrains.annotations.NotNull;
 
 public class MethodSignatureBackedByPsiMethod extends MethodSignatureBase {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.psi.util.MethodSignatureBackedByPsiMethod");
-
   private final PsiMethod myMethod;
   private final boolean myIsRaw;
   private final String myName;
index 634eda49bcdcd2159c06090af11757c2c4f87802..d916d1d1cf4a089929a26ade2028883f8704c3a5 100644 (file)
@@ -608,6 +608,22 @@ public class DeclarationParser {
       }
     }
 
+    if (typed) {
+      IElementType tokenType = builder.getTokenType();
+      if (tokenType == JavaTokenType.THIS_KEYWORD || tokenType == JavaTokenType.IDENTIFIER && builder.lookAhead(1) == JavaTokenType.DOT) {
+        PsiBuilder.Marker mark = builder.mark();
+
+        PsiBuilder.Marker expr = myParser.getExpressionParser().parse(builder);
+        if (expr != null && exprType(expr) == JavaElementType.THIS_EXPRESSION) {
+          mark.drop();
+          done(param, JavaElementType.RECEIVER_PARAMETER);
+          return param;
+        }
+
+        mark.rollbackTo();
+      }
+    }
+
     if (expect(builder, JavaTokenType.IDENTIFIER)) {
       if (!resource) {
         eatBrackets(builder, typeInfo != null && typeInfo.isVarArg ? "expected.rparen" : null);
index dc919245f5c9a497127b95d53beffbb474281f29..2b8fead86fc4ef17f3d292c159f981311a1d8d02 100644 (file)
@@ -401,17 +401,21 @@ public class ExpressionParser {
           expr.done(dotTokenType == JavaTokenType.THIS_KEYWORD ? JavaElementType.THIS_EXPRESSION : JavaElementType.SUPER_EXPRESSION);
         }
         else {
-          dotPos.drop();
           PsiBuilder.Marker refExpr = expr.precede();
 
           myParser.getReferenceParser().parseReferenceParameterList(builder, false, false);