Merge branch 'master' of git.labs.intellij.net:idea/community into smartcompletion
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Thu, 4 Feb 2010 12:42:09 +0000 (15:42 +0300)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Thu, 4 Feb 2010 12:42:09 +0000 (15:42 +0300)
378 files changed:
build/conf/mac/Contents/Resources/idea.icns
build/order.txt
community-resources/src/idea/IdeaApplicationInfo.xml
java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/BuildRecipeImpl.java
java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java
java/compiler/impl/src/com/intellij/packaging/impl/elements/ArchiveElementType.java
java/compiler/impl/src/com/intellij/packaging/impl/elements/DirectoryElementType.java
java/compiler/impl/src/com/intellij/packaging/impl/elements/PackagingElementFactoryImpl.java
java/compiler/openapi/src/com/intellij/packaging/artifacts/ArtifactTemplate.java
java/compiler/openapi/src/com/intellij/packaging/elements/CompositePackagingElementType.java
java/compiler/openapi/src/com/intellij/packaging/ui/ArtifactEditor.java
java/debugger/impl/src/com/intellij/debugger/settings/ArrayRendererConfigurable.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPanel.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactTypeCellRenderer.java [new file with mode: 0644]
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactsStructureConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactAction.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.form [new file with mode: 0644]
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java [new file with mode: 0644]
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/SurroundElementWithAction.java [new file with mode: 0644]
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/ModuleSourceItemGroup.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/SourceItemsTree.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/actions/SourceItemFindUsagesAction.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/actions/SourceItemNavigateAction.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java
java/java-impl/src/com/intellij/codeInspection/ex/StandardInspectionToolsProvider.java
java/java-impl/src/com/intellij/cyclicDependencies/actions/CyclicDependenciesAction.java
java/java-impl/src/com/intellij/psi/impl/ElementPresentationUtil.java
java/java-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java
java/java-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java
java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
java/java-impl/src/com/intellij/psi/impl/PsiImplUtil.java
java/java-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
java/java-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java
java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java
java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java
java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineParameterDialog.java
java/java-impl/src/com/intellij/refactoring/inline/InlineParameterExpressionProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassHandler.java
java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousConstructorProcessor.java
java/java-impl/src/com/intellij/refactoring/inline/InlineViewDescriptor.java
java/java-impl/src/com/intellij/refactoring/makeStatic/MakeClassStaticProcessor.java
java/java-impl/src/com/intellij/refactoring/move/MoveInstanceMembersUtil.java
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassToInnerProcessor.java
java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java
java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticParametersRenamerFactory.java
java/java-impl/src/com/intellij/slicer/SliceDereferenceUsage.java
java/java-impl/src/com/intellij/slicer/SliceLeafValueRootNode.java
java/java-impl/src/com/intellij/slicer/SliceNode.java
java/java-impl/src/com/intellij/slicer/SliceNullnessAnalyzer.java
java/java-impl/src/com/intellij/slicer/SliceTooComplexDFAUsage.java [new file with mode: 0644]
java/java-impl/src/com/intellij/slicer/SliceUsage.java
java/java-impl/src/com/intellij/slicer/SliceUtil.java
java/java-tests/testData/inspection/numericOverflow/simple/expected.xml [new file with mode: 0644]
java/java-tests/testData/inspection/numericOverflow/simple/src/Foo.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/WithSuperInside.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineMethod/WithSuperInside.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/HandleExceptions.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/HandleExceptions.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/Ref2ConstantsWithTheSameValue.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/Ref2ConstantsWithTheSameValue.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefArrayAccess.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefConstantAndField.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefNewInner.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefNewInnerForMethod.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefNewInnerForMethod.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefNewLocal.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefNewTopLevel.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefNewTopLevel.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefOuterThis.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefQualifiedThis.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefQualifiedThis.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalField.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalField.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalFieldOtherObject.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefThis.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineParameter/RefThis.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineToAnonymousClass/GetClassConflict.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineToAnonymousClass/MultipleAssignments.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineToAnonymousClass/MultipleAssignments.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineToAnonymousClass/NoInlineRecursiveAccess.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineToAnonymousClass/ParamTypeReplacement.java [new file with mode: 0644]
java/java-tests/testData/refactoring/inlineToAnonymousClass/ParamTypeReplacement.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/makeClassStatic/FieldInitializerMoveToConstructor.java [new file with mode: 0644]
java/java-tests/testData/refactoring/makeClassStatic/FieldInitializerMoveToConstructor_after.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/after/pack1/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/after/pack2/A.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/after/pack2/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/after/packUser/Class2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/before/pack1/Class1.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/before/pack1/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/before/pack2/A.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/before/pack2/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/insertInnerClassImport/before/packUser/Class2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/after/pack1/Usage.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/after/pack1/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/after/pack2/A.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/after/pack2/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/before/pack1/Class1.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/before/pack1/Usage.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/before/pack1/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/before/pack2/A.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveClassToInner/locallyUsedPackageLocalToPublicInterface/before/pack2/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/moveInner/qualifyThisHierarchy/after/pack1/DImpl.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveInner/qualifyThisHierarchy/after/pack1/MyRunnable.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveInner/qualifyThisHierarchy/before/pack1/DImpl.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveInstanceMethod/QualifyThisHierarchy.java [new file with mode: 0644]
java/java-tests/testData/refactoring/moveInstanceMethod/QualifyThisHierarchy.java.after [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/after/Bar.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/after/BarImpl.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/after/IBar.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/after/IFoo.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/before/Bar.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/before/BarImpl.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/before/IBar.java [new file with mode: 0644]
java/java-tests/testData/refactoring/safeDelete/multipleInterfacesImplementationThroughCommonInterface/before/IFoo.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInspection/NumericOverflowTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/MakeClassStaticTest.java
java/java-tests/testSrc/com/intellij/refactoring/MoveClassToInnerTest.java
java/java-tests/testSrc/com/intellij/refactoring/MoveInnerTest.java
java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineParameterTest.java
java/java-tests/testSrc/com/intellij/refactoring/inline/InlineToAnonymousClassTest.java
java/java-tests/testSrc/com/intellij/refactoring/moveMethod/MoveInstanceMethodTest.java
java/openapi/src/com/intellij/psi/util/TypeConversionUtil.java
platform/bootstrap/src/com/intellij/ide/startup/StartupActionScriptManager.java
platform/icons/src/general/help.png [new file with mode: 0644]
platform/icons/src/icon_CE.png [new file with mode: 0644]
platform/icons/src/icon_CEsmall.png [new file with mode: 0644]
platform/icons/src/icon_CEwhite.png [new file with mode: 0644]
platform/icons/src/idea.ico
platform/icons/src/idea_CE.ico [new file with mode: 0644]
platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
platform/lang-api/src/com/intellij/lang/TokenSeparatorGenerator.java [new file with mode: 0644]
platform/lang-api/src/com/intellij/openapi/roots/ProjectClasspathTraversing.java
platform/lang-api/src/com/intellij/openapi/roots/ProjectRootsTraversing.java
platform/lang-api/src/com/intellij/openapi/roots/RecursiveRootPolicy.java
platform/lang-api/src/com/intellij/psi/search/searches/DefinitionsSearch.java
platform/lang-api/src/com/intellij/psi/search/searches/ReferencesSearch.java
platform/lang-api/src/com/intellij/psi/util/PsiFilter.java [moved from platform/lang-impl/src/com/intellij/openapi/vcs/changes/PsiElementFilter.java with 75% similarity]
platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/BlankLinesSettingsProvider.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesConfigurable.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/codeInsight/codeFragment/CodeFragment.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java
platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/ListTemplatesHandler.java
platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java
platform/lang-impl/src/com/intellij/execution/ExecutionUtil.java
platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java
platform/lang-impl/src/com/intellij/facet/impl/FacetFinderImpl.java
platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmarkAction.java
platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleNumberedBookmarkActionBase.java
platform/lang-impl/src/com/intellij/lang/LanguageTokenSeparatorGenerators.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/openapi/vcs/changes/PsiChangeTracker.java
platform/lang-impl/src/com/intellij/psi/impl/meta/MetaRegistry.java
platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java
platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java
platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/PyExtractMethodDialog.form with 79% similarity]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/ExtractMethodDialog.java with 80% similarity]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractParameterTablePanel.java [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/ParameterTablePanel.java with 94% similarity]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractVariableData.java [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/VariableData.java with 91% similarity]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDecorator.java [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/ExtractMethodDecorator.java with 83% similarity]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodSettings.java [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/ExtractMethodSettings.java with 88% similarity]
platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodValidator.java [moved from platform/lang-impl/src/com/intellij/refactoring/extractmethod/ExtractMethodValidator.java with 94% similarity]
platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
platform/lang-impl/src/com/intellij/tools/ToolRunProfile.java
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
platform/platform-api/src/com/intellij/notification/Notifications.java
platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java
platform/platform-api/src/com/intellij/openapi/util/SimpleTimerTask.java
platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java
platform/platform-api/src/com/intellij/ui/EditorNotifications.java
platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java
platform/platform-impl/src/com/intellij/ide/actions/ResizeToolWindowAction.java
platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/FragmentHighlighterImpl.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/DiffMarkup.java
platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/SimpleDiffPanelState.java
platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java
platform/platform-impl/src/com/intellij/openapi/diff/impl/splitter/DividerPoligon.java
platform/platform-impl/src/com/intellij/openapi/diff/impl/splitter/LineBlocks.java
platform/platform-impl/src/com/intellij/openapi/diff/impl/util/TextDiffType.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/options/ex/SingleConfigurableEditor.java
platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFocusManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
platform/platform-impl/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
platform/platform-resources-en/src/messages/CommonBundle.properties
platform/platform-resources-en/src/messages/DiffBundle.properties
platform/platform-resources-en/src/messages/ProjectBundle.properties
platform/platform-resources-en/src/messages/RefactoringBundle.properties
platform/platform-resources-en/src/messages/VcsBundle.properties
platform/platform-resources/src/META-INF/LangExtensionPoints.xml
platform/platform-resources/src/componentSets/Platform.xml
platform/platform-resources/src/componentSets/UICore.xml
platform/platform-resources/src/idea/PlatformActions.xml
platform/testFramework/src/com/intellij/testFramework/TestEditorManagerImpl.java
platform/testFramework/src/com/intellij/testFramework/vcs/MockChangelistBuilder.java
platform/usageView/src/com/intellij/usages/PsiNamedElementUsageGroupBase.java [new file with mode: 0644]
platform/util/src/com/intellij/openapi/diff/LineTokenizer.java [moved from platform/platform-api/src/com/intellij/openapi/diff/LineTokenizer.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/ex/DiffFragment.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffFragment.java with 98% similarity]
platform/util/src/com/intellij/openapi/diff/impl/ComparisonPolicy.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/ComparisonPolicy.java with 96% similarity]
platform/util/src/com/intellij/openapi/diff/impl/DiffFragmentBuilder.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffFragmentBuilder.java with 99% similarity]
platform/util/src/com/intellij/openapi/diff/impl/DiffRange.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffRange.java with 99% similarity]
platform/util/src/com/intellij/openapi/diff/impl/fragments/Fragment.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/Fragment.java with 82% similarity]
platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentHighlighter.java [new file with mode: 0644]
platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentList.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/FragmentList.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentListImpl.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/FragmentListImpl.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/fragments/InlineFragment.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/InlineFragment.java with 82% similarity]
platform/util/src/com/intellij/openapi/diff/impl/fragments/LineBlock.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/LineBlock.java with 89% similarity]
platform/util/src/com/intellij/openapi/diff/impl/fragments/LineFragment.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/fragments/LineFragment.java with 73% similarity]
platform/util/src/com/intellij/openapi/diff/impl/highlighting/BufferedStringList.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/BufferedStringList.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/highlighting/FragmentSide.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/FragmentSide.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/highlighting/List2D.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/List2D.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/highlighting/Util.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/Util.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/processing/DiffCorrection.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/DiffCorrection.java with 96% similarity]
platform/util/src/com/intellij/openapi/diff/impl/processing/DiffPolicy.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/DiffPolicy.java with 92% similarity]
platform/util/src/com/intellij/openapi/diff/impl/processing/Formatting.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/Formatting.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/processing/Word.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/Word.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/util/TextDiffTypeEnum.java [new file with mode: 0644]
platform/util/src/com/intellij/util/QueryFactory.java
platform/util/src/com/intellij/util/ResourceUtil.java
platform/util/src/com/intellij/util/UniqueResultsQuery.java
platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangelistBuilder.java
platform/vcs-api/src/com/intellij/openapi/vcs/changes/EmptyChangelistBuilder.java
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchBuilder.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AbstractVcsAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/DescindingFilesFilter.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FileHolder.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FileHolderComposite.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/SwitchedFileHolder.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdatingChangeListBuilder.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/FilePatchInProgress.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/MergedDiffRequestPresentable.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListViewerDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeNodeDecorator.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowser.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserChangeNode.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesComparator.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesListView.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/RemoteStatusChangeNodeDecorator.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeModelBuilder.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java
platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/PatternValidator.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/util/SubstitutedExpressionEvaluationHelper.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/BrowseCvsRepositoryAction.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsExecution/CvsOperationExecutor.java
plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsstatuses/CvsChangeProvider.java
plugins/groovy/resources/inspectionDescriptions/GroovyResultOfArrayAllocationIgnored.html [deleted file]
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateFieldFix.java [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateFieldFromConstructorLabelFix.java [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateFieldFromUsageFix.java
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/QuickfixUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicMethodFix.java [moved from plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicFix.java with 75% similarity]
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicPropertyFix.java [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicMethodDialog.java
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicPropertyDialog.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspectionVisitor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionProvider.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyResultOfArrayAllocationIgnoredInspection.java [deleted file]
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyResultOfObjectAllocationIgnoredInspection.java
plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java
plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java
plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java
plugins/groovy/src/org/jetbrains/plugins/groovy/gant/AntTasksProvider.java
plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradlePositionManager.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/GroovySmartEnterProcessor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/arguments/GrArgumentLabel.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/arguments/GrNamedArgument.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrNewExpression.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFieldImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrNamedArgumentImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java
plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/MissingReturnTest.java [new file with mode: 0644]
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/dynamic/DynamicTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/smartEnter/SmartEnterTest.java
plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test [new file with mode: 0644]
plugins/groovy/testdata/highlighting/SingleAllocationInClosure.groovy [new file with mode: 0644]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnFromClosure.groovy [new file with mode: 0644]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnImplicitReturns.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnImplicitReturns.groovy with 92% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnLastNull.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnLastNull.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnOvertReturnType.groovy [new file with mode: 0644]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnThrowException.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnThrowException.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnTryCatch.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnTryCatch.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnWithAssertion.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnWithAssertion.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnWithIf.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnWithIf.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnWithLastLoop.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnWithLastLoop.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/MissingReturnWithUnknownCall.groovy [moved from plugins/groovy/testdata/highlighting/MissingReturnWithUnknownCall.groovy with 100% similarity]
plugins/groovy/testdata/highlighting/missingReturn/ReturnsWithoutValue.groovy [new file with mode: 0644]
plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJavaClasspathPolicyExtender.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessor.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/JavaClasspathConfigurationTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java
plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java
plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java
plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShowPropertiesDiffAction.java
plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShowPropertiesDiffWithLocalAction.java
plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShowSvnMapAction.java
plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GatheringChangelistBuilder.java
plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/context/XsltContextProvider.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/XsltReferenceProvider.java
resources-en/src/inspectionDescriptions/NumericOverflow.html [new file with mode: 0644]
resources-en/src/messages/CompilerBundle.properties
resources-en/src/messages/DebuggerBundle.properties
resources/src/componentSets/IdeaComponents.xml
resources/src/idea/IdeaActions.xml
xml/dom-impl/src/com/intellij/util/xml/impl/EvaluatedXmlNameImpl.java
xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java
xml/dom-impl/src/com/intellij/util/xml/impl/GetInvocation.java
xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java
xml/dom-openapi/src/com/intellij/util/xml/model/DomModelCache.java
xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileBasedUserDataCache.java
xml/impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java
xml/impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
xml/impl/src/com/intellij/xml/impl/dtd/XmlElementDescriptorImpl.java
xml/impl/src/com/intellij/xml/impl/dtd/XmlNSDescriptorImpl.java
xml/impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java
xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java
xml/impl/src/com/intellij/xml/util/XmlUtil.java

index b26ebf35cf4c2f046c4df27a30007f469bc48476..8b9cc02aa2963919760f8733519c352c80e75efb 100644 (file)
Binary files a/build/conf/mac/Contents/Resources/idea.icns and b/build/conf/mac/Contents/Resources/idea.icns differ
index b61ff7d46653090228468f37bee92f31683f2d0f..348e0fb43eec4a298333a32cc4f87f8e42720031 100644 (file)
@@ -7666,7 +7666,6 @@ org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyNonShortCircuitBooleanIns
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyInfiniteLoopStatementInspection.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyInfiniteRecursionInspection.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyDivideByZeroInspection.class:/plugins/Groovy/lib/Groovy.jar
-org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyResultOfArrayAllocationIgnoredInspection.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyResultOfObjectAllocationIgnoredInspection.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/naming/GroovyClassNamingConventionInspection.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/naming/ConventionInspection.class:/plugins/Groovy/lib/Groovy.jar
@@ -9001,7 +9000,6 @@ org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyNonShortCircuitBooleanIns
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyInfiniteLoopStatementInspection$Visitor.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyInfiniteRecursionInspection$Visitor.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyDivideByZeroInspection$Visitor.class:/plugins/Groovy/lib/Groovy.jar
-org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyResultOfArrayAllocationIgnoredInspection$Visitor.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyResultOfObjectAllocationIgnoredInspection$Visitor.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/utils/RegExFormatter.class:/plugins/Groovy/lib/Groovy.jar
 org/jetbrains/plugins/groovy/codeInspection/utils/RegExInputVerifier.class:/plugins/Groovy/lib/Groovy.jar
index d472995872f7db89f940ca8918e4066d17c97fd7..e9a399d6a09abab10628dafaa938f4de63677ce3 100644 (file)
@@ -5,7 +5,7 @@
   <install-over minbuild="0" maxbuild="0" version="9.0"/>
   <logo url="/idea_community_logo.png" textcolor="FFFFFF"/>
   <about url="/idea_community_about.png"/>
-  <icon size32="/icon.png" size16="/icon_small.png" size32opaque="/icon_white.png" size12="/general/toolWindowProject.png"/>
+  <icon size32="/icon_CE.png" size16="/icon_CEsmall.png" size32opaque="/icon_CEwhite.png" size12="/general/toolWindowProject.png"/>
   <package code="__PACKAGE_CODE__"/>
   <names product="IDEA" fullname="IntelliJ IDEA"/>
 
index 85cddf7838116cbe1508ae743b56dd1b820fd22b..d8b2065fa3d7a4409a2329dee126c35d9108d5bd 100644 (file)
@@ -19,7 +19,6 @@
  */
 package com.intellij.compiler.impl.packagingCompiler;
 
-import com.intellij.openapi.compiler.CompilerBundle;
 import com.intellij.openapi.compiler.make.BuildInstruction;
 import com.intellij.openapi.compiler.make.BuildInstructionVisitor;
 import com.intellij.openapi.compiler.make.BuildRecipe;
@@ -71,7 +70,7 @@ public class BuildRecipeImpl implements BuildRecipe {
   }
 
   public String toString() {
-    String s = CompilerBundle.message("message.text.build.recipe");
+    String s = "Build recipe:";
     for (BuildInstruction buildInstruction : myInstructions) {
       s += "\n" + buildInstruction + "; ";
     }
index c68fde48614c20dacccf9074d59e7a85f9b0f4a4..9dc9aa2f60de0673b55dfb0c824b87743a52ac0c 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.compiler.impl.packagingCompiler;
 
-import com.intellij.openapi.compiler.CompilerBundle;
 import com.intellij.openapi.compiler.make.BuildInstructionVisitor;
 import com.intellij.openapi.compiler.make.FileCopyInstruction;
 
@@ -35,7 +34,7 @@ public class FileCopyInstructionImpl extends BuildInstructionBase implements Fil
   }
 
   public String toString() {
-    return CompilerBundle.message("file.copy.instruction.file.to.file.message.text", getFile(), getOutputRelativePath());
+    return "Copy " + getFile() + "->" + getOutputRelativePath();
   }
 
   public boolean equals(Object o) {
index d5abb844fe8e70092b59d76cc0eeeb4d326cbc56..77c78ee99e5039a270d58b3befa23acaef54e1ed 100644 (file)
@@ -21,12 +21,12 @@ import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.packaging.elements.CompositePackagingElement;
 import com.intellij.packaging.elements.CompositePackagingElementType;
-import com.intellij.packaging.elements.PackagingElement;
 import com.intellij.packaging.impl.ui.properties.ArchiveElementPropertiesPanel;
 import com.intellij.packaging.ui.ArtifactEditorContext;
 import com.intellij.packaging.ui.PackagingElementPropertiesPanel;
 import com.intellij.util.Icons;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 
@@ -59,8 +59,8 @@ class ArchiveElementType extends CompositePackagingElementType<ArchivePackagingE
     return null;
   }
 
-  public PackagingElement<?> createComposite(@NotNull ArtifactEditorContext context, CompositePackagingElement<?> parent) {
-    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent, "archive", ".jar");
+  public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent, @Nullable String baseName, @NotNull ArtifactEditorContext context) {
+    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent, baseName != null ? baseName : "archive", ".jar");
     final String path = Messages.showInputDialog(context.getProject(), "Enter archive name: ", "New Archive", null, initialValue, new FilePathValidator());
     if (path == null) return null;
     return PackagingElementFactoryImpl.createDirectoryOrArchiveWithParents(path, true);
index d3b9a5dd4609ad75678a99a95744cd6c45621edd..b133880138268edfe7a877a39bd88d96a84a578f 100644 (file)
@@ -21,7 +21,6 @@ import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.packaging.elements.CompositePackagingElement;
 import com.intellij.packaging.elements.CompositePackagingElementType;
-import com.intellij.packaging.elements.PackagingElement;
 import com.intellij.packaging.impl.artifacts.ArtifactUtil;
 import com.intellij.packaging.impl.ui.properties.DirectoryElementPropertiesPanel;
 import com.intellij.packaging.ui.ArtifactEditorContext;
@@ -59,8 +58,8 @@ class DirectoryElementType extends CompositePackagingElementType<DirectoryPackag
     return null;
   }
 
-  public PackagingElement<?> createComposite(@NotNull ArtifactEditorContext context, CompositePackagingElement<?> parent) {
-    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent, "folder", "");
+  public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent, String baseName, @NotNull ArtifactEditorContext context) {
+    final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent, baseName != null ? baseName : "folder", "");
     String path = Messages.showInputDialog(context.getProject(), "Enter directory name: ", "New Directory", null, initialValue, new FilePathValidator());
     if (path == null) return null;
     return PackagingElementFactoryImpl.createDirectoryOrArchiveWithParents(path, false);
index 643853800cce6e80a86f2f36dbc69068618fee69..1d527a257ddc53066cd40a22da1a5a132d65e950 100644 (file)
@@ -291,12 +291,12 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
     return Collections.singletonList(root);
   }
 
-  public static PackagingElement<?> createDirectoryOrArchiveWithParents(@NotNull String path, final boolean archive) {
+  public static CompositePackagingElement<?> createDirectoryOrArchiveWithParents(@NotNull String path, final boolean archive) {
     path = FileUtil.toSystemIndependentName(path);
     final String parentPath = PathUtil.getParentPath(path);
     final String fileName = PathUtil.getFileName(path);
     final PackagingElement<?> element = archive ? new ArchivePackagingElement(fileName) : new DirectoryPackagingElement(fileName);
-    return getInstance().createParentDirectories(parentPath, element);
+    return (CompositePackagingElement<?>)getInstance().createParentDirectories(parentPath, element);
   }
 
   private static class ArtifactRootElementType extends PackagingElementType<ArtifactRootElement<?>> {
index 342ceb5b746227274fb5873dc70dd735354cdccd..b39bd8ac69928273b44b11ae2adeb6f5cdf22595 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.packaging.artifacts;
 
 import com.intellij.packaging.elements.CompositePackagingElement;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * @author nik
@@ -25,10 +26,50 @@ public abstract class ArtifactTemplate {
 
   public abstract String getPresentableName();
 
-  public abstract CompositePackagingElement<?> createRootElement(@NotNull String artifactName);
+  /**
+   * @deprecated override {@link #createArtifact()} instead
+   */
+  @Deprecated
+  public CompositePackagingElement<?> createRootElement(@NotNull String artifactName) {
+    return null;
+  }
 
+  /**
+   * @deprecated override {@link #createArtifact()} instead
+   */
+  @Deprecated
   @NotNull
   public String suggestArtifactName() {
     return "unnamed";
   }
+
+  @Nullable
+  public NewArtifactConfiguration createArtifact() {
+    final String name = suggestArtifactName();
+    return new NewArtifactConfiguration(createRootElement(name), name, null);
+  }
+
+  public static class NewArtifactConfiguration {
+    private final CompositePackagingElement<?> myRootElement;
+    private final String myArtifactName;
+    private final ArtifactType myArtifactType;
+
+    public NewArtifactConfiguration(CompositePackagingElement<?> rootElement, String artifactName, ArtifactType artifactType) {
+      myRootElement = rootElement;
+      myArtifactName = artifactName;
+      myArtifactType = artifactType;
+    }
+
+    public CompositePackagingElement<?> getRootElement() {
+      return myRootElement;
+    }
+
+    public String getArtifactName() {
+      return myArtifactName;
+    }
+
+    public ArtifactType getArtifactType() {
+      return myArtifactType;
+    }
+  }
 }
index 66025980b4c4ba309140299c33af795b38a76a7d..92af59db1a8c8abf6a198df652e57e1ddf2174d2 100644 (file)
@@ -39,11 +39,11 @@ public abstract class CompositePackagingElementType<E extends CompositePackaging
 
 
   @Nullable
-  protected abstract PackagingElement<?> createComposite(@NotNull ArtifactEditorContext context, CompositePackagingElement<?> parent);
+  public abstract CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent, @Nullable String baseName, @NotNull ArtifactEditorContext context);
 
   @NotNull
   public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
-    final PackagingElement<?> composite = createComposite(context, parent);
+    final PackagingElement<?> composite = createComposite(parent, null, context);
     return composite != null ? Collections.singletonList(composite) : Collections.<E>emptyList();
   }
 }
index 4609d97c51da7fbf77797de2ce09b2e554e128f5..144bda2e6e01ca6377134e3ce8b48b30f53af637 100644 (file)
@@ -33,4 +33,6 @@ public interface ArtifactEditor {
   void putModuleIntoDefaultLocation(@NotNull Module module);
 
   void addToClasspath(CompositePackagingElement<?> element, List<String> classpath);
+
+  boolean isDisposed();
 }
index bd872b0879b5baac8a6f63ddc97fe291a7bba5dc..a1a65b84602287699dd2700e4c85cbf6e226f53d 100644 (file)
@@ -31,7 +31,9 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{
   private JTextField myEntriesLimit;
   private JTextField myStartIndex;
   private JTextField myEndIndex;
-
+  private boolean myEntriesLimitUpdateEnabled = true;
+  private boolean myIndexUpdateEnabled = true;
+  
   private final ArrayRenderer myRenderer;
   private JComponent myPanel;
 
@@ -121,7 +123,16 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{
 
     final DocumentListener listener = new DocumentListener() {
       private void updateEntriesLimit() {
-        myEntriesLimit.setText(String.valueOf(getInt(myEndIndex) - getInt(myStartIndex) + 1));
+        final boolean state = myIndexUpdateEnabled;
+        myIndexUpdateEnabled = false;
+        try {
+          if (myEntriesLimitUpdateEnabled) {
+            myEntriesLimit.setText(String.valueOf(getInt(myEndIndex) - getInt(myStartIndex) + 1));
+          }
+        }
+        finally {
+          myIndexUpdateEnabled = state;
+        }
       }
       public void changedUpdate(DocumentEvent e) {
         updateEntriesLimit();
@@ -135,6 +146,31 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{
     };
     myStartIndex.getDocument().addDocumentListener(listener);
     myEndIndex.getDocument().addDocumentListener(listener);
+    myEntriesLimit.getDocument().addDocumentListener(new DocumentListener() {
+      private void updateEndIndex() {
+        final boolean state = myEntriesLimitUpdateEnabled;
+        myEntriesLimitUpdateEnabled = false;
+        try {
+          if (myIndexUpdateEnabled) {
+            myEndIndex.setText(String.valueOf(getInt(myEntriesLimit) + getInt(myStartIndex) - 1));
+          }
+        }
+        finally {
+          myEntriesLimitUpdateEnabled = state;
+        }
+      }
+      public void insertUpdate(DocumentEvent e) {
+        updateEndIndex();
+      }
+
+      public void removeUpdate(DocumentEvent e) {
+        updateEndIndex();
+      }
+
+      public void changedUpdate(DocumentEvent e) {
+        updateEndIndex();
+      }
+    });
     return myPanel;
   }
 
index 31ef0d280d61c13ad786e92fd9787eff9618ccf1..06bfd3b94767cd433e6926e4d0b7133630fe7109 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.psi.PsiField;
 import com.intellij.ui.IdeBorderFactory;
 import com.intellij.ui.ScrollPaneFactory;
 import com.intellij.ui.TableUtil;
+import com.intellij.util.ui.tree.TreeUtil;
 import com.intellij.xdebugger.impl.breakpoints.ui.AbstractBreakpointPanel;
 import gnu.trove.TIntArrayList;
 import org.jetbrains.annotations.NonNls;
@@ -34,6 +35,7 @@ import org.jetbrains.annotations.NonNls;
 import javax.swing.*;
 import javax.swing.event.*;
 import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
 import javax.swing.tree.TreeSelectionModel;
 import java.awt.*;
 import java.util.ArrayList;
@@ -378,27 +380,41 @@ public class BreakpointPanel extends AbstractBreakpointPanel<Breakpoint> {
 
   public void removeSelectedBreakpoints() {
     final Breakpoint[] selectedBreakpoints = getSelectedBreakpoints();
-    Breakpoint breakpointToSelect = null;
-    if (selectedBreakpoints.length > 0) {
-      if (isTreeShowing()) {
-        breakpointToSelect = myTree.getPreviousSibling(selectedBreakpoints[0]);
-      }
-      else {
-        final int index = myTable.getModel().getBreakpointIndex(selectedBreakpoints[0]) - 1;
-        if (index >= 0 && index < (myTable.getRowCount() - selectedBreakpoints.length)) {
-          breakpointToSelect = myTable.getModel().getBreakpoint(index);
-        }
-      }
+    if (selectedBreakpoints.length == 0) {
+      return;
+    }
+
+    final boolean inTreeMode = isTreeShowing();
+    
+    final int minSelectionIndex;
+    if (inTreeMode) {
+      minSelectionIndex = Math.max(0, myTree.getSelectionModel().getMinSelectionRow());
+    }
+    else {
+      minSelectionIndex = Math.max(0, myTable.getSelectionModel().getMinSelectionIndex());
     }
+
     myTree.removeBreakpoints(selectedBreakpoints);
     myTable.getModel().removeBreakpoints(selectedBreakpoints);
     myCurrentViewableBreakpoint = null;
-    if (breakpointToSelect != null) {
-      selectBreakpoint(breakpointToSelect);
+
+    if (inTreeMode) {
+      if (myTree.getRowCount() > 0) {
+        int rowToSelect = minSelectionIndex >= myTree.getRowCount()? myTree.getRowCount() - 1 : minSelectionIndex;
+        final TreePath path = myTree.getPathForRow(rowToSelect);
+        if (path != null) {
+          TreeUtil.selectPath(myTree, path, true);
+        }
+      }
     }
     else {
-      updateCurrentBreakpointPropertiesPanel();
+      if (myTable.getRowCount() > 0) { // if in table mode and there are items to select
+        int indexToSelect = minSelectionIndex >= myTable.getRowCount()? myTable.getRowCount() - 1 : minSelectionIndex;
+        TableUtil.selectRows(myTable, new int[] {indexToSelect});
+      }
     }
+
+    updateCurrentBreakpointPropertiesPanel();
   }
 
   public void insertBreakpointAt(Breakpoint breakpoint, int index) {
index 39aa60543a40d5d44411ceca40d5d280a974bc3b..255e9bfefd8b627cd89cd8c4c677ee4e1b7f114c 100644 (file)
@@ -108,16 +108,7 @@ public class ArtifactConfigurable extends ProjectStructureElementConfigurable<Ar
       artifactTypeBox.addItem(type);
     }
 
-    artifactTypeBox.setRenderer(new DefaultListCellRenderer() {
-      @Override
-      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
-        final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-        final ArtifactType type = (ArtifactType)value;
-        setIcon(type.getIcon());
-        setText(type.getPresentableName());
-        return component;
-      }
-    });
+    artifactTypeBox.setRenderer(new ArtifactTypeCellRenderer());
 
     artifactTypeBox.setSelectedItem(getArtifact().getArtifactType());
     artifactTypeBox.addActionListener(new ActionListener() {
@@ -148,4 +139,5 @@ public class ArtifactConfigurable extends ProjectStructureElementConfigurable<Ar
 
   public void disposeUIResources() {
   }
+
 }
index abc93e948ccaa647bba19723e003bee5f2ce7741..058e1c427034023e23999d152d9918b514a734b2 100644 (file)
@@ -15,6 +15,8 @@
  */
 package com.intellij.openapi.roots.ui.configuration.artifacts;
 
+import com.intellij.codeInsight.hint.HintManager;
+import com.intellij.codeInsight.hint.HintUtil;
 import com.intellij.ide.CommonActionsManager;
 import com.intellij.ide.DataManager;
 import com.intellij.ide.DefaultTreeExpander;
@@ -49,10 +51,8 @@ import com.intellij.packaging.impl.artifacts.ArtifactUtil;
 import com.intellij.packaging.impl.elements.ArchivePackagingElement;
 import com.intellij.packaging.impl.elements.ManifestFileUtil;
 import com.intellij.packaging.ui.ManifestFileConfiguration;
-import com.intellij.ui.PopupHandler;
-import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.ui.TabbedPaneWrapper;
-import com.intellij.ui.TreeToolTipHandler;
+import com.intellij.ui.*;
+import com.intellij.ui.awt.RelativePoint;
 import com.intellij.util.EventDispatcher;
 import com.intellij.util.Icons;
 import com.intellij.util.ui.ThreeStateCheckBox;
@@ -61,6 +61,8 @@ import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import javax.swing.border.Border;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -90,6 +92,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
   private TabbedPaneWrapper myTabbedPane;
   private ArtifactPropertiesEditors myPropertiesEditors;
   private ArtifactValidationManagerImpl myValidationManager;
+  private boolean myDisposed;
 
   public ArtifactEditorImpl(final @NotNull ArtifactsStructureConfigurableContext context, @NotNull Artifact artifact, @NotNull ArtifactEditorSettings settings) {
     myContext = createArtifactEditorContext(context);
@@ -200,9 +203,25 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
 
     final JPanel rightPanel = new JPanel(new BorderLayout());
     final JPanel rightTopPanel = new JPanel(new BorderLayout());
-    rightTopPanel.add(new JLabel("Available Elements (drag'n'drop to layout tree)"), BorderLayout.SOUTH);
+    final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
+    labelPanel.add(new JLabel("Available Elements"));
+    final HyperlinkLabel link = new HyperlinkLabel("");
+    link.setIcon(IconLoader.getIcon("/general/help.png"));
+    link.addHyperlinkListener(new HyperlinkListener() {
+      public void hyperlinkUpdate(HyperlinkEvent e) {
+        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+          final JLabel label = new JLabel(ProjectBundle.message("artifact.source.items.tree.tooltip"));
+          label.setBorder(HintUtil.createHintBorder());
+          label.setBackground(HintUtil.INFORMATION_COLOR);
+          label.setOpaque(true);
+          HintManager.getInstance().showHint(label, RelativePoint.getSouthEastOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
+        }
+      }
+    });
+    labelPanel.add(link);
+    rightTopPanel.add(labelPanel, BorderLayout.SOUTH);
     rightPanel.add(rightTopPanel, BorderLayout.NORTH);
-    rightPanel.add(ScrollPaneFactory.createScrollPane(mySourceItemsTree.getTree()), BorderLayout.CENTER);
+    rightPanel.add(ScrollPaneFactory.createScrollPane(mySourceItemsTree), BorderLayout.CENTER);
     rightPanel.setBorder(border);
     splitter.setSecondComponent(rightPanel);
 
@@ -303,6 +322,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
     popupActionGroup.add(new ExtractArtifactAction(this));
     popupActionGroup.add(new InlineArtifactAction(this));
     popupActionGroup.add(new RenamePackagingElementAction(this));
+    popupActionGroup.add(new SurroundElementWithAction(this));
     popupActionGroup.add(Separator.getInstance());
     popupActionGroup.add(new HideContentAction(this));
     popupActionGroup.add(new LayoutTreeNavigateAction(myLayoutTreeComponent));
@@ -350,6 +370,11 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
   }
 
   public void dispose() {
+    myDisposed = true;
+  }
+
+  public boolean isDisposed() {
+    return myDisposed;
   }
 
   public LayoutTreeComponent getLayoutTreeComponent() {
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactTypeCellRenderer.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactTypeCellRenderer.java
new file mode 100644 (file)
index 0000000..f2c633d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.ui.configuration.artifacts;
+
+import com.intellij.packaging.artifacts.ArtifactType;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+* @author nik
+*/
+public class ArtifactTypeCellRenderer extends DefaultListCellRenderer {
+  @Override
+  public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+    final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+    final ArtifactType type = (ArtifactType)value;
+    setIcon(type.getIcon());
+    setText(type.getPresentableName());
+    return component;
+  }
+}
index 6dfdc7a276a92ccf8da27a74217c6e261b44df85..750786171bf92219f83ba4ea019e6fe702a8c275 100644 (file)
@@ -38,7 +38,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.*;
 import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
 import com.intellij.openapi.ui.MasterDetailsStateService;
 import com.intellij.packaging.artifacts.*;
-import com.intellij.packaging.elements.CompositePackagingElement;
 import com.intellij.packaging.impl.artifacts.ArtifactUtil;
 import com.intellij.packaging.impl.artifacts.PackagingElementPath;
 import com.intellij.packaging.impl.artifacts.PackagingElementProcessor;
@@ -245,10 +244,10 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable {
       }
 
       @Override
-      public CompositePackagingElement<?> createRootElement(@NotNull String artifactName) {
-        return type.createRootElement(artifactName);
+      public NewArtifactConfiguration createArtifact() {
+        final String name = "unnamed";
+        return new NewArtifactConfiguration(type.createRootElement(name), name, type);
       }
-
     };
 
     if (templates.isEmpty()) {
@@ -265,14 +264,24 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable {
   }
 
   private void addArtifact(@NotNull ArtifactType type, @NotNull ArtifactTemplate artifactTemplate) {
-    final String baseName = artifactTemplate.suggestArtifactName();
+    final ArtifactTemplate.NewArtifactConfiguration configuration = artifactTemplate.createArtifact();
+    if (configuration == null) {
+      return;
+    }
+
+    final String baseName = configuration.getArtifactName();
     String name = baseName;
     int i = 2;
     while (myPackagingEditorContext.getArtifactModel().findArtifact(name) != null) {
       name = baseName + i;
       i++;
     }
-    final ModifiableArtifact artifact = myPackagingEditorContext.getOrCreateModifiableArtifactModel().addArtifact(name, type, artifactTemplate.createRootElement(name));
+
+    ArtifactType actualType = configuration.getArtifactType();
+    if (actualType == null) {
+      actualType = type;
+    }
+    final ModifiableArtifact artifact = myPackagingEditorContext.getOrCreateModifiableArtifactModel().addArtifact(name, actualType, configuration.getRootElement());
     selectNodeInTree(findNodeByObject(myRoot, artifact));
   }
 
index 1bbe35c178493900f5b5cb50551f98a1677dbc26..a3ab8d20e2abbd9a04ca414a2a6eea8bb60b499e 100644 (file)
@@ -22,14 +22,15 @@ import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorEx;
 import com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent;
 import com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection;
 import com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode;
-import com.intellij.openapi.ui.Messages;
 import com.intellij.packaging.artifacts.ArtifactPointerManager;
 import com.intellij.packaging.artifacts.ModifiableArtifact;
+import com.intellij.packaging.artifacts.ModifiableArtifactModel;
 import com.intellij.packaging.elements.CompositePackagingElement;
 import com.intellij.packaging.elements.PackagingElement;
 import com.intellij.packaging.impl.artifacts.ArtifactUtil;
-import com.intellij.packaging.impl.artifacts.PlainArtifactType;
 import com.intellij.packaging.impl.elements.ArtifactPackagingElement;
+import com.intellij.util.PathUtil;
+import com.intellij.util.containers.ContainerUtil;
 
 import java.util.Collection;
 
@@ -58,25 +59,32 @@ public class ExtractArtifactAction extends LayoutTreeActionBase {
       return;
     }
 
+
     final Collection<? extends PackagingElement> selectedElements = selection.getElements();
-    final String name = Messages.showInputDialog(myArtifactEditor.getMainComponent(), ProjectBundle.message("label.text.specify.artifact.name"),
-                                                 ProjectBundle.message("dialog.title.extract.artifact"), null);
-    if (name != null) {
-      final Project project = myArtifactEditor.getContext().getProject();
-      //todo[nik] select type?
-      final ModifiableArtifact artifact = myArtifactEditor.getContext().getOrCreateModifiableArtifactModel().addArtifact(name, PlainArtifactType.getInstance());
-      treeComponent.editLayout(new Runnable() {
-        public void run() {
-          for (PackagingElement<?> element : selectedElements) {
-            artifact.getRootElement().addOrFindChild(ArtifactUtil.copyWithChildren(element, project));
-          }
-          for (PackagingElement element : selectedElements) {
-            parent.removeChild(element);
-          }
-          parent.addOrFindChild(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifact, myArtifactEditor.getContext().getArtifactModel())));
-        }
-      });
-      treeComponent.rebuildTree();
+    String initialName = "artifact";
+    if (selectedElements.size() == 1) {
+      initialName = PathUtil.suggestFileName(ContainerUtil.getFirstItem(selectedElements, null).createPresentation(myArtifactEditor.getContext()).getPresentableName());
+    }
+    final ExtractArtifactDialog dialog = new ExtractArtifactDialog(myArtifactEditor.getContext(), treeComponent, initialName);
+    dialog.show();
+    if (!dialog.isOK()) {
+      return;
     }
+
+    final Project project = myArtifactEditor.getContext().getProject();
+    final ModifiableArtifactModel model = myArtifactEditor.getContext().getOrCreateModifiableArtifactModel();
+    final ModifiableArtifact artifact = model.addArtifact(dialog.getArtifactName(), dialog.getArtifactType());
+    treeComponent.editLayout(new Runnable() {
+      public void run() {
+        for (PackagingElement<?> element : selectedElements) {
+          artifact.getRootElement().addOrFindChild(ArtifactUtil.copyWithChildren(element, project));
+        }
+        for (PackagingElement element : selectedElements) {
+          parent.removeChild(element);
+        }
+        parent.addOrFindChild(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifact, myArtifactEditor.getContext().getArtifactModel())));
+      }
+    });
+    treeComponent.rebuildTree();
   }
 }
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.form b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.form
new file mode 100644 (file)
index 0000000..d7499bf
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.roots.ui.configuration.artifacts.actions.ExtractArtifactDialog">
+  <grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+    <margin top="0" left="0" bottom="0" right="0"/>
+    <constraints>
+      <xy x="20" y="20" width="500" height="400"/>
+    </constraints>
+    <properties/>
+    <border type="none"/>
+    <children>
+      <component id="7d6b1" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <labelFor value="e88c4"/>
+          <text resource-bundle="messages/ProjectBundle" key="label.text.specify.artifact.name"/>
+        </properties>
+      </component>
+      <vspacer id="d3681">
+        <constraints>
+          <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+        </constraints>
+      </vspacer>
+      <component id="e88c4" class="javax.swing.JTextField" binding="myNameField">
+        <constraints>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="1" use-parent-layout="false">
+            <preferred-size width="150" height="-1"/>
+          </grid>
+        </constraints>
+        <properties/>
+      </component>
+      <component id="facb9" class="javax.swing.JLabel">
+        <constraints>
+          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <labelFor value="b2bb9"/>
+          <text value="Select artifact &amp;type:"/>
+        </properties>
+      </component>
+      <component id="b2bb9" class="javax.swing.JComboBox" binding="myTypeBox">
+        <constraints>
+          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+      </component>
+    </children>
+  </grid>
+</form>
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/ExtractArtifactDialog.java
new file mode 100644 (file)
index 0000000..11752e6
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.ui.configuration.artifacts.actions;
+
+import com.intellij.CommonBundle;
+import com.intellij.openapi.project.ProjectBundle;
+import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactTypeCellRenderer;
+import com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.packaging.artifacts.ArtifactType;
+import com.intellij.packaging.impl.artifacts.PlainArtifactType;
+import com.intellij.packaging.ui.ArtifactEditorContext;
+import com.intellij.ui.DocumentAdapter;
+
+import javax.swing.*;
+import javax.swing.event.DocumentEvent;
+
+/**
+ * @author nik
+ */
+public class ExtractArtifactDialog extends DialogWrapper {
+  private JPanel myMainPanel;
+  private JTextField myNameField;
+  private JComboBox myTypeBox;
+  private final ArtifactEditorContext myContext;
+
+  public ExtractArtifactDialog(ArtifactEditorContext context, LayoutTreeComponent treeComponent, String initialName) {
+    super(treeComponent.getLayoutTree(), true);
+    myContext = context;
+    setTitle(ProjectBundle.message("dialog.title.extract.artifact"));
+    for (ArtifactType type : ArtifactType.getAllTypes()) {
+      myTypeBox.addItem(type);
+    }
+    myTypeBox.setSelectedItem(PlainArtifactType.getInstance());
+    myTypeBox.setRenderer(new ArtifactTypeCellRenderer());
+    myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
+      @Override
+      protected void textChanged(DocumentEvent e) {
+        setOKActionEnabled(!StringUtil.isEmptyOrSpaces(getArtifactName()));
+      }
+    });
+    myNameField.setText(initialName);
+    init();
+  }
+
+  @Override
+  protected void doOKAction() {
+    final String artifactName = getArtifactName();
+    if (myContext.getArtifactModel().findArtifact(artifactName) != null) {
+      Messages.showErrorDialog(myContext.getProject(), "Artifact '" + artifactName + "' already exists!", CommonBundle.getErrorTitle());
+      return;
+    }
+    super.doOKAction();
+  }
+
+  @Override
+  protected JComponent createCenterPanel() {
+    return myMainPanel;
+  }
+
+  public String getArtifactName() {
+    return myNameField.getText();
+  }
+
+  public ArtifactType getArtifactType() {
+    return (ArtifactType)myTypeBox.getSelectedItem();
+  }
+
+  @Override
+  public JComponent getPreferredFocusedComponent() {
+    return myNameField;
+  }
+}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/SurroundElementWithAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/actions/SurroundElementWithAction.java
new file mode 100644 (file)
index 0000000..686f241
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.ui.configuration.artifacts.actions;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CustomShortcutSet;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.keymap.KeymapManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorEx;
+import com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent;
+import com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection;
+import com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.ui.popup.PopupStep;
+import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.packaging.elements.CompositePackagingElement;
+import com.intellij.packaging.elements.CompositePackagingElementType;
+import com.intellij.packaging.elements.PackagingElement;
+import com.intellij.packaging.elements.PackagingElementFactory;
+import com.intellij.packaging.impl.artifacts.ArtifactUtil;
+import com.intellij.util.PathUtil;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public class SurroundElementWithAction extends LayoutTreeActionBase {
+  public SurroundElementWithAction(ArtifactEditorEx artifactEditor) {
+    super("Surround With...", artifactEditor);
+    final CustomShortcutSet shortcutSet = new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("SurroundWith"));
+    registerCustomShortcutSet(shortcutSet, artifactEditor.getLayoutTreeComponent().getLayoutTree());
+  }
+
+  @Override
+  protected boolean isEnabled() {
+    return myArtifactEditor.getLayoutTreeComponent().getSelection().getCommonParentElement() != null;
+  }
+
+  @Override
+  public void actionPerformed(AnActionEvent e) {
+    final LayoutTreeComponent treeComponent = myArtifactEditor.getLayoutTreeComponent();
+    final LayoutTreeSelection selection = treeComponent.getSelection();
+    final CompositePackagingElement<?> parent = selection.getCommonParentElement();
+    if (parent == null) return;
+    final PackagingElementNode<?> parentNode = selection.getNodes().get(0).getParentNode();
+    if (parentNode == null) return;
+
+    if (!treeComponent.checkCanModifyChildren(parent, parentNode, selection.getNodes())) {
+      return;
+    }
+
+    final CompositePackagingElementType<?>[] types = PackagingElementFactory.getInstance().getCompositeElementTypes();
+    final List<PackagingElement<?>> selected = selection.getElements();
+    if (types.length == 1) {
+      surroundWith(types[0], parent, selected, treeComponent);
+    }
+    else {
+      JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<CompositePackagingElementType>("Surround With...", types) {
+        @Override
+        public Icon getIconFor(CompositePackagingElementType aValue) {
+          return aValue.getCreateElementIcon();
+        }
+
+        @NotNull
+        @Override
+        public String getTextFor(CompositePackagingElementType value) {
+          return value.getPresentableName();
+        }
+
+        @Override
+        public PopupStep onChosen(final CompositePackagingElementType selectedValue, boolean finalChoice) {
+          ApplicationManager.getApplication().invokeLater(new Runnable() {
+            public void run() {
+              surroundWith(selectedValue, parent, selected, treeComponent);
+            }
+          });
+          return FINAL_CHOICE;
+        }
+      }).showInBestPositionFor(e.getDataContext());
+    }
+  }
+
+  private void surroundWith(final CompositePackagingElementType<?> type, final CompositePackagingElement<?> parent, final List<PackagingElement<?>> selected,
+                            LayoutTreeComponent treeComponent) {
+    if (myArtifactEditor.isDisposed() || selected.isEmpty()) return;
+
+    final Project project = myArtifactEditor.getContext().getProject();
+    final String elementName = ContainerUtil.getFirstItem(selected, null).createPresentation(myArtifactEditor.getContext()).getPresentableName();
+    final String baseName = PathUtil.suggestFileName(elementName);
+    final CompositePackagingElement<?> newParent = type.createComposite(parent, baseName, myArtifactEditor.getContext());
+    if (newParent != null) {
+      treeComponent.editLayout(new Runnable() {
+        public void run() {
+          for (PackagingElement<?> element : selected) {
+            newParent.addOrFindChild(ArtifactUtil.copyWithChildren(element, project));
+          }
+          for (PackagingElement<?> element : selected) {
+            parent.removeChild(element);
+          }
+          parent.addOrFindChild(newParent);
+        }
+      });
+      treeComponent.rebuildTree();
+    }
+  }
+}
index 483acd57e62c6936883fa4d52b648263525f1f76..cb176187e3a519a0e9294eb976ddffae46d2c3fe 100644 (file)
@@ -17,17 +17,19 @@ package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems;
 
 import com.intellij.ide.projectView.PresentationData;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.roots.DependencyScope;
+import com.intellij.openapi.roots.ModuleOrderEntry;
+import com.intellij.openapi.roots.OrderEntry;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactType;
 import com.intellij.packaging.elements.PackagingElement;
-import com.intellij.packaging.ui.ArtifactEditorContext;
-import com.intellij.packaging.ui.PackagingSourceItem;
-import com.intellij.packaging.ui.SourceItemPresentation;
-import com.intellij.packaging.ui.SourceItemWeights;
+import com.intellij.packaging.elements.PackagingElementFactory;
+import com.intellij.packaging.ui.*;
 import com.intellij.ui.ColoredTreeCellRenderer;
 import com.intellij.ui.SimpleTextAttributes;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 
 /**
  * @author nik
@@ -36,7 +38,7 @@ public class ModuleSourceItemGroup extends PackagingSourceItem {
   private final Module myModule;
 
   public ModuleSourceItemGroup(@NotNull Module module) {
-    super(false);
+    super(true);
     myModule = module;
   }
 
@@ -54,7 +56,47 @@ public class ModuleSourceItemGroup extends PackagingSourceItem {
 
   @NotNull
   public List<? extends PackagingElement<?>> createElements(@NotNull ArtifactEditorContext context) {
-    return Collections.emptyList();
+    final Set<Module> modules = new LinkedHashSet<Module>();
+    collectDependentModules(myModule, modules, context);
+
+    final Artifact artifact = context.getArtifact();
+    final ArtifactType artifactType = artifact.getArtifactType();
+    Set<PackagingSourceItem> items = new LinkedHashSet<PackagingSourceItem>();
+    for (Module module : modules) {
+      for (PackagingSourceItemsProvider provider : PackagingSourceItemsProvider.EP_NAME.getExtensions()) {
+        final ModuleSourceItemGroup parent = new ModuleSourceItemGroup(module);
+        for (PackagingSourceItem sourceItem : provider.getSourceItems(context, artifact, parent)) {
+          if (artifactType.isSuitableItem(sourceItem) && sourceItem.isProvideElements()) {
+            items.add(sourceItem);
+          }
+        }
+      }
+    }
+
+    List<PackagingElement<?>> result = new ArrayList<PackagingElement<?>>();
+    final PackagingElementFactory factory = PackagingElementFactory.getInstance();
+    for (PackagingSourceItem item : items) {
+      final String path = artifactType.getDefaultPathFor(item.getKindOfProducedElements());
+      if (path != null) {
+        result.addAll(factory.createParentDirectories(path, item.createElements(context)));
+      }
+    }
+    return result;
+  }
+
+  private static void collectDependentModules(final Module module, Set<Module> modules, ArtifactEditorContext context) {
+    if (!modules.add(module)) return;
+    
+    for (OrderEntry entry : context.getModulesProvider().getRootModel(module).getOrderEntries()) {
+      if (entry instanceof ModuleOrderEntry) {
+        final ModuleOrderEntry moduleEntry = (ModuleOrderEntry)entry;
+        final Module dependency = moduleEntry.getModule();
+        final DependencyScope scope = moduleEntry.getScope();
+        if (dependency != null && scope != DependencyScope.TEST && scope != DependencyScope.PROVIDED) {
+          collectDependentModules(dependency, modules, context);
+        }
+      }
+    }
   }
 
   public Module getModule() {
index 615542cd1d4697228d333f002830b23e86ba5f35..a7597efd4d1a109c40c70d3a34d3e541600868e4 100644 (file)
@@ -17,10 +17,10 @@ package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems;
 
 import com.intellij.ide.CommonActionsManager;
 import com.intellij.ide.DefaultTreeExpander;
+import com.intellij.ide.dnd.AdvancedDnDSource;
 import com.intellij.ide.dnd.DnDAction;
 import com.intellij.ide.dnd.DnDDragStartBean;
 import com.intellij.ide.dnd.DnDManager;
-import com.intellij.ide.dnd.DnDSource;
 import com.intellij.ide.dnd.aware.DnDAwareTree;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
@@ -37,7 +37,6 @@ import com.intellij.packaging.ui.PackagingSourceItem;
 import com.intellij.ui.PopupHandler;
 import com.intellij.ui.treeStructure.SimpleTreeBuilder;
 import com.intellij.ui.treeStructure.SimpleTreeStructure;
-import com.intellij.ui.treeStructure.Tree;
 import com.intellij.ui.treeStructure.WeightBasedComparator;
 import com.intellij.util.ui.tree.TreeUtil;
 
@@ -49,22 +48,24 @@ import java.util.List;
 /**
  * @author nik
  */
-public class SourceItemsTree implements DnDSource, Disposable{
-  private SimpleDnDAwareTree myTree;
+public class SourceItemsTree extends SimpleDnDAwareTree implements AdvancedDnDSource, Disposable{
   private final ArtifactEditorImpl myArtifactsEditor;
   private SimpleTreeBuilder myBuilder;
 
   public SourceItemsTree(ArtifactEditorContext editorContext, ArtifactEditorImpl artifactsEditor) {
     myArtifactsEditor = artifactsEditor;
-    myTree = new SimpleDnDAwareTree();
-    myBuilder = new SimpleTreeBuilder(myTree, myTree.getBuilderModel(), new SourceItemsTreeStructure(editorContext, artifactsEditor), new WeightBasedComparator(true));
-    myTree.setRootVisible(false);
-    myTree.setShowsRootHandles(true);
+    myBuilder = new SimpleTreeBuilder(this, this.getBuilderModel(), new SourceItemsTreeStructure(editorContext, artifactsEditor), new WeightBasedComparator(true));
+    setRootVisible(false);
+    setShowsRootHandles(true);
     Disposer.register(this, myBuilder);
+    PopupHandler.installPopupHandler(this, createPopupGroup(), ActionPlaces.UNKNOWN, ActionManager.getInstance());
+    installDnD();
+  }
+
+  private void installDnD() {
     if (!ApplicationManager.getApplication().isUnitTestMode()) {
-      DnDManager.getInstance().registerSource(this, myTree);
+      DnDManager.getInstance().registerSource(this);
     }
-    PopupHandler.installPopupHandler(myTree, createPopupGroup(), ActionPlaces.UNKNOWN, ActionManager.getInstance());
   }
 
   private ActionGroup createPopupGroup() {
@@ -77,11 +78,11 @@ public class SourceItemsTree implements DnDSource, Disposable{
     group.add(new SourceItemNavigateAction(this));
     group.add(new SourceItemFindUsagesAction(this, myArtifactsEditor.getContext().getProject(), myArtifactsEditor.getContext().getParent()));
 
-    DefaultTreeExpander expander = new DefaultTreeExpander(myTree);
+    DefaultTreeExpander expander = new DefaultTreeExpander(this);
     final CommonActionsManager commonActionsManager = CommonActionsManager.getInstance();
     group.add(Separator.getInstance());
-    group.addAction(commonActionsManager.createExpandAllAction(expander, myTree));
-    group.addAction(commonActionsManager.createCollapseAllAction(expander, myTree));
+    group.addAction(commonActionsManager.createExpandAllAction(expander, this));
+    group.addAction(commonActionsManager.createCollapseAllAction(expander, this));
     return group;
   }
 
@@ -93,18 +94,14 @@ public class SourceItemsTree implements DnDSource, Disposable{
     myBuilder.initRootNode();
   }
 
-  public Tree getTree() {
-    return myTree;
-  }
-
   public void dispose() {
     if (!ApplicationManager.getApplication().isUnitTestMode()) {
-      DnDManager.getInstance().unregisterSource(this, myTree);
+      DnDManager.getInstance().unregisterSource(this);
     }
   }
 
   private DefaultMutableTreeNode[] getSelectedTreeNodes() {
-    return myTree.getSelectedNodes(DefaultMutableTreeNode.class, null);
+    return getSelectedNodes(DefaultMutableTreeNode.class, null);
   }
 
   public boolean canStartDragging(DnDAction action, Point dragOrigin) {
@@ -141,9 +138,9 @@ public class SourceItemsTree implements DnDSource, Disposable{
   public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) {
     final DefaultMutableTreeNode[] nodes = getSelectedTreeNodes();
     if (nodes.length == 1) {
-      return DnDAwareTree.getDragImage(myTree, TreeUtil.getPathFromRoot(nodes[0]), dragOrigin);
+      return DnDAwareTree.getDragImage(this, TreeUtil.getPathFromRoot(nodes[0]), dragOrigin);
     }
-    return DnDAwareTree.getDragImage(myTree, ProjectBundle.message("drag.n.drop.text.0.packaging.elements", nodes.length), dragOrigin);
+    return DnDAwareTree.getDragImage(this, ProjectBundle.message("drag.n.drop.text.0.packaging.elements", nodes.length), dragOrigin);
   }
 
   public void dragDropEnd() {
index 44ec77dc7da224f408a4ba8e6acfa4e810f8b5af..b6a6bc66e296f9e7fbe603bf0e3dcd402538e806 100644 (file)
@@ -31,7 +31,7 @@ public class SourceItemFindUsagesAction extends ArtifactEditorFindUsagesActionBa
   private final SourceItemsTree myTree;
 
   public SourceItemFindUsagesAction(SourceItemsTree tree, Project project, ArtifactsStructureConfigurableContext artifactContext) {
-    super(tree.getTree(), project, artifactContext);
+    super(tree, project, artifactContext);
     myTree = tree;
   }
 
index 9f914d9741450b684c2ab81f5cf040c011306ebd..e066771f45aa31803cb8542c3d9078fc8977e3e4 100644 (file)
@@ -29,7 +29,7 @@ public class SourceItemNavigateAction extends ArtifactEditorNavigateActionBase {
   private final SourceItemsTree mySourceItemsTree;
 
   public SourceItemNavigateAction(SourceItemsTree sourceItemsTree) {
-    super(sourceItemsTree.getTree());
+    super(sourceItemsTree);
     mySourceItemsTree = sourceItemsTree;
   }
 
index 6594fcacc4c59e845917686e4a4559c06837f9fe..86c0da0a6c75ff74baab4c7915c67f09cf302ab7 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.impl;
 
 import com.intellij.codeHighlighting.Pass;
 import com.intellij.codeHighlighting.TextEditorHighlightingPass;
+import com.intellij.codeInsight.CodeInsightSettings;
 import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
@@ -680,7 +681,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
   }
 
   private boolean timeToOptimizeImports() {
-    if (!com.intellij.codeInsight.CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false;
+    if (!CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false;
 
     DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
     PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
index 775cf7597b224d15872d34ca09c26e3543cd40b3..9aaed86e9c53b3e850483aafd55b4b25eab1b001 100644 (file)
@@ -68,7 +68,6 @@ public class HighlightUtil {
   private static final Map<String, Set<String>> ourClassInitializerIncompatibleModifiers;
   private static final Set<String> ourConstructorNotAllowedModifiers;
 
-  private static final Key<String> HAS_OVERFLOW_IN_CHILD = Key.create("HAS_OVERFLOW_IN_CHILD");
   @NonNls private static final String SERIAL_VERSION_UID_FIELD_NAME = "serialVersionUID";
   @NonNls private static final String SERIAL_PERSISTENT_FIELDS_FIELD_NAME = "serialPersistentFields";
   private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
@@ -1766,30 +1765,6 @@ public class HighlightUtil {
   }
 
 
-  static HighlightInfo checkConstantExpressionOverflow(PsiExpression expr) {
-    boolean overflow = false;
-    try {
-      if (expr.getUserData(HAS_OVERFLOW_IN_CHILD) == null && TypeConversionUtil.isNumericType(expr.getType())) {
-        JavaPsiFacade.getInstance(expr.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr, true);
-      }
-      else {
-        overflow = true;
-      }
-    }
-    catch (ConstantEvaluationOverflowException e) {
-      overflow = true;
-      return HighlightInfo.createHighlightInfo(HighlightInfoType.OVERFLOW_WARNING, expr, JavaErrorMessages.message("numeric.overflow.in.expression"));
-    }
-    finally {
-      PsiElement parent = expr.getParent();
-      if (overflow && parent instanceof PsiExpression) {
-        parent.putUserData(HAS_OVERFLOW_IN_CHILD, "");
-      }
-    }
-
-    return null;
-  }
-
   @NonNls
   private static String redIfNotMatch(PsiType type, boolean matches) {
     if (matches) return getFQName(type, false);
index aabd791320d6a2aec6e332f55ecf6cd8eca245e7..393f3f204681eafb43ea8b2a15bd03878b9b41e9 100644 (file)
@@ -354,7 +354,6 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
     if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkAssertOperatorTypes(expression));
     if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkSynchronizedExpressionType(expression));
     if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkConditionalExpressionBranchTypesMatch(expression));
-    if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkConstantExpressionOverflow(expression));
     if (!myHolder.hasErrorResults()
         && expression.getParent() instanceof PsiThrowStatement
         && ((PsiThrowStatement)expression.getParent()).getException() == expression) {
diff --git a/java/java-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java b/java/java-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java
new file mode 100644 (file)
index 0000000..5fbf4c3
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.daemon.GroupNames;
+import com.intellij.codeInsight.daemon.JavaErrorMessages;
+import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
+import com.intellij.openapi.util.Key;
+import com.intellij.psi.*;
+import com.intellij.psi.util.ConstantEvaluationOverflowException;
+import com.intellij.psi.util.TypeConversionUtil;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * User: cdr
+ */
+public class NumericOverflowInspection extends BaseLocalInspectionTool {
+  private static final Key<String> HAS_OVERFLOW_IN_CHILD = Key.create("HAS_OVERFLOW_IN_CHILD");
+
+  @Nls
+  @NotNull
+  @Override
+  public String getGroupDisplayName() {
+    return GroupNames.NUMERIC_GROUP_NAME;
+  }
+
+  @Nls
+  @NotNull
+  @Override
+  public String getDisplayName() {
+    return "Numeric overflow";
+  }
+
+  @NotNull
+  @Override
+  public String getShortName() {
+    return "NumericOverflow";
+  }
+
+  @NotNull
+  @Override
+  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
+    return new JavaElementVisitor() {
+      @Override
+      public void visitReferenceExpression(PsiReferenceExpression expression) {
+        visitExpression(expression);
+      }
+
+      @Override
+      public void visitExpression(PsiExpression expression) {
+        boolean info = hasOverflow(expression);
+        if (info) {
+          holder.registerProblem(expression, JavaErrorMessages.message("numeric.overflow.in.expression"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+        }
+      }
+    };
+  }
+
+  private static boolean hasOverflow(PsiExpression expr) {
+    if (!TypeConversionUtil.isNumericType(expr.getType())) return false;
+    boolean overflow = false;
+    try {
+      if (expr.getUserData(HAS_OVERFLOW_IN_CHILD) == null) {
+        JavaPsiFacade.getInstance(expr.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr, true);
+      }
+      else {
+        overflow = true;
+      }
+    }
+    catch (ConstantEvaluationOverflowException e) {
+      overflow = true;
+    }
+    finally {
+      PsiElement parent = expr.getParent();
+      if (overflow && parent instanceof PsiExpression) {
+        parent.putUserData(HAS_OVERFLOW_IN_CHILD, "");
+      }
+    }
+
+    return overflow;
+  }
+
+}
index dc020b2206d0430f1e0841d213dc71756eb21145..1bcbe7ae9380aff21c949ace19398d4284b6efb4 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.CachedValue;
 import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.NullableFunction;
 import com.intellij.util.containers.ContainerUtil;
@@ -47,13 +48,15 @@ public class DfaUtil {
   private DfaUtil() {
   }
 
+  private static final MultiValuesMap<PsiVariable, PsiExpression> TOO_COMPLEX = new MultiValuesMap<PsiVariable, PsiExpression>();
+  @Nullable("null means DFA analysis has failed (too complex to analyze)")
   public static Collection<PsiExpression> getCachedVariableValues(@Nullable final PsiVariable variable, @Nullable final PsiElement context) {
     if (variable == null || context == null) return Collections.emptyList();
 
     CachedValue<MultiValuesMap<PsiVariable, PsiExpression>> cachedValue = context.getUserData(DFA_VARIABLE_INFO_KEY);
     if (cachedValue == null) {
       final PsiElement codeBlock = getEnclosingCodeBlock(variable, context);
-      cachedValue = context.getManager().getCachedValuesManager().createCachedValue(new CachedValueProvider<MultiValuesMap<PsiVariable, PsiExpression>>() {
+      cachedValue = CachedValuesManager.getManager(context.getProject()).createCachedValue(new CachedValueProvider<MultiValuesMap<PsiVariable, PsiExpression>>() {
         public Result<MultiValuesMap<PsiVariable, PsiExpression>> compute() {
           final MultiValuesMap<PsiVariable, PsiExpression> result;
           if (codeBlock == null) {
@@ -65,7 +68,7 @@ public class DfaUtil {
               result = visitor.myValues;
             }
             else {
-              result = null;
+              result = TOO_COMPLEX;
             }
           }
           return new Result<MultiValuesMap<PsiVariable, PsiExpression>>(result, codeBlock);
@@ -74,6 +77,7 @@ public class DfaUtil {
       context.putUserData(DFA_VARIABLE_INFO_KEY, cachedValue);
     }
     final MultiValuesMap<PsiVariable, PsiExpression> value = cachedValue.getValue();
+    if (value == TOO_COMPLEX) return null;
     final Collection<PsiExpression> expressions = value == null ? null : value.get(variable);
     return expressions == null ? Collections.<PsiExpression>emptyList() : expressions;
   }
@@ -81,7 +85,7 @@ public class DfaUtil {
   public static enum Nullness {
     NOT_NULL,NULL,UNKNOWN
   }
-  // TRUE->not null, FALSE->null, null->unknown
+
   @NotNull
   public static Nullness checkNullness(@Nullable final PsiVariable variable, @Nullable final PsiElement context) {
     if (variable == null || context == null) return Nullness.UNKNOWN;
@@ -139,6 +143,7 @@ public class DfaUtil {
     return codeBlock;
   }
 
+  @Nullable("null means DFA analysis has failed (too complex to analyze)")
   public static Collection<? extends PsiElement> getPossibleInitializationElements(final PsiElement qualifierExpression) {
     if (qualifierExpression instanceof PsiMethodCallExpression) {
       return Collections.singletonList(qualifierExpression);
@@ -146,7 +151,8 @@ public class DfaUtil {
     else if (qualifierExpression instanceof PsiReferenceExpression) {
       final PsiElement targetElement = ((PsiReferenceExpression)qualifierExpression).resolve();
       if (targetElement instanceof PsiVariable) {
-        final Collection<? extends PsiElement> variableValues = getCachedVariableValues((PsiVariable)targetElement, (PsiExpression)qualifierExpression);
+        final Collection<? extends PsiElement> variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression);
+        if (variableValues == null) return null;
         if (variableValues.isEmpty() && targetElement instanceof PsiField) {
           return getVariableAssignmentsInFile((PsiVariable)targetElement, false);
         }
@@ -159,6 +165,7 @@ public class DfaUtil {
     return Collections.emptyList();
   }
 
+  @NotNull
   public static Collection<PsiExpression> getVariableAssignmentsInFile(final PsiVariable psiVariable, final boolean literalsOnly) {
     final Ref<Boolean> modificationRef = Ref.create(Boolean.FALSE);
     final List<PsiExpression> list = ContainerUtil.mapNotNull(
index 5ced11509a14869cabc2e200ebc988e5e5763c8e..9978aecbd1ec3681c150465baf61cdfe2d762f67 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.ex;
 
 import com.intellij.codeInspection.InspectionToolProvider;
 import com.intellij.codeInspection.LossyEncodingInspection;
+import com.intellij.codeInspection.NumericOverflowInspection;
 import com.intellij.codeInspection.RedundantSuppressInspection;
 import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance;
 import com.intellij.codeInspection.canBeFinal.CanBeFinalInspection;
@@ -79,6 +80,7 @@ public class StandardInspectionToolsProvider implements InspectionToolProvider {
 
       DataFlowInspection.class,
       DefUseInspection.class,
+      NumericOverflowInspection.class,
       RedundantCastInspection.class,
       RedundantTypeArgsInspection.class,
       RedundantArrayForVarargsCallInspection.class,
index b1765a431d5c5fce08c89fc9e0ef89b9a690d154..615f21a72f70af6a8d6b9e9d82b990c9eed525f6 100644 (file)
@@ -36,12 +36,12 @@ import javax.swing.*;
  */
 public class CyclicDependenciesAction extends AnAction{
   private final String myAnalysisVerb;
-  private final String myAnalysisNoon;
+  private final String myAnalysisNoun;
   private final String myTitle;
 
   public CyclicDependenciesAction() {
     myAnalysisVerb = AnalysisScopeBundle.message("action.analyze.verb");
-    myAnalysisNoon = AnalysisScopeBundle.message("action.analysis.noun");
+    myAnalysisNoun = AnalysisScopeBundle.message("action.analysis.noun");
     myTitle = AnalysisScopeBundle.message("action.cyclic.dependency.title");
   }
 
@@ -167,7 +167,7 @@ public class CyclicDependenciesAction extends AnAction{
     }
 
     protected JComponent createCenterPanel() {
-      myScopePanel.setBorder(IdeBorderFactory.createTitledBorder(AnalysisScopeBundle.message("analysis.scope.title", myAnalysisNoon)));
+      myScopePanel.setBorder(IdeBorderFactory.createTitledBorder(AnalysisScopeBundle.message("analysis.scope.title", myAnalysisNoun)));
       myProjectButton.setText(AnalysisScopeBundle.message("cyclic.dependencies.scope.dialog.project.button", myAnalysisVerb));
       ButtonGroup group = new ButtonGroup();
       group.add(myProjectButton);
index c6df423c7ca75192c9c4188cbbb4d32489a6daf4..c632be2bc9739b69c39a7c34702381e814a813c2 100644 (file)
@@ -119,7 +119,7 @@ public class ElementPresentationUtil {
 
     CachedValue<Integer> value = aClass.getUserData(CLASS_KIND_KEY);
     if (value == null) {
-      value = aClass.getManager().getCachedValuesManager().createCachedValue(new CachedValueProvider<Integer>() {
+      value = CachedValuesManager.getManager(aClass.getProject()).createCachedValue(new CachedValueProvider<Integer>() {
         public Result<Integer> compute() {
           return Result.createSingleDependency(Integer.valueOf(getClassKindImpl(aClass)), aClass);
         }
index f453e01fe5ad59a96de373ec11aee2ae2fadd60e..e705a693cc2790f915f034d1e1595e13e548e8e8 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.util.containers.HashSet;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.Set;
@@ -31,11 +32,11 @@ import java.util.Set;
 public class InheritanceImplUtil {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.InheritanceImplUtil");
 
-  public static boolean isInheritor(PsiClass candidateClass, final PsiClass baseClass, final boolean checkDeep) {
+  public static boolean isInheritor(@NotNull PsiClass candidateClass, @NotNull PsiClass baseClass, final boolean checkDeep) {
     return !(baseClass instanceof PsiAnonymousClass) && isInheritor(candidateClass, baseClass, checkDeep, null);
   }
 
-  private static boolean isInheritor(PsiClass candidateClass, PsiClass baseClass, boolean checkDeep, Set<PsiClass> checkedClasses) {
+  private static boolean isInheritor(@NotNull PsiClass candidateClass, @NotNull PsiClass baseClass, boolean checkDeep, Set<PsiClass> checkedClasses) {
     if (candidateClass instanceof PsiAnonymousClass) {
       final PsiClass baseCandidateClass = ((PsiAnonymousClass)candidateClass).getBaseClassType().resolve();
       return baseCandidateClass != null && InheritanceUtil.isInheritorOrSelf(baseCandidateClass, baseClass, checkDeep);
@@ -156,7 +157,7 @@ public class InheritanceImplUtil {
   }
 
   private static boolean checkInheritor(PsiClass aClass, PsiClass baseClass, boolean checkDeep, Set<PsiClass> checkedClasses) {
-    ProgressManager.getInstance().checkCanceled();
+    ProgressManager.checkCanceled();
     if (aClass != null) {
       PsiManager manager = baseClass.getManager();
       if (manager.areElementsEquivalent(baseClass, aClass)) {
@@ -174,7 +175,7 @@ public class InheritanceImplUtil {
     return false;
   }
 
-  public static boolean isInheritorDeep(final PsiClass candidateClass, final PsiClass baseClass, @Nullable final PsiClass classToByPass) {
+  public static boolean isInheritorDeep(@NotNull PsiClass candidateClass, @NotNull PsiClass baseClass, @Nullable final PsiClass classToByPass) {
     if (baseClass instanceof PsiAnonymousClass) {
       return false;
     }
index fda3fe6e00d5151a2ecfe9fde749c9b3a5bcf962..6286f0df796a80d6f92f15ab9377c9ba976fb920 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.Key;
 import com.intellij.psi.*;
 import com.intellij.psi.util.CachedValue;
 import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.PsiModificationTracker;
 import com.intellij.util.ConcurrencyUtil;
 import com.intellij.util.containers.ConcurrentSoftHashMap;
@@ -48,7 +49,7 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking
       public ConcurrentMap<PsiElement, Object> create() {
         final Key<CachedValue<ConcurrentMap<PsiElement, Object>>> key =
           throwExceptionOnOverflow ? CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY : CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY;
-        return PsiManager.getInstance(myProject).getCachedValuesManager().getCachedValue(myProject, key, PROVIDER, false);
+        return CachedValuesManager.getManager(myProject).getCachedValue(myProject, key, PROVIDER, false);
       }
     };
     myProject = project;
index f524e85552cb7ac59f856f27ae713a882aa807b1..61601dd5b00a18e9a34ad6c925d0a8d0cce7ead9 100644 (file)
@@ -272,7 +272,7 @@ public class PsiClassImplUtil {
     CachedValue<Map> value = aClass.getUserData(MAP_IN_CLASS_KEY);
     if (value == null) {
       final CachedValueProvider<Map> provider = new ByNameCachedValueProvider(aClass);
-      value = aClass.getManager().getCachedValuesManager().createCachedValue(provider, false);
+      value = CachedValuesManager.getManager(aClass.getProject()).createCachedValue(provider, false);
       //Do not cache for nonphysical elements
       if (aClass.isPhysical()) {
         value = ((UserDataHolderEx)aClass).putUserDataIfAbsent(MAP_IN_CLASS_KEY, value);
@@ -905,7 +905,7 @@ public class PsiClassImplUtil {
     //see com.intellij.psi.impl.PsiFileFactoryImpl#createFileFromText(CharSequence,PsiFile)
     final PsiFile original1 = file1.getUserData(PsiFileFactory.ORIGINAL_FILE);
     final PsiFile original2 = file2.getUserData(PsiFileFactory.ORIGINAL_FILE);
-    if ((original1 == original2 && original1 != null)
+    if (original1 == original2 && original1 != null
         || original1 == file2 || original2 == file1) {
       return true;
     }    
@@ -913,12 +913,8 @@ public class PsiClassImplUtil {
     final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(aClass.getProject()).getFileIndex();
     final VirtualFile vfile1 = file1.getViewProvider().getVirtualFile();
     final VirtualFile vfile2 = file2.getViewProvider().getVirtualFile();
-    if ((fileIndex.isInSource(vfile1) || fileIndex.isInLibraryClasses(vfile1)) &&
-        (fileIndex.isInSource(vfile2) || fileIndex.isInLibraryClasses(vfile2))) {
-      return true;
-    }
-
-    return false;
+    return (fileIndex.isInSource(vfile1) || fileIndex.isInLibraryClasses(vfile1)) &&
+           (fileIndex.isInSource(vfile2) || fileIndex.isInLibraryClasses(vfile2));
   }
 
   private static PsiElement originalElement(PsiClass aClass) {
index 288cff3236bef70850daa348a70dd0e36c38308f..d466d532ad7a4fa1bb01f10d60b829a31f53e5bd 100644 (file)
@@ -57,7 +57,7 @@ public class PsiImplUtil {
   }
 
   @NotNull
-  public static PsiMethod[] getConstructors(PsiClass aClass) {
+  public static PsiMethod[] getConstructors(@NotNull PsiClass aClass) {
     final List<PsiMethod> constructorsList = new SmartList<PsiMethod>();
     final PsiMethod[] methods = aClass.getMethods();
     for (final PsiMethod method : methods) {
@@ -67,7 +67,7 @@ public class PsiImplUtil {
   }
 
   @Nullable
-  public static PsiAnnotationMemberValue findDeclaredAttributeValue(PsiAnnotation annotation, @NonNls String attributeName) {
+  public static PsiAnnotationMemberValue findDeclaredAttributeValue(@NotNull PsiAnnotation annotation, @NonNls String attributeName) {
     if ("value".equals(attributeName)) attributeName = null;
     PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
     for (PsiNameValuePair attribute : attributes) {
@@ -80,7 +80,7 @@ public class PsiImplUtil {
   }
 
   @Nullable
-  public static PsiAnnotationMemberValue findAttributeValue(PsiAnnotation annotation, @NonNls String attributeName) {
+  public static PsiAnnotationMemberValue findAttributeValue(@NotNull PsiAnnotation annotation, @NonNls String attributeName) {
     final PsiAnnotationMemberValue value = findDeclaredAttributeValue(annotation, attributeName);
     if (value != null) return value;
 
@@ -100,7 +100,8 @@ public class PsiImplUtil {
     return null;
   }
 
-  public static PsiTypeParameter[] getTypeParameters(PsiTypeParameterListOwner owner) {
+  @NotNull
+  public static PsiTypeParameter[] getTypeParameters(@NotNull PsiTypeParameterListOwner owner) {
     final PsiTypeParameterList typeParameterList = owner.getTypeParameterList();
     if (typeParameterList != null) {
       return typeParameterList.getTypeParameters();
@@ -109,7 +110,7 @@ public class PsiImplUtil {
   }
 
   @NotNull
-  public static PsiJavaCodeReferenceElement[] namesToPackageReferences(PsiManager manager, String[] names) {
+  public static PsiJavaCodeReferenceElement[] namesToPackageReferences(@NotNull PsiManager manager, @NotNull String[] names) {
     PsiJavaCodeReferenceElement[] refs = new PsiJavaCodeReferenceElement[names.length];
     for (int i = 0; i < names.length; i++) {
       String name = names[i];
@@ -123,16 +124,17 @@ public class PsiImplUtil {
     return refs;
   }
 
-  public static int getParameterIndex(PsiParameter parameter, PsiParameterList parameterList) {
+  public static int getParameterIndex(@NotNull PsiParameter parameter, @NotNull PsiParameterList parameterList) {
     PsiParameter[] parameters = parameterList.getParameters();
     for (int i = 0; i < parameters.length; i++) {
       if (parameter.equals(parameters[i])) return i;
     }
-    LOG.error("Parameter " + parameter + " not found among paramaters: " + Arrays.asList(parameters));
+    LOG.error("Parameter " + parameter + " not found among parameters: " + Arrays.asList(parameters)+
+              ". parameterList' parent: "+parameterList.getParent()+"; parameter.getParent()==paramList: "+(parameter.getParent()==parameterList));
     return -1;
   }
 
-  public static int getTypeParameterIndex(PsiTypeParameter typeParameter, PsiTypeParameterList typeParameterList) {
+  public static int getTypeParameterIndex(@NotNull PsiTypeParameter typeParameter, @NotNull PsiTypeParameterList typeParameterList) {
     PsiTypeParameter[] typeParameters = typeParameterList.getTypeParameters();
     for (int i = 0; i < typeParameters.length; i++) {
       if (typeParameter.equals(typeParameters[i])) return i;
@@ -142,14 +144,14 @@ public class PsiImplUtil {
   }
 
   @NotNull
-  public static Object[] getReferenceVariantsByFilter(PsiJavaCodeReferenceElement reference, ElementFilter filter) {
+  public static Object[] getReferenceVariantsByFilter(@NotNull PsiJavaCodeReferenceElement reference, @NotNull ElementFilter filter) {
     FilterScopeProcessor processor = new FilterScopeProcessor(filter);
     PsiScopesUtil.resolveAndWalk(processor, reference, null, true);
     return processor.getResults().toArray();
   }
 
   public static boolean processDeclarationsInMethod(PsiMethod method,
-                                                    PsiScopeProcessor processor,
+                                                    @NotNull PsiScopeProcessor processor,
                                                     ResolveState state,
                                                     PsiElement lastParent,
                                                     PsiElement place) {
@@ -169,20 +171,20 @@ public class PsiImplUtil {
     return true;
   }
 
-  public static boolean hasTypeParameters(PsiTypeParameterListOwner owner) {
+  public static boolean hasTypeParameters(@NotNull PsiTypeParameterListOwner owner) {
     final PsiTypeParameterList typeParameterList = owner.getTypeParameterList();
     return typeParameterList != null && typeParameterList.getTypeParameters().length != 0;
   }
 
   @NotNull
-  public static PsiType[] typesByReferenceParameterList(final PsiReferenceParameterList parameterList) {
+  public static PsiType[] typesByReferenceParameterList(@NotNull PsiReferenceParameterList parameterList) {
     PsiTypeElement[] typeElements = parameterList.getTypeParameterElements();
 
     return typesByTypeElements(typeElements);
   }
 
   @NotNull
-  public static PsiType[] typesByTypeElements(PsiTypeElement[] typeElements) {
+  public static PsiType[] typesByTypeElements(@NotNull PsiTypeElement[] typeElements) {
     PsiType[] types = new PsiType[typeElements.length];
     for (int i = 0; i < types.length; i++) {
       types[i] = typeElements[i].getType();
@@ -190,7 +192,7 @@ public class PsiImplUtil {
     return types;
   }
 
-  public static PsiType getType(PsiClassObjectAccessExpression classAccessExpression) {
+  public static PsiType getType(@NotNull PsiClassObjectAccessExpression classAccessExpression) {
     GlobalSearchScope resolveScope = classAccessExpression.getResolveScope();
     PsiManager manager = classAccessExpression.getManager();
     final PsiClass classClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.lang.Class", resolveScope);
@@ -221,7 +223,7 @@ public class PsiImplUtil {
     return new PsiImmediateClassType(classClass, substitutor);
   }
 
-  public static PsiAnnotation findAnnotation(PsiAnnotationOwner modifierList, @NotNull String qualifiedName) {
+  public static PsiAnnotation findAnnotation(@NotNull PsiAnnotationOwner modifierList, @NotNull String qualifiedName) {
     final String shortName = StringUtil.getShortName(qualifiedName);
     PsiAnnotation[] annotations = modifierList.getAnnotations();
     for (PsiAnnotation annotation : annotations) {
@@ -235,7 +237,7 @@ public class PsiImplUtil {
   }
 
   @Nullable
-  public static ASTNode findDocComment(final CompositeElement element) {
+  public static ASTNode findDocComment(@NotNull CompositeElement element) {
     TreeElement node = element.getFirstChildNode();
     while (node != null &&
            (ElementType.WHITE_SPACE_BIT_SET.contains(node.getElementType()) ||
@@ -252,7 +254,7 @@ public class PsiImplUtil {
     }
   }
 
-  public static PsiType normalizeWildcardTypeByPosition(final PsiType type, final PsiExpression expression) {
+  public static PsiType normalizeWildcardTypeByPosition(@NotNull PsiType type, @NotNull PsiExpression expression) {
     PsiExpression toplevel = expression;
     while (toplevel.getParent() instanceof PsiArrayAccessExpression &&
            ((PsiArrayAccessExpression)toplevel.getParent()).getArrayExpression() == toplevel) {
@@ -300,7 +302,7 @@ public class PsiImplUtil {
   }
 
   @NotNull
-  public static SearchScope getMemberUseScope(final PsiMember member) {
+  public static SearchScope getMemberUseScope(@NotNull PsiMember member) {
     final PsiManagerEx psiManager = (PsiManagerEx)member.getManager();
     final GlobalSearchScope maximalUseScope = psiManager.getFileManager().getUseScope(member);
     PsiFile file = member.getContainingFile();
@@ -337,28 +339,28 @@ public class PsiImplUtil {
     }
   }
 
-  public static PsiElement setName(PsiElement element, String name) throws IncorrectOperationException {
+  public static PsiElement setName(@NotNull PsiElement element, @NotNull String name) throws IncorrectOperationException {
     PsiManager manager = element.getManager();
     PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
     PsiIdentifier newNameIdentifier = factory.createIdentifier(name);
     return element.replace(newNameIdentifier);
   }
 
-  public static boolean isDeprecatedByAnnotation(PsiModifierListOwner owner) {
+  public static boolean isDeprecatedByAnnotation(@NotNull PsiModifierListOwner owner) {
     PsiModifierList modifierList = owner.getModifierList();
     return modifierList != null && modifierList.findAnnotation("java.lang.Deprecated") != null;
   }
 
-  public static boolean isDeprecatedByDocTag(PsiDocCommentOwner owner) {
+  public static boolean isDeprecatedByDocTag(@NotNull PsiDocCommentOwner owner) {
     PsiDocComment docComment = owner.getDocComment();
     return docComment != null && docComment.findTagByName("deprecated") != null;
   }
 
   @Nullable
   public static PsiAnnotationMemberValue setDeclaredAttributeValue(@NotNull PsiAnnotation psiAnnotation,
-                                                                    @Nullable String attributeName,
-                                                                           @Nullable PsiAnnotationMemberValue value,
-                                                                           @NotNull PairFunction<Project, String, PsiAnnotation> annotationCreator) {
+                                                                   @Nullable String attributeName,
+                                                                   @Nullable PsiAnnotationMemberValue value,
+                                                                   @NotNull PairFunction<Project, String, PsiAnnotation> annotationCreator) {
     final PsiAnnotationMemberValue existing = psiAnnotation.findDeclaredAttributeValue(attributeName);
     if (value == null) {
       if (existing == null) {
@@ -387,8 +389,9 @@ public class PsiImplUtil {
     return psiAnnotation.findDeclaredAttributeValue(attributeName);
   }
 
-  public static PsiNameValuePair createNameValuePair(PsiAnnotationMemberValue value, String namePrefix,
-                                               PairFunction<Project, String, PsiAnnotation> annotationCreator) {
+  private static PsiNameValuePair createNameValuePair(@NotNull PsiAnnotationMemberValue value,
+                                                     @NotNull String namePrefix,
+                                                     @NotNull PairFunction<Project, String, PsiAnnotation> annotationCreator) {
     return annotationCreator.fun(value.getProject(), "@A(" + namePrefix + value.getText() + ")").getParameterList().getAttributes()[0];
   }
 }
index 2b97f5f305ea7bd9afc26c26245a51d92ebb1574..ac7768ffdb75ca2d135242136dd3188af287d0f6 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.psi.impl;
 
 import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.UserDataHolderEx;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.HierarchicalMethodSignatureImpl;
@@ -154,26 +155,25 @@ public class PsiSuperMethodImplUtil {
       Map<MethodSignature, HierarchicalMethodSignature> superResult = buildMethodHierarchy(superClass, finalSubstitutor, false, visited, isInRawContextSuper);
       visited.remove(superClass);
 
+      List<Pair<MethodSignature, HierarchicalMethodSignature>> flattened = new ArrayList<Pair<MethodSignature, HierarchicalMethodSignature>>();
       for (Map.Entry<MethodSignature, HierarchicalMethodSignature> entry : superResult.entrySet()) {
-        HierarchicalMethodSignature hierarchicalMethodSignature = entry.getValue();
-        if (!PsiUtil.isAccessible(hierarchicalMethodSignature.getMethod(), aClass, aClass)) continue;
-        MethodSignature superSignature = entry.getKey();
-        HierarchicalMethodSignatureImpl existing = map.get(superSignature);
-        if (existing == null) {
-          map.put(superSignature, copy(hierarchicalMethodSignature));
-        }
-        else if (isReturnTypeIsMoreSpecificThan(hierarchicalMethodSignature, existing) && isSuperMethod(aClass, hierarchicalMethodSignature, existing)) {
-          HierarchicalMethodSignatureImpl newSuper = copy(hierarchicalMethodSignature);
-          mergeSupers(newSuper, existing);
-          map.put(superSignature, newSuper);
-        }
-        else if (isSuperMethod(aClass, existing, hierarchicalMethodSignature)) {
-          mergeSupers(existing, hierarchicalMethodSignature);
-        }
-        // just drop an invalid method declaration there - to highlight accordingly
-        else if (!result.containsKey(superSignature)) {
-          result.put(superSignature, hierarchicalMethodSignature);
+        HierarchicalMethodSignature hms = entry.getValue();
+        MethodSignature signature = entry.getKey();
+        PsiClass containingClass = hms.getMethod().getContainingClass();
+        List<HierarchicalMethodSignature> supers = new ArrayList<HierarchicalMethodSignature>(hms.getSuperSignatures());
+        for (HierarchicalMethodSignature aSuper : supers) {
+          PsiClass superContainingClass = aSuper.getMethod().getContainingClass();
+          if (containingClass != null && superContainingClass != null && !containingClass.isInheritor(superContainingClass, true)) {
+            // methods must be inherited from unrelated classes, so flatten hierarchy here
+            // class C implements SAM1, SAM2 { void methodimpl() {} }
+            //hms.getSuperSignatures().remove(aSuper);
+            flattened.add(new Pair<MethodSignature, HierarchicalMethodSignature>(signature, aSuper));
+          }
         }
+        putInMap(aClass, result, map, hms, signature);
+      }
+      for (Pair<MethodSignature, HierarchicalMethodSignature> pair : flattened) {
+        putInMap(aClass, result, map, pair.second, pair.first);
       }
     }
 
@@ -189,6 +189,28 @@ public class PsiSuperMethodImplUtil {
     return result;
   }
 
+  private static void putInMap(PsiClass aClass, Map<MethodSignature, HierarchicalMethodSignature> result,
+                           Map<MethodSignature, HierarchicalMethodSignatureImpl> map, HierarchicalMethodSignature hierarchicalMethodSignature,
+                           MethodSignature signature) {
+    if (!PsiUtil.isAccessible(hierarchicalMethodSignature.getMethod(), aClass, aClass)) return;
+    HierarchicalMethodSignatureImpl existing = map.get(signature);
+    if (existing == null) {
+      map.put(signature, copy(hierarchicalMethodSignature));
+    }
+    else if (isReturnTypeIsMoreSpecificThan(hierarchicalMethodSignature, existing) && isSuperMethod(aClass, hierarchicalMethodSignature, existing)) {
+      HierarchicalMethodSignatureImpl newSuper = copy(hierarchicalMethodSignature);
+      mergeSupers(newSuper, existing);
+      map.put(signature, newSuper);
+    }
+    else if (isSuperMethod(aClass, existing, hierarchicalMethodSignature)) {
+      mergeSupers(existing, hierarchicalMethodSignature);
+    }
+    // just drop an invalid method declaration there - to highlight accordingly
+    else if (!result.containsKey(signature)) {
+      result.put(signature, hierarchicalMethodSignature);
+    }
+  }
+
   private static boolean isReturnTypeIsMoreSpecificThan(@NotNull HierarchicalMethodSignature thisSig, @NotNull HierarchicalMethodSignature thatSig) {
     PsiType thisRet = thisSig.getMethod().getReturnType();
     PsiType thatRet = thatSig.getMethod().getReturnType();
@@ -276,7 +298,7 @@ public class PsiSuperMethodImplUtil {
     CachedValue<Map<MethodSignature, HierarchicalMethodSignature>> value = aClass.getUserData(SIGNATURES_KEY);
     if (value == null) {
       BySignaturesCachedValueProvider provider = new BySignaturesCachedValueProvider(aClass);
-      value = aClass.getManager().getCachedValuesManager().createCachedValue(provider, false);
+      value = CachedValuesManager.getManager(aClass.getProject()).createCachedValue(provider, false);
       //Do not cache for nonphysical elements
       if (aClass.isPhysical()) {
         UserDataHolderEx dataHolder = (UserDataHolderEx)aClass;
index 49ebc4cf45b3a318c4e2495f7cb75524217f5dcf..98d9004078d4c9bec94dfd25d0f5458e7fc249e5 100644 (file)
@@ -104,7 +104,7 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
 
   private Collection<PsiDirectory> getAllDirectories() {
     if (myDirectories == null) {
-      myDirectories = myManager.getCachedValuesManager().createCachedValue(new CachedValueProvider<Collection<PsiDirectory>>() {
+      myDirectories = CachedValuesManager.getManager(myManager.getProject()).createCachedValue(new CachedValueProvider<Collection<PsiDirectory>>() {
         public Result<Collection<PsiDirectory>> compute() {
           return Result.create(new DirectoriesSearch().search(GlobalSearchScope.allScope(myManager.getProject())).findAll(),
                                PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, ProjectRootManager.getInstance(getProject()));
@@ -419,7 +419,7 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
   @Nullable
   public PsiModifierList getAnnotationList() {
     if (myAnnotationList == null) {
-      myAnnotationList = myManager.getCachedValuesManager().createCachedValue(new PackageAnnotationValueProvider());
+      myAnnotationList = CachedValuesManager.getManager(myManager.getProject()).createCachedValue(new PackageAnnotationValueProvider());
     }
     return myAnnotationList.getValue();
   }
index a954648aec5eff41028f874986411e51ebcf5e39..498473e25a0d328f6f40fcab90cb389d9507799d 100644 (file)
@@ -42,10 +42,7 @@ import com.intellij.psi.scope.NameHint;
 import com.intellij.psi.scope.PsiScopeProcessor;
 import com.intellij.psi.stubs.StubElement;
 import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.util.CachedValue;
-import com.intellij.psi.util.CachedValueProvider;
-import com.intellij.psi.util.PsiModificationTracker;
-import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.*;
 import com.intellij.util.NotNullFunction;
 import com.intellij.util.Processor;
 import com.intellij.util.containers.HashSet;
@@ -67,7 +64,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
 
   protected PsiJavaFileBaseImpl(IElementType elementType, IElementType contentElementType, FileViewProvider viewProvider) {
     super(elementType, contentElementType, viewProvider);
-    myResolveCache = myManager.getCachedValuesManager().createCachedValue(new MyCacheBuilder(), false);
+    myResolveCache = CachedValuesManager.getManager(myManager.getProject()).createCachedValue(new MyCacheBuilder(), false);
   }
 
   @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"})
index 9495bfeaf694a12b2f5fed5d1bb2f8137eb96850..c81487e7c909769b3aa47af3db67d51cfadb74fa 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.DebugUtil;
 import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.source.tree.*;
 import com.intellij.psi.scope.PsiScopeProcessor;
@@ -172,7 +173,15 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
     else {
       text = getText().trim();
     }
-    return JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(text, context);
+    try {
+      return JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(text, context);
+    }
+    catch (IncorrectOperationException e) {
+      String s = "Parent: " + DebugUtil.psiToString(getParent(), false);
+      s += "Context: " + DebugUtil.psiToString(context, false);
+      LOG.error(s,e);
+      return null;
+    }
   }
 
   @NotNull
index 7c9004f6f66f0e07a6a1d3e9aff56e1b0c20d9fb..a21c030c697eed3b6dc66b55432a5c6bdb7b3872 100644 (file)
@@ -65,7 +65,7 @@ public class JavaClassReferenceProvider extends GenericReferenceProvider impleme
 
   public JavaClassReferenceProvider(GlobalSearchScope scope, final Project project) {
     myScope = scope;
-    myDefaltPackages = PsiManager.getInstance(project).getCachedValuesManager().createCachedValue(new CachedValueProvider<List<PsiElement>>() {
+    myDefaltPackages = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<List<PsiElement>>() {
       public Result<List<PsiElement>> compute() {
         final List<PsiElement> psiPackages = new ArrayList<PsiElement>();
         final String defPackageName = DEFAULT_PACKAGE.getValue(myOptions);
index 364531dc8c05c5ed618474e3f637247e2cca7c57..f067d7eb25e0ee1c35556375fda5bee119712348 100644 (file)
@@ -27,10 +27,7 @@ import com.intellij.openapi.util.ModificationTracker;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.PsiManagerEx;
 import com.intellij.psi.impl.PsiParameterizedCachedValue;
-import com.intellij.psi.util.CachedValueProvider;
-import com.intellij.psi.util.ParameterizedCachedValue;
-import com.intellij.psi.util.ParameterizedCachedValueProvider;
-import com.intellij.psi.util.PsiModificationTracker;
+import com.intellij.psi.util.*;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -137,7 +134,8 @@ public class JavaConcatenationInjectorManager implements ProjectComponent, Modif
 
       if (registrar.result != null) {
         // store this everywhere
-        ParameterizedCachedValue<Places, PsiElement> cachedValue = context.getManager().getCachedValuesManager().createParameterizedCachedValue(this, false);
+        ParameterizedCachedValue<Places, PsiElement> cachedValue =
+          CachedValuesManager.getManager(context.getProject()).createParameterizedCachedValue(this, false);
         ((PsiParameterizedCachedValue<Places, PsiElement>)cachedValue).setValue(result);
 
         for (PsiElement operand : operands) {
index 8b5ab5b0a9d7a9f0bdc6e54683062ae690ba4758..1ca3b4b5de976b788dd4691192b83b847f0c9504 100644 (file)
@@ -37,14 +37,15 @@ import java.util.*;
 public class JavaMethodsConflictResolver implements PsiConflictResolver{
   private final PsiElement myArgumentsList;
   private final PsiType[] myActualParameterTypes;
+  private static final Function<PsiExpression,PsiType> EXPRESSION_TO_TYPE = new Function<PsiExpression, PsiType>() {
+    public PsiType fun(final PsiExpression expression) {
+      return expression.getType();
+    }
+  };
 
   public JavaMethodsConflictResolver(PsiExpressionList list) {
     myArgumentsList = list;
-    myActualParameterTypes = ContainerUtil.map2Array(list.getExpressions(), PsiType.class, new Function<PsiExpression, PsiType>() {
-      public PsiType fun(final PsiExpression expression) {
-        return expression.getType();
-      }
-    });
+    myActualParameterTypes = ContainerUtil.map2Array(list.getExpressions(), PsiType.class, EXPRESSION_TO_TYPE);
   }
 
   public JavaMethodsConflictResolver(final PsiElement argumentsList, final PsiType[] actualParameterTypes) {
@@ -376,11 +377,17 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
         if (MethodSignatureUtil.isSubsignature(method1.getSignature(info1.getSubstitutor()), method2.getSignature(info2.getSubstitutor()))) {
           isMoreSpecific = Specifics.SECOND;
         }
+        else if (method1.hasModifierProperty(PsiModifier.STATIC) && method2.hasModifierProperty(PsiModifier.STATIC)) {
+          isMoreSpecific = Specifics.SECOND;
+        }
       }
       else if (class1.isInheritor(class2, true) || class2.isInterface()) {
         if (MethodSignatureUtil.isSubsignature(method2.getSignature(info2.getSubstitutor()), method1.getSignature(info1.getSubstitutor()))) {
           isMoreSpecific = Specifics.FIRST;
         }
+        else if (method1.hasModifierProperty(PsiModifier.STATIC) && method2.hasModifierProperty(PsiModifier.STATIC)) {
+          isMoreSpecific = Specifics.FIRST;
+        }
       }
     }
     if (isMoreSpecific == null) {
index c7918f0acc595d411933cfe5361f176ed2e50f2c..10fc740ad51444a8899407e128771601926beb2b 100644 (file)
@@ -284,9 +284,10 @@ public class EncapsulateFieldsProcessor extends BaseRefactoringProcessor {
 
     for (List<MyUsageInfo> usageInfos : usagesInFiles.values()) {
       //this is to avoid elements to become invalid as a result of processUsage
-      RefactoringUtil.sortDepthFirstRightLeftOrder(usages);
+      final MyUsageInfo[] infos = usageInfos.toArray(new MyUsageInfo[usageInfos.size()]);
+      RefactoringUtil.sortDepthFirstRightLeftOrder(infos);
 
-      for (MyUsageInfo info : usageInfos) {
+      for (MyUsageInfo info : infos) {
         processUsage(info);
       }
     }
index 40321570a909805da9d7827950aad32ff7b8f105..a6d90d599927ba9e5476dfcadb8e967a0e7ac3f7 100644 (file)
@@ -145,7 +145,14 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
   }
 
   private void addInaccessibleSuperCallsConflicts(final UsageInfo[] usagesIn, final MultiMap<PsiElement, String> conflicts) {
+
     myMethod.accept(new JavaRecursiveElementWalkingVisitor(){
+      @Override
+      public void visitClass(PsiClass aClass) {}
+
+      @Override
+      public void visitAnonymousClass(PsiAnonymousClass aClass) {}
+
       @Override
       public void visitSuperExpression(PsiSuperExpression expression) {
         super.visitSuperExpression(expression);
index 215220b1d8778ff40368925d64b98c2f6ab87ee0..98f1e6884366190679d7ff2b22c3527db56c12cf 100644 (file)
  */
 package com.intellij.refactoring.inline;
 
-import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiCallExpression;
+import com.intellij.psi.PsiExpression;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiParameter;
+import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.refactoring.util.RefactoringMessageDialog;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.refactoring.ui.RefactoringDialog;
 
 import javax.swing.*;
 import java.awt.*;
@@ -26,29 +29,45 @@ import java.awt.*;
 /**
  * @author yole
  */
-public class InlineParameterDialog extends RefactoringMessageDialog {
+public class InlineParameterDialog extends RefactoringDialog {
   private JCheckBox myCreateLocalCheckbox;
+  private final PsiCallExpression myMethodCall;
+  private final PsiMethod myMethod;
+  private final PsiParameter myParameter;
+  private final PsiExpression myInitializer;
 
-  public InlineParameterDialog(String title, String message, String helpTopic, @NonNls String iconId, boolean showCancelButton, Project project) {
-    super(title, message, helpTopic, iconId, showCancelButton, project);
+  public InlineParameterDialog(PsiCallExpression methodCall, PsiMethod method, PsiParameter psiParameter, PsiExpression initializer) {
+    super(method.getProject(), true);
+    myMethodCall = methodCall;
+    myMethod = method;
+    myParameter = psiParameter;
+    myInitializer = initializer;
+    init();
+    setTitle(InlineParameterHandler.REFACTORING_NAME);
   }
 
+  @Override
   protected JComponent createNorthPanel() {
-    JComponent superPanel = super.createNorthPanel();
+    final JPanel panel = new JPanel(new BorderLayout());
+    panel.add(new JLabel(RefactoringBundle.message("inline.parameter.confirmation", myParameter.getName(), myInitializer.getText()), UIManager.getIcon("OptionPane.questionIcon"), 2), BorderLayout.NORTH);
+    return panel;
+  }
+
+  @Override
+  protected JComponent createCenterPanel() {
     JPanel panel = new JPanel(new BorderLayout());
-    panel.add(superPanel, BorderLayout.CENTER);
     myCreateLocalCheckbox = new JCheckBox(RefactoringBundle.message("inline.parameter.replace.with.local.checkbox"));
     panel.add(myCreateLocalCheckbox, BorderLayout.SOUTH);
     return panel;
   }
 
-  public boolean isCreateLocal() {
-    return myCreateLocalCheckbox.isSelected();
+  @Override
+  protected String getHelpId() {
+    return HelpID.INLINE_VARIABLE;
   }
 
-  public boolean showDialog() {
-      show();
-      return isOK();
+  @Override
+  protected void doAction() {
+    invokeRefactoring(new InlineParameterExpressionProcessor(myMethodCall, myMethod, myParameter, myInitializer, myCreateLocalCheckbox.isSelected()));
   }
-
 }
index 9b59188f265d64f50d5c0bd4ff916df93312809e..ec8f158f715c9ef1e50160a6aff831b87e874492 100644 (file)
  */
 package com.intellij.refactoring.inline;
 
+import com.intellij.codeInsight.ExceptionUtil;
 import com.intellij.codeInspection.sameParameterValue.SameParameterValueInspection;
-import com.intellij.openapi.application.Result;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.UndoConfirmationPolicy;
-import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
@@ -30,217 +25,314 @@ import com.intellij.psi.controlFlow.DefUseUtil;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.refactoring.HelpID;
-import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.refactoring.util.CommonRefactoringUtil;
+import com.intellij.refactoring.BaseRefactoringProcessor;
 import com.intellij.refactoring.util.InlineUtil;
+import com.intellij.refactoring.util.RefactoringUIUtil;
 import com.intellij.refactoring.util.RefactoringUtil;
-import com.intellij.util.IncorrectOperationException;
+import com.intellij.usageView.UsageInfo;
+import com.intellij.usageView.UsageViewDescriptor;
+import com.intellij.usageView.UsageViewUtil;
+import com.intellij.util.containers.MultiMap;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author yole
  */
-public class InlineParameterExpressionProcessor {
+public class InlineParameterExpressionProcessor extends BaseRefactoringProcessor {
   private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.inline.InlineParameterExpressionProcessor");
+  public static final Key<Boolean> CREATE_LOCAL_FOR_TESTS = Key.create("CREATE_INLINE_PARAMETER_LOCAL_FOR_TESTS");
 
   private final PsiCallExpression myMethodCall;
   private final PsiMethod myMethod;
   private final PsiParameter myParameter;
-  private final PsiExpression myInitializer;
-  private final Editor myEditor;
+  private PsiExpression myInitializer;
   private final boolean mySameClass;
   private final PsiMethod myCallingMethod;
-  private Map<PsiVariable, PsiElement> myLocalReplacements;
+  private boolean myCreateLocal;
 
   public InlineParameterExpressionProcessor(final PsiCallExpression methodCall,
                                             final PsiMethod method,
                                             final PsiParameter parameter,
-                                            final PsiExpression initializer, Editor editor) {
+                                            final PsiExpression initializer,
+                                            boolean createLocal) {
+    super(method.getProject());
     myMethodCall = methodCall;
     myMethod = method;
     myParameter = parameter;
     myInitializer = initializer;
-    myEditor = editor;
+    myCreateLocal = createLocal;
 
     PsiClass callingClass = PsiTreeUtil.getParentOfType(methodCall, PsiClass.class);
     mySameClass = (callingClass == myMethod.getContainingClass());
     myCallingMethod = PsiTreeUtil.getParentOfType(myMethodCall, PsiMethod.class);
   }
 
-  void run() throws IncorrectOperationException {
+  @Override
+  protected String getCommandName() {
+    return InlineParameterHandler.REFACTORING_NAME;
+  }
+
+  @Override
+  protected void refreshElements(PsiElement[] elements) {
+  }
+
+  @Override
+  protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) {
+    return new InlineViewDescriptor(myParameter);
+  }
+
+  @NotNull
+  @Override
+  protected UsageInfo[] findUsages() {
+
     int parameterIndex = myMethod.getParameterList().getParameterIndex(myParameter);
-    myLocalReplacements = new HashMap<PsiVariable, PsiElement>();
+    final Map<PsiVariable, PsiElement> localToParamRef = new HashMap<PsiVariable, PsiElement>();
     final PsiExpression[] arguments = myMethodCall.getArgumentList().getExpressions();
-    for(int i=0; i<arguments.length; i++) {
-      if (i != parameterIndex && arguments [i] instanceof PsiReferenceExpression) {
+    for (int i = 0; i < arguments.length; i++) {
+      if (i != parameterIndex && arguments[i] instanceof PsiReferenceExpression) {
         final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)arguments[i];
         final PsiElement element = referenceExpression.resolve();
         if (element instanceof PsiLocalVariable || element instanceof PsiParameter) {
           final PsiParameter param = myMethod.getParameterList().getParameters()[i];
           final PsiExpression paramRef =
             JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory().createExpressionFromText(param.getName(), myMethod);
-          myLocalReplacements.put((PsiVariable) element, paramRef);
+          localToParamRef.put((PsiVariable)element, paramRef);
         }
       }
     }
 
-    processParameterInitializer();
-
-    PsiExpression initializerInMethod = (PsiExpression) myInitializer.copy();
-    final Map<PsiElement, PsiElement> elementsToReplace = new HashMap<PsiElement, PsiElement>();
-    final boolean canEvaluate = replaceLocals(initializerInMethod, elementsToReplace);
-    if (!canEvaluate) {
-      CommonRefactoringUtil.showErrorHint(myMethod.getProject(), myEditor,
-                                          "Parameter initializer depends on values which are not available inside the method and cannot be inlined",
-                                          RefactoringBundle.message("inline.parameter.refactoring"), null);
-      return;
-    }
-
-    final Collection<PsiReference> parameterRefs = ReferencesSearch.search(myParameter).findAll();
-
-    initializerInMethod = (PsiExpression) RefactoringUtil.replaceElementsWithMap(initializerInMethod, elementsToReplace);
-
-    String question = RefactoringBundle.message("inline.parameter.confirmation", myParameter.getName(),
-                                                initializerInMethod.getText());
-    boolean createLocal;
-    if (ApplicationManager.getApplication().isUnitTestMode()) {
-      createLocal = myMethod.getProject().getUserData(CREATE_LOCAL_FOR_TESTS);
-    }
-    else {
-      InlineParameterDialog dlg =
-        new InlineParameterDialog(InlineParameterHandler.REFACTORING_NAME, question, HelpID.INLINE_VARIABLE, "OptionPane.questionIcon",
-                                  true, myMethod.getProject());
-      if (!dlg.showDialog()) {
-        return;
-      }
-      createLocal = dlg.isCreateLocal();
-    }
-    performRefactoring(initializerInMethod, parameterRefs, createLocal);
-  }
-  public static final Key<Boolean> CREATE_LOCAL_FOR_TESTS = Key.create("CREATE_INLINE_PARAMETER_LOCAL_FOR_TESTS");
-
-  private void processParameterInitializer() {
+    final List<UsageInfo> result = new ArrayList<UsageInfo>();
     myInitializer.accept(new JavaRecursiveElementVisitor() {
-      @Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
+      @Override
+      public void visitReferenceExpression(final PsiReferenceExpression expression) {
         super.visitReferenceExpression(expression);
         final PsiElement element = expression.resolve();
         if (element instanceof PsiLocalVariable) {
           final PsiLocalVariable localVariable = (PsiLocalVariable)element;
-          if (myLocalReplacements.containsKey(localVariable)) return;
           final PsiElement[] elements = DefUseUtil.getDefs(myCallingMethod.getBody(), localVariable, expression);
           if (elements.length == 1) {
             PsiExpression localInitializer = null;
-            if (elements [0] instanceof PsiLocalVariable) {
-              localInitializer = ((PsiLocalVariable) elements [0]).getInitializer();
+            if (elements[0] instanceof PsiLocalVariable) {
+              localInitializer = ((PsiLocalVariable)elements[0]).getInitializer();
             }
-            else if (elements [0] instanceof PsiAssignmentExpression) {
-              localInitializer = ((PsiAssignmentExpression) elements [0]).getRExpression();
+            else if (elements[0] instanceof PsiAssignmentExpression) {
+              localInitializer = ((PsiAssignmentExpression)elements[0]).getRExpression();
             }
             if (localInitializer != null) {
-              if (InlineToAnonymousConstructorProcessor.isConstant(localInitializer)) {
-                myLocalReplacements.put(localVariable, localInitializer);
+              final PsiElement replacement;
+              if (localToParamRef.containsKey(localVariable)) {
+                replacement = localToParamRef.get(localVariable);
               }
               else {
-                final Map<PsiElement, PsiElement> elementsToReplace = new HashMap<PsiElement, PsiElement>();
-                PsiExpression replacedInitializer = (PsiExpression)localInitializer.copy();
-                if (replaceLocals(replacedInitializer, elementsToReplace)) {
-                  try {
-                    replacedInitializer = (PsiExpression) RefactoringUtil.replaceElementsWithMap(replacedInitializer, elementsToReplace);
-                  }
-                  catch (IncorrectOperationException e) {
-                    LOG.error(e);
-                  }
-                  myLocalReplacements.put(localVariable, replacedInitializer);
-                }
+                replacement = replaceArgs(localToParamRef, localInitializer.copy());
               }
+              result.add(new LocalReplacementUsageInfo(expression, replacement));
             }
           }
         }
       }
     });
+
+    if (!myCreateLocal) {
+      for (PsiReference ref : ReferencesSearch.search(myParameter).findAll()) {
+        result.add(new UsageInfo(ref));
+      }
+    }
+
+    final UsageInfo[] usageInfos = result.toArray(new UsageInfo[result.size()]);
+    return UsageViewUtil.removeDuplicatedUsages(usageInfos);
   }
 
-  private void performRefactoring(final PsiExpression initializerInMethod, final Collection<PsiReference> parameterRefs,
-                                  final boolean createLocal) {
-    final Collection<PsiFile> containingFiles = new HashSet<PsiFile>();
-    containingFiles.add(myMethod.getContainingFile());
-    containingFiles.add(myMethodCall.getContainingFile());
-
-    final Project project = myMethod.getProject();
-    new WriteCommandAction(project,
-                           RefactoringBundle.message("inline.parameter.command.name", myParameter.getName()),
-                           containingFiles.toArray(new PsiFile[containingFiles.size()])) {
-      protected void run(final Result result) throws Throwable {
-        final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory();
-        if (!createLocal) {
-          for(PsiReference ref: parameterRefs) {
-            InlineUtil.inlineVariable(myParameter, initializerInMethod, (PsiJavaCodeReferenceElement) ref.getElement());
+  private static PsiElement replaceArgs(final Map<PsiVariable, PsiElement> elementsToReplace, PsiElement expression) {
+    final Map<PsiElement, PsiElement> replacements = new HashMap<PsiElement, PsiElement>();
+    expression.accept(new JavaRecursiveElementVisitor() {
+      @Override
+      public void visitReferenceExpression(PsiReferenceExpression referenceExpression) {
+        super.visitReferenceExpression(referenceExpression);
+        final PsiElement resolved = referenceExpression.resolve();
+        if (resolved instanceof PsiVariable) {
+          final PsiVariable variable = (PsiVariable)resolved;
+          final PsiElement replacement = elementsToReplace.get(variable);
+          if (replacement != null) {
+            replacements.put(referenceExpression, replacement);
           }
         }
-        PsiDeclarationStatement localDeclaration = factory.createVariableDeclarationStatement(myParameter.getName(),
-                                                                                              myParameter.getType(),
-                                                                                              initializerInMethod);
-        boolean parameterIsFinal = myParameter.hasModifierProperty(PsiModifier.FINAL);
-        SameParameterValueInspection.InlineParameterValueFix.removeParameter(myMethod, myParameter);
-        if (createLocal) {
-          final PsiLocalVariable declaredVar = (PsiLocalVariable) localDeclaration.getDeclaredElements()[0];
-          PsiUtil.setModifierProperty(declaredVar, PsiModifier.FINAL, parameterIsFinal);
-          final PsiCodeBlock body = myMethod.getBody();
-          if (body != null) {
-            body.addAfter(localDeclaration, body.getLBrace());
+      }
+    });
+    return RefactoringUtil.replaceElementsWithMap(expression, replacements);
+  }
+
+  @Override
+  protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
+    final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
+    myInitializer.accept(new JavaRecursiveElementWalkingVisitor() {
+      @Override
+      public void visitReferenceExpression(final PsiReferenceExpression expression) {
+        super.visitReferenceExpression(expression);
+        final PsiElement element = expression.resolve();
+        if (element instanceof PsiMethod || element instanceof PsiField) {
+          if (!mySameClass && !((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) {
+            conflicts.putValue(expression, "Parameter initializer depend on non static member from some other class");
           }
         }
+      }
+
+      @Override
+      public void visitThisExpression(PsiThisExpression thisExpression) {
+        super.visitThisExpression(thisExpression);
+        final PsiJavaCodeReferenceElement qualifier = thisExpression.getQualifier();
+        PsiElement containingClass;
+        if (qualifier != null) {
+          containingClass = qualifier.resolve();
+        }
+        else {
+          containingClass = PsiTreeUtil.getParentOfType(myMethodCall, PsiClass.class);
+        }
+        final PsiClass methodContainingClass = myMethod.getContainingClass();
+        LOG.assertTrue(methodContainingClass != null);
+        if (!PsiTreeUtil.isAncestor(containingClass, methodContainingClass, false)) {
+          conflicts.putValue(thisExpression,
+                             "Parameter initializer depends on this which is not available inside the method and cannot be inlined");
+        }
+      }
 
-        for(PsiVariable var: myLocalReplacements.keySet()) {
-          if (ReferencesSearch.search(var).findFirst() == null) {
-            var.delete();
+      @Override
+      public void visitNewExpression(PsiNewExpression expression) {
+        super.visitNewExpression(expression);
+        final PsiJavaCodeReferenceElement reference = expression.getClassOrAnonymousClassReference();
+        if (reference != null) {
+          final PsiElement resolved = reference.resolve();
+          if (resolved instanceof PsiClass) {
+            final PsiClass refClass = (PsiClass)resolved;
+            final String classUnavailableMessage = "Parameter initializer depends on " +
+                                                   RefactoringUIUtil.getDescription(refClass, true) +
+                                                   " which is not available inside method and cannot be inlined";
+            if (!PsiUtil.isAccessible(refClass, myMethod, null)) {
+              conflicts.putValue(expression, classUnavailableMessage);
+            }
+            else {
+              final PsiClass methodContainingClass = myMethod.getContainingClass();
+              LOG.assertTrue(methodContainingClass != null);
+              if (!(refClass.getParent() instanceof PsiFile) && !PsiTreeUtil.isAncestor(methodContainingClass, refClass, false)) {
+                conflicts.putValue(expression, classUnavailableMessage);
+              }
+            }
           }
         }
       }
+    });
 
-      protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
-        return UndoConfirmationPolicy.DEFAULT;
+    final UsageInfo[] usages = refUsages.get();
+    final Set<PsiVariable> vars = new HashSet<PsiVariable>();
+    for (UsageInfo usageInfo : usages) {
+      if (usageInfo instanceof LocalReplacementUsageInfo) {
+        final PsiVariable var = ((LocalReplacementUsageInfo)usageInfo).getVariable();
+        if (var != null) {
+          vars.add(var);
+        }
       }
-    }.execute();
+    }
+    for (PsiVariable var : vars) {
+      for (PsiReference ref : ReferencesSearch.search(var)) {
+        final PsiElement element = ref.getElement();
+        if (element instanceof PsiExpression && isAccessedForWriting((PsiExpression)element)) {
+          conflicts.putValue(element, "Parameter initializer depends on value which is not available inside method and cannot be inlined");
+          break;
+        }
+      }
+    }
+    return showConflicts(conflicts);
   }
 
-  private boolean replaceLocals(final PsiExpression expression,
-                                final Map<PsiElement, PsiElement> elementsToReplace) {
-    final Ref<Boolean> refCannotEvaluate = new Ref<Boolean>();
-    expression.accept(new JavaRecursiveElementWalkingVisitor() {
-      @Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
-        super.visitReferenceExpression(expression);
-        final PsiElement element = expression.resolve();
-        if (!canEvaluate(expression, element, elementsToReplace)) {
-          refCannotEvaluate.set(Boolean.TRUE);
+  private static boolean isAccessedForWriting (PsiExpression expr) {
+    while (expr.getParent() instanceof PsiArrayAccessExpression) {
+      expr = (PsiExpression)expr.getParent();
+    }
+    return PsiUtil.isAccessedForWriting(expr);
+  }
+
+  @Override
+  protected void performRefactoring(UsageInfo[] usages) {
+    final List<PsiClassType> thrownExceptions = ExceptionUtil.getThrownCheckedExceptions(new PsiElement[]{myInitializer});
+    final Set<PsiVariable> varsUsedInInitializer = new HashSet<PsiVariable>();
+    final Set<PsiJavaCodeReferenceElement> paramRefsToInline = new HashSet<PsiJavaCodeReferenceElement>();
+    final Map<PsiElement, PsiElement> replacements = new HashMap<PsiElement, PsiElement>();
+    for (UsageInfo usage : usages) {
+      if (usage instanceof LocalReplacementUsageInfo) {
+        final LocalReplacementUsageInfo replacementUsageInfo = (LocalReplacementUsageInfo)usage;
+        final PsiElement element = replacementUsageInfo.getElement();
+        final PsiElement replacement = replacementUsageInfo.getReplacement();
+        if (element != null && replacement != null) {
+          replacements.put(element, replacement);
         }
+        varsUsedInInitializer.add(replacementUsageInfo.getVariable());
       }
-    });
-    return refCannotEvaluate.isNull();
-  }
+      else {
+        LOG.assertTrue(!myCreateLocal);
+        paramRefsToInline.add((PsiJavaCodeReferenceElement)usage.getElement());
+      }
+    }
+    myInitializer = (PsiExpression)RefactoringUtil.replaceElementsWithMap(myInitializer, replacements);
 
-  private boolean canEvaluate(final PsiReferenceExpression expression,
-                              final PsiElement element,
-                              final Map<PsiElement, PsiElement> elementsToReplace) {
-    if (element instanceof PsiLocalVariable || element instanceof PsiParameter) {
-      final PsiVariable localVariable = (PsiVariable)element;
-      final PsiElement localReplacement = myLocalReplacements.get(localVariable);
-      if (localReplacement != null) {
-        elementsToReplace.put(expression, localReplacement);
-        return true;
+    if (myCreateLocal) {
+      final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory();
+      PsiDeclarationStatement localDeclaration =
+        factory.createVariableDeclarationStatement(myParameter.getName(), myParameter.getType(), myInitializer);
+      final PsiLocalVariable declaredVar = (PsiLocalVariable)localDeclaration.getDeclaredElements()[0];
+      PsiUtil.setModifierProperty(declaredVar, PsiModifier.FINAL, myParameter.hasModifierProperty(PsiModifier.FINAL));
+      final PsiCodeBlock body = myMethod.getBody();
+      if (body != null) {
+        body.addAfter(localDeclaration, body.getLBrace());
+      }
+    } else {
+      for (PsiJavaCodeReferenceElement paramRef : paramRefsToInline) {
+        InlineUtil.inlineVariable(myParameter, myInitializer, paramRef);
       }
     }
-    else if (element instanceof PsiMethod || element instanceof PsiField) {
-      return mySameClass || ((PsiModifierListOwner) element).hasModifierProperty(PsiModifier.STATIC);
+
+    //delete var if it becomes unused
+    for (PsiVariable variable : varsUsedInInitializer) {
+      if (variable != null && variable.isValid()) {
+        if (ReferencesSearch.search(variable).findFirst() == null) {
+          variable.delete();
+        }
+      }
     }
-    else if (element instanceof PsiClass) {
-      return true;
+
+    SameParameterValueInspection.InlineParameterValueFix.removeParameter(myMethod, myParameter);
+
+    if (!thrownExceptions.isEmpty()) {
+      for (PsiClassType exception : thrownExceptions) {
+        PsiClass exceptionClass = exception.resolve();
+        if (exceptionClass != null) {
+          PsiUtil.addException(myMethod, exceptionClass);
+        }
+      }
+    }
+  }
+
+  private static class LocalReplacementUsageInfo extends UsageInfo {
+    private final PsiElement myReplacement;
+    private final PsiVariable myVariable;
+
+    public LocalReplacementUsageInfo(@NotNull PsiReference element, @NotNull PsiElement replacement) {
+      super(element);
+      final PsiElement resolved = element.resolve();
+      myVariable = resolved instanceof PsiVariable ? (PsiVariable)resolved : null;
+      myReplacement = replacement;
+    }
+
+    @Nullable
+    public PsiElement getReplacement() {
+      return myReplacement.isValid() ? myReplacement : null;
+    }
+
+    @Nullable
+    public PsiVariable getVariable() {
+      return myVariable != null && myVariable.isValid() ? myVariable : null;
     }
-    return false;
   }
 }
\ No newline at end of file
index 603f71bc13e56e52425664bef9cd6bdfca539585..07afe23604e21d64eec43c87019f749bc57d1c86 100644 (file)
  */
 package com.intellij.refactoring.inline;
 
+import com.intellij.codeInsight.PsiEquivalenceUtil;
 import com.intellij.codeInspection.sameParameterValue.SameParameterValueInspection;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.Result;
-import com.intellij.openapi.application.ex.ApplicationEx;
 import com.intellij.openapi.command.UndoConfirmationPolicy;
 import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.diagnostic.Logger;
@@ -28,11 +28,11 @@ import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
 import com.intellij.psi.search.searches.OverridingMethodsSearch;
 import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.psi.util.PsiUtil;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.RefactoringMessageDialog;
-import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.Processor;
 import org.jetbrains.annotations.Nullable;
 
@@ -49,10 +49,6 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
   public static final String REFACTORING_NAME = RefactoringBundle.message("inline.parameter.refactoring");
 
   public boolean canInlineElement(PsiElement element) {
-    return false;
-  }
-
-  public boolean canInlineElementInEditor(PsiElement element) {
     return element instanceof PsiParameter && element.getParent() instanceof PsiParameterList;
   }
 
@@ -80,13 +76,16 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
     boolean result = ReferencesSearch.search(method).forEach(new Processor<PsiReference>() {
       public boolean process(final PsiReference psiReference) {
         PsiElement element = psiReference.getElement();
-        if (element.getParent() instanceof PsiCallExpression) {
+        final PsiElement parent = element.getParent();
+        if (parent instanceof PsiCallExpression) {
+          final PsiCallExpression methodCall = (PsiCallExpression)parent;
           occurrences.add(psiReference);
           containingFiles.add(element.getContainingFile());
-          PsiCallExpression methodCall = (PsiCallExpression) element.getParent();
           PsiExpression argument = methodCall.getArgumentList().getExpressions()[index];
           if (!refInitializer.isNull()) {
-            return false;
+            return argument != null
+                   && PsiEquivalenceUtil.areElementsEquivalent(refInitializer.get(), argument)
+                   && PsiEquivalenceUtil.areElementsEquivalent(refMethodCall.get(), methodCall);
           }
           if (InlineToAnonymousConstructorProcessor.isConstant(argument) || getReferencedFinalField(argument) != null) {
             if (refConstantInitializer.isNull()) {
@@ -97,6 +96,7 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
             }
           }
           else {
+            if (!refConstantInitializer.isNull()) return false;
             refInitializer.set(argument);
             refMethodCall.set(methodCall);
           }
@@ -112,13 +112,17 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
       CommonRefactoringUtil.showErrorHint(project, editor, "Cannot find constant initializer for parameter", RefactoringBundle.message("inline.parameter.refactoring"), null);
       return;
     }
-    final ApplicationEx app = (ApplicationEx)ApplicationManager.getApplication();
-    if ((app.isInternal() || app.isUnitTestMode()) && !refInitializer.isNull()) {
-      try {
-        new InlineParameterExpressionProcessor(refMethodCall.get(), method, psiParameter, refInitializer.get(), editor).run();
+    if (!refInitializer.isNull()) {
+      if (ApplicationManager.getApplication().isUnitTestMode()) {
+        final InlineParameterExpressionProcessor processor =
+          new InlineParameterExpressionProcessor(refMethodCall.get(), method, psiParameter, refInitializer.get(),
+                                                 method.getProject().getUserData(
+                                                   InlineParameterExpressionProcessor.CREATE_LOCAL_FOR_TESTS));
+        processor.run();
       }
-      catch (IncorrectOperationException e) {
-        LOG.error(e);
+      else {
+        InlineParameterDialog dlg = new InlineParameterDialog(refMethodCall.get(), method, psiParameter, refInitializer.get());
+        dlg.show();
       }
       return;
     }
@@ -127,10 +131,27 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
       return;
     }
 
+    final Ref<Boolean> isNotConstantAccessible = new Ref<Boolean>();
+    final PsiExpression constantExpression = refConstantInitializer.get();
+    constantExpression.accept(new JavaRecursiveElementVisitor(){
+      @Override
+      public void visitReferenceExpression(PsiReferenceExpression expression) {
+        super.visitReferenceExpression(expression);
+        final PsiElement resolved = expression.resolve();
+        if (resolved instanceof PsiMember && !PsiUtil.isAccessible((PsiMember)resolved, method, null)) {
+          isNotConstantAccessible.set(Boolean.TRUE);
+        }
+      }
+    });
+    if (!isNotConstantAccessible.isNull() && isNotConstantAccessible.get()) {
+      CommonRefactoringUtil.showErrorHint(project, editor, "Constant initializer is not accessible in method body", RefactoringBundle.message("inline.parameter.refactoring"), null);
+      return;
+    }
+
     if (!ApplicationManager.getApplication().isUnitTestMode()) {
       String occurencesString = RefactoringBundle.message("occurences.string", occurrences.size());
       String question = RefactoringBundle.message("inline.parameter.confirmation", psiParameter.getName(),
-                                                  refConstantInitializer.get().getText()) + " " + occurencesString;
+                                                  constantExpression.getText()) + " " + occurencesString;
       RefactoringMessageDialog dialog = new RefactoringMessageDialog(
         REFACTORING_NAME,
         question,
@@ -148,7 +169,7 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
                            RefactoringBundle.message("inline.parameter.command.name", psiParameter.getName()),
                            containingFiles.toArray(new PsiFile[containingFiles.size()]) ) {
       protected void run(final Result result) throws Throwable {
-        SameParameterValueInspection.InlineParameterValueFix.inlineSameParameterValue(method, psiParameter, refConstantInitializer.get());
+        SameParameterValueInspection.InlineParameterValueFix.inlineSameParameterValue(method, psiParameter, constantExpression);
       }
 
       protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
@@ -178,10 +199,10 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
     if (expr1Null || expr2Null) {
       return expr1Null && expr2Null;
     }
-    PsiField field1 = getReferencedFinalField(expr1);
-    PsiField field2 = getReferencedFinalField(expr2);
-    if (field1 != null || field2 != null) {
-      return field1 == field2;
+    final PsiField field1 = getReferencedFinalField(expr1);
+    final PsiField field2 = getReferencedFinalField(expr2);
+    if (field1 != null && field1 == field2) {
+      return true;
     }
     Object value1 = JavaPsiFacade.getInstance(expr1.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr1);
     Object value2 = JavaPsiFacade.getInstance(expr2.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr2);
index dc8ad3b3adc1080ebaccbd19ab7091f9b3ae38e1..9d1a6536bfb812ddcda76508d8e18e686e4f7d87 100644 (file)
@@ -284,7 +284,8 @@ public class InlineToAnonymousClassHandler extends JavaInlineActionHandler {
       }
       final PsiElement parentElement = element.getParent();
       if (parentElement != null) {
-        if (parentElement.getParent() instanceof PsiClassObjectAccessExpression) {
+        final PsiElement grandPa = parentElement.getParent();
+        if (grandPa instanceof PsiClassObjectAccessExpression) {
           return "Class cannot be inlined because it has usages of its class literal";
         }
         if (ourCatchClausePattern.accepts(parentElement)) {
index 92f13b35846db93c991f92d627309831a5cb53f7..07b674caefaa0b8e934ddac693faad15ae760b29 100644 (file)
@@ -134,7 +134,7 @@ public class InlineToAnonymousClassProcessor extends BaseRefactoringProcessor {
   }
 
   public MultiMap<PsiElement, String> getConflicts(final UsageInfo[] usages) {
-    MultiMap<PsiElement, String> result = new MultiMap<PsiElement, String>();
+    final MultiMap<PsiElement, String> result = new MultiMap<PsiElement, String>();
     ReferencedElementsCollector collector = new ReferencedElementsCollector() {
       protected void checkAddMember(@NotNull final PsiMember member) {
         if (PsiTreeUtil.isAncestor(myClass, member, false)) {
@@ -150,6 +150,53 @@ public class InlineToAnonymousClassProcessor extends BaseRefactoringProcessor {
       }
     };
     InlineMethodProcessor.addInaccessibleMemberConflicts(myClass, usages, collector, result);
+    myClass.accept(new JavaRecursiveElementVisitor(){
+      @Override
+      public void visitParameter(PsiParameter parameter) {
+        super.visitParameter(parameter);
+        if (PsiUtil.resolveClassInType(parameter.getType()) != myClass) return;
+
+        for (PsiReference psiReference : ReferencesSearch.search(parameter)) {
+          final PsiElement refElement = psiReference.getElement();
+          if (refElement instanceof PsiExpression) {
+            final PsiReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(refElement, PsiReferenceExpression.class);
+            if (referenceExpression != null && referenceExpression.getQualifierExpression() == refElement) {
+              final PsiElement resolvedMember = referenceExpression.resolve();
+              if (resolvedMember != null && PsiTreeUtil.isAncestor(myClass, resolvedMember, false)) {
+                if (resolvedMember instanceof PsiMethod) {
+                  if (myClass.findMethodsBySignature((PsiMethod)resolvedMember, true).length > 1) { //skip inherited methods
+                    continue;
+                  }
+                }
+                result.putValue(refElement, "Class cannot be inlined because a call to its member inside body");
+              }
+            }
+          }
+        }
+      }
+
+      @Override
+      public void visitNewExpression(PsiNewExpression expression) {
+        super.visitNewExpression(expression);
+        if (PsiUtil.resolveClassInType(expression.getType()) != myClass) return;
+        result.putValue(expression, "Class cannot be inlined because a call to its constructor inside body");
+      }
+
+      @Override
+      public void visitMethodCallExpression(PsiMethodCallExpression expression) {
+        super.visitMethodCallExpression(expression);
+        final PsiReferenceExpression methodExpression = expression.getMethodExpression();
+        final PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
+        if (qualifierExpression != null && PsiUtil.resolveClassInType(qualifierExpression.getType()) != myClass) return;
+        final PsiElement resolved = methodExpression.resolve();
+        if (resolved instanceof PsiMethod) {
+          final PsiMethod method = (PsiMethod)resolved;
+          if ("getClass".equals(method.getName()) && method.getParameterList().getParametersCount() == 0) {
+            result.putValue(methodExpression, "Result of getClass() invocation would be changed");
+          }
+        }
+      }
+    });
     return result;
   }
 
index d826d9998d59d19ed3e87ab56a8784af6bae99e7..7ce79aef8a64118685e378d13cc578cc5b12d5a5 100644 (file)
@@ -183,7 +183,7 @@ class InlineToAnonymousConstructorProcessor {
         ProcessingContext context = new ProcessingContext();
         if (ourAssignmentPattern.accepts(stmt, context)) {
           PsiAssignmentExpression expression = context.get(ourAssignmentKey);
-          if (!processAssignmentInConstructor(expression)) {
+          if (processAssignmentInConstructor(expression)) {
             initializerBlock.addBefore(replaceParameterReferences(stmt, null, false), initializerBlock.getRBrace());
           }
         }
@@ -205,7 +205,7 @@ class InlineToAnonymousConstructorProcessor {
     if (expression.getLExpression() instanceof PsiReferenceExpression) {
       PsiReferenceExpression lExpr = (PsiReferenceExpression) expression.getLExpression();
       final PsiExpression rExpr = expression.getRExpression();
-      if (rExpr == null) return true;
+      if (rExpr == null) return false;
       final PsiElement psiElement = lExpr.resolve();
       if (psiElement instanceof PsiField) {
         PsiField field = (PsiField) psiElement;
@@ -217,25 +217,20 @@ class InlineToAnonymousConstructorProcessor {
           }
           catch (IncorrectOperationException e) {
             LOG.error(e);
-            return true;
+            return false;
           }
           if (!localVarRefs.isEmpty()) {
-            return false;
+            return true;
           }
 
           myFieldInitializers.put(field.getName(), initializer);
         }
       }
       else if (psiElement instanceof PsiVariable) {
-        try {
-          replaceParameterReferences(rExpr.copy(), new ArrayList<PsiReferenceExpression>(), false);
-        }
-        catch (IncorrectOperationException e) {
-          LOG.error(e);
-        }
+        return true;
       }
     }
-    return true;
+    return false;
   }
 
   public static boolean isConstant(final PsiExpression expr) {
index 6a904dcafbc2fd3a7fa8f219bc374f47e270036c..40c09091b5a50bb3b9d6d268aa9ce4371651df00 100644 (file)
@@ -16,9 +16,7 @@
  */
 package com.intellij.refactoring.inline;
 
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMethod;
+import com.intellij.psi.*;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.usageView.UsageViewBundle;
 import com.intellij.usageView.UsageViewDescriptor;
@@ -38,12 +36,19 @@ class InlineViewDescriptor implements UsageViewDescriptor{
   }
 
   public String getProcessedElementsHeader() {
+    if (myElement instanceof PsiField) {
+      return RefactoringBundle.message("inline.field.elements.header");
+    }
+    if (myElement instanceof PsiVariable) {
+      return RefactoringBundle.message("inline.vars.elements.header");
+    }
     if (myElement instanceof PsiClass) {
       return RefactoringBundle.message("inline.class.elements.header");
     }
-    return myElement instanceof PsiMethod ?
-           RefactoringBundle.message("inline.method.elements.header") :
-           RefactoringBundle.message("inline.field.elements.header");
+    if (myElement instanceof PsiMethod) {
+      return RefactoringBundle.message("inline.method.elements.header");
+    }
+    return "Unknown element";
   }
 
   public String getCodeReferencesText(int usagesCount, int filesCount) {
index 08802c0d681baacd6987be17f36463703d255925..9f674cae0bf2247b458cc2d11d44eec90cffcb82 100644 (file)
@@ -109,6 +109,18 @@ public class MakeClassStaticProcessor extends MakeMethodOrClassStaticProcessor<P
           anchor = javaDocHelper.addParameterAfter(fieldParameter.name, anchor);
           addAssignmentToField(fieldParameter.name, constructor);
         }
+        for (UsageInfo usage : usages) {
+          if (usage instanceof InternalUsageInfo) {
+            final PsiElement element = usage.getElement();
+            final PsiElement referencedElement = ((InternalUsageInfo)usage).getReferencedElement();
+            if (referencedElement instanceof PsiField && mySettings.getNameForField((PsiField)referencedElement) != null) {
+              final PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class);
+              if (field != null) {
+                moveInitializerToConstructor(factory, constructor, field);
+              }
+            }
+          }
+        }
       }
     }
 
@@ -121,6 +133,34 @@ public class MakeClassStaticProcessor extends MakeMethodOrClassStaticProcessor<P
     modifierList.setModifierProperty(PsiModifier.FINAL, false);
   }
 
+  private static void moveInitializerToConstructor(PsiElementFactory factory, PsiMethod constructor, PsiField field) {
+    final PsiExpression initializer = field.getInitializer();
+    PsiExpression initializerCopy = (PsiExpression)initializer.copy();
+    final PsiCodeBlock body = constructor.getBody();
+    if (body != null) {
+      try {
+        String fieldName = field.getName();
+        final PsiReferenceExpression refExpr = (PsiReferenceExpression)factory.createExpressionFromText(fieldName, body);
+        if (refExpr.resolve() != null) fieldName = "this." + fieldName;
+        PsiExpressionStatement statement = (PsiExpressionStatement)factory.createStatementFromText(fieldName + "= y;", null);
+        if (initializerCopy instanceof PsiArrayInitializerExpression) {
+          PsiType type = initializer.getType();
+          PsiNewExpression newExpression =
+            (PsiNewExpression)factory.createExpressionFromText("new " + type.getCanonicalText() + "{}", body);
+          newExpression.getArrayInitializer().replace(initializerCopy);
+          initializerCopy = newExpression;
+        }
+        ((PsiAssignmentExpression)statement.getExpression()).getRExpression().replace(initializerCopy);
+        statement = (PsiExpressionStatement)field.getManager().getCodeStyleManager().reformat(statement);
+        body.add(statement);
+        initializer.delete();
+      }
+      catch (IncorrectOperationException e) {
+        LOG.error(e);
+      }
+    }
+  }
+
   private void addAssignmentToField(final String parameterName, final PsiMethod constructor) {
     @NonNls String fieldName = convertToFieldName(parameterName);
     final PsiManager manager = PsiManager.getInstance(myProject);
index 2de506c22fd1fa6a6298d7cbc3d73f56ed588436..0e8732a95e6a76d2d285d1957a3bcaceb4095fcf 100644 (file)
  */
 package com.intellij.refactoring.move;
 
+import com.intellij.openapi.util.Pair;
 import com.intellij.psi.*;
+import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.containers.HashSet;
-import com.intellij.openapi.util.Pair;
+import org.jetbrains.annotations.Nullable;
 
-import java.util.Set;
-import java.util.Map;
 import java.util.LinkedHashMap;
-
-import org.jetbrains.annotations.Nullable;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @author ven
@@ -120,7 +120,7 @@ public class MoveInstanceMembersUtil {
       if (referencedClass == null) return null;
       final PsiClass parentClass = PsiTreeUtil.getParentOfType(expression, PsiClass.class);
       assert parentClass != null;
-      if (!PsiTreeUtil.isAncestor(referencedClass, parentClass, false)) {
+      if (InheritanceUtil.isInheritorOrSelf(parentClass, referencedClass, false)) {
         referencedClass = parentClass;
       }
       return referencedClass;
index 7ab8824f8e6b0e5710b395ba5a7ed7e8512567bf..112436e3f89a05cb56d8ec550b5f5d270d063e7e 100644 (file)
@@ -128,6 +128,13 @@ public class MoveClassToInnerProcessor extends BaseRefactoringProcessor {
     final List<PsiElement> importStatements = new ArrayList<PsiElement>();
     if (!CodeStyleSettingsManager.getSettings(myProject).INSERT_INNER_CLASS_IMPORTS) {
       usages = filterUsagesInImportStatements(usages, importStatements);
+    } else {
+      //rebind imports first
+      Arrays.sort(usages, new Comparator<UsageInfo>() {
+        public int compare(UsageInfo o1, UsageInfo o2) {
+          return PsiUtil.BY_POSITION.compare(o1.getElement(), o2.getElement());
+        }
+      });
     }
     saveNonCodeUsages(usages);
     final Map<PsiElement, PsiElement> oldToNewElementsMapping = new HashMap<PsiElement, PsiElement>();
@@ -346,7 +353,7 @@ public class MoveClassToInnerProcessor extends BaseRefactoringProcessor {
   private boolean isInaccessibleFromTarget(final PsiElement element, final String visibility) {
     final PsiPackage elementPackage = JavaDirectoryService.getInstance().getPackage(element.getContainingFile().getContainingDirectory());
     return !PsiUtil.isAccessible(myTargetClass, element, null) ||
-        (visibility.equals(PsiModifier.PACKAGE_LOCAL) && !Comparing.equal(elementPackage, myTargetPackage));
+        (!myTargetClass.isInterface() && visibility.equals(PsiModifier.PACKAGE_LOCAL) && !Comparing.equal(elementPackage, myTargetPackage));
   }
 
   private void detectInaccessibleMemberUsages(final ConflictsCollector collector) {
index b481f359ceec4287802442d4aae91f376ed90d1a..e0486a59062a35c86ffeebab84a0dc09f8bdcd3d 100644 (file)
@@ -31,6 +31,7 @@ import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.codeStyle.SuggestedNameInfo;
 import com.intellij.psi.codeStyle.VariableKind;
+import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.JavaRefactoringSettings;
 import com.intellij.refactoring.PackageWrapper;
@@ -52,6 +53,8 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.util.Map;
+import java.util.Set;
 
 public class MoveInnerDialog extends RefactoringDialog {
   private final Project myProject;
@@ -133,7 +136,7 @@ public class MoveInnerDialog extends RefactoringDialog {
     }
 
     if (myCbPassOuterClass.isEnabled()) {
-      final boolean thisNeeded = MoveInstanceMembersUtil.getThisClassesToMembers(myInnerClass).containsKey(myOuterClass);
+      boolean thisNeeded = isThisNeeded(myInnerClass, myOuterClass);
       myCbPassOuterClass.setSelected(thisNeeded);
       myParameterField.setEnabled(thisNeeded);
     }
@@ -153,6 +156,16 @@ public class MoveInnerDialog extends RefactoringDialog {
     super.init();
   }
 
+  public static boolean isThisNeeded(final PsiClass innerClass, final PsiClass outerClass) {
+    final Map<PsiClass, Set<PsiMember>> classesToMembers = MoveInstanceMembersUtil.getThisClassesToMembers(innerClass);
+    for (PsiClass psiClass : classesToMembers.keySet()) {
+      if (InheritanceUtil.isInheritorOrSelf(outerClass, psiClass, true)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   public JComponent getPreferredFocusedComponent() {
     return myClassNameField;
   }
index f19839efe1921409c4b404a9cb0c2a19cbbc2ea1..850f443a40625a7c91bb4adb668ed5f877c48428 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import com.intellij.psi.PsiParameter;
 import com.intellij.refactoring.JavaRefactoringSettings;
+import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.usageView.UsageInfo;
 
 import java.util.Collection;
@@ -34,7 +35,7 @@ public class AutomaticParametersRenamerFactory implements AutomaticRenamerFactor
   }
 
   public String getOptionName() {
-    return "Rename parameters in hierarchy";
+    return RefactoringBundle.message("rename.parameters.hierarchy");
   }
 
   public boolean isEnabled() {
index a53baf82e11c0509749d4b5e68b1b6f159a20c5c..2fac0dd884f5c29bd6e63b11c242da2d52c14c8d 100644 (file)
@@ -17,9 +17,13 @@ package com.intellij.slicer;
 
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiSubstitutor;
+import com.intellij.usages.TextChunk;
+import com.intellij.usages.UsagePresentation;
 import com.intellij.util.Processor;
 import org.jetbrains.annotations.NotNull;
 
+import javax.swing.*;
+
 /**
  * User: cdr
  */
@@ -32,4 +36,30 @@ public class SliceDereferenceUsage extends SliceUsage {
   public void processChildren(Processor<SliceUsage> processor) {
     // no children
   }
+
+  @NotNull
+  @Override
+  public UsagePresentation getPresentation() {
+    final UsagePresentation presentation = super.getPresentation();
+
+    return new UsagePresentation() {
+      @NotNull
+      public TextChunk[] getText() {
+        return presentation.getText();
+      }
+
+      @NotNull
+      public String getPlainText() {
+        return presentation.getPlainText();
+      }
+
+      public Icon getIcon() {
+        return presentation.getIcon();
+      }
+
+      public String getTooltipText() {
+        return "Variable dereferenced";
+      }
+    };
+  }
 }
index 82b714aeac8d0606171eb8eed9dd43b752a0e549..8f4e245ae4c4482a5d6c9fc2ac6591c6f7ad5caa 100644 (file)
@@ -91,19 +91,4 @@ public class SliceLeafValueRootNode extends SliceNode implements MyColoredTreeCe
       renderer.append("Other", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
     }
   }
-
-  @Override
-  public void navigate(boolean requestFocus) {
-    getValue().navigate(requestFocus);
-  }
-
-  @Override
-  public boolean canNavigate() {
-    return getValue().canNavigate();
-  }
-
-  @Override
-  public boolean canNavigateToSource() {
-    return getValue().canNavigateToSource();
-  }
 }
index 827b1444dae29c2a9111d5cf70b224ec0351cecf..78749ce354efb53b60e8206636ad5864f173fdf7 100644 (file)
@@ -146,19 +146,15 @@ public class SliceNode extends AbstractTreeNode<SliceUsage> implements Duplicate
 
   protected void update(PresentationData presentation) {
     if (!initialized) {
-      duplicate = targetEqualUsages.putNodeCheckDupe(this);
+      if (!(getValue() instanceof SliceTooComplexDFAUsage)) duplicate = targetEqualUsages.putNodeCheckDupe(this);
       initialized = true;
     }
     if (presentation != null) {
-      presentation.setChanged(presentation.isChanged() || changed);
-      changed = false;
       if (duplicate != null) {
         presentation.setTooltip("Duplicate node");
       }
-
-      if (getValue() instanceof SliceDereferenceUsage) {
-        presentation.setTooltip("Variable dereferenced");
-      }
+      presentation.setChanged(presentation.isChanged() || changed);
+      changed = false;
     }
   }
 
index 2aba643f5d7e1c9220429a467b9d012d89184576..f4a638d5290f5cdf957c874acbc0cfa3a547b21b 100644 (file)
@@ -221,6 +221,7 @@ public class SliceNullnessAnalyzer {
     return node(root, map);
   }
 
+  @NotNull
   private static DfaUtil.Nullness checkNullness(final PsiElement element) {
     // null
     PsiElement value = element;
@@ -256,15 +257,21 @@ public class SliceNullnessAnalyzer {
       // exception thrown is always not null
       return DfaUtil.Nullness.NOT_NULL;
     }
+
+    if (value instanceof PsiLocalVariable || value instanceof PsiParameter) {
+      DfaUtil.Nullness result = DfaUtil.checkNullness((PsiVariable)value, context);
+      if (result != DfaUtil.Nullness.UNKNOWN) {
+        return result;
+      }
+    }
+
     if (value instanceof PsiModifierListOwner) {
       if (AnnotationUtil.isNotNull((PsiModifierListOwner)value)) return DfaUtil.Nullness.NOT_NULL;
       if (AnnotationUtil.isNullable((PsiModifierListOwner)value)) return DfaUtil.Nullness.NULL;
     }
 
-    if (value instanceof PsiLocalVariable || value instanceof PsiParameter) {
-      return DfaUtil.checkNullness((PsiVariable)value, context);
-    }
-    return null;
+    if (value instanceof PsiEnumConstant) return DfaUtil.Nullness.NOT_NULL;
+    return DfaUtil.Nullness.UNKNOWN;
   }
 
   public static class NullAnalysisResult {
diff --git a/java/java-impl/src/com/intellij/slicer/SliceTooComplexDFAUsage.java b/java/java-impl/src/com/intellij/slicer/SliceTooComplexDFAUsage.java
new file mode 100644 (file)
index 0000000..03bb3a1
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2010 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.slicer;
+
+import com.intellij.openapi.editor.markup.EffectType;
+import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiSubstitutor;
+import com.intellij.usages.TextChunk;
+import com.intellij.usages.UsagePresentation;
+import com.intellij.util.Processor;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * User: cdr
+ */
+public class SliceTooComplexDFAUsage extends SliceUsage {
+  public SliceTooComplexDFAUsage(@NotNull PsiElement element, @NotNull SliceUsage parent, @NotNull PsiSubstitutor substitutor) {
+    super(element, parent, substitutor);
+  }
+
+  @Override
+  public void processChildren(Processor<SliceUsage> processor) {
+    // no children
+  }
+
+  @NotNull
+  @Override
+  public UsagePresentation getPresentation() {
+    final UsagePresentation presentation = super.getPresentation();
+    return new UsagePresentation() {
+      @NotNull
+      public TextChunk[] getText() {
+        return new TextChunk[]{
+          new TextChunk(new TextAttributes(Color.RED, null, null, EffectType.WAVE_UNDERSCORE, Font.PLAIN), getTooltipText())
+        };
+      }
+
+      @NotNull
+      public String getPlainText() {
+        return presentation.getPlainText();
+      }
+
+      public Icon getIcon() {
+        return presentation.getIcon();
+      }
+
+      public String getTooltipText() {
+        return "Too complex to analyze, analysis stoppped here";
+      }
+    };
+  }
+}
index e4c6b5374befaabbfbb83f7b00db8918d3e22aba..b7965c25e3232abb8bde79d1339ce48867cba49c 100644 (file)
@@ -54,7 +54,6 @@ public class SliceUsage extends UsageInfo2UsageAdapter {
   public void processChildren(Processor<SliceUsage> processor) {
     final PsiElement element = getElement();
     ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
-    //indicator.setText2("<html><body>Searching for usages of "+ StringUtil.trimStart(SliceManager.getElementDescription(element),"<html><body>")+"</body></html>");
     indicator.checkCanceled();
 
     final Processor<SliceUsage> uniqueProcessor =
index 2185ac0a5d32ab669a3cd5f0e8efb247fc94c15e..fef3a5487f3d14b2282f12024c3df81a634db7d0 100644 (file)
@@ -73,8 +73,12 @@ public class SliceUtil {
     }
     if (expression instanceof PsiVariable) {
       PsiVariable variable = (PsiVariable)expression;
-
-      final Set<PsiExpression> expressions = new THashSet<PsiExpression>(DfaUtil.getCachedVariableValues(variable, original));
+      Collection<PsiExpression> values = DfaUtil.getCachedVariableValues(variable, original);
+      if (values == null) {
+        SliceUsage stopUsage = createTooComplexDFAUsage(expression, parent, parentSubstitutor);
+        return processor.process(stopUsage);
+      }
+      final Set<PsiExpression> expressions = new THashSet<PsiExpression>(values);
       PsiExpression initializer = variable.getInitializer();
       if (initializer != null && expressions.isEmpty()) expressions.add(initializer);
       for (PsiExpression exp : expressions) {
@@ -232,6 +236,9 @@ public class SliceUtil {
   public static SliceUsage createSliceUsage(@NotNull PsiElement element, @NotNull SliceUsage parent, @NotNull PsiSubstitutor substitutor) {
     return new SliceUsage(simplify(element), parent, substitutor);
   }
+  public static SliceUsage createTooComplexDFAUsage(@NotNull PsiElement element, @NotNull SliceUsage parent, @NotNull PsiSubstitutor substitutor) {
+    return new SliceTooComplexDFAUsage(simplify(element), parent, substitutor);
+  }
 
   static boolean processParameterUsages(@NotNull final PsiParameter parameter, @NotNull final Processor<SliceUsage> processor, @NotNull final SliceUsage parent,
                                         @NotNull final PsiSubstitutor parentSubstitutor) {
diff --git a/java/java-tests/testData/inspection/numericOverflow/simple/expected.xml b/java/java-tests/testData/inspection/numericOverflow/simple/expected.xml
new file mode 100644 (file)
index 0000000..197b876
--- /dev/null
@@ -0,0 +1,656 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+  <problem>
+    <file>Foo.java</file>
+    <line>87</line>
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>16</line>
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>17</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>17</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>18</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>18</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>19</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>19</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>25</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>27</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>27</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>28</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>28</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>29</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>29</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>30</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>30</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>34</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>35</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>35</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>36</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>36</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>37</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>37</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>38</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>38</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>39</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>39</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>43</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>43</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>44</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>44</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>45</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>45</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>47</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>47</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>48</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>48</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>51</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>52</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>52</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>53</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>53</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>54</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>54</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>55</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>55</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>56</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>56</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>60</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>60</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>62</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>62</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>63</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>63</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>64</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>64</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>65</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>65</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>67</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>67</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>68</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>68</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>69</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>69</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>71</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>71</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>72</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>72</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>72</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>72</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>73</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+
+
+  
+  <problem>
+    <file>Foo.java</file>
+    <line>73</line>
+    
+    <description>Numeric overflow in expression</description>
+  </problem>
+</problems>
+
diff --git a/java/java-tests/testData/inspection/numericOverflow/simple/src/Foo.java b/java/java-tests/testData/inspection/numericOverflow/simple/src/Foo.java
new file mode 100644 (file)
index 0000000..153606c
--- /dev/null
@@ -0,0 +1,88 @@
+// overflows in const expressions
+
+
+class c {
+ // @*#$& ! references do not work in JRE
+ static final long LONG_MIN_VALUE = 0x8000000000000000L;
+ static final long LONG_MAX_VALUE = 0x7fffffffffffffffL;
+ static final int INTEGER_MIN_VALUE = 0x80000000;
+ static final int INTEGER_MAX_VALUE = 0x7fffffff;
+ static final float FLOAT_MIN_VALUE = 1.4e-45f;
+ static final float FLOAT_MAX_VALUE = 3.4028235e+38f;
+ static final double DOUBLE_MIN_VALUE = 4.9e-324;
+ static final double DOUBLE_MAX_VALUE = 1.7976931348623157e+308;
+
+ void f() {
+   float f1 = 1.0f / 0.0f;
+   f1 = FLOAT_MAX_VALUE + FLOAT_MAX_VALUE;
+   f1 = FLOAT_MAX_VALUE * 2;
+   f1 = 2 / FLOAT_MIN_VALUE;
+   f1 = FLOAT_MIN_VALUE + 1;
+   f1 = - FLOAT_MIN_VALUE;
+   f1 = -FLOAT_MAX_VALUE;
+   System.out.println(f1);
+
+   double d1 = DOUBLE_MAX_VALUE - -DOUBLE_MAX_VALUE;
+   d1 = DOUBLE_MAX_VALUE + 1;
+   d1 = 2 * DOUBLE_MAX_VALUE;
+   d1 = 2 / DOUBLE_MIN_VALUE;
+   d1 = 2 / 0.0d;
+   d1 = 2 / 0.0;
+   System.out.println(d1);
+
+
+   int i1 = INTEGER_MAX_VALUE + 1;
+   i1 = INTEGER_MAX_VALUE - 1 + 2;
+   i1 = INTEGER_MAX_VALUE - INTEGER_MIN_VALUE;
+   i1 = -INTEGER_MIN_VALUE;
+   i1 = INTEGER_MIN_VALUE - 1;
+   i1 = INTEGER_MIN_VALUE - INTEGER_MAX_VALUE;
+   i1 = INTEGER_MIN_VALUE + INTEGER_MAX_VALUE;
+   i1 = - INTEGER_MAX_VALUE;
+   i1 = - -INTEGER_MAX_VALUE;
+   i1 = INTEGER_MIN_VALUE * -1;
+   i1 = INTEGER_MIN_VALUE * 2;
+   i1 = INTEGER_MAX_VALUE * -2;
+   i1 = INTEGER_MAX_VALUE * -1;
+   i1 = 2 / 0;
+   i1 = INTEGER_MIN_VALUE / -1;
+   System.out.println(i1);
+
+   long l1 = LONG_MAX_VALUE + 1;
+   l1 = LONG_MAX_VALUE - 1 + 2;
+   l1 = LONG_MAX_VALUE - LONG_MIN_VALUE;
+   l1 = -LONG_MIN_VALUE;
+   l1 = LONG_MIN_VALUE - 1;
+   l1 = LONG_MIN_VALUE - LONG_MAX_VALUE;
+   l1 = LONG_MIN_VALUE + LONG_MAX_VALUE;
+   l1 = - LONG_MAX_VALUE;
+   l1 = - -LONG_MAX_VALUE;
+   l1 = -INTEGER_MIN_VALUE;
+   l1 =  -1L + INTEGER_MIN_VALUE;
+   l1 = LONG_MIN_VALUE * INTEGER_MIN_VALUE;
+   l1 = LONG_MIN_VALUE * -1;
+   l1 = LONG_MIN_VALUE * 2;
+   l1 = LONG_MAX_VALUE * -2;
+   l1 = INTEGER_MIN_VALUE * -1L;
+   l1 = 2 / 0L;
+   l1 = 2 % 0L;
+   l1 = LONG_MIN_VALUE / -1;
+
+   l1 = 30 * 24 * 60 * 60 * 1000; 
+   l1 = 30000000 * 243232323 
+        * (LONG_MAX_VALUE +3) / 5; 
+   System.out.println(l1);
+
+
+   
+   }
+   
+    private static final long MILLIS_PER_DAY = 24 * 3600 * 1000;
+    private static final long _7DAYS = 7 * MILLIS_PER_DAY;
+    private static final long _30DAYS = 30 * MILLIS_PER_DAY;
+    private static final long _1000DAYS = 1000 * MILLIS_PER_DAY;
+    {
+       System.out.println(_1000DAYS + _30DAYS + _7DAYS);
+    }
+    int iii = 2 % 0;
+}
diff --git a/java/java-tests/testData/refactoring/inlineMethod/WithSuperInside.java b/java/java-tests/testData/refactoring/inlineMethod/WithSuperInside.java
new file mode 100644 (file)
index 0000000..015e3b0
--- /dev/null
@@ -0,0 +1,17 @@
+public class Usage {
+  void foo() {
+    b<caret>ar();
+  }
+
+  void bar() {
+    new W() {
+      protected void www() {
+        super.www();
+      }
+    };
+  }
+}
+
+class W {
+  protected void www() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineMethod/WithSuperInside.java.after b/java/java-tests/testData/refactoring/inlineMethod/WithSuperInside.java.after
new file mode 100644 (file)
index 0000000..d454a7f
--- /dev/null
@@ -0,0 +1,14 @@
+public class Usage {
+  void foo() {
+      new W() {
+        protected void www() {
+          super.www();
+        }
+      };
+  }
+
+}
+
+class W {
+  protected void www() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/HandleExceptions.java b/java/java-tests/testData/refactoring/inlineParameter/HandleExceptions.java
new file mode 100644 (file)
index 0000000..2558922
--- /dev/null
@@ -0,0 +1,26 @@
+import java.io.*;
+public class Subject {
+  private int myInt;
+
+  public void withClass(Object <caret>o) {
+    myInt += o.hashCode();
+  }
+}
+
+class User {
+  private void oper() throws IOException {
+    Subject subj = new Subject();
+    subj.withClass(new ThirdParty(false));
+  }
+}
+
+class ThirdParty {
+  public ThirdParty() {
+  }
+
+  public ThirdParty(boolean b) throws IOException {
+    if (b) {
+      throw new IOException();
+    }
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/HandleExceptions.java.after b/java/java-tests/testData/refactoring/inlineParameter/HandleExceptions.java.after
new file mode 100644 (file)
index 0000000..8e87464
--- /dev/null
@@ -0,0 +1,26 @@
+import java.io.*;
+public class Subject {
+  private int myInt;
+
+  public void withClass() throws IOException {
+    myInt += new ThirdParty(false).hashCode();
+  }
+}
+
+class User {
+  private void oper() throws IOException {
+    Subject subj = new Subject();
+    subj.withClass();
+  }
+}
+
+class ThirdParty {
+  public ThirdParty() {
+  }
+
+  public ThirdParty(boolean b) throws IOException {
+    if (b) {
+      throw new IOException();
+    }
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/Ref2ConstantsWithTheSameValue.java b/java/java-tests/testData/refactoring/inlineParameter/Ref2ConstantsWithTheSameValue.java
new file mode 100644 (file)
index 0000000..1893d8c
--- /dev/null
@@ -0,0 +1,18 @@
+public class Subject {
+  private int myInt;
+
+  public void wp(int <caret>p) {
+    myInt += p;
+  }
+}
+
+class User {
+  public static final int OUR_CONST = 2;
+  public static final int OUR_CONST2 = 2;
+
+  private void oper() {
+    Subject subj = new Subject();
+    subj.wp(OUR_CONST);
+    subj.wp(OUR_CONST2);
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/Ref2ConstantsWithTheSameValue.java.after b/java/java-tests/testData/refactoring/inlineParameter/Ref2ConstantsWithTheSameValue.java.after
new file mode 100644 (file)
index 0000000..692154d
--- /dev/null
@@ -0,0 +1,18 @@
+public class Subject {
+  private int myInt;
+
+  public void wp() {
+    myInt += User.OUR_CONST;
+  }
+}
+
+class User {
+  public static final int OUR_CONST = 2;
+  public static final int OUR_CONST2 = 2;
+
+  private void oper() {
+    Subject subj = new Subject();
+    subj.wp();
+    subj.wp();
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefArrayAccess.java b/java/java-tests/testData/refactoring/inlineParameter/RefArrayAccess.java
new file mode 100644 (file)
index 0000000..929fd27
--- /dev/null
@@ -0,0 +1,16 @@
+public class Subject {
+  private int myInt;
+
+  public void withArray(int[] <caret>pia) {
+    myInt += pia[0];
+  }
+}
+
+class User {
+  private void oper() {
+    Subject subj = new Subject();
+    int[] ia = new int[]{0, 1};
+    ia[0] = 2;
+    subj.withArray(ia);
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefConstantAndField.java b/java/java-tests/testData/refactoring/inlineParameter/RefConstantAndField.java
new file mode 100644 (file)
index 0000000..bbe02f9
--- /dev/null
@@ -0,0 +1,18 @@
+public class Subject {
+  private int myInt;
+
+  public void wp(int <caret>p) {
+    myInt += p;
+  }
+}
+
+class User {
+  public static int ourStatic = 0;
+  public static final int OUR_CONST = 0;
+
+  private void oper() {
+    Subject subj = new Subject();
+    subj.wp(OUR_CONST);
+    subj.wp(ourStatic);
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefNewInner.java b/java/java-tests/testData/refactoring/inlineParameter/RefNewInner.java
new file mode 100644 (file)
index 0000000..ebac975
--- /dev/null
@@ -0,0 +1,17 @@
+public class Subject {
+  private int myInt;
+
+  public void withClass(Object <caret>o) {
+    myInt += o.hashCode();
+  }
+}
+
+class User {
+  private void oper() throws IOException {
+    Subject subj = new Subject();
+    subj.withClass(new Local());
+  }
+
+  class Local {
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefNewInnerForMethod.java b/java/java-tests/testData/refactoring/inlineParameter/RefNewInnerForMethod.java
new file mode 100644 (file)
index 0000000..6ec3664
--- /dev/null
@@ -0,0 +1,21 @@
+public class Subject {
+    private int myInt;
+
+    public void withClass(Object <caret>o) {
+        myInt += o.hashCode();
+    }
+
+    class User {
+        private void oper() throws IOException {
+            Subject subj = new Subject();
+
+            subj.withClass(new Local());
+        }
+
+
+    }
+
+    class Local {
+    }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefNewInnerForMethod.java.after b/java/java-tests/testData/refactoring/inlineParameter/RefNewInnerForMethod.java.after
new file mode 100644 (file)
index 0000000..e1f8917
--- /dev/null
@@ -0,0 +1,21 @@
+public class Subject {
+    private int myInt;
+
+    public void withClass() {
+        myInt += new Local().hashCode();
+    }
+
+    class User {
+        private void oper() throws IOException {
+            Subject subj = new Subject();
+
+            subj.withClass();
+        }
+
+
+    }
+
+    class Local {
+    }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefNewLocal.java b/java/java-tests/testData/refactoring/inlineParameter/RefNewLocal.java
new file mode 100644 (file)
index 0000000..3948972
--- /dev/null
@@ -0,0 +1,18 @@
+public class Subject {
+  private int myInt;
+
+  public void withClass(Object <caret>o) {
+    myInt += o.hashCode();
+  }
+}
+
+class User {
+  private void oper() throws IOException {
+    Subject subj = new Subject();
+    class Local {
+    }
+    subj.withClass(new Local());
+  }
+
+
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefNewTopLevel.java b/java/java-tests/testData/refactoring/inlineParameter/RefNewTopLevel.java
new file mode 100644 (file)
index 0000000..c5212b2
--- /dev/null
@@ -0,0 +1,16 @@
+public class Subject {
+  private int myInt;
+
+  public void withClass(Object <caret>o) {
+    myInt += o.hashCode();
+  }
+}
+
+class User {
+  private void oper() throws IOException {
+    Subject subj = new Subject();
+    subj.withClass(new TopLevel());
+  }
+}
+
+class TopLevel {}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefNewTopLevel.java.after b/java/java-tests/testData/refactoring/inlineParameter/RefNewTopLevel.java.after
new file mode 100644 (file)
index 0000000..82bcacc
--- /dev/null
@@ -0,0 +1,16 @@
+public class Subject {
+  private int myInt;
+
+  public void withClass() {
+    myInt += new TopLevel().hashCode();
+  }
+}
+
+class User {
+  private void oper() throws IOException {
+    Subject subj = new Subject();
+    subj.withClass();
+  }
+}
+
+class TopLevel {}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefOuterThis.java b/java/java-tests/testData/refactoring/inlineParameter/RefOuterThis.java
new file mode 100644 (file)
index 0000000..e3ef672
--- /dev/null
@@ -0,0 +1,14 @@
+public class Subject {
+  private int myInt;
+
+  public void withClass(Object <caret>o) {
+    myInt += o.hashCode();
+  }
+}
+
+class User {
+  private void oper() {
+    Subject subj = new Subject();
+    subj.withClass(this);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefQualifiedThis.java b/java/java-tests/testData/refactoring/inlineParameter/RefQualifiedThis.java
new file mode 100644 (file)
index 0000000..108aa6a
--- /dev/null
@@ -0,0 +1,14 @@
+class Outer {
+  class User {
+    public class Subject {
+      public void withClass(Object <caret>o) {
+        System.out.println(o.toString());
+      }
+    }
+
+    private void oper() {
+      Subject subj = new Subject();
+      subj.withClass(Outer.this);
+    }
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefQualifiedThis.java.after b/java/java-tests/testData/refactoring/inlineParameter/RefQualifiedThis.java.after
new file mode 100644 (file)
index 0000000..be2095d
--- /dev/null
@@ -0,0 +1,14 @@
+class Outer {
+  class User {
+    public class Subject {
+      public void withClass() {
+        System.out.println(Outer.this.toString());
+      }
+    }
+
+    private void oper() {
+      Subject subj = new Subject();
+      subj.withClass();
+    }
+  }
+}
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalField.java b/java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalField.java
new file mode 100644 (file)
index 0000000..6a8a8a1
--- /dev/null
@@ -0,0 +1,13 @@
+public class Subject {
+  private int myInt;
+  private int t;
+
+  public void wp(int <caret>p) {
+    myInt += p;
+  }
+
+  void foo() {
+      wp(t);
+      wp(t);
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalField.java.after b/java/java-tests/testData/refactoring/inlineParameter/RefSameNonFinalField.java.after
new file mode 100644 (file)
index 0000000..55b393e