Merge remote-tracking branch 'origin/master'
authorIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Wed, 2 Apr 2014 15:38:34 +0000 (19:38 +0400)
committerIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Wed, 2 Apr 2014 15:38:34 +0000 (19:38 +0400)
237 files changed:
.idea/compiler.xml
build/conf/classVersions.txt
build/scripts/layouts.gant
java/compiler/instrumentation-util/instrumentation-util.iml
java/debugger/impl/src/com/intellij/debugger/ui/EvaluationDialog.java
java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromMethodReferenceFix.java [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java
java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java
java/java-impl/src/com/intellij/psi/impl/smartPointers/AnchorElementInfo.java
java/java-impl/src/com/intellij/spi/SPIFileType.java
java/java-impl/src/resources/projectTemplates/Java/Command_Line_App.zip
java/java-psi-impl/src/com/intellij/ide/highlighter/JavaClassFileType.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnsupportedFeatures7.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA123316.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/TypeArgsConsistency.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/AccessModifiers.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Ambiguity.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Assignability.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorRefInnerFromSuper.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorRefs.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorRefsInnerClasses.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/DefaultConstructor.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodRefAcceptance.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodRefMisc1.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/QualifierTypeArgs.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RefOnArrayDeclaration.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Varargs.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/VarargsInReceiverPosition.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AssertNumberOfParameters.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA123223.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA123248.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterConstructor.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterReferenceType.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterThisType.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeConstructor.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeReferenceType.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeThisType.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMissedBraces.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMissedBraces.java [new file with mode: 0644]
java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromMethodReferenceFixTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/ide/fileTemplates/SimpleTemplatesTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/index/StringIndex.java
java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java
jps/model-serialization/jps-serialization-tests.iml
jps/plugin-system/jps-plugin-system.iml
lib/asm-all.jar
platform/core-api/src/com/intellij/ide/highlighter/ArchiveFileType.java
platform/core-api/src/com/intellij/lang/LanguageUtil.java
platform/core-api/src/com/intellij/openapi/fileTypes/FileType.java
platform/core-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java
platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java
platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java
platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java
platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java
platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/core-impl/src/com/intellij/psi/templateLanguages/TreePatcher.java [moved from platform/lang-impl/src/com/intellij/psi/templateLanguages/TreePatcher.java with 100% similarity]
platform/core-impl/src/com/intellij/util/indexing/FileContentImpl.java
platform/core-impl/src/com/intellij/util/indexing/SubstitutedFileType.java
platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/id/PlatformIdTableBuilding.java
platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/todo/TodoIndex.java
platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
platform/external-system-api/src/com/intellij/openapi/externalSystem/model/ExternalSystemException.java
platform/external-system-api/src/com/intellij/openapi/externalSystem/model/LocationAwareExternalSystemException.java [new file with mode: 0644]
platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/EditableNotificationMessageElement.java [new file with mode: 0644]
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemIdeNotificationManager.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtension.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationData.java [new file with mode: 0644]
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java [new file with mode: 0644]
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationSource.java [new file with mode: 0644]
platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/remote/RemoteExternalSystemProjectResolverImpl.java
platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
platform/indexing-api/src/com/intellij/util/indexing/DataIndexer.java
platform/indexing-api/src/com/intellij/util/indexing/FileBasedIndexExtension.java
platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/id/IdIndex.java
platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/id/IdTableBuilding.java
platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/id/LexerBasedIdIndexer.java
platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/LexerBasedTodoIndexer.java
platform/indexing-impl/src/com/intellij/psi/search/FileTypeIndex.java
platform/indexing-impl/src/com/intellij/psi/search/FilenameIndex.java
platform/indexing-impl/src/com/intellij/util/indexing/SingleEntryIndexer.java
platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
platform/lang-impl/src/com/intellij/find/ngrams/TrigramIndex.java
platform/lang-impl/src/com/intellij/framework/detection/impl/FrameworkDetectionIndex.java
platform/lang-impl/src/com/intellij/openapi/file/exclude/EnforcedPlainTextFileTypeFactory.java
platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java
platform/lang-impl/src/com/intellij/ui/debugger/extensions/UiScriptFileType.java
platform/lang-impl/src/com/intellij/util/indexing/TaskQueue.java
platform/platform-api/src/com/intellij/ide/highlighter/WorkspaceFileType.java
platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeConsumer.java
platform/platform-api/src/com/intellij/openapi/fileTypes/NativeFileType.java
platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java
platform/platform-api/src/com/intellij/openapi/ui/popup/ComponentPopupBuilder.java
platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileAttribute.java
platform/platform-api/src/com/intellij/ui/ScreenUtil.java
platform/platform-impl/src/com/intellij/ide/actions/QuickChangeColorSchemeAction.java
platform/platform-impl/src/com/intellij/ide/actions/TabsPlacementAction.java
platform/platform-impl/src/com/intellij/ide/errorTreeView/CustomizeColoredTreeCellRendererReplacement.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/errorTreeView/EditableMessageElement.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/errorTreeView/ErrorViewStructure.java
platform/platform-impl/src/com/intellij/ide/errorTreeView/NewEditableErrorTreeViewPanel.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeRenderer.java
platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java
platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FakeFileType.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/FogLayer.java [deleted file]
platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java
platform/platform-impl/src/com/intellij/ui/popup/ComponentPopupBuilderImpl.java
platform/platform-resources-en/src/messages/DesignerBundle.properties [moved from plugins/ui-designer-core/src/messages/DesignerBundle.properties with 95% similarity]
platform/platform-resources-en/src/tips/css/tips_darcula.css
platform/platform-resources/src/META-INF/XmlPlugin.xml
platform/platform-resources/src/idea/Keymap_Mac.xml
platform/platform-resources/src/idea/Keymap_MacClassic.xml
platform/platform-resources/src/idea/PlatformActions.xml
platform/projectModel-api/src/com/intellij/ide/highlighter/ModuleFileType.java
platform/projectModel-api/src/com/intellij/ide/highlighter/ProjectFileType.java
platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java [moved from platform/lang-impl/src/com/intellij/openapi/roots/impl/RootIndex.java with 98% similarity]
platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
platform/util-rt/src/com/intellij/execution/rmi/RemoteDeadHand.java
platform/util-rt/src/com/intellij/execution/rmi/RemoteServer.java
platform/util-rt/src/com/intellij/openapi/diagnostic/LoggerRt.java
platform/util-rt/src/com/intellij/openapi/util/Condition.java
platform/util-rt/src/com/intellij/openapi/util/Conditions.java
platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java
platform/util-rt/src/com/intellij/util/Function.java
platform/util-rt/src/com/intellij/util/NotNullFunction.java
platform/util-rt/src/com/intellij/util/NullableConsumer.java
platform/util-rt/src/com/intellij/util/NullableFunction.java
platform/util-rt/src/com/intellij/util/containers/EmptyIterator.java
platform/util-rt/src/com/intellij/util/containers/EmptyListIterator.java
platform/util/src/com/intellij/util/ui/UIUtil.java
platform/util/src/com/intellij/util/xmlb/Accessor.java
platform/util/src/com/intellij/util/xmlb/FieldAccessor.java
platform/util/testSrc/com/intellij/util/text/DateFormatUtilTest.java
platform/util/testSrc/com/intellij/util/text/PrintTime.js [new file with mode: 0644]
platform/util/util.iml
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchFileType.java
platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bitwise/PointlessBitwiseExpressionInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classlayout/ClassMayBeInterfaceInspection.java
plugins/InspectionGadgets/src/inspectionDescriptions/ClassMayBeInterface.html
plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBitwiseExpression.html
plugins/InspectionGadgets/test/com/siyeh/igfixes/classlayout/class_may_be_interface/ConvertMe.after.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igfixes/classlayout/class_may_be_interface/ConvertMe.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/bitwise/pointless_bitwise_expression/PointlessBitwiseExpressionInspection.java
plugins/InspectionGadgets/test/com/siyeh/igtest/bitwise/pointless_bitwise_expression/expected.xml
plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/ClassMayBeInterfaceInspectionTest.java [new file with mode: 0644]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/classlayout/ClassMayBeInterfaceFixTest.java [new file with mode: 0644]
plugins/IntentionPowerPak/src/com/siyeh/ipp/concatenation/MethodCallChainPredicate.java
plugins/IntentionPowerPak/test/com/siyeh/ipp/concatenation/call_chain/Builder.java [new file with mode: 0644]
plugins/IntentionPowerPak/test/com/siyeh/ipp/concatenation/call_chain/Builder_after.java [new file with mode: 0644]
plugins/IntentionPowerPak/test/com/siyeh/ipp/concatenation/call_chain/ThisCollapse.java [new file with mode: 0644]
plugins/IntentionPowerPak/test/com/siyeh/ipp/concatenation/call_chain/Transformation.java [new file with mode: 0644]
plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/concatenation/MakeCallChainIntoCallSequenceTest.java [new file with mode: 0644]
plugins/ant/jps-plugin/ant-jps-plugin.iml
plugins/ant/src/com/intellij/lang/ant/AntImportsIndex.java
plugins/devkit/jps-plugin/devkit-jps-plugin.iml
plugins/eclipse/common-eclipse-util/common-eclipse-util.iml
plugins/eclipse/jps-plugin/eclipse-jps-plugin.iml
plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseFileType.java
plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java
plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java
plugins/git4idea/tests/git4idea/history/GitLogParserTest.java
plugins/git4idea/tests/git4idea/repo/GitConfigTest.java
plugins/google-app-engine/jps-plugin/google-app-engine-jps-plugin.iml
plugins/gradle/src/META-INF/plugin.xml
plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/actions/AddGradleDslPluginAction.java
plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/maven/ImportMavenRepositoriesTask.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/ApplyGradlePluginCallback.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GotoSourceNotificationCallback.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GradleNotificationExtension.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/OpenGradleSettingsCallback.java [new file with mode: 0644]
plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/AbstractProjectImportErrorHandler.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseProjectImportErrorHandler.java
plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
plugins/gradle/testSources/org/jetbrains/plugins/gradle/service/project/BaseProjectImportErrorHandlerTest.java
plugins/groovy/jps-plugin/groovy-jps-plugin.iml
plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java
plugins/hg4idea/src/org/zmlx/hg4idea/command/HgLogCommand.java
plugins/hg4idea/src/org/zmlx/hg4idea/log/HgBaseLogParser.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/log/HgFileRevisionLogParser.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
plugins/hg4idea/src/org/zmlx/hg4idea/util/HgHistoryUtil.java [deleted file]
plugins/hg4idea/testSrc/hg4idea/test/history/HgLogHistoryTest.java
plugins/hg4idea/testSrc/org/zmlx/hg4idea/log/HgLogParseTest.java [moved from plugins/hg4idea/testSrc/hg4idea/test/history/HgLogParseTest.java with 86% similarity]
plugins/javaFX/javaFX-jps-plugin/javaFX-jps-plugin.iml
plugins/javaFX/src/org/jetbrains/plugins/javaFX/FxmlDataIndexer.java
plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxControllerClassIndex.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java
plugins/maven/jps-plugin/maven-jps-plugin.iml
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomPluginModelDescription.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenResumeAction.java
plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesFileType.java
plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/xml/XmlPropertiesIndex.java
plugins/ui-designer/jps-plugin/ui-designer-jps-plugin.iml
plugins/ui-designer/src/com/intellij/uiDesigner/GuiFormFileType.java
plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltSymbolIndex.java
python/psi-api/src/com/jetbrains/python/PythonFileType.java
python/src/com/jetbrains/pyqt/QtFileType.java
python/src/com/jetbrains/python/psi/stubs/PyModuleNameIndex.java
resources/src/idea/RichPlatformPlugin.xml
xml/dom-impl/src/com/intellij/util/xml/DomFileIndex.java
xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/GenerationNode.java
xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java
xml/impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java
xml/impl/src/com/intellij/xml/index/XmlTagNamesIndex.java
xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxSymbolIndex.java
xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java
xml/xml-psi-impl/src/com/intellij/ide/highlighter/HtmlFileType.java
xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlLikeFileType.java
xml/xml-psi-impl/src/com/intellij/lang/xml/XmlTemplateTreePatcher.java [new file with mode: 0644]
xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java

index b803bcf74e00d1fc7588c6f5d038204d7874475b..bb073aff93a90ada6700648b554e1e05d34f8ad8 100644 (file)
@@ -44,7 +44,6 @@
       <module name="remote-servers-agent-rt" target="1.5" />
       <module name="testng_rt" target="1.5" />
       <module name="ui-designer-jps-plugin" target="1.6" />
-      <module name="util" target="1.5" />
       <module name="util-rt" target="1.5" />
     </bytecodeTargetLevel>
   </component>
index aab86e5913357d79ea73801a33a5fb1eeff5ebff..dd39ad0006d343fd2de3146d7be3a96e12089066 100644 (file)
@@ -29,7 +29,6 @@
 1.6 =>
 
 1.3 => lib/idea_rt.jar
-1.5 => lib/util.jar
 
 1.7 => lib/fxHelpBrowser.jar
 1.7 => lib/optimizedFileManager.jar
index 71971d4c2d7b0139bbd06d0a5f9f5e531b1a1a3e..c2766d0a8b012525d17620b2d2c5397185a061a7 100644 (file)
@@ -83,7 +83,8 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir
     "remote-servers-java-impl",
     "testFramework",
     "tests_bootstrap",
-          ].flatten()
+    "ui-designer-core"
+  ].flatten()
   implementationModules.removeAll(jpsCommonModules) //todo[nik] remove jps modules from platformImplementationModules instead and update layouts of minor IDEs accordingly
 
   ant.patternset(id: "resources.included") {
@@ -687,15 +688,7 @@ def layoutAndroid(String androidHome) {
 
     dir("android-designer") {
       dir("lib") {
-        jar("resources_en.jar") {
-          module("ui-designer-core") {
-            patternset(refid: "resources.included")
-          }
-        }
         jar("android-designer.jar") {
-          module("ui-designer-core") {
-            patternset(refid: "resources.excluded")
-          }
           module("android-designer")
         }
       }
index 60d62d325d2392b08039c7eca8a3378a3d8b76c7..370070ea380bd29a8a4419d3547b481201943d38 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module relativePaths="true" type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
index 7deaf44e8c47f4e0f7628cbccd86e48c1b3972da..6359af31e5a375dc6f43c6026db4cf3c0ca3daad 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.DebuggerContextListener;
 import com.intellij.debugger.impl.DebuggerSession;
 import com.intellij.debugger.impl.PositionUtil;
+import com.intellij.debugger.ui.impl.ValueNodeDnD;
 import com.intellij.debugger.ui.impl.WatchDebuggerTree;
 import com.intellij.debugger.ui.impl.WatchPanel;
 import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
@@ -176,6 +177,7 @@ public abstract class EvaluationDialog extends DialogWrapper {
       });
       setUpdateEnabled(true);
       getTree().getEmptyText().setText(XDebuggerBundle.message("debugger.no.results"));
+      new ValueNodeDnD(myTree, project);
     }
 
     protected ActionPopupMenu createPopupMenu() {
index 6386fb41314e5d743077f7d1c2e68b1a46a13dcc..b6de2556e696d2cd2df5eedfbfa53e1e7261a3d2 100644 (file)
@@ -423,7 +423,7 @@ public class PositionHighlighter {
       DefaultActionGroup group = new DefaultActionGroup();
       for (Pair<Breakpoint, Event> eventDescriptor : myEventsOutOfLine) {
         Breakpoint breakpoint = eventDescriptor.getFirst();
-        AnAction viewBreakpointsAction = new ViewBreakpointsAction(breakpoint.getDisplayName(), breakpoint);
+        AnAction viewBreakpointsAction = new ViewBreakpointsAction(breakpoint.getDisplayName(), breakpoint.getXBreakpoint());
         group.add(viewBreakpointsAction);
       }
 
index bd74d0ff6d90f5cb66a88790bfd52d6d434ff6a6..58596262ba439ba982f2c9f740a8bb042b86b6e4 100644 (file)
@@ -91,6 +91,10 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
     return myXBreakpoint.getProperties();
   }
 
+  public XBreakpoint<P> getXBreakpoint() {
+    return myXBreakpoint;
+  }
+
   @Nullable
   public abstract PsiClass getPsiClass();
   /**
index 98930c82224c6ae66ccb2b180ca5d63cf66eb441..8bbc7567cbdc95d7a96d7db5735f8bb6d0d5fc70 100644 (file)
@@ -179,6 +179,7 @@ public abstract class QuickFixFactory {
                                                   int minUsagesNumberToShowDialog);
 
   @NotNull public abstract IntentionAction createCreateMethodFromUsageFix(@NotNull PsiMethodCallExpression call);
+  @NotNull public abstract IntentionAction createCreateMethodFromUsageFix(PsiMethodReferenceExpression methodReferenceExpression);
 
   @NotNull public abstract IntentionAction createCreateAbstractMethodFromUsageFix(@NotNull PsiMethodCallExpression call);
 
index 77a928abfb6b11ac274445ac8233ae018d2c5605..493534132d5c0801696705f824bbb9c04f6296b1 100644 (file)
@@ -715,8 +715,10 @@ public class GenericsHighlightUtil {
   }
 
   @Nullable
-  public static HighlightInfo checkEnumInstantiation(PsiNewExpression expression, PsiClass aClass) {
-    if (aClass != null && aClass.isEnum() && expression.getArrayDimensions().length == 0 && expression.getArrayInitializer() == null) {
+  public static HighlightInfo checkEnumInstantiation(PsiElement expression, PsiClass aClass) {
+    if (aClass != null && aClass.isEnum() && 
+        (!(expression instanceof PsiNewExpression) ||
+         ((PsiNewExpression)expression).getArrayDimensions().length == 0 && ((PsiNewExpression)expression).getArrayInitializer() == null)) {
       String description = JavaErrorMessages.message("enum.types.cannot.be.instantiated");
       return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
     }
index ac211ff387bac34b733b9674e6b5cdcdca18b2e6..975794d9419fecfd7d80cc241a3b2ef16b8ac9de 100644 (file)
@@ -1181,6 +1181,7 @@ public class HighlightMethodUtil {
             continue;
           }
         }
+        if (JavaGenericsUtil.isRawToGeneric(currentType, otherSuperReturnType)) continue;
       }
       return createIncompatibleReturnTypeMessage(currentMethod, otherSuperMethod, otherSuperReturnType,
                                                  currentType, JavaErrorMessages.message("unrelated.overriding.methods.return.types"),
index 7e3f3b8e46674062dc7f1632bb765c4ac9db78d5..1a52d32cce1da2ba8269ece6d3f48f142c27b0b0 100644 (file)
@@ -760,7 +760,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
     if (!myHolder.hasErrorResults() && method.isConstructor()) {
       myHolder.add(HighlightClassUtil.checkThingNotAllowedInInterface(method, aClass));
     }
-    if (!myHolder.hasErrorResults() && method.hasModifierProperty(PsiModifier.DEFAULT)) {
+    if (!myHolder.hasErrorResults() && (method.hasModifierProperty(PsiModifier.DEFAULT) || 
+                                        aClass != null && aClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC))) {
       myHolder.add(HighlightUtil.checkExtensionMethodsFeature(method, myLanguageLevel, myFile));
     }
 
@@ -1211,9 +1212,11 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
   @Override
   public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
     myHolder.add(HighlightUtil.checkMethodReferencesFeature(expression, myLanguageLevel,myFile));
-    JavaResolveResult result;
+    final JavaResolveResult result;
+    final JavaResolveResult[] results;
     try {
-      result = expression.advancedResolve(true);
+      results = expression.multiResolve(true);
+      result = results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
     }
     catch (IndexNotReadyException e) {
       return;
@@ -1305,6 +1308,35 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
       }
       myHolder.add(GenericsHighlightUtil.checkInferredTypeArguments(typeParameters, expression, result.getSubstitutor()));
     }
+
+    if (!myHolder.hasErrorResults()) {
+      if (results.length == 0) {
+        String description = null;
+        if (expression.isConstructor()) {
+          final PsiClass containingClass = PsiMethodReferenceUtil.getQualifierResolveResult(expression).getContainingClass();
+
+          if (containingClass != null) {
+            if (!myHolder.add(HighlightClassUtil.checkInstantiationOfAbstractClass(containingClass, expression)) &&
+                !myHolder.add(GenericsHighlightUtil.checkEnumInstantiation(expression, containingClass)) &&
+                containingClass.isPhysical()) {
+              description = JavaErrorMessages.message("cannot.resolve.constructor", containingClass.getName());
+            }
+          }
+        }
+        else {
+          description = JavaErrorMessages.message("cannot.resolve.method", expression.getReferenceName());
+        }
+
+        if (description != null) {
+          final PsiElement referenceNameElement = expression.getReferenceNameElement();
+          final HighlightInfo highlightInfo =
+            HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).descriptionAndTooltip(description).range(referenceNameElement).create();
+          myHolder.add(highlightInfo);
+          final TextRange fixRange = HighlightMethodUtil.getFixRange(referenceNameElement);
+          QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QuickFixFactory.getInstance().createCreateMethodFromUsageFix(expression));
+        }
+      }
+    }
   }
 
   @Override
index 017d9a59377835ab61133066ce40f61cf055e191..297913eebce0d67f8db69e5654461f66a2bedfd5 100644 (file)
@@ -255,7 +255,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
           final PsiParameter parameter = foreachStatement.getIterationParameter();
           final PsiIfStatement ifStmt = extractIfStatement(body);
 
-          String foreEachText = body.getText();
+          String foreEachText = wrapInBlock(body);
           String iterated = iteratedValue.getText();
           if (ifStmt != null) {
             final PsiExpression condition = ifStmt.getCondition();
@@ -264,7 +264,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
               LOG.assertTrue(thenBranch != null);
               if (InheritanceUtil.isInheritor(iteratedValue.getType(), CommonClassNames.JAVA_UTIL_COLLECTION)) {
                 body = thenBranch;
-                foreEachText = thenBranch.getText();
+                foreEachText = wrapInBlock(thenBranch);
                 iterated += ".stream().filter(" + parameter.getName() + " -> " + condition.getText() +")";
               }
             }
@@ -298,6 +298,19 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
         }
       }
     }
+
+    private static String wrapInBlock(PsiStatement body) {
+
+      if (body instanceof PsiExpressionStatement) {
+        return ((PsiExpressionStatement)body).getExpression().getText();
+      }
+
+      final String bodyText = body.getText();
+      if (!(body instanceof PsiBlockStatement)) {
+        return "{" + bodyText + "}";
+      }
+      return bodyText;
+    }
   }
 
   private static class ReplaceWithCollectCallFix implements LocalQuickFix {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromMethodReferenceFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromMethodReferenceFix.java
new file mode 100644 (file)
index 0000000..b0c29bf
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2000-2014 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.daemon.impl.quickfix;
+
+import com.intellij.codeInsight.ExpectedTypeInfo;
+import com.intellij.codeInsight.ExpectedTypeInfoImpl;
+import com.intellij.codeInsight.TailType;
+import com.intellij.codeInsight.daemon.QuickFixBundle;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.List;
+
+public class CreateMethodFromMethodReferenceFix extends CreateFromUsageBaseFix {
+  private static final Logger LOG = Logger.getInstance("#" + CreateMethodFromMethodReferenceFix.class.getName());
+
+  private final SmartPsiElementPointer myMethodReferenceExpression;
+
+  public CreateMethodFromMethodReferenceFix(@NotNull PsiMethodReferenceExpression methodRef) {
+    myMethodReferenceExpression = SmartPointerManager.getInstance(methodRef.getProject()).createSmartPsiElementPointer(methodRef);
+  }
+
+  @Override
+  protected boolean isAvailableImpl(int offset) {
+    final PsiMethodReferenceExpression call = getMethodReference();
+    if (call == null || !call.isValid()) return false;
+    final PsiType functionalInterfaceType = call.getFunctionalInterfaceType();
+    if (functionalInterfaceType == null || 
+        LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType) == null){
+      return false;
+    }
+
+    final String name = call.getReferenceName();
+
+    if (name == null) return false;
+    if (call.isConstructor() && name.equals("new") || PsiNameHelper.getInstance(call.getProject()).isIdentifier(name)) {
+      setText(call.isConstructor() ? QuickFixBundle.message("create.constructor.from.new.text") : QuickFixBundle.message("create.method.from.usage.text", name));
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  protected PsiElement getElement() {
+    final PsiMethodReferenceExpression call = getMethodReference();
+    if (call == null || !call.getManager().isInProject(call)) return null;
+    return call;
+  }
+
+  @Override
+  @NotNull
+  protected List<PsiClass> getTargetClasses(PsiElement element) {
+    List<PsiClass> targets = super.getTargetClasses(element);
+    PsiMethodReferenceExpression call = getMethodReference();
+    if (call == null) return Collections.emptyList();
+    return targets;
+  }
+
+  @Override
+  protected void invokeImpl(final PsiClass targetClass) {
+    if (targetClass == null) return;
+    PsiMethodReferenceExpression expression = getMethodReference();
+    if (expression == null) return;
+
+    if (isValidElement(expression)) return;
+
+    PsiClass parentClass = PsiTreeUtil.getParentOfType(expression, PsiClass.class);
+    PsiMember enclosingContext = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, PsiField.class, PsiClassInitializer.class);
+
+    String methodName = expression.getReferenceName();
+    LOG.assertTrue(methodName != null);
+
+
+    final Project project = targetClass.getProject();
+    JVMElementFactory elementFactory = JVMElementFactories.getFactory(targetClass.getLanguage(), project);
+    if (elementFactory == null) elementFactory = JavaPsiFacade.getElementFactory(project);
+
+    PsiMethod method = expression.isConstructor() ? (PsiMethod)targetClass.add(elementFactory.createConstructor()) 
+                                                  : CreateMethodFromUsageFix.createMethod(targetClass, parentClass, enclosingContext, methodName);
+    if (method == null) {
+      return;
+    }
+
+    if (!expression.isConstructor()) {
+      setupVisibility(parentClass, targetClass, method.getModifierList());
+    }
+
+    expression = getMethodReference();
+    LOG.assertTrue(expression.isValid());
+
+    if (!expression.isConstructor() && shouldCreateStaticMember(expression, targetClass)) {
+      PsiUtil.setModifierProperty(method, PsiModifier.STATIC, true);
+    }
+
+    final PsiElement context = PsiTreeUtil.getParentOfType(expression, PsiClass.class, PsiMethod.class);
+
+    final PsiType functionalInterfaceType = expression.getFunctionalInterfaceType();
+    final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
+    final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(classResolveResult);
+    LOG.assertTrue(interfaceMethod != null);
+
+    final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType);
+    LOG.assertTrue(interfaceReturnType != null);
+
+    final ExpectedTypeInfo[] expectedTypes = {new ExpectedTypeInfoImpl(interfaceReturnType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, interfaceReturnType, TailType.NONE, null, ExpectedTypeInfoImpl.NULL)};
+    CreateMethodFromUsageFix.doCreate(targetClass, method, false,
+                                      ContainerUtil.map2List(interfaceMethod.getParameterList().getParameters(), new Function<PsiParameter, Pair<PsiExpression, PsiType>>() {
+                                        @Override
+                                        public Pair<PsiExpression, PsiType> fun(PsiParameter parameter) {
+                                          return Pair.create(null, parameter.getType());
+                                        }
+                                      }),
+                                      LambdaUtil.getSubstitutor(interfaceMethod, classResolveResult),
+                                      expectedTypes, context);
+  }
+
+  
+
+  @Override
+  protected boolean isValidElement(PsiElement element) {
+    return false;
+  }
+
+  @Override
+  @NotNull
+  public String getFamilyName() {
+    return QuickFixBundle.message("create.method.from.usage.family");
+  }
+
+  @Nullable
+  protected PsiMethodReferenceExpression getMethodReference() {
+    return (PsiMethodReferenceExpression)myMethodReferenceExpression.getElement();
+  }
+}
index 3f02e6edc72db8bcb38c5a8c93fc36861ceafc15..3ce012705c0f933993fdcd19f4cf44dd86f8ea79 100644 (file)
@@ -66,7 +66,7 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
     PsiReferenceExpression ref = call.getMethodExpression();
     String name = ref.getReferenceName();
 
-    if (name == null || !JavaPsiFacade.getInstance(ref.getProject()).getNameHelper().isIdentifier(name)) return false;
+    if (name == null || !PsiNameHelper.getInstance(ref.getProject()).isIdentifier(name)) return false;
     if (hasErrorsInArgumentList(call)) return false;
     setText(getDisplayString(name));
     return true;
@@ -133,7 +133,6 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
     if (targetClass == null) return;
     PsiMethodCallExpression expression = getMethodCall();
     if (expression == null) return;
-    final Project project = expression.getProject();
     PsiReferenceExpression ref = expression.getMethodExpression();
 
     if (isValidElement(expression)) return;
@@ -144,30 +143,11 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
     String methodName = ref.getReferenceName();
     LOG.assertTrue(methodName != null);
 
-    JVMElementFactory factory = JVMElementFactories.getFactory(targetClass.getLanguage(), project);
-    if (factory == null) {
+    PsiMethod method = createMethod(targetClass, parentClass, enclosingContext, methodName);
+    if (method == null) {
       return;
     }
 
-    PsiMethod method = factory.createMethod(methodName, PsiType.VOID);
-
-    if (targetClass.equals(parentClass)) {
-      method = (PsiMethod)targetClass.addAfter(method, enclosingContext);
-    }
-    else {
-      PsiElement anchor = enclosingContext;
-      while (anchor != null && anchor.getParent() != null && !anchor.getParent().equals(targetClass)) {
-        anchor = anchor.getParent();
-      }
-      if (anchor != null && anchor.getParent() == null) anchor = null;
-      if (anchor != null) {
-        method = (PsiMethod)targetClass.addAfter(method, anchor);
-      }
-      else {
-        method = (PsiMethod)targetClass.add(method);
-      }
-    }
-
     if (enclosingContext instanceof PsiMethod && methodName.equals(enclosingContext.getName()) &&
         PsiTreeUtil.isAncestor(targetClass, parentClass, true) && !ref.isQualified()) {
       RefactoringChangeUtil.qualifyReference(ref, method, null);
@@ -201,6 +181,36 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
              context);
   }
 
+  protected static PsiMethod createMethod(PsiClass targetClass,
+                                          PsiClass parentClass,
+                                          PsiMember enclosingContext,
+                                          String methodName) {
+    JVMElementFactory factory = JVMElementFactories.getFactory(targetClass.getLanguage(), targetClass.getProject());
+    if (factory == null) {
+      return null;
+    }
+
+    PsiMethod method = factory.createMethod(methodName, PsiType.VOID);
+
+    if (targetClass.equals(parentClass)) {
+      method = (PsiMethod)targetClass.addAfter(method, enclosingContext);
+    }
+    else {
+      PsiElement anchor = enclosingContext;
+      while (anchor != null && anchor.getParent() != null && !anchor.getParent().equals(targetClass)) {
+        anchor = anchor.getParent();
+      }
+      if (anchor != null && anchor.getParent() == null) anchor = null;
+      if (anchor != null) {
+        method = (PsiMethod)targetClass.addAfter(method, anchor);
+      }
+      else {
+        method = (PsiMethod)targetClass.add(method);
+      }
+    }
+    return method;
+  }
+
   public static void doCreate(PsiClass targetClass, PsiMethod method, List<Pair<PsiExpression, PsiType>> arguments, PsiSubstitutor substitutor,
                               ExpectedTypeInfo[] expectedTypes, @Nullable PsiElement context) {
     doCreate(targetClass, method, shouldBeAbstractImpl(targetClass), arguments, substitutor, expectedTypes, context);
@@ -227,8 +237,11 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
     TemplateBuilderImpl builder = new TemplateBuilderImpl(method);
 
     CreateFromUsageUtils.setupMethodParameters(method, builder, context, substitutor, arguments);
-    new GuessTypeParameters(JavaPsiFacade.getInstance(project).getElementFactory())
-      .setupTypeElement(method.getReturnTypeElement(), expectedTypes, substitutor, builder, context, targetClass);
+    final PsiTypeElement returnTypeElement = method.getReturnTypeElement();
+    if (returnTypeElement != null) {
+      new GuessTypeParameters(JavaPsiFacade.getInstance(project).getElementFactory())
+        .setupTypeElement(returnTypeElement, expectedTypes, substitutor, builder, context, targetClass);
+    }
     PsiCodeBlock body = method.getBody();
     builder.setEndVariableAfter(shouldBeAbstract || body == null ? method : body.getLBrace());
     method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
index 768341918c8182eb06e323c58258d9bec0841f92..5f95da053db3ea7ea7006e7a29eebbfa4b078640 100644 (file)
@@ -467,6 +467,12 @@ public class QuickFixFactoryImpl extends QuickFixFactory {
     return new CreateMethodFromUsageFix(call);
   }
 
+  @NotNull
+  @Override
+  public IntentionAction createCreateMethodFromUsageFix(PsiMethodReferenceExpression methodReferenceExpression) {
+    return new CreateMethodFromMethodReferenceFix(methodReferenceExpression);
+  }
+
   @NotNull
   @Override
   public IntentionAction createCreateAbstractMethodFromUsageFix(@NotNull PsiMethodCallExpression call) {
index 809f65d80d7d4c67b3bcf668a27a8426c5530ce8..c59ab2c24cb947b3939333a8c96e8e41eeca777b 100644 (file)
@@ -78,13 +78,15 @@ public class BasePackageParameterFactory extends ProjectTemplateParameterFactory
         HashMap<String, String> map = new HashMap<String, String>(2);
         map.put(getId(), getValue());
         map.put("IJ_BASE_PACKAGE_DIR", getValue().replace('.', '/'));
+        map.put("IJ_BASE_PACKAGE_PREFIX", StringUtil.isEmpty(getValue()) ? "" : getValue() + ".");
         return map;
       }
 
       @Override
       public boolean validate() throws ConfigurationException {
-        if (!PsiNameHelperImpl.getInstance().isQualifiedName(getValue())) {
-          throw new ConfigurationException(getValue() + " is not a valid package name");
+        String value = getValue();
+        if (!StringUtil.isEmpty(value) && !PsiNameHelperImpl.getInstance().isQualifiedName(value)) {
+          throw new ConfigurationException(value + " is not a valid package name");
         }
         return true;
       }
index 0309800ad8139b75729a9cc579576bbed15d5ca9..c3319d2d2ce792639fde1ad0b6bf71eb7f6f3074 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi.impl.smartPointers;
 
+import com.intellij.lang.LanguageUtil;
 import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.util.ProperTextRange;
 import com.intellij.openapi.util.TextRange;
@@ -38,7 +39,7 @@ class AnchorElementInfo extends SelfElementInfo {
 
   AnchorElementInfo(@NotNull PsiElement anchor, @NotNull PsiFile containingFile) {
     super(containingFile.getProject(), ProperTextRange.create(anchor.getTextRange()), anchor.getClass(), containingFile,
-          containingFile.getLanguage());
+          LanguageUtil.getRootLanguage(anchor));
     assert !(anchor instanceof PsiFile) : "FileElementInfo must be used for file: "+anchor;
   }
   // will restore by stub index until file tree get loaded
index ad254be57360db21a260be0d32fbdb8de0255efa..215ca3b30f996b1bab8e347441991367ee8e92e2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -88,7 +88,7 @@ public class SPIFileType extends LanguageFileType implements FileTypeIdentifiabl
 
   @Nullable
   @Override
-  public String getCharset(@NotNull VirtualFile file, byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
     return CharsetToolkit.UTF8;
   }
 }
index 03fcc258406f9acfbbb014c311ad2f6fa429ad04..11be02e80768a3b06864d119eb3f12c2d586a646 100644 (file)
Binary files a/java/java-impl/src/resources/projectTemplates/Java/Command_Line_App.zip and b/java/java-impl/src/resources/projectTemplates/Java/Command_Line_App.zip differ
index eef4824cfbd1e54a0b5f9e9a2cd52a9dc1983c6c..d8dc8ad1e87af1c7901e2882b7853cfd80341ff5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -73,7 +73,7 @@ public class JavaClassFileType implements FileType {
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return null;
   }
 }
index 4d64082d088f9087df2250dcaea248c83fb43487..a3d5ab69da6269cfb91a0c86653c1273dde5a23c 100644 (file)
@@ -849,8 +849,7 @@ public class InferenceSession {
       }
 
       //resolve input variables
-      PsiSubstitutor substitutor = resolveSubset(varsToResolve, siteSubstitutor);
-
+      PsiSubstitutor substitutor = resolveSubset(varsToResolve, retrieveNonPrimitiveEqualsBounds(getInferenceVariables()).putAll(siteSubstitutor));
       if (substitutor == null) {
         return false;
       }
index 9262a2d96c1ea178e84ba6eae36ce8190505211c..a4353788d65ea1f1d785498eb23292d4fdfa2838 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.psi.impl.source.resolve.graphInference.constraints;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
-import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
 import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
 import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
@@ -27,7 +26,8 @@ import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
 
-import java.util.*;
+import java.util.List;
+import java.util.Map;
 
 /**
  * User: anna
@@ -58,10 +58,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
     final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, classResolveResult);
     final PsiParameter[] targetParameters = interfaceMethod.getParameterList().getParameters();
     final PsiType interfaceMethodReturnType = interfaceMethod.getReturnType();
-    PsiType returnType = substitutor.substitute(interfaceMethodReturnType);
-    if (myExpression.getTypeParameters().length == 0 && returnType != null) {
-      returnType = PsiImplUtil.normalizeWildcardTypeByPosition(returnType, myExpression);
-    }
+    final PsiType returnType = substitutor.substitute(interfaceMethodReturnType);
     final PsiType[] typeParameters = myExpression.getTypeParameters();
     if (!myExpression.isExact()) {
       for (PsiParameter parameter : targetParameters) {
index b5b0b7729bdbb924a0af076a984dab5575f6020f..22b0c520f47b541eec6e82d1a44e279f05ea0511 100644 (file)
@@ -426,16 +426,19 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
           final PsiSubstitutor functionalInterfaceSubstitutor = interfaceMethod != null ? LambdaUtil.getSubstitutor(interfaceMethod, resolveResult) : null;
           final MethodSignature signature = interfaceMethod != null ? interfaceMethod.getSignature(functionalInterfaceSubstitutor) : null;
           final PsiType interfaceMethodReturnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType);
-          if (isConstructor && interfaceMethod != null && containingClass.getConstructors().length == 0) {
-            final PsiClassType returnType = composeReturnType(containingClass, substitutor);
-            final InferenceSession session = new InferenceSession(containingClass.getTypeParameters(), substitutor, getManager(), null);
-            if (!(session.isProperType(returnType) && session.isProperType(interfaceMethodReturnType))) {
-              session.registerConstraints(returnType, interfaceMethodReturnType);
-              substitutor = session.infer();
+          if (isConstructor && containingClass.getConstructors().length == 0) {
+            if (interfaceMethod != null) {
+              final PsiClassType returnType = composeReturnType(containingClass, substitutor);
+              final InferenceSession session = new InferenceSession(containingClass.getTypeParameters(), substitutor, getManager(), null);
+              if (!(session.isProperType(returnType) && session.isProperType(interfaceMethodReturnType))) {
+                session.registerConstraints(returnType, interfaceMethodReturnType);
+                substitutor = session.infer();
+              }
             }
             ClassCandidateInfo candidateInfo = null;
             final boolean isArray = containingClass == JavaPsiFacade.getElementFactory(getProject()).getArrayClass(PsiUtil.getLanguageLevel(containingClass));
-            if (!isArray && (containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass)) && signature.getParameterTypes().length == 0 ||
+            if (signature == null ||
+                !isArray && (containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass)) && signature.getParameterTypes().length == 0 ||
                 isArray && arrayCreationSignature(signature)) {
               candidateInfo = new ClassCandidateInfo(containingClass, substitutor);
             }
index d0d4dbc5324afeb6d4d4d91012f601990e950380..ac3eb042da5fb5f96ed5b38fbb1512e862fa1726 100644 (file)
@@ -45,5 +45,6 @@ class UnsupportedFeatures {
 
   interface I {
     <error descr="Extension methods are not supported at this language level">default void m() { }</error>
+    <error descr="Extension methods are not supported at this language level">static void m() { }</error>
   }
 }
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA123316.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA123316.java
new file mode 100644 (file)
index 0000000..101c8f3
--- /dev/null
@@ -0,0 +1,24 @@
+class Temp {
+
+  interface Future<F> {}
+
+  class Message {
+  }
+
+  interface Client<C extends Client, M> {
+    <T> Future<T> request(M request);
+  }
+
+  interface MessageClient extends Client<MessageClient, Message> {
+    Future<Message> request(Message request);
+  }
+
+  abstract class AbstractClient implements MessageClient {
+  }
+
+  class ConcreteClient extends AbstractClient {
+    public Future<Message> request(Message request) {
+      return null;
+    }
+  }
+} 
\ No newline at end of file
index 0c79d849fca7cd50e5d0514015936a948935e659..911f35c615e67af20b670406c4f685786f816854 100644 (file)
@@ -12,7 +12,7 @@ class TypeArgsConsistency {
       I<Integer> i1 = (i, j) -> i + j;
       foo((i, j) -> i + j);
       I<Integer> i2 = bar((i, j) -> i + j);
-      I<Integer> i3 = bar(<error descr="Cyclic inference">(i, j) -> "" + i + j</error>);
+      I<Integer> i3 = bar(<error descr="Incompatible return type String in lambda expression">(i, j) -> "" + i + j</error>);
     }
 }
 
@@ -43,7 +43,7 @@ class TypeArgsConsistency2 {
         I<Integer> i1 = bar(x -> x);
         I1<Integer> i2 = bar1(x -> 1);
         I2<String> aI2 = bar2(x -> "");
-        I2<Integer> aI28 = bar2( <error descr="Cyclic inference">x-> ""</error>);
+        I2<Integer> aI28 = bar2( <error descr="Incompatible return type String in lambda expression">x-> ""</error>);
         I2<Integer> i3 = bar2(x -> x);
         I2<Integer> i4 = bar2(x -> foooI());
         System.out.println(i4.foo(2));
index bc235b224c31b70bb81ca01086b9ce73d5fbfd23..cb76d7470816516c1894f4b7e009f14843f741c6 100644 (file)
@@ -25,9 +25,9 @@ class AlienTest {
     }
 
     static {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i1 = MyTest::abracadabra;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i2 = MyTest::foo;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i3 = MyTest::bar;</error>
+        IInt i1 = MyTest::<error descr="Cannot resolve method 'abracadabra'">abracadabra</error>;
+        IInt i2 = MyTest::<error descr="Cannot resolve method 'foo'">foo</error>;
+        IInt i3 = MyTest::<error descr="Cannot resolve method 'bar'">bar</error>;
         <error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IIntInt'">IIntInt i4 = MyTest::bar;</error>
         IInt i5 = <error descr="Non-static method cannot be referenced from a static context">MyTest::baz</error>;
         IInt i6 = <error descr="'foo(int)' is not public in 'MyTest.Foo'. Cannot be accessed from outside package">MyTest.foo::foo</error>;
index c7f2194a151d96ffd2c71959b0d5d4a82cbaa091..475ae43cdd788aef70bc00f4e99e069c20519496 100644 (file)
@@ -54,7 +54,7 @@ class MyTest1 {
     }
 
     {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'todelete.MyTest1.Bar1'">Bar1 b1 = MyTest2 :: foo;</error>
+        Bar1 b1 = MyTest2 :: <error descr="Cannot resolve method 'foo'">foo</error>;
         bar(MyTest1 :: foo);
     }
 }
@@ -80,7 +80,7 @@ class MyTest2 {
     }*/
 
     {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'todelete.MyTest2.Bar1'">Bar1 b1 = MyTest2 :: foo;</error>
+        Bar1 b1 = MyTest2 :: <error descr="Cannot resolve method 'foo'">foo</error>;
         bar(MyTest2 :: foo);
     }
 }
@@ -106,8 +106,8 @@ class MyTest3 {
     }
 
     {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'todelete.MyTest3.Bar1'">Bar1 b1 = MyTest2 :: foo;</error>
-        bar<error descr="'bar(todelete.MyTest3.Bar2)' in 'todelete.MyTest3' cannot be applied to '(<method reference>)'">(MyTest3 :: foo)</error>;
+        Bar1 b1 = MyTest2 :: <error descr="Cannot resolve method 'foo'">foo</error>;
+        bar(MyTest3 :: <error descr="Cannot resolve method 'foo'">foo</error>);
     }
 }
 
@@ -129,7 +129,7 @@ class MyTest4 {
     }
 
     {
-         bar<error descr="'bar(todelete.MyTest4.Bar1)' in 'todelete.MyTest4' cannot be applied to '(<method reference>)'">(MyTest4:: foo)</error>;
+         bar(MyTest4:: <error descr="Cannot resolve method 'foo'">foo</error>);
     }
 }
 
index 6b8d1fbfa6a52db44fcb24572d83df77c78cd5d3..a5dbcd07db183e056b7702e39db3c37a95248066 100644 (file)
@@ -1,8 +1,8 @@
 class Test {
   {
-      <error descr="Incompatible types. Found: '<method reference>', required: 'java.lang.Runnable'">Runnable b = Test :: length;</error>
+      Runnable b = Test :: <error descr="Cannot resolve method 'length'">length</error>;
       Comparable<String> c = Test :: length;
-      <error descr="Incompatible types. Found: '<method reference>', required: 'java.lang.Comparable<java.lang.Integer>'">Comparable<Integer> c1 =  Test :: length;</error>
+      Comparable<Integer> c1 =  Test :: <error descr="Cannot resolve method 'length'">length</error>;
   }
 
   public static Integer length(String s) {
@@ -16,7 +16,7 @@ class Test {
 
 class Test1 {
     {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'java.lang.Runnable'">Runnable b = Test1 :: length;</error>
+        Runnable b = Test1 :: <error descr="Cannot resolve method 'length'">length</error>;
         Comparable<String> c = Test1 :: length;
         Comparable<Integer> c1 =  Test1 :: length;
     }
index 7c3bff9f386c20ec497d9e40cf2e3f835029311f..145823ff7ebd4feb3405b0726c6fd98eb08f6221 100644 (file)
@@ -13,7 +13,7 @@ class MyTest {
         }
 
         void test() {
-            <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.Child.I'">I var = Child.Inner::new;</error>
+            I var = Child.Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
         }
     }
 }
index c9cb53a5c4d2bd3926b76216eba4b246941e9f99..1b0893c0e0bef35f7fa008a2166358f84dad3393 100644 (file)
@@ -70,8 +70,8 @@ class MyTest3<X> {
     static void test(I<Integer> s) {   }
 
     public static void main(String[] args) {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest3.I<java.lang.Integer>'">I<Integer> s = MyTest3<String>::new;</error>
-        test<error descr="'test(MyTest3.I<java.lang.Integer>)' in 'MyTest3' cannot be applied to '(<method reference>)'">(MyTest3<String>::new)</error>;
+        I<Integer> s = MyTest3<String>::<error descr="Cannot resolve constructor 'MyTest3'">new</error>;
+        test(MyTest3<String>::<error descr="Cannot resolve constructor 'MyTest3'">new</error>);
     }
 }
 
@@ -99,6 +99,6 @@ class MyTestInvalidQ {
     interface I {
       A foo();
     }
-    <error descr="Incompatible types. Found: '<method reference>', required: 'MyTestInvalidQ.A.I'">I i = A :: new;</error>
+    I i = <error descr="'A' is abstract; cannot be instantiated">A :: new</error>;
   }
 }
\ No newline at end of file
index 99337ff597c2f60a5d15296d23b3ea9e57c9826c..887a776275a1f83a232cbb4c36f6e1e2b848bc54 100644 (file)
@@ -88,11 +88,11 @@ class StaticInner2 {
 
 
   static {
-     <error descr="Incompatible types. Found: '<method reference>', required: 'StaticInner2.I1'">I1 i1 = StaticInner2.Inner :: new;</error>
+     I1 i1 = StaticInner2.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
   }
 
   {
-     <error descr="Incompatible types. Found: '<method reference>', required: 'StaticInner2.I1'">I1 i1 = StaticInner2.Inner :: new;</error>
+     I1 i1 = StaticInner2.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
   }
 }
 
@@ -109,11 +109,11 @@ class NonStaticInner2 {
 
 
   static {
-     <error descr="Incompatible types. Found: '<method reference>', required: 'NonStaticInner2.I1'">I1 i1 = NonStaticInner2.Inner :: new;</error>
+     I1 i1 = NonStaticInner2.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
   }
 
   {
-     <error descr="Incompatible types. Found: '<method reference>', required: 'NonStaticInner2.I1'">I1 i1 = NonStaticInner2.Inner :: new;</error>
+     I1 i1 = NonStaticInner2.Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
   }
 }
 
@@ -145,7 +145,7 @@ class NonStaticInner3 {
     }
 
     {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'NonStaticInner3.I3<NonStaticInner3.Foo>'">I3<Foo> b1 = Foo::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'NonStaticInner3.I4<NonStaticInner3.Foo>'">I4<Foo> b2 = Foo::new;</error>
+        I3<Foo> b1 = Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>;
+        I4<Foo> b2 = Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>;
     }
 }
index 25349976f2495ceb4034df2ba892e6387d78a8a2..53cd6381f3f960640e50af477fb37c825abdaad3 100644 (file)
@@ -13,25 +13,25 @@ class DefaultConstructor {
         }
         
         static void test1() {
-            <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,DefaultConstructor.Outer>'">I2<Inner, Outer> i2 = Inner :: new;</error>
-            <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,java.lang.String>'">I2<Inner, String> i2str = Inner :: new;</error>
+            I2<Inner, Outer> i2 = Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
+            I2<Inner, String> i2str = Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
         }
         
         void test2() {
             I1<Inner> i1 = Inner :: new;
             <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I1<java.lang.Integer>'">I1<Integer> i1Int = Inner :: new;</error>
-            <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,DefaultConstructor.Outer>'">I2<Inner, Outer> i2 =  Inner :: new;</error>
+            I2<Inner, Outer> i2 =  Inner :: <error descr="Cannot resolve constructor 'Inner'">new</error>;
         }
     }
     
     static void test1() {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,DefaultConstructor.Outer>'">I2<Outer.Inner, Outer> i2 = Outer.Inner::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,java.lang.String>'">I2<Outer.Inner, String> i2str = Outer.Inner::new;</error>
+        I2<Outer.Inner, Outer> i2 = Outer.Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
+        I2<Outer.Inner, String> i2str = Outer.Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
     }
     
     void test2() {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,DefaultConstructor.Outer>'">I2<Outer.Inner, Outer> i2 = Outer.Inner::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor.I2<DefaultConstructor.Outer.Inner,java.lang.String>'">I2<Outer.Inner, String> i2str = Outer.Inner::new;</error>
+        I2<Outer.Inner, Outer> i2 = Outer.Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
+        I2<Outer.Inner, String> i2str = Outer.Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
     }
 }
 
@@ -52,7 +52,7 @@ class DefaultConstructor2 {
 
 
     void f() {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor2.I'">I i1 = DefaultConstructor2 :: new;</error>
+        I i1 = DefaultConstructor2 :: <error descr="Cannot resolve constructor 'DefaultConstructor2'">new</error>;
         I i2 = <error descr="Cannot find class this">this</error>::new;
     }
 }
@@ -61,7 +61,7 @@ class DefaultConstructor3 {
    public class Inner {}
    public static class StaticInner {}
    
-   static <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor3.I'">I i = Inner::new;</error>
+   static I i = Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
    static I1 i1 = StaticInner::new;
    interface I {
      Inner foo();
@@ -76,8 +76,8 @@ class DefaultConstructor4 {
    public class Inner {}
    public static class StaticInner {}
    
-   static <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor4.I'">I i = Inner::new;</error>
-   static <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor4.I1'">I1 i1 = StaticInner::new;</error>
+   static I i = Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
+   static I1 i1 = StaticInner::<error descr="Cannot resolve constructor 'StaticInner'">new</error>;
    interface I {
      Inner foo(DefaultConstructor4 receiver);
    }
@@ -91,7 +91,7 @@ class DefaultConstructor5 {
     public class Inner {}
 
     static void test() {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'DefaultConstructor5.I'">I i = Inner::new;</error>
+        I i = Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;
     }
 
     void test1() {
index f3bc8d4b8a6c0ce503ee98c81efd7bc8e0df692c..632f83b23701acfe404faf471b37acc7dbd8f5ab 100644 (file)
@@ -5,7 +5,7 @@ class ThreadExample {
     }
     {
         A a = new A();
-        <error descr="Incompatible types. Found: '<method reference>', required: 'ThreadExample.Function<? super ThreadExample.A,? extends java.lang.String>'">Function<? super A,? extends String> foo = a::foo;</error>
+        Function<? super A,? extends String> foo = a::<error descr="Cannot resolve method 'foo'">foo</error>;
     }
 
     static class A {
index 315a8e0c8dffa89b4a8b4153794bf5978905c00f..75f049fefef7e0be9a23ae13f6d5e3976bb62406 100644 (file)
@@ -22,20 +22,20 @@ class Test {
     void foo(IFactory cf) { }
 
     void testAssign() {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'Test.IFactory'">IFactory c1 = Anno::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'Test.IFactory'">IFactory c2 = E::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'Test.IFactory'">IFactory c3 = I::new;</error>
+        IFactory c1 = <error descr="'Anno' is abstract; cannot be instantiated">Anno::new</error>;
+        IFactory c2 = <error descr="Enum types cannot be instantiated">E::new</error>;
+        IFactory c3 = <error descr="'I' is abstract; cannot be instantiated">I::new</error>;
         IFactory c4 = <error descr="Unexpected wildcard">Foo<?></error>::new;
         IFactory c5 = <error descr="Cannot find class 1">1</error>::new;
-        <error descr="Incompatible types. Found: '<method reference>', required: 'Test.IFactory'">IFactory c6 = ABar::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'Test.IFactory'">IFactory c7 = ABaz::new;</error>
+        IFactory c6 = <error descr="'ABar' is abstract; cannot be instantiated">ABar::new</error>;
+        IFactory c7 = <error descr="'ABaz' is abstract; cannot be instantiated">ABaz::new</error>;
 
-        foo<error descr="'foo(Test.IFactory)' in 'Test' cannot be applied to '(<method reference>)'">(Anno::new)</error>;
-        foo<error descr="'foo(Test.IFactory)' in 'Test' cannot be applied to '(<method reference>)'">(E::new)</error>;
-        foo<error descr="'foo(Test.IFactory)' in 'Test' cannot be applied to '(<method reference>)'">(I::new)</error>;
+        foo(<error descr="'Anno' is abstract; cannot be instantiated">Anno::new</error>);
+        foo(<error descr="Enum types cannot be instantiated">E::new</error>);
+        foo(<error descr="'I' is abstract; cannot be instantiated">I::new</error>);
         foo(<error descr="Unexpected wildcard">Foo<?></error>::new);
         foo(<error descr="Cannot find class 1">1</error>::new);
-        foo<error descr="'foo(Test.IFactory)' in 'Test' cannot be applied to '(<method reference>)'">(ABar::new)</error>;
-        foo<error descr="'foo(Test.IFactory)' in 'Test' cannot be applied to '(<method reference>)'">(ABaz::new)</error>;
+        foo(<error descr="'ABar' is abstract; cannot be instantiated">ABar::new</error>);
+        foo(<error descr="'ABaz' is abstract; cannot be instantiated">ABaz::new</error>);
     }
 }
\ No newline at end of file
index bd9c9ca188d951f44b99e610f1b24f1211a33266..14b9a2baa2b276dc63d21250b2128785c599394b 100644 (file)
@@ -144,10 +144,10 @@ class MyTest7{
     enum E { }
     
     void test() {
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest7.I'">I s1 = A::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest7.I'">I s2 = I::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest7.I'">I s3 = AC::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest7.I'">I s4 = E::new;</error>
+        I s1 = <error descr="'A' is abstract; cannot be instantiated">A::new</error>;
+        I s2 = <error descr="'I' is abstract; cannot be instantiated">I::new</error>;
+        I s3 = <error descr="'AC' is abstract; cannot be instantiated">AC::new</error>;
+        I s4 = <error descr="Enum types cannot be instantiated">E::new</error>;
     }
 }
 
@@ -165,7 +165,7 @@ class MyTest8{
         }
 
         void test() {
-            <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest8.Sub.I'">I var = Sub.Inner::new;</error>;
+            I var = Sub.Inner::<error descr="Cannot resolve constructor 'Inner'">new</error>;;
         }
     }
 }
index 7c1e04f2dc5e050d4731e2060efe1c1d06b2d67d..f88c5bf76c051204e4933fee5a00f14c2d4d241d 100644 (file)
@@ -12,7 +12,7 @@ class MyTest {
 
     {
       I i = Foo<String> :: foo;
-      <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I'">I i1 = Foo<Integer> :: foo;</error>
+      I i1 = Foo<Integer> :: <error descr="Cannot resolve method 'foo'">foo</error>;
     }
   }
 }
index ed1efe80d21db10051608a1679c79ba926c872e6..f11a6dedddc93b270553edbbfcd190b14aac2bb1 100644 (file)
@@ -34,7 +34,7 @@ class OnArrayTest {
         Cln s =  int[]::clone;
         IA a =  int[]::new;
         <error descr="Incompatible types. Found: '<method reference>', required: 'OnArrayTest.I'">I i = int[]::new;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'OnArrayTest.Len<java.lang.String>'">Len<String> strLen = String[]::length;</error>
+        Len<String> strLen = String[]::<error descr="Cannot resolve method 'length'">length</error>;
         ToStr<Integer> toStr = Integer[]::toString;
 
         ArrayReturnType<String[]> a1 = String[]::new;
index e521df2c2d40383a2d0d71fdf63c432509a51c38..db0dd15780833755ed8e553f58698c2d31134114 100644 (file)
@@ -48,27 +48,27 @@ class MyTest {
 
     static {
         I1 i1 = MyTest::static_1;
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i2 = MyTest::static_2;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i3 = MyTest::static_3;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i4 = MyTest::static_4;</error>
+        I1 i2 = MyTest::<error descr="Cannot resolve method 'static_2'">static_2</error>;
+        I1 i3 = MyTest::<error descr="Cannot resolve method 'static_3'">static_3</error>;
+        I1 i4 = MyTest::<error descr="Cannot resolve method 'static_4'">static_4</error>;
     }
 
 
     {
         I1 i_1 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_1</error>;
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_2 = MyTest::_2;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_3 = MyTest::_3;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_4 = MyTest::_4;</error>
+        I1 i_2 = MyTest::<error descr="Cannot resolve method '_2'">_2</error>;
+        I1 i_3 = MyTest::<error descr="Cannot resolve method '_3'">_3</error>;
+        I1 i_4 = MyTest::<error descr="Cannot resolve method '_4'">_4</error>;
 
         I1 i1 = this::_1;
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i2 = this::_2;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i3 = this::_3;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i4 = this::_4;</error>
-
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I2'">I2 i21 = MyTest::m1;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I2'">I2 i22 = MyTest::m2;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I2'">I2 i23 = MyTest::m3;</error>
-        <error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I2'">I2 i24 = MyTest::m4;</error>
+        I1 i2 = this::<error descr="Cannot resolve method '_2'">_2</error>;
+        I1 i3 = this::<error descr="Cannot resolve method '_3'">_3</error>;
+        I1 i4 = this::<error descr="Cannot resolve method '_4'">_4</error>;
+
+        I2 i21 = MyTest::<error descr="Cannot resolve method 'm1'">m1</error>;
+        I2 i22 = MyTest::<error descr="Cannot resolve method 'm2'">m2</error>;
+        I2 i23 = MyTest::<error descr="Cannot resolve method 'm3'">m3</error>;
+        I2 i24 = MyTest::<error descr="Cannot resolve method 'm4'">m4</error>;
     }
 }
 
index cf2151dc76d8f80d7921b7305b5cd9b9971f414d..b34634cfa6a0c607b82cbadb27c4f4f22e50d4c4 100644 (file)
@@ -4,7 +4,7 @@ class Test {
     void test() {
         Comparator<Test> r2 = Test::yyy;
         Comparator1<Test> c1 = <error descr="Non-static method cannot be referenced from a static context">Test::yyy</error>;
-        <error descr="Incompatible types. Found: '<method reference>', required: 'Comparator1<Test>'">Comparator1<Test> c2 = Test::xxx;</error>
+        Comparator1<Test> c2 = Test::<error descr="Cannot resolve method 'xxx'">xxx</error>;
     }
     int yyy(Test... p) { return 1; }
     int xxx(Test t) {return 42;}
index 77c670063cd2d5072d8b53560395dcf564245d70..9449054c0a18173d999d75adfd805208cddde1bf 100644 (file)
@@ -10,6 +10,6 @@ class Test {
     <T> void bar(I i) {}
 
     void test() {
-        bar<error descr="'bar(Test.I)' in 'Test' cannot be applied to '(<method reference>)'">(Foo::foo)</error>;
+        bar(Foo::<error descr="Cannot resolve method 'foo'">foo</error>);
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA123223.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA123223.java
new file mode 100644 (file)
index 0000000..becb426
--- /dev/null
@@ -0,0 +1,31 @@
+import java.util.List;
+import java.util.function.Function;
+
+class FluTr<K> {
+
+  class Group {
+    List<Authority> getAuthorities() {
+      return null;
+    }
+  }
+
+  class Authority {
+    String getPermission() {
+      return null;
+    }
+  }
+
+  public void filterForPermission(final String permission) {
+    transformAndConcat(Group::getAuthorities)
+      .transform(Authority::getPermission)
+      .contains(permission);
+  }
+
+  boolean contains(String f) {
+    return false;
+  }
+
+  public final <T> FluTr<T> transform(Function<? super K,T> function) { return null; }
+  public <T> FluTr<T> transformAndConcat(Function<? super Group,? extends Iterable<? extends T>> function) { return null; }
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA123248.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA123248.java
new file mode 100644 (file)
index 0000000..bedd4e2
--- /dev/null
@@ -0,0 +1,11 @@
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Stream;
+
+class App {
+
+  void foo(Stream<Integer> boxed) {
+    final Map<Integer, Integer> count = boxed.collect(HashMap::new, null, HashMap::putAll);
+  }
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterConstructor.java
new file mode 100644 (file)
index 0000000..4c5e012
--- /dev/null
@@ -0,0 +1,13 @@
+// "Create Constructor" "true"
+class FooBar {
+  FooBar(int i) {
+  }
+
+  {
+    Runnable r = FooBar::new;
+  }
+
+    public FooBar() {
+        
+    }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterReferenceType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterReferenceType.java
new file mode 100644 (file)
index 0000000..7c81889
--- /dev/null
@@ -0,0 +1,10 @@
+// "Create Method 'fooBar'" "true"
+class FooBar {
+  {
+    Runnable r = FooBar::fooBar;
+  }
+
+    private static void fooBar() {
+        
+    }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterThisType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/afterThisType.java
new file mode 100644 (file)
index 0000000..f1d2b64
--- /dev/null
@@ -0,0 +1,10 @@
+// "Create Method 'fooBar'" "true"
+class FooBar {
+  {
+    Runnable r = this::fooBar;
+  }
+
+    private void fooBar() {
+        
+    }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeConstructor.java
new file mode 100644 (file)
index 0000000..5660b9f
--- /dev/null
@@ -0,0 +1,9 @@
+// "Create Constructor" "true"
+class FooBar {
+  FooBar(int i) {
+  }
+
+  {
+    Runnable r = FooBar::ne<caret>w;
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeReferenceType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeReferenceType.java
new file mode 100644 (file)
index 0000000..6430bdb
--- /dev/null
@@ -0,0 +1,6 @@
+// "Create Method 'fooBar'" "true"
+class FooBar {
+  {
+    Runnable r = FooBar::foo<caret>Bar;
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeThisType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef/beforeThisType.java
new file mode 100644 (file)
index 0000000..9f3e0d8
--- /dev/null
@@ -0,0 +1,6 @@
+// "Create Method 'fooBar'" "true"
+class FooBar {
+  {
+    Runnable r = this::foo<caret>Bar;
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMissedBraces.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMissedBraces.java
new file mode 100644 (file)
index 0000000..6cfe43a
--- /dev/null
@@ -0,0 +1,13 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+  List<String> foo = new ArrayList<>();
+  String foo(){
+      foo.stream().filter(s -> s == null).forEach(s -> {
+          int i = 0;
+      });
+    return null;
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMissedBraces.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMissedBraces.java
new file mode 100644 (file)
index 0000000..f366f2f
--- /dev/null
@@ -0,0 +1,13 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+  List<String> foo = new ArrayList<>();
+  String foo(){
+    for (String s : fo<caret>o) {
+      if (s == null) int i = 0;
+    }
+    return null;
+  }
+}
index a4b5330a289f99fe551ad740fd27dfe810c74cbf..6e02ab00eb5602257f46a8a65899e258b9990b00 100644 (file)
@@ -4,7 +4,7 @@ interface SAM<X> {
 
 class Foo {  
     void test() {
-        SAM<X> c = (i, j) -> "" + i + j;
+        SAM<Integer> c = (i, j) -> "" + i + j;
         SAM<Integer> s3 = m(c);
     }
     <X> SAM<X> m(SAM<X> s) { return null; }
index f45d3cb77c37d30848a4032d1f23797888daa635..17479ab92534f91338309b1bc0b9fcca40f7ee68 100644 (file)
@@ -340,6 +340,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
   public void testIDEA120153() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
   public void testIDEA120563() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
   public void testIDEA121400() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+  public void testIDEA123316() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
 
   public void testJavaUtilCollections_NoVerify() throws Exception {
     PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
index 4cccb61dabf931c507bed7a20a3e20d95bb123b1..3b095b9c82d7c908046a1acf614aff579c5ad303 100644 (file)
@@ -217,6 +217,14 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest();
   }
 
+  public void testIDEA123223() throws Exception {
+    doTest();
+  }
+
+  public void testIDEA123248() throws Exception {
+    doTest();
+  }
+
   private void doTest() {
     doTest(false);
   }
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromMethodReferenceFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromMethodReferenceFixTest.java
new file mode 100644 (file)
index 0000000..6182f87
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2014 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.daemon.quickFix;
+
+public class CreateMethodFromMethodReferenceFixTest extends LightQuickFixParameterizedTestCase {
+  public void test() throws Exception { doAllTests(); }
+
+  @Override
+  protected String getBasePath() {
+    return "/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromMethodRef";
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/ide/fileTemplates/SimpleTemplatesTest.java b/java/java-tests/testSrc/com/intellij/ide/fileTemplates/SimpleTemplatesTest.java
new file mode 100644 (file)
index 0000000..193dd7d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2014 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.ide.fileTemplates;
+
+import com.intellij.ide.fileTemplates.impl.CustomFileTemplate;
+import com.intellij.testFramework.IdeaTestCase;
+import com.intellij.testFramework.LightPlatformTestCase;
+
+import java.util.Properties;
+
+/**
+ * @author Dmitry Avdeev
+ */
+public class SimpleTemplatesTest extends LightPlatformTestCase {
+
+  @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
+  public SimpleTemplatesTest() {
+    IdeaTestCase.initPlatformPrefix();
+  }
+
+  public void testConditional() throws Exception {
+    CustomFileTemplate template = new CustomFileTemplate("foo", "bar");
+    template.setText("#set($flag = \"$!IJ_BASE_PACKAGE\" != \"\")\n" +
+                     "<option name=\"MAIN_CLASS_NAME\" value=\"$IJ_BASE_PACKAGE#if($flag).#{end}Main\" />"
+    );
+    Properties attributes = new Properties();
+    attributes.setProperty("IJ_BASE_PACKAGE", "");
+    assertEquals("<option name=\"MAIN_CLASS_NAME\" value=\"Main\" />", template.getText(attributes));
+    attributes.setProperty("IJ_BASE_PACKAGE", "foo.bar");
+    assertEquals("<option name=\"MAIN_CLASS_NAME\" value=\"foo.bar.Main\" />", template.getText(attributes));
+  }
+
+  public void testInline() throws Exception {
+    CustomFileTemplate template = new CustomFileTemplate("foo", "bar");
+    template.setText("$IJ_BASE_PACKAGE.replace(\".\", \"/\")");
+    Properties attributes = new Properties();
+    attributes.setProperty("IJ_BASE_PACKAGE", "foo.bar");
+    assertEquals("foo/bar", template.getText(attributes));
+  }
+}
index 7d2dd108ceac1f49b2e112844e3dae795564d8e7..0b5d48dcfa9128c456ae66519b16a245ee831dc4 100644 (file)
@@ -59,7 +59,7 @@ public class StringIndex {
   private static class Indexer implements DataIndexer<String, String, PathContentPair> {
     @Override
     @NotNull
-    public Map<String,String> map(final PathContentPair inputData) {
+    public Map<String,String> map(@NotNull final PathContentPair inputData) {
       final Map<String,String> _map = new HashMap<String, String>();
       final StringBuilder builder = new StringBuilder();
       final String content = inputData.content;
index 1d0db9f7a9dbaa0868ba74dc89ee5583473dc2db..34745372977e60124b01f7b15ed4c7c4f93ba6f3 100644 (file)
@@ -433,7 +433,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
   }
 
   public void testLambdaExprNotAccepted() {
-    doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<X>"));
+    doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.Integer>"));
   }
 
   public void testOneLineLambdaVoidCompatible() {
index d7f46af4743701e213c6e0ebb7aaaec71e5a2ce5..7cf0a804f7c9f2015db6472d8fa3cfb3f61e4fec 100644 (file)
@@ -513,15 +513,20 @@ public class IncProjectBuilder {
       context.checkCanceled();
       boolean okToDelete = true;
       final File outputRoot = entry.getKey();
-      if (JpsPathUtil.isUnder(allSourceRoots, outputRoot)) {
-        okToDelete = false;
-      }
-      else {
-        final Set<File> _outRoot = Collections.singleton(outputRoot);
-        for (File srcRoot : allSourceRoots) {
-          if (JpsPathUtil.isUnder(_outRoot, srcRoot)) {
-            okToDelete = false;
-            break;
+      if (!moduleIndex.isExcluded(outputRoot)) {
+        // if output root itself is directly or indirectly excluded, 
+        // there cannot be any manageable sources under it, even if the output root is located under some source root
+        // so in this case it is safe to delete such root
+        if (JpsPathUtil.isUnder(allSourceRoots, outputRoot)) {
+          okToDelete = false;
+        }
+        else {
+          final Set<File> _outRoot = Collections.singleton(outputRoot);
+          for (File srcRoot : allSourceRoots) {
+            if (JpsPathUtil.isUnder(_outRoot, srcRoot)) {
+              okToDelete = false;
+              break;
+            }
           }
         }
       }
index 953fef28dd82b674048eed470aad827772c5778f..7b50a082eb1afaaae0c3b2d8ab946e5b5fb4b03e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$/testSrc">
       <sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
index 86bfb44bb35f99b651e61998f38ca56a925c4c7b..894dfedadd5e9c5a8e161fb76de4d859b69220c5 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
index 2f3ed7f10bf2526add884781848de464d922be59..c83fcebb709c5d2896aa7e22171b77abb51bd8e2 100644 (file)
Binary files a/lib/asm-all.jar and b/lib/asm-all.jar differ
index 72b2b9bae445fb00e2a3cb8c350bef4a43568f6c..4c61d42cb84f6208d4720330aa030c9f236902b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -69,7 +69,7 @@ public class ArchiveFileType implements FileType {
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return null;
   }
 }
index cdb92e41194baf935d320ec85d58fcf4b957153e..b5e2313628f2f05cc40aa9dfc0a2b69cb7df06c5 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.lang;
 
 import com.intellij.lexer.Lexer;
 import com.intellij.openapi.util.Condition;
+import com.intellij.psi.FileViewProvider;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.templateLanguages.TemplateLanguage;
@@ -27,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.util.Comparator;
 import java.util.List;
+import java.util.Set;
 
 public final class LanguageUtil {
   private LanguageUtil() {
@@ -90,4 +92,19 @@ public final class LanguageUtil {
     }
     return true;
   }
+
+  @NotNull
+  public static Language getRootLanguage(@NotNull PsiElement element) {
+    final FileViewProvider provider = element.getContainingFile().getViewProvider();
+    final Set<Language> languages = provider.getLanguages();
+    if (languages.size() > 1) {
+      PsiElement current = element;
+      while (current != null) {
+        final Language language = current.getLanguage();
+        if (languages.contains(language)) return language;
+        current = current.getParent();
+      }
+    }
+    return provider.getBaseLanguage();
+  }
 }
index 97c85807817ad98953369c5256e38c5a2ce45319..40a04418b3114177602b66ad431040b67b4b2f56 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@ public interface FileType extends Scheme {
    * Returns the name of the file type. The name must be unique among all file types registered in the system.
    * @return The file type name.
    */
-
   @Override
   @NotNull
   @NonNls
@@ -82,12 +81,11 @@ public interface FileType extends Scheme {
   /**
    * Returns the character set for the specified file.
    * @param file The file for which the character set is requested.
-   * @param content
    * @return The character set name, in the format supported by {@link java.nio.charset.Charset} class.
    */
 
   @Nullable
   @NonNls
-  String getCharset(@NotNull VirtualFile file, final byte[] content);
+  String getCharset(@NotNull VirtualFile file, @NotNull byte[] content);
 
 }
index 9fc9f112053a55114a52ac1e4598c77ea30d9c1f..4e74b2d043ecce2b9bc20f8b8602ecca3a746842 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -58,7 +58,7 @@ public abstract class LanguageFileType implements FileType{
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return null;
   }
 
index 6b71c76a52065aa6c56fbd627c0e0b765724f237..5e34421c6ca3daba7c88465932834d23e63917a8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -68,7 +68,7 @@ public class UnknownFileType implements FileType {
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return null;
   }
 }
index be7c12587b7371978d35792edca8080d08c42993..8c42ce71835ca9361e0a70fd12e2d5d88a86ab94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.intellij.openapi.util.io.FileUtilRt;
 public class PersistentFSConstants {
   public static final long FILE_LENGTH_TO_CACHE_THRESHOLD = FileUtilRt.LARGE_FOR_CONTENT_LOADING;
   /**
-   * always  in range [0, PersistentFS.FILE_LENGTH_TO_CACHE_THRESHOLD]
+   * always  in range [0, {@link #FILE_LENGTH_TO_CACHE_THRESHOLD}]
    */
   private static int ourMaxIntellisenseFileSize = Math.min(FileUtilRt.getUserFileSizeLimit(), (int)FILE_LENGTH_TO_CACHE_THRESHOLD);
 
index 830b6f4d40c41433d5f7fa13dc28aaa8887b990f..2448646dd63e49f23b70a309356bf43e799811d0 100644 (file)
@@ -876,7 +876,7 @@ public class PluginManagerCore {
     final String pathProperty = System.getProperty(PROPERTY_PLUGIN_PATH);
     if (pathProperty == null) return;
 
-    for (StringTokenizer t = new StringTokenizer(pathProperty, File.pathSeparator); t.hasMoreTokens();) {
+    for (StringTokenizer t = new StringTokenizer(pathProperty, File.pathSeparator + ","); t.hasMoreTokens();) {
       String s = t.nextToken();
       final IdeaPluginDescriptorImpl ideaPluginDescriptor = loadDescriptor(new File(s), PLUGIN_XML);
       if (ideaPluginDescriptor != null) {
index 5ea2cdbf8ee94f0cb9f218a685e946eb2250a556..748a98ead7de73b8605075e9713761cf31926871 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.psi.impl.smartPointers;
 
 import com.intellij.lang.Language;
+import com.intellij.lang.LanguageUtil;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.RangeMarker;
@@ -48,7 +49,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
 
   protected SelfElementInfo(@NotNull Project project, @NotNull PsiElement anchor) {
     this(project, ProperTextRange.create(anchor.getTextRange()), anchor.getClass(), anchor.getContainingFile(),
-         anchor.getContainingFile().getLanguage());
+         LanguageUtil.getRootLanguage(anchor));
   }
   public SelfElementInfo(@NotNull Project project,
                          @NotNull ProperTextRange range,
index 7c66ef4539fa628065b5ed33d6b9cfe2c3cbc58b..9e755ad5a61530b6792db61d0c23625783be0a42 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.intellij.psi.impl.smartPointers;
 
+import com.intellij.lang.LanguageUtil;
 import com.intellij.lang.injection.InjectedLanguageManager;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Document;
@@ -161,7 +162,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
     }
     ProperTextRange proper = ProperTextRange.create(elementRange);
 
-    return new SelfElementInfo(project, proper, element.getClass(), containingFile, containingFile.getLanguage());
+    return new SelfElementInfo(project, proper, element.getClass(), containingFile, LanguageUtil.getRootLanguage(element));
   }
 
   @Override
index 5137ace2d63de2d47b6d40cfdc1f5affe46b3a03..c6b4d0ffb12dd2e013159ad5b4b998bf2799d3ff 100644 (file)
@@ -37,7 +37,6 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileWithId;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.*;
-import com.intellij.psi.impl.cache.CacheUtil;
 import com.intellij.psi.impl.file.PsiFileImplUtil;
 import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
 import com.intellij.psi.impl.source.resolve.FileContextUtil;
@@ -57,7 +56,6 @@ import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.PatchedWeakReference;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.text.CharArrayUtil;
-import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -345,7 +343,9 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
   }
 
   private void scheduleDropCachesWithInvalidStubPsi() {
-    UIUtil.invokeLaterIfNeeded(new Runnable() {
+    // invokeLater even if already on EDT, because
+    // we might be inside an index query and write actions might result in deadlocks there (http://youtrack.jetbrains.com/issue/IDEA-123118)
+    ApplicationManager.getApplication().invokeLater(new Runnable() {
       @Override
       public void run() {
         ApplicationManager.getApplication().runWriteAction(new Runnable() {
index f320f856f5412ce7f2fb6ef3966cfb6c20a0b2be..d39126e0d1c67c60a028c0ac1b646fbf121d4105 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -73,7 +73,7 @@ public final class FileContentImpl extends UserDataHolderBase implements FileCon
     return psi;
   }
 
-  public PsiFile createFileFromText(CharSequence text) {
+  public PsiFile createFileFromText(@NotNull CharSequence text) {
     Project project = getProject();
     if (project == null) {
       project = DefaultProjectFactory.getInstance().getDefaultProject();
@@ -105,7 +105,11 @@ public final class FileContentImpl extends UserDataHolderBase implements FileCon
     this(file, null, null, null, -1);
   }
 
-  private FileContentImpl(@NotNull VirtualFile file, CharSequence contentAsText, byte[] content, Charset charset, long stamp) {
+  private FileContentImpl(@NotNull VirtualFile file,
+                          CharSequence contentAsText,
+                          byte[] content,
+                          Charset charset,
+                          long stamp) {
     myFile = file;
     myContentAsText = contentAsText;
     myContent = content;
index 3af0ef4665b9f1f09e49762c0a247505494cef0a..83c257338a5c42b8c14a616f3591bfed604e2d11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -81,7 +81,7 @@ public class SubstitutedFileType extends LanguageFileType{
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
     return myFileType.getCharset(file, content);
   }
 
index febee0d328f1c2f971137d6f644e92ac78274dcc..330dcfdf5e6ab5e7acc007b539fd6939993283da 100644 (file)
@@ -125,7 +125,7 @@ public abstract class PlatformIdTableBuilding {
 
     @NotNull
     @Override
-    public Map<TodoIndexEntry, Integer> map(FileContent inputData) {
+    public Map<TodoIndexEntry, Integer> map(@NotNull FileContent inputData) {
       Map<TodoIndexEntry, Integer> result = ContainerUtil.newTroveMap();
       for (DataIndexer<TodoIndexEntry, Integer, FileContent> indexer : indexers) {
         for (Map.Entry<TodoIndexEntry, Integer> entry : indexer.map(inputData).entrySet()) {
@@ -152,7 +152,7 @@ public abstract class PlatformIdTableBuilding {
 
     @Override
     @NotNull
-    public Map<TodoIndexEntry, Integer> map(final FileContent inputData) {
+    public Map<TodoIndexEntry, Integer> map(@NotNull final FileContent inputData) {
       if (IndexPatternUtil.getIndexPatternCount() > 0) {
         final CharSequence chars = inputData.getContentAsText();
         final OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
@@ -204,7 +204,7 @@ public abstract class PlatformIdTableBuilding {
   public static class PlainTextTodoIndexer implements DataIndexer<TodoIndexEntry, Integer, FileContent> {
     @Override
     @NotNull
-    public Map<TodoIndexEntry, Integer> map(final FileContent inputData) {
+    public Map<TodoIndexEntry, Integer> map(@NotNull final FileContent inputData) {
       String chars = inputData.getContentAsText().toString(); // matching strings is faster than HeapCharBuffer
 
       final IndexPattern[] indexPatterns = IndexPatternUtil.getIndexPatterns();
index 08eab82f0dcff3ce2a38d411a2222b77dd6ccfdb..86372ccbc60a7fbeb51c1fe86c2acbef22022966 100644 (file)
@@ -93,7 +93,7 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
   private final DataIndexer<TodoIndexEntry, Integer, FileContent> myIndexer = new DataIndexer<TodoIndexEntry, Integer, FileContent>() {
     @Override
     @NotNull
-    public Map<TodoIndexEntry,Integer> map(final FileContent inputData) {
+    public Map<TodoIndexEntry,Integer> map(@NotNull final FileContent inputData) {
       final VirtualFile file = inputData.getFile();
       final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = PlatformIdTableBuilding
         .getTodoIndexer(inputData.getFileType(), file);
index e195238eec95cf8d18cdd2055b20549cb4a62920..2df3fb54f275282a4dd2ae7f7c71eb55d079788b 100644 (file)
@@ -47,8 +47,8 @@ action.open.config.text=Open {0} config
 action.open.config.description=Allows to open project file of the linked {0} project at the editor
 
 # Notification
-notification.project.refresh.fail.description={0} ''{1}'' project refresh failed:\n{2}
-notification.action.show.settings=<a href="configure">{0} settings</a>
+notification.project.refresh.fail.title={0} ''{1}'' project refresh failed
+notification.messages.project.sync.tab.name={0} Sync
 
 # Tasks.
 tasks.recent.title=Recent tasks
index 11a5f5ef967f4c35c57b9d730025cb10551e51c7..6c7eae51ab9ec22aa9b0fb9db079700dd5dddb38 100644 (file)
@@ -24,6 +24,9 @@ public class ExternalSystemException extends RuntimeException {
   
   private final String myOriginalReason;
 
+  @NotNull
+  private final String[] myQuickFixes;
+
   public ExternalSystemException() {
     this(null, null);
   }
@@ -36,8 +39,9 @@ public class ExternalSystemException extends RuntimeException {
     this("", cause);
   }
 
-  public ExternalSystemException(@Nullable String message, @Nullable Throwable cause) {
+  public ExternalSystemException(@Nullable String message, @Nullable Throwable cause, @NotNull String... quickFixes) {
     super(extractMessage(message, cause));
+    myQuickFixes = quickFixes;
     if (cause == null) {
       myOriginalReason = "";
       return;
@@ -62,6 +66,11 @@ public class ExternalSystemException extends RuntimeException {
     return myOriginalReason;
   }
 
+  @NotNull
+  public String[] getQuickFixes() {
+    return myQuickFixes;
+  }
+
   @Override
   public void printStackTrace(PrintWriter s) {
     super.printStackTrace(s);
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/LocationAwareExternalSystemException.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/LocationAwareExternalSystemException.java
new file mode 100644 (file)
index 0000000..cfe7a74
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2014 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.externalSystem.model;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/26/14
+ */
+public class LocationAwareExternalSystemException extends ExternalSystemException {
+  private final String myFilePath;
+  private final Integer myLine;
+  private final Integer myColumn;
+
+  public LocationAwareExternalSystemException(@Nullable String message, String filePath, @NotNull String... quickFixes) {
+    this(message, null, filePath, -1, -1, quickFixes);
+  }
+
+  public LocationAwareExternalSystemException(@Nullable String message, String filePath, Integer line, @NotNull String... quickFixes) {
+    this(message, null, filePath, line, -1, quickFixes);
+  }
+
+  public LocationAwareExternalSystemException(@Nullable String message, String filePath, Integer line, Integer column, @NotNull String... quickFixes) {
+    this(message, null, filePath, line, column, quickFixes);
+  }
+
+  public LocationAwareExternalSystemException(@Nullable Throwable cause, String filePath, Integer line, Integer column, @NotNull String... quickFixes) {
+    this(null, cause, filePath, line, column, quickFixes);
+  }
+
+  public LocationAwareExternalSystemException(@Nullable String message,
+                                              @Nullable Throwable cause,
+                                              String filePath,
+                                              Integer line,
+                                              Integer column,
+                                              @NotNull String... quickFixes) {
+    super(message, cause, quickFixes);
+    myFilePath = filePath;
+    myLine = line;
+    myColumn = column;
+  }
+
+  public String getFilePath() {
+    return myFilePath;
+  }
+
+  public Integer getLine() {
+    return myLine;
+  }
+
+  public Integer getColumn() {
+    return myColumn;
+  }
+}
index 6ed82492ce745275bd3b9d7a8829636167c8712b..eda9ad99da16f66e0b3f1bcefadc8c05c9f676cf 100644 (file)
@@ -403,7 +403,7 @@ public class ExternalSystemApiUtil {
     if (unitTestMode) {
       UIUtil.invokeLaterIfNeeded(runnable);
     }
-    else if (application.isHeadlessEnvironment() || SwingUtilities.isEventDispatchThread()) {
+    else if (application.isHeadlessEnvironment() || application.isDispatchThread()) {
       runnable.run();
     }
     else {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/EditableNotificationMessageElement.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/EditableNotificationMessageElement.java
new file mode 100644 (file)
index 0000000..e98211f
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2000-2014 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.externalSystem.service.notification;
+
+import com.intellij.ide.IdeTooltipManager;
+import com.intellij.ide.errorTreeView.*;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.pom.Navigatable;
+import com.intellij.ui.*;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.tree.TreeCellEditor;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.util.Map;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/24/2014
+ */
+public class EditableNotificationMessageElement extends NotificationMessageElement implements EditableMessageElement {
+
+  @NotNull private final TreeCellEditor myRightTreeCellEditor;
+  @NotNull private final Notification myNotification;
+  @NotNull private final Map<String/*url*/, String/*link text to replace*/> disabledLinks;
+
+  public EditableNotificationMessageElement(@NotNull Notification notification,
+                                            @NotNull ErrorTreeElementKind kind,
+                                            @Nullable GroupingElement parent,
+                                            String[] message,
+                                            Navigatable navigatable,
+                                            String exportText, String rendererTextPrefix) {
+    super(kind, parent, message, navigatable, exportText, rendererTextPrefix);
+    myNotification = notification;
+    disabledLinks = ContainerUtil.newHashMap();
+    myRightTreeCellEditor = new MyCellEditor();
+  }
+
+
+  public void addDisabledLink(@NotNull String url, @Nullable String text) {
+    disabledLinks.put(url, text);
+  }
+
+  @NotNull
+  @Override
+  public TreeCellEditor getRightSelfEditor() {
+    return myRightTreeCellEditor;
+  }
+
+  @Override
+  public boolean startEditingOnMouseMove() {
+    return true;
+  }
+
+  public static void disableLink(@NotNull HyperlinkEvent event) {
+    disableLink(event, null);
+  }
+
+  private static void disableLink(@NotNull final HyperlinkEvent event, @Nullable final String linkText) {
+    if (event.getSource() instanceof MyJEditorPane) {
+      UIUtil.invokeLaterIfNeeded(new Runnable() {
+        @Override
+        public void run() {
+          final MyJEditorPane editorPane = (MyJEditorPane)event.getSource();
+          editorPane.myElement.addDisabledLink(event.getDescription(), linkText);
+          editorPane.myElement.updateStyle(editorPane, null, null, true, false);
+        }
+      });
+    }
+  }
+
+  protected void updateStyle(@NotNull JEditorPane editorPane, @Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
+    super.updateStyle(editorPane, tree, value, selected, hasFocus);
+
+    final HTMLDocument htmlDocument = (HTMLDocument)editorPane.getDocument();
+    final Style linkStyle = htmlDocument.getStyleSheet().getStyle(LINK_STYLE);
+    StyleConstants.setForeground(linkStyle, IdeTooltipManager.getInstance().getLinkForeground(false));
+    StyleConstants.setItalic(linkStyle, true);
+    HTMLDocument.Iterator iterator = htmlDocument.getIterator(HTML.Tag.A);
+    while (iterator.isValid()) {
+      boolean disabledLink = false;
+      final AttributeSet attributes = iterator.getAttributes();
+      if (attributes instanceof SimpleAttributeSet) {
+        final Object attribute = attributes.getAttribute(HTML.Attribute.HREF);
+        if (attribute instanceof String && disabledLinks.containsKey(attribute)) {
+          disabledLink = true;
+          //TODO [Vlad] add support for disabled link text update
+          ////final String linkText = disabledLinks.get(attribute);
+          //if (linkText != null) {
+          //}
+          ((SimpleAttributeSet)attributes).removeAttribute(HTML.Attribute.HREF);
+        }
+        if (attribute == null) {
+          disabledLink = true;
+        }
+      }
+      if (!disabledLink) {
+        htmlDocument.setCharacterAttributes(
+          iterator.getStartOffset(), iterator.getEndOffset() - iterator.getStartOffset(), linkStyle, false);
+      }
+      iterator.next();
+    }
+  }
+
+  private static class MyJEditorPane extends JEditorPane {
+    @NotNull
+    private final EditableNotificationMessageElement myElement;
+
+    public MyJEditorPane(@NotNull EditableNotificationMessageElement element) {
+      myElement = element;
+    }
+  }
+
+  private class MyCellEditor extends AbstractCellEditor implements TreeCellEditor {
+    private final JEditorPane editorComponent;
+    @Nullable
+    private JTree myTree;
+
+    private MyCellEditor() {
+      editorComponent = installJep(new MyJEditorPane(EditableNotificationMessageElement.this));
+
+      HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener();
+      editorComponent.addHyperlinkListener(hyperlinkListener);
+      editorComponent.addMouseListener(new PopupHandler() {
+        @Override
+        public void invokePopup(Component comp, int x, int y) {
+          if (myTree == null) return;
+
+          final TreePath path = myTree.getLeadSelectionPath();
+          if (path == null) {
+            return;
+          }
+          DefaultActionGroup group = new DefaultActionGroup();
+          group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE));
+          group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COPY));
+
+          ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.COMPILER_MESSAGES_POPUP, group);
+          menu.getComponent().show(comp, x, y);
+        }
+      });
+    }
+
+    @Override
+    public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
+      myTree = tree;
+      updateStyle(editorComponent, tree, value, selected, false);
+      return editorComponent;
+    }
+
+    @Override
+    public Object getCellEditorValue() {
+      return null;
+    }
+
+    private class ActivatedHyperlinkListener implements HyperlinkListener {
+
+      @Override
+      public void hyperlinkUpdate(HyperlinkEvent e) {
+        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+          final NotificationListener notificationListener = myNotification.getListener();
+          if (notificationListener != null) {
+            notificationListener.hyperlinkUpdate(myNotification, e);
+          }
+        }
+      }
+    }
+  }
+}
index 0aa949f9f44ec20b19ecb887cb9bf3b59530ece5..9e1cf126aaf4141ff7a9a09823bd6e2b4d5935fe 100644 (file)
@@ -1,32 +1,42 @@
 package com.intellij.openapi.externalSystem.service.notification;
 
+import com.intellij.execution.rmi.RemoteUtil;
+import com.intellij.ide.errorTreeView.*;
 import com.intellij.notification.Notification;
 import com.intellij.notification.NotificationGroup;
-import com.intellij.notification.NotificationListener;
 import com.intellij.notification.NotificationType;
+import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.externalSystem.ExternalSystemConfigurableAware;
 import com.intellij.openapi.externalSystem.ExternalSystemManager;
 import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
+import com.intellij.openapi.externalSystem.model.LocationAwareExternalSystemException;
 import com.intellij.openapi.externalSystem.model.ProjectSystemId;
 import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
 import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
 import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
-import com.intellij.openapi.options.Configurable;
-import com.intellij.openapi.options.ShowSettingsUtil;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.openapi.wm.ToolWindowId;
+import com.intellij.openapi.wm.ToolWindowManager;
+import com.intellij.pom.Navigatable;
 import com.intellij.ui.EditorNotifications;
+import com.intellij.ui.content.Content;
+import com.intellij.ui.content.ContentFactory;
+import com.intellij.ui.content.MessageView;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.ObjectUtils;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
-import javax.swing.event.HyperlinkEvent;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * This class is responsible for ide user by external system integration-specific events.
@@ -35,24 +45,18 @@ import java.util.regex.Pattern;
  * show corresponding message to the end-user.
  * <p/>
  * Thread-safe.
- * 
- * @author Denis Zhdanov
+ *
+ * @author Denis Zhdanov, Vladislav Soroka
  * @since 3/21/12 4:04 PM
  */
 public class ExternalSystemIdeNotificationManager {
-  private static final Pattern ERROR_LOCATION_PATTERN;
-
-  static {
-    ERROR_LOCATION_PATTERN = Pattern.compile("error in file: (.*?) at line: (\\d+)");
-  }
-
+  @NotNull private static final Key<Pair<NotificationSource, ProjectSystemId>> CONTENT_ID_KEY = Key.create("CONTENT_ID");
   @NotNull private final AtomicReference<Notification> myNotification = new AtomicReference<Notification>();
 
   public void processExternalProjectRefreshError(@NotNull Throwable error,
                                                  @NotNull final Project project,
                                                  @NotNull String externalProjectName,
-                                                 @NotNull ProjectSystemId externalSystemId)
-  {
+                                                 @NotNull ProjectSystemId externalSystemId) {
     if (project.isDisposed() || !project.isOpen()) {
       return;
     }
@@ -61,95 +65,157 @@ public class ExternalSystemIdeNotificationManager {
       return;
     }
 
+    String title =
+      ExternalSystemBundle.message("notification.project.refresh.fail.title", externalSystemId.getReadableName(), externalProjectName);
     String message = ExternalSystemApiUtil.buildErrorMessage(error);
-    String title = ExternalSystemBundle.message("notification.project.refresh.fail.description",
-                                                externalSystemId.getReadableName(), externalProjectName, message);
-    String messageToShow = ExternalSystemBundle.message("notification.action.show.settings", externalSystemId.getReadableName());
-    NotificationType notificationType = NotificationType.WARNING;
-    final Configurable configurable = ((ExternalSystemConfigurableAware)manager).getConfigurable(project);
-    NotificationListener listener = new NotificationListener() {
-      @Override
-      public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
-        if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
-          return;
-        }
-        if ("configure".equals(event.getDescription())) {
-          ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
-        }
-        else if (!StringUtil.isEmpty(event.getDescription())) {
-          Matcher matcher = ERROR_LOCATION_PATTERN.matcher(event.getDescription());
-          if(matcher.find()) {
-            String file = matcher.group(1);
-            String lineText = matcher.group(2);
-            Integer line;
-            try {
-              line = Integer.valueOf(lineText);
-            }
-            catch (NumberFormatException e) {
-              line = 0;
-            }
-            VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(file);
-            if(virtualFile != null) {
-              new OpenFileDescriptor(project, virtualFile, line - 1, -1).navigate(true);
-            }
-          }
-        }
-      }
-    };
-    
+    NotificationType notificationType = NotificationType.ERROR;
+    String filePath = null;
+    Integer line = null;
+    Integer column = null;
+
+    //noinspection ThrowableResultOfMethodCallIgnored
+    Throwable unwrapped = RemoteUtil.unwrap(error);
+    if (unwrapped instanceof LocationAwareExternalSystemException) {
+      LocationAwareExternalSystemException locationAwareExternalSystemException = (LocationAwareExternalSystemException)unwrapped;
+      filePath = locationAwareExternalSystemException.getFilePath();
+      line = locationAwareExternalSystemException.getLine();
+      column = locationAwareExternalSystemException.getColumn();
+    }
+
+    NotificationData notificationData =
+      new NotificationData(
+        title, message, notificationType, NotificationSource.PROJECT_SYNC,
+        filePath, ObjectUtils.notNull(line, -1), ObjectUtils.notNull(column, -1), false);
+
     for (ExternalSystemNotificationExtension extension : ExternalSystemNotificationExtension.EP_NAME.getExtensions()) {
       if (!externalSystemId.equals(extension.getTargetExternalSystemId())) {
         continue;
       }
-      ExternalSystemNotificationExtension.CustomizationResult customizationResult = extension.customize(
-        project, error, ExternalSystemNotificationExtension.UsageHint.PROJECT_REFRESH
-      );
-      if (customizationResult == null) {
-        continue;
-      }
-      if (customizationResult.getTitle() != null) {
-        title = customizationResult.getTitle();
-      }
-      if (customizationResult.getMessage() != null) {
-        messageToShow = customizationResult.getMessage();
-      }
-      if (customizationResult.getNotificationType() != null) {
-        notificationType = customizationResult.getNotificationType();
-      }
-      if (customizationResult.getListener() != null) {
-        listener = customizationResult.getListener();
-      }
+      extension.customize(notificationData, project, error);
     }
 
     EditorNotifications.getInstance(project).updateAllNotifications();
-    showNotification(title, messageToShow, notificationType, project, externalSystemId, listener);
+    showNotification(project, externalSystemId, notificationData);
   }
 
-  public void showNotification(@NotNull final String title,
-                               @NotNull final String message,
-                               @NotNull final NotificationType type,
-                               @NotNull final Project project,
+  public void showNotification(@NotNull final Project project,
                                @NotNull final ProjectSystemId externalSystemId,
-                               @Nullable final NotificationListener listener)
-  {
+                               @NotNull final NotificationData notificationData) {
+
     UIUtil.invokeLaterIfNeeded(new Runnable() {
       @Override
       public void run() {
-        NotificationGroup group = ExternalSystemUtil.getToolWindowElement(NotificationGroup.class,
-                                                                          project,
-                                                                          ExternalSystemDataKeys.NOTIFICATION_GROUP,
-                                                                          externalSystemId);
-        if (group == null) {
-          return;
+        if (project.isDisposed()) return;
+
+        final NotificationGroup group = ExternalSystemUtil.getToolWindowElement(
+          NotificationGroup.class, project, ExternalSystemDataKeys.NOTIFICATION_GROUP, externalSystemId);
+        if (group == null) return;
+
+        final Notification notification = group.createNotification(
+          notificationData.getTitle(), notificationData.getMessage(),
+          notificationData.getNotificationType(), notificationData.getListener());
+
+        if (notificationData.isBalloonNotification()) {
+          applyNotification(notification, project);
         }
+        else {
+          addMessage(notification, project, externalSystemId, notificationData);
+        }
+      }
+    });
+  }
 
-        Notification notification = group.createNotification(title, message, type, listener);
-        applyNotification(notification, project); 
+  public void clearNotificationMessages(@NotNull final Project project,
+                                        @NotNull final NotificationSource notificationSource,
+                                        @NotNull final ProjectSystemId externalSystemId) {
+    UIUtil.invokeLaterIfNeeded(new Runnable() {
+      @Override
+      public void run() {
+        final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
+        if (toolWindow == null) return;
+
+        final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
+        final MessageView messageView = ServiceManager.getService(project, MessageView.class);
+        for (Content content : messageView.getContentManager().getContents()) {
+          if (!content.isPinned() && contentIdPair.equals(content.getUserData(CONTENT_ID_KEY))) {
+            messageView.getContentManager().removeContent(content, true);
+          }
+        }
       }
     });
-    
   }
-  
+
+
+  private static void addMessage(@NotNull final Notification notification,
+                                 @NotNull final Project project,
+                                 @NotNull final ProjectSystemId externalSystemId,
+                                 @NotNull final NotificationData notificationData) {
+    notification.expire();
+
+    final NewErrorTreeViewPanel[] errorTreeView = {null};
+    CommandProcessor commandProcessor = CommandProcessor.getInstance();
+    commandProcessor.executeCommand(project, new Runnable() {
+      @Override
+      public void run() {
+        errorTreeView[0] = prepareMessagesView(project, externalSystemId, notificationData);
+      }
+    }, "Open message view", null);
+
+    final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
+    if (tw != null) {
+      tw.activate(null, false);
+    }
+
+    final VirtualFile virtualFile = notificationData.getFilePath() != null
+                                    ?
+                                    LocalFileSystem.getInstance().refreshAndFindFileByPath(notificationData.getFilePath())
+                                    : null;
+
+    final String groupName = virtualFile != null ? virtualFile.getPresentableUrl() : notificationData.getTitle();
+
+    int line = notificationData.getLine() - 1;
+    int column = notificationData.getColumn() - 1;
+
+    if (virtualFile == null) line = column = -1;
+
+    final int guiLine = line < 0 ? -1 : line + 1;
+    final int guiColumn = column < 0 ? 0 : column + 1;
+
+    final Navigatable navigatable = notificationData.getNavigatable() != null
+                                    ? notificationData.getNavigatable()
+                                    : virtualFile != null ? new OpenFileDescriptor(project, virtualFile, line, column) : null;
+
+    final ErrorTreeElementKind kind = getErrorTreeElementKind(notificationData.getNotificationType());
+    final String[] message = notificationData.getMessage().split("\n");
+    final GroupingElement groupingElement = errorTreeView[0].getErrorViewStructure().getGroupingElement(groupName, null, virtualFile);
+    final String exportPrefix = NewErrorTreeViewPanel.createExportPrefix(guiLine);
+    final String rendererPrefix = NewErrorTreeViewPanel.createRendererPrefix(guiLine, guiColumn);
+
+    final NavigatableMessageElement navigatableMessageElement;
+    if (notificationData.hasLinks()) {
+      navigatableMessageElement = new EditableNotificationMessageElement(
+        notification,
+        kind,
+        groupingElement,
+        message,
+        navigatable,
+        exportPrefix,
+        rendererPrefix);
+    }
+    else {
+      navigatableMessageElement = new NotificationMessageElement(
+        kind,
+        groupingElement,
+        message,
+        navigatable,
+        exportPrefix,
+        rendererPrefix);
+    }
+
+    errorTreeView[0].getErrorViewStructure().addNavigatableMessage(groupName, navigatableMessageElement);
+    errorTreeView[0].updateTree();
+  }
+
   private void applyNotification(@NotNull final Notification notification, @NotNull final Project project) {
     final Notification oldNotification = myNotification.get();
     if (oldNotification != null && myNotification.compareAndSet(oldNotification, null)) {
@@ -164,4 +230,71 @@ public class ExternalSystemIdeNotificationManager {
       notification.notify(project);
     }
   }
-}
+
+  @NotNull
+  private static ErrorTreeElementKind getErrorTreeElementKind(@NotNull final NotificationType notificationType) {
+    ErrorTreeElementKind errorTreeElementKind = ErrorTreeElementKind.GENERIC;
+    switch (notificationType) {
+      case INFORMATION:
+        errorTreeElementKind = ErrorTreeElementKind.INFO;
+        break;
+      case WARNING:
+        errorTreeElementKind = ErrorTreeElementKind.WARNING;
+        break;
+      case ERROR:
+        errorTreeElementKind = ErrorTreeElementKind.ERROR;
+        break;
+    }
+    return errorTreeElementKind;
+  }
+
+  @NotNull
+  private static NewErrorTreeViewPanel prepareMessagesView(@NotNull final Project project,
+                                                           @NotNull final ProjectSystemId externalSystemId,
+                                                           @NotNull final NotificationData notificationData) {
+    final NotificationSource notificationSource = notificationData.getNotificationSource();
+    final String contentDisplayName = getContentDisplayName(notificationSource, externalSystemId);
+    final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
+
+    Content projectSyncContent = null;
+    final MessageView messageView = ServiceManager.getService(project, MessageView.class);
+    for (Content content : messageView.getContentManager().getContents()) {
+      if (contentIdPair.equals(content.getUserData(CONTENT_ID_KEY))
+          && StringUtil.equals(content.getDisplayName(), contentDisplayName) && !content.isPinned()) {
+        projectSyncContent = content;
+      }
+    }
+    final NewEditableErrorTreeViewPanel errorTreeView;
+    if (projectSyncContent == null || !contentIdPair.equals(projectSyncContent.getUserData(CONTENT_ID_KEY))) {
+      errorTreeView = new NewEditableErrorTreeViewPanel(project, null, true, true, null);
+
+      projectSyncContent = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, contentDisplayName, true);
+      projectSyncContent.putUserData(CONTENT_ID_KEY, contentIdPair);
+
+      messageView.getContentManager().addContent(projectSyncContent);
+      Disposer.register(projectSyncContent, errorTreeView);
+    }
+    else {
+      assert projectSyncContent.getComponent() instanceof NewEditableErrorTreeViewPanel;
+      errorTreeView = (NewEditableErrorTreeViewPanel)projectSyncContent.getComponent();
+    }
+
+    messageView.getContentManager().setSelectedContent(projectSyncContent);
+    return errorTreeView;
+  }
+
+  @NotNull
+  private static String getContentDisplayName(@NotNull final NotificationSource notificationSource,
+                                              @NotNull final ProjectSystemId externalSystemId) {
+    final String contentDisplayName;
+    switch (notificationSource) {
+      case PROJECT_SYNC:
+        contentDisplayName =
+          ExternalSystemBundle.message("notification.messages.project.sync.tab.name", externalSystemId.getReadableName());
+        break;
+      default:
+        throw new AssertionError("unsupported notification source found: " + notificationSource);
+    }
+    return contentDisplayName;
+  }
+}
\ No newline at end of file
index 1a0d50cb280bc4db0fe6e8149844865bf7a34815..1f183b1c200200bd7177c0d93d8e7ff84302c2c9 100644 (file)
@@ -15,8 +15,6 @@
  */
 package com.intellij.openapi.externalSystem.service.notification;
 
-import com.intellij.notification.NotificationListener;
-import com.intellij.notification.NotificationType;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.externalSystem.model.ProjectSystemId;
 import com.intellij.openapi.project.Project;
@@ -25,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
 
 /**
  * Allows to customize {@link ExternalSystemIdeNotificationManager external system notifications} shown to end-user by the ide.
- * 
+ *
  * @author Denis Zhdanov
  * @since 8/5/13 8:52 AM
  */
@@ -33,61 +31,18 @@ public interface ExternalSystemNotificationExtension {
 
   ExtensionPointName<ExternalSystemNotificationExtension> EP_NAME
     = ExtensionPointName.create("com.intellij.externalSystemNotificationExtension");
-  
+
   @NotNull
   ProjectSystemId getTargetExternalSystemId();
 
   /**
-   * Allows to customize external system processing error.
-   * 
-   * @param project  target ide project
-   * @param error    error occurred during external system processing
-   * @param hint     hint for a use-case during processing of which given error occurs
-   * @return         customization result (if applicable)
+   * Allows to customize external system processing notification.
+   *
+   * @param notificationData notification data
+   * @param project target ide project
+   * @param error   error occurred during external system processing
    */
-  @Nullable
-  CustomizationResult customize(@NotNull Project project, @NotNull Throwable error, @Nullable UsageHint hint);
-  
-  enum UsageHint {
-    PROJECT_REFRESH
-  }
-  
-  class CustomizationResult {
-
-    @Nullable private final String               myTitle;
-    @Nullable private final String               myMessage;
-    @Nullable private final NotificationType     myNotificationType;
-    @Nullable private final NotificationListener myListener;
-
-    public CustomizationResult(@Nullable String title,
-                               @Nullable String message,
-                               @Nullable NotificationType notificationType,
-                               @Nullable NotificationListener listener)
-    {
-      myTitle = title;
-      myMessage = message;
-      myNotificationType = notificationType;
-      myListener = listener;
-    }
-
-    @Nullable
-    public String getTitle() {
-      return myTitle;
-    }
-
-    @Nullable
-    public String getMessage() {
-      return myMessage;
-    }
-
-    @Nullable
-    public NotificationType getNotificationType() {
-      return myNotificationType;
-    }
-
-    @Nullable
-    public NotificationListener getListener() {
-      return myListener;
-    }
-  }
+  void customize(@NotNull NotificationData notificationData,
+                 @NotNull Project project,
+                 @Nullable Throwable error);
 }
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationData.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationData.java
new file mode 100644 (file)
index 0000000..987ba0a
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2000-2014 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.externalSystem.service.notification;
+
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.notification.NotificationType;
+import com.intellij.pom.Navigatable;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/28/14
+ */
+public class NotificationData {
+
+  @NotNull private String myTitle;
+  @NotNull private String myMessage;
+  @NotNull private NotificationType myNotificationType;
+  @NotNull private final NotificationSource myNotificationSource;
+  @NotNull private NotificationListener myListener;
+  @Nullable private String myFilePath;
+  @Nullable private Navigatable navigatable;
+  private int myLine;
+  private int myColumn;
+  private boolean myBalloonNotification;
+
+  private final Map<String, NotificationListener> myListenerMap;
+
+  public NotificationData(@NotNull String title,
+                          @NotNull String message,
+                          @NotNull NotificationType notificationType,
+                          @NotNull NotificationSource notificationSource) {
+    this(title, message, notificationType, notificationSource, null, -1, -1, false);
+  }
+
+  public NotificationData(@NotNull String title,
+                          @NotNull String message,
+                          @NotNull NotificationType notificationType,
+                          @NotNull NotificationSource notificationSource,
+                          @Nullable String filePath,
+                          int line,
+                          int column,
+                          boolean balloonNotification) {
+    myTitle = title;
+    myMessage = message;
+    myNotificationType = notificationType;
+    myNotificationSource = notificationSource;
+    myListenerMap = ContainerUtil.newHashMap();
+    myListener = new NotificationListener.Adapter() {
+      @Override
+      protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
+        if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
+
+        final NotificationListener notificationListener = myListenerMap.get(event.getDescription());
+        if (notificationListener != null) {
+          notificationListener.hyperlinkUpdate(notification, event);
+        }
+      }
+    };
+    myFilePath = filePath;
+    myLine = line;
+    myColumn = column;
+    myBalloonNotification = balloonNotification;
+  }
+
+  @NotNull
+  public String getTitle() {
+    return myTitle;
+  }
+
+  public void setTitle(@NotNull String title) {
+    myTitle = title;
+  }
+
+  @NotNull
+  public String getMessage() {
+    return myMessage;
+  }
+
+  public void setMessage(@NotNull String message) {
+    myMessage = message;
+  }
+
+  @NotNull
+  public NotificationType getNotificationType() {
+    return myNotificationType;
+  }
+
+  public void setNotificationType(@NotNull NotificationType notificationType) {
+    myNotificationType = notificationType;
+  }
+
+  @NotNull
+  public NotificationSource getNotificationSource() {
+    return myNotificationSource;
+  }
+
+  @NotNull
+  public NotificationListener getListener() {
+    return myListener;
+  }
+
+  @Nullable
+  public String getFilePath() {
+    return myFilePath;
+  }
+
+  public void setFilePath(@Nullable String filePath) {
+    myFilePath = filePath;
+  }
+
+  @NotNull
+  public Integer getLine() {
+    return myLine;
+  }
+
+  public void setLine(int line) {
+    myLine = line;
+  }
+
+  public int getColumn() {
+    return myColumn;
+  }
+
+  public void setColumn(int column) {
+    myColumn = column;
+  }
+
+  public boolean isBalloonNotification() {
+    return myBalloonNotification;
+  }
+
+  public void setBalloonNotification(boolean balloonNotification) {
+    myBalloonNotification = balloonNotification;
+  }
+
+  public void setListener(@NotNull String listenerId, @NotNull NotificationListener listener) {
+    myListenerMap.put(listenerId, listener);
+  }
+
+  boolean hasLinks() {
+    return !myListenerMap.isEmpty();
+  }
+
+  public List<String> getRegisteredListenerIds() {
+    return ContainerUtil.newArrayList(myListenerMap.keySet());
+  }
+
+  @Nullable
+  public Navigatable getNavigatable() {
+    return navigatable;
+  }
+
+  public void setNavigatable(@Nullable Navigatable navigatable) {
+    this.navigatable = navigatable;
+  }
+}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationMessageElement.java
new file mode 100644 (file)
index 0000000..6b49328
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2000-2014 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.externalSystem.service.notification;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.errorTreeView.*;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.pom.Navigatable;
+import com.intellij.ui.CustomizeColoredTreeCellRenderer;
+import com.intellij.ui.JBColor;
+import com.intellij.ui.LoadingNode;
+import com.intellij.ui.SimpleColoredComponent;
+import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.tree.WideSelectionTreeUI;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.StyleSheet;
+import java.awt.*;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/24/2014
+ */
+public class NotificationMessageElement extends NavigatableMessageElement {
+  public static final String MSG_STYLE = "messageStyle";
+  public static final String LINK_STYLE = "linkStyle";
+
+  @NotNull private final CustomizeColoredTreeCellRenderer myLeftTreeCellRenderer;
+  @NotNull private final CustomizeColoredTreeCellRenderer myRightTreeCellRenderer;
+
+  public NotificationMessageElement(@NotNull final ErrorTreeElementKind kind,
+                                    @Nullable GroupingElement parent,
+                                    String[] message,
+                                    Navigatable navigatable,
+                                    String exportText,
+                                    String rendererTextPrefix) {
+    super(kind, parent, message, navigatable, exportText, rendererTextPrefix);
+    myLeftTreeCellRenderer = new CustomizeColoredTreeCellRenderer() {
+      public void customizeCellRenderer(SimpleColoredComponent renderer,
+                                        JTree tree,
+                                        Object value,
+                                        boolean selected,
+                                        boolean expanded,
+                                        boolean leaf,
+                                        int row,
+                                        boolean hasFocus) {
+        renderer.setIcon(getIcon(kind));
+        renderer.setFont(tree.getFont());
+        renderer.append(NewErrorTreeRenderer.calcPrefix(NotificationMessageElement.this));
+      }
+
+      @NotNull
+      private Icon getIcon(@NotNull ErrorTreeElementKind kind) {
+        Icon icon = AllIcons.General.Mdot_empty;
+        switch (kind) {
+          case INFO:
+            icon = AllIcons.General.Information;
+            break;
+          case ERROR:
+            icon = AllIcons.General.Error;
+            break;
+          case WARNING:
+            icon = AllIcons.General.Warning;
+            break;
+          case NOTE:
+            icon = AllIcons.General.Tip;
+            break;
+          case GENERIC:
+            icon = AllIcons.General.Mdot_empty;
+            break;
+        }
+        return icon;
+      }
+    };
+
+    myRightTreeCellRenderer = new MyCustomizeColoredTreeCellRendererReplacement();
+  }
+
+  @Nullable
+  @Override
+  public CustomizeColoredTreeCellRenderer getRightSelfRenderer() {
+    return myRightTreeCellRenderer;
+  }
+
+  @Nullable
+  @Override
+  public CustomizeColoredTreeCellRenderer getLeftSelfRenderer() {
+    return myLeftTreeCellRenderer;
+  }
+
+  protected JEditorPane installJep(@NotNull JEditorPane myEditorPane) {
+    String message = StringUtil.join(this.getText(), "<br>");
+    myEditorPane.setEditable(false);
+    myEditorPane.setOpaque(false);
+    myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit());
+    myEditorPane.setHighlighter(null);
+
+    final StyleSheet styleSheet = ((HTMLDocument)myEditorPane.getDocument()).getStyleSheet();
+    final Style style = styleSheet.addStyle(MSG_STYLE, null);
+    styleSheet.addStyle(LINK_STYLE, style);
+    myEditorPane.setText(message);
+
+    return myEditorPane;
+  }
+
+  protected void updateStyle(@NotNull JEditorPane editorPane, @Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
+    final HTMLDocument htmlDocument = (HTMLDocument)editorPane.getDocument();
+    final Style style = htmlDocument.getStyleSheet().getStyle(MSG_STYLE);
+    if (value instanceof LoadingNode) {
+      StyleConstants.setForeground(style, JBColor.GRAY);
+    }
+    else {
+      if (selected) {
+        StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground());
+      }
+      else {
+        StyleConstants.setForeground(style, UIUtil.getTreeTextForeground());
+      }
+    }
+
+    if (UIUtil.isUnderGTKLookAndFeel() ||
+        UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus ||
+        tree != null && tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
+      editorPane.setOpaque(false);
+    }
+    else {
+      editorPane.setOpaque(selected && hasFocus);
+    }
+
+    htmlDocument.setCharacterAttributes(0, htmlDocument.getLength(), style, false);
+  }
+
+  private class MyCustomizeColoredTreeCellRendererReplacement extends CustomizeColoredTreeCellRendererReplacement {
+    @NotNull
+    private final JEditorPane myEditorPane;
+
+    private MyCustomizeColoredTreeCellRendererReplacement() {
+      myEditorPane = installJep(new JEditorPane());
+    }
+
+    @Override
+    public Component getTreeCellRendererComponent(JTree tree,
+                                                  Object value,
+                                                  boolean selected,
+                                                  boolean expanded,
+                                                  boolean leaf,
+                                                  int row,
+                                                  boolean hasFocus) {
+      updateStyle(myEditorPane, tree, value, selected, hasFocus);
+      return myEditorPane;
+    }
+  }
+}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationSource.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/NotificationSource.java
new file mode 100644 (file)
index 0000000..4a20167
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 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.externalSystem.service.notification;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/28/14
+ */
+public enum NotificationSource {
+  PROJECT_SYNC
+}
index 8b57b368784e457b506d61d994cbb21be43caf2b..58bb34c369fb5ab37f78c182fde303f49cc415ee 100644 (file)
@@ -31,14 +31,14 @@ public class RemoteExternalSystemProjectResolverImpl<S extends ExternalSystemExe
   public DataNode<ProjectData> resolveProjectInfo(@NotNull final ExternalSystemTaskId id,
                                                   @NotNull final String projectPath,
                                                   final boolean isPreviewMode,
-                                                  ExternalSystemExecutionSettings settings)
+                                                  final S settings)
     throws ExternalSystemException, IllegalArgumentException, IllegalStateException
   {
     return execute(id, new Producer<DataNode<ProjectData>>() {
       @Nullable
       @Override
       public DataNode<ProjectData> produce() {
-        return myDelegate.resolveProjectInfo(id, projectPath, isPreviewMode, getSettings(), getNotificationListener());
+        return myDelegate.resolveProjectInfo(id, projectPath, isPreviewMode, settings, getNotificationListener());
       }
     });
   }
index 3a5572193aac4797ddf924749205347acfbaba91..8d2cb7bef4aeba85aff10c7e6da0c52cb64fd082 100644 (file)
@@ -42,6 +42,7 @@ import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMo
 import com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager;
 import com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask;
 import com.intellij.openapi.externalSystem.service.notification.ExternalSystemIdeNotificationManager;
+import com.intellij.openapi.externalSystem.service.notification.NotificationSource;
 import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
 import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
 import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
@@ -62,7 +63,6 @@ import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.ToolWindow;
 import com.intellij.openapi.wm.ToolWindowEP;
@@ -199,93 +199,8 @@ public class ExternalSystemUtil {
     final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
     final int[] counter = new int[1];
 
-    ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
-
-      @NotNull
-      private final Set<String> myExternalModulePaths = ContainerUtilRt.newHashSet();
-
-      @Override
-      public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
-        if (externalProject == null) {
-          return;
-        }
-        Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(externalProject, ProjectKeys.MODULE);
-        for (DataNode<ModuleData> node : moduleNodes) {
-          myExternalModulePaths.add(node.getData().getLinkedExternalProjectPath());
-        }
-        ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
-          @Override
-          public void execute() {
-            ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
-              @Override
-              public void run() {
-                projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), project, true);
-              }
-            });
-
-            processOrphanProjectLibraries();
-          }
-        });
-        if (--counter[0] <= 0) {
-          processOrphanModules();
-        }
-      }
-
-      @Override
-      public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
-        counter[0] = Integer.MAX_VALUE; // Don't process orphan modules if there was an error on refresh.
-      }
-
-      private void processOrphanModules() {
-        if(project.isDisposed()) return;
-        if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
-          LOG.info(String.format(
-            "Checking for orphan modules. External paths returned by external system: '%s'", myExternalModulePaths
-          ));
-        }
-        PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
-        List<Module> orphanIdeModules = ContainerUtilRt.newArrayList();
-        String externalSystemIdAsString = externalSystemId.toString();
-
-        for (Module module : platformFacade.getModules(project)) {
-          String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
-          String p = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
-          if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
-            LOG.info(String.format(
-              "IDE module: EXTERNAL_SYSTEM_ID_KEY - '%s', LINKED_PROJECT_PATH_KEY - '%s'.", s, p
-            ));
-          }
-          if (externalSystemIdAsString.equals(s) && !myExternalModulePaths.contains(p)) {
-            orphanIdeModules.add(module);
-            if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
-              LOG.info(String.format(
-                "External paths doesn't contain IDE module LINKED_PROJECT_PATH_KEY anymore => add to orphan IDE modules."
-              ));
-            }
-          }
-        }
-
-        if (!orphanIdeModules.isEmpty()) {
-          ruleOrphanModules(orphanIdeModules, project, externalSystemId);
-        }
-      }
-
-      private void processOrphanProjectLibraries() {
-        PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
-        List<Library> orphanIdeLibraries = ContainerUtilRt.newArrayList();
-
-        LibraryTable projectLibraryTable = platformFacade.getProjectLibraryTable(project);
-        for (Library library : projectLibraryTable.getLibraries()) {
-          if (!ExternalSystemApiUtil.isExternalSystemLibrary(library, externalSystemId)) continue;
-          if (ProjectStructureHelper.isOrphanProjectLibrary(library, platformFacade.getModules(project))) {
-            orphanIdeLibraries.add(library);
-          }
-        }
-        for (Library orphanIdeLibrary : orphanIdeLibraries) {
-          projectLibraryTable.removeLibrary(orphanIdeLibrary);
-        }
-      }
-    };
+    ExternalProjectRefreshCallback callback =
+      new MyMultiExternalProjectRefreshCallback(project, projectDataManager, counter, externalSystemId);
 
     Map<String, Long> modificationStamps = manager.getLocalSettingsProvider().fun(project).getExternalConfigModificationStamps();
     Set<String> toRefresh = ContainerUtilRt.newHashSet();
@@ -298,6 +213,11 @@ public class ExternalSystemUtil {
     }
 
     if (!toRefresh.isEmpty()) {
+      ExternalSystemIdeNotificationManager notificationManager = ServiceManager.getService(ExternalSystemIdeNotificationManager.class);
+      if (notificationManager != null) {
+        notificationManager.clearNotificationMessages(project, NotificationSource.PROJECT_SYNC, externalSystemId);
+      }
+
       counter[0] = toRefresh.size();
       for (String path : toRefresh) {
         refreshProject(project, externalSystemId, path, callback, false, progressExecutionMode);
@@ -462,6 +382,13 @@ public class ExternalSystemUtil {
           return;
         }
 
+        if(!(callback instanceof MyMultiExternalProjectRefreshCallback)) {
+          ExternalSystemIdeNotificationManager notificationManager = ServiceManager.getService(ExternalSystemIdeNotificationManager.class);
+          if (notificationManager != null) {
+            notificationManager.clearNotificationMessages(project, NotificationSource.PROJECT_SYNC, externalSystemId);
+          }
+        }
+
         ExternalSystemResolveProjectTask task
           = new ExternalSystemResolveProjectTask(externalSystemId, project, externalProjectPath, isPreviewMode);
 
@@ -767,4 +694,107 @@ public class ExternalSystemUtil {
   private interface TaskUnderProgress {
     void execute(@NotNull ProgressIndicator indicator);
   }
+
+  private static class MyMultiExternalProjectRefreshCallback implements ExternalProjectRefreshCallback {
+
+    @NotNull
+    private final Set<String> myExternalModulePaths;
+    private final Project myProject;
+    private final ProjectDataManager myProjectDataManager;
+    private final int[] myCounter;
+    private final ProjectSystemId myExternalSystemId;
+
+    public MyMultiExternalProjectRefreshCallback(Project project,
+                                                 ProjectDataManager projectDataManager,
+                                                 int[] counter,
+                                                 ProjectSystemId externalSystemId) {
+      myProject = project;
+      myProjectDataManager = projectDataManager;
+      myCounter = counter;
+      myExternalSystemId = externalSystemId;
+      myExternalModulePaths = ContainerUtilRt.newHashSet();
+    }
+
+    @Override
+    public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
+      if (externalProject == null) {
+        return;
+      }
+      Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(externalProject, ProjectKeys.MODULE);
+      for (DataNode<ModuleData> node : moduleNodes) {
+        myExternalModulePaths.add(node.getData().getLinkedExternalProjectPath());
+      }
+      ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(myProject) {
+        @Override
+        public void execute() {
+          ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
+            @Override
+            public void run() {
+              myProjectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), myProject, true);
+            }
+          });
+
+          processOrphanProjectLibraries();
+        }
+      });
+      if (--myCounter[0] <= 0) {
+        processOrphanModules();
+      }
+    }
+
+    @Override
+    public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
+      myCounter[0] = Integer.MAX_VALUE; // Don't process orphan modules if there was an error on refresh.
+    }
+
+    private void processOrphanModules() {
+      if(myProject.isDisposed()) return;
+      if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
+        LOG.info(String.format(
+          "Checking for orphan modules. External paths returned by external system: '%s'", myExternalModulePaths
+        ));
+      }
+      PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
+      List<Module> orphanIdeModules = ContainerUtilRt.newArrayList();
+      String externalSystemIdAsString = myExternalSystemId.toString();
+
+      for (Module module : platformFacade.getModules(myProject)) {
+        String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
+        String p = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
+        if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
+          LOG.info(String.format(
+            "IDE module: EXTERNAL_SYSTEM_ID_KEY - '%s', LINKED_PROJECT_PATH_KEY - '%s'.", s, p
+          ));
+        }
+        if (externalSystemIdAsString.equals(s) && !myExternalModulePaths.contains(p)) {
+          orphanIdeModules.add(module);
+          if(ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
+            LOG.info(String.format(
+              "External paths doesn't contain IDE module LINKED_PROJECT_PATH_KEY anymore => add to orphan IDE modules."
+            ));
+          }
+        }
+      }
+
+      if (!orphanIdeModules.isEmpty()) {
+        ruleOrphanModules(orphanIdeModules, myProject, myExternalSystemId);
+      }
+    }
+
+    private void processOrphanProjectLibraries() {
+      PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
+      List<Library> orphanIdeLibraries = ContainerUtilRt.newArrayList();
+
+      LibraryTable projectLibraryTable = platformFacade.getProjectLibraryTable(myProject);
+      for (Library library : projectLibraryTable.getLibraries()) {
+        if (!ExternalSystemApiUtil.isExternalSystemLibrary(library, myExternalSystemId)) continue;
+        if (ProjectStructureHelper.isOrphanProjectLibrary(library, platformFacade.getModules(myProject))) {
+          orphanIdeLibraries.add(library);
+        }
+      }
+      for (Library orphanIdeLibrary : orphanIdeLibraries) {
+        projectLibraryTable.removeLibrary(orphanIdeLibrary);
+      }
+    }
+  }
 }
index 780e3d2009082d19dfc80644596d318a9a8a1d77..b6b108b8eff0522b3240a6668487258f766c1109 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,5 +26,5 @@ import java.util.Map;
  */
 public interface DataIndexer<Key, Value, Data> {
   @NotNull
-  Map<Key,Value> map(Data inputData);
+  Map<Key,Value> map(@NotNull Data inputData);
 }
index dc6091964163a13eb10b951a36486eb27b84f46d..5db15deff7b8462fc9c4cef9332525068ac160cd 100644 (file)
@@ -71,7 +71,7 @@ public abstract class FileBasedIndexExtension<K, V> {
    *
    * Use carefully, because indexing large files may influence index update speed dramatically.
    *
-   * @see com.intellij.openapi.vfs.PersistentFSConstants#MAX_INTELLISENSE_FILESIZE
+   * @see com.intellij.openapi.vfs.PersistentFSConstants#getMaxIntellisenseFileSize()
    */
   @NotNull
   public Collection<FileType> getFileTypesWithSizeLimitNotApplicable() {
index 3e96882ddea1615d53d4c99ac9e6c96a34f7571c..1f1ee7b86580394476c04055e103b2b76e789610 100644 (file)
@@ -75,7 +75,7 @@ public class IdIndex extends FileBasedIndexExtension<IdIndexEntry, Integer> {
   private final DataIndexer<IdIndexEntry, Integer, FileContent> myIndexer = new DataIndexer<IdIndexEntry, Integer, FileContent>() {
     @Override
     @NotNull
-    public Map<IdIndexEntry, Integer> map(final FileContent inputData) {
+    public Map<IdIndexEntry, Integer> map(@NotNull final FileContent inputData) {
       final FileTypeIdIndexer indexer = IdTableBuilding.getFileTypeIndexer(inputData.getFileType());
       if (indexer != null) {
         return indexer.map(inputData);
index eb64dcff475f3a5cacce5bdfee64e10ccb127e04..3e6571405a91b1a1b014a152570a339bfbfa2d47 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -50,7 +50,7 @@ public class IdTableBuilding {
   public static class PlainTextIndexer extends FileTypeIdIndexer {
     @Override
     @NotNull
-    public Map<IdIndexEntry, Integer> map(final FileContent inputData) {
+    public Map<IdIndexEntry, Integer> map(@NotNull final FileContent inputData) {
       final IdDataConsumer consumer = new IdDataConsumer();
       final CharSequence chars = inputData.getContentAsText();
       scanWords(new ScanWordProcessor() {
@@ -132,7 +132,7 @@ public class IdTableBuilding {
 
     @Override
     @NotNull
-    public Map<IdIndexEntry, Integer> map(final FileContent inputData) {
+    public Map<IdIndexEntry, Integer> map(@NotNull final FileContent inputData) {
       final CharSequence chars = inputData.getContentAsText();
       final char[] charsArray = CharArrayUtil.fromSequenceWithoutCopying(chars);
       final IdDataConsumer consumer = new IdDataConsumer();
index d1cf6548f4920ab3ab52a83b09705042354c413e..4441071040e4af794b5f0fd201e283a192c7d578 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ public abstract class LexerBasedIdIndexer extends FileTypeIdIndexer implements I
   
   @Override
   @NotNull
-  public final Map<IdIndexEntry,Integer> map(final FileContent inputData) {
+  public final Map<IdIndexEntry,Integer> map(@NotNull final FileContent inputData) {
     return BaseFilterLexerUtil.scanContent(inputData, this).idMap;
   }
 }
index a5d45163918f6d3e4b541eb1b124a71586bac53e..b05ef6a9853a922e6a4827a4656efad831d52336 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ public abstract class LexerBasedTodoIndexer implements DataIndexer<TodoIndexEntr
                                                        IdAndToDoScannerBasedOnFilterLexer {
   @Override
   @NotNull
-  public Map<TodoIndexEntry,Integer> map(final FileContent inputData) {
+  public Map<TodoIndexEntry,Integer> map(@NotNull final FileContent inputData) {
     return BaseFilterLexerUtil.scanContent(inputData, this).todoMap;
   }
 }
index 061100b77470104c4e0a6a0f102619de6a57807c..94388d0d25587599bfd48fc822d6e987bd2f2504 100644 (file)
@@ -36,9 +36,10 @@ import java.util.Map;
  */
 public class FileTypeIndex extends ScalarIndexExtension<FileType>
   implements FileBasedIndex.InputFilter, KeyDescriptor<FileType>, DataIndexer<FileType, Void, FileContent> {
-  private final EnumeratorStringDescriptor myEnumeratorStringDescriptor = new EnumeratorStringDescriptor();
+  private static final EnumeratorStringDescriptor ENUMERATOR_STRING_DESCRIPTOR = new EnumeratorStringDescriptor();
 
-  public static Collection<VirtualFile> getFiles(FileType fileType, GlobalSearchScope scope) {
+  @NotNull
+  public static Collection<VirtualFile> getFiles(@NotNull FileType fileType, @NotNull GlobalSearchScope scope) {
     return FileBasedIndex.getInstance().getContainingFiles(NAME, fileType, scope);
   }
 
@@ -96,12 +97,12 @@ public class FileTypeIndex extends ScalarIndexExtension<FileType>
 
   @Override
   public void save(@NotNull DataOutput out, FileType value) throws IOException {
-    myEnumeratorStringDescriptor.save(out, value.getName());
+    ENUMERATOR_STRING_DESCRIPTOR.save(out, value.getName());
   }
 
   @Override
   public FileType read(@NotNull DataInput in) throws IOException {
-    String read = myEnumeratorStringDescriptor.read(in);
+    String read = ENUMERATOR_STRING_DESCRIPTOR.read(in);
     return myFileTypeManager.findFileTypeByName(read);
   }
 
@@ -117,7 +118,7 @@ public class FileTypeIndex extends ScalarIndexExtension<FileType>
 
   @NotNull
   @Override
-  public Map<FileType, Void> map(FileContent inputData) {
+  public Map<FileType, Void> map(@NotNull FileContent inputData) {
     return Collections.singletonMap(inputData.getFileType(), null);
   }
 
index 0e95aefcc0bb10c530b28ba96c37277f8d6eca3f..134938d7815d9d7ec529656abe7d2b19d251951e 100644 (file)
@@ -151,7 +151,7 @@ public class FilenameIndex extends ScalarIndexExtension<String> {
   private static class MyDataIndexer implements DataIndexer<String, Void, FileContent> {
     @Override
     @NotNull
-    public Map<String, Void> map(final FileContent inputData) {
+    public Map<String, Void> map(@NotNull final FileContent inputData) {
       return Collections.singletonMap(inputData.getFileName(), null);
     }
   }
index c45a7993474b7147cc33f61c411c431a6875b338..3143e87d30420fc9791eaf755031d4eefa3ac81a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -37,7 +37,7 @@ public abstract class SingleEntryIndexer<V> implements DataIndexer<Integer, V, F
 
   @Override
   @NotNull
-  public final Map<Integer, V> map(FileContent inputData) {
+  public final Map<Integer, V> map(@NotNull FileContent inputData) {
     if (inputData == null) {
       return Collections.emptyMap();
     }
index 4300898ea57eea5a2465efd13b16332347f2673b..10de34286fb17dc26755f82d879303fae0804afd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -854,7 +854,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
     }
 
     @Override
-    public String getCharset(@NotNull VirtualFile file, byte[] content) {
+    public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
       return null;
     }
   }
index 6cf661d2cc6f6ad937329875532330c19d910d9b..27d58470fda8fb0cc3f3501e6689c377459d7f48 100644 (file)
@@ -61,7 +61,7 @@ public class TrigramIndex extends ScalarIndexExtension<Integer> {
     return new DataIndexer<Integer, Void, FileContent>() {
       @Override
       @NotNull
-      public Map<Integer, Void> map(FileContent inputData) {
+      public Map<Integer, Void> map(@NotNull FileContent inputData) {
         final Map<Integer, Void> result = new THashMap<Integer, Void>();
         TIntHashSet built = TrigramBuilder.buildTrigram(inputData.getContentAsText());
         built.forEach(new TIntProcedure() {
index 514f0777a6387180411a442bf66a62b3238503ae..8e3724d82ce350278f3f4acc3b6ba32dd82e1190 100644 (file)
@@ -68,7 +68,7 @@ public class FrameworkDetectionIndex extends ScalarIndexExtension<Integer> {
     return new DataIndexer<Integer, Void, FileContent>() {
       @NotNull
       @Override
-      public Map<Integer, Void> map(FileContent inputData) {
+      public Map<Integer, Void> map(@NotNull FileContent inputData) {
         final FileType fileType = inputData.getFileType();
         if (!detectors.containsKey(fileType)) {
           return Collections.emptyMap();
index 80188761441315f8a8166707fbe5d9e0d620c0bc..b0c58d3020092e98f683da9409bc5c47edbf8ee4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -91,7 +91,7 @@ public class EnforcedPlainTextFileTypeFactory extends FileTypeFactory {
       }
 
       @Override
-      public String getCharset(@NotNull VirtualFile file, byte[] content) {
+      public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
         return null;
       }
     };
index e0e4f66906d575bfa9af3368ed3b0f19984cbd26..6d009188e43547472484145c27acf0d057e08bc6 100644 (file)
@@ -82,7 +82,7 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
     return new DataIndexer<Key, List<FileIncludeInfoImpl>, FileContent>() {
       @Override
       @NotNull
-      public Map<Key, List<FileIncludeInfoImpl>> map(FileContent inputData) {
+      public Map<Key, List<FileIncludeInfoImpl>> map(@NotNull FileContent inputData) {
 
         Map<Key, List<FileIncludeInfoImpl>> map = new FactoryMap<Key, List<FileIncludeInfoImpl>>() {
           @Override
index ce374bbb2f716722c9aa28850cb54b6da00c365b..b92a3c0432ab52211356bea3124143b4e6c7594e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -77,7 +77,7 @@ public class UiScriptFileType implements FileType {
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
     return CharsetToolkit.UTF8;
   }
 }
index 22be737ddba11f0b450f375796709af0e88cd4d7..3742c2a901e67a6e1d0569f0f61909d08a3dda8c 100644 (file)
@@ -1,10 +1,25 @@
+/*
+ * Copyright 2000-2014 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.util.indexing;
 
-import com.intellij.openapi.application.AccessToken;
 import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ReadAction;
 import com.intellij.openapi.util.Computable;
+import org.jetbrains.annotations.NotNull;
 
+import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -15,8 +30,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 class TaskQueue {
   private final AtomicInteger myDoWorkRequest = new AtomicInteger();
   private final AtomicInteger myUpdatesCount = new AtomicInteger();
-  private final LinkedBlockingQueue<Runnable> myPendingWriteRequestsQueue = new LinkedBlockingQueue<Runnable>();
-  private final LinkedBlockingQueue<Runnable> myTimestampUpdates = new LinkedBlockingQueue<Runnable>();
+  private final BlockingQueue<Runnable> myPendingWriteRequestsQueue = new LinkedBlockingQueue<Runnable>();
+  private final BlockingQueue<Runnable> myTimestampUpdates = new LinkedBlockingQueue<Runnable>();
   private final int myLimit;
   private final int myStealLimit;
   private final int myTimeStampUpdateSizeLimit;
@@ -27,7 +42,7 @@ class TaskQueue {
     myTimeStampUpdateSizeLimit = 32;
   }
 
-  void submit(final Computable<Boolean> update, final Runnable successRunnable) {
+  void submit(@NotNull final Computable<Boolean> update, @NotNull final Runnable successRunnable) {
     int currentTasksCount = myUpdatesCount.incrementAndGet();
 
     myPendingWriteRequestsQueue.add(new Runnable() {
@@ -61,20 +76,19 @@ class TaskQueue {
     }
   }
 
-  private void applyTimeStamps(int max) {
-    Runnable runnable = myTimestampUpdates.poll();
+  private void applyTimeStamps(final int max) {
+    final Runnable runnable = myTimestampUpdates.poll();
     if (runnable == null) return;
-    int updates = 0;
-    AccessToken accessToken = ReadAction.start();
-    try {
-      while(runnable != null) {
-        runnable.run();
-        if (++updates == max) break;
-        runnable = myTimestampUpdates.poll();
+    ApplicationManager.getApplication().runReadAction(new Runnable() {
+      @Override
+      public void run() {
+        int updates = 0;
+        for (Runnable r = runnable; r != null; r = myTimestampUpdates.poll()) {
+          r.run();
+          if (++updates == max) break;
+        }
       }
-    } finally {
-      accessToken.finish();
-    }
+    });
   }
 
   public void ensureUpToDate() {
@@ -84,7 +98,8 @@ class TaskQueue {
         if (runnable != null) runnable.run();
       }
       applyTimeStamps(Integer.MAX_VALUE);
-    } catch (Exception e) {
+    }
+    catch (InterruptedException e) {
       throw new RuntimeException(e);
     }
   }
index 0b30e86ceba0a8f65b7c14536b8b113fc3ddad35..bff9dc107e43160fdea833313e309e14f80c232b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -63,7 +63,7 @@ public class WorkspaceFileType implements InternalFileType {
   }
 
   @Override
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return CharsetToolkit.UTF8;
   }
 }
index 9718f0b4dd2c87b7ede9f94c76f2036a64ecbac7..274a69275184504676791164f5fa7ecaf3f2a9e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,9 +27,9 @@ public interface FileTypeConsumer {
 
   void consume(@NotNull FileType fileType);
 
-  void consume(@NotNull FileType fileType, @NonNls final String extensions);
+  void consume(@NotNull FileType fileType, @NonNls String extensions);
 
-  void consume(@NotNull FileType fileType, final FileNameMatcher... matchers);
+  void consume(@NotNull FileType fileType, @NotNull FileNameMatcher... matchers);
 
   @Nullable
   FileType getStandardFileTypeByName(@NonNls @NotNull String name);
index afb00378c0b8462f54018e281fa567c5a091fd86..d9b3946cce741a83a97856eb17c27660cf7ccafa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class NativeFileType implements INativeFileType {
     return false;
   }
 
-  public String getCharset(@NotNull VirtualFile file, byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
     return null;
   }
 
index f7ab208f14cdd3ca431552c177d27b84c28ba256..3ad19615454b7061ed29ba6d8ffd35285fac1f59 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -69,7 +69,7 @@ public abstract class UserFileType <T extends UserFileType> implements FileType,
     return false;
   }
 
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return null;
   }
 
index eda48cc3be0385936b3e2de5316ba4eee36b7bf4..4cba9ddca7193dfdb3b552670c56c97eb466c596 100644 (file)
@@ -96,6 +96,13 @@ public interface ComponentPopupBuilder {
   @NotNull
   ComponentPopupBuilder setMinSize(Dimension minSize);
 
+  /**
+   * Use this method to customize shape of popup window (e.g. to use bounded corners).
+   */
+  @SuppressWarnings("UnusedDeclaration")//used in 'Presentation Assistant' plugin
+  @NotNull
+  ComponentPopupBuilder setMaskProvider(MaskProvider maskProvider);
+
   @NotNull
   ComponentPopupBuilder setAlpha(float alpha);
 
index 51edca1107ee9b353c22c60e64ed5fca71697724..6f3b59cf7a69e74a68842c7259be9651c74862b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -55,7 +55,7 @@ public class FileAttribute {
   }
 
   @Nullable
-  public DataInputStream readAttribute(VirtualFile file) {
+  public DataInputStream readAttribute(@NotNull VirtualFile file) {
     DataInputStream stream = ManagingFS.getInstance().readAttribute(file, this);
     if (stream != null) {
       try {
@@ -72,7 +72,8 @@ public class FileAttribute {
     return stream;
   }
 
-  public DataOutputStream writeAttribute(VirtualFile file) {
+  @NotNull
+  public DataOutputStream writeAttribute(@NotNull VirtualFile file) {
     final DataOutputStream stream = ManagingFS.getInstance().writeAttribute(file, this);
     try {
       DataInputOutputUtil.writeINT(stream, myVersion);
index 76bb6f25e3575f3eb021ed62794d8d31aad4d9c5..456282c1cc0eee0cd1401cc17946fd58ba9d1157 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -50,7 +50,10 @@ public class ScreenUtil {
       if (intersection.isEmpty()) continue;
       final int sq1 = intersection.width * intersection.height;
       final int sq2 = bounds.width * bounds.height;
-      return (double)sq1 / (double)sq2 > 0.1;
+      double visibleFraction = (double)sq1 / (double)sq2;
+      if (visibleFraction > 0.1) {
+        return true;
+      }
     }
     return false;
   }
index dbc2bc9124bafa63254981fa2b8628d55a4eec40..606f2f708e0b8ed748ac5d653674d9a1242beb5a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package com.intellij.ide.actions;
 
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.actionSystem.Separator;
 import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl;
 import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
 import com.intellij.openapi.options.SharedScheme;
+import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.openapi.project.Project;
 import org.jetbrains.annotations.NotNull;
 
@@ -54,7 +58,7 @@ public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction {
                                 final EditorColorsScheme current,
                                 final EditorColorsScheme scheme,
                                 final boolean addScheme) {
-    group.add(new AnAction(scheme.getName(), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) {
+    group.add(new DumbAwareAction(scheme.getName(), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) {
       public void actionPerformed(AnActionEvent e) {
         if (addScheme) {
           EditorColorsManager.getInstance().addColorsScheme(scheme);
index 30a5eece04a8bb9a0f7ea5a30aeeca31f5bd3ed5..0266cc4eda623befda229f459bd290a572ac7ebe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -45,4 +45,5 @@ public abstract class TabsPlacementAction extends ToggleAction implements DumbAw
   public static class Left   extends TabsPlacementAction {int getPlace() {return SwingConstants.LEFT;}}
   public static class Bottom extends TabsPlacementAction {int getPlace() {return SwingConstants.BOTTOM;}}
   public static class Right  extends TabsPlacementAction {int getPlace() {return SwingConstants.RIGHT;}}
+  public static class None   extends TabsPlacementAction {int getPlace() {return UISettings.TABS_NONE;}}
 }
diff --git a/platform/platform-impl/src/com/intellij/ide/errorTreeView/CustomizeColoredTreeCellRendererReplacement.java b/platform/platform-impl/src/com/intellij/ide/errorTreeView/CustomizeColoredTreeCellRendererReplacement.java
new file mode 100644 (file)
index 0000000..71383de
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2014 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.ide.errorTreeView;
+
+import com.intellij.ui.CustomizeColoredTreeCellRenderer;
+import com.intellij.ui.SimpleColoredComponent;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/25/14
+ */
+public abstract class CustomizeColoredTreeCellRendererReplacement extends CustomizeColoredTreeCellRenderer {
+  @Override
+  public final void customizeCellRenderer(SimpleColoredComponent renderer,
+                                    JTree tree,
+                                    Object value,
+                                    boolean selected,
+                                    boolean expanded,
+                                    boolean leaf,
+                                    int row,
+                                    boolean hasFocus) {
+  }
+
+  public abstract Component getTreeCellRendererComponent(JTree tree,
+                                                Object value,
+                                                boolean selected,
+                                                boolean expanded,
+                                                boolean leaf,
+                                                int row,
+                                                boolean hasFocus);
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/errorTreeView/EditableMessageElement.java b/platform/platform-impl/src/com/intellij/ide/errorTreeView/EditableMessageElement.java
new file mode 100644 (file)
index 0000000..f44264f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2014 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.ide.errorTreeView;
+
+import com.intellij.ui.CustomizeColoredTreeCellRenderer;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.tree.TreeCellEditor;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/26/14
+ */
+public interface EditableMessageElement {
+  @NotNull
+  TreeCellEditor getRightSelfEditor();
+  @Nullable
+  CustomizeColoredTreeCellRenderer getLeftSelfRenderer();
+
+  boolean startEditingOnMouseMove();
+}
index 4d199bb17b6bc447a9659f6a4e0800d5694de16c..b964f200fc41eff3e8461f96a748b39c496c3ed1 100644 (file)
@@ -271,6 +271,22 @@ public class ErrorViewStructure extends AbstractTreeStructure {
     }
   }
 
+  public void addNavigatableMessage(@NotNull String groupName,
+                                    @NotNull NavigatableMessageElement navigatableMessageElement) {
+    synchronized (myLock) {
+      List<NavigatableMessageElement> elements = myGroupNameToMessagesMap.get(groupName);
+      if (elements == null) {
+        elements = new ArrayList<NavigatableMessageElement>();
+        myGroupNameToMessagesMap.put(groupName, elements);
+      }
+      if (!myGroupNameToElementMap.containsKey(groupName)) {
+        myGroupNames.add(groupName);
+        myGroupNameToElementMap.put(groupName, navigatableMessageElement.getParent());
+      }
+      elements.add(navigatableMessageElement);
+    }
+  }
+
   private void addSimpleMessage(@NotNull ErrorTreeElementKind kind, final String[] text, final Object data) {
     addSimpleMessageElement(new SimpleMessageElement(kind, text, data));
   }
diff --git a/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewEditableErrorTreeViewPanel.java b/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewEditableErrorTreeViewPanel.java
new file mode 100644 (file)
index 0000000..a5000d2
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2014 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.ide.errorTreeView;
+
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nullable;
+
+public class NewEditableErrorTreeViewPanel extends NewErrorTreeViewPanel {
+
+
+  public NewEditableErrorTreeViewPanel(Project project, String helpId) {
+    this(project, helpId, true);
+  }
+
+  public NewEditableErrorTreeViewPanel(Project project, String helpId, boolean createExitAction) {
+    this(project, helpId, createExitAction, true);
+  }
+
+  public NewEditableErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar) {
+    this(project, helpId, createExitAction, createToolbar, null);
+  }
+
+  public NewEditableErrorTreeViewPanel(Project project,
+                                       String helpId,
+                                       boolean createExitAction,
+                                       boolean createToolbar,
+                                       @Nullable Runnable rerunAction) {
+    super(project, helpId, createExitAction, createToolbar, rerunAction);
+    NewErrorTreeEditor.install(myTree);
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java b/platform/platform-impl/src/com/intellij/ide/errorTreeView/NewErrorTreeEditor.java
new file mode 100644 (file)
index 0000000..e84f04d
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2000-2014 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.ide.errorTreeView;
+
+import com.intellij.ui.CustomizeColoredTreeCellRenderer;
+import com.intellij.ui.JBColor;
+import com.intellij.ui.LoadingNode;
+import com.intellij.ui.treeStructure.Tree;
+import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.tree.WideSelectionTreeUI;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeCellEditor;
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+import java.util.EventObject;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 3/25/14
+ */
+public class NewErrorTreeEditor extends AbstractCellEditor implements TreeCellEditor, MouseMotionListener {
+
+  public static void install(Tree tree) {
+    NewErrorTreeEditor treeEditor = new NewErrorTreeEditor(tree);
+    tree.setCellEditor(treeEditor);
+    tree.addMouseMotionListener(treeEditor);
+    tree.setEditable(true);
+  }
+
+  private final MyWrapperEditor myWrapperEditor;
+  private final CallingBackColoredTreeCellRenderer myColoredTreeCellRenderer;
+  private final CellEditorDelegate myRightCellRenderer;
+  private final JTree myTree;
+
+  private NewErrorTreeEditor(JTree tree) {
+    myTree = tree;
+    myRightCellRenderer = new CellEditorDelegate();
+    myColoredTreeCellRenderer = new CallingBackColoredTreeCellRenderer();
+    myWrapperEditor = new MyWrapperEditor(myColoredTreeCellRenderer, myRightCellRenderer);
+  }
+
+  @Override
+  public boolean isCellEditable(EventObject e) {
+    Object node;
+    if(e instanceof MouseEvent) {
+      final Point point = ((MouseEvent)e).getPoint();
+      final TreePath location = myTree.getClosestPathForLocation(point.x, point.y);
+      node = location.getLastPathComponent();
+    } else {
+      node = myTree.getLastSelectedPathComponent();
+    }
+    final ErrorTreeElement element = getElement(node);
+    return element instanceof EditableMessageElement;
+  }
+
+  @Override
+  public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
+    final ErrorTreeElement element = getElement(value);
+    if (element instanceof EditableMessageElement) {
+      EditableMessageElement editableMessageElement = (EditableMessageElement)element;
+      final CustomizeColoredTreeCellRenderer leftSelfRenderer = editableMessageElement.getLeftSelfRenderer();
+      final TreeCellEditor rightSelfEditor = editableMessageElement.getRightSelfEditor();
+      myColoredTreeCellRenderer.setCurrentCallback(leftSelfRenderer);
+      myRightCellRenderer.setCurrentCallback(rightSelfEditor);
+      return myWrapperEditor.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row);
+    }
+    return myTree.getCellRenderer().getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, true);
+  }
+
+  @Override
+  public Object getCellEditorValue() {
+    return null;
+  }
+
+  @Override
+  public void mouseDragged(MouseEvent e) {
+  }
+
+  @Override
+  public void mouseMoved(MouseEvent e) {
+    JTree tree = (JTree)e.getSource();
+    int selRow = tree.getRowForLocation(e.getX(), e.getY());
+    if (selRow != -1) {
+      TreePath treePath = tree.getPathForRow(selRow);
+      if (treePath != null && treePath != tree.getEditingPath()) {
+        final ErrorTreeElement element = getElement(treePath.getLastPathComponent());
+        if (element instanceof EditableMessageElement && ((EditableMessageElement)element).startEditingOnMouseMove()) {
+          if (!tree.isRowSelected(selRow)) {
+            tree.setSelectionRow(selRow);
+          }
+          tree.startEditingAtPath(treePath);
+        }
+      }
+    }
+  }
+
+  @Nullable
+  private static ErrorTreeElement getElement(@Nullable Object value) {
+    if (!(value instanceof DefaultMutableTreeNode)) return null;
+    final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
+    if (!(userObject instanceof ErrorTreeNodeDescriptor)) return null;
+    return ((ErrorTreeNodeDescriptor)userObject).getElement();
+  }
+
+  private static class MyWrapperEditor extends AbstractCellEditor implements TreeCellEditor {
+    private final TreeCellRenderer myLeft;
+    private final TreeCellEditor myRight;
+    private final JPanel myPanel;
+
+    public TreeCellRenderer getLeft() {
+      return myLeft;
+    }
+
+    public TreeCellEditor getRight() {
+      return myRight;
+    }
+
+    public MyWrapperEditor(final TreeCellRenderer left, final TreeCellEditor right) {
+      myLeft = left;
+      myRight = right;
+      myPanel = new JPanel(new BorderLayout());
+    }
+
+    public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
+      myPanel.removeAll();
+      myPanel.add(myLeft.getTreeCellRendererComponent(tree, value, false, expanded, leaf, row, true), BorderLayout.WEST);
+      myPanel.add(myRight.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row), BorderLayout.EAST);
+
+      if (UIUtil.isFullRowSelectionLAF()) {
+        myPanel.setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
+      }
+      else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
+        if (selected) {
+          myPanel.setBackground(UIUtil.getTreeSelectionBackground());
+        }
+      }
+      else if (selected) {
+        myPanel.setBackground(UIUtil.getTreeSelectionBackground());
+      }
+      else {
+        myPanel.setBackground(null);
+      }
+
+      if (value instanceof LoadingNode) {
+        myPanel.setForeground(JBColor.GRAY);
+      }
+      else {
+        myPanel.setForeground(tree.getForeground());
+      }
+
+      if (UIUtil.isUnderGTKLookAndFeel() ||
+          UIUtil.isUnderNimbusLookAndFeel() && selected ||
+          tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
+        myPanel.setOpaque(false);
+      }
+      return myPanel;
+    }
+
+    @Override
+    public Object getCellEditorValue() {
+      return null;
+    }
+  }
+
+
+  private static class CellEditorDelegate extends AbstractCellEditor implements TreeCellEditor {
+    private TreeCellEditor myCurrentCallback;
+
+    public Component getTreeCellEditorComponent(JTree tree,
+                                                Object value,
+                                                boolean selected,
+                                                boolean expanded,
+                                                boolean leaf,
+                                                int row) {
+      return myCurrentCallback.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row);
+    }
+
+    public void setCurrentCallback(final TreeCellEditor currentCallback) {
+      myCurrentCallback = currentCallback;
+    }
+
+    @Override
+    public Object getCellEditorValue() {
+      return null;
+    }
+  }
+}
index f9d8d9c6a195e1f05ab0408847833c1f01da922b..30e154a28d73265f527e00093730317828d82e53 100644 (file)
@@ -81,6 +81,11 @@ public class NewErrorTreeRenderer extends MultilineTreeCellRenderer {
                                                   boolean leaf,
                                                   int row,
                                                   boolean hasFocus) {
+      if (myCurrentCallback instanceof CustomizeColoredTreeCellRendererReplacement) {
+        return ((CustomizeColoredTreeCellRendererReplacement)myCurrentCallback)
+          .getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+      }
+
       clear();
       setBackground(UIUtil.getBgFillColor(tree));
 
@@ -131,6 +136,7 @@ public class NewErrorTreeRenderer extends MultilineTreeCellRenderer {
                                                   boolean leaf,
                                                   int row,
                                                   boolean hasFocus) {
+      myPanel.removeAll();
       myPanel.setBackground(tree.getBackground());
       myPanel.add(myLeft.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus), BorderLayout.WEST);
       myPanel.add(myRight.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus), BorderLayout.EAST);
@@ -139,7 +145,7 @@ public class NewErrorTreeRenderer extends MultilineTreeCellRenderer {
   }
 
   @NotNull
-  static String calcPrefix(@Nullable ErrorTreeElement element) {
+  public static String calcPrefix(@Nullable ErrorTreeElement element) {
     if(element instanceof SimpleMessageElement || element instanceof NavigatableMessageElement) {
       String prefix = element.getKind().getPresentableText();
 
index f619212db61d14674fd4cb2504746d5d96fd41cf..d842aa4ed0752ff48ffb2d2cb8e39fd831d9aa9f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -205,6 +205,8 @@ public class TipUIUtil {
   public static JEditorPane createTipBrowser() {
     JEditorPane browser = new JEditorPane();
     browser.setEditable(false);
+    HTMLEditorKit editorKit = new HTMLEditorKit();
+    browser.setEditorKit(editorKit);
     browser.setBackground(UIUtil.getTextFieldBackground());
     browser.addHyperlinkListener(
       new HyperlinkListener() {
@@ -215,23 +217,16 @@ public class TipUIUtil {
         }
       }
     );
-    HTMLEditorKit kit;
     try {
       // set default CSS for plugin tips
       URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css");
-      final StyleSheet styleSheet = new StyleSheet();
-      styleSheet.loadRules(new InputStreamReader(resource.openStream()), resource);
-      kit = new HTMLEditorKit() {
-        @Override
-        public StyleSheet getStyleSheet() {
-          return styleSheet;
-        }
-      };
+      StyleSheet sheet = new StyleSheet();
+      sheet.loadRules(new InputStreamReader(resource.openStream()), resource);
+      editorKit.setStyleSheet(sheet);
     }
     catch (IOException ignored) {
-      kit = new HTMLEditorKit();
     }
-    browser.setEditorKit(kit);
+
     return browser;
   }
 }
index ee2c8f00a5e6ca9edce3adbc8ca6b7bb5dc10881..4038a6ec18fca04a52d87d9070bb826e03609725 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public abstract class FakeFileType implements FileTypeIdentifiableByVirtualFile
     return true;
   }
 
-  public String getCharset(@NotNull VirtualFile file, final byte[] content) {
+  public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
     return null;
   }
 }
\ No newline at end of file
index 5a766c45775c9938a4f71079fcfc61b537f9989e..ff4781b26182d47d9a43184c01cd7a2e196976b7 100644 (file)
@@ -311,6 +311,11 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
     throw new IOException(VfsBundle.message("jar.modification.not.supported.error", vFile.getUrl()));
   }
 
+  @Override
+  public boolean markNewFilesAsDirty() {
+    return true;
+  }
+
   @Override
   public int getRank() {
     return 2;
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FogLayer.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FogLayer.java
deleted file mode 100644 (file)
index de0d401..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2000-2014 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.wm.impl;
-
-import com.intellij.concurrency.JobScheduler;
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.editor.impl.EditorComponentImpl;
-import com.intellij.openapi.editor.impl.EditorImpl;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.registry.Registry;
-import com.intellij.ui.ColorUtil;
-import com.intellij.ui.JBColor;
-import com.intellij.util.Alarm;
-import com.intellij.util.containers.HashMap;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.AWTEventListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Ellipse2D;
-import java.awt.image.BufferedImage;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Random;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-class FogLayer extends JComponent implements AWTEventListener, Runnable, Disposable {
-  private static final int MAX_SPOT_NUMBER = 20000;
-  private static final int LAYER_NUMBER = 5;
-  private static final int INIT_DELAY = 5000;
-  private static final int IDLE_THRESHOLD = 20000;
-  private static final int FADE_CYCLE = 20000;
-  private static final int EYE_SIZE = 50;
-  private static final int REPAINT_INTERVAL = 66;//ms
-  private static final Color BASE = Color.DARK_GRAY;
-  private static final Color D_BASE = Color.LIGHT_GRAY;
-  private static final Color FOG = new JBColor(ColorUtil.toAlpha(BASE, 1), ColorUtil.toAlpha(D_BASE, 1));
-  private static final double MIN_ROTATION_RATE = .0016;
-  private static final double MAX_ROTATION_RATE = .002;
-  private static final double MIN_SUBROTATION_RATE = 0.01;
-  private static final double MAX_SUBROTATION_RATE = 0.02;
-  private static final int SPOT_RADIUS_FACTOR = 150;
-
-
-  private final Random myRandom = new Random();
-  private final Alarm myAlarm;
-  private final AtomicBoolean myInitialized = new AtomicBoolean(false);
-  private final AtomicBoolean myDisposed = new AtomicBoolean(false);
-
-  private BufferedImage myTexture;
-  private HashMap<Integer, BufferedImage> myCache = new HashMap<Integer, BufferedImage>();
-
-
-  private double[] myTextureAngle = new double[LAYER_NUMBER];
-  private double[] myTextureRate = new double[LAYER_NUMBER];//rotation rate
-
-  private double[] myCenterAngle = new double[LAYER_NUMBER];
-  private double[] myCenterRate = new double[LAYER_NUMBER];
-  private long myLastTime = System.currentTimeMillis();
-  private Point myPoint = null;
-  private long myLastPaintTime = -1;
-  private long myStartPaintTime = -1;
-
-  private int myEffectiveRadius;
-  private final ScheduledFuture<?> myFuture;
-
-  static boolean isAvailable() {
-    return (new SimpleDateFormat("dd/MM").format(new Date()).equals("01/04") || Boolean.getBoolean("eggs"))
-           && !Registry.is("ui.no.bangs.and.whistles", false) && !Boolean.getBoolean("noeggs")
-           && Runtime.getRuntime().availableProcessors() >= 4;
-  }
-
-
-  FogLayer(Disposable parent) {
-    setOpaque(false);
-    myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
-    myFuture = JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() {
-      @Override
-      public void run() {
-        if (System.currentTimeMillis() - myLastTime >= IDLE_THRESHOLD &&
-            myPoint != null &&
-            myAlarm.isEmpty() &&
-            myInitialized.get() &&
-            !myDisposed.get()) {
-          repaint();
-        }
-      }
-    }, (long)INIT_DELAY, (long)REPAINT_INTERVAL, TimeUnit.MILLISECONDS);
-    Disposer.register(parent, this);
-  }
-
-  @Override
-  public void dispose() {
-    if (myDisposed.get()) return;
-    myFuture.cancel(true);
-    myDisposed.set(true);
-  }
-
-  @Override
-  public void addNotify() {
-    super.addNotify();
-    Toolkit.getDefaultToolkit().addAWTEventListener(this,
-                                                    AWTEvent.KEY_EVENT_MASK |
-                                                    AWTEvent.MOUSE_EVENT_MASK |
-                                                    AWTEvent.MOUSE_MOTION_EVENT_MASK
-    );
-  }
-
-  @Override
-  public void removeNotify() {
-    super.removeNotify();
-    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
-  }
-
-  //update textures
-  @Override
-  public void run() {
-    if (myPoint == null || myDisposed.get()) return;
-    if (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory() < 1L << 25) return;
-    int width = getWidth();
-    int height = getHeight();
-    myEffectiveRadius = (int)(Math.max(
-      Math.max(myPoint.distance(0, 0), myPoint.distance(width, 0)),
-      Math.max(myPoint.distance(0, height), myPoint.distance(width, height)))) + 2 * EYE_SIZE;
-
-    for (int i = 0; i < LAYER_NUMBER; i++) {
-      myTextureAngle[i] = getRandomDouble(0, 2 * Math.PI);
-      myTextureRate[i] = getRandomDouble(MIN_ROTATION_RATE, MAX_ROTATION_RATE) * ((myEffectiveRadius < 1000) ? 2 : 1);
-      myCenterAngle[i] = getRandomDouble(0, 2 * Math.PI);
-      myCenterRate[i] = -getRandomDouble(MIN_SUBROTATION_RATE, MAX_SUBROTATION_RATE) * (myRandom.nextDouble() > .5 ? 1 : -1);
-    }
-    myTexture = GraphicsEnvironment.getLocalGraphicsEnvironment()
-      .getDefaultScreenDevice().getDefaultConfiguration()
-      .createCompatibleImage(2 * myEffectiveRadius, 2 * myEffectiveRadius, Transparency.TRANSLUCENT);
-    myLastPaintTime = -1;
-    Graphics2D graphics = (Graphics2D)myTexture.getGraphics();
-    for (int j = 0; j < MAX_SPOT_NUMBER; j++) {
-      double v = (1 + Math.cos(myRandom.nextDouble() * Math.PI)) / 2;
-      v = Math.pow(v, .18);
-      double spotDistance = 2 * EYE_SIZE + (myEffectiveRadius - 2 * EYE_SIZE) * v;
-      double distanceRatio = spotDistance / myEffectiveRadius;
-      double minR = 30;
-      double maxR = Math.max(Math.sqrt(distanceRatio) * SPOT_RADIUS_FACTOR, minR);
-      int spotSize = (int)getRandomDouble(minR, maxR);
-      spotSize -= spotSize % 4;
-      double spotPhi = getRandomDouble(0, 2 * Math.PI);
-      BufferedImage ellipseImage = myCache.get(spotSize);
-      if (ellipseImage == null) {
-        myCache.put(spotSize, ellipseImage = GraphicsEnvironment.getLocalGraphicsEnvironment()
-          .getDefaultScreenDevice().getDefaultConfiguration()
-          .createCompatibleImage(spotSize, spotSize, Transparency.TRANSLUCENT));
-        Graphics2D g2d = (Graphics2D)ellipseImage.getGraphics();
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-        g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
-        g2d.setColor(FOG);
-        g2d.fill(new Ellipse2D.Double(0, 0, spotSize, spotSize)
-        );
-      }
-      graphics.drawImage(ellipseImage, (int)(myEffectiveRadius + spotDistance * Math.cos(spotPhi) - spotSize / 2),
-                         (int)(myEffectiveRadius - spotDistance * Math.sin(spotPhi) - spotSize / 2), this);
-    }
-    myCache.clear();
-    myStartPaintTime = -1;
-    myInitialized.set(true);
-  }
-
-  private double getRandomDouble(double min, double max) {
-    return min + myRandom.nextDouble() * (max - min);
-  }
-
-  @Override
-  public void reshape(int x, int y, int w, int h) {
-    int width = getWidth();
-    int height = getHeight();
-    super.reshape(x, y, w, h);
-    if (width != w || height != h) {
-      scheduleUpdate();
-    }
-  }
-
-  @Override
-  public void eventDispatched(AWTEvent event) {
-    myLastTime = System.currentTimeMillis();
-    myInitialized.set(false);
-    if (event instanceof KeyEvent) {
-      Component component = ((KeyEvent)event).getComponent();
-      if (component instanceof EditorComponentImpl) {
-        EditorImpl editor = ((EditorComponentImpl)component).getEditor();
-        Point position = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
-        myPoint = SwingUtilities.convertPoint(component, position, this);
-      }
-      else {
-        Point position = new Point(component.getWidth() / 2, component.getHeight() / 2);
-        myPoint = SwingUtilities.convertPoint(component, position, this);
-      }
-    }
-    if (event instanceof MouseEvent) {
-      if (event.getID() == MouseEvent.MOUSE_EXITED) {
-        myPoint = null;
-      }
-      else {
-        Point point = ((MouseEvent)event).getPoint();
-        myPoint = SwingUtilities.convertPoint(((MouseEvent)event).getComponent(), point, this);
-      }
-    }
-    if (myPoint != null) {
-      myPoint.x = Math.min(getWidth(), Math.max(0, myPoint.x));
-      myPoint.y = Math.min(getHeight(), Math.max(0, myPoint.y));
-      scheduleUpdate();
-    }
-  }
-
-  private void scheduleUpdate() {
-    if (myDisposed.get()) return;
-    myInitialized.set(false);
-    repaint();
-    myTexture = null;
-    myCache.clear();
-    myAlarm.cancelAllRequests();
-    myAlarm.addRequest(this, INIT_DELAY);
-  }
-
-  @Override
-  protected void paintComponent(Graphics g) {
-    long now = System.currentTimeMillis();
-    if (now - myLastTime < IDLE_THRESHOLD || myPoint == null || !myAlarm.isEmpty() || !myInitialized.get()) {
-      return;
-    }
-    Window window = SwingUtilities.getWindowAncestor(this);
-    if (window == null || !window.isActive()) {
-      myPoint = null;
-      return;
-    }
-    if (myLastPaintTime == -1) myLastPaintTime = now - REPAINT_INTERVAL;
-    if (myStartPaintTime == -1) myStartPaintTime = now;
-
-    long passedTime = now - myLastPaintTime;
-
-    for (int i = 0; i < LAYER_NUMBER; i++) {
-      myTextureAngle[i] += (myTextureRate[i] * passedTime) / REPAINT_INTERVAL;
-      myCenterAngle[i] += (myCenterRate[i] * passedTime) / REPAINT_INTERVAL;
-    }
-
-    double linearProgress = (double)(myLastPaintTime - myStartPaintTime) / FADE_CYCLE;
-    if (linearProgress > 1) {
-      myPoint = null;
-      repaint();
-      return;
-    }
-    double progress = (1 - Math.cos(2 * Math.PI * linearProgress)) / 2;
-
-
-    Graphics2D g2d = (Graphics2D)g.create();
-    try {
-      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-      g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
-      AffineTransform pointTransform = AffineTransform.getTranslateInstance(myPoint.x, myPoint.y);
-      AffineTransform oldTransform = g2d.getTransform();
-      pointTransform.concatenate(oldTransform);
-      float textureProgress = (float)(progress < 1 ? Math.sqrt(progress) * (LAYER_NUMBER + 1) : LAYER_NUMBER);
-      int textureNumber = (int)textureProgress;
-      float localProgress = textureProgress - textureNumber;
-      for (int i = 0; i < textureNumber; i++) {
-        AffineTransform t = AffineTransform.getRotateInstance(myTextureAngle[i]);
-        t.concatenate(
-          AffineTransform.getTranslateInstance(EYE_SIZE * Math.cos(myCenterAngle[i]), -EYE_SIZE * Math.sin(myCenterAngle[i])));
-        t.preConcatenate(pointTransform);
-        g2d.setTransform(t);
-        if (i == textureNumber - 1 && progress < 1) {
-          g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, localProgress));
-        }
-        g2d.drawImage(myTexture, -myEffectiveRadius, -myEffectiveRadius, this);
-      }
-    }
-    finally {
-      g2d.dispose();
-    }
-    myLastPaintTime = now;
-  }
-
-  @Override
-  public String toString() {
-    return "Day#16161";
-  }
-}
index 841634f4d7753c1b0a1fe60bc1219e33c823e112..89a0da4ee3b5f1f005cdb876eb0abf6578f2bb84 100644 (file)
@@ -130,21 +130,6 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
     super.setGlassPane(glass);
   }
 
-  @Override
-  public void setLayeredPane(final JLayeredPane layered) {
-    super.setLayeredPane(layered);
-    //noinspection UnnecessaryFullyQualifiedName
-    if (FogLayer.isAvailable()) {
-      //noinspection SSBasedInspection
-      SwingUtilities.invokeLater(new Runnable() {
-        @Override
-        public void run() {
-          layered.add(new FogLayer(myApplication), new Integer(JLayeredPane.DRAG_LAYER + 1));
-        }
-      });
-    }
-  }
-
 
   /**
    * Invoked when enclosed frame is being shown.
index 0495d41871dc5dc3ca7e72c78180e587a0f73b49..03cc488f45df52a5c1cbfcc7c23f08765bd2f5f7 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
 import com.intellij.openapi.application.Application;
-import com.intellij.openapi.application.ApplicationInfo;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ex.ApplicationInfoEx;
 import com.intellij.openapi.components.*;
@@ -129,10 +128,6 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat
 
   /**
    * invoked by reflection
-   * @param dataManager
-   * @param applicationInfoEx
-   * @param actionManager
-   * @param uiSettings
    */
   public WindowManagerImpl(DataManager dataManager,
                            ApplicationInfoEx applicationInfoEx,
@@ -182,6 +177,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat
     myScreenBounds = screenBounds;
 
     myActivationListener = new WindowAdapter() {
+      @Override
       public void windowActivated(WindowEvent e) {
         Window activeWindow = e.getWindow();
         if (activeWindow instanceof IdeFrameImpl) { // must be
@@ -224,6 +220,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat
     }
   }
 
+  @Override
   @NotNull
   public IdeFrameImpl[] getAllProjectFrames() {
     final Collection<IdeFrameImpl> ideFrames = myProject2Frame.values();
@@ -241,10 +238,12 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat
     myEventDispatcher.addListener(listener);
   }
 
+  @Override
   public void removeListener(final WindowManagerListener listener) {
     myEventDispatcher.removeListener(listener);
   }
 
+  @Override
   public final Rectangle getScreenBounds() {
     return myScreenBounds;
   }
@@ -264,6 +263,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat
     return null;
   }
 
+  @Override
   public final boolean isInsideScreenBounds(final int x, final int y, final int width) {
     return
       x >= myScreenBounds.x + 50 - width &&
@@ -272,10 +272,12 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat