Merge remote branch 'origin/master'
authorirengrig <Irina.Chernushina@jetbrains.com>
Fri, 7 Sep 2012 10:54:01 +0000 (14:54 +0400)
committerirengrig <Irina.Chernushina@jetbrains.com>
Fri, 7 Sep 2012 10:54:01 +0000 (14:54 +0400)
306 files changed:
images/src/META-INF/ImagesPlugin.xml
java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
java/compiler/impl/src/com/intellij/compiler/impl/CompilerUtil.java
java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
java/compiler/impl/src/com/intellij/packaging/impl/elements/ManifestFileUtil.java
java/debugger/impl/src/com/intellij/debugger/DebugUIEnvironment.java
java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java
java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
java/execution/impl/execution-impl.iml
java/execution/impl/src/com/intellij/execution/applet/AppletConfigurationProducer.java
java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java
java/idea-ui/src/com/intellij/framework/addSupport/impl/AddSupportForSingleFrameworkDialog.java
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromSourcesMode.java
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportImlMode.java
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportMode.java
java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/WizardMode.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/UsageInArtifact.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddLibraryDependencyAction.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FindUsagesInProjectStructureActionBase.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureElementUsage.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/UsageInModuleClasspath.java
java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddDefaultConstructorFix.java
java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
java/java-impl/src/com/intellij/ide/actions/JavaQualifiedNameProvider.java
java/java-impl/src/com/intellij/openapi/roots/LibraryDependencyScopeSuggester.java [new file with mode: 0644]
java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaArrangementVisitor.java
java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
java/java-psi-api/src/com/intellij/codeInsight/ExternalAnnotationsListener.java [new file with mode: 0644]
java/java-psi-api/src/com/intellij/codeInsight/ExternalAnnotationsManager.java
java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java
java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
java/java-psi-impl/src/com/intellij/psi/scope/util/PsiScopesUtil.java
java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/TryWithResourcesThrowsException-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/TryWithResourcesThrowsException.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/VariableInitialization.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsAnnotateLibrary_after.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsDeannotation1_after.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsDeannotation_after.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root1/multiRoot/annotations.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root1/multiRoot/annotations_after.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root2/multiRoot/annotations.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root2/multiRoot/annotations_after.xml [new file with mode: 0644]
java/java-tests/testData/codeInsight/externalAnnotations/lib/multiRoot/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/FromLambdaBody.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethod/FromLambdaBody_after.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineConstantField/CastWhenLambdaAsQualifier.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineConstantField/CastWhenLambdaAsQualifier.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineLocal/LocalVarInsideLambdaBody.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineLocal/LocalVarInsideLambdaBody.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleOneLine.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleOneLine.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleToBlock.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleToBlock.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleOneLine.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleOneLine.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleToBlock.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleToBlock.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaValueCompatible.after.java [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaValueCompatible.java [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaVoidCompatible.after.java [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaVoidCompatible.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java
java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java
java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineConstantFieldTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java
jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java
jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsArtifactSerializationTest.java
jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java
jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsSerializationTestCase.java
jps/plugins/appLauncher/jps-appLauncher.iml
platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
platform/core-api/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java
platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/JdkScope.java
platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/LibraryScope.java [new file with mode: 0644]
platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/LibraryScopeBase.java [new file with mode: 0644]
platform/lang-api/lang-api.iml
platform/lang-api/src/com/intellij/codeInsight/editorActions/moveUpDown/LineRange.java
platform/lang-api/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementUpDownMover.java
platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementAtomNodeComponent.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java
platform/lang-impl/src/com/intellij/codeInsight/completion/actions/HippieWordCompletionHandler.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
platform/lang-impl/src/com/intellij/codeInsight/generation/actions/ImplementMethodsAction.java
platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java
platform/lang-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.form
platform/lang-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java
platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java
platform/lang-impl/src/com/intellij/ide/bookmarks/actions/GotoBookmarkActionBase.java
platform/lang-impl/src/com/intellij/ide/bookmarks/actions/NextBookmarkAction.java
platform/lang-impl/src/com/intellij/ide/bookmarks/actions/PreviousBookmarkAction.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java
platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
platform/platform-api/src/com/intellij/ide/util/treeView/SelectionRequest.java
platform/platform-api/src/com/intellij/ide/util/treeView/UpdaterTreeState.java
platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java
platform/platform-api/src/com/intellij/ui/RoundedLineBorder.java
platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java
platform/platform-impl/src/com/intellij/execution/DelayedDocumentWatcher.java
platform/platform-impl/src/com/intellij/ide/dnd/DnDManagerImpl.java
platform/platform-impl/src/com/intellij/notification/EventLog.java
platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/notification/LogModel.java
platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java
platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandler.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java
platform/platform-impl/src/com/intellij/ui/AppIcon.java
platform/platform-impl/src/com/intellij/ui/ListCellRendererWithRightAlignedComponent.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java
platform/platform-impl/src/org/jetbrains/io/WebServer.java
platform/platform-resources/src/META-INF/LangExtensions.xml
platform/platform-resources/src/META-INF/PlatformExtensions.xml
platform/platform-resources/src/idea/Keymap_Default.xml
platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java [moved from platform/platform-tests/testSrc/com/intellij/openapi/editor/RangeMarkerTest.java with 99% similarity]
platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java
platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java
platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java
platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DirectoryStorageData.java
platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java
platform/projectModel-impl/src/messages/ProjectBundle.properties
platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java
platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java
platform/util-rt/src/com/intellij/openapi/util/SystemInfoRt.java
platform/util/src/com/intellij/openapi/util/text/StringUtil.java
platform/util/src/com/intellij/util/Timed.java
platform/util/src/com/intellij/util/TimedReference.java
platform/util/src/com/intellij/util/containers/ContainerUtil.java
platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
plugins/InspectionGadgets/src/META-INF/plugin.xml
plugins/IntelliLang/src/META-INF/plugin.xml
plugins/IntentionPowerPak/build.xml [deleted file]
plugins/IntentionPowerPak/src/IPPIcon.png [deleted file]
plugins/IntentionPowerPak/src/IPPIconold.png [deleted file]
plugins/IntentionPowerPak/src/META-INF/plugin.xml
plugins/IntentionPowerPak/src/icons/IntentionPowerPackPluginIcons.java [deleted file]
plugins/android-designer/src/META-INF/plugin.xml
plugins/android/jps-plugin/android-jps-plugin.iml
plugins/android/resources/icons/AndroidIcons.java
plugins/android/resources/icons/androidLarge.png [deleted file]
plugins/android/resources/icons/ddms.png [deleted file]
plugins/android/resources/icons/navigate.png [deleted file]
plugins/android/src/META-INF/plugin.xml
plugins/ant/src/META-INF/plugin.xml
plugins/cvs/cvs-plugin/src/META-INF/plugin.xml
plugins/devkit/devkit.iml
plugins/devkit/resources/META-INF/plugin.xml
plugins/gettext/src/META-INF/plugin.xml
plugins/git4idea/git4idea.iml
plugins/git4idea/resources/icons/Git4ideaIcons.java
plugins/git4idea/resources/icons/allRevisions.png [deleted file]
plugins/git4idea/resources/icons/filter.png [deleted file]
plugins/git4idea/resources/icons/gitlogtree.png [deleted file]
plugins/git4idea/resources/icons/goto.png [deleted file]
plugins/git4idea/resources/icons/inclusion.png [deleted file]
plugins/git4idea/resources/icons/show.png [deleted file]
plugins/git4idea/resources/icons/tag.png [deleted file]
plugins/git4idea/resources/icons/user.png [deleted file]
plugins/github/src/META-INF/plugin.xml
plugins/gradle/gradle.iml
plugins/gradle/src/META-INF/plugin.xml
plugins/groovy/resources/icons/JetgroovyIcons.java
plugins/groovy/resources/icons/groovy/ant.png [deleted file]
plugins/groovy/resources/icons/groovy/gant_task.png [deleted file]
plugins/groovy/resources/icons/groovy/groovy_18x18.png [deleted file]
plugins/groovy/resources/icons/groovy/groovy_24x24.png [deleted file]
plugins/groovy/resources/icons/groovy/groovy_48x48.png [deleted file]
plugins/groovy/resources/icons/groovy/groovy_64x64.png [deleted file]
plugins/groovy/resources/icons/groovy/groovy_fileType.png [deleted file]
plugins/groovy/resources/icons/groovy/groovy_sdk.png [deleted file]
plugins/groovy/resources/icons/groovy/no_gant_sdk.png [deleted file]
plugins/groovy/resources/icons/groovy/no_groovy_sdk.png [deleted file]
plugins/groovy/resources/icons/groovy/static.png [deleted file]
plugins/groovy/src/META-INF/plugin.xml
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrVariableDeclaration.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationBase.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy
plugins/java-i18n/src/META-INF/plugin.xml
plugins/junit/src/META-INF/plugin.xml
plugins/junit/src/com/intellij/execution/junit/JUnitDependencyScopeSuggester.java [new file with mode: 0644]
plugins/maven/src/main/java/icons/MavenIcons.java
plugins/maven/src/main/resources/META-INF/plugin.xml
plugins/maven/src/main/resources/images/attachPlugin.png [deleted file]
plugins/maven/src/main/resources/images/detachPlugin.png [deleted file]
plugins/maven/src/main/resources/images/icon-robots.txt [new file with mode: 0644]
plugins/maven/src/main/resources/images/mavenSettings.png [deleted file]
plugins/maven/src/main/resources/images/modulesOpen.png [deleted file]
plugins/maven/src/main/resources/images/phasesOpen.png [deleted file]
plugins/maven/src/main/resources/images/profilesOpen.png [deleted file]
plugins/maven/src/main/resources/images/repository.png [deleted file]
plugins/maven/src/main/resources/images/updateDependencies.png [deleted file]
plugins/maven/src/main/resources/images/updateIndices.png [deleted file]
plugins/maven/src/main/resources/images/warning.png [deleted file]
plugins/properties/src/META-INF/plugin.xml
plugins/rearranger/rearranger.iml
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/AggregatedDictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/ProjectDictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/UserDictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/engine/BaseSpellChecker.java
plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/AcceptWordAsCorrect.java
plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java
plugins/spellchecker/src/icons/SpellcheckerIcons.java
plugins/spellchecker/src/icons/spellcheck.png [moved from plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/spellcheck.png with 100% similarity]
plugins/svn4idea/src/META-INF/plugin.xml
plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictState.java
plugins/swing-designer/src/META-INF/plugin.xml
plugins/tasks/tasks-core/src/META-INF/plugin.xml
plugins/tasks/tasks-core/src/icons/TasksCoreIcons.java
plugins/tasks/tasks-core/src/icons/navigate.png [deleted file]
plugins/tasks/tasks-core/src/icons/save.png [deleted file]
plugins/tasks/tasks-core/src/icons/web.png [deleted file]
plugins/testng/src/META-INF/plugin.xml
plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGDependencyScopeSuggester.java [new file with mode: 0644]
plugins/ui-designer/src/META-INF/plugin.xml
plugins/ui-designer/src/com/intellij/uiDesigner/icons/break.png [deleted file]
plugins/ui-designer/src/com/intellij/uiDesigner/icons/delete.png [deleted file]
plugins/ui-designer/src/com/intellij/uiDesigner/icons/grid.png [deleted file]
plugins/ui-designer/src/com/intellij/uiDesigner/icons/horizontal.png [deleted file]
plugins/ui-designer/src/com/intellij/uiDesigner/icons/vertical.png [deleted file]
plugins/ui-designer/src/icons/UIDesignerIcons.java
plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml
resources/src/META-INF/IdeaPlugin.xml
samples/actions/src/META-INF/plugin.xml
samples/comparingReferences/source/META-INF/plugin.xml
samples/conditionalOperatorConvertor/META-INF/plugin.xml
samples/plugin/src/META-INF/plugin.xml
samples/vfs/src/META-INF/plugin.xml
xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java
xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java
xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java
xml/impl/src/com/intellij/ide/browsers/BrowsersConfiguration.java
xml/impl/src/com/intellij/ide/browsers/impl/UrlOpenerImpl.java
xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java
xml/impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java
xml/impl/src/com/intellij/xml/XmlExtension.java
xml/impl/src/com/intellij/xml/impl/dtd/XmlNSDescriptorImpl.java
xml/tests/src/com/intellij/codeInsight/XmlDtdTest.java
xml/tests/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMoverTest.java
xml/tests/testData/mover/moveTag.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTag1.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTag1_afterDown.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTag1_afterUp.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTagWithEmptyLines.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTagWithEmptyLines_afterDown.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTagWithEmptyLines_afterUp.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTag_afterDown.xml [new file with mode: 0644]
xml/tests/testData/mover/moveTag_afterUp.xml [new file with mode: 0644]
xml/tests/testData/mover/multiLineTag.xml [new file with mode: 0644]
xml/tests/testData/mover/multiLineTag_afterDown.xml [new file with mode: 0644]
xml/tests/testData/mover/multiLineTag_afterUp.xml [new file with mode: 0644]
xml/tests/testData/mover/rootTag.xml [new file with mode: 0644]
xml/tests/testData/mover/rootTag1.xml [new file with mode: 0644]
xml/tests/testData/mover/singleTag.xml [new file with mode: 0644]
xml/tests/testData/mover/singleTag_afterUp.xml [new file with mode: 0644]
xml/tests/testData/xml/CorrectGeneratedDtdUpdate.xml

index 40642d8c2abc766527fa6d66b28fecff8bbca080..c11f25f8120aa262426d8f8ff414b8e76dc20a5c 100644 (file)
@@ -1,6 +1,6 @@
 <idea-plugin version="2">\r
 \r
-  <vendor>Alexey Efimov</vendor>\r
+  <vendor>JetBrains</vendor>\r
 \r
   <extensions defaultExtensionNs="com.intellij">\r
     <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>\r
index a1b1747ae286ae3c246df6dab66dfa73e55d5ac4..c467cd1e47ca13b9d16fb79ed61e2dff97fe9dfa 100644 (file)
@@ -32,10 +32,7 @@ import com.intellij.compiler.server.BuildManager;
 import com.intellij.compiler.server.DefaultMessageHandler;\r
 import com.intellij.diagnostic.IdeErrorsDialog;\r
 import com.intellij.diagnostic.PluginException;\r
-import com.intellij.openapi.application.ApplicationManager;\r
-import com.intellij.openapi.application.ModalityState;\r
-import com.intellij.openapi.application.Result;\r
-import com.intellij.openapi.application.WriteAction;\r
+import com.intellij.openapi.application.*;\r
 import com.intellij.openapi.compiler.*;\r
 import com.intellij.openapi.compiler.Compiler;\r
 import com.intellij.openapi.compiler.ex.CompileContextEx;\r
@@ -598,7 +595,11 @@ public class CompileDriver {
 \r
             final Collection<String> paths = fetchFiles(compileContext);\r
             final List<Module> modules = paths.isEmpty() && !isRebuild && !allProjectModulesAffected(compileContext)? Arrays.asList(compileContext.getCompileScope().getAffectedModules()) : Collections.<Module>emptyList();\r
-            final Set<Artifact> artifacts = ArtifactCompileScope.getArtifactsToBuild(myProject, compileContext.getCompileScope(), true);\r
+            final Set<Artifact> artifacts = new ReadAction<Set<Artifact>>() {\r
+              protected void run(final Result<Set<Artifact>> result) {\r
+                result.setResult(ArtifactCompileScope.getArtifactsToBuild(myProject, compileContext.getCompileScope(), true));\r
+              }\r
+            }.execute().getResultObject();\r
             final RequestFuture future = compileInExternalProcess(compileContext, modules, artifacts, paths, callback);\r
             if (future != null) {\r
               while (!future.waitFor(200L , TimeUnit.MILLISECONDS)) {\r
@@ -950,7 +951,7 @@ public class CompileDriver {
             outputsToRefresh.add(generated.getSecond());\r
           }\r
 \r
-          RefreshQueue.getInstance().refresh(false, true, null, VfsUtilCore.toVirtualFileArray(outputsToRefresh));\r
+          RefreshQueue.getInstance().refresh(false, true, null, outputsToRefresh);\r
           if (progressIndicator.isCanceled()) {\r
             return ExitStatus.CANCELLED;\r
           }\r
index e462c98e08bae655518522cafc8f0fd024b6d3e9..1417fa69a0e2a53a8f70c71980c90b364fb25bf8 100644 (file)
@@ -124,7 +124,7 @@ public class CompilerUtil {
       }
     }
     if (!filesToRefresh.isEmpty()) {
-      RefreshQueue.getInstance().refresh(false, true, null, VfsUtil.toVirtualFileArray(filesToRefresh));
+      RefreshQueue.getInstance().refresh(false, true, null, filesToRefresh);
     }
   }
 
index d86be2d6acb131febcf226ea34323f31d60663a8..26c0751abdae6814dd4f2366552bf72cff5485f0 100644 (file)
@@ -128,7 +128,7 @@ public class BuildManager implements ApplicationComponent{
 
   private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("build-manager");
   private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher();
-  private int myListenPort = -1;
+  private volatile int myListenPort = -1;
   private volatile CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings myGlobals;
 
   public BuildManager(final ProjectManager projectManager) {
@@ -146,11 +146,7 @@ public class BuildManager implements ApplicationComponent{
 
     projectManager.addProjectManagerListener(new ProjectWatcher());
     final MessageBusConnection conn = ApplicationManager.getApplication().getMessageBus().connect();
-    conn.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
-      @Override
-      public void before(@NotNull List<? extends VFileEvent> events) {
-      }
-
+    conn.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
       @Override
       public void after(@NotNull List<? extends VFileEvent> events) {
         if (shouldTriggerMake(events)) {
@@ -380,7 +376,11 @@ public class BuildManager implements ApplicationComponent{
     // ensure server is listening
     if (myListenPort < 0) {
       try {
-        myListenPort = startListening();
+        synchronized (this) {
+          if (myListenPort < 0) {
+            myListenPort = startListening();
+          }
+        }
       }
       catch (Exception e) {
         handler.handleFailure(sessionId, CmdlineProtoUtil.createFailure(e.getMessage(), null));
@@ -795,7 +795,7 @@ public class BuildManager implements ApplicationComponent{
   }
 
   private int startListening() throws Exception {
-    final ChannelFactory channelFactory = new NioServerSocketChannelFactory(myPooledThreadExecutor, myPooledThreadExecutor);
+    final ChannelFactory channelFactory = new NioServerSocketChannelFactory(myPooledThreadExecutor, myPooledThreadExecutor, 2);
     final SimpleChannelUpstreamHandler channelRegistrar = new SimpleChannelUpstreamHandler() {
       public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
         myAllOpenChannels.add(e.getChannel());
index 2aa991e0b1faf17cfd53518ac88cf1781488f076..4aeda0815f8ee9d7bedb947784f3efdc7a280ff9 100644 (file)
@@ -34,6 +34,7 @@ import com.intellij.openapi.roots.OrderEnumerator;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
@@ -348,8 +349,13 @@ public class ManifestFileUtil {
   }
 
   private static class MainClassFilter implements ClassFilter {
-    public boolean isAccepted(PsiClass aClass) {
-      return PsiMethodUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.hasMainMethod(aClass);
+    public boolean isAccepted(final PsiClass aClass) {
+      return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
+        @Override
+        public Boolean compute() {
+          return PsiMethodUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.hasMainMethod(aClass);
+        }
+      });
     }
   }
 }
index dbe88aa9f168aed24cb214c929301f8edde7ed7c..8c89bada270da40f3c4f3d9032314c1536caa926 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.debugger;
 
 import com.intellij.diagnostic.logging.LogFilesManager;
+import com.intellij.execution.configurations.RunProfile;
 import com.intellij.execution.ui.RunContentDescriptor;
 import com.intellij.openapi.actionSystem.DefaultActionGroup;
 import org.jetbrains.annotations.Nullable;
@@ -39,4 +40,7 @@ public interface DebugUIEnvironment {
   void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager);
 
   void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup);
+
+  @Nullable
+  RunProfile getRunProfile();
 }
index 41ba909b5283b8b242f4c3ef02ab110aff0e2ca7..66614159b2719907b6e6be2d7ec34696277b27f6 100644 (file)
@@ -118,4 +118,9 @@ public class DefaultDebugUIEnvironment implements DebugUIEnvironment {
     actionGroup.add(new CloseAction(myExecutor, content, myProject));
     actionGroup.add(new ContextHelpAction(myExecutor.getHelpId()));
   }
+
+  @Override
+  public RunProfile getRunProfile() {
+    return myRunProfile;
+  }
 }
index 34ed6ce5604e29afe55bbbac25aa521fd9db75eb..bb8f331d06c43f5f5d1dfe8afd7d851d36305a29 100644 (file)
@@ -35,6 +35,7 @@ import com.intellij.execution.DefaultExecutionResult;
 import com.intellij.execution.ExecutionException;
 import com.intellij.execution.ExecutionManager;
 import com.intellij.execution.ExecutionResult;
+import com.intellij.execution.configurations.RunProfile;
 import com.intellij.execution.executors.DefaultDebugExecutor;
 import com.intellij.execution.filters.ExceptionFilters;
 import com.intellij.execution.filters.Filter;
@@ -80,7 +81,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
   private final MyDebuggerStateManager myStateManager = new MyDebuggerStateManager();
 
   private final FramesPanel myFramesPanel;
-  private DebugUIEnvironment myEnvironment;
+  private DebugUIEnvironment myDebugUIEnvironment;
 
   private final ThreadsPanel myThreadsPanel;
   private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump";
@@ -255,7 +256,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
     }
     console.setActions(consoleActions, ActionPlaces.DEBUGGER_TOOLBAR, myConsole.getPreferredFocusableComponent());
 
-    myEnvironment.initLogs(myRunContentDescriptor, getLogManager());
+    myDebugUIEnvironment.initLogs(myRunContentDescriptor, getLogManager());
 
     DefaultActionGroup group = new DefaultActionGroup();
 
@@ -322,7 +323,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
 
     addActionToGroup(group, PinToolwindowTabAction.ACTION_NAME);
 
-    myEnvironment.initActions(myRunContentDescriptor, group);
+    myDebugUIEnvironment.initActions(myRunContentDescriptor, group);
 
     myUi.getOptions().setLeftToolbar(group, ActionPlaces.DEBUGGER_TOOLBAR);
 
@@ -373,7 +374,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
   }
 
   public String getSessionName() {
-    return myEnvironment.getEnvironment().getSessionName();
+    return myDebugUIEnvironment.getEnvironment().getSessionName();
   }
 
   public DebuggerStateManager getContextManager() {
@@ -416,10 +417,16 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
     }
   }
 
+  @Nullable
+  @Override
+  protected RunProfile getRunProfile() {
+    return myDebugUIEnvironment != null ? myDebugUIEnvironment.getRunProfile() : null;
+  }
+
   public RunContentDescriptor attachToSession(final DebuggerSession session, DebugUIEnvironment environment) throws ExecutionException {
     disposeSession();
     myDebuggerSession = session;
-    myEnvironment = environment;
+    myDebugUIEnvironment = environment;
 
     session.getContextManager().addListener(new DebuggerContextListener() {
       public void changeEvent(DebuggerContextImpl newContext, int event) {
index b3e1db2cbc1fbe881e78aada356d2c05639ad5d7..602b82583a84febea86169bbc052ad82f4da591e 100644 (file)
@@ -11,7 +11,6 @@
     <orderEntry type="module" module-name="execution-openapi" />
     <orderEntry type="module" module-name="java-runtime" />
     <orderEntry type="module" module-name="debugger-impl" />
-    <orderEntry type="library" name="JUnit4" level="project" />
     <orderEntry type="library" name="jgoodies-forms" level="project" />
     <orderEntry type="module" module-name="testRunner" exported="" />
     <orderEntry type="module" module-name="compiler-openapi" />
index 3ddddf466c231ca92055bcaebf873b9706c78bec..6401d8df6b1267507f6e1c182f64602ee073157f 100644 (file)
@@ -24,9 +24,9 @@ import com.intellij.execution.JavaExecutionUtil;
 import com.intellij.execution.Location;
 import com.intellij.execution.RunnerAndConfigurationSettings;
 import com.intellij.execution.actions.ConfigurationContext;
-import com.intellij.execution.junit.JUnitUtil;
 import com.intellij.execution.junit.JavaRuntimeConfigurationProducerBase;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.psi.JavaPsiFacade;
@@ -36,6 +36,7 @@ import com.intellij.psi.PsiManager;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.PsiClassUtil;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 public class AppletConfigurationProducer extends JavaRuntimeConfigurationProducerBase {
   private PsiClass myPsiClass;
@@ -60,7 +61,7 @@ public class AppletConfigurationProducer extends JavaRuntimeConfigurationProduce
     RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
     final AppletConfiguration configuration = (AppletConfiguration)settings.getConfiguration();
     configuration.MAIN_CLASS_NAME = JavaExecutionUtil.getRuntimeQualifiedName(myPsiClass);
-    configuration.setModule(new JUnitUtil.ModuleOfClass().convert(myPsiClass));
+    configuration.setModule(myPsiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(myPsiClass) : null);
     configuration.setName(configuration.getGeneratedName());
     return settings;
   }
@@ -70,6 +71,7 @@ public class AppletConfigurationProducer extends JavaRuntimeConfigurationProduce
   }
 
 
+  @Nullable
   private static PsiClass getAppletClass(PsiElement element, final PsiManager manager) {
     while (element != null) {
       if (element instanceof PsiClass) {
index 6c38b54e9d93c4c07c0be784d5ce65405ace248b..493f01137da4bbe43c1c07b4300ebcf0c812e20d 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.execution.*;
 import com.intellij.execution.junit2.info.MethodLocation;
 import com.intellij.execution.testframework.SourceScope;
 import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Condition;
@@ -30,18 +29,13 @@ import com.intellij.psi.search.searches.ClassInheritorsSearch;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiClassUtil;
 import com.intellij.util.Processor;
-import com.intellij.util.containers.Convertor;
-import junit.runner.BaseTestRunner;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.runners.Parameterized;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
 
 @SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
 public class JUnitUtil {
@@ -51,6 +45,12 @@ public class JUnitUtil {
   @NonNls private static final String TEST_ANNOTATION = "org.junit.Test";
   @NonNls public static final String RUN_WITH = "org.junit.runner.RunWith";
   @NonNls public static final String SUITE_METHOD_NAME = "suite";
+  private static final String BEFORE_ANNOTATION_NAME = "org.junit.Before";
+  private static final String AFTER_ANNOTATION_NAME = "org.junit.After";
+  private static final String PARAMETRIZED_PARAMETERS_ANNOTATION_NAME = "org.junit.runners.Parameterized.Parameters";
+  private static final String AFTER_CLASS_ANNOTATION_NAME = "org.junit.AfterClass";
+  private static final String BEFORE_CLASS_ANNOTATION_NAME = "org.junit.BeforeClass";
+  private static final String PARAMETERIZED_CLASS_NAME = "org.junit.runners.Parameterized";
 
   public static boolean isSuiteMethod(@NotNull PsiMethod psiMethod) {
     if (!psiMethod.hasModifierProperty(PsiModifier.PUBLIC)) return false;
@@ -78,7 +78,7 @@ public class JUnitUtil {
     if (psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) return false;
     if (AnnotationUtil.isAnnotated(aClass, RUN_WITH, true)) return true;
     if (psiMethod.getParameterList().getParametersCount() > 0) return false;
-    if (psiMethod.hasModifierProperty(PsiModifier.STATIC) && BaseTestRunner.SUITE_METHODNAME.equals(psiMethod.getName())) return false;
+    if (psiMethod.hasModifierProperty(PsiModifier.STATIC) && SUITE_METHOD_NAME.equals(psiMethod.getName())) return false;
     if (!psiMethod.getName().startsWith("test")) return false;
     PsiClass testCaseClass = getTestCaseClassOrNull(location);
     return testCaseClass != null && psiMethod.getContainingClass().isInheritor(testCaseClass, true);
@@ -91,15 +91,6 @@ public class JUnitUtil {
     return testCaseClass != null && aClass.isInheritor(testCaseClass, true);
   }
 
-  /**
-   *
-   * @param aClassLocation
-   * @return true if aClassLocation can be used as JUnit test class.
-   */
-  private static boolean isTestClass(final Location<? extends PsiClass> aClassLocation) {
-    return isTestClass(aClassLocation.getPsiElement());
-  }
-
   public static boolean isTestClass(final PsiClass psiClass) {
     return isTestClass(psiClass, true, true);
   }
@@ -151,7 +142,7 @@ public class JUnitUtil {
           final PsiAnnotationMemberValue value = attribute.getValue();
           if (value instanceof PsiClassObjectAccessExpression ) {
             final PsiTypeElement typeElement = ((PsiClassObjectAccessExpression)value).getOperand();
-            if (typeElement.getType().getCanonicalText().equals(Parameterized.class.getName())) {
+            if (typeElement.getType().getCanonicalText().equals(PARAMETERIZED_CLASS_NAME)) {
               return false;
             }
           }
@@ -223,13 +214,13 @@ public class JUnitUtil {
         return true;
       }
       if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) {
-        if (AnnotationUtil.isAnnotated(psiMethod, Arrays.asList(BeforeClass.class.getName(), AfterClass.class.getName(),
-                                                                Parameterized.Parameters.class.getName().replace('$', '.')))) {
+        if (AnnotationUtil.isAnnotated(psiMethod, Arrays.asList(BEFORE_CLASS_ANNOTATION_NAME, AFTER_CLASS_ANNOTATION_NAME,
+                                                                PARAMETRIZED_PARAMETERS_ANNOTATION_NAME))) {
           return true;
         }
       }
       else {
-        if (AnnotationUtil.isAnnotated(psiMethod, Arrays.asList(Before.class.getName(), After.class.getName()))) return true;
+        if (AnnotationUtil.isAnnotated(psiMethod, Arrays.asList(BEFORE_ANNOTATION_NAME, AFTER_ANNOTATION_NAME))) return true;
       }
     }
     return false;
@@ -298,55 +289,6 @@ public class JUnitUtil {
     return null;
   }
 
-  /**
-   * @param collection
-   * @param comparator returns 0 iff elemets are incomparable.
-   * @return maximum elements
-   */
-  public static <T> Collection<T> findMaximums(final Collection<T> collection, final Comparator<T> comparator) {
-    final ArrayList<T> maximums = new ArrayList<T>();
-    loop:
-    for (final T candidate : collection) {
-      for (final T element : collection) {
-        if (comparator.compare(element, candidate) > 0) continue loop;
-      }
-      maximums.add(candidate);
-    }
-    return maximums;
-  }
-
-  /*public static Map<Module, Collection<Module>> buildAllDependencies(final Project project) {
-    final Module[] modules = ModuleManager.getInstance(project).getSortedModules();
-    final HashMap<Module, Collection<Module>> lessers = new HashMap<Module, Collection<Module>>();
-    int prevProcessedCount = 0;
-    while (modules.length > lessers.size()) {
-      for (int i = 0; i < modules.length; i++) {
-        final Module module = modules[i];
-        if (lessers.containsKey(module)) continue;
-        final Module[] dependencies = ModuleRootManager.getInstance(module).getDependencies();
-        if (lessers.keySet().containsAll(Arrays.asList(dependencies))) {
-          final HashSet<Module> allDependencies = new HashSet<Module>();
-          for (int j = 0; j < dependencies.length; j++) {
-            final Module dependency = dependencies[j];
-            allDependencies.add(dependency);
-            allDependencies.addAll(lessers.get(dependency));
-          }
-          lessers.put(module, allDependencies);
-        }
-      }
-      if (lessers.size() == prevProcessedCount) return null;
-      prevProcessedCount = lessers.size();
-    }
-    return lessers;
-  }*/
-
-  public static class ModuleOfClass implements Convertor<PsiClass, Module> {
-    public Module convert(final PsiClass psiClass) {
-      if (psiClass == null || !psiClass.isValid()) return null;
-      return ModuleUtil.findModuleForPsiElement(psiClass);
-    }
-  }
-
   public static class NoJUnitException extends CantRunException {
     public NoJUnitException() {
       super(ExecutionBundle.message("no.junit.error.message"));
index 0a4a3e6334ee52d46de6cf9a77813e9536b26194..22dc207506897004aa721e0145ed70adbaf8d5c4 100644 (file)
@@ -23,8 +23,8 @@ import com.intellij.execution.configurations.JavaParameters;
 import com.intellij.execution.configurations.RunConfigurationModule;
 import com.intellij.execution.configurations.RuntimeConfigurationWarning;
 import com.intellij.execution.configurations.SimpleJavaParameters;
-import com.intellij.execution.junit.JUnitUtil;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.JavaSdk;
 import com.intellij.openapi.projectRoots.Sdk;
@@ -78,7 +78,7 @@ public class JavaParametersUtil {
     if (psiFile == null) throw CantRunException.classNotFound(mainClassName, module);
     final VirtualFile virtualFile = psiFile.getVirtualFile();
     if (virtualFile == null) throw CantRunException.classNotFound(mainClassName, module);
-    Module classModule = new JUnitUtil.ModuleOfClass().convert(psiClass);
+    Module classModule = psiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(psiClass) : null;
     if (classModule == null) classModule = module;
     ModuleFileIndex fileIndex = ModuleRootManager.getInstance(classModule).getFileIndex();
     if (fileIndex.isInSourceContent(virtualFile)) {
index 873ec94591897ef27f3c59a5bed3e822d39713f4..81a0fb658c5e88620b55a44cfb79ba9159254d11 100644 (file)
@@ -81,6 +81,7 @@ public class AddSupportForSingleFrameworkDialog extends DialogWrapper {
           myModifiableModelsProvider.disposeModuleModifiableModel(modifiableModel);
           return;
         }
+        return;
       }
       myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
 
index 3440da1ac19ded7332485d478b485236d2bee9ac..6e4ba5a0fa4859ac7d15a6a7a463b7a52e5f4e42 100644 (file)
@@ -56,6 +56,7 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
   private static final String ADD_MODULE_TITLE = IdeBundle.message("title.add.module");
   private static final String NEW_PROJECT_TITLE = IdeBundle.message("title.new.project");
   private final Project myCurrentProject;
+  private final ModulesProvider myModulesProvider;
   private WizardContext myWizardContext;
   private ProjectCreateModeStep myRootStep;
 
@@ -63,22 +64,24 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
   /**
    * @param project if null, the wizard will start creating new project, otherwise will add a new module to the existing project.
    */
-  public AddModuleWizard(final Project project, final ModulesProvider modulesProvider, @Nullable String defaultPath) {
+  public AddModuleWizard(final Project project, final @NotNull ModulesProvider modulesProvider, @Nullable String defaultPath) {
     super(project == null ? NEW_PROJECT_TITLE : ADD_MODULE_TITLE, project);
     myCurrentProject = project;
-    initModuleWizard(project, modulesProvider, defaultPath);
+    myModulesProvider = modulesProvider;
+    initModuleWizard(project, defaultPath);
   }
 
   /**
    * @param project if null, the wizard will start creating new project, otherwise will add a new module to the existing proj.
    */
-  public AddModuleWizard(Component parent, final Project project, ModulesProvider modulesProvider) {
+  public AddModuleWizard(Component parent, final Project project, @NotNull ModulesProvider modulesProvider) {
     super(project == null ? NEW_PROJECT_TITLE : ADD_MODULE_TITLE, parent);
     myCurrentProject = project;
-    initModuleWizard(project, modulesProvider, null);
+    myModulesProvider = modulesProvider;
+    initModuleWizard(project, null);
   }
 
-  private void initModuleWizard(final Project project, final ModulesProvider modulesProvider, @Nullable final String defaultPath) {
+  private void initModuleWizard(final Project project, @Nullable final String defaultPath) {
     myWizardContext = new WizardContext(project);
     if (defaultPath != null) {
       myWizardContext.setProjectFileDirectory(defaultPath);
@@ -101,7 +104,7 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
     };
     addStep(myRootStep);
     for (WizardMode mode : myRootStep.getModes()) {
-      appendSteps(mode.getSteps(myWizardContext, modulesProvider));
+      appendSteps(mode.getSteps(myWizardContext, myModulesProvider));
     }
     init();
   }
@@ -257,7 +260,7 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
 
   protected final int getNextStep(int step) {
     ModuleWizardStep nextStep = null;
-    final StepSequence stepSequence = getMode().getSteps(myWizardContext, null);
+    final StepSequence stepSequence = getMode().getSteps(myWizardContext, myModulesProvider);
     if (stepSequence != null) {
       if (myRootStep == mySteps.get(step)) {
         return mySteps.indexOf(stepSequence.getFirstStep());
@@ -272,7 +275,7 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
 
   protected final int getPreviousStep(final int step) {
     ModuleWizardStep previousStep = null;
-    final StepSequence stepSequence = getMode().getSteps(myWizardContext, null);
+    final StepSequence stepSequence = getMode().getSteps(myWizardContext, myModulesProvider);
     if (stepSequence != null) {
       previousStep = stepSequence.getPreviousStep(mySteps.get(step));
       while (previousStep != null && !previousStep.isStepVisible()) {
@@ -381,7 +384,7 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
 
       // Switch to the target mode if necessary.
       for (WizardMode mode : myRootStep.getModes()) {
-        StepSequence steps = mode.getSteps(myWizardContext, null);
+        StepSequence steps = mode.getSteps(myWizardContext, myModulesProvider);
         if (steps == null || !steps.getAllSteps().contains(step)) {
           continue;
         }
index e729aeadff4bb410fd2176157ef18dd855e63e1b..ff24e526f97e3382060726723a78af5fe1145a15 100644 (file)
@@ -52,7 +52,7 @@ public class CreateFromScratchMode extends WizardMode {
   }
 
   @Nullable
-  protected StepSequence createSteps(final WizardContext context, @Nullable final ModulesProvider modulesProvider) {
+  protected StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
     final StepSequence sequence = new StepSequence();
     sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, this));
     for (ModuleBuilder builder : ModuleBuilder.getAllBuilders()) {
index fbc9d9a364f42ebeeef497ace2e0ce6fef3c007d..89f5cd5bc0f12cd9c53b09319b9366812df0b85a 100644 (file)
@@ -56,7 +56,7 @@ public abstract class CreateFromSourcesMode extends WizardMode {
   }
 
   @Nullable
-  protected StepSequence createSteps(final WizardContext context, @Nullable final ModulesProvider modulesProvider) {
+  protected StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
     final ProjectFromSourcesBuilderImpl projectBuilder = new ProjectFromSourcesBuilderImpl(context, modulesProvider);
     myProjectBuilder = projectBuilder;
     
index b4663e796a289bba7af41853d60a839ec39a3fb1..6bac24df66cceffb5a1dc435dce9c3919f611e1e 100644 (file)
@@ -58,7 +58,7 @@ public class ImportImlMode extends WizardMode {
 
 
   @Nullable
-  protected StepSequence createSteps(final WizardContext context, @Nullable final ModulesProvider modulesProvider) {
+  protected StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
     return null;
   }
 
index e00eef20309c0603e62e366c37f792401ca91408..5d18b373837feaf69da091608efac7401c1cf37d 100644 (file)
@@ -59,7 +59,7 @@ public class ImportMode extends WizardMode {
   }
 
   @Nullable
-  protected StepSequence createSteps(final WizardContext context, @Nullable final ModulesProvider modulesProvider) {
+  protected StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
     final StepSequence stepSequence = new StepSequence();
     final ProjectImportProvider[] providers = Extensions.getExtensions(ProjectImportProvider.PROJECT_IMPORT_PROVIDER);
     if (providers.length == 1) {
index 7ed90ab7ef64dd42ab9ddb064fa71e522841eb08..3c4d1f763ad906307740172181681098c18268ae 100644 (file)
@@ -46,7 +46,7 @@ public abstract class WizardMode implements Disposable {
   public abstract boolean isAvailable(final WizardContext context);
 
   @Nullable
-  public StepSequence getSteps(final WizardContext context, @Nullable final ModulesProvider modulesProvider) {
+  public StepSequence getSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
     if (myStepSequence == null) {
       myStepSequence = createSteps(context, modulesProvider);
     }
@@ -54,7 +54,7 @@ public abstract class WizardMode implements Disposable {
   }
 
   @Nullable
-  protected abstract StepSequence createSteps(final WizardContext context, @Nullable final ModulesProvider modulesProvider);
+  protected abstract StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider);
 
   @Nullable
   public abstract ProjectBuilder getModuleBuilder();
index e5be355f73d67144e97cde5f3b0c6e2eb8ce72ea..c46b39917f98270b365798419361ad96dfdd0725 100644 (file)
@@ -8,6 +8,7 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStr
 import com.intellij.packaging.artifacts.Artifact;
 import com.intellij.packaging.elements.PackagingElement;
 import com.intellij.packaging.elements.PackagingElementFactory;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 
@@ -80,6 +81,12 @@ public class UsageInArtifact extends ProjectStructureElementUsage {
     return myOriginalArtifact.getArtifactType().getIcon();
   }
 
+  @Nullable
+  @Override
+  public String getPresentableLocationInElement() {
+    return "[" + myParentPath + "]";
+  }
+
   @Override
   public void removeSourceElement() {
     removeElement();
index 99f4b30df41e7bdfd7605bc4a47c7b6aadad286f..2cb5106f92ebf1a7462b9bd29c3a1d0bd780d94f 100644 (file)
 package com.intellij.openapi.roots.ui.configuration.classpath;
 
 import com.intellij.openapi.project.ProjectBundle;
-import com.intellij.openapi.roots.LibraryOrderEntry;
-import com.intellij.openapi.roots.ModifiableRootModel;
-import com.intellij.openapi.roots.OrderEntry;
-import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
+import com.intellij.openapi.roots.*;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.roots.libraries.LibraryType;
@@ -100,7 +97,8 @@ class AddLibraryDependencyAction extends AddItemPopupAction<Library> {
         if (item.equals(libraryOrderEntry.getLibrary())) {
           return ClasspathTableItem.createLibItem(libraryOrderEntry, myContext);
         }
-        if (item.getName().equals(libraryOrderEntry.getLibraryName())) {
+        String name = item.getName();
+        if (name != null && name.equals(libraryOrderEntry.getLibraryName())) {
           if (orderEntry.isValid()) {
             Messages.showErrorDialog(ProjectBundle.message("classpath.message.library.already.added", item.getName()),
                                      ProjectBundle.message("classpath.title.adding.dependency"));
@@ -113,13 +111,24 @@ class AddLibraryDependencyAction extends AddItemPopupAction<Library> {
       }
     }
     final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(item);
-    final LibraryTable table = item.getTable();
-    if (table instanceof LibraryTableBase) {
-      orderEntry.setScope(((LibraryTableBase)table).getDefaultDependencyScope());
+    DependencyScope defaultScope = getDefaultScope(item);
+    if (defaultScope != null) {
+      orderEntry.setScope(defaultScope);
     }
     return ClasspathTableItem.createLibItem(orderEntry, myContext);
   }
 
+  @Nullable
+  private static DependencyScope getDefaultScope(Library item) {
+    for (LibraryDependencyScopeSuggester suggester : LibraryDependencyScopeSuggester.EP_NAME.getExtensions()) {
+      DependencyScope scope = suggester.getDefaultDependencyScope(item);
+      if (scope != null) {
+        return scope;
+      }
+    }
+    return null;
+  }
+
   protected ClasspathElementChooser<Library> createChooser() {
     return new ExistingLibraryChooser();
   }
index acee2ff5e846aba20e48932a77cf7fae4fabb149..2457a6a14a3a2f0913ef306bcc89bcbdc3f029fa 100644 (file)
@@ -19,7 +19,9 @@ import com.intellij.CommonBundle;
 import com.intellij.analysis.AnalysisScope;
 import com.intellij.find.FindBundle;
 import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.impl.scopes.LibraryScope;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.projectRoots.Sdk;
@@ -83,6 +85,7 @@ import java.util.List;
 import java.util.Set;
 
 public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.classpath.ClasspathPanelImpl");
   private final JBTable myEntryTable;
   private final ClasspathTableModel myModel;
   private final EventDispatcher<OrderPanelListener> myListeners = EventDispatcher.create(OrderPanelListener.class);
@@ -716,11 +719,19 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
     @Override
     public void actionPerformed(AnActionEvent e) {
       final OrderEntry selectedEntry = getSelectedEntry();
-      assert selectedEntry instanceof ModuleOrderEntry;
-      final Module module = ((ModuleOrderEntry)selectedEntry).getModule();
-      assert module != null;
-      new AnalyzeDependenciesOnSpecifiedTargetHandler(module.getProject(), new AnalysisScope(myState.getRootModel().getModule()),
-                                                      GlobalSearchScope.moduleScope(module)) {
+      GlobalSearchScope targetScope;
+      if (selectedEntry instanceof ModuleOrderEntry) {
+        final Module module = ((ModuleOrderEntry)selectedEntry).getModule();
+        LOG.assertTrue(module != null);
+        targetScope = GlobalSearchScope.moduleScope(module);
+      }
+      else {
+        Library library = ((LibraryOrderEntry)selectedEntry).getLibrary();
+        LOG.assertTrue(library != null);
+        targetScope = new LibraryScope(getProject(), library);
+      }
+      new AnalyzeDependenciesOnSpecifiedTargetHandler(getProject(), new AnalysisScope(myState.getRootModel().getModule()),
+                                                      targetScope) {
         @Override
         protected boolean canStartInBackground() {
           return false;
@@ -752,7 +763,8 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
     @Override
     public void update(AnActionEvent e) {
       final OrderEntry entry = getSelectedEntry();
-      e.getPresentation().setVisible(entry instanceof ModuleOrderEntry && ((ModuleOrderEntry)entry).getModule() != null);
+      e.getPresentation().setVisible(entry instanceof ModuleOrderEntry && ((ModuleOrderEntry)entry).getModule() != null
+                                   || entry instanceof LibraryOrderEntry && ((LibraryOrderEntry)entry).getLibrary() != null);
     }
   }
 }
index 0898ac87fefc2c362e751ff29832d49c4260eb62..0c40e2ef9a64da57947c4eccb42d6a324f156ab0 100644 (file)
@@ -27,14 +27,16 @@ import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage;
 import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.ui.popup.PopupStep;
 import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.ui.ListCellRendererWithRightAlignedComponent;
 import com.intellij.ui.awt.RelativePoint;
+import com.intellij.ui.popup.list.ListPopupImpl;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
+import java.awt.*;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
@@ -76,26 +78,40 @@ public abstract class FindUsagesInProjectStructureActionBase extends AnAction im
         return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName());
       }
     });
-    
-    JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ProjectStructureElementUsage>(ProjectBundle.message("dependencies.used.in.popup.title"), usagesArray) {
-      @Override
-      public PopupStep onChosen(final ProjectStructureElementUsage selected, final boolean finalChoice) {
-        selected.getPlace().navigate();
-        return FINAL_CHOICE;
-      }
 
-      @NotNull
-      @Override
-      public String getTextFor(ProjectStructureElementUsage value) {
-        return value.getPresentableName();
-      }
+    BaseListPopupStep<ProjectStructureElementUsage> step =
+      new BaseListPopupStep<ProjectStructureElementUsage>(ProjectBundle.message("dependencies.used.in.popup.title"), usagesArray) {
+        @Override
+        public PopupStep onChosen(final ProjectStructureElementUsage selected, final boolean finalChoice) {
+          selected.getPlace().navigate();
+          return FINAL_CHOICE;
+        }
+
+        @NotNull
+        @Override
+        public String getTextFor(ProjectStructureElementUsage value) {
+          return value.getPresentableName();
+        }
 
+        @Override
+        public Icon getIconFor(ProjectStructureElementUsage selection) {
+          return selection.getIcon();
+        }
+      };
+    new ListPopupImpl(step) {
       @Override
-      public Icon getIconFor(ProjectStructureElementUsage selection) {
-        return selection.getIcon();
+      protected ListCellRenderer getListElementRenderer() {
+        return new ListCellRendererWithRightAlignedComponent<ProjectStructureElementUsage>() {
+          @Override
+          protected void customize(ProjectStructureElementUsage value) {
+            setLeftText(value.getPresentableName());
+            setIcon(value.getIcon());
+            setRightForeground(Color.GRAY);
+            setRightText(value.getPresentableLocationInElement());
+          }
+        };
       }
-
-    }).show(point);
+    }.show(point);
   }
 
   @Nullable
index 34899425c492d67dc8744d3dad0ebd5b7799fac7..a3242a73e08b6f9288dd28acea2f7cd1bf84ee71 100644 (file)
@@ -99,21 +99,24 @@ public class ModuleProjectStructureElement extends ProjectStructureElement {
     if (moduleEditor != null) {
       for (OrderEntry entry : moduleEditor.getOrderEntries()) {
         if (entry instanceof ModuleOrderEntry) {
-          final Module module = ((ModuleOrderEntry)entry).getModule();
+          ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry)entry;
+          final Module module = moduleOrderEntry.getModule();
           if (module != null) {
-            usages.add(new UsageInModuleClasspath(myContext, this, new ModuleProjectStructureElement(myContext, module)));
+            usages.add(new UsageInModuleClasspath(myContext, this, new ModuleProjectStructureElement(myContext, module), moduleOrderEntry.getScope()));
           }
         }
         else if (entry instanceof LibraryOrderEntry) {
-          final Library library = ((LibraryOrderEntry)entry).getLibrary();
+          LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
+          final Library library = libraryOrderEntry.getLibrary();
           if (library != null) {
-            usages.add(new UsageInModuleClasspath(myContext, this, new LibraryProjectStructureElement(myContext, library)));
+            usages.add(new UsageInModuleClasspath(myContext, this, new LibraryProjectStructureElement(myContext, library),
+                                                  libraryOrderEntry.getScope()));
           }
         }
         else if (entry instanceof JdkOrderEntry) {
           final Sdk jdk = ((JdkOrderEntry)entry).getJdk();
           if (jdk != null) {
-            usages.add(new UsageInModuleClasspath(myContext, this, new SdkProjectStructureElement(myContext, jdk)));
+            usages.add(new UsageInModuleClasspath(myContext, this, new SdkProjectStructureElement(myContext, jdk), null));
           }
         }
       }
index 0cc923e8f0c1933a80664ec2c72e8a50bf42023f..ad680b26ef3d79bdef1bd3a3892cd81447d4b214 100644 (file)
@@ -1,6 +1,6 @@
 package com.intellij.openapi.roots.ui.configuration.projectRoot.daemon;
 
-import com.intellij.openapi.roots.libraries.Library;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 
@@ -14,6 +14,11 @@ public abstract class ProjectStructureElementUsage {
 
   public abstract String getPresentableName();
 
+  @Nullable
+  public String getPresentableLocationInElement() {
+    return null;
+  }
+
   public abstract PlaceInProjectStructure getPlace();
 
   @Override
index db3f94366ac4d080b17a25f37338425852f38a6e..d2ee781b07ac9001c76ec0f13c874b47e192b031 100644 (file)
@@ -2,12 +2,15 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot.daemon;
 
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleType;
+import com.intellij.openapi.roots.DependencyScope;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.impl.OrderEntryUtil;
 import com.intellij.openapi.roots.ui.configuration.ModuleEditor;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
+import com.intellij.openapi.util.text.StringUtil;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 
@@ -17,12 +20,17 @@ import javax.swing.*;
 public class UsageInModuleClasspath extends ProjectStructureElementUsage {
   private final StructureConfigurableContext myContext;
   private final ModuleProjectStructureElement myContainingElement;
+  @Nullable private final DependencyScope myScope;
   private final ProjectStructureElement mySourceElement;
   private final Module myModule;
 
-  public UsageInModuleClasspath(@NotNull StructureConfigurableContext context, @NotNull ModuleProjectStructureElement containingElement, ProjectStructureElement sourceElement) {
+  public UsageInModuleClasspath(@NotNull StructureConfigurableContext context,
+                                @NotNull ModuleProjectStructureElement containingElement,
+                                ProjectStructureElement sourceElement,
+                                @Nullable DependencyScope scope) {
     myContext = context;
     myContainingElement = containingElement;
+    myScope = scope;
     myModule = containingElement.getModule();
     mySourceElement = sourceElement;
   }
@@ -76,6 +84,12 @@ public class UsageInModuleClasspath extends ProjectStructureElementUsage {
     }
   }
 
+  @Nullable
+  @Override
+  public String getPresentableLocationInElement() {
+    return myScope != null && myScope != DependencyScope.COMPILE ? "[" + StringUtil.decapitalize(myScope.getDisplayName()) + "]" : null;
+  }
+
   @Override
   public void replaceElement(final ProjectStructureElement newElement) {
     final ModuleEditor editor = myContext.getModulesConfigurator().getModuleEditor(myModule);
index 2e40838d208fecaae60f90091a88c4491b72b73e..e0aa9bbae79beba4c184e1270556731680d98e78 100644 (file)
@@ -336,33 +336,47 @@ public class ExpectedTypesProvider {
       final PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
       final PsiMethod scopeMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType);
       if (scopeMethod != null) {
-        visitMethodReturnType(scopeMethod, LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType));
+        visitMethodReturnType(scopeMethod, LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType), insertSemicolonAfter(lambdaExpression));
       }
     }
 
     @Override public void visitReturnStatement(PsiReturnStatement statement) {
       final PsiMethod method;
       final PsiType type;
+      final boolean tailTypeSemicolon;
       final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(statement, PsiLambdaExpression.class);
       if (lambdaExpression != null) {
         final PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
         method = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType);
         type = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType);
+        tailTypeSemicolon = insertSemicolonAfter(lambdaExpression);
       }
       else {
         method = PsiTreeUtil.getParentOfType(statement, PsiMethod.class);
         type = method != null ? method.getReturnType() : null;
+        tailTypeSemicolon = true;
       }
 
       if (method != null) {
-        visitMethodReturnType(method, type);
+        visitMethodReturnType(method, type, tailTypeSemicolon);
       }
     }
 
-    private void visitMethodReturnType(final PsiMethod scopeMethod, PsiType type) {
+    private static boolean insertSemicolonAfter(PsiLambdaExpression lambdaExpression) {
+       if (lambdaExpression.getBody() instanceof PsiCodeBlock) {
+         return true;
+       }
+      final PsiElement parent = lambdaExpression.getParent();
+      if (parent instanceof PsiExpressionList || parent instanceof PsiExpression) {
+        return false;
+      }
+      return true;
+    }
+
+    private void visitMethodReturnType(final PsiMethod scopeMethod, PsiType type, boolean tailTypeSemicolon) {
       if (type != null) {
         ExpectedTypeInfoImpl info = createInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type,
-                                                   TailType.SEMICOLON);
+                                                   tailTypeSemicolon ? TailType.SEMICOLON : TailType.NONE);
         if (PropertyUtil.isSimplePropertyAccessor(scopeMethod)) {
           info.expectedName = new NullableComputable<String>() {
             @Override
index 67ef4ee390b0041d90bb9bb27bb40d031686c71f..88737683c4b5d647ad8011c43733382e73b5b92b 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.ProjectTopics;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.icons.AllIcons;
 import com.intellij.ide.DataManager;
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.CommandProcessor;
@@ -60,6 +61,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.ui.popup.PopupStep;
 import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
 import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.*;
@@ -69,6 +71,7 @@ import com.intellij.psi.xml.XmlDocument;
 import com.intellij.psi.xml.XmlFile;
 import com.intellij.psi.xml.XmlTag;
 import com.intellij.util.*;
+import com.intellij.util.messages.MessageBus;
 import com.intellij.util.messages.MessageBusConnection;
 import com.intellij.util.ui.OptionsMessageDialog;
 import org.jetbrains.annotations.NonNls;
@@ -86,16 +89,35 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
   private static final Logger LOG = Logger.getInstance("#" + ExternalAnnotationsManagerImpl.class.getName());
 
   @NotNull private volatile ThreeState myHasAnyAnnotationsRoots = ThreeState.UNSURE;
+  private final MessageBus myBus;
 
   public ExternalAnnotationsManagerImpl(@NotNull final Project project, final PsiManager psiManager) {
     super(psiManager);
-    final MessageBusConnection connection = project.getMessageBus().connect(project);
+    myBus = project.getMessageBus();
+    final MessageBusConnection connection = myBus.connect(project);
     connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
       @Override
       public void rootsChanged(ModuleRootEvent event) {
         dropCache();
       }
     });
+
+    final MyVirtualFileListener fileListener = new MyVirtualFileListener();
+    VirtualFileManager.getInstance().addVirtualFileListener(fileListener);
+    Disposer.register(myPsiManager.getProject(), new Disposable() {
+      @Override
+      public void dispose() {
+        VirtualFileManager.getInstance().removeVirtualFileListener(fileListener);
+      }
+    });
+  }
+
+  private void notifyAfterAnnotationChanging(@NotNull PsiModifierListOwner owner, @NotNull String annotationFQName, boolean successful) {
+    myBus.syncPublisher(TOPIC).afterExternalAnnotationChanging(owner, annotationFQName, successful);
+  }
+
+  private void notifyChangedExternally() {
+    myBus.syncPublisher(TOPIC).externalAnnotationsChangedExternally();
   }
 
   @Override
@@ -127,10 +149,11 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
   public void annotateExternally(@NotNull final PsiModifierListOwner listOwner,
                                  @NotNull final String annotationFQName,
                                  @NotNull final PsiFile fromFile,
-                                 final PsiNameValuePair[] value) {
+                                 @Nullable final PsiNameValuePair[] value) {
     final Project project = myPsiManager.getProject();
     final PsiFile containingFile = listOwner.getContainingFile();
     if (!(containingFile instanceof PsiJavaFile)) {
+      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
       return;
     }
     final String packageName = ((PsiJavaFile)containingFile).getPackageName();
@@ -138,6 +161,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
     LOG.assertTrue(containingVirtualFile != null);
     final List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(containingVirtualFile);
     if (entries.isEmpty()) {
+      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
       return;
     }
     for (final OrderEntry entry : entries) {
@@ -150,6 +174,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
       }
       else {
         if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) {
+          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
           return;
         }
         SwingUtilities.invokeLater(new Runnable() {
@@ -179,30 +204,34 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
   }
 
   private void setupRootAndAnnotateExternally(@NotNull final OrderEntry entry,
-                                              @NotNull Project project,
+                                              @NotNull final Project project,
                                               @NotNull final PsiModifierListOwner listOwner,
                                               @NotNull final String annotationFQName,
                                               @NotNull final PsiFile fromFile,
                                               @NotNull final String packageName,
-                                              final PsiNameValuePair[] value) {
+                                              @Nullable final PsiNameValuePair[] value) {
     final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
     descriptor.setTitle(ProjectBundle.message("external.annotations.root.chooser.title", entry.getPresentableName()));
     descriptor.setDescription(ProjectBundle.message("external.annotations.root.chooser.description"));
-    final VirtualFile file = FileChooser.chooseFile(descriptor, project, null);
-    if (file == null) {
+    final VirtualFile newRoot = FileChooser.chooseFile(descriptor, project, null);
+    if (newRoot == null) {
+      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
       return;
     }
     new WriteCommandAction(project) {
       @Override
       protected void run(final Result result) throws Throwable {
-        appendChosenAnnotationsRoot(entry, file);
-        final List<XmlFile> xmlFiles = findExternalAnnotationsXmlFiles(listOwner);
-        if (xmlFiles != null) { //file already exists under appeared content root
-          if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFiles.get(0))) return;
-          annotateExternally(listOwner, annotationFQName, xmlFiles.get(0), fromFile, value);
+        appendChosenAnnotationsRoot(entry, newRoot);
+        XmlFile xmlFileInRoot = findXmlFileInRoot(findExternalAnnotationsXmlFiles(listOwner), newRoot);
+        if (xmlFileInRoot != null) { //file already exists under appeared content root
+          if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFileInRoot)) {
+            notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
+            return;
+          }
+          annotateExternally(listOwner, annotationFQName, xmlFileInRoot, fromFile, value);
         }
         else {
-          final XmlFile annotationsXml = createAnnotationsXml(file, packageName);
+          final XmlFile annotationsXml = createAnnotationsXml(newRoot, packageName);
           if (annotationsXml != null) {
             final List<PsiFile> createdFiles = new ArrayList<PsiFile>();
             createdFiles.add(annotationsXml);
@@ -217,15 +246,35 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
     }.execute();
   }
 
+  @Nullable
+  private static XmlFile findXmlFileInRoot(@Nullable List<XmlFile> xmlFiles, @NotNull VirtualFile root) {
+    if (xmlFiles != null) {
+      for (XmlFile xmlFile : xmlFiles) {
+        VirtualFile vf = xmlFile.getVirtualFile();
+        if (vf != null) {
+          if (VfsUtilCore.isAncestor(root, vf, false)) {
+            return xmlFile;
+          }
+        }
+      }
+    }
+    return null;
+  }
+
   private void chooseRootAndAnnotateExternally(@NotNull final PsiModifierListOwner listOwner,
                                                @NotNull final String annotationFQName,
                                                @NotNull final PsiFile fromFile,
                                                @NotNull final Project project,
                                                @NotNull final String packageName,
                                                @NotNull VirtualFile[] roots,
-                                               final PsiNameValuePair[] value) {
+                                               @Nullable final PsiNameValuePair[] value) {
     if (roots.length > 1) {
       JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<VirtualFile>("Annotation Roots", roots) {
+        @Override
+        public void canceled() {
+          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
+        }
+
         @Override
         public PopupStep onChosen(@NotNull final VirtualFile file, final boolean finalChoice) {
           annotateExternally(file, listOwner, project, packageName, annotationFQName, fromFile, value);
@@ -262,52 +311,54 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
 
   private void annotateExternally(@NotNull final VirtualFile root,
                                   @NotNull final PsiModifierListOwner listOwner,
-                                  @NotNull Project project,
+                                  @NotNull final Project project,
                                   @NotNull final String packageName,
                                   @NotNull final String annotationFQName,
                                   @NotNull final PsiFile fromFile,
-                                  final PsiNameValuePair[] value) {
-    final XmlFile[] annotationsXml = new XmlFile[1];
+                                  @Nullable final PsiNameValuePair[] value) {
     List<XmlFile> xmlFiles = findExternalAnnotationsXmlFiles(listOwner);
-    if (xmlFiles != null) {
-      for (XmlFile xmlFile : xmlFiles) {
-        final VirtualFile vXmlFile = xmlFile.getVirtualFile();
-        assert vXmlFile != null;
-        if (VfsUtilCore.isAncestor(root, vXmlFile, false)) {
-          annotationsXml[0] = xmlFile;
-          if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFile)) return;
-        }
-      }
-    } else {
-      xmlFiles = new ArrayList<XmlFile>();
+
+    final XmlFile existingXml = findXmlFileInRoot(xmlFiles, root);
+    if (existingXml != null && !CodeInsightUtilBase.preparePsiElementForWrite(existingXml)) {
+      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
+      return;
     }
 
-    final List<PsiFile> annotationFiles = new ArrayList<PsiFile>(xmlFiles);
+    final List<PsiFile> annotationFiles = xmlFiles == null ? new ArrayList<PsiFile>() : new ArrayList<PsiFile>(xmlFiles);
+
     new WriteCommandAction(project) {
       @Override
       protected void run(final Result result) throws Throwable {
-        if (annotationsXml[0] == null) {
-          annotationsXml[0] = createAnnotationsXml(root, packageName);
+        if (existingXml != null) {
+          annotateExternally(listOwner, annotationFQName, existingXml, fromFile, value);
         }
-        if (annotationsXml[0] != null) {
-          annotationFiles.add(annotationsXml[0]);
-          myExternalAnnotations.put(getFQN(packageName, fromFile), annotationFiles);
-          annotateExternally(listOwner, annotationFQName, annotationsXml[0], fromFile, value);
+        else {
+          XmlFile newXml = createAnnotationsXml(root, packageName);
+          if (newXml == null) {
+            notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
+          }
+          else {
+            annotationFiles.add(newXml);
+            myExternalAnnotations.put(getFQN(packageName, fromFile), annotationFiles);
+            annotateExternally(listOwner, annotationFQName, existingXml, fromFile, value);
+          }
         }
-      }
-    }.execute();
 
-    UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction() {
-      @Override
-      public void undo() throws UnexpectedUndoException {
-        dropCache();
-      }
+        UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction() {
+          @Override
+          public void undo() throws UnexpectedUndoException {
+            dropCache();
+            notifyChangedExternally();
+          }
 
-      @Override
-      public void redo() throws UnexpectedUndoException {
-        dropCache();
+          @Override
+          public void redo() throws UnexpectedUndoException {
+            dropCache();
+            notifyChangedExternally();
+          }
+        });
       }
-    });
+    }.execute();
   }
 
   @Override
@@ -315,11 +366,11 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
     return processExistingExternalAnnotations(listOwner, annotationFQN, new Processor<XmlTag>() {
       @Override
       public boolean process(XmlTag annotationTag) {
-        annotationTag.delete();
         PsiElement parent = annotationTag.getParent();
+        annotationTag.delete();
         if (parent instanceof XmlTag) {
           if (((XmlTag)parent).getSubTags().length == 0) {
-            annotationTag.delete();
+            parent.delete();
           }
         }
         return true;
@@ -330,7 +381,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
   @Override
   public boolean editExternalAnnotation(@NotNull PsiModifierListOwner listOwner,
                                         @NotNull final String annotationFQN,
-                                        @NotNull final PsiNameValuePair[] value) {
+                                        @Nullable final PsiNameValuePair[] value) {
     return processExistingExternalAnnotations(listOwner, annotationFQN, new Processor<XmlTag>() {
       @Override
       public boolean process(XmlTag annotationTag) {
@@ -346,6 +397,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
     try {
       final List<XmlFile> files = findExternalAnnotationsXmlFiles(listOwner);
       if (files == null) {
+        notifyAfterAnnotationChanging(listOwner, annotationFQN, false);
         return false;
       }
       boolean processedAnything = false;
@@ -368,7 +420,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
         final String externalName = getExternalName(listOwner, false);
         final String oldExternalName = getNormalizedExternalName(listOwner);
         for (final XmlTag tag : rootTag.getSubTags()) {
-          final String className = tag.getAttributeValue("name");
+          final String className = StringUtil.unescapeXml(tag.getAttributeValue("name"));
           if (!Comparing.strEqual(className, externalName) && !Comparing.strEqual(className, oldExternalName)) {
             continue;
           }
@@ -392,6 +444,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
           }
         }
       }
+      notifyAfterAnnotationChanging(listOwner, annotationFQN, processedAnything);
       return processedAnything;
     }
     finally {
@@ -490,8 +543,11 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
                                   @NotNull final String annotationFQName,
                                   @Nullable final XmlFile xmlFile,
                                   @NotNull final PsiFile codeUsageFile,
-                                  final PsiNameValuePair[] values) {
-    if (xmlFile == null) return;
+                                  @Nullable final PsiNameValuePair[] values) {
+    if (xmlFile == null) {
+      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
+      return;
+    }
     CommandProcessor.getInstance().executeCommand(myPsiManager.getProject(), new Runnable() {
       @Override
       public void run() {
@@ -511,6 +567,8 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
                   }
                   tag.add(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(
                     createAnnotationTag(annotationFQName, values)));
+                  commitChanges(xmlFile);
+                  notifyAfterAnnotationChanging(listOwner, annotationFQName, true);
                   return;
                 }
               }
@@ -522,9 +580,11 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
             }
           }
           commitChanges(xmlFile);
+          notifyAfterAnnotationChanging(listOwner, annotationFQName, true);
         }
         catch (IncorrectOperationException e) {
           LOG.error(e);
+          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
         }
         finally {
           dropCache();
@@ -546,7 +606,7 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
   @NotNull
   private static String createAnnotationTag(@NotNull String annotationFQName, @Nullable PsiNameValuePair[] values) {
     @NonNls String text;
-    if (values != null) {
+    if (values != null && values.length != 0) {
       text = "  <annotation name=\'" + annotationFQName + "\'>\n";
       text += StringUtil.join(values, new Function<PsiNameValuePair, String>() {
         @NonNls
@@ -687,4 +747,38 @@ public class ExternalAnnotationsManagerImpl extends BaseExternalAnnotationsManag
       return true;
     }
   }
+
+  private class MyVirtualFileListener extends VirtualFileAdapter {
+    private void processEvent(VirtualFileEvent event) {
+      if (event.isFromRefresh() && ANNOTATIONS_XML.equals(event.getFileName())) {
+        dropCache();
+        notifyChangedExternally();
+      }
+    }
+
+    @Override
+    public void contentsChanged(VirtualFileEvent event) {
+      processEvent(event);
+    }
+
+    @Override
+    public void fileCreated(VirtualFileEvent event) {
+      processEvent(event);
+    }
+
+    @Override
+    public void fileDeleted(VirtualFileEvent event) {
+      processEvent(event);
+    }
+
+    @Override
+    public void fileMoved(VirtualFileMoveEvent event) {
+      processEvent(event);
+    }
+
+    @Override
+    public void fileCopied(VirtualFileCopyEvent event) {
+      processEvent(event);
+    }
+  }
 }
index dead663710e724f923d3987807cefe1197b2ab6f..0c4f5329ecd29ec47ebae8be6baf051ea5cd7693 100644 (file)
@@ -70,7 +70,7 @@ public class JavaCompletionContributor extends CompletionContributor {
   static {
     ourCompletionData = new LinkedHashMap<LanguageLevel, JavaCompletionData>();
     ourCompletionData.put(LanguageLevel.JDK_1_8, new Java18CompletionData());
-    ourCompletionData.put(LanguageLevel.JDK_1_3, new Java15CompletionData());
+    ourCompletionData.put(LanguageLevel.JDK_1_5, new Java15CompletionData());
     ourCompletionData.put(LanguageLevel.JDK_1_3, new JavaCompletionData());
   }
 
index 57510cfc8f5c24d1efbf3baf781e01cd2464f05c..875d600e91f24e4e833fbe7938a60466efa7cd01 100644 (file)
@@ -210,8 +210,7 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
           ProgressManager.checkCanceled();
 
           final PsiMethod superMethod = pair.getFirst();
-          if (superMethod.isPhysical() && pair.getSecond().isPhysical() //groovy, scala
-              && methods.remove(superMethod)) {
+          if (methods.remove(superMethod)) {
             overridden.add(superMethod);
           }
           return !methods.isEmpty();
index 4118d62129e629ab2f7fa48ebaaf1f44d76de7c7..4cd483e4509ad266659329261c5e087f891d6591 100644 (file)
@@ -28,15 +28,15 @@ public class AddDefaultConstructorFix extends AddMethodFix {
   }
 
   public AddDefaultConstructorFix(PsiClass aClass, @PsiModifier.ModifierConstant final String modifier) {
-    super(generateConstructor(aClass, modifier), aClass);
+    super(generateConstructor(aClass.getName(), modifier), aClass);
     setText(QuickFixBundle.message("add.default.constructor.text", VisibilityUtil.toPresentableText(modifier), aClass.getName()));
   }
 
-  private static String generateConstructor(PsiClass aClass, @PsiModifier.ModifierConstant final String modifier) {
+  private static String generateConstructor(final String className, @PsiModifier.ModifierConstant final String modifier) {
     if (modifier == PsiModifier.PACKAGE_LOCAL) {
-      return aClass.getName() + "() {}";
+      return className + "() {}";
     }
-    return modifier + " " + aClass.getName() + "() {}";
+    return modifier + " " + className + "() {}";
   }
 
   @Override
index 352a3cc6a5cba9008cf2022e408b1a8e6b246695..92b9c8a6e93a373ae3a2f9df83f2832cf6791e58 100644 (file)
@@ -109,7 +109,7 @@ public class JavaCopyPasteReferenceProcessor extends CopyPasteReferenceProcessor
                                         PsiJavaCodeReferenceElement[] refs) {
     for (int i = 0; i < refs.length; i++) {
       PsiJavaCodeReferenceElement reference = refs[i];
-      if (reference == null) continue;
+      if (reference == null || !reference.isValid()) continue;
       try {
         PsiManager manager = reference.getManager();
         ReferenceTransferableData.ReferenceData refData = referenceData[i];
index 1b473a310e061b550e86aa176a6e04ce86312149..cd033cb95d442d07432c7a840353aa3bd49a7d7b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2012 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.
@@ -428,7 +428,10 @@ public class OverrideImplementUtil {
   public static PsiGenerationInfo<PsiMethod> createGenerationInfo(PsiMethod s, boolean mergeIfExists) {
     for (MethodImplementor implementor : getImplementors()) {
       final GenerationInfo info = implementor.createGenerationInfo(s, mergeIfExists);
-      if (info instanceof PsiGenerationInfo) return (PsiGenerationInfo<PsiMethod>)info;
+      if (info instanceof PsiGenerationInfo) {
+        @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) final PsiGenerationInfo<PsiMethod> psiGenerationInfo = (PsiGenerationInfo<PsiMethod>)info;
+        return psiGenerationInfo;
+      }
     }
     return new PsiGenerationInfo<PsiMethod>(s);
   }
@@ -523,9 +526,9 @@ public class OverrideImplementUtil {
   }
 
   public static void chooseAndOverrideOrImplementMethods(final Project project,
-                                                          final Editor editor,
-                                                          final PsiClass aClass,
-                                                          final boolean toImplement){
+                                                         final Editor editor,
+                                                         final PsiClass aClass,
+                                                         final boolean toImplement) {
     LOG.assertTrue(aClass.isValid());
     ApplicationManager.getApplication().assertReadAccessAllowed();
 
@@ -558,47 +561,43 @@ public class OverrideImplementUtil {
     final PsiMethodMember[] onlyPrimary = convertToMethodMembers(candidates);
     final PsiMethodMember[] all = ArrayUtil.mergeArrays(onlyPrimary, convertToMethodMembers(secondary));
 
-    final String toMerge = PropertiesComponent.getInstance(project).getValue(PROP_COMBINED_OVERRIDE_IMPLEMENT);
-    final Ref<Boolean> merge = Ref.create(!"false".equals(toMerge));
-
-    final boolean isAll = merge.get().booleanValue();
-    final MemberChooser<PsiMethodMember> chooser = new MemberChooser<PsiMethodMember>(isAll ? all : onlyPrimary, false, true, project,
-                                                                                      PsiUtil.isLanguageLevel5OrHigher(aClass)) {
-
-      @Override
-      protected void fillToolbarActions(DefaultActionGroup group) {
-        super.fillToolbarActions(group);
-        if (toImplement) return;
-
-        final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement",
-                                                          AllIcons.General.Show_to_implement) {
-          @Override
-          public boolean isSelected(AnActionEvent e) {
-            return merge.get().booleanValue();
-          }
+    final Ref<Boolean> merge = Ref.create(PropertiesComponent.getInstance(project).isTrueValue(PROP_COMBINED_OVERRIDE_IMPLEMENT));
+    final MemberChooser<PsiMethodMember> chooser =
+      new MemberChooser<PsiMethodMember>(merge.get() ? all : onlyPrimary, false, true, project, PsiUtil.isLanguageLevel5OrHigher(aClass)) {
+        @Override
+        protected void fillToolbarActions(DefaultActionGroup group) {
+          super.fillToolbarActions(group);
+          if (toImplement) return;
+
+          final ToggleAction mergeAction = new ToggleAction("Show methods to implement", "Show methods to implement",
+                                                            AllIcons.General.Show_to_implement) {
+            @Override
+            public boolean isSelected(AnActionEvent e) {
+              return merge.get().booleanValue();
+            }
 
-          @Override
-          public void setSelected(AnActionEvent e, boolean state) {
-            merge.set(state);
-            resetElements(state ? all : onlyPrimary);
-            setTitle(getChooserTitle(false, merge));
-          }
-        };
-        mergeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK)), myTree);
+            @Override
+            public void setSelected(AnActionEvent e, boolean state) {
+              merge.set(state);
+              resetElements(state ? all : onlyPrimary);
+              setTitle(getChooserTitle(false, merge));
+            }
+          };
+          mergeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK)), myTree);
 
-        Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("OverrideMethods");
-        mergeAction.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
+          Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("OverrideMethods");
+          mergeAction.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
 
-        group.add(mergeAction);
-      }
-    };
+          group.add(mergeAction);
+        }
+      };
     chooser.setTitle(getChooserTitle(toImplement, merge));
     registerHandlerForComplementaryAction(project, editor, aClass, toImplement, chooser);
 
     chooser.setCopyJavadocVisible(true);
 
     if (toImplement) {
-      chooser.selectElements(isAll ? all : onlyPrimary);
+      chooser.selectElements((boolean)merge.get() ? all : onlyPrimary);
     }
 
     if (ApplicationManager.getApplication().isUnitTestMode()) {
index 6b241e3080a35e9374b2b5561a1e4678a808d8ca..124636cb063f1a7ba02266504f4aff1f2d5d1c6c 100644 (file)
@@ -91,7 +91,7 @@ public class QuickFixFactoryImpl extends QuickFixFactory {
 
   @Override
   public LocalQuickFixAndIntentionActionOnPsiElement createAddConstructorFix(@NotNull PsiClass aClass, String modifier) {
-    return new AddDefaultConstructorFix(aClass, modifier);
+    return aClass.getName() != null ? new AddDefaultConstructorFix(aClass, modifier) : null;
   }
 
   @Override
index 6f6841b074c17eda9901f775f19bb548f10baf14..d340460bb645409eacbddf7dabf1bcf194ddf19a 100644 (file)
@@ -210,7 +210,7 @@ public class JavaQualifiedNameProvider implements QualifiedNameProvider {
                                                          : expression instanceof PsiReferenceExpression
                                                            ? (PsiReferenceExpression)expression
                                                            : null;
-      if (referenceExpression == null) {
+      if (referenceExpression == null || !referenceExpression.isValid()) {
         toInsert = fqn;
       }
       else if (!isReferencedTo(referenceExpression, targetElement)) {
diff --git a/java/java-impl/src/com/intellij/openapi/roots/LibraryDependencyScopeSuggester.java b/java/java-impl/src/com/intellij/openapi/roots/LibraryDependencyScopeSuggester.java
new file mode 100644 (file)
index 0000000..1cc0795
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.roots.libraries.Library;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public abstract class LibraryDependencyScopeSuggester {
+  public static final ExtensionPointName<LibraryDependencyScopeSuggester> EP_NAME = ExtensionPointName.create("com.intellij.library.dependencyScopeSuggester");
+
+  @Nullable
+  public abstract DependencyScope getDefaultDependencyScope(@NotNull Library library);
+}
index 2137a0c06318c998f7012c4f4bcce2c7662a9400..36f4a4948c7f9e241fa28d37403857e746739cab 100644 (file)
@@ -233,7 +233,10 @@ public class JavaArrangementVisitor extends JavaElementVisitor {
     }
     for (String modifier : PsiModifier.MODIFIERS) {
       if (modifierList.hasModifierProperty(modifier)) {
-        entry.addModifier(MODIFIERS.get(modifier));
+        ArrangementModifier arrangementModifier = MODIFIERS.get(modifier);
+        if (arrangementModifier != null) {
+          entry.addModifier(arrangementModifier);
+        }
       }
     }
     if (modifierList.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) {
index 1359bfb5028190a640d3094e27fdb4b401856fcd..1dfe910c13dceeb17a3031d2dab43e5bf47cb7fb 100644 (file)
@@ -316,7 +316,7 @@ public class ExtractMethodProcessor implements MatchProvider {
         if (myOutputVariable != null) {
           elements = ArrayUtil.append(myElements, myOutputVariable, PsiElement.class);
         }
-        if (myCodeFragmentMember != null && myReturnType == ((PsiMethod)myCodeFragmentMember).getReturnType()) {
+        if (myCodeFragmentMember instanceof PsiMethod && myReturnType == ((PsiMethod)myCodeFragmentMember).getReturnType()) {
           elements = ArrayUtil.append(myElements, ((PsiMethod)myCodeFragmentMember).getReturnTypeElement(), PsiElement.class);
         }
       }
index ac1ab26c57a5c5c573cb3c6880cf40565d52da42..fe1e30842e642c4db06200fc559f5ab1d163542f 100644 (file)
@@ -170,34 +170,7 @@ public class InlineConstantFieldProcessor extends BaseRefactoringProcessor {
   private void inlineExpressionUsage(PsiExpression expr,
                                      final PsiConstantEvaluationHelper evalHelper,
                                      PsiExpression initializer1) throws IncorrectOperationException {
-    while (expr.getParent() instanceof PsiArrayAccessExpression) {
-      PsiArrayAccessExpression arrayAccess = (PsiArrayAccessExpression)expr.getParent();
-      Object value = evalHelper.computeConstantExpression(arrayAccess.getIndexExpression());
-      if (value instanceof Integer) {
-        int intValue = ((Integer)value).intValue();
-        if (initializer1 instanceof PsiNewExpression) {
-          PsiExpression[] arrayInitializers = ((PsiNewExpression)initializer1).getArrayInitializer().getInitializers();
-          if (0 <= intValue && intValue < arrayInitializers.length) {
-            expr = (PsiExpression)expr.getParent();
-            initializer1 = normalize(arrayInitializers[intValue]);
-            continue;
-          }
-        }
-      }
-
-      break;
-    }
-
-    if (initializer1 instanceof PsiArrayInitializerExpression) {
-      final PsiType type = expr.getType();
-      if (type != null) {
-        initializer1 = (PsiExpression)initializer1.replace(
-          (PsiNewExpression)JavaPsiFacade.getInstance(expr.getProject()).getElementFactory()
-            .createExpressionFromText("new " + type.getCanonicalText() + initializer1.getText(), initializer1));
-      }
-    }
     myField.normalizeDeclaration();
-    ChangeContextUtil.encodeContextInfo(initializer1, true);
     if (expr instanceof PsiReferenceExpression) {
       PsiExpression qExpression = ((PsiReferenceExpression)expr).getQualifierExpression();
       if (qExpression != null) {
@@ -214,8 +187,8 @@ public class InlineConstantFieldProcessor extends BaseRefactoringProcessor {
         }
       }
     }
-    PsiElement element = expr.replace(initializer1);
-    ChangeContextUtil.decodeContextInfo(element, null, null);
+
+    InlineUtil.inlineVariable(myField, initializer1, (PsiJavaCodeReferenceElement)expr);
   }
 
   private static PsiExpression normalize(PsiExpression expression) {
index b2eb3a4618d95886a9963090c1fea30a4b6eca4b..75f9a4d40575e9a70e7baab6b49b7d1381674820 100644 (file)
@@ -86,19 +86,19 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
     }
 
     final PsiClass containingClass = PsiTreeUtil.getParentOfType(local, PsiClass.class);
-    final List<PsiClass> innerClassesWithUsages = Collections.synchronizedList(new ArrayList<PsiClass>());
+    final List<PsiElement> innerClassesWithUsages = Collections.synchronizedList(new ArrayList<PsiElement>());
     final List<PsiElement> innerClassUsages = Collections.synchronizedList(new ArrayList<PsiElement>());
     query.forEach(new Processor<PsiReference>() {
       public boolean process(final PsiReference psiReference) {
         final PsiElement element = psiReference.getElement();
-        PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
-        while (psiClass != containingClass && psiClass != null) {
-          final PsiClass parentPsiClass = PsiTreeUtil.getParentOfType(psiClass, PsiClass.class, true);
+        PsiElement innerClass = PsiTreeUtil.getParentOfType(element, PsiClass.class, PsiLambdaExpression.class);
+        while (innerClass != containingClass && innerClass != null) {
+          final PsiClass parentPsiClass = PsiTreeUtil.getParentOfType(innerClass, PsiClass.class, true);
           if (parentPsiClass == containingClass) {
-            innerClassesWithUsages.add(psiClass);
+            innerClassesWithUsages.add(innerClass);
             innerClassUsages.add(element);
           }
-          psiClass = parentPsiClass;
+          innerClass = parentPsiClass;
         }
         return true;
       }
index 15a8d9fd56a4ca3731780579cd1a435a8f54b274..08bdc4cf790d3a067824c8b8dec455681de0e3ef 100644 (file)
@@ -74,7 +74,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
   private final CodeStyleManager myCodeStyleManager;
   private final JavaCodeStyleManager myJavaCodeStyle;
 
-  private PsiBlockStatement[] myAddedBraces;
+  private PsiCodeBlock[] myAddedBraces;
   private final String myDescriptiveName;
   private Map<PsiField, PsiClassInitializer> myAddedClassInitializers;
   private PsiMethod myMethodCopy;
@@ -577,7 +577,9 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
     }
     ChangeContextUtil.decodeContextInfo(anchorParent, thisClass, thisAccessExpr);
 
-    if (methodCall.getParent() instanceof PsiExpressionStatement || tailCall == InlineUtil.TailCallType.Return) {
+    if (methodCall.getParent() instanceof PsiLambdaExpression) {
+      methodCall.delete();
+    } else if (methodCall.getParent() instanceof PsiExpressionStatement || tailCall == InlineUtil.TailCallType.Return) {
       methodCall.getParent().delete();
     }
     else {
@@ -1170,7 +1172,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
 
   private PsiReferenceExpression[] addBracesWhenNeeded(PsiReferenceExpression[] refs) throws IncorrectOperationException {
     ArrayList<PsiReferenceExpression> refsVector = new ArrayList<PsiReferenceExpression>();
-    ArrayList<PsiBlockStatement> addedBracesVector = new ArrayList<PsiBlockStatement>();
+    ArrayList<PsiCodeBlock> addedBracesVector = new ArrayList<PsiCodeBlock>();
     myAddedClassInitializers = new HashMap<PsiField, PsiClassInitializer>();
 
     for (PsiReferenceExpression ref : refs) {
@@ -1194,11 +1196,33 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
 
             PsiElement newStatement = blockStatement.getCodeBlock().getStatements()[0];
             addMarkedElements(refsVector, newStatement);
-            addedBracesVector.add(blockStatement);
+            addedBracesVector.add(blockStatement.getCodeBlock());
             continue RefLoop;
           }
           parent = parent.getParent();
         }
+        final PsiElement lambdaExpr = parentStatement.getParent();
+        if (lambdaExpr instanceof PsiLambdaExpression) {
+          final PsiLambdaExpression newLambdaExpr = (PsiLambdaExpression)myFactory.createExpressionFromText(
+            ((PsiLambdaExpression)lambdaExpr).getParameterList().getText() + " -> " + "{\n}", lambdaExpr);
+          final PsiStatement statementFromText;
+          if (LambdaUtil.getFunctionalInterfaceReturnType((PsiLambdaExpression)lambdaExpr) == PsiType.VOID ) {
+            statementFromText = myFactory.createStatementFromText("a;", lambdaExpr);
+            ((PsiExpressionStatement)statementFromText).getExpression().replace(parentStatement);
+          } else {
+            statementFromText = myFactory.createStatementFromText("return a;", lambdaExpr);
+            ((PsiReturnStatement)statementFromText).getReturnValue().replace(parentStatement);
+          }
+
+          newLambdaExpr.getBody().add(statementFromText);
+
+          final PsiCodeBlock body = (PsiCodeBlock)((PsiLambdaExpression)lambdaExpr.replace(newLambdaExpr)).getBody();
+          PsiElement newStatement = body.getStatements()[0];
+          addMarkedElements(refsVector, newStatement);
+          addedBracesVector.add(body);
+          continue;
+
+        }
       }
       else {
         final PsiField field = PsiTreeUtil.getParentOfType(ref, PsiField.class);
@@ -1236,7 +1260,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
       ref.putCopyableUserData(MARK_KEY, null);
     }
 
-    myAddedBraces = addedBracesVector.toArray(new PsiBlockStatement[addedBracesVector.size()]);
+    myAddedBraces = addedBracesVector.toArray(new PsiCodeBlock[addedBracesVector.size()]);
     return refsVector.toArray(new PsiReferenceExpression[refsVector.size()]);
   }
 
@@ -1296,10 +1320,27 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
   private void removeAddedBracesWhenPossible() throws IncorrectOperationException {
     if (myAddedBraces == null) return;
 
-    for (PsiBlockStatement blockStatement : myAddedBraces) {
-      PsiStatement[] statements = blockStatement.getCodeBlock().getStatements();
+    for (PsiCodeBlock codeBlock : myAddedBraces) {
+      PsiStatement[] statements = codeBlock.getStatements();
       if (statements.length == 1) {
-        blockStatement.replace(statements[0]);
+        final PsiElement codeBlockParent = codeBlock.getParent();
+        if (codeBlockParent instanceof PsiLambdaExpression) {
+          if (statements[0] instanceof PsiReturnStatement) {
+            final PsiExpression returnValue = ((PsiReturnStatement)statements[0]).getReturnValue();
+            if (returnValue != null) {
+              codeBlock.replace(returnValue);
+            }
+          } else if (statements[0] instanceof PsiExpressionStatement){
+            codeBlock.replace(((PsiExpressionStatement)statements[0]).getExpression());
+          }
+        }
+        else {
+          if (codeBlockParent instanceof PsiBlockStatement) {
+            codeBlockParent.replace(statements[0]);
+          } else {
+            codeBlock.replace(statements[0]);
+          }
+        }
       }
     }
 
index 640d596aaffc56edfd80f122414a6ceb7e78c4f8..1c2a7fe01dcf61417c4890b25413e1c67a118c62 100644 (file)
@@ -524,7 +524,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
 
     final PsiElement tempContainer = anchorStatement.getParent();
 
-    if (!(tempContainer instanceof PsiCodeBlock) && !isLoopOrIf(tempContainer)) {
+    if (!(tempContainer instanceof PsiCodeBlock) && !isLoopOrIf(tempContainer) && (tempContainer.getParent() instanceof PsiLambdaExpression)) {
       String message = RefactoringBundle.message("refactoring.is.not.supported.in.the.current.context", REFACTORING_NAME);
       showErrorMessage(project, editor, message);
       return false;
@@ -913,10 +913,11 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
 
   public static PsiStatement putStatementInLoopBody(PsiStatement declaration, PsiElement container, PsiElement finalAnchorStatement)
     throws IncorrectOperationException {
+    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(container.getProject()).getElementFactory();
     if(isLoopOrIf(container)) {
       PsiStatement loopBody = getLoopBody(container, finalAnchorStatement);
       PsiStatement loopBodyCopy = loopBody != null ? (PsiStatement) loopBody.copy() : null;
-      PsiBlockStatement blockStatement = (PsiBlockStatement)JavaPsiFacade.getInstance(container.getProject()).getElementFactory()
+      PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory
         .createStatementFromText("{}", null);
       blockStatement = (PsiBlockStatement) CodeStyleManager.getInstance(container.getProject()).reformat(blockStatement);
       final PsiElement prevSibling = loopBody.getPrevSibling();
@@ -931,6 +932,35 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
       declaration = (PsiStatement) codeBlock.add(declaration);
       JavaCodeStyleManager.getInstance(declaration.getProject()).shortenClassReferences(declaration);
       if (loopBodyCopy != null) codeBlock.add(loopBodyCopy);
+    } else if (container instanceof PsiLambdaExpression) {
+      final PsiLambdaExpression lambdaExpression = (PsiLambdaExpression)container;
+      final PsiElement lambdaExpressionBody = lambdaExpression.getBody();
+      LOG.assertTrue(lambdaExpressionBody != null);
+
+      final PsiLambdaExpression expressionFromText = (PsiLambdaExpression)elementFactory
+        .createExpressionFromText(lambdaExpression.getParameterList().getText() + " -> {}", lambdaExpression);
+      PsiCodeBlock newBody = (PsiCodeBlock)expressionFromText.getBody();
+      LOG.assertTrue(newBody != null);
+      newBody.add(declaration);
+
+      final PsiStatement lastBodyStatement;
+      if (LambdaUtil.getFunctionalInterfaceReturnType(lambdaExpression) == PsiType.VOID) {
+        lastBodyStatement = elementFactory.createStatementFromText("a;", lambdaExpression);
+        ((PsiExpressionStatement)lastBodyStatement).getExpression().replace(lambdaExpressionBody);
+      }
+      else {
+        lastBodyStatement = elementFactory.createStatementFromText("return a;", lambdaExpression);
+        final PsiExpression returnValue = ((PsiReturnStatement)lastBodyStatement).getReturnValue();
+        LOG.assertTrue(returnValue != null);
+        returnValue.replace(lambdaExpressionBody);
+      }
+      newBody.add(lastBodyStatement);
+
+      final PsiLambdaExpression copy = (PsiLambdaExpression)lambdaExpression.replace(expressionFromText);
+      newBody = (PsiCodeBlock)copy.getBody();
+      LOG.assertTrue(newBody != null);
+      declaration = newBody.getStatements()[0];
+      declaration = (PsiStatement)JavaCodeStyleManager.getInstance(declaration.getProject()).shortenClassReferences(declaration);
     }
     return declaration;
   }
index d734719ad376809606bc5d780d194e3e3cfb2316..9a31eceddb7effc667bee56c1a09bd3a5714c672 100644 (file)
@@ -292,6 +292,7 @@ public class RefactoringUtil {
     PsiElement parent = place;
     while (true) {
       if (parent instanceof PsiStatement) break;
+      if (parent instanceof PsiExpression && parent.getParent() instanceof PsiLambdaExpression) return parent;
       parent = parent.getParent();
       if (parent == null) return null;
     }
index 8061ad46bd74d7f501cce870d17944719eeec3f4..d59035dab13670c999e00efa8b4ea798809cf8e6 100644 (file)
@@ -317,6 +317,10 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
       myMethod = psiMethod;
     }
 
+    @Override
+    public void visitLambdaExpression(PsiLambdaExpression expression) {
+    }
+
     public void visitReturnStatement(PsiReturnStatement statement) {
       super.visitReturnStatement(statement);
 
diff --git a/java/java-psi-api/src/com/intellij/codeInsight/ExternalAnnotationsListener.java b/java/java-psi-api/src/com/intellij/codeInsight/ExternalAnnotationsListener.java
new file mode 100644 (file)
index 0000000..31fb73e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight;
+
+import com.intellij.psi.PsiModifierListOwner;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.EventListener;
+
+/**
+ * @author Evgeny Gerashchenko
+ * @since  27 Aug 2012
+ */
+public interface ExternalAnnotationsListener extends EventListener {
+  /**
+   * Invoked at the end of annotateExternally/editExternalAnnotation/deannotate work.
+   * It's invoked in both cases: either it was completed successfully or not.
+   *
+   * @param owner annotation owner
+   * @param annotationFQName annotation class FQ name
+   * @param successful if annotation modification was successful
+   */
+  void afterExternalAnnotationChanging(@NotNull PsiModifierListOwner owner, @NotNull String annotationFQName, boolean successful);
+
+  /**
+   * Invoked when external annotations files were modified
+   */
+  void externalAnnotationsChangedExternally();
+
+  abstract class Adapter implements ExternalAnnotationsListener {
+    @Override
+    public void afterExternalAnnotationChanging(@NotNull PsiModifierListOwner owner, @NotNull String annotationFQName, boolean successful) {
+    }
+
+    @Override
+    public void externalAnnotationsChangedExternally() {
+    }
+  }
+}
index 7499657221557f09047bd8ac9a3f6be3d1567cc9..3d28df354eeeae0fe5db40acd73e4851e8dfc971 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.NotNullLazyKey;
 import com.intellij.psi.*;
+import com.intellij.util.messages.Topic;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -33,6 +34,8 @@ import java.util.List;
 public abstract class ExternalAnnotationsManager {
   @NonNls public static final String ANNOTATIONS_XML = "annotations.xml";
 
+  public static final Topic<ExternalAnnotationsListener> TOPIC = Topic.create("external annotations", ExternalAnnotationsListener.class);
+
   public enum AnnotationPlace {
     IN_CODE,
     EXTERNAL,
@@ -48,6 +51,7 @@ public abstract class ExternalAnnotationsManager {
   @Nullable
   public abstract PsiAnnotation findExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
 
+  // Method used in Kotlin plugin
   public abstract boolean isExternalAnnotationWritable(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
 
   @Nullable
@@ -56,12 +60,13 @@ public abstract class ExternalAnnotationsManager {
   public abstract void annotateExternally(@NotNull PsiModifierListOwner listOwner,
                                           @NotNull String annotationFQName,
                                           @NotNull PsiFile fromFile,
-                                          PsiNameValuePair[] value);
+                                          @Nullable PsiNameValuePair[] value);
 
   public abstract boolean deannotate(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
 
+  // Method used in Kotlin plugin when it is necessary to leave external annotation, but modify its arguments
   public abstract boolean editExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN,
-                                                 @NotNull PsiNameValuePair[] value);
+                                                 @Nullable PsiNameValuePair[] value);
 
   public abstract AnnotationPlace chooseAnnotationsPlace(@NotNull PsiElement element);
 
index d27d77536a2ecedf76d263d1fea57ab5d0de8dd0..20f87a9b2841003ed1e7d37d682efd1e72e448b2 100644 (file)
@@ -85,7 +85,8 @@ public class LambdaUtil {
            context instanceof PsiReturnStatement ||
            context instanceof PsiExpressionList ||
            context instanceof PsiParenthesizedExpression ||
-           context instanceof PsiArrayInitializerExpression;
+           context instanceof PsiArrayInitializerExpression ||
+           context instanceof PsiConditionalExpression;
   }
 
   public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
index 521508fb70c7c28f26d7f5b04ca9f6f4ea5fc911..ed67e417757cdb83331e64ef2927c91dd3d73969 100644 (file)
@@ -102,53 +102,62 @@ public class ExceptionUtil {
       return classTypes;
     }
     else if (element instanceof PsiTryStatement) {
-      PsiTryStatement tryStatement = (PsiTryStatement)element;
-      final PsiCodeBlock tryBlock = tryStatement.getTryBlock();
-      List<PsiClassType> array = new ArrayList<PsiClassType>();
-      if (tryBlock != null) {
-        List<PsiClassType> exceptions = getThrownExceptions(tryBlock);
-        array.addAll(exceptions);
+      return getTryExceptions((PsiTryStatement)element);
+    }
+    return getThrownExceptions(element.getChildren());
+  }
+
+  private static List<PsiClassType> getTryExceptions(PsiTryStatement tryStatement) {
+    List<PsiClassType> array = new ArrayList<PsiClassType>();
+
+    PsiResourceList resourceList = tryStatement.getResourceList();
+    if (resourceList != null) {
+      for (PsiResourceVariable variable : resourceList.getResourceVariables()) {
+        array.addAll(getUnhandledCloserExceptions(variable, resourceList));
       }
+    }
 
-      PsiParameter[] parameters = tryStatement.getCatchBlockParameters();
-      for (PsiParameter parameter : parameters) {
-        PsiType exception = parameter.getType();
-        for (int j = array.size() - 1; j >= 0; j--) {
-          PsiClassType exception1 = array.get(j);
-          if (exception.isAssignableFrom(exception1)) {
-            array.remove(exception1);
-          }
+    PsiCodeBlock tryBlock = tryStatement.getTryBlock();
+    if (tryBlock != null) {
+      array.addAll(getThrownExceptions(tryBlock));
+    }
+
+    for (PsiParameter parameter : tryStatement.getCatchBlockParameters()) {
+      PsiType exception = parameter.getType();
+      for (int j = array.size() - 1; j >= 0; j--) {
+        PsiClassType exception1 = array.get(j);
+        if (exception.isAssignableFrom(exception1)) {
+          array.remove(exception1);
         }
       }
+    }
 
-      PsiCodeBlock[] catchBlocks = tryStatement.getCatchBlocks();
-      for (PsiCodeBlock catchBlock : catchBlocks) {
-        addExceptions(array, getThrownExceptions(catchBlock));
-      }
+    for (PsiCodeBlock catchBlock : tryStatement.getCatchBlocks()) {
+      addExceptions(array, getThrownExceptions(catchBlock));
+    }
 
-      PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
-      if (finallyBlock != null) {
-        // if finally block completes normally, exception not caught
-        // if finally block completes abruptly, exception gets lost
-        try {
-          ControlFlow flow = ControlFlowFactory.getInstance(finallyBlock.getProject()).getControlFlow(finallyBlock, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(), false);
-          int completionReasons = ControlFlowUtil.getCompletionReasons(flow, 0, flow.getSize());
-          List<PsiClassType> thrownExceptions = getThrownExceptions(finallyBlock);
-          if ((completionReasons & ControlFlowUtil.NORMAL_COMPLETION_REASON) == 0) {
-            array = new ArrayList<PsiClassType>(thrownExceptions);
-          }
-          else {
-            addExceptions(array, thrownExceptions);
-          }
+    PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
+    if (finallyBlock != null) {
+      // if finally block completes normally, exception not caught
+      // if finally block completes abruptly, exception gets lost
+      try {
+        ControlFlow flow = ControlFlowFactory
+          .getInstance(finallyBlock.getProject()).getControlFlow(finallyBlock, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(), false);
+        int completionReasons = ControlFlowUtil.getCompletionReasons(flow, 0, flow.getSize());
+        List<PsiClassType> thrownExceptions = getThrownExceptions(finallyBlock);
+        if ((completionReasons & ControlFlowUtil.NORMAL_COMPLETION_REASON) == 0) {
+          array = new ArrayList<PsiClassType>(thrownExceptions);
         }
-        catch (AnalysisCanceledException e) {
-          // incomplete code
+        else {
+          addExceptions(array, thrownExceptions);
         }
       }
-
-      return array;
+      catch (AnalysisCanceledException e) {
+        // incomplete code
+      }
     }
-    return getThrownExceptions(element.getChildren());
+
+    return array;
   }
 
   @NotNull
index bbaa5017f0368c3e78c8fc91416af455f33a6c4d..4fea2e0d79986705bb26466c08c072199b2519c8 100644 (file)
@@ -1449,6 +1449,15 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
   @Override
   public void visitLambdaExpression(PsiLambdaExpression expression) {
     startElement(expression);
+    final PsiElement body = expression.getBody();
+    if (body != null) {
+      List<PsiVariable> array = new ArrayList<PsiVariable>();
+      addUsedVariables(array, body);
+      for (PsiVariable var : array) {
+        ProgressIndicatorProvider.checkCanceled();
+        generateReadInstruction(var);
+      }
+    }
     finishElement(expression);
   }
 
index 9d69c8eed47bd25596684169ea39b9a1676a45e5..1177603fde19e2a98dded82b7017eea574120680 100644 (file)
@@ -383,7 +383,8 @@ public class ControlFlowUtil {
       if (parent instanceof PsiDirectory
           || parent instanceof PsiMethod
           || parent instanceof PsiField || parent instanceof PsiClassInitializer
-          || parent instanceof DummyHolder) {
+          || parent instanceof DummyHolder
+          || parent instanceof PsiLambdaExpression) {
         break;
       }
       codeFragment = parent;
index 9f1aeb5ad548b04b81d2e200892d9b95e079e028..cb5ada2f6f1af38ffd2187ce5a7e986365be3cce 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi.impl.source;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
@@ -30,6 +31,7 @@ import java.util.List;
  * @author max
  */
 public class PsiClassReferenceType extends PsiClassType {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiClassReferenceType");
   private final PsiJavaCodeReferenceElement myReference;
 
   public PsiClassReferenceType(@NotNull PsiJavaCodeReferenceElement reference, LanguageLevel languageLevel) {
@@ -137,6 +139,7 @@ public class PsiClassReferenceType extends PsiClassType {
   @Override
   @NotNull
   public ClassResolveResult resolveGenerics() {
+    LOG.assertTrue(isValid());
     final JavaResolveResult result = myReference.advancedResolve(false);
     return new DelegatingClassResolveResult(result);
   }
index 97ed77c7da9d9ff046ea124969a66d1649b617fb..c1fce0e27bc0f773c9ebf6700a96887222c3475f 100644 (file)
@@ -363,10 +363,11 @@ public class PsiScopesUtil {
     }
   }
 
-  private static boolean processQualifierType(final PsiType type,
+  private static boolean processQualifierType(@NotNull final PsiType type,
                                               final MethodsProcessor processor,
                                               PsiManager manager,
                                               PsiMethodCallExpression call) throws MethodProcessorSetupFailedException {
+    LOG.assertTrue(type.isValid());
     if (type instanceof PsiClassType) {
       JavaResolveResult qualifierResult = ((PsiClassType)type).resolveGenerics();
       return processQualifierResult(qualifierResult, processor, call);
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable-out.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable-out.java
new file mode 100644 (file)
index 0000000..446d58f
--- /dev/null
@@ -0,0 +1,5 @@
+class Test {
+  public void foo() {
+    Runnable r = () -> {notify();};
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInCodeBlocBodyInLocalVariable.java
new file mode 100644 (file)
index 0000000..fa6f209
--- /dev/null
@@ -0,0 +1,5 @@
+class Test {
+  public void foo() {
+    Runnable r = () -> {<caret>};
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList-out.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList-out.java
new file mode 100644 (file)
index 0000000..8b17af9
--- /dev/null
@@ -0,0 +1,5 @@
+class Test {
+  public void foo() {
+    new Thread(() -> notify());
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInExpressionList.java
new file mode 100644 (file)
index 0000000..7b403c0
--- /dev/null
@@ -0,0 +1,5 @@
+class Test {
+  public void foo() {
+    new Thread(() -> <caret>);
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable-out.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable-out.java
new file mode 100644 (file)
index 0000000..f6950c0
--- /dev/null
@@ -0,0 +1,5 @@
+class Test {
+  public void foo() {
+    Runnable r = () -> notify();
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java b/java/java-tests/testData/codeInsight/completion/smartType/SemicolonInExpressionBodyInLocalVariable.java
new file mode 100644 (file)
index 0000000..e41c2a1
--- /dev/null
@@ -0,0 +1,5 @@
+class Test {
+  public void foo() {
+    Runnable r = () -> <caret>
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/TryWithResourcesThrowsException-out.java b/java/java-tests/testData/codeInsight/completion/smartType/TryWithResourcesThrowsException-out.java
new file mode 100644 (file)
index 0000000..7b35479
--- /dev/null
@@ -0,0 +1,11 @@
+import java.io.FileInputStream;
+import java.io.IOException;
+
+class Test {
+  void foo() {
+    try {
+      try (FileInputStream in = new FileInputStream("adsf")) {
+      }
+    } catch (IOException <caret>) {}
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/TryWithResourcesThrowsException.java b/java/java-tests/testData/codeInsight/completion/smartType/TryWithResourcesThrowsException.java
new file mode 100644 (file)
index 0000000..3683c71
--- /dev/null
@@ -0,0 +1,10 @@
+import java.io.FileInputStream;
+
+class Test {
+  void foo() {
+    try {
+      try (FileInputStream in = new FileInputStream("adsf")) {
+      }
+    } catch (IO<caret>) {}
+  }
+}
\ No newline at end of file
index c0e01a9c2a63bf294a25e85953fc76032d39120b..4fd368c7b029d348b0500cd00e1201d0da334934 100644 (file)
@@ -15,4 +15,13 @@ class Test {
         I o = (I)(int x)-> { };
         return (int x) -> {};
     }
+}
+
+interface II {
+  boolean _(String s);
+}
+class Test1 {
+  void bar(boolean b){
+    II ik = b ? (s)-> true : (s)->false;
+  }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/VariableInitialization.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/VariableInitialization.java
new file mode 100644 (file)
index 0000000..f6a1f6b
--- /dev/null
@@ -0,0 +1,5 @@
+class Test1 {
+    {
+        Runnable r = () -> { <error descr="Variable 'r' might not have been initialized">r</error>.run(); };
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsAnnotateLibrary_after.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsAnnotateLibrary_after.xml
new file mode 100644 (file)
index 0000000..97d0dd5
--- /dev/null
@@ -0,0 +1,11 @@
+<root>
+  <item name='p.TestDeannotation java.lang.String get()'>
+    <annotation name='org.jetbrains.annotations.NotNull'/>
+  </item>
+  <item name='p.TestDeannotation1 java.lang.String get(java.lang.String) 0'>
+    <annotation name='org.jetbrains.annotations.NotNull'/>
+  </item>
+    <item name='p.Test java.lang.String get()'>
+        <annotation name='org.jetbrains.annotations.NotNull'/>
+    </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsDeannotation1_after.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsDeannotation1_after.xml
new file mode 100644 (file)
index 0000000..62fa98b
--- /dev/null
@@ -0,0 +1,5 @@
+<root>
+  <item name='p.TestDeannotation java.lang.String get()'>
+    <annotation name='org.jetbrains.annotations.NotNull'/>
+  </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsDeannotation_after.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/anno/p/annotationsDeannotation_after.xml
new file mode 100644 (file)
index 0000000..7b5c7f7
--- /dev/null
@@ -0,0 +1,5 @@
+<root>
+    <item name='p.TestDeannotation1 java.lang.String get(java.lang.String) 0'>
+    <annotation name='org.jetbrains.annotations.NotNull'/>
+  </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root1/multiRoot/annotations.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root1/multiRoot/annotations.xml
new file mode 100644 (file)
index 0000000..36aa8d8
--- /dev/null
@@ -0,0 +1,7 @@
+<root>
+  <item name='multiRoot.Test java.lang.String get(java.lang.String) 0'>
+    <annotation name='org.jetbrains.annotations.NotNull'>
+      <val name="value" val="&quot;foo&quot;"/>
+    </annotation>
+  </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root1/multiRoot/annotations_after.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root1/multiRoot/annotations_after.xml
new file mode 100644 (file)
index 0000000..f635a33
--- /dev/null
@@ -0,0 +1,7 @@
+<root>
+  <item name='multiRoot.Test java.lang.String get(java.lang.String) 0'>
+      <annotation name='org.jetbrains.annotations.NotNull'>
+          <val name="value" val="&quot;bar&quot;"/>
+      </annotation>
+  </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root2/multiRoot/annotations.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root2/multiRoot/annotations.xml
new file mode 100644 (file)
index 0000000..e497a6e
--- /dev/null
@@ -0,0 +1,7 @@
+<root>
+  <item name='multiRoot.Test java.lang.String get(java.lang.String)'>
+    <annotation name='org.jetbrains.annotations.Nullable'>
+      <val name="value" val="&quot;foo&quot;"/>
+    </annotation>
+  </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root2/multiRoot/annotations_after.xml b/java/java-tests/testData/codeInsight/externalAnnotations/content/annoMultiRoot/root2/multiRoot/annotations_after.xml
new file mode 100644 (file)
index 0000000..60e041c
--- /dev/null
@@ -0,0 +1,7 @@
+<root>
+  <item name='multiRoot.Test java.lang.String get(java.lang.String)'>
+      <annotation name='org.jetbrains.annotations.Nullable'>
+          <val name="value" val="&quot;bar&quot;"/>
+      </annotation>
+  </item>
+</root>
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/externalAnnotations/lib/multiRoot/Test.java b/java/java-tests/testData/codeInsight/externalAnnotations/lib/multiRoot/Test.java
new file mode 100644 (file)
index 0000000..e478fac
--- /dev/null
@@ -0,0 +1,7 @@
+package multiRoot;
+
+class Test {
+  String get(String param) {
+    return null;
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody.java
new file mode 100644 (file)
index 0000000..eba4ec1
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+  public void foo() {
+    Runnable r = () -> {
+      String hello = "hello";
+      <selection>System.out.println(hello);</selection>
+    };
+  }
+}
diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody_after.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody_after.java
new file mode 100644 (file)
index 0000000..b8f4191
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+  public void foo() {
+    Runnable r = () -> {
+      String hello = "hello";
+        newMethod(hello);
+    };
+  }
+
+    private void newMethod(String hello) {
+        System.out.println(hello);
+    }
+}
diff --git a/java/java-tests/testData/refactoring/inlineConstantField/CastWhenLambdaAsQualifier.java b/java/java-tests/testData/refactoring/inlineConstantField/CastWhenLambdaAsQualifier.java
new file mode 100644 (file)
index 0000000..5be80c8
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+  Runnable r = () -> {};
+  void foo() {
+    <caret>r.run();
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineConstantField/CastWhenLambdaAsQualifier.java.after b/java/java-tests/testData/refactoring/inlineConstantField/CastWhenLambdaAsQualifier.java.after
new file mode 100644 (file)
index 0000000..15ba6fd
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+    void foo() {
+    ((Runnable) () -> {
+    }).run();
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineLocal/LocalVarInsideLambdaBody.java b/java/java-tests/testData/refactoring/inlineLocal/LocalVarInsideLambdaBody.java
new file mode 100644 (file)
index 0000000..550a93f
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+public class Test2 {
+  {
+    final String p = "hello";
+    Runnable r = () -> {System.out.println(<caret>p);};
+    System.out.println(p);
+  }
+}
+
diff --git a/java/java-tests/testData/refactoring/inlineLocal/LocalVarInsideLambdaBody.java.after b/java/java-tests/testData/refactoring/inlineLocal/LocalVarInsideLambdaBody.java.after
new file mode 100644 (file)
index 0000000..e941dd3
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+public class Test2 {
+  {
+      Runnable r = () -> {System.out.println("hello");};
+    System.out.println("hello");
+  }
+}
+
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleOneLine.java b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleOneLine.java
new file mode 100644 (file)
index 0000000..4e43186
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+import java.lang.Comparable;
+
+class Test {
+     private int bar() {
+       return 42;
+     }
+     public void foo() {
+         Comparable<String> c = (o) -> ba<caret>r();
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleOneLine.java.after b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleOneLine.java.after
new file mode 100644 (file)
index 0000000..a39e950
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+import java.lang.Comparable;
+
+class Test {
+     private int bar() {
+       return 42;
+     }
+     public void foo() {
+         Comparable<String> c = (o) -> 42;
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleToBlock.java b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleToBlock.java
new file mode 100644 (file)
index 0000000..abe9d74
--- /dev/null
@@ -0,0 +1,27 @@
+import java.lang.Comparable;
+
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+     private int bar() {
+       System.out.println("");
+       return 42;
+     }
+     public void foo() {
+         Comparable<String> c = (o) -> ba<caret>r();
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleToBlock.java.after b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaValueCompatibleToBlock.java.after
new file mode 100644 (file)
index 0000000..c44932d
--- /dev/null
@@ -0,0 +1,30 @@
+import java.lang.Comparable;
+
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+     private int bar() {
+       System.out.println("");
+       return 42;
+     }
+     public void foo() {
+         Comparable<String> c = (o) -> {
+             System.out.println("");
+             return 42;
+         };
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleOneLine.java b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleOneLine.java
new file mode 100644 (file)
index 0000000..5199637
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+     private void bar() {
+       System.out.println("");
+     }
+     public void foo() {
+         Runnable r = () -> ba<caret>r();
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleOneLine.java.after b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleOneLine.java.after
new file mode 100644 (file)
index 0000000..c69cb20
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+     private void bar() {
+       System.out.println("");
+     }
+     public void foo() {
+         Runnable r = () -> System.out.println("");
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleToBlock.java b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleToBlock.java
new file mode 100644 (file)
index 0000000..059ce33
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+     private void bar() {
+       System.out.println("");
+       System.out.println("");
+     }
+     public void foo() {
+         Runnable r = () -> ba<caret>r();
+     }
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleToBlock.java.after b/java/java-tests/testData/refactoring/inlineMethod/OneLineLambdaVoidCompatibleToBlock.java.after
new file mode 100644 (file)
index 0000000..3827120
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Test {
+     private void bar() {
+       System.out.println("");
+       System.out.println("");
+     }
+     public void foo() {
+         Runnable r = () -> {
+             System.out.println("");
+             System.out.println("");
+         };
+     }
+}
diff --git a/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaValueCompatible.after.java b/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaValueCompatible.after.java
new file mode 100644 (file)
index 0000000..a4dbe9c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Foo {  
+    void test() {
+        Comparable<String> java = o -> {
+            int c = o.length();
+            return c;
+        };
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaValueCompatible.java b/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaValueCompatible.java
new file mode 100644 (file)
index 0000000..104e522
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+class Foo {  
+    void test() {
+        Comparable<String> java = o -> <selection>o.length()</selection>;
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaVoidCompatible.after.java b/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaVoidCompatible.after.java
new file mode 100644 (file)
index 0000000..33cf47d
--- /dev/null
@@ -0,0 +1,8 @@
+class Foo {  
+    void test() {
+        Runnable java = () -> {
+            String c = "";
+            System.out.println(c);
+        };
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaVoidCompatible.java b/java/java-tests/testData/refactoring/introduceVariable/OneLineLambdaVoidCompatible.java
new file mode 100644 (file)
index 0000000..1905f6a
--- /dev/null
@@ -0,0 +1,5 @@
+class Foo {  
+    void test() {
+        Runnable java = () -> System.out.println(<selection>""</selection>);
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java
new file mode 100644 (file)
index 0000000..f74dbb9
--- /dev/null
@@ -0,0 +1,21 @@
+class Test {
+    Wrapper foo() {
+    return new Wrapper((o) -> {
+        return 0;
+    });
+  }
+
+    public class Wrapper {
+        private final Comparable<String> value;
+
+        public Wrapper(Comparable<String> value) {
+            this.value = value;
+        }
+
+
+        public Comparable<String> getValue() {
+            return value;
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java
new file mode 100644 (file)
index 0000000..bbc57c1
--- /dev/null
@@ -0,0 +1,7 @@
+class Test {
+  Comparable<String> foo() {
+    return (o) -> {
+      return 0;
+    };
+  }
+}
\ No newline at end of file
index 7d86c711b0e5166d5f6adcce635bdca41700c0ce..0af361a24e5afb22083853adae7818d1da8766b6 100644 (file)
@@ -4,12 +4,14 @@
  */
 package com.intellij.codeInsight;
 
+import com.intellij.codeInsight.intention.AddAnnotationFix;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.impl.DeannotateIntentionAction;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.editor.CaretModel;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.module.Module;
@@ -20,7 +22,12 @@ import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.OrderRootType;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
+import com.intellij.openapi.util.Trinity;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.io.StreamUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.testFramework.IdeaTestCase;
@@ -28,13 +35,21 @@ import com.intellij.testFramework.PsiTestUtil;
 import com.intellij.testFramework.UsefulTestCase;
 import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
 import com.intellij.testFramework.fixtures.*;
+import com.intellij.util.messages.MessageBusConnection;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 public class AddAnnotationFixTest extends UsefulTestCase {
   private CodeInsightTestFixture myFixture;
   private Module myModule;
+  private Project myProject;
+  private boolean myExpectedEventWasProduced = false;
+  private boolean myUnexpectedEventWasProduced = false;
+  private MessageBusConnection myBusConnection = null;
 
   public AddAnnotationFixTest() {
     IdeaTestCase.initPlatformPrefix();
@@ -53,6 +68,7 @@ public class AddAnnotationFixTest extends UsefulTestCase {
 
     myFixture.setUp();
     myModule = builder.getFixture().getModule();
+    myProject = myFixture.getProject();
   }
 
   @Override
@@ -61,9 +77,15 @@ public class AddAnnotationFixTest extends UsefulTestCase {
     myFixture.tearDown();
     myFixture = null;
     myModule = null;
+    myProject = null;
+    assertNull(myBusConnection);
   }
 
-  protected void addLibrary() {
+  private void addDefaultLibrary() {
+    addLibrary("/content/anno");
+  }
+
+  private void addLibrary(final @NotNull String... annotationsDirs) {
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       @Override
       public void run() {
@@ -73,29 +95,103 @@ public class AddAnnotationFixTest extends UsefulTestCase {
 
         final Library.ModifiableModel libraryModel = library.getModifiableModel();
         libraryModel.addRoot(VfsUtil.pathToUrl(myFixture.getTempDirPath() + "/lib"), OrderRootType.SOURCES);
-        libraryModel.addRoot(VfsUtil.pathToUrl(myFixture.getTempDirPath() + "/content/anno"), AnnotationOrderRootType.getInstance());
+        for (String annotationsDir : annotationsDirs) {
+          libraryModel.addRoot(VfsUtil.pathToUrl(myFixture.getTempDirPath() + annotationsDir), AnnotationOrderRootType.getInstance());
+        }
         libraryModel.commit();
         model.commit();
       }
     });
   }
 
+  @NotNull
+  private PsiModifierListOwner getOwner() {
+    CaretModel caretModel = myFixture.getEditor().getCaretModel();
+    int position = caretModel.getOffset();
+    PsiElement element = myFixture.getFile().findElementAt(position);
+    assert element != null;
+    PsiModifierListOwner container = AddAnnotationFix.getContainer(element);
+    assert container != null;
+    return container;
+  }
+
+  private void startListening(@NotNull final List<Trinity<PsiModifierListOwner, String, Boolean>> expectedSequence) {
+    myBusConnection = myProject.getMessageBus().connect();
+    myBusConnection.subscribe(ExternalAnnotationsManager.TOPIC, new DefaultAnnotationsListener() {
+      private int index = 0;
+
+      @Override
+      public void afterExternalAnnotationChanging(@NotNull PsiModifierListOwner owner, @NotNull String annotationFQName,
+                                                  boolean successful) {
+        if (index < expectedSequence.size() && expectedSequence.get(index).first == owner
+            && expectedSequence.get(index).second.equals(annotationFQName) && expectedSequence.get(index).third == successful) {
+          index++;
+          myExpectedEventWasProduced = true;
+        }
+        else {
+          super.afterExternalAnnotationChanging(owner, annotationFQName, successful);
+        }
+      }
+    });
+  }
+
+  private void startListening(@NotNull final PsiModifierListOwner expectedOwner, @NotNull final String expectedAnnotationFQName,
+                              final boolean expectedSuccessful) {
+    startListening(Arrays.asList(Trinity.create(expectedOwner, expectedAnnotationFQName, expectedSuccessful)));
+  }
+
+  private void startListeningForExternalChanges() {
+    myBusConnection = myProject.getMessageBus().connect();
+    myBusConnection.subscribe(ExternalAnnotationsManager.TOPIC, new DefaultAnnotationsListener() {
+      private boolean notifiedOnce;
+
+      @Override
+      public void externalAnnotationsChangedExternally() {
+        if (!notifiedOnce) {
+          myExpectedEventWasProduced = true;
+          notifiedOnce = true;
+        }
+        else {
+          super.externalAnnotationsChangedExternally();
+        }
+      }
+    });
+  }
+
+  private void stopListeningAndCheckEvents() {
+    myBusConnection.disconnect();
+    myBusConnection = null;
+
+    assertTrue(myExpectedEventWasProduced);
+    assertFalse(myUnexpectedEventWasProduced);
+
+    myExpectedEventWasProduced = false;
+    myUnexpectedEventWasProduced = false;
+  }
+
   public void testAnnotateLibrary() throws Throwable {
 
-    addLibrary();
+    addDefaultLibrary();
     myFixture.configureByFiles("lib/p/TestPrimitive.java", "content/anno/p/annotations.xml");
     myFixture.configureByFiles("lib/p/Test.java");
-    final Project project = myFixture.getProject();
     final PsiFile file = myFixture.getFile();
     final Editor editor = myFixture.getEditor();
 
     final IntentionAction fix = myFixture.findSingleIntention("Annotate method 'get' as @NotNull");
-    assertTrue(fix.isAvailable(project, editor, file));
-
-    new WriteCommandAction(project){
+    assertTrue(fix.isAvailable(myProject, editor, file));
+
+    // expecting other @Nullable annotations to be removed, and default @NotNull to be added
+    List<Trinity<PsiModifierListOwner, String, Boolean>> expectedSequence
+      = new ArrayList<Trinity<PsiModifierListOwner, String, Boolean>>();
+    for (String notNull : NullableNotNullManager.getInstance(myProject).getNullables()) {
+      expectedSequence.add(Trinity.create(getOwner(), notNull, false));
+    }
+    expectedSequence.add(Trinity.create(getOwner(), AnnotationUtil.NOT_NULL, true));
+    startListening(expectedSequence);
+    new WriteCommandAction(myProject){
       @Override
       protected void run(final Result result) throws Throwable {
-        fix.invoke(project, editor, file);
+        fix.invoke(myProject, editor, file);
       }
     }.execute();
 
@@ -105,7 +201,10 @@ public class AddAnnotationFixTest extends UsefulTestCase {
     assertNotNull(psiElement);
     final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(psiElement, PsiModifierListOwner.class);
     assertNotNull(listOwner);
-    assertNotNull(ExternalAnnotationsManager.getInstance(project).findExternalAnnotation(listOwner, AnnotationUtil.NOT_NULL));
+    assertNotNull(ExternalAnnotationsManager.getInstance(myProject).findExternalAnnotation(listOwner, AnnotationUtil.NOT_NULL));
+    stopListeningAndCheckEvents();
+
+    myFixture.checkResultByFile("content/anno/p/annotations.xml", "content/anno/p/annotationsAnnotateLibrary_after.xml", false);
   }
 
   public void testPrimitive() throws Throwable {
@@ -123,31 +222,31 @@ public class AddAnnotationFixTest extends UsefulTestCase {
   public void testAnnotated() throws Throwable {
     PsiFile psiFile = myFixture.configureByFile("lib/p/TestAnnotated.java");
     PsiTestUtil.addSourceRoot(myModule, psiFile.getVirtualFile().getParent());
-    final Project project = myFixture.getProject();
     final PsiFile file = myFixture.getFile();
     final Editor editor = myFixture.getEditor();
     assertNotAvailable("Annotate method 'get' as @NotNull");
     assertNotAvailable("Annotate method 'get' as @Nullable");
 
     final DeannotateIntentionAction deannotateFix = new DeannotateIntentionAction();
-    assertFalse(deannotateFix.isAvailable(project, editor, file));
+    assertFalse(deannotateFix.isAvailable(myProject, editor, file));
   }
 
   public void testDeannotation() throws Throwable {
-    addLibrary();
+    addDefaultLibrary();
     myFixture.configureByFiles("lib/p/TestPrimitive.java", "content/anno/p/annotations.xml");
     doDeannotate("lib/p/TestDeannotation.java", "Annotate method 'get' as @NotNull", "Annotate method 'get' as @Nullable");
+    myFixture.checkResultByFile("content/anno/p/annotations.xml", "content/anno/p/annotationsDeannotation_after.xml", false);
   }
 
   public void testDeannotation1() throws Throwable {
-    addLibrary();
+    addDefaultLibrary();
     myFixture.configureByFiles("lib/p/TestPrimitive.java", "content/anno/p/annotations.xml");
     doDeannotate("lib/p/TestDeannotation1.java", "Annotate parameter 'ss' as @NotNull", "Annotate parameter 'ss' as @Nullable");
+    myFixture.checkResultByFile("content/anno/p/annotations.xml", "content/anno/p/annotationsDeannotation1_after.xml", false);
   }
 
   private void doDeannotate(@NonNls final String testPath, String hint1, String hint2) throws Throwable {
     myFixture.configureByFile(testPath);
-    final Project project = myFixture.getProject();
     final PsiFile file = myFixture.getFile();
     final Editor editor = myFixture.getEditor();
 
@@ -155,14 +254,17 @@ public class AddAnnotationFixTest extends UsefulTestCase {
     assertNotAvailable(hint2);
 
     final DeannotateIntentionAction deannotateFix = new DeannotateIntentionAction();
-    assertTrue(deannotateFix.isAvailable(project, editor, file));
+    assertTrue(deannotateFix.isAvailable(myProject, editor, file));
 
-    new WriteCommandAction(project){
+    final PsiModifierListOwner container = DeannotateIntentionAction.getContainer(editor, file);
+    startListening(container, AnnotationUtil.NOT_NULL, true);
+    new WriteCommandAction(myProject){
       @Override
       protected void run(final Result result) throws Throwable {
-        ExternalAnnotationsManager.getInstance(project).deannotate(DeannotateIntentionAction.getContainer(editor, file), AnnotationUtil.NOT_NULL);
+        ExternalAnnotationsManager.getInstance(myProject).deannotate(container, AnnotationUtil.NOT_NULL);
       }
     }.execute();
+    stopListeningAndCheckEvents();
 
     FileDocumentManager.getInstance().saveAllDocuments();
 
@@ -172,16 +274,16 @@ public class AddAnnotationFixTest extends UsefulTestCase {
     fix = myFixture.findSingleIntention(hint2);
     assertNotNull(fix);
 
-    assertFalse(deannotateFix.isAvailable(project, editor, file));
+    assertFalse(deannotateFix.isAvailable(myProject, editor, file));
   }
 
   public void testReadingOldPersistenceFormat() throws Throwable {
-    addLibrary();
+    addDefaultLibrary();
     myFixture.configureByFiles("content/anno/persistence/annotations.xml");
     myFixture.configureByFiles("lib/persistence/Test.java");
 
 
-    ExternalAnnotationsManager manager = ExternalAnnotationsManager.getInstance(myFixture.getProject());
+    ExternalAnnotationsManager manager = ExternalAnnotationsManager.getInstance(myProject);
     PsiMethod method = ((PsiJavaFile)myFixture.getFile()).getClasses()[0].getMethods()[0];
     PsiParameter parameter = method.getParameterList().getParameters()[0];
 
@@ -193,4 +295,128 @@ public class AddAnnotationFixTest extends UsefulTestCase {
     assertNotNull(manager.findExternalAnnotation(parameter, AnnotationUtil.NON_NLS));
     assertEquals(2, manager.findExternalAnnotations(parameter).length);
   }
+
+  private static void assertMethodAndParameterAnnotationsValues(ExternalAnnotationsManager manager,
+                                                         PsiMethod method,
+                                                         PsiParameter parameter,
+                                                         String expectedValue) {
+    PsiAnnotation methodAnnotation = manager.findExternalAnnotation(method, AnnotationUtil.NULLABLE);
+    assertNotNull(methodAnnotation);
+    assertEquals(expectedValue, methodAnnotation.findAttributeValue("value").getText());
+
+    PsiAnnotation parameterAnnotation = manager.findExternalAnnotation(parameter, AnnotationUtil.NOT_NULL);
+    assertNotNull(parameterAnnotation);
+    assertEquals(expectedValue, parameterAnnotation.findAttributeValue("value").getText());
+  }
+
+  public void testEditingMultiRootAnnotations() {
+    addLibrary("/content/annoMultiRoot/root1", "/content/annoMultiRoot/root2");
+    myFixture.configureByFiles("/content/annoMultiRoot/root1/multiRoot/annotations.xml",
+                               "/content/annoMultiRoot/root2/multiRoot/annotations.xml");
+    myFixture.configureByFiles("lib/multiRoot/Test.java");
+
+    final ExternalAnnotationsManager manager = ExternalAnnotationsManager.getInstance(myProject);
+    final PsiMethod method = ((PsiJavaFile)myFixture.getFile()).getClasses()[0].getMethods()[0];
+    final PsiParameter parameter = method.getParameterList().getParameters()[0];
+
+    assertMethodAndParameterAnnotationsValues(manager, method, parameter, "\"foo\"");
+
+    final PsiAnnotation annotationFromText =
+      JavaPsiFacade.getElementFactory(myProject).createAnnotationFromText("@Annotation(value=\"bar\")", null);
+
+    startListening(method, AnnotationUtil.NULLABLE, true);
+    new WriteCommandAction(myProject) {
+      @Override
+      protected void run(final Result result) throws Throwable {
+        manager.editExternalAnnotation(method, AnnotationUtil.NULLABLE, annotationFromText.getParameterList().getAttributes());
+      }
+    }.execute();
+    stopListeningAndCheckEvents();
+
+    startListening(parameter, AnnotationUtil.NOT_NULL, true);
+    new WriteCommandAction(myProject) {
+      @Override
+      protected void run(final Result result) throws Throwable {
+        manager.editExternalAnnotation(parameter, AnnotationUtil.NOT_NULL, annotationFromText.getParameterList().getAttributes());
+      }
+    }.execute();
+    stopListeningAndCheckEvents();
+
+    assertMethodAndParameterAnnotationsValues(manager, method, parameter, "\"bar\"");
+
+    myFixture.checkResultByFile("content/annoMultiRoot/root1/multiRoot/annotations.xml",
+                                "content/annoMultiRoot/root1/multiRoot/annotations_after.xml", false);
+    myFixture.checkResultByFile("content/annoMultiRoot/root2/multiRoot/annotations.xml",
+                                "content/annoMultiRoot/root2/multiRoot/annotations_after.xml", false);
+  }
+
+  public void testListenerNotifiedWhenOperationsFail() {
+    addLibrary(); // no annotation roots: all operations should fail
+    myFixture.configureByFiles("lib/p/Test.java");
+    final PsiMethod method = ((PsiJavaFile)myFixture.getFile()).getClasses()[0].getMethods()[0];
+
+    startListening(method, AnnotationUtil.NOT_NULL, false);
+    new WriteCommandAction(myProject){
+      @Override
+      protected void run(final Result result) throws Throwable {
+        ExternalAnnotationsManager.getInstance(myProject).annotateExternally(method, AnnotationUtil.NOT_NULL, myFixture.getFile(), null);
+      }
+    }.execute();
+    stopListeningAndCheckEvents();
+
+    startListening(method, AnnotationUtil.NOT_NULL, false);
+    new WriteCommandAction(myProject){
+      @Override
+      protected void run(final Result result) throws Throwable {
+        ExternalAnnotationsManager.getInstance(myProject).editExternalAnnotation(method, AnnotationUtil.NOT_NULL, null);
+      }
+    }.execute();
+    stopListeningAndCheckEvents();
+
+    startListening(method, AnnotationUtil.NOT_NULL, false);
+    new WriteCommandAction(myProject){
+      @Override
+      protected void run(final Result result) throws Throwable {
+        ExternalAnnotationsManager.getInstance(myProject).deannotate(method, AnnotationUtil.NOT_NULL);
+      }
+    }.execute();
+    stopListeningAndCheckEvents();
+  }
+
+  public void testListenerNotifiedOnExternalChanges() {
+    addDefaultLibrary();
+    myFixture.configureByFiles("/content/anno/p/annotations.xml");
+    myFixture.configureByFiles("lib/p/Test.java");
+
+    ExternalAnnotationsManager.getInstance(myProject).findExternalAnnotation(getOwner(), AnnotationUtil.NOT_NULL); // force creating service
+
+    startListeningForExternalChanges();
+    new WriteCommandAction(myProject){
+      @Override
+      protected void run(final Result result) throws Throwable {
+        VirtualFile file = LocalFileSystem.getInstance().findFileByPath(myFixture.getTempDirPath() + "/content/anno/p/annotations.xml");
+        assert file != null;
+        String newText = "  " + StreamUtil.readText(file.getInputStream()) + "      "; // adding newspace to the beginning and end of file
+        FileUtil.writeToFile(VfsUtil.virtualToIoFile(file), newText); // writing using java.io.File to make this change external
+        file.refresh(false, false);
+      }
+    }.execute();
+    stopListeningAndCheckEvents();
+  }
+
+  private class DefaultAnnotationsListener extends ExternalAnnotationsListener.Adapter {
+    @Override
+    public void afterExternalAnnotationChanging(@NotNull PsiModifierListOwner owner, @NotNull String annotationFQName,
+                                                boolean successful) {
+      System.err.println("Unexpected ExternalAnnotationsListener.afterExternalAnnotationChanging event produced");
+      System.err.println("owner = [" + owner + "], annotationFQName = [" + annotationFQName + "], successful = [" + successful + "]");
+      myUnexpectedEventWasProduced = true;
+    }
+
+    @Override
+    public void externalAnnotationsChangedExternally() {
+      System.err.println("Unexpected ExternalAnnotationsListener.externalAnnotationsChangedExternally event produced");
+      myUnexpectedEventWasProduced = true;
+    }
+  }
 }
index cd531b3b91fa65a499f5b24a7f08635d5658373e..548f5df1500afa1ace3766b1b0a791e85e5a0235 100644 (file)
@@ -60,6 +60,8 @@ public class SmartType17CompletionTest extends LightFixtureCompletionTestCase {
 
   public void testTryWithResourcesNoSemicolon() { doTest(); }
 
+  public void testTryWithResourcesThrowsException() { doTest(); }
+
   public void testDiamondPresentation() {
     configureByFile("/" + getTestName(false) + ".java");
     LookupElementPresentation presentation = new LookupElementPresentation();
index 1edd597e381c71c46b6aa17bc6a0136c9e0f5227..06beba331d5c6eac99c1f3a376b9e47273d3dbbf 100644 (file)
@@ -50,6 +50,18 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
   public void testExpectedReturnType1() {
     doTest();
   }
+  
+  public void testSemicolonInExpressionBodyInLocalVariable() {
+    doTest();
+  }
+
+  public void testSemicolonInCodeBlocBodyInLocalVariable() {
+    doTest();
+  }
+
+  public void testSemicolonInExpressionBodyInExpressionList() {
+    doTest();
+  }
 
   private void doTest() {
     configureByFile("/" + getTestName(false) + ".java");
index 7dcec9c186b5edbbcbd07b3942750c038b91d32d..5b654b928770b2e263fafbc7ee3586142f82777f 100644 (file)
@@ -128,6 +128,10 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
   public void testIncompleteSubst() throws Exception {
     doTest();
   }
+
+  public void testVariableInitialization() throws Exception {
+    doTest();
+  }
   
   private void doTest() throws Exception {
     doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
index 803987f50f16f4975702484bfb844cef84a72fd5..7d2747f2d5b39083567371bed83b49f67d7e2054 100644 (file)
@@ -532,6 +532,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
     doTest();
   }
 
+  public void testFromLambdaBody() throws Exception {
+    doTest();
+  }
+
   private void doTestDisabledParam() throws PrepareFailedException {
     final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
     settings.ELSE_ON_NEW_LINE = true;
index c926f13cfdd389da794d8e9518e1ec8f584348b3..14c47a4a5431504f791dce9056adf261cb272548 100644 (file)
@@ -371,6 +371,13 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
     doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.String>"));
   }
 
+  public void testOneLineLambdaVoidCompatible() throws Exception {
+    doTest(new MockIntroduceVariableHandler("c", false, false, false, "java.lang.String"));
+  }
+  public void testOneLineLambdaValueCompatible() throws Exception {
+    doTest(new MockIntroduceVariableHandler("c", false, false, false, "int"));
+  }
+
   private void doTest(IntroduceVariableBase testMe) throws Exception {
     @NonNls String baseName = "/refactoring/introduceVariable/" + getTestName(false);
     configureByFile(baseName + ".java");
index 4d69c1ea463394294bb010e9f1f27979802ac05f..ddd3803fe854c485f811ab96bb5391d9c306fae9 100644 (file)
@@ -124,4 +124,8 @@ public class WrapReturnValueTest extends MultiFileTestCase{
     doTest(true, "Existing class does not have appropriate constructor");
   }
 
+  public void testReturnInsideLambda() throws Exception {
+    doTest(false, null, true);
+  }
+  
 }
\ No newline at end of file
index 8306fbb7b9abd8b17936ea3a8d2497f0f0e2dab8..4108293d4c80dab1f69271d598b379d1c505ff89 100644 (file)
@@ -31,6 +31,10 @@ public class InlineConstantFieldTest extends LightRefactoringTestCase {
     doTest();
   }
 
+  public void testCastWhenLambdaAsQualifier() throws Exception {
+    doTest();
+  }
+
   private void doTest() throws Exception {
     String name = getTestName(false);
     @NonNls String fileName = "/refactoring/inlineConstantField/" + name + ".java";
index 24c3fda9ecc58eb04afab79dac4ff6e643e3effa..45103653238f45bf99c8f33add17adee5176bc41 100644 (file)
@@ -154,6 +154,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
     doTest(true);
   }
 
+  public void testLocalVarInsideLambdaBody() throws Exception {
+    doTest(true);
+  }
+
   private void doTest(final boolean inlineDef, String conflictMessage) throws Exception {
     try {
       doTest(inlineDef);
index 0b4a346eda5501a57eb3f2d88453339d79dc6b69..b1fad6e5e2f71f0f777611fcc1497c6c3322b656 100644 (file)
@@ -209,6 +209,22 @@ public class InlineMethodTest extends LightRefactoringTestCase {
   public void testInlineRunnableRun() throws Exception {
     doTestInlineThisOnly();
   }
+  
+  public void testOneLineLambdaVoidCompatibleToBlock() throws Exception {
+    doTestInlineThisOnly();
+  }
+
+  public void testOneLineLambdaValueCompatibleToBlock() throws Exception {
+    doTestInlineThisOnly();
+  }
+
+  public void testOneLineLambdaVoidCompatibleOneLine() throws Exception {
+    doTestInlineThisOnly();
+  }
+  public void testOneLineLambdaValueCompatibleOneLine() throws Exception {
+    doTestInlineThisOnly();
+  }
 
   private void doTestInlineThisOnly() {
     @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
index b3bfc4994f78fc1d3db81d213a3374e3bb354e0b..87ad87d99caa6967b0e493a90ee8070b4c2c11d8 100644 (file)
@@ -50,6 +50,7 @@ public abstract class QuickFixFactory {
   public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiClass psiElement);
   public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodThrowsFix(@NotNull PsiMethod method, @NotNull PsiClassType exceptionClass, boolean shouldThrow, boolean showContainingClass);
   public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddDefaultConstructorFix(@NotNull PsiClass aClass);
+  @Nullable
   public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddConstructorFix(@NotNull PsiClass aClass, @PsiModifier.ModifierConstant String modifier);
   public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodParameterTypeFix(@NotNull PsiMethod method, int index, @NotNull PsiType newType, boolean fixWholeHierarchy);
   public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass);
index 917fe4cc4d90827ea2c42cd87290e3fc3effae0a..5fe369963613a5329b260b3984a9b9319031bb2f 100644 (file)
@@ -87,7 +87,6 @@ public class Mappings {
     myInitName = myContext.get("<init>");
     myEmptyName = myContext.get("");
     myDebugS = base.myDebugS;
-    myRootDir.mkdirs();
     createImplementation();
   }
 
@@ -120,6 +119,9 @@ public class Mappings {
       myClassToSourceFile = new IntIntTransientMaplet();
     }
     else {
+      if (myIsDelta) {
+        myRootDir.mkdirs();
+      }
       myClassToSubclasses = new IntIntPersistentMultiMaplet(DependencyContext.getTableFile(myRootDir, CLASS_TO_SUBCLASSES), INT_KEY_DESCRIPTOR);
       myClassToClassDependency = new IntIntPersistentMultiMaplet(DependencyContext.getTableFile(myRootDir, CLASS_TO_CLASS), INT_KEY_DESCRIPTOR);
       mySourceFileToClasses = new IntObjectPersistentMultiMaplet<ClassRepr>(
@@ -2186,7 +2188,9 @@ public class Mappings {
         }
       }
       else {
-        FileUtil.delete(myRootDir);
+        if (!myDeltaIsTransient) {
+          FileUtil.delete(myRootDir);
+        }
       }
     }
   }
index a0a665a2f17d87d2ed5055480d533a5ba4749fcf..bac5d4762266b9fdb2fef6c6c819a48e20e73d3d 100644 (file)
@@ -25,11 +25,12 @@ import org.jetbrains.asm4.ClassReader;
 import org.jetbrains.asm4.ClassVisitor;
 import org.jetbrains.asm4.ClassWriter;
 import org.jetbrains.asm4.Opcodes;
-import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
-import org.jetbrains.jps.builders.java.dependencyView.Mappings;
-import org.jetbrains.jps.*;
+import org.jetbrains.jps.ModuleChunk;
+import org.jetbrains.jps.ProjectPaths;
 import org.jetbrains.jps.api.GlobalOptions;
 import org.jetbrains.jps.api.RequestFuture;
+import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
+import org.jetbrains.jps.builders.java.dependencyView.Mappings;
 import org.jetbrains.jps.cmdline.ProjectDescriptor;
 import org.jetbrains.jps.incremental.*;
 import org.jetbrains.jps.incremental.fs.RootDescriptor;
@@ -545,25 +546,37 @@ public class JavaBuilder extends ModuleLevelBuilder {
     return client;
   }
 
-  private static int convertToNumber(final String ver) {
-    if (ver != null) {
-      final String prefix = "1.";
-      if (ver.startsWith(prefix)) {
-        final String versionNumberString;
-        final int dotIndex = ver.indexOf(".", prefix.length());
-        if (dotIndex > 0) {
-          versionNumberString = ver.substring(prefix.length(), dotIndex);
-        }
-        else {
-          versionNumberString = ver.substring(prefix.length());
-        }
-        try {
-          return Integer.parseInt(versionNumberString);
-        }
-        catch (NumberFormatException ignored) {
-        }
+  private static int convertToNumber(String ver) {
+    if (ver == null) {
+      return 0;
+    }
+    final int quoteBegin = ver.indexOf("\"");
+    if (quoteBegin >= 0) {
+      final int quoteEnd = ver.indexOf("\"", quoteBegin + 1);
+      if (quoteEnd > quoteBegin) {
+        ver = ver.substring(quoteBegin + 1, quoteEnd);
       }
     }
+    if (ver.isEmpty()) {
+      return 0;
+    }
+
+    final String prefix = "1.";
+    final int parseBegin = ver.startsWith(prefix)? prefix.length() : 0;
+
+    final int parseEnd = ver.indexOf(".", parseBegin);
+    if (parseEnd > 0) {
+      ver = ver.substring(parseBegin, parseEnd);
+    }
+    else {
+      ver = ver.substring(parseBegin);
+    }
+
+    try {
+      return Integer.parseInt(ver);
+    }
+    catch (NumberFormatException ignored) {
+    }
     return 0;
   }
 
index 226339d6e504958c33c779844122ae2dd6e3640d..05d3a279845eee9a8a109babdf94cadbc44a8fab 100644 (file)
@@ -13,7 +13,6 @@ import java.util.Collections;
 import java.util.List;
 
 import static org.jetbrains.jps.model.serialization.JpsProjectSerializationTest.SAMPLE_PROJECT_PATH;
-import static org.jetbrains.jps.model.serialization.JpsProjectSerializationTest.getFileInSampleProject;
 
 /**
  * @author nik
@@ -29,7 +28,7 @@ public class JpsArtifactSerializationTest extends JpsSerializationTestCase {
 
   public void testSaveProject() {
     loadProject(SAMPLE_PROJECT_PATH);
-    File[] artifactFiles = getFileInSampleProject(".idea/artifacts").listFiles();
+    File[] artifactFiles = new File(getTestDataFileAbsolutePath(SAMPLE_PROJECT_PATH + "/.idea/artifacts")).listFiles();
     assertNotNull(artifactFiles);
     for (File file : artifactFiles) {
       JpsArtifact artifact = getService().createReference(FileUtil.getNameWithoutExtension(file)).asExternal(myModel).resolve();
@@ -38,12 +37,12 @@ public class JpsArtifactSerializationTest extends JpsSerializationTestCase {
     }
   }
 
-  private static void doTestSaveArtifact(JpsArtifact artifact, File expectedFile) {
+  private void doTestSaveArtifact(JpsArtifact artifact, File expectedFile) {
     try {
       Element actual = new Element("component").setAttribute("name", "ArtifactManager");
       JpsArtifactSerializer.saveArtifact(artifact, actual);
       JpsMacroExpander
-        expander = JpsProjectLoader.createProjectMacroExpander(Collections.<String, String>emptyMap(), getFileInSampleProject(""));
+        expander = JpsProjectLoader.createProjectMacroExpander(Collections.<String, String>emptyMap(), new File(getTestDataFileAbsolutePath(SAMPLE_PROJECT_PATH)));
       Element expected = JpsLoaderBase.loadRootElement(expectedFile, expander);
       PlatformTestUtil.assertElementsEqual(expected, actual);
     }
index 08b458d080cc8e4fd857c531f1e247c1c17e46b1..4635d363d8e594b992dcc98089af079dbfed9f3e 100644 (file)
@@ -1,5 +1,6 @@
 package org.jetbrains.jps.model.serialization;
 
+import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.testFramework.PlatformTestUtil;
 import org.jdom.Element;
@@ -87,7 +88,7 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase {
     }
   }
 
-  private static void doTestSaveLibrary(File libFile, String libName, JpsLibrary library) {
+  private void doTestSaveLibrary(File libFile, String libName, JpsLibrary library) {
     try {
       Element actual = new Element("library");
       JpsLibraryTableSerializer.saveLibrary(library, actual, libName);
@@ -102,7 +103,7 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase {
     }
   }
 
-  private static void doTestSaveModule(JpsModule module, final String moduleFilePath) {
+  private void doTestSaveModule(JpsModule module, final String moduleFilePath) {
     try {
       Element actual = JDomSerializationUtil.createComponentElement("NewModuleRootManager");
       JpsModuleRootModelSerializer.saveRootModel(module, actual);
@@ -116,11 +117,12 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase {
     }
   }
 
-  public static File getFileInSampleProject(String relativePath) {
+  public File getFileInSampleProject(String relativePath) {
     return new File(getTestDataFileAbsolutePath(SAMPLE_PROJECT_PATH + "/" + relativePath));
   }
 
-  public void _testLoadIdeaProject() {
+  public void testLoadIdeaProject() {
+    PathManagerEx.getTestDataPath(getClass());
     long start = System.currentTimeMillis();
     final JpsProject project = myProject;
     loadProject("");
index 98af3b187460054ab9b774c845334b1474ec46b8..5f09ab70eb5ad477f5f0992a60d23f8d24bd6b3b 100644 (file)
@@ -46,8 +46,8 @@ public abstract class JpsSerializationTestCase extends JpsModelTestCase {
     }
   }
 
-  protected static String getTestDataFileAbsolutePath(String relativePath) {
-    return PathManagerEx.findFileUnderCommunityHome(relativePath).getAbsolutePath();
+  protected String getTestDataFileAbsolutePath(String relativePath) {
+    return PathManagerEx.findFileUnderProjectHome(relativePath, getClass()).getAbsolutePath();
   }
 
   protected static Element loadModuleRootTag(File imlFile) {
index 9d7005eff21af81385beaa0492e0752719dbd30a..d9956ab5a6d89135e6f03c54c4c7c19d89f25527 100644 (file)
@@ -8,7 +8,6 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="Groovy" level="project" />
     <orderEntry type="module" module-name="jps" />
   </component>
 </module>
index 9b497b88d6456aa6ad48d5e5182dbcdb6127cdb4..9d02d2052db42a43d6baa517392d08e104c9ae7a 100644 (file)
@@ -225,11 +225,14 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
 
   /**
    * Resolves all symbolic links containing in a path to this file and returns a path to a link target.
+   * <p/>
+   * <b>Note</b>: please use this method judiciously. In most cases VFS clients don't need to resolve links in paths and should
+   * work with those provided by a user.
    *
-   * @since 11.1
    * @return <code>getPath()</code> if there are no symbolic links in a file's path;
    *         <code>getCanonicalFile().getPath()</code> if the link was successfully resolved;
    *         <code>null</code> otherwise
+   * @since 11.1
    */
   @Nullable
   public String getCanonicalPath() {
@@ -238,11 +241,14 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
 
   /**
    * Resolves all symbolic links containing in a path to this file and returns a link target.
+   * <p/>
+   * <b>Note</b>: please use this method judiciously. In most cases VFS clients don't need to resolve links in paths and should
+   * work with those provided by a user.
    *
-   * @since 11.1
    * @return <code>this</code> if there are no symbolic links in a file's path;
    *         instance of <code>VirtualFile</code> if the link was successfully resolved;
    *         <code>null</code> otherwise
+   * @since 11.1
    */
   @Nullable
   public VirtualFile getCanonicalFile() {
index b0cd8b7b207e4bcd7b0ce7aee947ae87a534d932..90c521abab8eddd60800754c8782a6efc1067025 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2012 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-/*
- * @author max
- */
 package com.intellij.openapi.vfs.newvfs;
 
 import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
@@ -24,7 +20,15 @@ import org.jetbrains.annotations.NotNull;
 
 import java.util.List;
 
+/**
+ * @author max
+ */
 public interface BulkFileListener {
+  class Adapter implements BulkFileListener {
+    @Override public void before(@NotNull List<? extends VFileEvent> events) { }
+    @Override public void after(@NotNull List<? extends VFileEvent> events) { }
+  }
+
   void before(@NotNull List<? extends VFileEvent> events);
   void after(@NotNull List<? extends VFileEvent> events);
 }
\ No newline at end of file
index 61422556810af2c2b26bd1426060622e1e68f406..1c054a6c84b6dbc18d0058ac2e7bf6eef38c3713 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.vfs.impl.jar;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
 import com.intellij.openapi.util.io.FileAttributes;
 import com.intellij.openapi.util.io.FileUtil;
@@ -38,34 +39,44 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
 public class JarHandlerBase {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.impl.jar.JarHandlerBase");
+
   private static final long DEFAULT_LENGTH = 0L;
   private static final long DEFAULT_TIMESTAMP = -1L;
 
-  protected final TimedReference<JarFile> myJarFile = new TimedReference<JarFile>(null);
-  protected SoftReference<Map<String, EntryInfo>> myRelPathsToEntries = new SoftReference<Map<String, EntryInfo>>(null);
-  protected final Object lock = new Object();
+  private final TimedReference<JarFile> myJarFile = new TimedReference<JarFile>(null);
+  private SoftReference<Map<String, EntryInfo>> myRelPathsToEntries = new SoftReference<Map<String, EntryInfo>>(null);
+  private final Object lock = new Object();
+
   protected final String myBasePath;
 
   protected static class EntryInfo {
+    protected final boolean isDirectory;
+    protected final String shortName;
+    protected final EntryInfo parent;
+
     public EntryInfo(final String shortName, final EntryInfo parent, final boolean directory) {
       this.shortName = shortName;
       this.parent = parent;
-      isDirectory = directory;
+      this.isDirectory = directory;
     }
-
-    final boolean isDirectory;
-    protected final String shortName;
-    final EntryInfo parent;
   }
 
   public JarHandlerBase(String path) {
     myBasePath = path;
   }
 
+  protected void clear() {
+    synchronized (lock) {
+      myRelPathsToEntries = null;
+      myJarFile.set(null);
+    }
+  }
+
   @NotNull
   protected Map<String, EntryInfo> initEntries() {
     synchronized (lock) {
-      Map<String, EntryInfo> map = myRelPathsToEntries.get();
+      Map<String, EntryInfo> map = myRelPathsToEntries != null ? myRelPathsToEntries.get() : null;
       if (map == null) {
         final JarFile zip = getJar();
 
@@ -105,8 +116,9 @@ public class JarHandlerBase {
 
   @Nullable
   protected JarFile createJarFile() {
+    final File originalFile = getOriginalFile();
     try {
-      final ZipFile zipFile = new ZipFile(getMirrorFile(getOriginalFile()));
+      @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final ZipFile zipFile = new ZipFile(getMirrorFile(originalFile));
 
       class MyJarEntry implements JarFile.JarEntry {
         private ZipEntry myEntry;
@@ -180,6 +192,7 @@ public class JarHandlerBase {
       };
     }
     catch (IOException e) {
+      LOG.warn(e.getMessage() + ": " + originalFile.getPath());
       return null;
     }
   }
index a34f18259b577ee3e905c10c469de08c35e360f4..083292b07b44758c65c60935a3398c7af9e8c92e 100644 (file)
 
 package com.intellij.openapi.module.impl.scopes;
 
-import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.JdkOrderEntry;
 import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.roots.ProjectFileIndex;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.LinkedHashSet;
 
 /**
  * @author max
  */
-public class JdkScope extends GlobalSearchScope {
-  private final LinkedHashSet<VirtualFile> myEntries = new LinkedHashSet<VirtualFile>();
+public class JdkScope extends LibraryScopeBase {
   private final String myJdkName;
-  private final ProjectFileIndex myIndex;
 
   public JdkScope(Project project, JdkOrderEntry jdk) {
-    super(project);
-    myIndex = ProjectRootManager.getInstance(project).getFileIndex();
+    super(project, jdk.getRootFiles(OrderRootType.CLASSES), jdk.getRootFiles(OrderRootType.SOURCES));
     myJdkName = jdk.getJdkName();
-    ContainerUtil.addAll(myEntries, jdk.getRootFiles(OrderRootType.CLASSES));
   }
 
   public int hashCode() {
@@ -51,41 +37,10 @@ public class JdkScope extends GlobalSearchScope {
 
   public boolean equals(Object object) {
     if (object == this) return true;
+    if (object == null) return false;
     if (object.getClass() != JdkScope.class) return false;
 
     final JdkScope that = (JdkScope)object;
     return that.myJdkName.equals(myJdkName);
   }
-
-  public boolean contains(VirtualFile file) {
-    return myEntries.contains(getFileRoot(file));
-  }
-
-  private VirtualFile getFileRoot(VirtualFile file) {
-    if (myIndex.isInLibraryClasses(file)) {
-      return myIndex.getClassRootForFile(file);
-    }
-    if (myIndex.isInContent(file)) {
-      return myIndex.getSourceRootForFile(file);
-    }
-    return null;
-  }
-
-  public int compare(VirtualFile file1, VirtualFile file2) {
-    final VirtualFile r1 = getFileRoot(file1);
-    final VirtualFile r2 = getFileRoot(file2);
-    for (VirtualFile root : myEntries) {
-      if (Comparing.equal(r1, root)) return 1;
-      if (Comparing.equal(r2, root)) return -1;
-    }
-    return 0;
-  }
-
-  public boolean isSearchInModuleContent(@NotNull Module aModule) {
-    return false;
-  }
-
-  public boolean isSearchInLibraries() {
-    return true;
-  }
 }
diff --git a/platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/LibraryScope.java b/platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/LibraryScope.java
new file mode 100644 (file)
index 0000000..2dcbf35
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.module.impl.scopes;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.OrderRootType;
+import com.intellij.openapi.roots.libraries.Library;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.util.PathUtil;
+
+/**
+ * @author nik
+ */
+public class LibraryScope extends LibraryScopeBase {
+  private final Library myLibrary;
+
+  public LibraryScope(Project project, Library library) {
+    super(project, library.getFiles(OrderRootType.CLASSES), library.getFiles(OrderRootType.SOURCES));
+    myLibrary = library;
+  }
+
+  @Override
+  public String getDisplayName() {
+    String name = myLibrary.getName();
+    if (name == null) {
+      String[] urls = myLibrary.getUrls(OrderRootType.CLASSES);
+      if (urls.length > 0) {
+        name = PathUtil.getFileName(VfsUtilCore.urlToPath(urls[0]));
+      }
+      else {
+        name = "empty";
+      }
+    }
+    return "Library '" + name + "'";
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    return myLibrary.equals(((LibraryScope)o).myLibrary);
+  }
+
+  @Override
+  public int hashCode() {
+    return 31 * super.hashCode() + myLibrary.hashCode();
+  }
+}
diff --git a/platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/LibraryScopeBase.java b/platform/indexing-impl/src/com/intellij/openapi/module/impl/scopes/LibraryScopeBase.java
new file mode 100644 (file)
index 0000000..60563fe
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.module.impl.scopes;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectFileIndex;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+
+/**
+ * @author nik
+ */
+public abstract class LibraryScopeBase extends GlobalSearchScope {
+  private final LinkedHashSet<VirtualFile> myEntries;
+  private final ProjectFileIndex myIndex;
+
+  public LibraryScopeBase(Project project, VirtualFile[] classes, VirtualFile[] sources) {
+    super(project);
+    myIndex = ProjectRootManager.getInstance(project).getFileIndex();
+    myEntries = new LinkedHashSet<VirtualFile>(classes.length + sources.length);
+    Collections.addAll(myEntries, classes);
+    Collections.addAll(myEntries, sources);
+  }
+
+  public boolean contains(VirtualFile file) {
+    return myEntries.contains(getFileRoot(file));
+  }
+
+  @Nullable
+  private VirtualFile getFileRoot(VirtualFile file) {
+    if (myIndex.isInLibraryClasses(file)) {
+      return myIndex.getClassRootForFile(file);
+    }
+    if (myIndex.isInContent(file)) {
+      return myIndex.getSourceRootForFile(file);
+    }
+    return null;
+  }
+
+  public int compare(VirtualFile file1, VirtualFile file2) {
+    final VirtualFile r1 = getFileRoot(file1);
+    final VirtualFile r2 = getFileRoot(file2);
+    for (VirtualFile root : myEntries) {
+      if (Comparing.equal(r1, root)) return 1;
+      if (Comparing.equal(r2, root)) return -1;
+    }
+    return 0;
+  }
+
+  public boolean isSearchInModuleContent(@NotNull Module aModule) {
+    return false;
+  }
+
+  public boolean isSearchInLibraries() {
+    return true;
+  }
+}
index d06a652f25b6050641447775691a216cf57b2a1f..b8ffb1cfee1cb8ce688093c833fb0fbd44b4b7d2 100644 (file)
@@ -13,8 +13,7 @@
     <orderEntry type="library" exported="" name="NanoXML" level="project" />
     <orderEntry type="module" module-name="indexing-api" exported="" />
     <orderEntry type="module" module-name="projectModel-api" exported="" />
-    <orderEntry type="library" name="JUnit4" level="project" />
-    <orderEntry type="library" name="Groovy" level="project" />
+    <orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
     <orderEntry type="library" scope="TEST" name="Mocks" level="project" />
   </component>
 </module>
index cce3cd8c39e36dda8e707c6915130c3e0e37ac3c..fc4b45da5464f3b6cd7b05d6f95e319aab605fc7 100644 (file)
@@ -60,4 +60,7 @@ public class LineRange {
     return startLine <= lineNumber && endLine > lineNumber;
   }
 
+  public boolean contains(LineRange range) {
+    return startLine <= range.startLine && endLine >= range.endLine;
+  }
 }
index 8de2e77fb89f4e735c99461eadd1c948ba678a17..f68a5da94994a3071b306a1baef3e844282d9c51 100644 (file)
@@ -38,8 +38,10 @@ public abstract class StatementUpDownMover {
     @NotNull
     public LineRange toMove;
 
-    /** Target line range, or <code>null</code> if move not available */
-    @Nullable
+    /**
+     * Target line range, or <code>null</code> if move not available
+     * @see #prohibitMove()
+     */
     public LineRange toMove2;
 
     public RangeMarker range1;
@@ -47,6 +49,15 @@ public abstract class StatementUpDownMover {
 
     public boolean indentSource;
     public boolean indentTarget = true;
+
+    /**
+     * Use this method in {@link StatementUpDownMover#checkAvailable(com.intellij.openapi.editor.Editor, com.intellij.psi.PsiFile, com.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover.MoveInfo, boolean)}
+     * @return true to suppress further movers processing
+     */
+    public final boolean prohibitMove() {
+      toMove2 = null;
+      return true;
+    }
   }
 
   public abstract boolean checkAvailable(@NotNull final Editor editor, @NotNull final PsiFile file, @NotNull final MoveInfo info, final boolean down);
@@ -100,11 +111,13 @@ public abstract class StatementUpDownMover {
     return null;
   }
 
+  @Nullable
   protected static PsiElement firstNonWhiteElement(int offset, PsiFile file, final boolean lookRight) {
     final ASTNode leafElement = file.getNode().findLeafElementAt(offset);
     return leafElement == null ? null : firstNonWhiteElement(leafElement.getPsi(), lookRight);
   }
 
+  @Nullable
   protected static PsiElement firstNonWhiteElement(PsiElement element, final boolean lookRight) {
     if (element instanceof PsiWhiteSpace) {
       element = lookRight ? element.getNextSibling() : element.getPrevSibling();
index e6dac0cc7cb33b3c5851faa2711aced330674dda..ac6634241050b6e511d863372a1a064a590e2b16 100644 (file)
@@ -48,9 +48,13 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
   @NonNls private static final String FILE_OUTPUT = "output_file";\r
   @NonNls private static final String SAVE = "is_save";\r
   @NonNls private static final String OUTPUT_FILE = "path";\r
+  @NonNls private static final String SHOW_CONSOLE_ON_STD_OUT = "show_console_on_std_out";\r
+  @NonNls private static final String SHOW_CONSOLE_ON_STD_ERR = "show_console_on_std_err";\r
 \r
   private final Icon myIcon;\r
   private boolean mySaveOutput = false;\r
+  private boolean myShowConsoleOnStdOut = false;\r
+  private boolean myShowConsoleOnStdErr = false;\r
   private String myFileOutputPath = null;\r
 \r
   protected RunConfigurationBase(final Project project, final ConfigurationFactory factory, final String name) {\r
@@ -114,6 +118,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
     runConfiguration.myPredefinedLogFiles = new ArrayList<PredefinedLogFile>(myPredefinedLogFiles);\r
     runConfiguration.myFileOutputPath = myFileOutputPath;\r
     runConfiguration.mySaveOutput = mySaveOutput;\r
+    runConfiguration.myShowConsoleOnStdOut = myShowConsoleOnStdOut;\r
+    runConfiguration.myShowConsoleOnStdErr = myShowConsoleOnStdErr;\r
     copyCopyableDataTo(runConfiguration);\r
     return runConfiguration;\r
   }\r
@@ -190,6 +196,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
       final String isSave = fileOutputElement.getAttributeValue(SAVE);\r
       mySaveOutput = isSave != null && Boolean.parseBoolean(isSave);\r
     }\r
+    myShowConsoleOnStdOut = Boolean.parseBoolean(element.getAttributeValue(SHOW_CONSOLE_ON_STD_OUT));\r
+    myShowConsoleOnStdErr = Boolean.parseBoolean(element.getAttributeValue(SHOW_CONSOLE_ON_STD_ERR));\r
   }\r
 \r
   public void writeExternal(Element element) throws WriteExternalException {\r
@@ -211,6 +219,12 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
     if (myFileOutputPath != null || mySaveOutput) {\r
       element.addContent(fileOutputPathElement);\r
     }\r
+    if (myShowConsoleOnStdOut) {//default value shouldn't be written\r
+      element.setAttribute(SHOW_CONSOLE_ON_STD_OUT, String.valueOf(myShowConsoleOnStdOut));\r
+    }\r
+    if (myShowConsoleOnStdErr) {//default value shouldn't be written\r
+      element.setAttribute(SHOW_CONSOLE_ON_STD_ERR, String.valueOf(myShowConsoleOnStdErr));\r
+    }\r
   }\r
 \r
   public boolean isSaveOutputToFile() {\r
@@ -221,6 +235,22 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
     mySaveOutput = redirectOutput;\r
   }\r
 \r
+  public boolean isShowConsoleOnStdOut() {\r
+    return myShowConsoleOnStdOut;\r
+  }\r
+\r
+  public void setShowConsoleOnStdOut(boolean showConsoleOnStdOut) {\r
+    myShowConsoleOnStdOut = showConsoleOnStdOut;\r
+  }\r
+\r
+  public boolean isShowConsoleOnStdErr() {\r
+    return myShowConsoleOnStdErr;\r
+  }\r
+\r
+  public void setShowConsoleOnStdErr(boolean showConsoleOnStdErr) {\r
+    myShowConsoleOnStdErr = showConsoleOnStdErr;\r
+  }\r
+\r
   public String getOutputFilePath() {\r
     return myFileOutputPath;\r
   }\r
index d4cc06133666058f491158e239535e7d9a9f9b2b..ced6425cc4e4e75f335167021c3b733f842d5ffb 100644 (file)
 package com.intellij.application.options.codeStyle.arrangement;
 
 import com.intellij.openapi.actionSystem.impl.ActionButton;
+import com.intellij.openapi.components.ServiceManager;
 import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
 import com.intellij.ui.IdeBorderFactory;
+import com.intellij.ui.RoundedLineBorder;
 import com.intellij.ui.awt.RelativePoint;
 import com.intellij.util.Consumer;
 import com.intellij.util.ui.GridBag;
-import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -39,9 +40,11 @@ import java.awt.event.MouseEvent;
  */
 public class ArrangementAtomNodeComponent implements ArrangementNodeComponent {
 
-  public static final int VERTICAL_PADDING = 2;
+  public static final int VERTICAL_PADDING   = 2;
   public static final int HORIZONTAL_PADDING = 8;
 
+  @NotNull private final ArrangementColorsService myColorsService = ServiceManager.getService(ArrangementColorsService.class);
+  
   @NotNull private final JPanel myRenderer = new JPanel(new GridBagLayout()) {
     @Override
     public void paint(Graphics g) {
@@ -57,7 +60,8 @@ public class ArrangementAtomNodeComponent implements ArrangementNodeComponent {
     }
   };
 
-  @NotNull private final JLabel myLabel = new JLabel() {
+  @NotNull
+  private final JLabel myLabel = new JLabel() {
     @Override
     public Dimension getMinimumSize() {
       return getPreferredSize();
@@ -73,16 +77,18 @@ public class ArrangementAtomNodeComponent implements ArrangementNodeComponent {
       return myLabelSize == null ? super.getPreferredSize() : myLabelSize;
     }
   };
+  @NotNull private final RoundedLineBorder myBorder;
 
   @NotNull private final  ArrangementAtomMatchCondition           myCondition;
   @Nullable private final ActionButton                            myCloseButton;
   @Nullable private final Consumer<ArrangementAtomMatchCondition> myCloseCallback;
 
+  @NotNull private Color myBackgroundColor;
+  
   @Nullable private Dimension myLabelSize;
   @Nullable private Rectangle myScreenBounds;
-
+  
   private boolean myEnabled = true;
-  private boolean mySelected;
   private boolean myInverted;
   private boolean myCloseButtonHovered;
 
@@ -130,9 +136,9 @@ public class ArrangementAtomNodeComponent implements ArrangementNodeComponent {
           Point mouseScreenLocation = MouseInfo.getPointerInfo().getLocation();
           myCloseButtonHovered = buttonBounds.contains(mouseScreenLocation);
         }
-        Color color = mySelected ? UIUtil.getTreeSelectionBackground() : UIUtil.getPanelBackground();
+        
         Rectangle bounds = getBounds();
-        g.setColor(color);
+        g.setColor(myBackgroundColor);
         g.fillRoundRect(0, 0, bounds.width, bounds.height, arcSize, arcSize);
         super.paint(g);
       }
@@ -141,12 +147,14 @@ public class ArrangementAtomNodeComponent implements ArrangementNodeComponent {
     if (myCloseButton != null) {
       roundBorderPanel.add(myCloseButton, new GridBag().anchor(GridBagConstraints.CENTER).insets(VERTICAL_PADDING, 0, 0, 0));
     }
-    roundBorderPanel.setBorder(IdeBorderFactory.createRoundedBorder(arcSize));
+    myBorder = IdeBorderFactory.createRoundedBorder(arcSize);
+    roundBorderPanel.setBorder(myBorder);
     roundBorderPanel.setOpaque(false);
     
     myRenderer.setBorder(IdeBorderFactory.createEmptyBorder(VERTICAL_PADDING));
     myRenderer.add(roundBorderPanel, constraints);
     myRenderer.setOpaque(false);
+    setSelected(false);
   }
 
   @NotNull
@@ -183,7 +191,9 @@ public class ArrangementAtomNodeComponent implements ArrangementNodeComponent {
    * @param selected  flag that indicates if current component should be drawn as 'selected'
    */
   public void setSelected(boolean selected) {
-    mySelected = selected;
+    myLabel.setForeground(myColorsService.getTextColor(selected));
+    myBorder.setColor(myColorsService.getBorderColor(selected));
+    myBackgroundColor = myColorsService.getBackgroundColor(selected);
   }
 
   /**
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/ArrangementColorsService.java
new file mode 100644 (file)
index 0000000..f7d2bb2
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.application.options.co