Merge branch 'master' into changeSignature
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Tue, 16 Mar 2010 14:21:59 +0000 (17:21 +0300)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Tue, 16 Mar 2010 14:21:59 +0000 (17:21 +0300)
279 files changed:
RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl.java
RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpPropertyImpl.java
build/scripts/layouts.gant
java/compiler/impl/src/com/intellij/compiler/impl/CompileContextExProxy.java
java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
java/compiler/impl/src/com/intellij/compiler/impl/CompositeScope.java
java/compiler/impl/src/com/intellij/compiler/impl/TrackDependenciesScope.java
java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java
java/compiler/impl/src/com/intellij/packaging/impl/compiler/IncrementalArtifactsCompiler.java
java/compiler/impl/src/com/intellij/packaging/impl/elements/ModuleOutputPackagingElement.java
java/compiler/openapi/src/com/intellij/openapi/compiler/DummyCompileContext.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java
java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorContextBase.java
java/idea-ui/src/com/intellij/facet/impl/ui/FacetErrorPanel.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/FieldCanBeLocalInspection.java
java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java
java/java-impl/src/com/intellij/ide/todo/nodes/TodoPackageNode.java
java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
java/java-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java
java/java-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
java/java-impl/src/com/intellij/psi/impl/compiled/ClsJavaCodeReferenceElementImpl.java
java/java-impl/src/com/intellij/psi/impl/compiled/ClsReferenceExpressionImpl.java
java/java-impl/src/com/intellij/psi/impl/compiled/ClsTypeParameterReferenceImpl.java
java/java-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java
java/java-impl/src/com/intellij/psi/impl/light/LightClassReference.java
java/java-impl/src/com/intellij/psi/impl/light/LightClassReferenceExpression.java
java/java-impl/src/com/intellij/psi/impl/light/LightMemberReference.java
java/java-impl/src/com/intellij/psi/impl/light/LightPackageReference.java
java/java-impl/src/com/intellij/psi/impl/source/PsiClassImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiEnumConstantImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiFieldImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java
java/java-impl/src/com/intellij/psi/impl/source/PsiLabelReference.java
java/java-impl/src/com/intellij/psi/impl/source/PsiMethodImpl.java
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java
java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocMethodOrFieldRef.java
java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocParamRef.java
java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/MethodPropertyReference.java
java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiPackageReference.java
java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiNameValuePairImpl.java
java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiNewExpressionImpl.java
java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
java/java-tests/testData/inspection/fieldCanBeLocal/localStateVar2InnerClass/expected.xml [new file with mode: 0644]
java/java-tests/testData/inspection/fieldCanBeLocal/localStateVar2InnerClass/src/Test.java [new file with mode: 0644]
java/java-tests/testData/inspection/fieldCanBeLocal/stateField/expected.xml [new file with mode: 0644]
java/java-tests/testData/inspection/fieldCanBeLocal/stateField/src/Test.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/completion/WordCompletionTest.java
java/java-tests/testSrc/com/intellij/codeInspection/FieldCanBeLocalTest.java
java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java
java/java-tests/testSrc/com/intellij/projectView/JavaTreeStructureTest.java
java/java-tests/testSrc/com/intellij/projectView/ProjectTreeStructureTest.java
java/java-tests/testSrc/com/intellij/projectView/ToDoTreeStructureTest.java
java/testFramework/src/com/intellij/projectView/BaseProjectViewTestCase.java
platform/lang-api/src/com/intellij/openapi/roots/ProjectRootsTraversing.java
platform/lang-api/src/com/intellij/psi/PsiReferenceBase.java
platform/lang-api/src/com/intellij/psi/TokenType.java
platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java
platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java
platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java
platform/lang-impl/src/com/intellij/codeInspection/reference/RefEntityImpl.java
platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java
platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java
platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java
platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
platform/lang-impl/src/com/intellij/ide/util/DefaultPsiElementCellRenderer.java
platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java
platform/lang-impl/src/com/intellij/injected/editor/RangeMarkerWindow.java
platform/lang-impl/src/com/intellij/mock/MockPsiManager.java
platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java
platform/lang-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java
platform/lang-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/PsiMultiReference.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceCharFilter.java
platform/lvcs-impl/src/com/intellij/history/integration/patches/PatchCreator.java
platform/lvcs-impl/testSrc/com/intellij/historyIntegrTests/PatchingTestCase.java
platform/platform-api/src/com/intellij/execution/process/OSProcessHandler.java
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java
platform/platform-api/src/com/intellij/openapi/ui/Queryable.java [new file with mode: 0644]
platform/platform-api/src/com/intellij/openapi/util/process/ProcessCloseUtil.java
platform/platform-api/src/com/intellij/ui/tabs/TabInfo.java
platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
platform/platform-api/src/com/intellij/util/ui/DialogUtil.java
platform/platform-api/src/com/intellij/util/ui/OptionsDialog.java
platform/platform-impl/src/com/intellij/openapi/command/impl/DocumentReferenceByVirtualFile.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorComponentImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/IndentsModelImpl.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java
platform/platform-impl/src/com/intellij/openapi/progress/util/SmoothProgressAdapter.java
platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java
platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AssertFocused.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java
platform/platform-resources/src/META-INF/XmlPlugin.xml
platform/testFramework/src/com/intellij/mock/MockDocument.java
platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java [new file with mode: 0644]
platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
platform/usageView/src/com/intellij/usages/UsageViewSettings.java
platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
platform/usageView/src/com/intellij/usages/impl/rules/UsageScopeGroupingRule.java [new file with mode: 0644]
platform/usageView/src/com/intellij/usages/impl/rules/UsageType.java
platform/usageView/src/com/intellij/usages/impl/rules/UsageTypeGroupingRule.java
platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java [new file with mode: 0644]
platform/util/src/com/intellij/openapi/diff/impl/patch/PatchLine.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchLine.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/processing/DiffFragmentsProcessor.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/DiffFragmentsProcessor.java with 100% similarity]
platform/util/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java [moved from platform/platform-impl/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java with 100% similarity]
platform/util/src/com/intellij/openapi/util/UserDataHolderBase.java
platform/util/src/com/intellij/util/ui/UIUtil.java
platform/util/testSrc/com/intellij/util/Assertion.java
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/BinaryFilePatch.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/BinaryFilePatch.java with 72% similarity]
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/FilePatch.java [new file with mode: 0644]
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchReader.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchReader.java with 96% similarity]
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchSyntaxException.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchSyntaxException.java with 100% similarity]
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextFilePatch.java [new file with mode: 0644]
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextPatchBuilder.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchBuilder.java with 98% similarity]
platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/UnifiedDiffWriter.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/UnifiedDiffWriter.java with 99% similarity]
platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java
platform/vcs-api/src/com/intellij/openapi/vcs/VcsShowConfirmationOption.java
platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangeListListener.java
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchVirtualFileReader.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/TextFilePatch.java [deleted file]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyBinaryFilePatch.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyBinaryShelvedFilePatch.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyFilePatch.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyFilePatchBase.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/FilePatch.java with 74% similarity]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyFilePatchFactory.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyPatchHunk.java [moved from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java with 63% similarity]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/ApplyTextFilePatch.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/CustomBinaryPatchApplier.java
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PatchApplier.java
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PathsVerifier.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsConfirmationDialog.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RevertCommittedStuffAbstractAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDialog.form [deleted file]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDialog.java [deleted file]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/LazyPatchContentRevision.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java
platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form
platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java
platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java
plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/EmptyFinallyBlockInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/initialization/InstanceVariableUninitializedUseInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/UninitializedReadCollector.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/LanguageReference.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/java/RegExpEnumReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntAttributeReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntElementNameReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntEntityReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntMacroDefParameterReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntPropertyReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntRefIdReference.java
plugins/ant/src/com/intellij/lang/ant/psi/impl/reference/AntTargetReference.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocParameterReferenceImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrListOrMapImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationNameValuePairImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrConstructorInvocationImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
plugins/groovy/testdata/highlighting/IndexPropertyAccess.groovy [new file with mode: 0644]
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomUtil.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenModulePsiReference.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContibutor.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
plugins/maven/src/main/resources/META-INF/plugin.xml
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyCompletionAndResolutionTest.java
plugins/spellchecker/lib-src/jazzy-0.5.2.src.zip [deleted file]
plugins/spellchecker/lib/jazzy-core.jar [deleted file]
plugins/spellchecker/lib/patricia-trie-0.1.jar [deleted file]
plugins/spellchecker/spellchecker.iml
plugins/spellchecker/src/com/intellij/spellchecker/BaseSuggestionProvider.java
plugins/spellchecker/src/com/intellij/spellchecker/BundledDictionaryProvider.java
plugins/spellchecker/src/com/intellij/spellchecker/DefaultBundledDictionariesProvider.java
plugins/spellchecker/src/com/intellij/spellchecker/FileLoader.java
plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java
plugins/spellchecker/src/com/intellij/spellchecker/StreamLoader.java
plugins/spellchecker/src/com/intellij/spellchecker/compress/Alphabet.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/compress/Compressor.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/compress/EncodingException.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/compress/UnitBitSet.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/AggregatedDictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/Dictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/EditableDictionary.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/EditableDictionaryLoader.java [new file with mode: 0644]
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/Loader.java
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/ProjectDictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/dictionary/UserDictionary.java
plugins/spellchecker/src/com/intellij/spellchecker/engine/BaseSpellChecker.java
plugins/spellchecker/src/com/intellij/spellchecker/engine/SpellCheckerEngine.java
plugins/spellchecker/src/com/intellij/spellchecker/engine/Transformation.java
plugins/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java
plugins/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java
plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/ChangeTo.java
plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java
plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java
plugins/spellchecker/src/com/intellij/spellchecker/state/CachedDictionaryState.java
plugins/spellchecker/src/com/intellij/spellchecker/state/DictionaryState.java
plugins/spellchecker/src/com/intellij/spellchecker/state/ProjectDictionaryState.java
plugins/spellchecker/src/com/intellij/spellchecker/state/StateLoader.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/CommentTokenizer.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/HtmlSpellcheckingStrategy.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/TextTokenizer.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/Token.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/Tokenizer.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/XmlAttributeTokenizer.java
plugins/spellchecker/src/com/intellij/spellchecker/tokenizer/XmlTextTokenizer.java
plugins/spellchecker/src/com/intellij/spellchecker/util/Strings.java
plugins/spellchecker/testData/inspection/groovy/Test.groovy
plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/CompressorTest.java [new file with mode: 0644]
plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/DictionaryTest.java [new file with mode: 0644]
plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/EncodeAndCompressTest.java [new file with mode: 0644]
plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/EncoderTest.java [new file with mode: 0644]
plugins/spellchecker/testSrc/com/intellij/spellchecker/compress/UnitBitSetTests.java [new file with mode: 0644]
plugins/spellchecker/testSrc/com/intellij/spellchecker/inspection/SpellcheckerInspectionTestCase.java
plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java
plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/contents.txt [new file with mode: 0644]
plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/crt.txt [new file with mode: 0644]
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnCopiesRefreshManager.java
plugins/testng/src/com/theoryinpractice/testng/TestNGReferenceContributor.java
plugins/ui-designer/src/com/intellij/uiDesigner/binding/ReferenceInForm.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/psi/impl/PrefixReferenceImpl.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/psi/impl/ReferenceBase.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/psi/impl/XPathFunctionCallImpl.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/psi/impl/XPathNodeTestImpl.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/psi/impl/XPathVariableReferenceImpl.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/AttributeReference.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/ExternalResourceReference.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/ModeReference.java
plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/references/SelfReference.java
xml/dom-impl/src/com/intellij/util/xml/impl/DomFileElementImpl.java
xml/dom-impl/src/com/intellij/util/xml/impl/GenericDomValueReference.java
xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java
xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java
xml/dom-openapi/src/com/intellij/util/xml/converters/QuotedValueConverter.java
xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java
xml/impl/src/com/intellij/codeInsight/template/XmlZenCodingTemplate.java [deleted file]
xml/impl/src/com/intellij/codeInsight/template/zencoding/MarkerToken.java [moved from platform/platform-api/src/com/intellij/openapi/ui/TestableUi.java with 76% similarity]
xml/impl/src/com/intellij/codeInsight/template/zencoding/NumberToken.java [new file with mode: 0644]
xml/impl/src/com/intellij/codeInsight/template/zencoding/OperationToken.java [new file with mode: 0644]
xml/impl/src/com/intellij/codeInsight/template/zencoding/State.java [new file with mode: 0644]
xml/impl/src/com/intellij/codeInsight/template/zencoding/TemplateToken.java [new file with mode: 0644]
xml/impl/src/com/intellij/codeInsight/template/zencoding/Token.java [moved from plugins/spellchecker/src/com/intellij/spellchecker/trie/Action.java with 79% similarity]
xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingInterpreter.java [new file with mode: 0644]
xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java [new file with mode: 0644]
xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTagInspection.java
xml/impl/src/com/intellij/psi/impl/source/parsing/xml/OldXmlParsing.java
xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/AttributeValueSelfReference.java
xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DtdReferencesProvider.java
xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/IdRefReference.java
xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java
xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java
xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java
xml/impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
xml/impl/src/com/intellij/xml/util/AnchorReference.java
xml/impl/src/com/intellij/xml/util/CheckEmptyTagInspection.java

index 5aa03c2cac45dd718e0b8394215823383e7d3760..63bad0e924d710e64fbe7d8d67751d24675f4f54 100644 (file)
@@ -104,6 +104,7 @@ public class RegExpBackrefImpl extends RegExpElementImpl implements RegExpBackre
                 return RegExpBackrefImpl.this.resolve();
             }
             
+            @NotNull
             public Object[] getVariants() {
                 return ArrayUtil.EMPTY_OBJECT_ARRAY;
             }
index b4b9cfe87dd16cac776e1c3dfa36037e0eda5ef9..8f58881c7f96cb69f2aa5e40b139ad238e2f7ef2 100644 (file)
@@ -118,6 +118,7 @@ public class RegExpPropertyImpl extends RegExpElementImpl implements RegExpPrope
             return false;
         }
 
+        @NotNull
         public Object[] getVariants() {
             final ASTNode categoryNode = getCategoryNode();
             if (categoryNode != null && categoryNode.getText().startsWith("In") && !categoryNode.getText().startsWith("Intelli")) {
index 2ef163ed660df5dee5e917a6e7e3384316157a69..952d7834d069f09634f2de413f89a0fe4ce2f688 100644 (file)
@@ -159,9 +159,7 @@ def layoutFull(String home, String targetDirectory) {
       layoutPlugin("IntentionPowerPack", "IntentionPowerPackPlugin")
       layoutPlugin("ToString", "generate-tostring", "toString")
 
-      layoutPlugin("SpellChecker", "spellchecker", "spellchecker-core") {
-        fileset(dir: "$home/plugins/spellchecker/lib")
-      }
+      layoutPlugin("SpellChecker", "spellchecker", "spellchecker-core")
 
 
       layoutPlugin("maven") {
index e312ca89abe2527a854a659944065b210a99c182..5e45940a6e003952abbd56151ca69108aeda43c9 100644 (file)
@@ -141,11 +141,11 @@ public class CompileContextExProxy implements CompileContextEx {
     return myDelegate.isRebuild();
   }
 
-  public <T> T getUserData(final Key<T> key) {
+  public <T> T getUserData(@NotNull final Key<T> key) {
     return myDelegate.getUserData(key);
   }
 
-  public <T> void putUserData(final Key<T> key, final T value) {
+  public <T> void putUserData(@NotNull final Key<T> key, final T value) {
     myDelegate.putUserData(key, value);
   }
 
index 00b601bf69bf46522bb7edf563160628c6390e35..aef725908db7ce5043cf9bb9ee8e8620799186f3 100644 (file)
@@ -1703,6 +1703,9 @@ public class CompileDriver {
     if (context.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
       return false;
     }
+    if (LOG.isDebugEnabled() && items.length > 0) {
+      LOG.debug("Start processing files by " + adapter.getCompiler().getDescription());
+    }
     final CompileScope scope = context.getCompileScope();
     final List<FileProcessingCompiler.ProcessingItem> toProcess = new ArrayList<FileProcessingCompiler.ProcessingItem>();
     final Set<String> allUrls = new HashSet<String>();
@@ -1806,7 +1809,6 @@ public class CompileDriver {
           final VirtualFile file = aProcessed.getFile();
           vFiles.add(file);
           if (LOG.isDebugEnabled()) {
-            LOG.debug("File processed by " + adapter.getCompiler().getDescription());
             LOG.debug("\tFile processed " + file.getPresentableUrl() + "; ts=" + file.getTimeStamp());
           }
 
index 3f15c8af5ab3b2d33294d53f25bcec397232f61f..2b8195fbe55641cae9fb9e9536ea0f8ff488e7a9 100644 (file)
@@ -89,7 +89,7 @@ public class CompositeScope extends UserDataHolderBase implements CompileScope{
     return modules.toArray(new Module[modules.size()]);
   }
 
-  public <T> T getUserData(Key<T> key) {
+  public <T> T getUserData(@NotNull Key<T> key) {
     for (CompileScope compileScope : myScopes) {
       T userData = compileScope.getUserData(key);
       if (userData != null) {
index 00a37258adf8fd04c22ec044d2690e497c8e69d1..a26e5a50ed40b9ffba264f176c2c1270d8c38a1c 100644 (file)
@@ -66,7 +66,7 @@ public class TrackDependenciesScope extends UserDataHolderBase implements Compil
     }
   }
 
-  public <T> T getUserData(final Key<T> key) {
+  public <T> T getUserData(@NotNull final Key<T> key) {
     T userData = myDelegate.getUserData(key);
     if (userData != null) {
       return userData;
index 4702d30f3f3163d90c424ccc09d000fea000d60e..38805aa9083caf3b981a118bd760ff442c35b08a 100644 (file)
@@ -31,10 +31,7 @@ import com.intellij.util.Processor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
 
 /**
  * @author nik
@@ -87,9 +84,10 @@ public class ArtifactCompileScope {
     Set<Artifact> artifacts = new HashSet<Artifact>();
     final ArtifactManager artifactManager = ArtifactManager.getInstance(project);
     final Set<Module> modules = new HashSet<Module>(Arrays.asList(compileScope.getAffectedModules()));
+    final List<Module> allModules = Arrays.asList(ModuleManager.getInstance(project).getModules());
     for (Artifact artifact : artifactManager.getArtifacts()) {
       if (artifact.isBuildOnMake()) {
-        if (modules.containsAll(Arrays.asList(ModuleManager.getInstance(project).getModules()))
+        if (modules.containsAll(allModules)
             || containsModuleOutput(artifact, modules, artifactManager)) {
           artifacts.add(artifact);
         }
index 38d04612f2e8155d1fbcb46a9ec517c0854d09d2..770fc0989716d741eb9811cb78a993cfc48c75ac 100644 (file)
@@ -84,6 +84,9 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
     final CompileContext context = builderContext.getCompileContext();
 
     final Set<Artifact> artifactsToBuild = ArtifactCompileScope.getArtifactsToBuild(project, context.getCompileScope());
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("artifacts to build: " + artifactsToBuild);
+    }
     List<Artifact> additionalArtifacts = new ArrayList<Artifact>();
     for (BuildParticipantProvider provider : BuildParticipantProvider.EXTENSION_POINT_NAME.getExtensions()) {
       for (Module module : ModuleManager.getInstance(project).getModules()) {
@@ -93,6 +96,9 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
         }
       }
     }
+    if (LOG.isDebugEnabled() && !additionalArtifacts.isEmpty()) {
+      LOG.debug("additional artifacts to build: " + additionalArtifacts);
+    }
     artifactsToBuild.addAll(additionalArtifacts);
 
     final List<Artifact> allArtifacts = new ArrayList<Artifact>(Arrays.asList(ArtifactManager.getInstance(project).getArtifacts()));
@@ -120,7 +126,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
         ArtifactPackagingProcessingItem[] allProcessingItems = collectItems(builderContext, context.getProject());
 
         if (LOG.isDebugEnabled()) {
-          int num = Math.min(100, allProcessingItems.length);
+          int num = Math.min(5000, allProcessingItems.length);
           LOG.debug("All files (" + num + " of " + allProcessingItems.length + "):");
           for (int i = 0; i < num; i++) {
             LOG.debug(allProcessingItems[i].getFile().getPath());
@@ -203,7 +209,7 @@ public class IncrementalArtifactsCompiler implements PackagingCompiler {
     final boolean testMode = ApplicationManager.getApplication().isUnitTestMode();
 
     if (LOG.isDebugEnabled()) {
-      int num = Math.min(100, items.length);
+      int num = Math.min(200, items.length);
       LOG.debug("Files to process (" + num + " of " + items.length + "):");
       for (int i = 0; i < num; i++) {
         LOG.debug(items[i].getFile().getPath());
index 3f2083f9e12d1c160696a2f19cc22aca76a4e09c..29d5c9d709b9721d8fa5ec027da2372fabb5a938 100644 (file)
@@ -80,9 +80,12 @@ public class ModuleOutputPackagingElement extends PackagingElement<ModuleOutputP
                                                      @NotNull ArtifactIncrementalCompilerContext compilerContext, @NotNull ArtifactType artifactType) {
     final Module module = findModule(resolvingContext);
     if (module != null) {
-      final VirtualFile output = CompilerModuleExtension.getInstance(module).getCompilerOutputPath();
-      if (output != null) {
-        creator.addDirectoryCopyInstructions(output, null);
+      final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
+      if (extension != null) {
+        final VirtualFile output = extension.getCompilerOutputPath();
+        if (output != null) {
+          creator.addDirectoryCopyInstructions(output, null);
+        }
       }
     }
   }
index 82f02dc6bb9136900ac3663b1dcefcd0cf47a08c..4a42a17d2966a2565ea06501d690b79382783f7f 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.Navigatable;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 public class DummyCompileContext implements CompileContext {
@@ -99,11 +100,11 @@ public class DummyCompileContext implements CompileContext {
     return null;
   }
 
-  public <T> T getUserData(Key<T> key) {
+  public <T> T getUserData(@NotNull Key<T> key) {
     return null;
   }
 
-  public <T> void putUserData(Key<T> key, T value) {
+  public <T> void putUserData(@NotNull Key<T> key, T value) {
   }
 
   public boolean isMake() {
@@ -113,4 +114,4 @@ public class DummyCompileContext implements CompileContext {
   public boolean isRebuild() {
     return false;
   }
-}
\ No newline at end of file
+}
index 64f8259bb958f4f5afb84aff7b00346c70367964..21b0febf54e9f91d68b2d6f9d5f8a2d2914eb71e 100644 (file)
@@ -110,8 +110,12 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
       myStoredEvaluationContext.getDebugProcess().getManagerThread().invoke(new SuspendContextCommandImpl(myStoredEvaluationContext.getSuspendContext()) {
         public void contextAction() throws Exception {
           // re-setting the context will cause value recalculation
-          setContext(myStoredEvaluationContext);
-          semaphore.up();
+          try {
+            setContext(myStoredEvaluationContext);
+          }
+          finally {
+            semaphore.up();
+          }
         }
       });
       semaphore.waitFor();
index c54f96d755c09351780270ba99605522ff0f026d..ac4e67d51576dea8e4fb880653dc99c0c19ac6e1 100644 (file)
@@ -98,7 +98,7 @@ public abstract class FacetEditorContextBase extends UserDataHolderBase implemen
   public abstract ArtifactsStructureConfigurableContext getArtifactsStructureContext();
 
   @Nullable
-  public <T> T getUserData(final Key<T> key) {
+  public <T> T getUserData(@NotNull final Key<T> key) {
     T t = super.getUserData(key);
     if (t == null && myParentContext != null) {
       t = myParentContext.getUserData(key);
index 55dc5bedd559621ff3bdcfc61aeef1474c0ca9c6..00b7f5e687a6085d4c2fcfe053921c7bcd6b2057 100644 (file)
@@ -56,6 +56,7 @@ public class FacetErrorPanel {
       public void actionPerformed(final ActionEvent e) {
         if (myCurrentQuickFix != null) {
           myCurrentQuickFix.run(myQuickFixButton);
+          myValidatorsManager.validate();
         }
       }
     });
index d4d47895b2c77a0e35f8d2810dd5e05a9042a494..1003a570f89168509dc647f003228e3858f34782 100644 (file)
@@ -383,7 +383,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
 
   public ActionCallback select(@NotNull LibraryOrderEntry libraryOrderEntry, final boolean requestFocus) {
     final Library lib = libraryOrderEntry.getLibrary();
-    if (lib != null && lib.getTable() == null) {
+    if (lib == null || lib.getTable() == null) {
       Place place = new Place().putPath(CATEGORY, myModulesConfig);
       place.putPath(BaseStructureConfigurable.TREE_OBJECT, libraryOrderEntry.getOwnerModule());
       return navigateTo(place, requestFocus);
index 7d4f51e5a0470cd38507fd93e0c2d47e3e087851..2d3079a3e5c0b6f5ff8b740a163d3082261e5ad2 100644 (file)
@@ -274,21 +274,21 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
           for (VirtualFile file : files) {
             if (mySaveAsCb.isSelected() && myPathTf.getText().trim().length() > 0) {
               final File copy = new File(new File(myPathTf.getText()), file.getName());
-              if (copy.mkdirs()) {
-                try {
-                  final File fromFile = VfsUtil.virtualToIoFile(file);
-                  if (fromFile.isFile()) {
-                    FileUtil.copy(fromFile, copy);
-                  } else {
-                    FileUtil.copyDir(fromFile, copy);
-                  }
-                  model.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(copy), type);
+              if (!copy.getParentFile().exists() && !copy.getParentFile().mkdirs()) continue;
+              try {
+                final File fromFile = VfsUtil.virtualToIoFile(file);
+                if (fromFile.isFile()) {
+                  FileUtil.copy(fromFile, copy);
+                } else {
+                  FileUtil.copyDir(fromFile, copy);
                 }
-                catch (IOException e1) {
-                  //skip
-                }
-                continue;
+                model.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(copy), type);
+              }
+              catch (IOException e1) {
+                LOG.error(e1);
               }
+
+              continue;
             }
 
             model.addRoot(file, type);
index c34393b8415a9ef47b63a9ee1133b13e1ccf7865..7087c9eb2c1745f784146dd60d8f2ecebc4e5889 100644 (file)
@@ -32,11 +32,13 @@ import com.intellij.codeInsight.intention.QuickFixFactory;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.infos.CandidateInfo;
 import com.intellij.psi.infos.MethodCandidateInfo;
 import com.intellij.psi.util.*;
 import com.intellij.xml.util.XmlStringUtil;
+import org.intellij.lang.annotations.Language;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -558,7 +560,7 @@ public class HighlightMethodUtil {
     return createMismatchedArgumentsHtmlTooltip(list, parameters, methodName, substitutor, aClass);
   }
 
-  private static String createMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
+  private static String createShortMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
                                                              PsiParameter[] parameters,
                                                              String methodName,
                                                              PsiSubstitutor substitutor,
@@ -572,11 +574,86 @@ public class HighlightMethodUtil {
       Integer.valueOf(cols - parameters.length + 1), parensizedName,
       HighlightUtil.formatClass(aClass, false),
       createMismatchedArgsHtmlTooltipParamsRow(parameters, substitutor, expressions),
-      createMismatchedArgsHtmlTooltipExpressionsRow(expressions, parameters, substitutor, cols)
+      createMismatchedArgsHtmlTooltipArgumentsRow(expressions, parameters, substitutor, cols)
     );
   }
 
-  private static String createMismatchedArgsHtmlTooltipExpressionsRow(final PsiExpression[] expressions, final PsiParameter[] parameters,
+  private static String esctrim(@NotNull String s) {
+    return StringUtil.first(XmlStringUtil.escapeString(s), 40, true);
+  }
+
+  private static String createMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
+                                                             PsiParameter[] parameters,
+                                                             String methodName,
+                                                             PsiSubstitutor substitutor,
+                                                             PsiClass aClass) {
+    if (Math.max(parameters.length, list.getExpressions().length) <= 2) {
+      return createShortMismatchedArgumentsHtmlTooltip(list, parameters, methodName, substitutor, aClass);
+    }
+    else {
+      return createLongMismatchedArgumentsHtmlTooltip(list, parameters, methodName, substitutor, aClass);
+    }
+  }
+  
+  private static String createLongMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
+                                                             PsiParameter[] parameters,
+                                                             String methodName,
+                                                             PsiSubstitutor substitutor,
+                                                             PsiClass aClass) {
+    PsiExpression[] expressions = list.getExpressions();
+
+    @NonNls @Language("HTML")
+    String s = "<html><body><table border=0>" +
+               " <caption align=top><nobr><b>" + methodName + "() </b> in <b>" + HighlightUtil.formatClass(aClass, false) +"</b>  cannot be applied to:</nobr></caption>"+
+               "  <tr><th colspan=2 align=left>Expected<br>Parameters:</th><th align=left>Actual<br>Arguments:</th></tr>"
+               +"  <tr><td colspan=3><hr></td></tr>"
+      ;
+
+
+    for (int i = 0; i < Math.max(parameters.length,expressions.length); i++) {
+      PsiParameter parameter = i < parameters.length ? parameters[i] : null;
+      PsiExpression expression = i < expressions.length ? expressions[i] : null;
+      @NonNls String mismatchColor = showShortType(i, parameters, expressions, substitutor) ? null : "red";
+
+      s += "<tr>";
+      s += "<td><b><nobr>";
+      if (parameter != null) {
+        s += esctrim(parameter.getName()) +":";
+      }
+      s += "</nobr></b></td>";
+      
+      s += "<td><b><nobr>";
+      if (parameter != null) {
+        PsiType type = substitutor.substitute(parameter.getType());
+        s +=  "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
+              esctrim(showShortType(i, parameters, expressions, substitutor)
+                                         ? type.getPresentableText()
+                                         : HighlightUtil.formatType(type))
+              + "</font>"
+              ;
+      }
+      s += "</nobr></b></td>";
+
+      s += "<td><b><nobr>";
+      if (expression != null) {
+        PsiType type = expression.getType();
+        s += "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
+               esctrim(expression.getText()) + "&nbsp;&nbsp;"+
+              (mismatchColor == null || type == null || type == PsiType.NULL ? "" : "("+esctrim(HighlightUtil.formatType(type))+")")
+              + "</font>"
+              ;
+
+      }
+      s += "</nobr></b></td>";
+
+      s += "</tr>";
+    }
+
+    s+= "  </table></body></html>";
+    return s;
+  }
+
+  private static String createMismatchedArgsHtmlTooltipArgumentsRow(final PsiExpression[] expressions, final PsiParameter[] parameters,
                                                                       final PsiSubstitutor substitutor, final int cols) {
     @NonNls String ms = "";
     for (int i = 0; i < expressions.length; i++) {
index 1ab725bc535b6e5844dc3b8cbdca25f51934bffb..6a021df380488a44ec5b0aeb36c5004901fd47c4 100644 (file)
@@ -69,6 +69,17 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
   private final Map<String, Pair<PsiImportStatementBase, PsiClass>> mySingleImportedClasses = new THashMap<String, Pair<PsiImportStatementBase, PsiClass>>();
   private final Map<String, Pair<PsiImportStaticReferenceElement, PsiField>> mySingleImportedFields = new THashMap<String, Pair<PsiImportStaticReferenceElement, PsiField>>();
   private PsiFile myFile;
+  private final PsiElementVisitor REGISTER_REFERENCES_VISITOR = new PsiRecursiveElementWalkingVisitor() {
+    @Override public void visitElement(PsiElement element) {
+      super.visitElement(element);
+      for (PsiReference reference : element.getReferences()) {
+        PsiElement resolved = reference.resolve();
+        if (resolved instanceof PsiNamedElement) {
+          myRefCountHolder.registerLocallyReferenced((PsiNamedElement)resolved);
+        }
+      }
+    }
+  };
   
   @SuppressWarnings({"UnusedDeclaration"}) //in plugin.xml
   public HighlightVisitorImpl(Project project) {
@@ -111,6 +122,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
       }
     }, false);
   }
+  
+  private void registerReferencesFromInjectedFragments(final PsiElement element) {
+    InjectedLanguageUtil.enumerate(element, myFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
+      public void visit(@NotNull final PsiFile injectedPsi, @NotNull final List<PsiLanguageInjectionHost.Shred> places) {
+        injectedPsi.accept(REGISTER_REFERENCES_VISITOR);
+      }
+    }, false);
+  }
 
   public boolean analyze(final Runnable action, final boolean updateWholeFile, final PsiFile file) {
     myFile = file;
@@ -269,6 +288,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
   @Override public void visitComment(PsiComment comment) {
     super.visitComment(comment);
     if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkUnclosedComment(comment));
+    if (!myHolder.hasErrorResults()) registerReferencesFromInjectedFragments(comment);
   }
 
   @Override public void visitContinueStatement(PsiContinueStatement statement) {
@@ -499,6 +519,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
     super.visitLiteralExpression(expression);
     if (myHolder.hasErrorResults()) return;
     myHolder.add(HighlightUtil.checkLiteralExpressionParsingError(expression));
+    if (!myHolder.hasErrorResults()) registerReferencesFromInjectedFragments(expression);
   }
 
   @Override public void visitMethod(PsiMethod method) {
index d6c709e8fa87e9bf93456b9027048f6645acff6a..c78e0a180756757a913b682f286d5a9049b2cab2 100644 (file)
@@ -15,9 +15,9 @@
  */
 package com.intellij.codeInspection.varScopeCanBeNarrowed;
 
+import com.intellij.codeInsight.CodeInsightUtil;
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
-import com.intellij.codeInsight.CodeInsightUtil;
 import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
@@ -29,6 +29,7 @@ import com.intellij.openapi.editor.ScrollType;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.codeStyle.VariableKind;
@@ -153,13 +154,13 @@ public class FieldCanBeLocalInspection extends BaseLocalInspectionTool {
           }
         }
       }
-      final Collection<PsiVariable> writtenVariables = ControlFlowUtil.getWrittenVariables(controlFlow, 0, controlFlow.getSize(), false);
+      final Ref<Collection<PsiVariable>> writtenVariables = new Ref<Collection<PsiVariable>>();
       final List<PsiReferenceExpression> readBeforeWrites = ControlFlowUtil.getReadBeforeWrite(controlFlow);
       for (final PsiReferenceExpression readBeforeWrite : readBeforeWrites) {
         final PsiElement resolved = readBeforeWrite.resolve();
         if (resolved instanceof PsiField) {
           final PsiField field = (PsiField)resolved;
-          if (writtenVariables.contains(field)){
+          if (!(field.getType() instanceof PsiPrimitiveType) || getWrittenVariables(controlFlow, writtenVariables).contains(field)){
             PsiElement parent = body.getParent();
             if (!(parent instanceof PsiMethod) ||
                 !((PsiMethod)parent).isConstructor() ||
@@ -177,6 +178,13 @@ public class FieldCanBeLocalInspection extends BaseLocalInspectionTool {
     }
   }
 
+  private static Collection<PsiVariable> getWrittenVariables(ControlFlow controlFlow, Ref<Collection<PsiVariable>> writtenVariables) {
+    if (writtenVariables.get() == null) {
+      writtenVariables.set(ControlFlowUtil.getWrittenVariables(controlFlow, 0, controlFlow.getSize(), false));
+    }
+    return writtenVariables.get();
+  }
+
   private static void removeFieldsReferencedFromInitializers(final PsiClass aClass, final Set<PsiField> candidates) {
     aClass.accept(new JavaRecursiveElementWalkingVisitor() {
       @Override public void visitMethod(PsiMethod method) {
index a890764555429b3e036dce129a65ec49444a2054..870bbb702191529884d5a1b98c76844398ae2066 100644 (file)
@@ -17,14 +17,17 @@ package com.intellij.ide.projectView.impl.nodes;
 
 import com.intellij.openapi.actionSystem.DataKey;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.psi.PsiPackage;
 
+import java.util.Map;
+
 /**
  * @author Eugene Zhuravlev
  * Date: Sep 19, 2003
  * Time: 3:51:02 PM
  */
-public final class PackageElement {
+public final class PackageElement implements Queryable {
   public static final DataKey<PackageElement> DATA_KEY =  DataKey.create("package.element");
 
   private final Module myModule;
@@ -69,4 +72,11 @@ public final class PackageElement {
   public boolean isLibraryElement() {
     return myIsLibraryElement;
   }
+
+  public void putInfo(Map<String, String> info) {
+    PsiPackage pkg = getPackage();
+    if (pkg instanceof Queryable) {
+      ((Queryable)pkg).putInfo(info);
+    }
+  }
 }
index 0136a6d90ce3a698664ecf9696a3ce853455c2cf..7adfab1b46c3cda1dd58d39695d21ed4c6b23dcb 100644 (file)
@@ -46,10 +46,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.awt.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
+import java.util.*;
 
 public final class TodoPackageNode extends PackageElementNode implements HighlightedRegionProvider {
   private final ArrayList<HighlightedRegion> myHighlightedRegions;
@@ -144,6 +141,12 @@ public final class TodoPackageNode extends PackageElementNode implements Highlig
     }
   }
 
+  @Override
+  public void apply(Map<String, String> info) {
+    info.put("toDoFileCount", String.valueOf(getFileCount(getValue())));
+    info.put("toDoItemCount", String.valueOf(getTodoItemCount(getValue())));
+  }
+
   private int getFileCount(final PackageElement packageElement) {
     int count = 0;
     if (getSettings().isFlattenPackages()) {
index c9115d619abec42f9e23169967fe90eaf2d8f6d9..900283e9661fdadaebd1c1d3da41e836e6dbaaee 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
+import com.intellij.psi.augment.PsiAugmentProvider;
 import com.intellij.psi.filters.OrFilter;
 import com.intellij.psi.impl.compiled.ClsElementImpl;
 import com.intellij.psi.impl.source.PsiImmediateClassType;
@@ -554,6 +555,10 @@ public class PsiClassImplUtil {
           if (!processor.execute(field, state)) return false;
         }
       }
+
+      for (PsiField field : PsiAugmentProvider.collectAugments(aClass, PsiField.class)) {
+        if (!processor.execute(field, state)) return false;
+      }
     }
 
     if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclaractionKind.METHOD)) {
@@ -566,6 +571,10 @@ public class PsiClassImplUtil {
         }
         if (!processor.execute(method, state)) return false;
       }
+
+      for (PsiMethod method : PsiAugmentProvider.collectAugments(aClass, PsiMethod.class)) {
+        if (!processor.execute(method, state)) return false;
+      }
     }
 
     if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclaractionKind.CLASS)) {
index 04e05f7b1cc81e0b019400cee79945835a1ef78a..22af7a58b33d1fb463a887b5a39d82c73ee2046b 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.compiled;
 
 import com.intellij.navigation.ItemPresentation;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Pair;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.InheritanceImplUtil;
@@ -27,6 +28,7 @@ import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
 import com.intellij.psi.impl.java.stubs.PsiClassStub;
 import com.intellij.psi.impl.source.ClassInnerStuffCache;
 import com.intellij.psi.impl.source.Constants;
+import com.intellij.psi.impl.source.PsiClassImpl;
 import com.intellij.psi.impl.source.SourceTreeToPsiMap;
 import com.intellij.psi.impl.source.tree.TreeElement;
 import com.intellij.psi.javadoc.PsiDocComment;
@@ -40,8 +42,9 @@ import org.jetbrains.annotations.NotNull;
 import javax.swing.*;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
-public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement {
+public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsClassImpl");
 
   private final ClassInnerStuffCache innersCache = new ClassInnerStuffCache(this);
@@ -518,4 +521,8 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
     return file == null ? null : (dir = file.getContainingDirectory()) == null
                                  ? null : JavaDirectoryService.getInstance().getPackage(dir);
   }
+
+  public void putInfo(Map<String, String> info) {
+    PsiClassImpl.putInfo(this, info);
+  }
 }
index fd9ae54733c016a5ec9b22f251abc2a1baeae91b..7e2bbef95a5d5c581ad35e3148fd49a91d296142 100644 (file)
@@ -28,6 +28,7 @@ import com.intellij.openapi.roots.OrderEntry;
 import com.intellij.openapi.roots.OrderRootType;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.java.LanguageLevel;
@@ -37,6 +38,7 @@ import com.intellij.psi.impl.PsiManagerEx;
 import com.intellij.psi.impl.PsiManagerImpl;
 import com.intellij.psi.impl.java.stubs.PsiClassStub;
 import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl;
+import com.intellij.psi.impl.source.PsiFileImpl;
 import com.intellij.psi.impl.source.PsiFileWithStubSupport;
 import com.intellij.psi.impl.source.SourceTreeToPsiMap;
 import com.intellij.psi.impl.source.resolve.FileContextUtil;
@@ -52,8 +54,10 @@ import org.jetbrains.annotations.Nullable;
 
 import java.lang.ref.SoftReference;
 import java.util.List;
+import java.util.Map;
 
-public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub> implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx {
+public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub> implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx,
+                                                                                            Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsFileImpl");
 
   static final Object MIRROR_LOCK = new String("Mirror Lock");
@@ -440,4 +444,8 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
   public PsiFile cacheCopy(final FileContent content) {
     return this;
   }
+
+  public void putInfo(Map<String, String> info) {
+    PsiFileImpl.putInfo(this, info);
+  }
 }
index 5708a57807150ea0d0f650f4948fa0a44b20d89e..57adfbf230427ad9c6150440dec90c4b6060c28b 100644 (file)
@@ -206,6 +206,7 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
            || getManager().areElementsEquivalent(resolve(), element);
   }
 
+  @NotNull
   public Object[] getVariants() {
     throw new RuntimeException("Variants are not available for references to compiled code");
   }
index 61c128e1d647fd8eae7aa677bdf3826b44b1e166..2983154903b66e2ddf6fb0c4fa9cd15c8754c997 100644 (file)
@@ -145,6 +145,7 @@ public class ClsReferenceExpressionImpl extends ClsElementImpl implements PsiRef
     return myPatternExpression.isReferenceTo(element);
   }
 
+  @NotNull
   public Object[] getVariants() {
     return myPatternExpression.getVariants();
   }
index e1c42bb22e73ee51ac47ff226ea8600cac9a5183..2c9c154b800c2f0c7fb52a6f12e0dc2314dc55c4 100644 (file)
@@ -146,6 +146,7 @@ public class ClsTypeParameterReferenceImpl extends ClsElementImpl implements Psi
     throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
   }
 
+  @NotNull
   public Object[] getVariants() {
     throw new RuntimeException("Variants are not available for references to compiled code");
   }
index a6d10ea76f7c6857fe0547151d2775bb7efc0d85..b42290fa48d4878ec779958d0af634d9b1f1ba12 100644 (file)
@@ -32,6 +32,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.roots.*;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.vfs.VfsUtil;
@@ -61,12 +62,9 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
-public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
+public class PsiPackageImpl extends PsiElementBase implements PsiPackage, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.PsiPackageImpl");
 
   private final PsiManagerEx myManager;
@@ -643,4 +641,9 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
   public PsiQualifiedNamedElement getContainer() {
     return getParentPackage();
   }
+
+  public void putInfo(Map<String, String> info) {
+    info.put("packageName", getName());
+    info.put("packageQualifiedName", getQualifiedName());
+  }
 }
index bbfba0ba65eb43112a56c402c922d965ecce91e1..ec5f6e4f8a13a76c25eaf43537ca439937de52a6 100644 (file)
@@ -228,6 +228,7 @@ public class LightClassReference extends LightElement implements PsiJavaCodeRefe
     return getManager().areElementsEquivalent(resolve(), element);
   }
 
+  @NotNull
   public Object[] getVariants() {
     throw new RuntimeException("Variants are not available for light references");
   }
index 9baa3097148ad488cb60bac726dbf933138e7e85..add6df030299f95f1ff28081802f27bdff51ab28 100644 (file)
@@ -48,6 +48,7 @@ public class LightClassReferenceExpression extends LightClassReference implement
     return getManager().areElementsEquivalent(resolve(), element);
   }
 
+  @NotNull
   public Object[] getVariants() {
     throw new RuntimeException("Variants are not available for light references");
   }
index 898718bffa882fb05b425b0b69e592c68e40c4f0..b02a2c66fb82d5b8e82383bd89921c928bf09fec 100644 (file)
@@ -144,6 +144,7 @@ public class LightMemberReference extends LightElement implements PsiJavaCodeRef
     return element instanceof PsiClass && element.getManager().areElementsEquivalent(resolve(), element);
   }
 
+  @NotNull
   public Object[] getVariants() {
     throw new RuntimeException("Variants are not available for light references");
   }
index 3c7d906efde6a9883a1a764720347b3a8c76bd89..c6b7e8c8a42de1f7a03f8f9dc813491f2a710136 100644 (file)
@@ -114,6 +114,7 @@ public class LightPackageReference extends LightElement implements PsiJavaCodeRe
     return getManager().areElementsEquivalent(resolve(), element);
   }
 
+  @NotNull
   public Object[] getVariants() {
     throw new RuntimeException("Variants are not available for light references");
   }
index f71306d568fc220886fa8eed8dd621db1f2e147b..b3b167fd4a641ffbe6c44f9ff09e0dec50c28222 100644 (file)
@@ -23,10 +23,10 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.roots.OrderEntry;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
-import com.intellij.psi.augment.PsiAugmentProvider;
 import com.intellij.psi.impl.InheritanceImplUtil;
 import com.intellij.psi.impl.PsiClassImplUtil;
 import com.intellij.psi.impl.PsiImplUtil;
@@ -51,7 +51,6 @@ import com.intellij.psi.stubs.IStubElementType;
 import com.intellij.psi.stubs.PsiFileStub;
 import com.intellij.psi.stubs.StubElement;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -60,8 +59,9 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
-public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement {
+public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiClassImpl");
 
   private final ClassInnerStuffCache innersCache = new ClassInnerStuffCache(this);
@@ -302,16 +302,12 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
 
   @NotNull
   public PsiField[] getFields() {
-    final PsiField[] owns = getStubOrPsiChildren(Constants.FIELD_BIT_SET, PsiField.ARRAY_FACTORY);
-    final List<PsiField> augments = PsiAugmentProvider.collectAugments(this, PsiField.class);
-    return ArrayUtil.mergeArrayAndCollection(owns, augments, PsiField.ARRAY_FACTORY);
+    return getStubOrPsiChildren(Constants.FIELD_BIT_SET, PsiField.ARRAY_FACTORY);
   }
 
   @NotNull
   public PsiMethod[] getMethods() {
-    final PsiMethod[] owns = getStubOrPsiChildren(Constants.METHOD_BIT_SET, PsiMethod.ARRAY_FACTORY);
-    final List<PsiMethod> augments = PsiAugmentProvider.collectAugments(this, PsiMethod.class);
-    return ArrayUtil.mergeArrayAndCollection(owns, augments, PsiMethod.ARRAY_FACTORY);
+    return getStubOrPsiChildren(Constants.METHOD_BIT_SET, PsiMethod.ARRAY_FACTORY);
   }
 
   @NotNull
@@ -645,4 +641,17 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
     return file == null ? null : (dir = file.getContainingDirectory()) == null
                                  ? null : JavaDirectoryService.getInstance().getPackage(dir);
   }
+
+  public void putInfo(Map<String, String> info) {
+    putInfo(this, info);
+  }
+
+  public static void putInfo(PsiClass psiClass, Map<String, String> info) {
+    info.put("className", psiClass.getName());
+    info.put("qualifiedClassName", psiClass.getQualifiedName());
+    PsiFile file = psiClass.getContainingFile();
+    if (file instanceof Queryable) {
+      ((Queryable)file).putInfo(info);
+    }
+  }
 }
index 958702a4692839e766386e1246aa531be6b60c80..75796c8dd24f9f3a596d2081e8eeefa4c5639283 100644 (file)
@@ -202,6 +202,7 @@ public class PsiEnumConstantImpl extends JavaStubPsiElement<PsiFieldStub> implem
       throw new IncorrectOperationException("Invalid operation");
     }
 
+    @NotNull
     public Object[] getVariants() {
       return ArrayUtil.EMPTY_OBJECT_ARRAY;
     }
index 4cec786ca1ac0dcd149c43e25ddd9ae37b2eaf58..186468ce2255cc0a5bebeb52610690270e8f3433 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source;
 import com.intellij.lang.ASTNode;
 import com.intellij.navigation.ItemPresentation;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.*;
 import com.intellij.psi.impl.cache.InitializerTooLongException;
@@ -44,9 +45,10 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
-public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements PsiField, PsiVariableEx {
+public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements PsiField, PsiVariableEx, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiFieldImpl");
 
   private volatile PatchedSoftReference<PsiType> myCachedType = null;
@@ -432,4 +434,7 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
     return PsiImplUtil.getMemberUseScope(this);
   }
 
+  public void putInfo(Map<String, String> info) {
+    info.put("fieldName", getName());
+  }
 }
index a61ed6a614ba8601d3d47eee975eaeb997383a73..1528fd1b25dc74b344d97756c58396bfd811f037 100644 (file)
@@ -383,6 +383,7 @@ public class PsiImportStaticReferenceElementImpl extends CompositePsiElement imp
     PsiScopesUtil.resolveAndWalk(proc, this, null, true);
   }
 
+  @NotNull
   public Object[] getVariants() {
     // IMPLEMENT[dsl]
     return ArrayUtil.EMPTY_OBJECT_ARRAY;
index 2ce9002a3470f3a99e7e2dd69ac337ec5c70d7e8..1d6aff6e3c014198434d5bec44b019e87083b691 100644 (file)
@@ -694,6 +694,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
     myCachedTextSkipWhiteSpaceAndComments = null;
   }
 
+  @NotNull
   public Object[] getVariants() {
     final ElementFilter filter;
     switch (getKind()) {
index c18ec0be8e8272a00de8d4344907bdf38d6c3ae2..fe1dac35655ce1225412e18a17fc2023bbf96b0c 100644 (file)
@@ -86,6 +86,7 @@ public class PsiLabelReference implements PsiReference{
       return resolve() == element;
     }
 
+    @NotNull
     public Object[] getVariants(){
       final List result = new ArrayList();
       PsiElement context = myStatement;
index d9d2c04dc6975565c8f4858c62dc4334c255f106..b67f023fc4fcfdd4224d6c1bdc577c8d02047d9a 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source;
 import com.intellij.lang.ASTNode;
 import com.intellij.navigation.ItemPresentation;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.ElementPresentationUtil;
 import com.intellij.psi.impl.PsiClassImplUtil;
@@ -46,8 +47,9 @@ import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import java.util.List;
+import java.util.Map;
 
-public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements PsiMethod {
+public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements PsiMethod, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiMethodImpl");
 
   private PatchedSoftReference<PsiType> myCachedType = null;
@@ -330,4 +332,8 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
   public SearchScope getUseScope() {
     return PsiImplUtil.getMemberUseScope(this);
   }
+
+  public void putInfo(Map<String, String> info) {
+    info.put("methodName", getName());
+  }
 }
index 7168c8a5213bfa6cd693fdcb55d22d29d767c834..aeca7ad6406551dedba5d23a09a2982a5bb74b6f 100644 (file)
@@ -671,7 +671,10 @@ public class ImportHelper{
 
         PsiElement currentFileResolveScope = resolveResult.getCurrentFileResolveScope();
         if (!(currentFileResolveScope instanceof PsiImportStatementBase)) continue;
-        if (context != null && currentFileResolveScope instanceof JspxImportStatement && context != ((JspxImportStatement)currentFileResolveScope).getDeclarationFile()) {
+        if (context != null &&
+            (!currentFileResolveScope.isValid() ||
+            currentFileResolveScope instanceof JspxImportStatement &&
+            context != ((JspxImportStatement)currentFileResolveScope).getDeclarationFile())) {
           continue;
         }
 
index 0798658ad3c3b8fe47c942d5c631a96b7ea15184..350ee4ee1644c4ff3a8da84e6819784a8e863e35 100644 (file)
@@ -116,6 +116,7 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
         }
 
         return new MyReference(method) {
+          @NotNull
           public PsiElement[] getVariants() {
             final List<PsiMethod> lst = new ArrayList<PsiMethod>();
             for (PsiMethod method : methods) {
@@ -240,6 +241,7 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
       return myReferencee == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[]{new CandidateInfo(myReferencee, PsiSubstitutor.EMPTY)};
     }
 
+    @NotNull
     public PsiElement[] getVariants(){
       final List<PsiModifierListOwner> vars = new ArrayList<PsiModifierListOwner>();
       final PsiElement scope = getScope();
index 1c785c586311574c5e21152cc39f179bcbf8a078..992e92302a3ad41b2f8f63560045ece4bdc9105c 100644 (file)
@@ -100,6 +100,7 @@ public class PsiDocParamRef extends CompositePsiElement implements PsiDocTagValu
         return getManager().areElementsEquivalent(resolve(), element);
       }
 
+      @NotNull
       public Object[] getVariants() {
         final PsiElement firstChild = getFirstChild();
         if (firstChild instanceof PsiDocToken && ((PsiDocToken)firstChild).getTokenType().equals(JavaDocTokenType.DOC_TAG_VALUE_LT)) {
index c0d884843bf27cc3073c642f64ccb4b1a5e579d1..a582a4d6993691da6ee4a34ac4cc52e46f0f449a 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.psi.xml.XmlAttribute;
 import com.intellij.psi.xml.XmlAttributeValue;
 import com.intellij.psi.xml.XmlTag;
 import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -93,6 +94,7 @@ public class MethodPropertyReference extends BasicAttributeValueReference {
     return super.handleElementRename(newElementName);
   }
 
+  @NotNull
   public Object[] getVariants() {
     return JspSpiUtil.getMethodPropertyReferenceVariants(this, resolveClass(), myReadable);
   }
index 57e715307b89aa0c92450c1070d7ac472aff224f..3dc30b5f557ef4339e26df36c7cabbc4632828d9 100644 (file)
@@ -46,6 +46,7 @@ public class PsiPackageReference extends PsiPolyVariantReferenceBase<PsiElement>
            (PsiPackage)myReferenceSet.getReference(myIndex - 1).resolve();
   }
 
+  @NotNull
   public Object[] getVariants() {
     final PsiPackage psiPackage = getContext();
     if (psiPackage == null) return ArrayUtil.EMPTY_OBJECT_ARRAY;
@@ -88,4 +89,4 @@ public class PsiPackageReference extends PsiPolyVariantReferenceBase<PsiElement>
   public PackageReferenceSet getReferenceSet() {
     return myReferenceSet;
   }
-}
\ No newline at end of file
+}
index a24afb5db17bde7a1cbe821a079161637a21e3cd..9b0cf8fd6df951cb7201edad8ed69ea0b7eda0b7 100644 (file)
@@ -185,6 +185,7 @@ public class PsiNameValuePairImpl extends CompositePsiElement implements PsiName
         return element instanceof PsiMethod && element.equals(resolve());
       }
 
+      @NotNull
       public Object[] getVariants() {
         return ArrayUtil.EMPTY_OBJECT_ARRAY;
       }
index 379787a85ad1febc1b95525622a1e9f19718c13a..08b7ec622f15e5cdc79586e225ef70bd2be61831 100644 (file)
@@ -160,6 +160,7 @@ public class PsiNewExpressionImpl extends ExpressionPsiElement implements PsiNew
         return null;
       }
 
+      @NotNull
       public Object[] getVariants() {
         return ArrayUtil.EMPTY_OBJECT_ARRAY;
       }
index 1ca3b4b5de976b788dd4691192b83b847f0c9504..24d624ff29203e801f0b25f7cf1b35cc9cb809cd 100644 (file)
@@ -56,20 +56,23 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
   public CandidateInfo resolveConflict(List<CandidateInfo> conflicts){
     if (conflicts.isEmpty()) return null;
     if (conflicts.size() == 1) return conflicts.get(0);
-    checkSameSignatures(conflicts);
 
+    checkParametersNumber(conflicts, myActualParameterTypes.length, true);
+    if (conflicts.size() == 1) return conflicts.get(0);
+
+    checkSameSignatures(conflicts);
     if (conflicts.size() == 1) return conflicts.get(0);
-    checkAccessLevels(conflicts);
 
+    checkAccessLevels(conflicts);
     if (conflicts.size() == 1) return conflicts.get(0);
 
-    checkParametersNumber(conflicts, myActualParameterTypes.length);
+    checkParametersNumber(conflicts, myActualParameterTypes.length, false);
     if (conflicts.size() == 1) return conflicts.get(0);
 
     final int applicabilityLevel = checkApplicability(conflicts);
     if (conflicts.size() == 1) return conflicts.get(0);
-    checkSpecifics(conflicts, applicabilityLevel);
 
+    checkSpecifics(conflicts, applicabilityLevel);
     if (conflicts.size() == 1) return conflicts.get(0);
 
     THashSet<CandidateInfo> uniques = new THashSet<CandidateInfo>(conflicts);
@@ -196,9 +199,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
     return ((MethodCandidateInfo)info).isApplicable();
   }
 
-  private static void checkParametersNumber(final List<CandidateInfo> conflicts, final int argumentsCount) {
+  private static void checkParametersNumber(final List<CandidateInfo> conflicts,
+                                            final int argumentsCount,
+                                            boolean checkForStaticAccessProblem) {
     boolean parametersNumberMatch = false;
     for (CandidateInfo info : conflicts) {
+      if (checkForStaticAccessProblem && !info.isStaticsScopeCorrect()) return;
       if (info instanceof MethodCandidateInfo) {
         final PsiMethod method = ((MethodCandidateInfo)info).getElement();
         if (method.isVarArgs()) return;
diff --git a/java/java-tests/testData/inspection/fieldCanBeLocal/localStateVar2InnerClass/expected.xml b/java/java-tests/testData/inspection/fieldCanBeLocal/localStateVar2InnerClass/expected.xml
new file mode 100644 (file)
index 0000000..4704d91
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems/>
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/fieldCanBeLocal/localStateVar2InnerClass/src/Test.java b/java/java-tests/testData/inspection/fieldCanBeLocal/localStateVar2InnerClass/src/Test.java
new file mode 100644 (file)
index 0000000..155a4d1
--- /dev/null
@@ -0,0 +1,11 @@
+import java.util.*;
+public class Outer {
+  private Map<String, String> value = new HashMap<String, String>();
+
+  public class Inner {
+
+    public Inner(String s) {
+      if (!value.containsKey(s)) value.put(s, "");
+    }
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/fieldCanBeLocal/stateField/expected.xml b/java/java-tests/testData/inspection/fieldCanBeLocal/stateField/expected.xml
new file mode 100644 (file)
index 0000000..580a889
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+</problems>
diff --git a/java/java-tests/testData/inspection/fieldCanBeLocal/stateField/src/Test.java b/java/java-tests/testData/inspection/fieldCanBeLocal/stateField/src/Test.java
new file mode 100644 (file)
index 0000000..79774c0
--- /dev/null
@@ -0,0 +1,8 @@
+import java.util.*;
+public class Test {
+  private final Map<String, String> myModuleToOutput = new HashMap<String, String>();
+
+  void foo() {
+    if (myModuleToOutput.containsKey(null)) myModuleToOutput.put("", "");
+  }
+}
\ No newline at end of file
index 772d769a79ab0ba3dfa07ac1912574a298514c55..a91ff5ed2da1115cda3486edd6f49f8cfe8b93ed 100644 (file)
@@ -48,6 +48,7 @@ public class WordCompletionTest extends CompletionTestCase {
             return true;
           }
 
+          @NotNull
           public Object[] getVariants() {
             return new Object[]{"MySoftVariant"};
           }
@@ -66,6 +67,7 @@ public class WordCompletionTest extends CompletionTestCase {
             return false;
           }
 
+          @NotNull
           public Object[] getVariants() {
             return new Object[]{"MyHardVariant"};
           }
index 10630e3c49c4cbecdf1f5223e529165b6d158c85..24a8d482ba1bc70d612874ab9d6c7e6556ddd4e1 100644 (file)
@@ -26,4 +26,6 @@ public class FieldCanBeLocalTest extends InspectionTestCase {
   public void testStaticAccess() throws Exception { doTest(); }
   public void testInnerClassConstructor() throws Exception { doTest(); }
   public void testLocalVar2InnerClass() throws Exception { doTest(); }
+  public void testStateField() throws Exception { doTest(); }
+  public void testLocalStateVar2InnerClass() throws Exception { doTest(); }
 }
index 647a9e0b5320cf445d09b977c25563bf5c62e84f..8aea26ae98c650c2f50f5c34e77e1919ce4c20fc 100644 (file)
@@ -6,8 +6,8 @@ import com.intellij.ide.projectView.TreeStructureProvider;
 import com.intellij.ide.projectView.ViewSettings;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import org.jetbrains.annotations.NotNull;
 
@@ -37,6 +37,11 @@ class ClassNameConvertor implements TreeStructureProvider {
             return Collections.emptyList();
           }
 
+          @Override
+          public String toTestString(Queryable.PrintInfo printInfo) {
+            return super.toTestString(printInfo) + " converted";
+          }
+
           public String getTestPresentation() {
             return name + " converted";
           }
index bc8cf98d8a7adb9fe642b439959bcc2e7a96f5a4..9397acc1e38439eefb847c05ba94ff9887f406c5 100644 (file)
@@ -141,7 +141,7 @@ public class JavaTreeStructureTest extends TestSourceBasedTestCase {
     });
   }
 
-  public void _testVisibilitySorter() throws Exception {
+  public void testVisibilitySorter() throws Exception {
     dotest(new CheckAction() {
       public void testClassStructure(StructureViewComponent structureViewComponent) {
         structureViewComponent.setActionActive(InheritedMembersFilter.ID, true);
index 8245af6c29bdf4778ecc657d0bdd8f9213842af0..8e98c92febdff66c8a6abb595f3fed4888fce381 100644 (file)
 package com.intellij.projectView;
 
+import com.intellij.openapi.ui.Queryable;
+
 public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
 
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    myPrintInfo = new Queryable.PrintInfo(new String[] {"className", "fileName", "fieldName", "methodName", "packageName"});
+  }
+
   public void test1() {
     getProjectTreeStructure().setProviders(new SameNamesJoiner(), new ClassNameConvertor(myProject));
-    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
+    assertStructureEqual(getPackageDirectory(),
+                                  "package1\n" +
                                   " Class2.java converted\n" +
                                   " Form1 joined\n" +
                                   "  Form1.java converted\n" +
-                                  "  PsiFile(plain text):Form1.form\n" +
-                                  " PsiFile(plain text):Form2.form\n");
+                                  "  Form1.form\n" +
+                                  " Form2.form\n");
   }
 
-  public void _testStandardProviders() {
+  public void testStandardProviders() {
     useStandardProviders();
 
-    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
-                                                " PsiClass:Class1\n" +
-                                                " PsiClass:Form1\n" +
-                                                " PsiFile(plain text):Form1.form\n" +
-                                                " PsiFile(plain text):Form2.form\n" +
-                                                " PsiJavaFile:Class2.java\n" +
-                                                "  PsiClass:Class2\n" +
-                                                "  PsiClass:Class3\n" +
-                                                " PsiJavaFile:Class4.java\n");
+    assertStructureEqual(getPackageDirectory(), "package1\n" +
+                                                " Class1\n" +
+                                                " Form1\n" +
+                                                " Form1.form\n" +
+                                                " Form2.form\n" +
+                                                " Class2.java\n" +
+                                                "  Class2\n" +
+                                                "  Class3\n" +
+                                                " Class4.java\n");
     assertStructureEqual("Project\n" +
            " External Libraries\n" +
            "  Library: < java 1.4 >\n" +
-           "   PsiDirectory: jsp-api.jar\n" +
-           "    PsiDirectory: META-INF\n" +
-           "     PsiFile(plain text):MANIFEST.MF\n" +
-           "    PsiDirectory: javax\n" +
-           "     PsiDirectory: servlet\n" +
-           "      PsiDirectory: jsp\n" +
-           "       PsiClass:ErrorData\n" +
-           "       PsiClass:HttpJspPage\n" +
-           "       PsiClass:JspContext\n" +
-           "       PsiClass:JspEngineInfo\n" +
-           "       PsiClass:JspException\n" +
-           "       PsiClass:JspFactory\n" +
-           "       PsiClass:JspPage\n" +
-           "       PsiClass:JspTagException\n"
+           "   jsp-api.jar\n" +
+           "    META-INF\n" +
+           "     MANIFEST.MF\n" +
+           "    javax\n" +
+           "     servlet\n" +
+           "      jsp\n" +
+           "       ErrorData\n" +
+           "       HttpJspPage\n" +
+           "       JspContext\n" +
+           "       JspEngineInfo\n" +
+           "       JspException\n" +
+           "       JspFactory\n" +
+           "       JspPage\n" +
+           "       JspTagException\n"
     );
 
     getProjectTreeStructure().setProviders();
 
-    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
-           " PsiFile(plain text):Form1.form\n" +
-           " PsiFile(plain text):Form2.form\n" +
-           " PsiJavaFile:Class1.java\n" +
-           " PsiJavaFile:Class2.java\n" +
-           " PsiJavaFile:Class4.java\n" +
-           " PsiJavaFile:Form1.java\n");
+    assertStructureEqual(getPackageDirectory(),
+           "package1\n" +
+           " Form1.form\n" +
+           " Form2.form\n" +
+           " Class1.java\n" +
+           " Class2.java\n" +
+           " Class4.java\n" +
+           " Form1.java\n");
 
     assertStructureEqual("Project\n" +
            " External Libraries\n" +
            "  Library: < java 1.4 >\n" +
-           "   PsiDirectory: jsp-api.jar\n" +
-           "    PsiDirectory: META-INF\n" +
-           "     PsiFile(plain text):MANIFEST.MF\n" +
-           "    PsiDirectory: javax\n" +
-           "     PsiDirectory: servlet\n" +
-           "      PsiDirectory: jsp\n" +
-           "       PsiDirectory: el\n" +
-           "        PsiFile:ELException.class\n" +
-           "        PsiFile:ELParseException.class\n" +
-           "        PsiFile:Expression.class\n" +
-           "        PsiFile:ExpressionEvaluator.class\n" +
-           "        PsiFile:FunctionMapper.class\n" +
-           "        PsiFile:VariableResolver.class\n" +
-           "       PsiDirectory: resources\n");
+           "   jsp-api.jar\n" +
+           "    META-INF\n" +
+           "     MANIFEST.MF\n" +
+           "    javax\n" +
+           "     servlet\n" +
+           "      jsp\n" +
+           "       el\n" +
+           "        ELException.class\n" +
+           "        ELParseException.class\n" +
+           "        Expression.class\n" +
+           "        ExpressionEvaluator.class\n" +
+           "        FunctionMapper.class\n" +
+           "        VariableResolver.class\n" +
+           "       resources\n");
   }
 
   public void testShowClassMembers() {
     useStandardProviders();
 
     myShowMembers = false;
-    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
-                                                " PsiClass:Class1\n" +
-                                                " PsiClass:Class2\n");
+    assertStructureEqual(getPackageDirectory(), "package1\n" +
+                                                " Class1\n" +
+                                                " Class2\n");
 
     myShowMembers = true;
-    assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
-                                                " PsiClass:Class1\n" +
-                                                "  PsiClass:InnerClass\n" +
-                                                "   PsiField:myInnerClassField\n" +
-                                                "  PsiField:myField1\n" +
-                                                "  PsiField:myField2\n" +
-                                                "  PsiMethod:getValue\n" +
-                                                " PsiClass:Class2\n" +
-                                                "  PsiClass:InnerClass1\n" +
-                                                "   PsiClass:InnerClass12\n" +
-                                                "    PsiClass:InnerClass13\n" +
-                                                "     PsiClass:InnerClass14\n" +
-                                                "      PsiClass:InnerClass15\n" +
-                                                "       PsiField:myInnerClassField\n" +
-                                                "      PsiField:myInnerClassField\n" +
-                                                "     PsiField:myInnerClassField\n" +
-                                                "    PsiField:myInnerClassField\n" +
-                                                "   PsiField:myInnerClassField\n" +
-                                                "  PsiClass:InnerClass2\n" +
-                                                "   PsiClass:InnerClass22\n" +
-                                                "    PsiClass:InnerClass23\n" +
-                                                "     PsiClass:InnerClass24\n" +
-                                                "      PsiClass:InnerClass25\n" +
-                                                "       PsiField:myInnerClassField\n" +
-                                                "      PsiField:myFieldToSelect\n" +
-                                                "     PsiField:myInnerClassField\n" +
-                                                "    PsiField:myInnerClassField\n" +
-                                                "   PsiField:myInnerClassField\n" +
-                                                "  PsiField:myField1\n" +
-                                                "  PsiField:myField2\n" +
-                                                "  PsiField:myField3\n" +
-                                                "  PsiField:myField4\n" +
-                                                "  PsiMethod:getValue\n", 100);
+    assertStructureEqual(getPackageDirectory(), "package1\n" +
+                                                " Class1\n" +
+                                                "  InnerClass\n" +
+                                                "   myInnerClassField\n" +
+                                                "  myField1\n" +
+                                                "  myField2\n" +
+                                                "  getValue\n" +
+                                                " Class2\n" +
+                                                "  InnerClass1\n" +
+                                                "   InnerClass12\n" +
+                                                "    InnerClass13\n" +
+                                                "     InnerClass14\n" +
+                                                "      InnerClass15\n" +
+                                                "       myInnerClassField\n" +
+                                                "      myInnerClassField\n" +
+                                                "     myInnerClassField\n" +
+                                                "    myInnerClassField\n" +
+                                                "   myInnerClassField\n" +
+                                                "  InnerClass2\n" +
+                                                "   InnerClass22\n" +
+                                                "    InnerClass23\n" +
+                                                "     InnerClass24\n" +
+                                                "      InnerClass25\n" +
+                                                "       myInnerClassField\n" +
+                                                "      myFieldToSelect\n" +
+                                                "     myInnerClassField\n" +
+                                                "    myInnerClassField\n" +
+                                                "   myInnerClassField\n" +
+                                                "  myField1\n" +
+                                                "  myField2\n" +
+                                                "  myField3\n" +
+                                                "  myField4\n" +
+                                                "  getValue\n", 100);
 
     
   }
@@ -122,20 +132,20 @@ public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
   public void testGetParentObject(){
     useStandardProviders();
     myShowMembers = true;
-    assertStructureEqual(getContentDirectory(), "PsiDirectory: getParentObject\n" +
-                                                " PsiDirectory: src\n" +
-                                                "  PsiDirectory: com\n" +
-                                                "   PsiDirectory: package1\n" +
-                                                "    PsiClass:Class1\n" +
-                                                "     PsiField:myField\n" +
-                                                "     PsiMethod:method\n" +
-                                                "    PsiClass:Form1\n" +
-                                                "    PsiFile(plain text):Form1.form\n" +
-                                                "    PsiFile(plain text):Form2.form\n" +
-                                                "    PsiJavaFile:Class2.java\n" +
-                                                "     PsiClass:Class2\n" +
-                                                "     PsiClass:Class3\n" +
-                                                "    PsiJavaFile:Class4.java\n");
+    assertStructureEqual(getContentDirectory(), "getParentObject\n" +
+                                                " src\n" +
+                                                "  com\n" +
+                                                "   package1\n" +
+                                                "    Class1\n" +
+                                                "     myField\n" +
+                                                "     method\n" +
+                                                "    Form1\n" +
+                                                "    Form1.form\n" +
+                                                "    Form2.form\n" +
+                                                "    Class2.java\n" +
+                                                "     Class2\n" +
+                                                "     Class3\n" +
+                                                "    Class4.java\n");
 
 
     checkContainsMethod(myStructure.getRootElement(), myStructure);
index 2b3544f3bd7314e453dfc7644ae6e8695e4c3f1a..f89eb8602dd4c0078cfc43103825675562d2ec97 100644 (file)
@@ -4,6 +4,7 @@ import com.intellij.ide.todo.AllTodosTreeBuilder;
 import com.intellij.ide.todo.CurrentFileTodosTreeBuilder;
 import com.intellij.ide.todo.TodoTreeStructure;
 import com.intellij.ide.todo.nodes.TodoItemNode;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.testFramework.IdeaTestUtil;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.util.ui.tree.TreeUtil;
@@ -14,6 +15,12 @@ import javax.swing.tree.DefaultTreeModel;
 
 public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
 
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    myPrintInfo = new Queryable.PrintInfo(new String[] {"className", "fileName", "fieldName", "methodName", "packageName"}, new String[] {"toDoFileCount", "toDoItemCount"});
+  }
+
   public void testToDo1() throws Exception {
     AllTodosTreeBuilder all = new AllTodosTreeBuilder(new JTree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
     all.init();
@@ -22,8 +29,8 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
     ((TodoTreeStructure)myStructure).setFlattenPackages(true);
     assertStructureEqual("Root\n" +
                          " Summary\n" +
-                         "  PsiPackage: package1.package2 (2 items in 1 file)\n" +
-                         "   PsiJavaFile:JavaClass.java\n" +
+                         "  package2 toDoFileCount=1,toDoItemCount=2\n" +
+                         "   JavaClass.java\n" +
                          "    Item: (62,78)\n" +
                          "    Item: (145,162)\n", null);
 
@@ -32,26 +39,26 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
  }
 
   //todo kirillk
-  public void _testToDo() throws Exception {
+  public void testToDo() throws Exception {
     AllTodosTreeBuilder all = new AllTodosTreeBuilder(new JTree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
     all.init();
 
     myStructure = all.getTreeStructure();
     assertStructureEqual("Root\n" +
                          " Summary\n" +
-                         "  PsiDirectory: toDo\n" +
-                         "   XmlFile:xmlFile.xml\n"+
+                         "  toDo\n" +
+                         "   xmlFile.xml\n"+
                          "    Item: (12,16)\n" +
-                         "  PsiPackage: package1 (4 items in 2 files)\n" +
-                         "   PsiPackage: package2 (2 items in 1 file)\n" +
-                         "    PsiJavaFile:JavaClass.java\n" +
+                         "  package1 toDoFileCount=2,toDoItemCount=4\n" +
+                         "   package2 toDoFileCount=1,toDoItemCount=2\n" +
+                         "    JavaClass.java\n" +
                          "     Item: (62,78)\n" +
                          "     Item: (145,162)\n" +
-                         "   PsiJavaFile:JavaClass.java\n" +
+                         "   JavaClass.java\n" +
                          "    Item: (52,68)\n" +
                          "    Item: (134,151)\n" +
-                         "  PsiPackage: package3 (2 items in 1 file)\n" +
-                         "   PsiJavaFile:JavaClass.java\n" +
+                         "  package3 toDoFileCount=1,toDoItemCount=2\n" +
+                         "   JavaClass.java\n" +
                          "    Item: (53,69)\n" +
                          "    Item: (136,153)\n", null);
 
@@ -69,28 +76,12 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
     builder.setFile(getSrcDirectory().findSubdirectory("package1").findFile("JavaClass.java"));
     builder.updateFromRoot();
     myStructure = builder.getTreeStructure();
-    assertStructureEqual("PsiJavaFile:JavaClass.java\n" +
-                         " PsiJavaFile:JavaClass.java\n" +
+    assertStructureEqual("JavaClass.java\n" +
+                         " JavaClass.java\n" +
                          "  Item: (52,68)\n" +
                          "  Item: (134,151)\n", null);
 
-    TreeUtil.expandAll(currentFileTree);
-
-    currentFileTree.getSelectionModel().setSelectionPath(currentFileTree.getPathForRow(4));
-
-    IdeaTestUtil.assertTreeEqual(currentFileTree, "-Root\n" +
-                                                  " -Summary\n" +
-                                                  "  -JavaClass.java\n" +
-                                                  "   Item: (52,68)\n" +
-                                                  "   [Item: (134,151)]\n", true);
-
-    IdeaTestUtil.waitForAlarm(600);
 
-    IdeaTestUtil.assertTreeEqual(currentFileTree, "-Root\n" +
-                                                  " -Summary\n" +
-                                                  "  -JavaClass.java\n" +
-                                                  "   Item: (52,68)\n" +
-                                                  "   [Item: (134,151)]\n", true);
     Disposer.dispose(builder);
     Disposer.dispose(all);
   }
index 5e804539cbfd08e16b2b4902fb11003d38f2f1c2..df81c6468b2c9b63ed8650179cb774e07f6d3fd5 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.ide.projectView.impl.*;
 import com.intellij.ide.projectView.impl.nodes.PackageElementNode;
 import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
 import com.intellij.ide.util.treeView.*;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.testFramework.IdeaTestUtil;
 import com.intellij.openapi.project.DumbAwareRunnable;
 import com.intellij.openapi.startup.StartupManager;
@@ -50,6 +51,8 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
   protected boolean myShowMembers = false;
   private List<AbstractProjectViewPSIPane> myPanes = new ArrayList<AbstractProjectViewPSIPane>();
 
+  protected Queryable.PrintInfo myPrintInfo;
+
   protected void setUp() throws Exception {
     super.setUp();
 
@@ -113,7 +116,7 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
 
   private void assertStructureEqual(Object rootNode, String expected, int maxRowCount, Comparator comparator) {
     checkGetParentConsistency(rootNode);
-    StringBuffer actual = IdeaTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ');
+    StringBuffer actual = IdeaTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ', myPrintInfo);
     assertEquals(expected, actual.toString());
   }
 
index d6391c012be24a740b985842df8e43607b5d09eb..8649f0ac31dc6ab3f35b01a95918f04a7ee9a15e 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.UserDataHolderBase;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.PathUtil;
 import com.intellij.util.PathsList;
+import org.jetbrains.annotations.NotNull;
 
 import java.util.HashSet;
 import java.util.List;
@@ -125,11 +126,11 @@ public class ProjectRootsTraversing {
       myCurrentModuleManager = restored;
     }
 
-    public <T> T getUserData(Key<T> key) {
+    public <T> T getUserData(@NotNull Key<T> key) {
       return myUserData.getUserData(key);
     }
 
-    public <T> void putUserData(Key<T> key, T value) {
+    public <T> void putUserData(@NotNull Key<T> key, T value) {
       myUserData.putUserData(key, value);
     }
 
index 3e150e937ab286eb22ed61ee1127f79538944e64..99aeb7473dd531a83c17379367af1c446269a16c 100644 (file)
@@ -118,6 +118,7 @@ public abstract class PsiReferenceBase<T extends PsiElement> implements PsiRefer
         return resolveTo;
       }
 
+      @NotNull
       public Object[] getVariants() {
         return EMPTY_ARRAY;
       }
index 795d8cd74301a62ef6ce24bea94c96df59594ad7..86f2877968239d8d801942a72839a5c278dfe40f 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.psi;
 
 import com.intellij.lang.Language;
-import com.intellij.openapi.fileTypes.FileTypes;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.tree.IFileElementType;
 
index b4026f9fc6b5f92d88114386277b7308e66f6182..34509ab6cb43f5a198cd538207f036d9ccffdb64 100644 (file)
@@ -254,11 +254,11 @@ public class PsiUtilBase {
         return null;
       }
 
-      public <T> T getUserData(Key<T> key) {
+      public <T> T getUserData(@NotNull Key<T> key) {
         return null;
       }
 
-      public <T> void putUserData(Key<T> key, T value) {
+      public <T> void putUserData(@NotNull Key<T> key, T value) {
 
       }
 
index 83942beb9bbcb19c3e8c3b35afd09c87efb1ec73..549744170b6422770aabf07577bffc41c173d5eb 100644 (file)
@@ -47,6 +47,7 @@ import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.Ref;
@@ -556,7 +557,30 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
           catch (Throwable e) {
             document.setText("");
             if (((ApplicationEx)ApplicationManager.getApplication()).isInternal()) {
-              LOG.error("old text: " + oldCopyText + "; new text: " + newText + "; old document text: " + oldDocumentText, e);
+              final StringBuilder sb = new StringBuilder();
+              boolean oldsAreSame = Comparing.equal(oldCopyText, oldDocumentText);
+              if (oldsAreSame) {
+                sb.append("oldCopyText == oldDocumentText");
+              }
+              else {
+                sb.append("oldCopyText != oldDocumentText");
+                sb.append("\n--- oldCopyText ------------------------------------------------\n").append(oldCopyText);
+                sb.append("\n--- oldDocumentText ------------------------------------------------\n").append(oldDocumentText);
+              }
+              if (Comparing.equal(oldCopyText, newText)) {
+                sb.insert(0, "newText == oldCopyText; ");
+              }
+              else if (!oldsAreSame && Comparing.equal(oldDocumentText, newText)) {
+                sb.insert(0, "newText == oldDocumentText; ");
+              }
+              else {
+                sb.insert(0, "newText != oldCopyText, oldDocumentText; ");
+                if (oldsAreSame) {
+                  sb.append("\n--- oldCopyText ------------------------------------------------\n").append(oldCopyText);
+                }
+                sb.append("\n--- newText ------------------------------------------------\n").append(newText);
+              }
+              LOG.error(sb.toString(), e);
             }
           }
         }
index 221f2dd4e26bda5e649e1dd4d0e7d5c57b4487e5..3c0c914d5e12968bdd0819a3abdfa29ef4005737 100644 (file)
@@ -21,10 +21,12 @@ package com.intellij.codeInsight.daemon.impl;
 
 import com.intellij.codeHighlighting.TextEditorHighlightingPass;
 import com.intellij.codeInsight.highlighting.BraceMatchingUtil;
+import com.intellij.lang.LanguageParserDefinitions;
 import com.intellij.openapi.editor.*;
 import com.intellij.openapi.editor.colors.EditorColors;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.ex.EditorEx;
+import com.intellij.openapi.editor.highlighter.EditorHighlighter;
 import com.intellij.openapi.editor.highlighter.HighlighterIterator;
 import com.intellij.openapi.editor.markup.CustomHighlighterRenderer;
 import com.intellij.openapi.editor.markup.HighlighterTargetArea;
@@ -36,6 +38,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiFile;
+import com.intellij.psi.tree.TokenSet;
 import com.intellij.util.containers.IntStack;
 import com.intellij.util.text.CharArrayUtil;
 import org.jetbrains.annotations.NotNull;
@@ -82,9 +85,16 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
       final VisualPosition startPosition = editor.offsetToVisualPosition(off);
       if (startPosition.column <= 0) return;
 
-      if (editor.getFoldingModel().isOffsetCollapsed(off)) return;
+      final FoldingModel foldingModel = editor.getFoldingModel();
+      if (foldingModel.isOffsetCollapsed(off)) return;
 
       final int endOffset = highlighter.getEndOffset();
+
+      final FoldRegion headerRegion = foldingModel.getCollapsedRegionAtOffset(doc.getLineEndOffset(doc.getLineNumber(off)));
+      final FoldRegion tailRegion = foldingModel.getCollapsedRegionAtOffset(doc.getLineStartOffset(doc.getLineNumber(endOffset)));
+      
+      if (tailRegion != null && tailRegion == headerRegion) return;
+
       final boolean selected;
       final IndentGuideDescriptor guide = editor.getIndentsModel().getCaretIndentGuide();
       if (guide != null) {
@@ -182,7 +192,7 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
   private List<IndentGuideDescriptor> buildDescriptors() {
     if (!myEditor.getSettings().isIndentGuidesShown()) return Collections.emptyList();
     
-    int[] lineIndents = calcIndents(myDocument);
+    int[] lineIndents = calcIndents();
 
     List<IndentGuideDescriptor> descriptors = new ArrayList<IndentGuideDescriptor>();
 
@@ -191,13 +201,14 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
 
     lines.push(0);
     indents.push(0);
+    final CharSequence chars = myDocument.getCharsSequence();
     for (int line = 1; line < lineIndents.length; line++) {
       int curIndent = lineIndents[line];
 
       while (!indents.empty() && curIndent <= indents.peek()) {
         final int level = indents.pop();
         int startLine = lines.pop();
-        descriptors.add(new IndentGuideDescriptor(level, startLine, line));
+        descriptors.add(createDescriptor(level, startLine, line, chars));
       }
 
       int prevLine = line - 1;
@@ -213,23 +224,47 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
       final int level = indents.pop();
       if (level > 0) {
         int startLine = lines.pop();
-        descriptors.add(new IndentGuideDescriptor(level, startLine, myDocument.getLineCount()));
+        descriptors.add(createDescriptor(level, startLine, myDocument.getLineCount(), chars));
       }
     }
     return descriptors;
   }
 
-  private int[] calcIndents(Document doc) {
+  private IndentGuideDescriptor createDescriptor(int level, int startLine, int endLine, CharSequence chars) {
+    while (startLine > 0 && isBlankLine(startLine, chars)) startLine--;
+    return new IndentGuideDescriptor(level, startLine, endLine);
+  }
+
+  private boolean isBlankLine(int line, CharSequence chars) {
+    int startOffset = myDocument.getLineStartOffset(line);
+    return CharArrayUtil.shiftForward(chars, startOffset, " \t") >= myDocument.getLineEndOffset(line);
+  }
+
+  private int[] calcIndents() {
+    final Document doc = myDocument;
     CharSequence chars = doc.getCharsSequence();
     int[] lineIndents = new int[doc.getLineCount()];
+    TokenSet comments = LanguageParserDefinitions.INSTANCE.forLanguage(myFile.getLanguage()).getCommentTokens();
 
+    int prevColumn = -1;
+    final EditorHighlighter highlighter = myEditor.getHighlighter();
     for (int line = 0; line < lineIndents.length; line++) {
-      int lineStart = myDocument.getLineStartOffset(line);
-      int lineEnd = myDocument.getLineEndOffset(line);
+      int lineStart = doc.getLineStartOffset(line);
+      int lineEnd = doc.getLineEndOffset(line);
 
       int nonWhitespaceOffset = CharArrayUtil.shiftForward(chars, lineStart, " \t");
       if (nonWhitespaceOffset < lineEnd) {
-        lineIndents[line] = myEditor.calcColumnNumber(nonWhitespaceOffset, line);
+        final int column = myEditor.calcColumnNumber(nonWhitespaceOffset, line);
+        if (column < prevColumn) {
+          final HighlighterIterator it = highlighter.createIterator(nonWhitespaceOffset);
+          if (comments.contains(it.getTokenType())) {
+            lineIndents[line] = -1;
+            continue;
+          }
+        }
+
+        lineIndents[line] = column;
+        prevColumn = column;
       }
       else {
         lineIndents[line] = -1;
@@ -243,13 +278,17 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
       }
       else {
         int startLine = line;
-        for (; line < lineIndents.length && lineIndents[line] == -1; line++);
+        while (line < lineIndents.length && lineIndents[line] == -1) {
+          //noinspection AssignmentToForLoopParameter
+          line++;
+        }
+
         int bottomIndent = line < lineIndents.length ? lineIndents[line] : topIndent;
 
         int indent = Math.min(topIndent, bottomIndent);
         if (bottomIndent < topIndent) {
-          int nonWhitespaceOffset = CharArrayUtil.shiftForward(chars, myDocument.getLineStartOffset(line), " \t");
-          HighlighterIterator iterator = myEditor.getHighlighter().createIterator(nonWhitespaceOffset);
+          int nonWhitespaceOffset = CharArrayUtil.shiftForward(chars, doc.getLineStartOffset(line), " \t");
+          HighlighterIterator iterator = highlighter.createIterator(nonWhitespaceOffset);
           if (BraceMatchingUtil.isRBraceToken(iterator, chars, myFile.getFileType())) {
             indent = topIndent;
           }
@@ -260,6 +299,7 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
           lineIndents[blankLine] = Math.min(topIndent, indent);
         }
 
+        //noinspection AssignmentToForLoopParameter
         line--; // will be incremented back at the end of the loop;
       }
     }
index 4978f3180d57250dab76dff2210b05759742c090..9d62e35ad33b99e58f4917e5ecb3035d98e6f178 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightActionHandler;
 import com.intellij.codeInsight.CodeInsightBundle;
 import com.intellij.codeInsight.TargetElementUtilBase;
 import com.intellij.codeInsight.actions.BaseCodeInsightAction;
+import com.intellij.codeInsight.hint.HintManager;
 import com.intellij.codeInsight.navigation.NavigationUtil;
 import com.intellij.featureStatistics.FeatureUsageTracker;
 import com.intellij.ide.util.DefaultPsiElementCellRenderer;
@@ -65,10 +66,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
   public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
     PsiDocumentManager.getInstance(project).commitAllDocuments();
 
-    PsiElement element;
     try {
       int offset = editor.getCaretModel().getOffset();
-      element = findTargetElement(project, editor, offset);
+      PsiElement element = findTargetElement(project, editor, offset);
       if (element == null) {
         FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.declaration");
         chooseAmbiguousTarget(editor, offset);
@@ -109,7 +109,10 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
         return true;
       }
     };
-    chooseAmbiguousTarget(editor, offset,navigateProcessor, CodeInsightBundle.message("declaration.navigation.title"));
+    boolean found = chooseAmbiguousTarget(editor, offset, navigateProcessor, CodeInsightBundle.message("declaration.navigation.title"));
+    if (!found) {
+      HintManager.getInstance().showErrorHint(editor, "Cannot find declaration to go to");
+    }
   }
 
   // returns true if processor is run or is going to be run after showing popup
@@ -127,7 +130,7 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
       processor.execute(element);
       return true;
     }
-    else if (candidates.size() > 1) {
+    if (candidates.size() > 1) {
       PsiElement[] elements = candidates.toArray(new PsiElement[candidates.size()]);
       final TextRange range = reference.getRangeInElement();
       final String refText = range.substring(reference.getElement().getText());
index 854c6d05290dabb69fb303abb3926297f934ff56..a62ab10381531799c32a462a485d404e845d95ff 100644 (file)
@@ -43,23 +43,13 @@ public class CustomTemplateCallback {
   private Project myProject;
   private RangeMarker myGlobalMarker;
   private RangeMarker myEndOffsetMarker;
-
-  //private final Map<Object, MyCheckpoint> myCheckpoints = new HashMap<Object, MyCheckpoint>();
   private final Map<Object, RangeMarker> myCheckpoints = new HashMap<Object, RangeMarker>();
 
-  /*private static class MyCheckpoint {
-    int myFixedLength = null;
-    RangeMarker myFixedOffset;
-  }*/
-
   public CustomTemplateCallback(Editor editor, PsiFile file) {
     myEditor = editor;
     myFile = file;
     myProject = file.getProject();
     myTemplateManager = TemplateManagerImpl.getInstance(myProject);
-  }
-
-  public void fixInitialEditorState() {
     myStartOffset = myEditor.getCaretModel().getOffset();
     myGlobalMarker = myEditor.getDocument().createRangeMarker(myStartOffset, myStartOffset);
     myGlobalMarker.setGreedyToLeft(true);
index d8baf07f3855e2f4a225e2aebcda31c4f64bf10f..0a331403e0df923645062d2e4a1eb1d2ad916891 100644 (file)
@@ -246,7 +246,6 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
         int caretOffset = editor.getCaretModel().getOffset();
         if (customLiveTemplate.isApplicable(file, caretOffset, false)) {
           final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file);
-          callback.fixInitialEditorState();
           String key = customLiveTemplate.computeTemplateKey(callback);
           if (key != null) {
             int offsetBeforeKey = caretOffset - key.length();
index 1f5492eb9c23f5f708cbf083c4a110dc78b9acbd..33e2bf36b7eac7bf5e4d070794323bc06cf663af 100644 (file)
@@ -28,6 +28,7 @@ import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.util.Key;
 import gnu.trove.THashMap;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
@@ -90,7 +91,7 @@ public abstract class RefEntityImpl implements RefEntity {
   }
   
  @Nullable
-  public <T> T getUserData(Key<T> key){
+  public <T> T getUserData(@NotNull Key<T> key){
     synchronized(this){
       if (myUserMap == null) return null;
       //noinspection unchecked
@@ -106,7 +107,7 @@ public abstract class RefEntityImpl implements RefEntity {
     });
   }
 
-  public <T> void putUserData(Key<T> key, T value){
+  public <T> void putUserData(@NotNull Key<T> key, T value){
     synchronized(this){
       if (myUserMap == null){
         if (value == null) return;
index 232c64880345ab51e0e96afed01678d8e7ae34f4..90b65bfd1e2610e9c74b7cf7084b38b5264ae0f9 100644 (file)
@@ -578,50 +578,51 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
   }
 
   private void waitForProcess(final RunContentDescriptor descriptor) {
-    String progressTitle =  ExecutionBundle.message("terminating.process.progress.title", descriptor.getDisplayName());
-
     ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
-      private ProgressIndicator myProgressIndicator;
-      private final Semaphore mySemaphore = new Semaphore();
-
-      private final Runnable myWaitThread = new Runnable() {
-        public void run() {
-          descriptor.getProcessHandler().waitFor();
-          mySemaphore.up();
-        }
-      };
+      public void run() {
+        final Semaphore semaphore = new Semaphore();
+        semaphore.down();
 
-      private final Runnable myCancelListener = new Runnable() {
-        public void run() {
-          while(true) {
-            if(myProgressIndicator != null && (myProgressIndicator.isCanceled() || !myProgressIndicator.isRunning())) {
-              mySemaphore.up();
-              break;
-            }
+        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+          public void run() {
+            final ProcessHandler processHandler = descriptor.getProcessHandler();
             try {
-              synchronized (this) {
-                wait(2000);
+              if (processHandler != null) {
+                processHandler.waitFor();
               }
             }
-            catch (InterruptedException ignore) {
+            finally {
+              semaphore.up();
             }
           }
-        }
-      };
+        });
+        
+        final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
 
-      public void run() {
-        myProgressIndicator = ProgressManager.getInstance().getProgressIndicator();
-        if (myProgressIndicator != null) {
-          myProgressIndicator.setText(ExecutionBundle.message("waiting.for.vm.detach.progress.text"));
+        if (progressIndicator != null) {
+          progressIndicator.setText(ExecutionBundle.message("waiting.for.vm.detach.progress.text"));
+          ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+            public void run() {
+              while(true) {
+                if(progressIndicator.isCanceled() || !progressIndicator.isRunning()) {
+                  semaphore.up();
+                  break;
+                }
+                try {
+                  synchronized (this) {
+                    wait(2000L);
+                  }
+                }
+                catch (InterruptedException ignore) {
+                }
+              }
+            }
+          });
         }
 
-        ApplicationManager.getApplication().executeOnPooledThread(myWaitThread);
-        ApplicationManager.getApplication().executeOnPooledThread(myCancelListener);
-
-        mySemaphore.down();
-        mySemaphore.waitFor();
+        semaphore.waitFor();
       }
-    }, progressTitle, true, myProject);
+    }, ExecutionBundle.message("terminating.process.progress.title", descriptor.getDisplayName()), true, myProject);
   }
 
   public interface MyRunContentListener extends EventListener {
index 14be608e3edb1749b5d8553376c67b6a7bc0e1b8..64110e91224d4bf0bb66dc3ad12085fae0593db0 100644 (file)
@@ -184,6 +184,7 @@ public class ShowUsagesAction extends AnAction {
     usageViewSettings.GROUP_BY_MODULE = false;
     usageViewSettings.GROUP_BY_PACKAGE = false;
     usageViewSettings.GROUP_BY_USAGE_TYPE = false;
+    usageViewSettings.GROUP_BY_SCOPE = false;
 
     UsageViewManager manager = UsageViewManager.getInstance(handler.getProject());
     final UsageViewImpl usageView = (UsageViewImpl)manager.createUsageView(UsageTarget.EMPTY_ARRAY, Usage.EMPTY_ARRAY, presentation, null);
@@ -194,6 +195,7 @@ public class ShowUsagesAction extends AnAction {
         usageViewSettings.GROUP_BY_MODULE = save.GROUP_BY_MODULE;
         usageViewSettings.GROUP_BY_PACKAGE = save.GROUP_BY_PACKAGE;
         usageViewSettings.GROUP_BY_USAGE_TYPE = save.GROUP_BY_USAGE_TYPE;
+        usageViewSettings.GROUP_BY_SCOPE = save.GROUP_BY_SCOPE;
       }
     });
 
@@ -694,4 +696,4 @@ public class ShowUsagesAction extends AnAction {
       return null;
     }
   }
-}
\ No newline at end of file
+}
index 646cd246e2678a069efc20475b9a1783bc62b1f7..0fda5957f06e008500de40c9f0dd1aac2242e038 100644 (file)
@@ -48,7 +48,7 @@ public abstract class GotoActionBase extends AnAction {
 
   protected abstract void gotoActionPerformed(AnActionEvent e);
 
-  public final void update(final AnActionEvent event) {
+  public void update(final AnActionEvent event) {
     final Presentation presentation = event.getPresentation();
     final DataContext dataContext = event.getDataContext();
     final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
index a0575affbbff8e6eaf1365ef39fc8a0e6ef27dfc..526f7921f6783f87ad6d1348fb7c4353d2766643 100644 (file)
@@ -59,6 +59,7 @@ import com.intellij.util.ui.UIUtil;
 import com.intellij.util.ui.tree.TreeUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import javax.swing.tree.DefaultMutableTreeNode;
@@ -457,14 +458,15 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider {
       }
     }
 
-    private PsiDirectory getDirectory() {
+    @Nullable
+    private PsiDirectory[] getSelectedDirectories() {
       if (myBuilder == null) return null;
       final Object[] selectedNodeElements = getSelectedNodeElements();
       if (selectedNodeElements.length != 1) return null;
       for (FavoriteNodeProvider nodeProvider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, myProject)) {
         final PsiElement psiElement = nodeProvider.getPsiElement(selectedNodeElements[0]);
         if (psiElement instanceof PsiDirectory) {
-          return (PsiDirectory)psiElement;
+          return new PsiDirectory[]{(PsiDirectory)psiElement};
         } else if (psiElement instanceof PsiDirectoryContainer) {
           final String moduleName = nodeProvider.getElementModuleName(selectedNodeElements[0]);
           GlobalSearchScope searchScope = GlobalSearchScope.projectScope(myProject);
@@ -474,16 +476,15 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider {
               searchScope = GlobalSearchScope.moduleScope(module);
             }
           }
-          final PsiDirectory[] directories = ((PsiDirectoryContainer)psiElement).getDirectories(searchScope);
-          if (directories.length == 1) return directories[0];
+          return ((PsiDirectoryContainer)psiElement).getDirectories(searchScope);
         }
       }
       return null;
     }
 
     public PsiDirectory[] getDirectories() {
-      PsiDirectory directory = getDirectory();
-      return directory == null ? PsiDirectory.EMPTY_ARRAY : new PsiDirectory[]{directory};
+      final PsiDirectory[] directories = getSelectedDirectories();
+      return directories == null ? PsiDirectory.EMPTY_ARRAY : directories;
     }
 
     public PsiDirectory getOrChooseDirectory() {
index 4581b24eb1253e43204ce81a26bee3476e9b9fc4..ea90cb413355afe67d01207e69f461b87d7a62d7 100644 (file)
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.Iconable;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.presentation.java.SymbolPresentationUtil;
 
-public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer {
+public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer<PsiElement> {
   protected int getIconFlags() {
     return Iconable.ICON_FLAG_VISIBILITY;
   }
@@ -33,4 +33,4 @@ public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer {
     return SymbolPresentationUtil.getSymbolContainerText(element);
   }
 
-}
\ No newline at end of file
+}
index 278cd1f1e4e2a844a20e104c1522c0e3fdccab51..893b28f93dac6ca0f25a63f2166cb743188e6c0c 100644 (file)
@@ -99,12 +99,11 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
           }
         }
 
-        SimpleTextAttributes nameAttributes;
         if (isProblemFile) {
           attributes = TextAttributes.merge(new TextAttributes(color, null, Color.red, EffectType.WAVE_UNDERSCORE, Font.PLAIN),attributes);
         }
 
-        nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes):null;
+        SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;
 
         if (nameAttributes == null)  nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);
 
index a7cecb3acf8b6cca569f3aad6c0e1f5d73ca3d14..134eb1c6b5b1593d59d6d8f43e93be4f36a16792 100644 (file)
@@ -65,11 +65,11 @@ public class RangeMarkerWindow implements RangeMarkerEx {
     myHostMarker.setGreedyToRight(greedy);
   }
 
-  public <T> T getUserData(final Key<T> key) {
+  public <T> T getUserData(@NotNull final Key<T> key) {
     return myHostMarker.getUserData(key);
   }
 
-  public <T> void putUserData(final Key<T> key, final T value) {
+  public <T> void putUserData(@NotNull final Key<T> key, final T value) {
     myHostMarker.putUserData(key, value);
   }
 
@@ -91,4 +91,4 @@ public class RangeMarkerWindow implements RangeMarkerEx {
   public boolean isGreedyToLeft() {
     return myHostMarker.isGreedyToLeft();
   }
-}
\ No newline at end of file
+}
index 65ea995863cb413bf61f0190f887e7e10b703444..5458638bce6b7758654c2c23b0a9dab1fba1ab0a 100644 (file)
@@ -145,11 +145,11 @@ public class MockPsiManager extends PsiManagerEx {
   public void finishBatchFilesProcessingMode() {
   }
 
-  public <T> T getUserData(Key<T> key) {
+  public <T> T getUserData(@NotNull Key<T> key) {
     return null;
   }
 
-  public <T> void putUserData(Key<T> key, T value) {
+  public <T> void putUserData(@NotNull Key<T> key, T value) {
   }
 
   public boolean isDisposed() {
@@ -250,4 +250,4 @@ public class MockPsiManager extends PsiManagerEx {
   public CacheManager getCacheManager() {
     return myCompositeCacheManager;
   }
-}
\ No newline at end of file
+}
index c7117d616122fcb140a3f23a2e6ac2be0461f49d..1b1cf675cf1d8d28ad7038691dd8167db8a23664 100644 (file)
 package com.intellij.openapi.editor.actions;
 
 import com.intellij.codeInsight.editorActions.SelectWordUtil;
+import com.intellij.codeInsight.highlighting.BraceMatchingUtil;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.editor.*;
 import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
-import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.editor.ex.EditorEx;
+import com.intellij.openapi.editor.highlighter.HighlighterIterator;
 import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.text.CharArrayUtil;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -111,7 +116,23 @@ public class SelectWordAtCaretAction extends TextComponentEditorAction implement
     private static void selectWithGuide(Editor editor, IndentGuideDescriptor guide) {
       final Document doc = editor.getDocument();
       int startOffset = editor.logicalPositionToOffset(new LogicalPosition(guide.startLine, 0));
-      int endOffset = Math.min(editor.logicalPositionToOffset(new LogicalPosition(guide.endLine + 1, 0)), doc.getTextLength());
+      int endOffset = Math.min(doc.getLineStartOffset(guide.endLine), doc.getTextLength());
+
+      final VirtualFile file = ((EditorEx)editor).getVirtualFile();
+      if (file != null) {
+        // Make sure selection contains closing matching brace.
+
+        final CharSequence chars = doc.getCharsSequence();
+        int nonWhitespaceOffset = CharArrayUtil.shiftForward(chars, endOffset, " \t\n");
+        HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(nonWhitespaceOffset);
+        if (BraceMatchingUtil.isRBraceToken(iterator, chars, file.getFileType())) {
+          if (((EditorEx)editor).calcColumnNumber(iterator.getStart(), doc.getLineNumber(iterator.getStart())) == guide.indentLevel) {
+            endOffset = iterator.getEnd();
+            endOffset = CharArrayUtil.shiftForward(chars, endOffset, " \t");
+            if (endOffset < chars.length() && chars.charAt(endOffset) == '\n') endOffset++;
+          }
+        }
+      }
 
       editor.getSelectionModel().setSelection(startOffset, endOffset);
     }
index 92719e340b4ac92d96cc1bd094122efafc1dcb5b..38ac34eddc50b9e533c975644773fcd0d99ece88 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
 import com.intellij.openapi.progress.ProgressManager;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.TextRange;
@@ -54,8 +55,9 @@ import javax.swing.*;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
+import java.util.Map;
 
-public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
+public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.PsiDirectoryImpl");
 
   private final PsiManagerImpl myManager;
@@ -563,5 +565,9 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
   protected Icon getElementIcon(final int flags) {
     return Icons.DIRECTORY_CLOSED_ICON;
   }
+
+  public void putInfo(Map<String, String> info) {
+    info.put("fileName", getName());
+  }
 }
 
index 1b536cff5fb67dfcc232209faaff87acdc3039a5..ca5790dbb3e1cfbf168797008ea365364dfe2377 100644 (file)
@@ -31,6 +31,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.vcs.FileStatus;
@@ -64,12 +65,9 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.lang.ref.Reference;
 import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
-public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiFileWithStubSupport {
+public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiFileWithStubSupport, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiFileImpl");
 
   private IElementType myElementType;
@@ -936,4 +934,13 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
       FileBasedIndex.getInstance().requestReindex(vFile);
     }
   }
+
+  public void putInfo(Map<String, String> info) {
+    putInfo(this, info);
+  }
+
+  public static void putInfo(PsiFile psiFile, Map<String, String> info) {
+    info.put("fileName", psiFile.getName());
+    info.put("fileType", psiFile.getFileType().toString());
+  }
 }
index 31b845def30a2356fbf42d00a0e2db890a4c7e84..c1670b02592f76c96c347ff1beac376910116e7f 100644 (file)
@@ -127,6 +127,7 @@ public class PsiMultiReference implements PsiPolyVariantReference {
     return false;
   }
 
+  @NotNull
   public Object[] getVariants() {
     Set<Object> variants = new HashSet<Object>();
     for(PsiReference ref: myReferences) {
index 4d63cd56127832a4ed76fb4d44c8875240af4c5e..b4de601a0a3fd9b684f4d420b63670347339bea4 100644 (file)
@@ -35,6 +35,8 @@ public class FileReferenceCharFilter extends CharFilter{
 
     final LookupElement item = lookup.getCurrentItem();
     if (item != null && item.getObject() instanceof PsiFileSystemItem) {
+      if ('.' == c) return Result.ADD_TO_PREFIX;
+
       final PsiReference reference = file.findReferenceAt(lookup.getEditor().getCaretModel().getOffset());
       if (reference instanceof FileReference) return Result.HIDE_LOOKUP;
 
index 7994f5961fa16d8ce40ea90da2aa29d94ed5b0cc..2f4dc002f43f49fe5a6485ea27801f170bf31593 100644 (file)
@@ -18,7 +18,7 @@ package com.intellij.history.integration.patches;
 
 import com.intellij.history.integration.IdeaGateway;
 import com.intellij.openapi.diff.impl.patch.FilePatch;
-import com.intellij.openapi.diff.impl.patch.PatchBuilder;
+import com.intellij.openapi.diff.impl.patch.TextPatchBuilder;
 import com.intellij.openapi.diff.impl.patch.UnifiedDiffWriter;
 import com.intellij.openapi.vcs.VcsException;
 import com.intellij.openapi.vcs.changes.Change;
@@ -35,7 +35,7 @@ public class PatchCreator {
     throws IOException, VcsException {
     Writer writer = new OutputStreamWriter(new FileOutputStream(filePath));
     try {
-      List<FilePatch> patches = PatchBuilder.buildPatch(changes, gw.getBaseDir(), false, isReverse);
+      List<FilePatch> patches = TextPatchBuilder.buildPatch(changes, gw.getBaseDir(), isReverse);
       String lineSeparator = CodeStyleSettingsManager.getInstance(gw.getProject()).getCurrentSettings().getLineSeparator();
       UnifiedDiffWriter.write(patches, writer, lineSeparator);
     }
index 6d89eb3df8856e83f3398de1d7affd37e263c83e..a36384218eb1fe98cc7fc54841af14f68ca3c8f3 100644 (file)
 
 package com.intellij.historyIntegrTests;
 
+import com.intellij.openapi.diff.impl.patch.BinaryFilePatch;
 import com.intellij.openapi.diff.impl.patch.FilePatch;
 import com.intellij.openapi.diff.impl.patch.PatchReader;
+import com.intellij.openapi.diff.impl.patch.PatchVirtualFileReader;
 import com.intellij.openapi.diff.impl.patch.formove.PatchApplier;
 import com.intellij.openapi.vfs.VirtualFile;
 
@@ -44,7 +46,7 @@ public abstract class PatchingTestCase extends IntegrationTestCase {
 
   protected void applyPatch() throws Exception {
     List<FilePatch> patches = new ArrayList<FilePatch>();
-    PatchReader reader = new PatchReader(getFS().refreshAndFindFileByPath(patchFilePath));
+    PatchReader reader = PatchVirtualFileReader.create(getFS().refreshAndFindFileByPath(patchFilePath));
 
     while (true) {
       FilePatch p = reader.readNextPatch();
@@ -52,6 +54,6 @@ public abstract class PatchingTestCase extends IntegrationTestCase {
       patches.add(p);
     }
 
-    new PatchApplier(myProject, root, patches, null, null).execute();
+    new PatchApplier<BinaryFilePatch>(myProject, root, patches, null, null).execute();
   }
 }
index bdc7a7dfd412f01c5ba34be7442796368b806e5d..8668e4d292a74b3087c990c3e7e1c12523ceae2a 100644 (file)
@@ -91,18 +91,19 @@ public class OSProcessHandler extends ProcessHandler {
 
     public ProcessWaitFor(final Process process) {
       myWaitSemaphore.down();
-      final Runnable action = new Runnable() {
+
+      myWaitForThreadFuture = executeOnPooledThread(new Runnable() {
         public void run() {
           try {
             myExitCode = process.waitFor();
           }
           catch (InterruptedException ignored) {
           }
-          myWaitSemaphore.up();
+          finally {
+            myWaitSemaphore.up();
+          }
         }
-      };
-
-      myWaitForThreadFuture = executeOnPooledThread(action);
+      });
     }
 
     public int waitFor() {
index d18ed42417c6d85c470030dd7d6264dba1206fdd..45a7a5324bf001ef1f5bd81db5b68ced4e6e06aa 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.colors.CodeInsightColors;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.openapi.ide.CopyPasteManager;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.vcs.FileStatus;
 import org.jetbrains.annotations.NonNls;
@@ -29,8 +30,9 @@ import org.jetbrains.annotations.Nullable;
 
 import java.awt.*;
 import java.util.Collection;
+import java.util.Map;
 
-public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor implements NavigationItem {
+public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor implements NavigationItem, Queryable.Contributor {
   private AbstractTreeNode myParent;
   private T myValue;
   private NodeDescriptor myParentDescriptor;
@@ -140,6 +142,23 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor impl
     myValue = value;
   }
 
+  @Nullable
+  public String toTestString(Queryable.PrintInfo printInfo) {
+    if (getValue() instanceof Queryable) {
+      String text = Queryable.Util.print((Queryable)getValue(), printInfo, this);
+      if (text != null) return text;
+    }
+
+    return getTestPresentation();
+  }
+
+  public void apply(Map<String, String> info) {
+  }
+
+  /**
+   * @deprecated use toTestString
+   * @return
+   */
   @Nullable
   @NonNls public String getTestPresentation() {
     if (myName != null) {
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Queryable.java b/platform/platform-api/src/com/intellij/openapi/ui/Queryable.java
new file mode 100644 (file)
index 0000000..93b5c85
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2000-2009 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.ui;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public interface Queryable {
+
+  void putInfo(Map<String, String> info);
+
+  static class PrintInfo {
+    String[] myIdKeys;
+    String[] myInfoKeys;
+
+    public PrintInfo() {
+      this(null, null);
+    }
+
+    public PrintInfo(@Nullable String[] idKeys) {
+      this(idKeys, null);
+    }
+
+    public PrintInfo(@Nullable String[] idKeys, @Nullable String[] infoKeys) {
+      myIdKeys = idKeys;
+      myInfoKeys = infoKeys;
+    }
+  }
+
+  static class Util {
+    @Nullable
+    public static String print(@NotNull Queryable ui, @Nullable PrintInfo printInfo, @Nullable Contributor contributor) {
+      PrintInfo print = printInfo != null ? printInfo : new PrintInfo();
+
+      LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
+      ui.putInfo(map);
+
+      if (contributor != null) {
+        contributor.apply(map);
+      }
+
+      String id = null;
+
+      String[] names = print.myIdKeys != null ? print.myIdKeys : new String[] {"name"};
+      for (String eachKey : names) {
+        String eachValue = map.get(eachKey);
+        if (eachValue != null) {
+          id = eachValue;
+        }
+      }
+
+      if (map.size() > 0) {
+        id = map.values().iterator().next();
+      }
+
+      StringBuffer info = new StringBuffer();
+      if (print.myInfoKeys != null) {
+        for (String eachKey : print.myInfoKeys) {
+          String eachValue = map.get(eachKey);
+          if (eachValue != null) {
+            if (info.length() > 0) {
+              info.append(",");
+            }
+            info.append(eachKey).append("=").append(eachValue);
+          }
+        }
+      }
+
+      return id + (info.length() > 0 ? " " + info.toString() : "");
+    }
+
+    @Nullable
+    public static String print(@NotNull Queryable ui, @Nullable PrintInfo printInfo) {
+      return print(ui, printInfo, null);
+    }
+  }
+
+  interface Contributor {
+    void apply(Map<String, String> info);
+  }
+
+}
\ No newline at end of file
index 7081c5fa1beb3735a626cab06a772379ce9d89ce..6f6db5543ffde0f1755aba8d47c4804ee4d2182f 100644 (file)
@@ -19,8 +19,8 @@ import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.util.concurrency.Semaphore;
 
-import java.util.concurrent.Future;
 import java.io.IOException;
+import java.util.concurrent.Future;
 
 public class ProcessCloseUtil {
   private static final long ourSynchronousWaitTimeout = 1000;
@@ -34,25 +34,32 @@ public class ProcessCloseUtil {
     outerSemaphore.down();
 
     final Application application = ApplicationManager.getApplication();
-    final Future<?> future = application.executeOnPooledThread(new Runnable() {
+    application.executeOnPooledThread(new Runnable() {
       public void run() {
-        final Semaphore semaphore = new Semaphore();
-        semaphore.down();
+        try {
+          final Semaphore semaphore = new Semaphore();
+          semaphore.down();
 
-        final Runnable closeRunnable = new Runnable() {
-          public void run() {
-            closeProcessImpl(process);
-            semaphore.up();
-          }
-        };
+          final Runnable closeRunnable = new Runnable() {
+            public void run() {
+              try {
+                closeProcessImpl(process);
+              }
+              finally {
+                semaphore.up();
+              }
+            }
+          };
 
-        final Future<?> innerFuture = application.executeOnPooledThread(closeRunnable);
-        semaphore.waitFor(ourAsynchronousWaitTimeout);
-        if ( ! (innerFuture.isDone() || innerFuture.isCancelled())) {
-          innerFuture.cancel(true); // will call interrupt()
+          final Future<?> innerFuture = application.executeOnPooledThread(closeRunnable);
+          semaphore.waitFor(ourAsynchronousWaitTimeout);
+          if ( ! (innerFuture.isDone() || innerFuture.isCancelled())) {
+            innerFuture.cancel(true); // will call interrupt()
+          }
+        }
+        finally {
+          outerSemaphore.up();
         }
-
-        outerSemaphore.up();
       }
     });
 
index 39a680408f58582136b8995d23362e5c93b09e8b..63eeb5c503034bb3a0ed144ae1515ce0d5d0f028 100644 (file)
@@ -16,7 +16,7 @@
 package com.intellij.ui.tabs;
 
 import com.intellij.openapi.actionSystem.ActionGroup;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.ui.SimpleColoredText;
 import com.intellij.ui.SimpleTextAttributes;
@@ -29,7 +29,7 @@ import java.beans.PropertyChangeSupport;
 import java.lang.ref.WeakReference;
 import java.util.Map;
 
-public final class TabInfo implements TestableUi {
+public final class TabInfo implements Queryable {
 
   public static final String ACTION_GROUP = "actionGroup";
   public static final String ICON = "icon";
@@ -80,7 +80,7 @@ public final class TabInfo implements TestableUi {
   private boolean myEnabled = true;
   private Color myTabColor = null;
 
-  private TestableUi myTestableUi;
+  private Queryable myQueryable;
 
   public TabInfo(final JComponent component) {
     myComponent = component;
@@ -343,14 +343,14 @@ public final class TabInfo implements TestableUi {
     return myTabColor;
   }
 
-  public TabInfo setTestableUi(TestableUi testableUi) {
-    myTestableUi = testableUi;
+  public TabInfo setTestableUi(Queryable queryable) {
+    myQueryable = queryable;
     return this;
   }
 
   public void putInfo(Map<String, String> info) {
-    if (myTestableUi != null) {
-      myTestableUi.putInfo(info);
+    if (myQueryable != null) {
+      myQueryable.putInfo(info);
     }
   }
 }
index 85054ea3447e5a72344ad8db3e222e246d9ce181..c5ab2124993296528fb3f267f8410c6bc728ec51 100644 (file)
@@ -19,8 +19,8 @@ import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.ui.ShadowAction;
-import com.intellij.openapi.ui.TestableUi;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.wm.FocusCommand;
@@ -56,7 +56,7 @@ import java.util.*;
 import java.util.List;
 
 public class JBTabsImpl extends JComponent
-  implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, TestableUi {
+  implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable {
 
   static DataKey<JBTabsImpl> NAVIGATION_ACTIONS_KEY = DataKey.create("JBTabs");
 
index 4af5395f6b23605e1f6911fc9dc8bcf77f3a9f72..8145957398b3d29e96eaf55a5cd48078fd882072 100644 (file)
@@ -17,7 +17,7 @@ package com.intellij.ui.treeStructure;
 
 import com.intellij.Patches;
 import com.intellij.ide.util.treeView.*;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.wm.impl.content.GraphicsConfig;
@@ -40,7 +40,7 @@ import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Map;
 
-public class Tree extends JTree implements Autoscroll, TestableUi {
+public class Tree extends JTree implements Autoscroll, Queryable {
 
   private AsyncProcessIcon myBusyIcon;
   private boolean myBusy;
index a40134fee4f7917037c84ec7635ee4d9126a660e..a09c07867f41274c93a011d48c47dc57b7434c5d 100644 (file)
@@ -25,7 +25,12 @@ import javax.swing.*;
  * @since 5.1
  */
 public class DialogUtil {
+
   public static void registerMnemonic(AbstractButton button) {
+    registerMnemonic(button, UIUtil.MNEMONIC);
+  }
+
+  public static void registerMnemonic(AbstractButton button, char mn) {
     String text = button.getText();
 
     if (text != null) {
@@ -34,7 +39,7 @@ public class DialogUtil {
       int index = -1;
       for (int i = 0; i < text.length(); i++) {
         char ch = text.charAt(i);
-        if (ch != UIUtil.MNEMONIC) {
+        if (ch != mn) {
           realText.append(ch);
         }
         else if (i + 1 < text.length()) {
index f1b84baca9c1d2af72e6e35bafaf7b097229b4af..a3fd2f94eb6a459e5fc47901b0a03d08f68def58 100644 (file)
@@ -28,7 +28,7 @@ import java.awt.*;
 
 public abstract class OptionsDialog extends DialogWrapper {
 
-  private JCheckBox myCheckBoxDoNotShowDialog;
+  protected JCheckBox myCheckBoxDoNotShowDialog;
 
   protected String getDoNotShowMessage() {
     return CommonBundle.message("dialog.options.do.not.show");
@@ -68,6 +68,7 @@ public abstract class OptionsDialog extends DialogWrapper {
 
     final JPanel panel = addDoNotShowCheckBox(southPanel, myCheckBoxDoNotShowDialog);
     myCheckBoxDoNotShowDialog.setSelected(!isToBeShown());
+    DialogUtil.registerMnemonic(myCheckBoxDoNotShowDialog, '&');
     return panel;
   }
 
index 25c33c45aa490536ce25925c5e5109964ca55e35..dc2c2643658fa73a8ad74cb89b19f4340f298518 100644 (file)
@@ -31,7 +31,7 @@ public class DocumentReferenceByVirtualFile implements DocumentReference {
 
   @Nullable
   public Document getDocument() {
-    assert myFile.isValid() : "should not be called on references to deleted files";
+    assert myFile.isValid() : "should not be called on references to deleted file: " + myFile;
     return FileDocumentManager.getInstance().getDocument(myFile);
   }
 
index e6c07a9ca7adbc70a1202858927d062e4a201f52..5a7076f1913fafb591cd956f688e9c894d9bbc0f 100644 (file)
@@ -21,7 +21,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.impl.ApplicationImpl;
 import com.intellij.openapi.editor.ex.util.EditorUtil;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.ui.TypingTarget;
 import com.intellij.openapi.util.ActionCallback;
 
@@ -35,7 +35,7 @@ import java.util.Map;
 /**
  *
  */
-public class EditorComponentImpl extends JComponent implements Scrollable, DataProvider, TestableUi, TypingTarget {
+public class EditorComponentImpl extends JComponent implements Scrollable, DataProvider, Queryable, TypingTarget {
   private final EditorImpl myEditor;
 
   public EditorComponentImpl(EditorImpl editor) {
index 66ae17517bafc7c01dcf45a059cad220048abfbb..aae9bffc60939774ccd0a2ae1882e771254c2cfe 100644 (file)
@@ -53,7 +53,7 @@ import com.intellij.openapi.editor.markup.*;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -101,7 +101,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
-public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, TestableUi {
+public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, Queryable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorImpl");
   private static final Key DND_COMMAND_KEY = Key.create("DndCommand");
   public static final Key<Boolean> DO_DOCUMENT_UPDATE_TEST = Key.create("DoDocumentUpdateTest");
index 907486af825e1504c710b072794cba71323e3921..eb86a65e1c29e9d4073ad86c247bf054a161cba0 100644 (file)
@@ -54,11 +54,11 @@ public class EmptyMarkupModel implements MarkupModelEx {
     return RangeHighlighter.EMPTY_ARRAY;
   }
 
-  public <T> T getUserData(Key<T> key) {
+  public <T> T getUserData(@NotNull Key<T> key) {
     return null;
   }
 
-  public <T> void putUserData(Key<T> key, T value) {
+  public <T> void putUserData(@NotNull Key<T> key, T value) {
   }
 
   public void dispose() {
index ddfa1218e4c367da34cff78d8a2f34fc1c7ab0d5..59527d4d3734d37d58fb2025b7c17b3af6c20e47 100644 (file)
@@ -19,8 +19,9 @@
  */
 package com.intellij.openapi.editor.impl;
 
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.*;
+import com.intellij.openapi.editor.IndentGuideDescriptor;
+import com.intellij.openapi.editor.IndentsModel;
+import com.intellij.openapi.editor.LogicalPosition;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -37,9 +38,12 @@ public class IndentsModelImpl implements IndentsModel {
     final LogicalPosition pos = myEditor.getCaretModel().getLogicalPosition();
     final int column = pos.column;
     final int line = pos.line;
-    for (IndentGuideDescriptor indent : myIndents) {
-      if (column == indent.indentLevel && line >= indent.startLine && line < indent.endLine) {
-        return indent;
+
+    if (column > 0) {
+      for (IndentGuideDescriptor indent : myIndents) {
+        if (column == indent.indentLevel && line >= indent.startLine && line < indent.endLine) {
+          return indent;
+        }
       }
     }
     return null;
index 4ba35866079a693727cae3bb89e6b04078c43e2f..b801faaf87a399dd8561ec8916ca2fdbb173379d 100644 (file)
@@ -29,7 +29,7 @@ import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.ShadowAction;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.IdeFocusManager;
@@ -222,7 +222,7 @@ final class EditorTabbedContainer implements Disposable {
     if (tab != null) return;
 
     tab = new TabInfo(comp).setText(calcTabTitle(myProject, file)).setIcon(icon).setTooltipText(tooltip).setObject(file).setTabColor(calcTabColor(myProject, file));
-    tab.setTestableUi(new MyTestableUi(tab));
+    tab.setTestableUi(new MyQueryable(tab));
 
     final DefaultActionGroup tabActions = new DefaultActionGroup();
     tabActions.add(new CloseTab(comp, tab));
@@ -231,11 +231,11 @@ final class EditorTabbedContainer implements Disposable {
     myTabs.addTab(tab, indexToInsert);
   }
 
-  private class MyTestableUi implements TestableUi {
+  private class MyQueryable implements Queryable {
 
     private TabInfo myTab;
 
-    public MyTestableUi(TabInfo tab) {
+    public MyQueryable(TabInfo tab) {
       myTab = tab;
     }
 
index 7b22b3b1e736e0467f2fdceed9cf87665a34d7df..950d6ea57978f2a71efdddb2ef67173758491cb3 100644 (file)
@@ -142,8 +142,12 @@ public class SmoothProgressAdapter extends BlockingProgressIndicator {
       }
     );
 
-    super.stop(); // should be last to not leaveModal before closing the dialog
-    semaphore.up();
+    try {
+      super.stop(); // should be last to not leaveModal before closing the dialog
+    }
+    finally {
+      semaphore.up();
+    }
   }
 
   public synchronized void setText(String text) {
index 4e4a68361ce17031df443ec52176e815ac248333..24005c0169ecb27874564b91bb276a2a0531bee1 100644 (file)
@@ -227,10 +227,10 @@ public class DumbServiceImpl extends DumbService {
     final Semaphore semaphore = new Semaphore();
     semaphore.down();
     runWhenSmart(new Runnable() {
-          public void run() {
-            semaphore.up();
-          }
-        });
+      public void run() {
+        semaphore.up();
+      }
+    });
     semaphore.waitFor();
   }
 
index c6355f45387789e9dc6f96fe858d21a9cc5c6a4a..ba030419efd73313b1eba09c34264a81da6310a6 100644 (file)
@@ -32,7 +32,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.DialogWrapperDialog;
 import com.intellij.openapi.ui.DialogWrapperPeer;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.ui.popup.StackingPopupDispatcher;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.registry.Registry;
@@ -458,7 +458,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
   }
 
 
-  private static class MyDialog extends JDialog implements DialogWrapperDialog, DataProvider, FocusTrackback.Provider, TestableUi {
+  private static class MyDialog extends JDialog implements DialogWrapperDialog, DataProvider, FocusTrackback.Provider, Queryable {
     private final WeakReference<DialogWrapper> myDialogWrapper;
     /**
      * Initial size of the dialog. When the dialog is being closed and
index f146d4a4dc77448a81c6dff6d80086f69ac2b38c..22c60e3f2eade38a08b08e53714cb08bb6ebd9e1 100644 (file)
@@ -15,7 +15,7 @@
  */
 package com.intellij.openapi.ui.playback.commands;
 
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.ui.playback.PlaybackRunner;
 import com.intellij.openapi.util.ActionCallback;
 import com.intellij.openapi.wm.IdeFocusManager;
@@ -77,8 +77,8 @@ public class AssertFocused extends AbstractCommand {
     Component eachParent = owner;
     final LinkedHashMap<String, String> actual = new LinkedHashMap<String, String>();
     while (eachParent != null) {
-      if (eachParent instanceof TestableUi) {
-        ((TestableUi)eachParent).putInfo(actual);
+      if (eachParent instanceof Queryable) {
+        ((Queryable)eachParent).putInfo(actual);
       }
 
       eachParent = eachParent.getParent();
index 697ce7a7cc9b1bf304ae14b6fffd735822424d51..85a52d461d70064afe9877d42251a4f179e3a9d7 100644 (file)
@@ -152,7 +152,7 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
     myLastUpdated = fsModCount;
 
     if (myFile == null) {
-      LOG.assertTrue(myUrl != null);
+      LOG.assertTrue(myUrl != null, "Both file & url are null");
       myFile = myVirtualFileManager.findFileByUrl(myUrl);
       if (myFile != null) {
         myUrl = null;
index 6e07ab8b7eaca46eb98108891ddf85df0101c03c..200c4aef79ff570d826c1b967956350fe72c83a4 100644 (file)
@@ -28,7 +28,7 @@ import com.intellij.openapi.keymap.ex.KeymapManagerEx;
 import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.TestableUi;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.util.SystemInfo;
@@ -59,7 +59,7 @@ import java.util.Map;
  * @author Eugene Belyaev
  * @author Vladimir Kondratyev
  */
-public final class InternalDecorator extends JPanel implements TestableUi, TypeSafeDataProvider {
+public final class InternalDecorator extends JPanel implements Queryable, TypeSafeDataProvider {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.InternalDecorator");
 
   private static final int DIVIDER_WIDTH = 5;
index 98b39a2de6cf571a67850bb00a752d27b771e1a2..0b04b7fe2ad722f8a199d166789e5ed471c991c1 100644 (file)
                                         implementationClass="com.intellij.codeInsight.hint.XmlImplementationTextSelectioner"/>
     <basicWordSelectionFilter implementation="com.intellij.codeInsight.editorActions.XmlBasicWordSelectionFilter"/>
     <defaultLiveTemplatesProvider implementation="com.intellij.codeInsight.template.XmlDefaultLiveTemplatesProvider"/>
-    <customLiveTemplate implementation="com.intellij.codeInsight.template.XmlZenCodingTemplate"/>
+    <customLiveTemplate implementation="com.intellij.codeInsight.template.zencoding.XmlZenCodingTemplate"/>
     <productivityFeaturesProvider implementation="com.intellij.featureStatistics.XmlProductivityFeatureProvider"/>
 
     <idIndexer filetype="XML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer"/>
index 6eee48594df80551e504009e43a384531dd008d5..07ff7eb4db5074ccb2fb234a85127d2dbecb35c3 100644 (file)
@@ -156,12 +156,12 @@ public class MockDocument implements DocumentEx {
   }
 
   @SuppressWarnings({"unchecked"})
-  public <T> T getUserData(Key<T> key) {
+  public <T> T getUserData(@NotNull Key<T> key) {
     return (T)myUserData.get(key);
   }
 
   @SuppressWarnings({"unchecked"})
-  public <T> void putUserData(Key<T> key, T value) {
+  public <T> void putUserData(@NotNull Key<T> key, T value) {
     myUserData.put(key, value);
   }
 
diff --git a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
new file mode 100644 (file)
index 0000000..64d6170
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.testFramework;
+
+import com.intellij.ide.DataManager;
+import com.intellij.openapi.actionSystem.IdeActions;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
+import com.intellij.openapi.editor.actionSystem.EditorActionManager;
+import com.intellij.openapi.editor.actionSystem.TypedAction;
+
+/**
+ * User: Maxim.Mossienko
+ * Date: 15.03.2010
+ * Time: 21:00:49
+ */
+public class EditorTestUtil {
+  public static final char BACKSPACE_FAKE_CHAR = '\uFFFF';
+  public static final char SMART_ENTER_FAKE_CHAR = '\uFFFE';
+
+  public static void performTypingAction(Editor editor, char c) {
+    EditorActionManager actionManager = EditorActionManager.getInstance();
+    if (c == BACKSPACE_FAKE_CHAR) {
+      EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
+      actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+    } else if (c == SMART_ENTER_FAKE_CHAR) {
+      EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT);
+      actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+    }
+    else if (c == '\n') {
+      EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
+      actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+    }
+    else {
+      TypedAction action = actionManager.getTypedAction();
+      action.actionPerformed(editor, c, DataManager.getInstance().getDataContext());
+    }
+  }
+}
index 3ec6a5aa7281f472521687c0dcec3097286a5a6a..44f9263ad9c74ffb1221a25bb19dca2d750c6452 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.openapi.extensions.ExtensionPoint;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.extensions.ExtensionsArea;
+import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Disposer;
@@ -64,9 +65,13 @@ public class PlatformTestUtil {
     });
   }
 
-  protected static String toString(Object node) {
+  protected static String toString(Object node, Queryable.PrintInfo printInfo) {
     if (node instanceof AbstractTreeNode) {
-      return ((AbstractTreeNode)node).getTestPresentation();
+      if (printInfo != null) {
+        return ((AbstractTreeNode)node).toTestString(printInfo);
+      } else {
+        return ((AbstractTreeNode)node).getTestPresentation();
+      }
     }
     else if (node == null) {
       return "NULL";
@@ -95,7 +100,7 @@ public class PlatformTestUtil {
     final Object userObject = defaultMutableTreeNode.getUserObject();
     String nodeText;
     if (userObject != null) {
-      nodeText = toString(userObject);
+      nodeText = toString(userObject, null);
     }
     else {
       nodeText = defaultMutableTreeNode + "";
@@ -207,14 +212,34 @@ public class PlatformTestUtil {
     return Comparing.equal(who, SystemProperties.getUserName(), false);
   }
 
+  /**
+   * @deprecated use {@link #print(AbstractTreeStructure structure,
+                                   Object node,
+                                   int currentLevel,
+                                   Comparator comparator,
+                                   int maxRowCount,
+                                   char paddingChar,
+                                   String[] dumpNames)}
+   */
   public static StringBuffer print(AbstractTreeStructure structure,
                                    Object node,
                                    int currentLevel,
                                    Comparator comparator,
                                    int maxRowCount,
                                    char paddingChar) {
+
+    return print(structure, node, currentLevel, comparator, maxRowCount, paddingChar, null);
+  }
+
+  public static StringBuffer print(AbstractTreeStructure structure,
+                                   Object node,
+                                   int currentLevel,
+                                   Comparator comparator,
+                                   int maxRowCount,
+                                   char paddingChar,
+                                   Queryable.PrintInfo printInfo) {
     StringBuffer buffer = new StringBuffer();
-    doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar);
+    doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar, printInfo);
     return buffer;
   }
 
@@ -226,10 +251,22 @@ public class PlatformTestUtil {
                              int maxRowCount,
                              int currentLine,
                              char paddingChar) {
+    return doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, currentLine, paddingChar, null);
+  }
+
+  private static int doPrint(StringBuffer buffer,
+                             int currentLevel,
+                             Object node,
+                             AbstractTreeStructure structure,
+                             Comparator comparator,
+                             int maxRowCount,
+                             int currentLine,
+                             char paddingChar,
+                             Queryable.PrintInfo printInfo) {
     if (currentLine >= maxRowCount && maxRowCount != -1) return currentLine;
 
     StringUtil.repeatSymbol(buffer, paddingChar, currentLevel);
-    buffer.append(toString(node)).append("\n");
+    buffer.append(toString(node, printInfo)).append("\n");
     currentLine++;
     Object[] children = structure.getChildElements(node);
 
@@ -239,7 +276,7 @@ public class PlatformTestUtil {
       children = ArrayUtil.toObjectArray(list);
     }
     for (Object child : children) {
-      currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar);
+      currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar, printInfo);
     }
 
     return currentLine;
@@ -253,7 +290,7 @@ public class PlatformTestUtil {
     StringBuilder result = new StringBuilder();
     for (Iterator iterator = c.iterator(); iterator.hasNext();) {
       Object each = iterator.next();
-      result.append(toString(each));
+      result.append(toString(each, null));
       if (iterator.hasNext()) {
         result.append("\n");
       }
@@ -265,7 +302,7 @@ public class PlatformTestUtil {
   public static String print(ListModel model) {
     StringBuilder result = new StringBuilder();
     for (int i = 0; i < model.getSize(); i++) {
-      result.append(toString(model.getElementAt(i)));
+      result.append(toString(model.getElementAt(i), null));
       result.append("\n");
     }
     return result.toString();
index cdaf24566a3edae400635f5e45ec910cf0e4fc2d..a5de4380aa788fc100ebb0d4ba3447c568fba55a 100644 (file)
@@ -49,6 +49,7 @@ public class UsageViewSettings implements PersistentStateComponent<UsageViewSett
   public boolean GROUP_BY_MODULE = true;
   public boolean GROUP_BY_PACKAGE = true;
   public boolean GROUP_BY_FILE_STRUCTURE = true;
+  public boolean GROUP_BY_SCOPE = false;
 
   public static UsageViewSettings getInstance() {
     return ServiceManager.getService(UsageViewSettings.class);
index f736b9136d6a440e3168728bf5cecbe25332c553..4bdf2de706b3f7ecffce308054f9e189a83005fb 100644 (file)
@@ -44,6 +44,9 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
   public UsageGroupingRule[] getActiveRules(Project project) {
     List<UsageGroupingRule> rules = new ArrayList<UsageGroupingRule>();
     rules.add(new NonCodeUsageGroupingRule());
+    if (UsageViewSettings.getInstance().GROUP_BY_SCOPE) {
+      rules.add(new UsageScopeGroupingRule());
+    }
     if (UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE) {
       rules.add(new UsageTypeGroupingRule());
     }
@@ -88,6 +91,7 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
       }
     });
 
+    final GroupByScopeAction groupByScopeAction = new GroupByScopeAction(impl);
     if(view.getPresentation().isCodeUsages()) {
       final GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl);
       groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component);
@@ -104,15 +108,17 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
 
       return new AnAction[] {
         groupByUsageTypeAction,
+        groupByScopeAction,
         groupByModuleTypeAction,
         groupByPackageAction,
-        groupByFileStructureAction
+        groupByFileStructureAction,
       };
     }
     else {
       return new AnAction[] {
+        groupByScopeAction,
         groupByModuleTypeAction,
-        groupByFileStructureAction
+        groupByFileStructureAction,
       };
     }
   }
@@ -129,6 +135,18 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
     }
   }
 
+  private static class GroupByScopeAction extends RuleAction {
+    private GroupByScopeAction(UsageViewImpl view) {
+      super(view, "Group by test/production", Icons.TEST_SOURCE_FOLDER);
+    }
+    protected boolean getOptionValue() {
+      return UsageViewSettings.getInstance().GROUP_BY_SCOPE;
+    }
+    protected void setOptionValue(boolean value) {
+      UsageViewSettings.getInstance().GROUP_BY_SCOPE = value;
+    }
+  }
+
   private static class GroupByModuleTypeAction extends RuleAction {
     private GroupByModuleTypeAction(UsageViewImpl view) {
       super(view, UsageViewBundle.message("action.group.by.module"), IconLoader.getIcon("/objectBrowser/showModules.png"));
diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/UsageScopeGroupingRule.java b/platform/usageView/src/com/intellij/usages/impl/rules/UsageScopeGroupingRule.java
new file mode 100644 (file)
index 0000000..77e667f
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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.usages.impl.rules;
+
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.vcs.FileStatus;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.usages.Usage;
+import com.intellij.usages.UsageGroup;
+import com.intellij.usages.UsageView;
+import com.intellij.usages.rules.PsiElementUsage;
+import com.intellij.usages.rules.UsageGroupingRule;
+import com.intellij.util.Icons;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+/**
+ * @author max
+ */
+public class UsageScopeGroupingRule implements UsageGroupingRule {
+  public UsageGroup groupUsage(Usage usage) {
+    if (!(usage instanceof PsiElementUsage)) {
+      return null;
+    }
+    PsiElementUsage elementUsage = (PsiElementUsage)usage;
+
+    PsiElement element = elementUsage.getElement();
+    VirtualFile virtualFile = PsiUtilBase.getVirtualFile(element);
+
+    if (virtualFile == null) {
+      return null;
+    }
+    boolean isInTest = ProjectRootManager.getInstance(element.getProject()).getFileIndex().isInTestSourceContent(virtualFile);
+    return isInTest ? TEST : PRODUCTION;
+  }
+
+  private static final UsageScopeGroup TEST = new UsageScopeGroup(true);
+  private static final UsageScopeGroup PRODUCTION = new UsageScopeGroup(false);
+  private static class UsageScopeGroup implements UsageGroup {
+    private final boolean isTest;
+
+    private UsageScopeGroup(boolean isTest) {
+      this.isTest = isTest;
+    }
+
+    public void update() {
+    }
+
+    public Icon getIcon(boolean isOpen) {
+      return isTest ? Icons.TEST_SOURCE_FOLDER : Icons.SOURCE_FOLDERS_ICON;
+    }
+
+    @NotNull
+    public String getText(UsageView view) {
+      return isTest ? "Test" : "Production";
+    }
+
+    public FileStatus getFileStatus() {
+      return null;
+    }
+
+    public boolean isValid() { return true; }
+    public void navigate(boolean focus) { }
+    public boolean canNavigate() { return false; }
+
+    public boolean canNavigateToSource() {
+      return false;
+    }
+
+    public int compareTo(UsageGroup usageGroup) {
+      return getText(null).compareTo(usageGroup.getText(null));
+    }
+
+    public boolean equals(Object o) {
+      if (this == o) return true;
+      if (!(o instanceof UsageScopeGroup)) return false;
+      final UsageScopeGroup usageTypeGroup = (UsageScopeGroup)o;
+      return isTest == usageTypeGroup.isTest;
+    }
+
+    public int hashCode() {
+      return isTest ? 0 : 1;
+    }
+  }
+}
index 09b96d088862e109c5ea25b162166b609fb0b328..3a720fd16a3e08f417bc627a287341723c905c87 100644 (file)
@@ -17,7 +17,7 @@ package com.intellij.usages.impl.rules;
 
 import com.intellij.usageView.UsageViewBundle;
 
-public class UsageType {
+public final class UsageType {
   public static final UsageType CLASS_INSTANCE_OF = new UsageType(UsageViewBundle.message("usage.type.instanceof"));
   public static final UsageType CLASS_IMPORT = new UsageType(UsageViewBundle.message("usage.type.import"));
   public static final UsageType CLASS_CAST_TO = new UsageType(UsageViewBundle.message("usage.type.cast.target"));
index fbd45e4e071f8e835a2e48471e9a61c877fc5e09..fba4bdf0b8780aae495656b64fd9311ca5bcefd1 100644 (file)
@@ -72,9 +72,6 @@ public class UsageTypeGroupingRule implements UsageGroupingRule {
     return null;
   }
 
-
-
-
   private class UsageTypeGroup implements UsageGroup {
     private final UsageType myUsageType;
 
diff --git a/platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java b/platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java
new file mode 100644 (file)
index 0000000..3ca09d8
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: yole
+ * Date: 15.11.2006
+ * Time: 20:20:15
+ */
+package com.intellij.openapi.diff.impl.patch;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class PatchHunk {
+  private final int myStartLineBefore;
+  private final int myEndLineBefore;
+  private final int myStartLineAfter;
+  private final int myEndLineAfter;
+  private final List<PatchLine> myLines = new ArrayList<PatchLine>();
+
+  public PatchHunk(final int startLineBefore, final int endLineBefore, final int startLineAfter, final int endLineAfter) {
+    myStartLineBefore = startLineBefore;
+    myEndLineBefore = endLineBefore;
+    myStartLineAfter = startLineAfter;
+    myEndLineAfter = endLineAfter;
+  }
+
+  public int getStartLineBefore() {
+    return myStartLineBefore;
+  }
+
+  public int getEndLineBefore() {
+    return myEndLineBefore;
+  }
+
+  public int getStartLineAfter() {
+    return myStartLineAfter;
+  }
+
+  public int getEndLineAfter() {
+    return myEndLineAfter;
+  }
+
+  public void addLine(final PatchLine line) {
+    myLines.add(line);
+  }
+
+  public List<PatchLine> getLines() {
+    return Collections.unmodifiableList(myLines);
+  }
+
+  public boolean isNewContent() {
+    return myStartLineBefore == -1 && myEndLineBefore == -1;
+  }
+
+  public boolean isDeletedContent() {
+    return myStartLineAfter == -1 && myEndLineAfter == -1;
+  }
+
+  public String getText() {
+    StringBuilder builder = new StringBuilder();
+    for(PatchLine line: myLines) {
+      builder.append(line.getText()).append("\n");
+    }
+    return builder.toString();
+  }
+
+  public boolean isNoNewLineAtEnd() {
+    if (myLines.size() == 0) {
+      return false;
+    }
+    return myLines.get(myLines.size()-1).isSuppressNewLine();
+  }
+}
index b2acd934eed13019ab415d93f59c0627661dfd86..056dee0267ff96b19cf64545cfc3196bb8278052 100644 (file)
@@ -70,12 +70,12 @@ public class UserDataHolderBase implements UserDataHolderEx, Cloneable {
     }
   }
 
-  public <T> T getUserData(Key<T> key) {
+  public <T> T getUserData(@NotNull Key<T> key) {
     final Map<Key, Object> map = myUserMap;
     return map == null ? null : (T)map.get(key);
   }
 
-  public <T> void putUserData(Key<T> key, T value) {
+  public <T> void putUserData(@NotNull Key<T> key, T value) {
     Map<Key, Object> map = getOrCreateMap();
 
     if (value == null) {
index a70d4b8ab392df24c6a693b7ded64e3df9a041c3..84fdb70b15815e87f3d9038438a3d8993ec66445 100644 (file)
@@ -42,10 +42,8 @@ import java.awt.*;
 import java.awt.event.*;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.regex.Pattern;
@@ -1064,5 +1062,28 @@ public class UIUtil {
     return g instanceof PrintGraphics;
   }
 
+  public static int getSelectedButton(ButtonGroup group) {
+    Enumeration<AbstractButton> enumeration = group.getElements();
+    int i = 0;
+    while (enumeration.hasMoreElements()) {
+      AbstractButton button = enumeration.nextElement();
+      if (group.isSelected(button.getModel())) {
+        return i;
+      }
+      i++;
+    }
+    return -1;
+  }
+
+  public static void setSelectedButton(ButtonGroup group, int index) {
+    Enumeration<AbstractButton> enumeration = group.getElements();
+    int i = 0;
+    while (enumeration.hasMoreElements()) {
+      AbstractButton button = enumeration.nextElement();
+      group.setSelected(button.getModel(), index == i);
+      i++;
+    }
+  }
+
 }
 
index e71a26bc4225c708e057a86742284824b7d85ce7..d8be62de91eaab8eb7eafd7f4e6f89da16fef6a1 100644 (file)
@@ -238,7 +238,6 @@ public class Assertion extends Assert {
   public void size(int size, Collection collection) {
     if (collection.size() != size) {
       System.err.println("Expected: " + size + " actual: " + collection.size());
-      compareUnordered(ArrayUtil.EMPTY_OBJECT_ARRAY, collection);
     }
     Assert.assertEquals(size, collection.size());
   }
similarity index 72%
rename from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/BinaryFilePatch.java
rename to platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/BinaryFilePatch.java
index 31ee275760f84495dd53d6db1bbe569075aa526e..6fe7ff86f336191b1d4579d8c765e0d776bcbc52 100644 (file)
  */
 package com.intellij.openapi.diff.impl.patch;
 
-import com.intellij.openapi.vfs.VirtualFile;
-
-import java.io.IOException;
-
 /**
  * @author yole
  */
@@ -31,15 +27,6 @@ public class BinaryFilePatch extends FilePatch {
     myAfterContent = afterContent;
   }
 
-  protected void applyCreate(final VirtualFile newFile) throws IOException, ApplyPatchException {
-    newFile.setBinaryContent(myAfterContent);
-  }
-
-  protected ApplyPatchStatus applyChange(final VirtualFile fileToPatch) throws IOException, ApplyPatchException {
-    fileToPatch.setBinaryContent(myAfterContent);
-    return ApplyPatchStatus.SUCCESS;
-  }
-
   public boolean isNewFile() {
     return myBeforeContent == null;
   }
@@ -47,4 +34,8 @@ public class BinaryFilePatch extends FilePatch {
   public boolean isDeletedFile() {
     return myAfterContent == null;
   }
+
+  public byte[] getAfterContent() {
+    return myAfterContent;
+  }
 }
diff --git a/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/FilePatch.java b/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/FilePatch.java
new file mode 100644 (file)
index 0000000..b1f8fb3
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2000-2009 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.
+ */
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: yole
+ * Date: 15.11.2006
+ * Time: 17:53:24
+ */
+package com.intellij.openapi.diff.impl.patch;
+
+import com.intellij.openapi.util.text.StringUtil;
+
+public abstract class FilePatch {
+  private String myBeforeName;
+  private String myAfterName;
+  private String myBeforeVersionId;
+  private String myAfterVersionId;
+
+  public String getBeforeName() {
+    return myBeforeName;
+  }
+
+  public String getAfterName() {
+    return myAfterName;
+  }
+
+  public String getBeforeFileName() {
+    String[] pathNameComponents = myBeforeName.split("/");
+    return pathNameComponents [pathNameComponents.length-1];
+  }
+
+  public String getAfterFileName() {
+    String[] pathNameComponents = myAfterName.split("/");
+    return pathNameComponents [pathNameComponents.length-1];
+  }
+
+  public void setBeforeName(final String fileName) {
+    myBeforeName = fileName;  
+  }
+
+  public void setAfterName(final String fileName) {
+    myAfterName = fileName;
+  }
+
+  public String getBeforeVersionId() {
+    return myBeforeVersionId;
+  }
+
+  public void setBeforeVersionId(final String beforeVersionId) {
+    myBeforeVersionId = beforeVersionId;
+  }
+
+  public String getAfterVersionId() {
+    return myAfterVersionId;
+  }
+
+  public void setAfterVersionId(final String afterVersionId) {
+    myAfterVersionId = afterVersionId;
+  }
+
+  public String getAfterNameRelative(int skipDirs) {
+    String[] components = myAfterName.split("/");
+    return StringUtil.join(components, skipDirs, components.length, "/");
+  }
+
+  public abstract boolean isNewFile();
+
+  public abstract boolean isDeletedFile();
+}
similarity index 96%
rename from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchReader.java
rename to platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/PatchReader.java
index 7baf2fe36210cdb49d481d6d4f25a0e05c701fe9..288b39586d53ae20f7dca23520d438d7f756c36e 100644 (file)
  */
 package com.intellij.openapi.diff.impl.patch;
 
-import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
 import com.intellij.openapi.util.text.LineTokenizer;
-import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
 
-import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.List;
-import java.util.ArrayList;
 
 public class PatchReader {
   @NonNls public static final String NO_NEWLINE_SIGNATURE = "\\ No newline at end of file";
@@ -48,12 +45,6 @@ public class PatchReader {
   @NonNls private static final Pattern ourContextBeforeHunkStartPattern = Pattern.compile("\\*\\*\\* (\\d+),(\\d+) \\*\\*\\*\\*");
   @NonNls private static final Pattern ourContextAfterHunkStartPattern = Pattern.compile("--- (\\d+),(\\d+) ----");
 
-  public PatchReader(VirtualFile virtualFile) throws IOException {
-    byte[] patchContents = virtualFile.contentsToByteArray();
-    CharSequence patchText = LoadTextUtil.getTextByBinaryPresentation(patchContents, virtualFile);
-    myLines = LineTokenizer.tokenize(patchText, false);
-  }
-
   public PatchReader(CharSequence patchContent) {
     myLines = LineTokenizer.tokenize(patchContent, false);
   }
diff --git a/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextFilePatch.java b/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextFilePatch.java
new file mode 100644 (file)
index 0000000..e92baf5
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2009 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.diff.impl.patch;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author yole
+ */
+public class TextFilePatch extends FilePatch {
+  private final List<PatchHunk> myHunks;
+
+  public void addHunk(final PatchHunk hunk) {
+    myHunks.add(hunk);
+  }
+
+  public List<PatchHunk> getHunks() {
+    return Collections.unmodifiableList(myHunks);
+  }
+
+  public TextFilePatch() {
+    myHunks = new ArrayList<PatchHunk>();
+  }
+
+  private TextFilePatch(final TextFilePatch patch) {
+    setBeforeVersionId(patch.getBeforeVersionId());
+    setAfterVersionId(patch.getAfterVersionId());
+    setBeforeName(patch.getBeforeName());
+    setAfterName(patch.getAfterName());
+    myHunks = patch.myHunks;
+  }
+
+  public TextFilePatch pathsOnlyCopy() {
+    return new TextFilePatch(this);
+  }
+
+  public boolean isNewFile() {
+    return myHunks.size() == 1 && myHunks.get(0).isNewContent();
+  }
+
+  public String getNewFileText() {
+    return myHunks.get(0).getText();
+  }
+
+  public boolean isDeletedFile() {
+    return myHunks.size() == 1 && myHunks.get(0).isDeletedContent();
+  }
+}
similarity index 98%
rename from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/PatchBuilder.java
rename to platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextPatchBuilder.java
index 606fa0bf836325d32ca1c1acd116a6c96d5cc66b..27be1b147901c42dfcefe5d0ccd70101570ed451 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * 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.
@@ -44,11 +44,11 @@ import java.util.List;
 /**
  * @author yole
  */
-public class PatchBuilder {
+public class TextPatchBuilder {
   private static final int CONTEXT_LINES = 3;
   @NonNls private static final String REVISION_NAME_TEMPLATE = "(revision {0})";
 
-  private PatchBuilder() {
+  private TextPatchBuilder() {
   }
 
   private static void checkCanceled(final ProgressIndicator ind) {
@@ -57,8 +57,7 @@ public class PatchBuilder {
     }
   }
 
-  public static List<FilePatch> buildPatch(final Collection<Change> changes, final String basePath, final boolean allowRename,
-                                           final boolean reversePatch) throws VcsException {
+  public static List<FilePatch> buildPatch(final Collection<Change> changes, final String basePath, final boolean reversePatch) throws VcsException {
     final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
     
     List<FilePatch> result = new ArrayList<FilePatch>();
similarity index 99%
rename from platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/UnifiedDiffWriter.java
rename to platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/UnifiedDiffWriter.java
index 44d3a84750613701985e2e3b5292b2a1a58603cc..037cbb0c925e4cdb051e9f545c40ceb0be94042e 100644 (file)
@@ -26,8 +26,8 @@ import org.jetbrains.annotations.NonNls;
 
 import java.io.IOException;
 import java.io.Writer;
-import java.util.Collection;
 import java.text.MessageFormat;
+import java.util.Collection;
 
 public class UnifiedDiffWriter {
   @NonNls private static final String INDEX_SIGNATURE = "Index: {0}{1}";
index 63159e43c35c61282498ca98436b5a0921579977..59dc044c95c547dbb930f85c2e80a08f2d1f8e46 100644 (file)
@@ -63,6 +63,7 @@ public final class VcsConfiguration implements PersistentStateComponent<Element>
   public boolean PERFORM_ROLLBACK_IN_BACKGROUND = false;
   public volatile boolean CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND = false;
   public VcsShowConfirmationOption.Value MOVE_TO_FAILED_COMMIT_CHANGELIST = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+  public VcsShowConfirmationOption.Value REMOVE_EMPTY_INACTIVE_CHANGELISTS = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
   public boolean ENABLE_BACKGROUND_PROCESSES = false;
   public int CHANGED_ON_SERVER_INTERVAL = 60;
 
index 4c43ad78a904b492a09c2bf7e156019ed67de93b..d077e7621ee482488f83e84894b6a5a13e131d89 100644 (file)
--- a/