Merge branch 'master' of git.labs.intellij.net:idea/community
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Fri, 10 Dec 2010 14:18:00 +0000 (17:18 +0300)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Mon, 13 Dec 2010 08:03:48 +0000 (11:03 +0300)
215 files changed:
RegExpSupport/src/org/intellij/lang/regexp/RegExpColorsPage.java
RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java
bin/win/idea.bat
build/Install-Linux-tar.txt [new file with mode: 0644]
build/scripts/dist.gant
community-resources/src/idea/IdeaApplicationInfo.xml
java/execution/impl/src/com/intellij/execution/junit2/SegmentedInputStream.java
java/idea-ui/src/com/intellij/openapi/projectRoots/ui/SdkEditor.java
java/idea-ui/src/com/intellij/openapi/projectRoots/ui/Util.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/AnnotationsOrderRootTypeUIFactory.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ClassesOrderRootTypeUIFactory.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavadocOrderRootTypeUIFactory.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/SourcesOrderRootTypeUIFactory.java
java/java-impl/src/com/intellij/codeInsight/completion/InheritorsHolder.java
java/java-impl/src/com/intellij/codeInsight/completion/SmartCompletionDecorator.java
java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java
java/java-impl/src/com/intellij/refactoring/changeSignature/inCallers/JavaCallerChooser.java
java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassDialog.java
java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java
java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterDialog.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java
java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java [new file with mode: 0644]
java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java
java/java-impl/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderDialog.java
java/java-impl/src/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryDialog.java
java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java
java/java-impl/src/com/intellij/refactoring/ui/TypeSelectorManagerImpl.java
java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java
java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java
java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistry.java
java/java-runtime/src/com/intellij/rt/execution/junit/segments/Packet.java
java/java-runtime/src/com/intellij/rt/execution/junit/segments/PoolOfDelimiters.java
java/java-tests/testData/codeInsight/completion/normal/ClassTypeParameters.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/normal/ClassTypeParametersGenericBounds.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/normal/LocalClassName.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/normal/LocalClassName_after.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/normal/LocalClassTwice.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/normal/LocalTopLevelConflict.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/NoConstructorTailWhenNoPairBracket-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/NoConstructorTailWhenNoPairBracket.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket2-out.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket2.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardCastConversion.java
java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java
java/jsp-spi/src/com/intellij/jsp/impl/TldAttributeDescriptor.java
java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
platform/extensions/src/com/intellij/openapi/extensions/LoadingOrder.java
platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java [moved from platform/lang-impl/src/com/intellij/openapi/projectRoots/ui/PathEditor.java with 98% similarity]
platform/lang-api/src/com/intellij/openapi/roots/ui/OrderRootTypeUIFactory.java [moved from java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/OrderRootTypeUIFactory.java with 96% similarity]
platform/lang-api/src/com/intellij/psi/search/SearchRequestCollector.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java
platform/lang-impl/src/com/intellij/codeInsight/editorActions/BackspaceHandler.java
platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteAllFavoritesListsButThisAction.java
platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/ScriptingLibrariesPanel.java
platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/ScriptingLibraryTableModel.java
platform/lang-impl/src/com/intellij/openapi/paths/GlobalPathReferenceProvider.java
platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocOrderRootType.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocOrderRootTypeUIFactory.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocUrlChooser.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibraryManager.java
platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibraryTable.java
platform/lang-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java
platform/lang-impl/src/com/intellij/psi/impl/source/tree/AstBufferUtil.java
platform/lang-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
platform/lang-impl/src/com/intellij/refactoring/changeSignature/CallerChooserBase.java
platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java
platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java
platform/platform-api/src/com/intellij/ide/plugins/PluginManager.java
platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java
platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDialog.java
platform/platform-api/src/com/intellij/ui/SeparatorWithText.java
platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java
platform/platform-impl/src/com/intellij/ide/actions/AboutAction.java
platform/platform-impl/src/com/intellij/ide/dnd/DnDManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/diff/actions/IgnoreWhiteSpacesAction.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/AbstractMappingStrategy.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CacheEntry.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/FoldingData.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/MappingStrategy.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java
platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java
platform/platform-impl/src/com/intellij/ui/Splash.java
platform/platform-impl/src/com/intellij/util/io/ByteBufferIntObjectMap.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/ByteBufferMap.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/ByteBufferMapWriteHandler.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/ByteBufferRADataInput.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/FileKeyProvider.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/IntArrayValueProvider.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/IntValueProvider.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/IntegerKeyProvider.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/StringKeyProvider.java [deleted file]
platform/platform-impl/src/com/intellij/util/io/WriteableMapAdapter.java [deleted file]
platform/platform-impl/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceOnDocumentModificationTest.java
platform/platform-resources-en/src/messages/IdeBundle.properties
platform/platform-resources-en/src/messages/ProjectBundle.properties
platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java
platform/util/src/com/intellij/util/io/MappedBufferWrapper.java
platform/util/src/com/intellij/util/io/MappedFile.java [deleted file]
platform/util/src/com/intellij/util/io/PagedFileStorage.java
platform/util/src/com/intellij/util/io/ReadOnlyMappedBufferWrapper.java
platform/util/src/com/intellij/util/io/ReadWriteMappedBufferWrapper.java
platform/vcs-api/src/com/intellij/openapi/vcs/ThreadLocalDefendedInvoker.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangeListRenderer.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/UnshelveChangesAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsFileStatusProvider.java
platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
plugins/InspectionGadgets/src/com/siyeh/ig/InspectionGadgetsPlugin.java
plugins/InspectionGadgets/src/com/siyeh/ig/fixes/NormalizeDeclarationFix.java
plugins/InspectionGadgets/src/com/siyeh/ig/style/MultipleDeclarationInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/style/SimplifiableAnnotationInspection.java [new file with mode: 0644]
plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryAnnotationParenthesesInspection.java [deleted file]
plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableAnnotation.html [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/style/simplifiable_annotation/SimplifiableAnnotation.java [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/style/simplifiable_annotation/expected.xml [new file with mode: 0644]
plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_annotation_parentheses/UnnecessaryAnnotationParentheses.java [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_annotation_parentheses/expected.xml [deleted file]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/SimplifiableAnnotationInspectionTest.java [new file with mode: 0644]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryAnnotationParenthesesInspectionTest.java [deleted file]
plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java
plugins/android/src/org/jetbrains/android/sdk/AndroidSdk.java
plugins/android/src/org/jetbrains/android/util/AndroidUtils.java
plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java
plugins/git4idea/src/git4idea/rebase/GitRebaseDialog.java
plugins/github/src/META-INF/plugin.xml
plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java [new file with mode: 0644]
plugins/github/src/org/jetbrains/plugins/github/GithubRebase.java [new file with mode: 0644]
plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java [new file with mode: 0644]
plugins/github/src/org/jetbrains/plugins/github/GithubSettings.java
plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java
plugins/github/src/org/jetbrains/plugins/github/RepositoryInfo.java
plugins/github/src/org/jetbrains/plugins/github/ui/GitHubSettingsConfigurable.java
plugins/github/src/org/jetbrains/plugins/github/ui/GithubRebaseDialog.java [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java
plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java
plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleScriptType.java
plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/JavaStylePropertiesInvocationIntention.java
plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/GroovySmartEnterProcessor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/fixers/GrListFixer.java [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/GroovyResolveResult.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentListImpl.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/DefaultCallExpressionTypeCalculator.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiElementUtil.java [deleted file]
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeInfoImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantHandler.java
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyRunConfigurationEditor.form
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyRunConfigurationEditor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfigurationProducer.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/smartEnter/SmartEnterTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/IntroduceConstantTest.java
plugins/groovy/testdata/refactoring/introduceConstant/InsertInEnum.groovy [new file with mode: 0644]
plugins/groovy/testdata/refactoring/introduceConstant/InsertInEnum_after.groovy [new file with mode: 0644]
plugins/groovy/testdata/refactoring/introduceConstant/InsertInInterface.groovy [new file with mode: 0644]
plugins/groovy/testdata/refactoring/introduceConstant/InsertInInterface_after.groovy [new file with mode: 0644]
plugins/groovy/testdata/resolve/property/nonStaticFieldInStaticContext/A.groovy [new file with mode: 0644]
plugins/groovy/testdata/resolve/property/staticFieldOfInterface/A.groovy [new file with mode: 0644]
plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java
plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java
plugins/junit_rt/src/com/intellij/junit3/TestResultsSender.java
plugins/junit_rt/src/com/intellij/junit3/TreeSender.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java
plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomUtil.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateDependencyAction.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateManagedDependencyAction.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/intentions/AddMavenDependencyQuickFix.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearchDialog.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearchPanel.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearcher.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenSearcher.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/AddingDependencyTest.java [deleted file]
plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java
plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchConfigurationDialog.java
plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java
plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ToBeMergedDialog.java
plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java
plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java
plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java
resources/src/META-INF/IdeaPlugin.xml

index 8afcb738c59ed1b5e932cda4073f3a46bbc5f72e..1c175c978094900263499f522ff033a29c95d9fb 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.intellij.lang.regexp;
 
-import com.intellij.application.options.colors.InspectionColorSettingsPage;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.openapi.fileTypes.SyntaxHighlighter;
 import com.intellij.openapi.options.colors.AttributesDescriptor;
@@ -31,13 +30,20 @@ import java.util.Map;
 /**
  * @author traff
  */
-public class RegExpColorsPage implements ColorSettingsPage, InspectionColorSettingsPage {
+public class RegExpColorsPage implements ColorSettingsPage {
   private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[] {
-    new AttributesDescriptor("Keywords",  RegExpHighlighter.META),
-    new AttributesDescriptor("Escaped characters",  RegExpHighlighter.ESC_CHARACTER),
-    new AttributesDescriptor("Braces",  RegExpHighlighter.BRACES),
-    new AttributesDescriptor("Brackets",  RegExpHighlighter.BRACKETS),
+    new AttributesDescriptor("Keyword",  RegExpHighlighter.META),
+    new AttributesDescriptor("Escaped character",  RegExpHighlighter.ESC_CHARACTER),
+    new AttributesDescriptor("Invalid escape sequence",  RegExpHighlighter.INVALID_CHARACTER_ESCAPE),
+    new AttributesDescriptor("Redundant escape sequence",  RegExpHighlighter.REDUNDANT_ESCAPE),
+    new AttributesDescriptor("Brace",  RegExpHighlighter.BRACES),
+    new AttributesDescriptor("Bracket",  RegExpHighlighter.BRACKETS),
     new AttributesDescriptor("Parenthesis",  RegExpHighlighter.PARENTHS),
+    new AttributesDescriptor("Comma",  RegExpHighlighter.COMMA),
+    new AttributesDescriptor("Bad character",  RegExpHighlighter.BAD_CHARACTER),
+    new AttributesDescriptor("Character class",  RegExpHighlighter.CHAR_CLASS),
+    new AttributesDescriptor("Quote character",  RegExpHighlighter.QUOTE_CHARACTER),
+    new AttributesDescriptor("Comment",  RegExpHighlighter.COMMENT)
   };
 
   @NonNls private static final HashMap<String,TextAttributesKey> ourTagToDescriptorMap = new HashMap<String, TextAttributesKey>();
@@ -71,7 +77,7 @@ public class RegExpColorsPage implements ColorSettingsPage, InspectionColorSetti
   @NotNull
   public String getDemoText() {
     return
-      "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
+      "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}\\x0g\\#\\p{alpha}\\Q\\E$";
 
   }
 
index 141391a7cbebd8bbe33648e05482943374628f39..17da2ae193b4df181f071a081386eaf959f3840c 100644 (file)
@@ -78,10 +78,6 @@ class RegExpHighlighter extends SyntaxHighlighterBase {
             "REGEXP.QUOTE_CHARACTER",
             SyntaxHighlighterColors.VALID_STRING_ESCAPE.getDefaultAttributes()
     );
-    static final TextAttributesKey CTRL_CHARACTER = TextAttributesKey.createTextAttributesKey(
-            "REGEXP.CTRL_CHARACTER",
-            SyntaxHighlighterColors.VALID_STRING_ESCAPE.getDefaultAttributes()
-    );
     static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey(
             "REGEXP.COMMENT",
             SyntaxHighlighterColors.LINE_COMMENT.getDefaultAttributes()
@@ -108,7 +104,6 @@ class RegExpHighlighter extends SyntaxHighlighterBase {
         keys1.put(RegExpTT.BAD_HEX_VALUE, INVALID_CHARACTER_ESCAPE);
         keys1.put(RegExpTT.BAD_OCT_VALUE, INVALID_CHARACTER_ESCAPE);
 
-        keys1.put(RegExpTT.CTRL_CHARACTER, CTRL_CHARACTER);
         keys1.put(RegExpTT.PROPERTY, CHAR_CLASS);
 
         keys1.put(RegExpTT.ESC_CHARACTER, ESC_CHARACTER);
index 632ae9142b2d1e6c20f312a94da13be4f1493a89..b849c97c27297f7c52f45bedbdf0738a2c9fc633 100644 (file)
@@ -6,7 +6,7 @@
 
 :: ---------------------------------------------------------------------
 :: Before you run IntelliJ IDEA specify the location of the
-:: JDK 1.5 installation directory which will be used for running IDEA
+:: JDK 1.6 installation directory which will be used for running IDEA
 :: ---------------------------------------------------------------------
 IF "%IDEA_JDK%" == "" SET IDEA_JDK=%JDK_HOME%
 IF "%IDEA_JDK%" == "" goto error
diff --git a/build/Install-Linux-tar.txt b/build/Install-Linux-tar.txt
new file mode 100644 (file)
index 0000000..d51b005
--- /dev/null
@@ -0,0 +1,51 @@
+IntelliJ IDEA
+
+INSTALLATION INSTRUCTIONS
+===============================================================================
+
+  Linux Installation Instructions
+  ------------------------------------------------------------------------------
+  1. Unpack the IntelliJ IDEA distribution file that you downloaded to
+     where you wish to install the program. We will refer to this destination
+     location as your {installation home} below.
+
+  2. Open a console and cd into "{installation home}/bin" and type:
+
+       ./idea.sh
+
+     to start the application.
+
+  3. [OPTIONAL] Add the "{installation home}/bin" to your PATH environmental
+     variable so that you may start IntelliJ IDEA from any directory.
+
+  4. [OPTIONAL] To adjust the value of JVM heap size open idea.vmoptions and
+     modify the -Xms and -Xmx parameters.
+
+
+  [OPTIONAL] Changing location of "config" and "system" directory
+  ------------------------------------------------------------------------------
+  By default IDEA stores all your settings under ~/.IntelliJIdea10/config directory
+  and stores data cache under ~/.IntelliJIdea10/system directory.
+  If you want to change these settings,
+
+  1. Open a console and cd into "{installation home}/bin"
+
+  2. Open file "idea.properties" in an editor. You should find strings like
+
+     idea.system.path=~/.IntelliJIdea10/system
+
+     and
+
+     idea.config.path=~/.IntelliJIdea10/config
+
+     and change them.
+
+  3. Note that we recommend to store data cache ("system" directory) at a disk 
+     with at least 1G bytes free space
+
+
+
+
+Enjoy!
+
+-IntelliJ IDEA Development Team
index d2635baf3b05085ab60a341d147e7ec7f19f44d9..bd8d82c0364d458bdc199519d65381df9d359995 100644 (file)
@@ -198,6 +198,7 @@ def layoutLinux(Map args, String home, Paths paths) {
       fileset(dir: "$home/bin/nix")
       fileset(dir: "$home/build/images")
     }
+    fileset(dir: "$home/build", includes: "Install-Linux-tar.txt")
   }
 
   patchPropertiesFile(paths.distUnix)
index 1bcdca8d3b400afe71491dbc6fd55fbc43f92187..3ab6ac4dd875a87faee4b7ea19712b652ef052f8 100644 (file)
@@ -18,8 +18,8 @@
   <feedback eap-url="http://youtrack.jetbrains.net" release-url="http://www.jetbrains.com/feedback/feedback.jsp?product=IDEA&amp;build=$BUILD&amp;timezone=$TIMEZONE&amp;eval=$EVAL"/>
   <plugins url="http://plugins.intellij.net"/>
   <whatsnew url="http://www.jetbrains.com/idea/whatsnew/index.html"/>
-  <keymap win="http://www.jetbrains.com/idea/docs/IntelliJIDEA9_ReferenceCard.pdf"
-          mac="http://www.jetbrains.com/idea/docs/IntelliJIDEA9_ReferenceCard_Mac.pdf"/>
+  <keymap win="http://www.jetbrains.com/idea/docs/IntelliJIDEA_ReferenceCard.pdf"
+          mac="http://www.jetbrains.com/idea/docs/IntelliJIDEA_ReferenceCard_Mac.pdf"/>
 
   <plugins-page category="VCS Integration" title="Select VCS Integration Plugins"/>
   <plugins-page title="Select Other Plugins"/>
index 40cd9bde5f65ef497d35658bb9ac64c83ec84e3e..3fc4d64b968cbb23ee45f5cc8b8b85f9f4a723a5 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.rt.execution.junit.segments.Packet;
 import com.intellij.rt.execution.junit.segments.PacketProcessor;
 import com.intellij.rt.execution.junit.segments.SegmentedStream;
 import com.intellij.util.StringBuilderSpinAllocator;
-import com.intellij.util.containers.HashMap;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -65,6 +64,7 @@ public class SegmentedInputStream extends InputStream {
       if (nextByte != SegmentedStream.SPECIAL_SYMBOL) break;
       final Integer packetRead = readControlSequence();
       if (packetRead != null) break;
+      if (available() == 0) return -1;
     }
     return nextByte;
   }
index 5a40b043b9e01d6138f29df09833e3be1649c7d8..f8ebd6dd79e47cd9dd9b630e1d6428c90deaea77 100644 (file)
@@ -25,7 +25,7 @@ import com.intellij.openapi.projectRoots.*;
 import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
 import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil;
 import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.roots.ui.configuration.OrderRootTypeUIFactory;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
 import com.intellij.openapi.util.ActionCallback;
@@ -132,8 +132,10 @@ public class SdkEditor implements Configurable, Place.Navigator {
     for (OrderRootType type : OrderRootType.getAllTypes()) {
       if (mySdk == null || mySdk.getSdkType().isRootTypeApplicable(type)) {
         final PathEditor pathEditor = OrderRootTypeUIFactory.FACTORY.getByKey(type).createPathEditor(mySdk);
-        myTabbedPane.addTab(pathEditor.getDisplayName(), pathEditor.createComponent());
-        myPathEditors.put(type, pathEditor);
+        if (pathEditor != null) {
+          myTabbedPane.addTab(pathEditor.getDisplayName(), pathEditor.createComponent());
+          myPathEditors.put(type, pathEditor);
+        }
       }
     }
 
index ff23ce84c6cd0b359204d92630a5c6324f61a5c3..c7b829999e5eb59c60024bde5730503e11920271 100644 (file)
  */
 package com.intellij.openapi.projectRoots.ui;
 
-import com.intellij.openapi.project.ProjectBundle;
-import com.intellij.openapi.ui.InputValidator;
-import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.roots.libraries.doc.DocUrlChooser;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileManager;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
-import java.net.MalformedURLException;
-import java.net.URL;
 
 /**
+ * Note: for languages other than Java use com.intellij.openapi.roots.libraries.doc.DocUrlChooser.
  * @author MYakovlev
  * Date: Oct 29, 2002
  * Time: 8:47:43 PM
  */
 public class Util{
 
+  @Nullable
   public static VirtualFile showSpecifyJavadocUrlDialog(JComponent parent) {
     return showSpecifyJavadocUrlDialog(parent, "");
   }
 
+  @Nullable
   public static VirtualFile showSpecifyJavadocUrlDialog(JComponent parent, String initialValue){
-    final String url = Messages.showInputDialog(parent, ProjectBundle.message("sdk.configure.javadoc.url.prompt"),
-                                                ProjectBundle.message("sdk.configure.javadoc.url.title"), Messages.getQuestionIcon(), initialValue, new InputValidator() {
-      public boolean checkInput(String inputString) {
-        return true;
-      }
-      public boolean canClose(String inputString) {
-        try {
-          new URL(inputString);
-          return true;
-        }
-        catch (MalformedURLException e1) {
-          Messages.showErrorDialog(e1.getMessage(), ProjectBundle.message("sdk.configure.javadoc.url.title"));
-        }
-        return false;
-      }
-    });
-    if (url == null) {
-      return null;
-    }
-    return VirtualFileManager.getInstance().findFileByUrl(url);
+    return DocUrlChooser.showSpecifyDocUrlDialog(parent, initialValue);
   }
 
 
index 2d876e7c0a70887c9e3de147225a95f73f3d3bf0..6d6daa4b2f69599bc6cd3ace9e9569ce42990dd4 100644 (file)
@@ -25,7 +25,7 @@ import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.ui.PathEditor;
 import com.intellij.openapi.roots.AnnotationOrderRootType;
-import com.intellij.openapi.roots.ui.configuration.OrderRootTypeUIFactory;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
 import com.intellij.openapi.util.IconLoader;
 
 import javax.swing.*;
@@ -47,4 +47,4 @@ public class AnnotationsOrderRootTypeUIFactory implements OrderRootTypeUIFactory
     return new PathEditor(ProjectBundle.message("sdk.configure.annotations.tab"), AnnotationOrderRootType.getInstance(),
                           FileChooserDescriptorFactory.createSingleFolderDescriptor());
   }
-}
\ No newline at end of file
+}
index 76ebf2e437ff12f57e3c0e61f6e1d8e17a61083d..5670ef01b81f31cd4fb94eef958bcef83a23a8bb 100644 (file)
@@ -25,7 +25,7 @@ import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.ui.PathEditor;
 import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.roots.ui.configuration.OrderRootTypeUIFactory;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
 import com.intellij.openapi.util.IconLoader;
 
 import javax.swing.*;
@@ -46,4 +46,4 @@ public class ClassesOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
   public String getNodeText() {
     return ProjectBundle.message("library.classes.node");
   }
-}
\ No newline at end of file
+}
index b775e13e1e346b33efb17c9e6811561545ba8268..86a602eb8091aceab0b2c5c619c800a806d70094 100644 (file)
@@ -23,7 +23,7 @@ import com.intellij.openapi.roots.libraries.ui.AttachRootButtonDescriptor;
 import com.intellij.openapi.roots.libraries.ui.ChooserBasedAttachRootButtonDescriptor;
 import com.intellij.openapi.roots.libraries.ui.LibraryRootsComponentDescriptor;
 import com.intellij.openapi.roots.libraries.ui.OrderRootTypePresentation;
-import com.intellij.openapi.roots.ui.configuration.OrderRootTypeUIFactory;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
 import com.intellij.openapi.roots.ui.configuration.PathUIUtils;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
index 6a5b19a546729c7c8a6a66b70695be3a06f3a539..b1d5134b30a8933e73434ccd00af4fbb120597f2 100644 (file)
@@ -25,9 +25,9 @@ import com.intellij.openapi.module.LanguageLevelUtil;
 import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.ui.PathEditor;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
 import com.intellij.openapi.projectRoots.ui.Util;
 import com.intellij.openapi.roots.JavadocOrderRootType;
-import com.intellij.openapi.roots.ui.configuration.OrderRootTypeUIFactory;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.java.LanguageLevel;
@@ -95,4 +95,4 @@ public class JavadocOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
       return "";
     }
   }
-}
\ No newline at end of file
+}
index dc821023264f9a85dc5f383b83c427c9205cb60a..a0f58c5ac57ec43741695356b935f19fcfb94316 100644 (file)
@@ -23,9 +23,9 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.project.ProjectBundle;
 import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
 import com.intellij.openapi.projectRoots.ui.PathEditor;
 import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.roots.ui.configuration.OrderRootTypeUIFactory;
 import com.intellij.openapi.roots.ui.configuration.PathUIUtils;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -54,4 +54,4 @@ public class SourcesOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
   public String getNodeText() {
     return ProjectBundle.message("library.sources.node");
   }
-}
\ No newline at end of file
+}
index 5230f321b66b62c7ec411fd7f2a544734c032e0c..a6e4dda462d770249340850a8a1dbb08f2008d72 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement;
 import com.intellij.util.Consumer;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -46,24 +47,24 @@ public class InheritorsHolder implements Consumer<LookupElement> {
       final PsiClass psiClass = (PsiClass)object;
       if (JavaCompletionUtil.hasAccessibleInnerClass(psiClass, myPosition)) return;
 
-      ContainerUtil.addIfNotNull(myAddedClasses, psiClass.getQualifiedName());
+      ContainerUtil.addIfNotNull(myAddedClasses, getClassName(psiClass));
     }
     myResult.addElement(AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(lookupElement));
   }
 
+  @Nullable
+  private static String getClassName(PsiClass psiClass) {
+    String name = psiClass.getQualifiedName();
+    return name == null ? psiClass.getName() : name;
+  }
+
   public boolean alreadyProcessed(@NotNull LookupElement element) {
     final Object object = element.getObject();
-    if (object instanceof PsiClass) {
-      if (alreadyProcessed((PsiClass)object)) return true;
-    }
-    return false;
+    return object instanceof PsiClass && alreadyProcessed((PsiClass)object);
   }
 
   public boolean alreadyProcessed(@NotNull PsiClass object) {
-    final String qualifiedName = object.getQualifiedName();
-    if (qualifiedName == null || myAddedClasses.contains(qualifiedName)) {
-      return true;
-    }
-    return false;
+    final String name = getClassName(object);
+    return name == null || myAddedClasses.contains(name);
   }
 }
index f2b56f94f0f0bff44bf7420724b6d747c032d6ba..2479f3a520fccc0a58bd7eea0a100947f784b16c 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.codeInsight.completion;
 
+import com.intellij.codeInsight.CodeInsightSettings;
 import com.intellij.codeInsight.CodeInsightUtilBase;
 import com.intellij.codeInsight.ExpectedTypeInfo;
 import com.intellij.codeInsight.TailType;
@@ -57,10 +58,15 @@ public class SmartCompletionDecorator extends TailTypeDecorator<LookupElement> {
       return defType;
     }
 
-    final PsiExpression enclosing = PsiTreeUtil.getContextOfType(myPosition, PsiExpression.class, true);
     LookupElement item = getDelegate();
+    Object object = item.getObject();
+    if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET && (object instanceof PsiMethod || object instanceof PsiClass)) {
+      return TailType.NONE;
+    }
+
+    final PsiExpression enclosing = PsiTreeUtil.getContextOfType(myPosition, PsiExpression.class, true);
 
-    if (enclosing != null && item.getObject() instanceof PsiElement) {
+    if (enclosing != null && object instanceof PsiElement) {
       final PsiType type = getItemType(item);
       final TailType itemType = item instanceof LookupItem ? ((LookupItem)item).getTailType() : TailType.NONE;
       TailType cached = itemType;
index c8b11d1f9f08ea08d533d903f4157bf0d0416ca3..b5c7822cbb0170b64eb0f3fdc78d59b6cad71a5a 100644 (file)
@@ -17,12 +17,15 @@ package com.intellij.psi.formatter.java;
 
 import com.intellij.formatting.*;
 import com.intellij.lang.ASTNode;
+import com.intellij.psi.JavaTokenType;
 import com.intellij.psi.codeStyle.CodeStyleSettings;
 import com.intellij.psi.formatter.FormatterUtil;
 import com.intellij.psi.impl.source.tree.ElementType;
 import com.intellij.psi.impl.source.tree.JavaDocElementType;
+import com.intellij.psi.impl.source.tree.JavaElementType;
 import com.intellij.psi.impl.source.tree.StdTokenSets;
 import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.ArrayList;
@@ -30,6 +33,10 @@ import java.util.List;
 
 public class BlockContainingJavaBlock extends AbstractJavaBlock{
 
+  private static final TokenSet TYPES_OF_STATEMENTS_WITH_OPTIONAL_BRACES = TokenSet.create(
+    JavaElementType.IF_STATEMENT, JavaElementType.WHILE_STATEMENT, JavaElementType.FOR_STATEMENT
+  );
+  
   private final static int BEFORE_FIRST = 0;
   private final static int BEFORE_BLOCK = 1;
   private final static int AFTER_ELSE = 2;
@@ -207,12 +214,37 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{
       return new ChildAttributes(getCodeBlockExternalIndent(), null);
     }
 
+    boolean useExternalIndent = false;
     if (newChildIndex == getSubBlocks().size()) {
+      useExternalIndent = true;
+    }
+    else if (TYPES_OF_STATEMENTS_WITH_OPTIONAL_BRACES.contains(myNode.getElementType())) {
+      // There is a possible case that we have situation like below:
+      //    if (true) <enter was pressed here>
+      //    <caret>
+      //    System.out.println();
+      // We would like to indent current caret position then because there is a high probability that the user starts
+      // typing there (populating statement body). So, we perform dedicated check for that here and use 'external indent'
+      // if necessary.
+      Block prevBlock = getSubBlocks().get(newChildIndex - 1);
+      Block nextBlock = getSubBlocks().get(newChildIndex);
+      if (prevBlock instanceof ASTBlock && nextBlock instanceof ASTBlock) {
+        ASTNode prevNode = ((ASTBlock)prevBlock).getNode();
+        ASTNode nextNode = ((ASTBlock)nextBlock).getNode();
+        if (prevNode != null && nextNode != null && prevNode.getElementType() == JavaTokenType.RPARENTH 
+            && nextNode.getElementType() != JavaTokenType.LBRACE) 
+        {
+          useExternalIndent = true;
+        }
+      }
+    }
+    
+    if (useExternalIndent) {
       return new ChildAttributes(getCodeBlockChildExternalIndent(newChildIndex), null);
     }
-
-    return new ChildAttributes(myIndentsBefore.get(newChildIndex), null);
-
+    else {
+      return new ChildAttributes(myIndentsBefore.get(newChildIndex), null);
+    }
   }
 
   private boolean isInsideForParens(final int newChildIndex) {
index 9bcc5021d159f5d68cdcab88c042d867a972c2dc..7d2dbaa9b7b69df19dd4845cc5149c8711bd5ed4 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.changeSignature.inCallers;
 
+import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiMethod;
 import com.intellij.refactoring.changeSignature.CallerChooserBase;
@@ -27,7 +28,7 @@ import java.util.Set;
 public class JavaCallerChooser extends CallerChooserBase<PsiMethod> {
 
   public JavaCallerChooser(PsiMethod method, Project project, String title, Tree previousTree, Consumer<Set<PsiMethod>> callback) {
-    super(method, project, title, previousTree, callback);
+    super(method, project, title, previousTree, "dummy." + StdFileTypes.JAVA.getDefaultExtension(), callback);
   }
 
   @Override
index 41a017c979f25911ce8a7f71bd23ad77c80a0327..950d984d4c46ebfc1d4eaec23c1ed214dec9c58e 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.refactoring.extractclass;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.presentation.java.SymbolPresentationUtil;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -148,12 +147,12 @@ class ExtractClassDialog extends RefactoringDialog implements MemberInfoChangeLi
 
     final String className = getClassName();
     if (className.length() == 0 || !nameHelper.isIdentifier(className)) {
-      throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' is invalid extracted class name");
+      throw new ConfigurationException("\'" + className + "\' is invalid extracted class name");
     }
 
     final String packageName = getPackageName();
     if (packageName.length() == 0 || !nameHelper.isQualifiedName(packageName)){
-      throw new ConfigurationException("\'" + StringUtil.last(packageName, 10, true) + "\' is invalid extracted class package name");
+      throw new ConfigurationException("\'" + packageName + "\' is invalid extracted class package name");
     }
   }
 
index 09a791c07986b408b41749c6c72f7460f0079fb2..bcc50ca04e75f561e2fa30c7e9d8970e799dd0f0 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.refactoring.inheritanceToDelegation;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.codeStyle.SuggestedNameInfo;
@@ -110,12 +109,12 @@ public class InheritanceToDelegationDialog extends RefactoringDialog {
     final String fieldName = getFieldName();
     final PsiNameHelper helper = JavaPsiFacade.getInstance(myProject).getNameHelper();
     if (!helper.isIdentifier(fieldName)){
-      throw new ConfigurationException("\'" + StringUtil.first(fieldName, 10, true) + "\' is invalid field name for delegation");
+      throw new ConfigurationException("\'" + fieldName + "\' is invalid field name for delegation");
     }
     if (myInnerClassNameField != null) {
       final String className = myInnerClassNameField.getEnteredName();
       if (!helper.isIdentifier(className)) {
-        throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' is invalid inner class name");
+        throw new ConfigurationException("\'" + className + "\' is invalid inner class name");
       }
     }
   }
index f4c21565fed9c6e2e13dd84195ae86a7f4b4090d..0c1686fa719d0cce1e22c4aa6a9bde5247def828 100644 (file)
@@ -27,7 +27,6 @@ package com.intellij.refactoring.introduceParameter;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
 import com.intellij.refactoring.HelpID;
@@ -462,7 +461,7 @@ public class IntroduceParameterDialog extends RefactoringDialog {
   protected void canRun() throws ConfigurationException {
     String name = getParameterName();
     if (name == null || !JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(name)) {
-      throw new ConfigurationException("\'" + StringUtil.first(name != null ? name : "", 10 , true) + "\' is invalid parameter name");
+      throw new ConfigurationException("\'" + (name != null ? name : "") + "\' is invalid parameter name");
     }
   }
 
index 24e4a997c72deef7e9ad2640e2e3e745bf2bfa22..e01e25fe1d764a79a63ce917fe515c53015204fa 100644 (file)
@@ -27,10 +27,7 @@ import com.intellij.codeInsight.CodeInsightUtil;
 import com.intellij.codeInsight.completion.JavaCompletionUtil;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.codeInsight.intention.impl.TypeExpression;
-import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInsight.lookup.LookupElementBuilder;
 import com.intellij.codeInsight.lookup.LookupManager;
-import com.intellij.codeInsight.template.*;
 import com.intellij.featureStatistics.FeatureUsageTracker;
 import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.lang.LanguageRefactoringSupport;
@@ -56,7 +53,6 @@ import com.intellij.psi.impl.source.tree.java.ReplaceExpressionUtil;
 import com.intellij.psi.util.PsiExpressionTrimRenderer;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.TypeConversionUtil;
 import com.intellij.refactoring.*;
 import com.intellij.refactoring.introduceField.ElementToWorkOn;
 import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
@@ -67,7 +63,6 @@ import com.intellij.refactoring.util.RefactoringUIUtil;
 import com.intellij.refactoring.util.RefactoringUtil;
 import com.intellij.refactoring.util.occurences.ExpressionOccurenceManager;
 import com.intellij.refactoring.util.occurences.NotInSuperCallOccurenceFilter;
-import com.intellij.util.Consumer;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.MultiMap;
 import org.jetbrains.annotations.NonNls;
@@ -476,63 +471,11 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
                 final PsiVariable elementToRename = variable.get().getElement();
                 if (elementToRename != null) {
                   editor.getCaretModel().moveToOffset(elementToRename.getTextOffset());
-                  final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(elementToRename, PsiDeclarationStatement.class);
-                  final SmartPsiElementPointer<PsiDeclarationStatement> pointer =
-                    SmartPointerManager.getInstance(project).createSmartPsiElementPointer(declarationStatement);
-                  editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, pointer);
-                  editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY,
-                                     occurrenceMarkers.toArray(new RangeMarker[occurrenceMarkers.size()]));
                   final boolean cantChangeFinalModifier = hasWriteAccess || (inFinalContext && choice == OccurrencesChooser.ReplaceChoice.ALL);
-                  final VariableInplaceRenamer renamer = new VariableInplaceRenamer(elementToRename, editor){
-                    @Override
-                    protected void addAdditionalVariables(TemplateBuilderImpl builder) {
-                      final PsiTypeElement typeElement = elementToRename.getTypeElement();
-                      builder.replaceElement(typeElement, "Variable_Type",
-                                             ReassignVariableUtil.createExpression(expression, typeElement.getText(), !cantChangeFinalModifier), true, true);
-                      if (!cantChangeFinalModifier) {
-                        builder.replaceElement(elementToRename.getModifierList(), "_FINAL_", new FinalExpression(project), false, true);
-                      }
-                    }
-                  };
-                  renamer.setAdvertisementText(
-                    ReassignVariableUtil.getAdvertisementText(editor, declarationStatement, elementToRename.getType(), typeSelectorManager.getTypesForAll(), !cantChangeFinalModifier));
-                  renamer.performInplaceRename(false, new LinkedHashSet<String>(Arrays.asList(suggestedName.names)), new Consumer<Boolean>() {
-                      @Override
-                      public void consume(Boolean apply) {
-                        if (apply) {
-                          final Document document = editor.getDocument();
-                          final PsiDeclarationStatement declarationStatement = pointer.getElement();
-                          final PsiVariable psiVariable = declarationStatement != null ? (PsiVariable)declarationStatement.getDeclaredElements()[0] : null;
-                          if (psiVariable != null) {
-                            JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = psiVariable.hasModifierProperty(PsiModifier.FINAL);
-                            FinalExpression.adjustLine(psiVariable, document);
-                          }
-                          int startOffset = exprMarker.getStartOffset();
-                          final PsiReference referenceAt = file.findReferenceAt(startOffset);
-                          if (referenceAt != null && referenceAt.resolve() instanceof PsiLocalVariable) {
-                            startOffset = referenceAt.getElement().getTextRange().getEndOffset();
-                          } else if (declarationStatement != null) {
-                            startOffset = declarationStatement.getTextRange().getEndOffset();
-                          }
-                          editor.getCaretModel().moveToOffset(startOffset);
-                          final PsiType selectedType = ReassignVariableUtil.getVariableType(declarationStatement);
-                          if (selectedType != null) {
-                            typeSelectorManager.typeSelected(selectedType);
-                          }
-                          ApplicationManager.getApplication().runWriteAction(new Runnable() {
-                            public void run() {
-                              appendTypeCasts(occurrenceMarkers, file, project, psiVariable);
-                            }
-                          });
-                        }
-                        editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, null);
-                        for (RangeMarker occurrenceMarker : occurrenceMarkers) {
-                          occurrenceMarker.dispose();
-                        }
-                        editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY, null);
-                        exprMarker.dispose();
-                      }
-                    });
+                  final VariableInplaceRenamer renamer =
+                    new VariableInplaceIntroducer(project, expression, editor, elementToRename, cantChangeFinalModifier,
+                                                  typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers);
+                  renamer.performInplaceRename(false, new LinkedHashSet<String>(Arrays.asList(suggestedName.names)));
                 }
               }
             }
@@ -549,47 +492,6 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
     return true;
   }
 
-  private static void appendTypeCasts(List<RangeMarker> occurrenceMarkers,
-                                      PsiFile file,
-                                      Project project,
-                                      PsiVariable psiVariable) {
-    for (RangeMarker occurrenceMarker : occurrenceMarkers) {
-      final PsiElement refVariableElement = file.findElementAt(occurrenceMarker.getStartOffset());
-      final PsiReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(refVariableElement, PsiReferenceExpression.class);
-      if (referenceExpression != null) {
-        final PsiElement parent = referenceExpression.getParent();
-        if (parent instanceof PsiVariable) {
-          createCastInVariableDeclaration(project, (PsiVariable)parent);
-        } else if (parent instanceof PsiReferenceExpression && psiVariable != null) {
-          final PsiExpression initializer = psiVariable.getInitializer();
-          LOG.assertTrue(initializer != null);
-          final PsiType type = initializer.getType();
-          if (((PsiReferenceExpression)parent).resolve() == null) {
-            final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
-            final PsiExpression castedExpr =
-              elementFactory.createExpressionFromText("((" + type.getCanonicalText() + ")" + referenceExpression.getText() + ")", parent);
-            JavaCodeStyleManager.getInstance(project).shortenClassReferences(referenceExpression.replace(castedExpr));
-          }
-        }
-      }
-    }
-    if (psiVariable != null && psiVariable.isValid()) {
-      createCastInVariableDeclaration(project, psiVariable);
-    }
-  }
-
-  private static void createCastInVariableDeclaration(Project project, PsiVariable psiVariable) {
-    final PsiExpression initializer = psiVariable.getInitializer();
-    LOG.assertTrue(initializer != null);
-    final PsiType type = psiVariable.getType();
-    final PsiType initializerType = initializer.getType();
-    if (initializerType != null && !TypeConversionUtil.isAssignable(type, initializerType)) {
-      final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
-      final PsiExpression castExpr =
-        elementFactory.createExpressionFromText("(" +psiVariable.getType().getCanonicalText()+ ")" + initializer.getText(), psiVariable);
-      JavaCodeStyleManager.getInstance(project).shortenClassReferences(initializer.replace(castExpr));
-    }
-  }
 
   private static Runnable introduce(final Project project,
                                     final PsiExpression expr,
@@ -895,7 +797,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
     };
   }
 
-  private static boolean createFinals(Project project) {
+  public static boolean createFinals(Project project) {
     final Boolean createFinals = JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS;
     return createFinals == null ? CodeStyleSettingsManager.getSettings(project).GENERATE_FINAL_LOCALS : createFinals.booleanValue();
   }
@@ -944,39 +846,5 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
     }
   }
 
-  private static class FinalExpression extends Expression {
-    private final Project myProject;
-
-    public FinalExpression(Project project) {
-      myProject = project;
-    }
-
-    @Override
-    public Result calculateResult(ExpressionContext context) {
-      return new TextResult(createFinals(myProject) ? PsiKeyword.FINAL : "");
-    }
-
-    @Override
-    public Result calculateQuickResult(ExpressionContext context) {
-      return calculateResult(context);
-    }
 
-    @Override
-    public LookupElement[] calculateLookupItems(ExpressionContext context) {
-      LookupElement[] lookupElements = new LookupElement[2];
-      lookupElements[0] = LookupElementBuilder.create("");
-      lookupElements[1] = LookupElementBuilder.create(PsiModifier.FINAL + " ");
-      return lookupElements;
-    }
-
-    public static void adjustLine(final PsiVariable psiVariable, final Document document) {
-      final int modifierListOffset = psiVariable.getTextRange().getStartOffset();
-      final int varLineNumber = document.getLineNumber(modifierListOffset);
-      ApplicationManager.getApplication().runWriteAction(new Runnable() { //adjust line indent if final was inserted and then deleted
-        public void run() {
-          CodeStyleManager.getInstance(psiVariable.getProject()).adjustLineIndent(document, document.getLineStartOffset(varLineNumber));
-        }
-      });
-    }
-  }
 }
index c90dc233f4235ae85855717dec68214228a4f25c..7b868165ad684e022d7799b2ce9df4dc351892ec 100644 (file)
  */
 package com.intellij.refactoring.introduceVariable;
 
-import com.intellij.codeInsight.intention.impl.TypeExpression;
-import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInsight.template.Expression;
-import com.intellij.codeInsight.template.ExpressionContext;
-import com.intellij.codeInsight.template.TextResult;
 import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
 import com.intellij.codeInsight.template.impl.TemplateState;
 import com.intellij.ide.ui.ListCellRendererWrapper;
-import com.intellij.openapi.actionSystem.Shortcut;
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.editor.VisualPosition;
-import com.intellij.openapi.keymap.Keymap;
-import com.intellij.openapi.keymap.KeymapManager;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.Key;
 import com.intellij.psi.*;
@@ -59,7 +51,7 @@ public class ReassignVariableUtil {
     final PsiDeclarationStatement declaration = pointer != null ? pointer.getElement() : null;
     final PsiType type = getVariableType(declaration);
     if (type != null) {
-      VariablesProcessor proc = findVariablesOfType(editor, declaration, type);
+      VariablesProcessor proc = findVariablesOfType(declaration, type);
       if (proc.size() > 0) {
 
         if (proc.size() == 1) {
@@ -111,7 +103,7 @@ public class ReassignVariableUtil {
     return null;
   }
 
-  private static VariablesProcessor findVariablesOfType(Editor editor, final PsiDeclarationStatement declaration, final PsiType type) {
+  static VariablesProcessor findVariablesOfType(final PsiDeclarationStatement declaration, final PsiType type) {
     VariablesProcessor proc = new VariablesProcessor(false) {
       @Override
       protected boolean check(PsiVariable var, ResolveState state) {
@@ -167,58 +159,4 @@ public class ReassignVariableUtil {
       editor.putUserData(VariableInplaceRenamer.INPLACE_RENAMER, null);
     }
   }
-
-  @Nullable
-  static String getAdvertisementText(Editor editor, PsiDeclarationStatement declaration, PsiType type, PsiType[] typesForAll, boolean canAdjustFinal) {
-    final VariablesProcessor processor = findVariablesOfType(editor, declaration, type);
-    final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
-    if (processor.size() > 0) {
-      final Shortcut[] shortcuts = keymap.getShortcuts("IntroduceVariable");
-      if (shortcuts.length > 0) {
-        return "Press " + shortcuts[0] + " to reassign existing variable";
-      }
-    }
-    if (typesForAll.length > 1) {
-      final Shortcut[] shortcuts = keymap.getShortcuts("PreviousTemplateVariable");
-      if  (shortcuts.length > 0) {
-        return "Press " + shortcuts[0] + " to change type";
-      }
-    }
-    return adjustFinalText(canAdjustFinal);
-  }
-
-  @Nullable
-  private static String adjustFinalText(boolean canBeFinalAdjusted) {
-    if (canBeFinalAdjusted) {
-      final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("PreviousTemplateVariable");
-      if (shortcuts.length > 0) {
-        return "Press " + shortcuts[0] + " to adjust final modifier";
-      }
-    }
-    return null;
-  }
-
-  public static Expression createExpression(final TypeExpression expression, final String defaultType, final boolean canBeFinalAdjusted) {
-    return new Expression() {
-      @Override
-      public com.intellij.codeInsight.template.Result calculateResult(ExpressionContext context) {
-        return new TextResult(defaultType);
-      }
-
-      @Override
-      public com.intellij.codeInsight.template.Result calculateQuickResult(ExpressionContext context) {
-        return new TextResult(defaultType);
-      }
-
-      @Override
-      public LookupElement[] calculateLookupItems(ExpressionContext context) {
-        return expression.calculateLookupItems(context);
-      }
-
-      @Override
-      public String getAdvertisingText() {
-        return adjustFinalText(canBeFinalAdjusted);
-      }
-    };
-  }
 }
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/VariableInplaceIntroducer.java
new file mode 100644 (file)
index 0000000..183a386
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * 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.refactoring.introduceVariable;
+
+import com.intellij.codeInsight.intention.impl.TypeExpression;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.lookup.LookupElementBuilder;
+import com.intellij.codeInsight.template.*;
+import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
+import com.intellij.codeInsight.template.impl.TemplateState;
+import com.intellij.openapi.actionSystem.Shortcut;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.RangeMarker;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.keymap.Keymap;
+import com.intellij.openapi.keymap.KeymapManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.scope.processor.VariablesProcessor;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.refactoring.JavaRefactoringSettings;
+import com.intellij.refactoring.rename.NameSuggestionProvider;
+import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
+import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+/**
+ * User: anna
+ * Date: 12/8/10
+ */
+class VariableInplaceIntroducer extends VariableInplaceRenamer {
+  private final PsiVariable myElementToRename;
+  private final Editor myEditor;
+  private final TypeExpression myExpression;
+  private final boolean myCantChangeFinalModifier;
+  private final Project myProject;
+  private final SmartPsiElementPointer<PsiDeclarationStatement> myPointer;
+  private final RangeMarker myExprMarker;
+  private final List<RangeMarker> myOccurrenceMarkers;
+  private final PsiType myDefaultType;
+
+  public VariableInplaceIntroducer(final Project project,
+                                   final TypeExpression expression,
+                                   final Editor editor,
+                                   final PsiVariable elementToRename,
+                                   final boolean cantChangeFinalModifier,
+                                   final boolean hasTypeSuggestion,
+                                   final RangeMarker exprMarker,
+                                   final List<RangeMarker> occurrenceMarkers) {
+    super(elementToRename, editor);
+    myProject = project;
+    myEditor = editor;
+    myElementToRename = elementToRename;
+    myExpression = expression;
+    myCantChangeFinalModifier = cantChangeFinalModifier;
+
+    myExprMarker = exprMarker;
+    myOccurrenceMarkers = occurrenceMarkers;
+
+    myDefaultType = elementToRename.getType();
+
+    final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(elementToRename, PsiDeclarationStatement.class);
+    myPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(declarationStatement);
+    editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
+    editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY,
+                       occurrenceMarkers.toArray(new RangeMarker[occurrenceMarkers.size()]));
+    setAdvertisementText(getAdvertisementText(declarationStatement, myDefaultType,
+                                              hasTypeSuggestion, !cantChangeFinalModifier));
+  }
+
+  @Override
+  protected void addAdditionalVariables(TemplateBuilderImpl builder) {
+    final PsiTypeElement typeElement = myElementToRename.getTypeElement();
+    builder.replaceElement(typeElement, "Variable_Type",
+                           createExpression(myExpression, typeElement.getText(), !myCantChangeFinalModifier), true,
+                           true);
+    if (!myCantChangeFinalModifier) {
+      builder.replaceElement(myElementToRename.getModifierList(), "_FINAL_", new FinalExpression(myProject), false, true);
+    }
+  }
+
+  @Override
+  protected LookupElement[] createLookupItems(LookupElement[] lookupItems, String name) {
+    TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor);
+    final PsiDeclarationStatement declarationStatement = myPointer.getElement();
+    final PsiVariable psiVariable =
+      declarationStatement != null ? (PsiVariable)declarationStatement.getDeclaredElements()[0] : null;
+    if (psiVariable != null) {
+      final TextResult insertedValue =
+        templateState != null ? templateState.getVariableValue(PRIMARY_VARIABLE_NAME) : null;
+      if (insertedValue != null) {
+        final String text = insertedValue.getText();
+        if (!text.isEmpty() && !Comparing.strEqual(text, name)) {
+          final LinkedHashSet<String> names = new LinkedHashSet<String>();
+          names.add(text);
+          for (NameSuggestionProvider provider : Extensions.getExtensions(NameSuggestionProvider.EP_NAME)) {
+            provider.getSuggestedNames(psiVariable, psiVariable, names);
+          }
+          final LookupElement[] items = new LookupElement[names.size()];
+          final Iterator<String> iterator = names.iterator();
+          for (int i = 0; i < items.length; i++) {
+            items[i] = LookupElementBuilder.create(iterator.next());
+          }
+          return items;
+        }
+      }
+    }
+    return super.createLookupItems(lookupItems, name);
+  }
+
+  @Override
+  protected void moveOffsetAfter(boolean success) {
+    if (success) {
+      final Document document = myEditor.getDocument();
+      final PsiDeclarationStatement declarationStatement = myPointer.getElement();
+      final PsiVariable psiVariable = declarationStatement != null ? (PsiVariable)declarationStatement.getDeclaredElements()[0] : null;
+      if (psiVariable != null) {
+        JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = psiVariable.hasModifierProperty(PsiModifier.FINAL);
+        FinalExpression.adjustLine(psiVariable, document);
+      }
+      int startOffset = myExprMarker.getStartOffset();
+      final PsiFile file = declarationStatement.getContainingFile();
+      final PsiReference referenceAt = file.findReferenceAt(startOffset);
+      if (referenceAt != null && referenceAt.resolve() instanceof PsiLocalVariable) {
+        startOffset = referenceAt.getElement().getTextRange().getEndOffset();
+      }
+      else if (declarationStatement != null) {
+        startOffset = declarationStatement.getTextRange().getEndOffset();
+      }
+      myEditor.getCaretModel().moveToOffset(startOffset);
+      final PsiType selectedType = ReassignVariableUtil.getVariableType(declarationStatement);
+      if (selectedType != null) {
+        TypeSelectorManagerImpl.typeSelected(selectedType, myDefaultType);
+      }
+      ApplicationManager.getApplication().runWriteAction(new Runnable() {
+        public void run() {
+          appendTypeCasts(myOccurrenceMarkers, file, myProject, psiVariable);
+        }
+      });
+    }
+    myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, null);
+    for (RangeMarker occurrenceMarker : myOccurrenceMarkers) {
+      occurrenceMarker.dispose();
+    }
+    myEditor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY, null);
+    myExprMarker.dispose();
+  }
+
+  private static void appendTypeCasts(List<RangeMarker> occurrenceMarkers,
+                                      PsiFile file,
+                                      Project project,
+                                      PsiVariable psiVariable) {
+    for (RangeMarker occurrenceMarker : occurrenceMarkers) {
+      final PsiElement refVariableElement = file.findElementAt(occurrenceMarker.getStartOffset());
+      final PsiReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(refVariableElement, PsiReferenceExpression.class);
+      if (referenceExpression != null) {
+        final PsiElement parent = referenceExpression.getParent();
+        if (parent instanceof PsiVariable) {
+          createCastInVariableDeclaration(project, (PsiVariable)parent);
+        }
+        else if (parent instanceof PsiReferenceExpression && psiVariable != null) {
+          final PsiExpression initializer = psiVariable.getInitializer();
+          LOG.assertTrue(initializer != null);
+          final PsiType type = initializer.getType();
+          if (((PsiReferenceExpression)parent).resolve() == null) {
+            final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
+            final PsiExpression castedExpr =
+              elementFactory.createExpressionFromText("((" + type.getCanonicalText() + ")" + referenceExpression.getText() + ")", parent);
+            JavaCodeStyleManager.getInstance(project).shortenClassReferences(referenceExpression.replace(castedExpr));
+          }
+        }
+      }
+    }
+    if (psiVariable != null && psiVariable.isValid()) {
+      createCastInVariableDeclaration(project, psiVariable);
+    }
+  }
+
+  private static void createCastInVariableDeclaration(Project project, PsiVariable psiVariable) {
+    final PsiExpression initializer = psiVariable.getInitializer();
+    LOG.assertTrue(initializer != null);
+    final PsiType type = psiVariable.getType();
+    final PsiType initializerType = initializer.getType();
+    if (initializerType != null && !TypeConversionUtil.isAssignable(type, initializerType)) {
+      final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
+      final PsiExpression castExpr =
+        elementFactory.createExpressionFromText("(" + psiVariable.getType().getCanonicalText() + ")" + initializer.getText(), psiVariable);
+      JavaCodeStyleManager.getInstance(project).shortenClassReferences(initializer.replace(castExpr));
+    }
+  }
+
+  @Nullable
+  private static String getAdvertisementText(final PsiDeclarationStatement declaration,
+                                             final PsiType type,
+                                             final boolean hasTypeSuggestion,
+                                             final boolean canAdjustFinal) {
+    final VariablesProcessor processor = ReassignVariableUtil.findVariablesOfType(declaration, type);
+    final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
+    if (processor.size() > 0) {
+      final Shortcut[] shortcuts = keymap.getShortcuts("IntroduceVariable");
+      if (shortcuts.length > 0) {
+        return "Press " + shortcuts[0] + " to reassign existing variable";
+      }
+    }
+    if (hasTypeSuggestion) {
+      final Shortcut[] shortcuts = keymap.getShortcuts("PreviousTemplateVariable");
+      if  (shortcuts.length > 0) {
+        return "Press " + shortcuts[0] + " to change type";
+      }
+    }
+    return adjustFinalText(canAdjustFinal);
+  }
+
+  @Nullable
+  private static String adjustFinalText(final boolean canBeFinalAdjusted) {
+    if (canBeFinalAdjusted) {
+      final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("PreviousTemplateVariable");
+      if (shortcuts.length > 0) {
+        return "Press " + shortcuts[0] + " to adjust final modifier";
+      }
+    }
+    return null;
+  }
+
+  private static Expression createExpression(final TypeExpression expression, final String defaultType, final boolean canBeFinalAdjusted) {
+    return new Expression() {
+      @Override
+      public Result calculateResult(ExpressionContext context) {
+        return new TextResult(defaultType);
+      }
+
+      @Override
+      public Result calculateQuickResult(ExpressionContext context) {
+        return new TextResult(defaultType);
+      }
+
+      @Override
+      public LookupElement[] calculateLookupItems(ExpressionContext context) {
+        return expression.calculateLookupItems(context);
+      }
+
+      @Override
+      public String getAdvertisingText() {
+        return adjustFinalText(canBeFinalAdjusted);
+      }
+    };
+  }
+
+  private static class FinalExpression extends Expression {
+    private final Project myProject;
+
+    public FinalExpression(Project project) {
+      myProject = project;
+    }
+
+    @Override
+    public Result calculateResult(ExpressionContext context) {
+      return new TextResult(IntroduceVariableBase.createFinals(myProject) ? PsiKeyword.FINAL : "");
+    }
+
+    @Override
+    public Result calculateQuickResult(ExpressionContext context) {
+      return calculateResult(context);
+    }
+
+    @Override
+    public LookupElement[] calculateLookupItems(ExpressionContext context) {
+      LookupElement[] lookupElements = new LookupElement[2];
+      lookupElements[0] = LookupElementBuilder.create("");
+      lookupElements[1] = LookupElementBuilder.create(PsiModifier.FINAL + " ");
+      return lookupElements;
+    }
+
+    public static void adjustLine(final PsiVariable psiVariable, final Document document) {
+      final int modifierListOffset = psiVariable.getTextRange().getStartOffset();
+      final int varLineNumber = document.getLineNumber(modifierListOffset);
+      ApplicationManager.getApplication().runWriteAction(new Runnable() { //adjust line indent if final was inserted and then deleted
+
+        public void run() {
+          CodeStyleManager.getInstance(psiVariable.getProject()).adjustLineIndent(document, document.getLineStartOffset(varLineNumber));
+        }
+      });
+    }
+  }
+}
index 924db50dc42b2d46672eb17d51eb805f57d3b999..d492c5e11bff48dd68c56f522e699802ed886123 100644 (file)
@@ -186,26 +186,26 @@ public class IntroduceParameterObjectDialog extends RefactoringDialog {
     }
     if (myCreateInnerClassRadioButton.isSelected()) {
       final String innerClassName = getInnerClassName().trim();
-      if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException("\'" + StringUtil.first(innerClassName, 10, true) + "\' is invalid inner class name");
-      if (sourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) throw new ConfigurationException("Inner class with name \'" + StringUtil.first(innerClassName, 10, true) + "\' already exist");
+      if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException("\'" + innerClassName + "\' is invalid inner class name");
+      if (sourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) throw new ConfigurationException("Inner class with name \'" + innerClassName + "\' already exist");
     } else if (!useExistingClass()) {
       final String className = getClassName();
       if (className.length() == 0 || !nameHelper.isIdentifier(className)) {
-        throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' is invalid parameter class name");
+        throw new ConfigurationException("\'" + className + "\' is invalid parameter class name");
       }
       final String packageName = getPackageName();
 
       if (packageName.length() == 0 || !nameHelper.isQualifiedName(packageName)) {
-        throw new ConfigurationException("\'" + StringUtil.last(packageName, 10, true) + "\' is invalid parameter class package name");
+        throw new ConfigurationException("\'" + packageName + "\' is invalid parameter class package name");
       }
     }
     else {
       final String className = getExistingClassName();
       if (className.length() == 0 || !nameHelper.isQualifiedName(className)) {
-        throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' is invalid qualified parameter class name");
+        throw new ConfigurationException("\'" + className + "\' is invalid qualified parameter class name");
       }
       if (JavaPsiFacade.getInstance(getProject()).findClass(className, GlobalSearchScope.allScope(getProject())) == null) {
-        throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' does not exist");
+        throw new ConfigurationException("\'" + className + "\' does not exist");
       }
     }
   }
index 3ee228fa95de287f51e23362901aa030a84ae6aa..de876972c34e02de42feb06f69d2019b53398489 100644 (file)
@@ -27,7 +27,6 @@ import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.search.ProjectScope;
@@ -269,7 +268,7 @@ public class MoveClassesOrPackagesDialog extends RefactoringDialog {
     if (isMoveToPackage()) {
       String name = getTargetPackage().trim();
       if (name.length() != 0 && !JavaPsiFacade.getInstance(myManager.getProject()).getNameHelper().isQualifiedName(name)) {
-        throw new ConfigurationException("\'" + StringUtil.last(name, 10, true) + "\' is invalid destination package name");
+        throw new ConfigurationException("\'" + name + "\' is invalid destination package name");
       }
     }
     else {
index 22faaca7de51b53f1da5f818d596c30a2a735271..1ded7c589922042cb1c346c8a0a61b94584242a5 100644 (file)
@@ -153,17 +153,17 @@ public class ReplaceConstructorWithBuilderDialog extends RefactoringDialog {
   protected void canRun() throws ConfigurationException {
     final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myProject).getNameHelper();
     for (ParameterData parameterData : myParametersMap.values()) {
-      if (!nameHelper.isIdentifier(parameterData.getFieldName())) throw new ConfigurationException("\'" + StringUtil.first(parameterData.getFieldName(), 10, true) + "\' is not a valid field name");
-      if (!nameHelper.isIdentifier(parameterData.getSetterName())) throw new ConfigurationException("\'" + StringUtil.first(parameterData.getSetterName(), 10, true) + "\' is not a valid setter name");
+      if (!nameHelper.isIdentifier(parameterData.getFieldName())) throw new ConfigurationException("\'" + parameterData.getFieldName() + "\' is not a valid field name");
+      if (!nameHelper.isIdentifier(parameterData.getSetterName())) throw new ConfigurationException("\'" + parameterData.getSetterName() + "\' is not a valid setter name");
     }
     if (myCreateBuilderClassRadioButton.isSelected()) {
       final String className = myNewClassName.getText().trim();
-      if (className.length() == 0 || !nameHelper.isQualifiedName(className)) throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' is invalid builder class name");
+      if (className.length() == 0 || !nameHelper.isQualifiedName(className)) throw new ConfigurationException("\'" + className + "\' is invalid builder class name");
       final String packageName = myPackageTextField.getText().trim();
-      if (packageName.length() > 0 && !nameHelper.isQualifiedName(packageName)) throw new ConfigurationException("\'" + StringUtil.last(packageName , 10, true)+ "\' is invalid builder package name");
+      if (packageName.length() > 0 && !nameHelper.isQualifiedName(packageName)) throw new ConfigurationException("\'" + packageName + "\' is invalid builder package name");
     } else {
       final String qualifiedName = myExistentClassTF.getText().trim();
-      if (qualifiedName.length() == 0 || !nameHelper.isQualifiedName(qualifiedName)) throw new ConfigurationException("\'" + StringUtil.last(qualifiedName, 10, true) + "\' is invalid builder qualified class name");
+      if (qualifiedName.length() == 0 || !nameHelper.isQualifiedName(qualifiedName)) throw new ConfigurationException("\'" + qualifiedName + "\' is invalid builder qualified class name");
     }
   }
 
index 16f35ea4d6519fb0e16542e8c858a2d5c809035e..3b96462bdaa50156d333a0c5110c502ad7e29654 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.ide.util.TreeClassChooserFactory;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.HelpID;
@@ -207,7 +206,7 @@ public class ReplaceConstructorWithFactoryDialog extends RefactoringDialog {
     final String name = myNameField.getEnteredName();
     final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myContainingClass.getProject()).getNameHelper();
     if (!nameHelper.isIdentifier(name)) {
-      throw new ConfigurationException("\'" + StringUtil.first(name, 10, true) + "\' is invalid factory method name");
+      throw new ConfigurationException("\'" + name + "\' is invalid factory method name");
     }
   }
 }
index d620d99416d1aa54436bf36b87e368215bbae837..dbf312f1159f69e98cfa3b5d1a976c4157b07857 100644 (file)
@@ -17,7 +17,6 @@ import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.LabeledComponent;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
@@ -139,7 +138,7 @@ public class TypeMigrationDialog extends RefactoringDialog {
 
   @Override
   protected void canRun() throws ConfigurationException {
-    if (!checkType(getMigrationType())) throw new ConfigurationException("\'" + StringUtil.first(myTypeCodeFragment.getText(), 10, true) + "\' is invalid type");
+    if (!checkType(getMigrationType())) throw new ConfigurationException("\'" + myTypeCodeFragment.getText() + "\' is invalid type");
     if (myScopeChooserCombo.getSelectedScope() == null) throw new ConfigurationException("Scope is not chosen");
   }
 
index 8b6356ca755605d3142150c545c1b621850fb4fc..e5b588e196d220d1bb81092211383fe487678841 100644 (file)
@@ -309,14 +309,22 @@ public class TypeSelectorManagerImpl implements TypeSelectorManager {
   }
 
   public void typeSelected(@NotNull PsiType type) {
-    StatisticsManager.getInstance().incUseCount(new StatisticsInfo(getStatsKey(), serialize(type)));
+    typeSelected(type, getDefaultType());
+  }
+
+  public static void typeSelected(final PsiType type, final PsiType defaultType) {
+    StatisticsManager.getInstance().incUseCount(new StatisticsInfo(getStatsKey(defaultType), serialize(type)));
   }
 
   private String getStatsKey() {
-    return "IntroduceVariable##" + serialize(getDefaultType());
+    return getStatsKey(getDefaultType());
+  }
+
+  private static String getStatsKey(final PsiType defaultType) {
+    return "IntroduceVariable##" + serialize(defaultType);
   }
 
-  private String serialize(PsiType type) {
+  private static String serialize(PsiType type) {
     if (PsiUtil.resolveClassInType(type) instanceof PsiTypeParameter) return type.getCanonicalText();
     return TypeConversionUtil.erasure(type).getCanonicalText();
   }
index 7b1b77b51b6ce7f988249d84fcafc1a79f683396..d6235e8774863332838100050ee4012bd162543a 100644 (file)
@@ -106,12 +106,12 @@ class WrapReturnValueDialog extends RefactoringDialog {
     final PsiNameHelper nameHelper = manager.getNameHelper();
     if (myCreateInnerClassButton.isSelected()) {
       final String innerClassName = getInnerClassName().trim();
-      if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException("\'" + StringUtil.first(innerClassName, 10, true) + "\' is invalid inner class name");
-      if (sourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) throw new ConfigurationException("Inner class with name \'" + StringUtil.first(innerClassName, 10, true) + "\' already exist");
+      if (!nameHelper.isIdentifier(innerClassName)) throw new ConfigurationException("\'" + innerClassName + "\' is invalid inner class name");
+      if (sourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) throw new ConfigurationException("Inner class with name \'" + innerClassName + "\' already exist");
     } else if (useExistingClassButton.isSelected()) {
       final String className = existingClassField.getText().trim();
       if (className.length() == 0 || !nameHelper.isQualifiedName(className)) {
-        throw new ConfigurationException("\'" + StringUtil.last(className, 10, true) + "\' is invalid qualified wrapper class name");
+        throw new ConfigurationException("\'" + className + "\' is invalid qualified wrapper class name");
       }
       final Object item = myFieldsCombo.getSelectedItem();
       if (item == null) {
@@ -120,12 +120,12 @@ class WrapReturnValueDialog extends RefactoringDialog {
     } else {
       final String className = getClassName();
       if (className.length() == 0 || !nameHelper.isIdentifier(className)) {
-        throw new ConfigurationException("\'" + StringUtil.first(className, 10, true) + "\' is invalid wrapper class name");
+        throw new ConfigurationException("\'" + className + "\' is invalid wrapper class name");
       }
       final String packageName = getPackageName();
 
       if (packageName.length() == 0 || !nameHelper.isQualifiedName(packageName)) {
-        throw new ConfigurationException("\'" + StringUtil.last(packageName, 10, true) + "\' is invalid wrapper class package name");
+        throw new ConfigurationException("\'" + packageName + "\' is invalid wrapper class package name");
       }
     }
   }
index 120e3d83c4efccdf23cbfe29b8b2ff2545432f7e..6c44fad99e3aa541769426068f196a2083eb0a32 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.unscramble;
 
 import com.intellij.openapi.application.ApplicationAdapter;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.wm.IdeFrame;
 
 import java.util.regex.Pattern;
@@ -32,8 +33,9 @@ public class UnscrambleListener extends ApplicationAdapter {
     final String clipboard = AnalyzeStacktraceUtil.getTextInClipboard();
     if (clipboard != null && clipboard.length() < MAX_STACKTRACE_SIZE && !clipboard.equals(stacktrace)) {
       stacktrace = clipboard;
-      if (isStacktrace(stacktrace)) {
-        final UnscrambleDialog dialog = new UnscrambleDialog(ideFrame.getProject());
+      final Project project = ideFrame.getProject();
+      if (project != null && isStacktrace(stacktrace)) {
+        final UnscrambleDialog dialog = new UnscrambleDialog(project);
         dialog.createNormalizeTextAction().actionPerformed(null);
         dialog.doOKAction();
       }
index c23c9c520ee4f1815f9487c51f2662e48616f531..8b7132d6bd37b33789063cf39a342152de158828 100644 (file)
  */
 package com.intellij.rt.execution.junit.segments;
 
+import java.util.Collection;
 import java.util.Hashtable;
 
 public abstract class OutputObjectRegistry  {
   private final Hashtable myKnownKeys = new Hashtable();
   private int myLastIndex = 0;
   private PacketProcessor myMainTransport;
-  private PacketProcessor myAuxilaryTransport;
 
   public OutputObjectRegistry(PacketProcessor transport) {
     myMainTransport = transport;
   }
 
-  public OutputObjectRegistry(PacketProcessor mainTransport, PacketProcessor auxilaryTransport) {
-    this(mainTransport);
-    myAuxilaryTransport = auxilaryTransport;
-  }
-
   public String referenceTo(Object test) {
     if (myKnownKeys.containsKey(test))
       return (String) myKnownKeys.get(test);
     return sendObject(test);
   }
 
+  public String referenceTo(Object test, Collection packets) {
+    if (myKnownKeys.containsKey(test))
+      return (String) myKnownKeys.get(test);
+    return sendObject(test, packets);
+  }
+
+  private String sendObject(Object test, Collection packets) {
+    String key = String.valueOf(myLastIndex++);
+    myKnownKeys.put(test, key);
+    final Packet packet = createPacket();
+    packet.addString(PoolOfDelimiters.OBJECT_PREFIX).addReference(key);
+    addStringRepresentation(test, packet);
+    packet.addLong(getTestCont(test));
+    packet.addString(PoolOfDelimiters.REFERENCE_END_STR);
+    packets.add(packet);
+    return key;
+  }
+
   public Packet createPacket() {
     return new Packet(myMainTransport, this);
   }
@@ -48,21 +61,13 @@ public abstract class OutputObjectRegistry  {
     Packet packet = createPacket().addString(PoolOfDelimiters.OBJECT_PREFIX).addReference(key);
     addStringRepresentation(test, packet);
     packet.addLong(getTestCont(test));
-    sendViaAllTransports(packet);
+    packet.send();
     return key;
   }
 
   protected abstract int getTestCont(Object test);
   protected abstract void addStringRepresentation(Object test, Packet packet);
 
-  private void sendViaAllTransports(Packet packet) {
-    packet.send();
-    if (myAuxilaryTransport != null)
-      packet.sendThrough(myAuxilaryTransport);
-  }
-
-
-
   protected static void addTestClass(Packet packet, String className) {
     packet.
         addLimitedString(PoolOfTestTypes.TEST_CLASS).
index b1970a947b6f0545de2b53d92af3f723eca08be0..8e72223bfa35d068c3c49e46ab716d223fa52733 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.rt.execution.junit.segments;
 import junit.runner.BaseTestRunner;
 
 import java.io.*;
+import java.util.Collection;
 import java.util.Vector;
 
 public class Packet extends PacketWriter {
@@ -36,6 +37,10 @@ public class Packet extends PacketWriter {
     return addReference(myRegistry.referenceTo(test));
   }
 
+  public Packet addObject(Object test, Collection packet) {
+    return addReference(myRegistry.referenceTo(test, packet));
+  }
+
   public Packet addReference(String reference) {
     appendString(reference + PoolOfDelimiters.REFERENCE_END);
     return this;
index 21f115f1038f22084e3677903367a621864d7968..6f87e8c788b1c8b74f5ad818d7811c54fbac6d11 100644 (file)
@@ -20,6 +20,7 @@ package com.intellij.rt.execution.junit.segments;
  */
 public interface PoolOfDelimiters {
   char REFERENCE_END = ':';
+  String REFERENCE_END_STR = ":";
   char INTEGER_DELIMITER = ' ';
 
   String OBJECT_PREFIX = "O";
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ClassTypeParameters.java b/java/java-tests/testData/codeInsight/completion/normal/ClassTypeParameters.java
new file mode 100644 (file)
index 0000000..5659211
--- /dev/null
@@ -0,0 +1,3 @@
+class Koo {}
+public class FooMap<K,V> implements YourMapInterface<K<caret>, V> {
+}
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ClassTypeParametersGenericBounds.java b/java/java-tests/testData/codeInsight/completion/normal/ClassTypeParametersGenericBounds.java
new file mode 100644 (file)
index 0000000..5e58f5d
--- /dev/null
@@ -0,0 +1,3 @@
+class Koo{}
+public class FooMap<K,V extends K<caret>> {
+}
diff --git a/java/java-tests/testData/codeInsight/completion/normal/LocalClassName.java b/java/java-tests/testData/codeInsight/completion/normal/LocalClassName.java
new file mode 100644 (file)
index 0000000..d2a3886
--- /dev/null
@@ -0,0 +1,6 @@
+public class FooMap<K,V extends K> implements YourMapInterface<K, V> {
+  void foo() {
+    class Zoooooooo {}
+    Zoo<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/LocalClassName_after.java b/java/java-tests/testData/codeInsight/completion/normal/LocalClassName_after.java
new file mode 100644 (file)
index 0000000..82b2d2e
--- /dev/null
@@ -0,0 +1,6 @@
+public class FooMap<K,V extends K> implements YourMapInterface<K, V> {
+  void foo() {
+    class Zoooooooo {}
+    Zoooooooo<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/LocalClassTwice.java b/java/java-tests/testData/codeInsight/completion/normal/LocalClassTwice.java
new file mode 100644 (file)
index 0000000..3396c28
--- /dev/null
@@ -0,0 +1,7 @@
+class Zooooo {}
+public class FooMap<K,V extends K> implements YourMapInterface<K, V> {
+  void foo() {
+    class Zoooz implements Runnable {}
+    Runnable r = new Zo<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/LocalTopLevelConflict.java b/java/java-tests/testData/codeInsight/completion/normal/LocalTopLevelConflict.java
new file mode 100644 (file)
index 0000000..daa47c1
--- /dev/null
@@ -0,0 +1,8 @@
+class Zoooz {}
+class Zooooo {}
+public class FooMap<K,V extends K> implements YourMapInterface<K, V> {
+  void foo() {
+    class Zoooz implements Runnable {}
+    Runnable r = new Zo<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoConstructorTailWhenNoPairBracket-out.java b/java/java-tests/testData/codeInsight/completion/smartType/NoConstructorTailWhenNoPairBracket-out.java
new file mode 100644 (file)
index 0000000..0ac5842
--- /dev/null
@@ -0,0 +1,5 @@
+class A {
+  {
+    String c = new String(<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoConstructorTailWhenNoPairBracket.java b/java/java-tests/testData/codeInsight/completion/smartType/NoConstructorTailWhenNoPairBracket.java
new file mode 100644 (file)
index 0000000..f05c021
--- /dev/null
@@ -0,0 +1,5 @@
+class A {
+  {
+    String c = new Stri<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket-out.java b/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket-out.java
new file mode 100644 (file)
index 0000000..6d72b12
--- /dev/null
@@ -0,0 +1,6 @@
+class A {
+  {
+    String x;
+    Class c = x.getClass(<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket.java b/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket.java
new file mode 100644 (file)
index 0000000..d90fbae
--- /dev/null
@@ -0,0 +1,6 @@
+class A {
+  {
+    String x;
+    Class c = x.getCl<caret>
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket2-out.java b/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket2-out.java
new file mode 100644 (file)
index 0000000..5dbeaa6
--- /dev/null
@@ -0,0 +1,7 @@
+class A {
+  {
+    Class c = this.xxxxx(<caret>
+  }
+
+  Class xxxxx() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket2.java b/java/java-tests/testData/codeInsight/completion/smartType/NoTailWhenNoPairBracket2.java
new file mode 100644 (file)
index 0000000..31d1d65
--- /dev/null
@@ -0,0 +1,7 @@
+class A {
+  {
+    Class c = this.xx<caret>
+  }
+
+  Class xxxxx() {}
+}
\ No newline at end of file
index 7b9a2bceb7db75bf81c95d0ff4aac9fae2d40e7f..2d29970dbc02201c9ee61eb90ee10c49c08b80a3 100644 (file)
@@ -478,4 +478,13 @@ public class Test {
 }
 
 class W<T> {}
-class P<L> {}
\ No newline at end of file
+class P<L> {}
+
+// IDEA-62529
+class Refx<T> {
+    Class<? super T> get() { return null; }
+    boolean f() {
+      if (get() == Enum.class) return false;
+      return (Class<Enum>)get() == Enum.class;
+    }
+}
index 3977b8c3cbb2cfadaa8755332bac04ddc8277dbb..b5659849377b9eae96d5e8e14010970e8b24826f 100644 (file)
@@ -346,7 +346,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
   }
 
   public void testExcessSpaceInTypeCast() throws Throwable {
-   configureByFile(getTestName(false) + ".java");
+   configure()
    selectItem(myItems[0]);
    checkResult()
   }
@@ -363,6 +363,28 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
     doTest();
   }
 
+  public void testLocalClassName() throws Throwable { doTest(); }
+
+  public void testClassTypeParameters() throws Throwable {
+    configure()
+    assert 'K' in myFixture.lookupElementStrings
+  }
+
+  public void testClassTypeParametersGenericBounds() throws Throwable {
+    configure()
+    assert 'K' in myFixture.lookupElementStrings
+  }
+
+  public void testLocalClassTwice() throws Throwable {
+    configure()
+    assertOrderedEquals myFixture.lookupElementStrings, 'Zoooz', 'Zooooo'
+  }
+
+  public void testLocalTopLevelConflict() throws Throwable {
+    configure()
+    assertOrderedEquals myFixture.lookupElementStrings, 'Zoooz', 'Zooooo'
+  }
+
   public void testMethodParenthesesSpaces() throws Throwable {
     final settings = CodeStyleSettingsManager.getSettings(getProject())
     settings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true
index 6c8181b467989eeccdc5e3649f4b8af82a18ca27..d00328d0b1b7b87cf5f2cd0591bf8e0234854950 100644 (file)
@@ -477,6 +477,29 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
 
   public void testSameNamedFieldAndLocal() throws Throwable { doTest(); }
 
+  public void testNoTailWhenNoPairBracket() throws Throwable {
+    doTestNoPairBracket();
+  }
+
+  public void testNoTailWhenNoPairBracket2() throws Throwable {
+    doTestNoPairBracket();
+  }
+
+  private void doTestNoPairBracket() throws Exception {
+    boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET;
+    CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = false;
+    try {
+      doTest();
+    }
+    finally {
+      CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = old;
+    }
+  }
+
+  public void testNoConstructorTailWhenNoPairBracket() throws Throwable {
+    doTestNoPairBracket();
+  }
+
   public void testAbstractClassTwice() throws Throwable {
     configureByTestName();
     assertOneElement(myItems);
index 5dbc7024806ac86910b2b85c304dcd21c01c0444..57bd038f57e04df0ca6f08f20f8977547ba32150 100644 (file)
@@ -45,4 +45,8 @@ public interface TldAttributeDescriptor extends XmlAttributeDescriptor {
    */
   @Nullable
   String getType();
+
+  boolean isDeferred();
+
+  boolean isDynamic();
 }
index 4ee177217e5751e1cea228a4b614c099eb37182a..6028e2bfb1c36fc76f34e2f2392b272e5edc05ba 100644 (file)
@@ -45,7 +45,6 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.impl.source.PostprocessReformattingAspect;
@@ -241,7 +240,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase {
                 }
               }));
 
-            VirtualFileManager.getInstance().refresh(false);
+            toDir.refresh(false, true);
           }
           else {
             editorInfos = new LinkedHashMap<VirtualFile, EditorInfo>();
index 79e032879c8f14f57393595a69e66cc8cb365ac9..629c98c6cf17b6ab5e6c45448127a08b290214bf 100644 (file)
@@ -55,8 +55,8 @@ public class LoadingOrder {
   @NonNls private final String myName; // for debug only
   private final boolean myFirst;
   private final boolean myLast;
-  private final Set<String> myBefore = new HashSet<String>();
-  private final Set<String> myAfter = new HashSet<String>();
+  private final Set<String> myBefore = new HashSet<String>(2);
+  private final Set<String> myAfter = new HashSet<String>(2);
 
   private LoadingOrder() {
     myName = "ANY";
@@ -117,12 +117,19 @@ public class LoadingOrder {
   }
 
   public static void sort(final Orderable[] orderables) {
+    // our graph is pretty sparse so do benefit from the fact
     final Map<String,Orderable> map = new HashMap<String, Orderable>();
-    for (final Orderable orderable : orderables) {
-      final String id = orderable.getOrderId();
-      if (StringUtil.isNotEmpty(id)) {
-        map.put(id, orderable);
-      }
+    final HashMap<Orderable, LoadingOrder> cachedMap = new HashMap<Orderable, LoadingOrder>(orderables.length);
+    final HashSet<Orderable> first = new HashSet<Orderable>(1);
+    final HashSet<Orderable> hasBefore = new HashSet<Orderable>(orderables.length);
+
+    for(Orderable o:orderables) {
+      final String id = o.getOrderId();
+      if (StringUtil.isNotEmpty(id)) map.put(id, o);
+      LoadingOrder order = o.getOrder();
+      cachedMap.put(o, order);
+      if (order.myFirst) first.add(o);
+      if (order.myBefore.size() != 0) hasBefore.add(o);
     }
 
     DFSTBuilder<Orderable> builder = new DFSTBuilder<Orderable>(new GraphGenerator<Orderable>(new CachingSemiGraph<Orderable>(new GraphGenerator.SemiGraph<Orderable>() {
@@ -133,7 +140,7 @@ public class LoadingOrder {
       }
 
       public Iterator<Orderable> getIn(final Orderable n) {
-        final LoadingOrder order = n.getOrder();
+        final LoadingOrder order = cachedMap.get(n);
 
         Set<Orderable> predecessors = new LinkedHashSet<Orderable>();
         for (final String id : order.myAfter) {
@@ -144,14 +151,30 @@ public class LoadingOrder {
         }
 
         String id = n.getOrderId();
-        for (final Orderable orderable : orderables) {
-          final LoadingOrder hisOrder = orderable.getOrder();
-          if (StringUtil.isNotEmpty(id) && hisOrder.myBefore.contains(id) ||
-              order.myLast && !hisOrder.myLast ||
-              hisOrder.myFirst && !order.myFirst) {
+        if (StringUtil.isNotEmpty(id)) {
+          for (final Orderable orderable : hasBefore) {
+            final LoadingOrder hisOrder = cachedMap.get(orderable);
+            if (hisOrder.myBefore.contains(id)) {
+              predecessors.add(orderable);
+            }
+          }
+        }
+
+        if (order.myLast) {
+          for (final Orderable orderable : orderables) {
+            final LoadingOrder hisOrder = cachedMap.get(orderable);
+            if (!hisOrder.myLast) {
+              predecessors.add(orderable);
+            }
+          }
+        }
+
+        if (!order.myFirst) {
+          for(Orderable orderable:first) {
             predecessors.add(orderable);
           }
         }
+
         return predecessors.iterator();
       }
     })));
similarity index 98%
rename from platform/lang-impl/src/com/intellij/openapi/projectRoots/ui/PathEditor.java
rename to platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java
index 270797fd916859635f02ef77f052b5ce21808dbc..04335e58083894eb0538d94deca4452cc804fd1c 100644 (file)
@@ -22,7 +22,7 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileChooser.FileChooser;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
-import com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl;
+import com.intellij.openapi.fileChooser.FileChooserDialog;
 import com.intellij.openapi.fileTypes.FileTypeManager;
 import com.intellij.openapi.fileTypes.FileTypes;
 import com.intellij.openapi.project.Project;
@@ -85,7 +85,7 @@ public class PathEditor {
     myDisplayName = displayName;
     myOrderRootType = orderRootType;
     myDescriptor = descriptor;
-    myDescriptor.putUserData(FileChooserDialogImpl.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE);
+    myDescriptor.putUserData(FileChooserDialog.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE);
     myModel = createListModel();
   }
 
similarity index 96%
rename from java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/OrderRootTypeUIFactory.java
rename to platform/lang-api/src/com/intellij/openapi/roots/ui/OrderRootTypeUIFactory.java
index 60a0c9f74c1ab150434bd5594d0f6d964282e10e..11e8c96a42751639edb283a570b379931e98a0e0 100644 (file)
@@ -18,7 +18,7 @@
  * User: anna
  * Date: 26-Dec-2007
  */
-package com.intellij.openapi.roots.ui.configuration;
+package com.intellij.openapi.roots.ui;
 
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.projectRoots.ui.PathEditor;
index 0e73b7db715d2f86b94278fae7d9ab2733e3136c..4a1f82d7903d91a3adf2ac3f07620f731678f9d5 100644 (file)
@@ -1,6 +1,7 @@
 package com.intellij.psi.search;
 
 import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFileSystemItem;
 import com.intellij.psi.PsiReference;
 import com.intellij.util.Processor;
 import com.intellij.util.containers.CollectionFactory;
@@ -28,7 +29,8 @@ public class SearchRequestCollector {
   }
 
   public void searchWord(@NotNull String word, @NotNull SearchScope searchScope, boolean caseSensitive, @NotNull PsiElement searchTarget) {
-    final short searchContext = UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_COMMENTS;
+    final short searchContext = (short)(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_COMMENTS
+                                | (searchTarget instanceof PsiFileSystemItem ? UsageSearchContext.IN_STRINGS : 0));
     searchWord(word, searchScope, searchContext, caseSensitive, searchTarget);
   }
 
index 7e147ae691c6792d0710c9361d22a7491bfbc0df..ac32823613bede0dbc015c45cd4136062f74ec83 100644 (file)
@@ -18,11 +18,14 @@ package com.intellij.codeInsight.daemon.impl;
 
 import com.intellij.ide.util.PsiElementListCellRenderer;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.openapi.ui.popup.PopupChooserBuilder;
 import com.intellij.psi.NavigatablePsiElement;
 import com.intellij.psi.PsiElement;
 import com.intellij.ui.awt.RelativePoint;
 import com.intellij.ui.components.JBList;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.event.MouseEvent;
@@ -34,35 +37,44 @@ public class PsiElementListNavigator {
   }
 
   public static void openTargets(MouseEvent e, NavigatablePsiElement[] targets, String title, ListCellRenderer listRenderer) {
-    if (targets.length == 0) return;
-    if (targets.length == 1){
+    JBPopup popup = navigateOrCreatePopup(targets, title, listRenderer);
+    if (popup != null) popup.show(new RelativePoint(e));
+  }
+
+  public static void openTargets(Editor e, NavigatablePsiElement[] targets, String title, ListCellRenderer listRenderer) {
+    JBPopup popup = navigateOrCreatePopup(targets, title, listRenderer);
+    if (popup != null) popup.showInBestPositionFor(e);
+  }
+
+  @Nullable
+  private static JBPopup navigateOrCreatePopup(NavigatablePsiElement[] targets, String title, ListCellRenderer listRenderer) {
+    if (targets.length == 0) return null;
+    if (targets.length == 1) {
       targets[0].navigate(true);
+      return null;
     }
-    else{
-      final JList list = new JBList(targets);
-      list.setCellRenderer(listRenderer);
+    final JList list = new JBList(targets);
+    list.setCellRenderer(listRenderer);
 
-      final PopupChooserBuilder builder = new PopupChooserBuilder(list);
-      if (listRenderer instanceof PsiElementListCellRenderer) {
-        ((PsiElementListCellRenderer)listRenderer).installSpeedSearch(builder);
-      }
+    final PopupChooserBuilder builder = new PopupChooserBuilder(list);
+    if (listRenderer instanceof PsiElementListCellRenderer) {
+      ((PsiElementListCellRenderer)listRenderer).installSpeedSearch(builder);
+    }
 
-      builder.
-        setTitle(title).
-        setMovable(true).
-        setItemChoosenCallback(new Runnable() {
-          public void run() {
-            int[] ids = list.getSelectedIndices();
-            if (ids == null || ids.length == 0) return;
-            Object [] selectedElements = list.getSelectedValues();
-            for (Object element : selectedElements) {
-              PsiElement selected = (PsiElement) element;
-              LOG.assertTrue(selected.isValid());
-              ((NavigatablePsiElement)selected).navigate(true);
-            }
+    return builder.
+      setTitle(title).
+      setMovable(true).
+      setItemChoosenCallback(new Runnable() {
+        public void run() {
+          int[] ids = list.getSelectedIndices();
+          if (ids == null || ids.length == 0) return;
+          Object[] selectedElements = list.getSelectedValues();
+          for (Object element : selectedElements) {
+            PsiElement selected = (PsiElement)element;
+            LOG.assertTrue(selected.isValid());
+            ((NavigatablePsiElement)selected).navigate(true);
           }
-        }).createPopup().
-        show(new RelativePoint(e));
-    }
+        }
+      }).createPopup();
   }
 }
index 928fae196e76efe691f7e33defa476f950eda977..b587487b740a53138c0320a104bab91f813bf0d7 100644 (file)
@@ -35,6 +35,7 @@ import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.util.PsiUtilBase;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.List;
@@ -56,7 +57,7 @@ public class BackspaceHandler extends EditorWriteActionHandler {
     Project project = PlatformDataKeys.PROJECT.getData(dataContext);
     if (project == null) return false;
 
-    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
+    PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
 
     if (file == null) return false;
 
index e08c4a7d677e63946cc82ebda4b1e6bde768e5f9..0bc22bbeea7c4538ddeb75de7ce818053f45ee6c 100644 (file)
@@ -1668,11 +1668,28 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
     nextAction.getTemplatePresentation().setText(getNextOccurenceActionName());
 
     final AnAction switchSoftWrapsAction = new ToggleUseSoftWrapsToolbarAction(SoftWrapAppliancePlaces.CONSOLE) {
+
+      /**
+       * There is a possible case that more than console is open and user toggles soft wraps mode at one of them. We want
+       * to update another console(s) representation as well when they are switched on after that. Hence, we remember last 
+       * used soft wraps mode and perform update if we see that the current value differs from the stored.
+       */
+      private boolean myLastIsSelected;
+      
       @Override
       protected Editor getEditor(AnActionEvent e) {
         return myEditor;
       }
 
+      @Override
+      public boolean isSelected(AnActionEvent e) {
+        boolean result = super.isSelected(e);
+        if (result ^ myLastIsSelected) {
+          setSelected(null, result);
+        }
+        return myLastIsSelected = result;
+      }
+
       @Override
       public void setSelected(AnActionEvent e, final boolean state) {
         super.setSelected(e, state);
index cc2634acbba23d83a06b794ef8c682a7b2b37088..bbcd092946fffa41ffb0207c2119e5ae1b2e5c46 100644 (file)
@@ -19,10 +19,7 @@ package com.intellij.ide.favoritesTreeView.actions;
 import com.intellij.ide.IdeBundle;
 import com.intellij.ide.favoritesTreeView.FavoritesManager;
 import com.intellij.ide.favoritesTreeView.FavoritesTreeViewPanel;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 
@@ -53,16 +50,23 @@ public class DeleteAllFavoritesListsButThisAction extends AnAction implements Du
 
   public void update(AnActionEvent e) {
     final DataContext dataContext = e.getDataContext();
-    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+    final Presentation presentation = e.getPresentation();
     if (project == null){
-      e.getPresentation().setEnabled(false);
+      presentation.setEnabled(false);
       return;
     }
-    String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
-    e.getPresentation().setEnabled(listName != null);
+    final String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
+    presentation.setEnabled(false);
     if (listName != null) {
-      e.getPresentation().setText(IdeBundle.message("action.delete.all.favorites.lists.but.this",listName));
-      e.getPresentation().setDescription(IdeBundle.message("action.delete.all.favorites.lists.but.this",listName));
+      final String[] favoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesLists();
+      if (listName.equals(project.getName())) {
+        presentation.setEnabled(favoritesLists.length > 1);
+      }  else {
+        presentation.setEnabled(favoritesLists.length > 2);
+      }
+      presentation.setText(IdeBundle.message("action.delete.all.favorites.lists.but.this", listName));
+      presentation.setDescription(IdeBundle.message("action.delete.all.favorites.lists.but.this", listName));
     }
   }
 }
index c2766e432d5ca480c9c3625aadd96aeb6bcfecc6..603dd40885512d1e02c893a9a4fe4f4329bc335a 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.ide.scriptingContext.ui;
 import com.intellij.ide.scriptingContext.LangScriptingContextProvider;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.scripting.ScriptingLibraryManager;
 import com.intellij.openapi.roots.libraries.scripting.ScriptingLibraryTable;
 import com.intellij.ui.table.JBTable;
@@ -97,7 +96,7 @@ public class ScriptingLibrariesPanel extends ScriptingLibrariesPanelStub {
     EditLibraryDialog editLibDialog = new EditLibraryDialog("New Library", myProvider, myProject);
     editLibDialog.show();
     if (editLibDialog.isOK()) {
-      myLibTableModel.createLibrary(editLibDialog.getLibName(), editLibDialog.getSourceFiles(), editLibDialog.getCompactFiles());
+      myLibTableModel.createLibrary(editLibDialog.getLibName(), editLibDialog.getSourceFiles(), editLibDialog.getCompactFiles(), null);
     }
   }
 
@@ -129,7 +128,8 @@ public class ScriptingLibrariesPanel extends ScriptingLibrariesPanelStub {
       EditLibraryDialog editLibDialog = new EditLibraryDialog("Edit Library", myProvider, myProject, lib);
       editLibDialog.show();
       if (editLibDialog.isOK()) {
-        myLibTableModel.updateLibrary(libName, editLibDialog.getLibName(), editLibDialog.getSourceFiles(), editLibDialog.getCompactFiles());
+        myLibTableModel
+          .updateLibrary(libName, editLibDialog.getLibName(), editLibDialog.getSourceFiles(), editLibDialog.getCompactFiles(), null);
       }
     }
   }
index d136891b233890db2c2ed38d96e9cfc3fa99c12a..bb71c9a61d188c8d5c91d4cca7e6b41c40b13421 100644 (file)
@@ -75,11 +75,11 @@ public class ScriptingLibraryTableModel extends AbstractTableModel {
     return "?";
   }
 
-  public void createLibrary(final String name, final VirtualFile[] sourceFiles, final VirtualFile[] compactFiles) {
+  public void createLibrary(final String name, final VirtualFile[] sourceFiles, final VirtualFile[] compactFiles, final String[] docUrls) {
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       @Override
       public void run() {
-        ScriptingLibraryTable.LibraryModel lib = myLibraryManager.createLibrary(name, sourceFiles, compactFiles);
+        ScriptingLibraryTable.LibraryModel lib = myLibraryManager.createLibrary(name, sourceFiles, compactFiles, docUrls);
         if (lib != null) {
           fireLibTableChanged();
         }
@@ -100,11 +100,15 @@ public class ScriptingLibraryTableModel extends AbstractTableModel {
     }
   }
 
-  public void updateLibrary(final String oldName, final String name, final VirtualFile[] sourceFiles, final VirtualFile[] compactFiles) {
+  public void updateLibrary(final String oldName,
+                            final String name,
+                            final VirtualFile[] sourceFiles,
+                            final VirtualFile[] compactFiles,
+                            final String[] docUrls) {
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       @Override
       public void run() {
-        myLibraryManager.updateLibrary(oldName, name, sourceFiles, compactFiles);
+        myLibraryManager.updateLibrary(oldName, name, sourceFiles, compactFiles, docUrls);
         fireLibTableChanged();
       }
     });
index 205f71cabad885e06d1d2b327da4d727302c5475..15d216e15ff143123d75188dcb1888a6491b2ed3 100644 (file)
@@ -29,9 +29,18 @@ import java.util.List;
  */
 public class GlobalPathReferenceProvider implements PathReferenceProvider {
 
-  @NonNls private static final String MAILTO_PREFIX = "mailto:";
-  @NonNls private static final String TEL_PREFIX = "tel:";
-  @NonNls private static final String SMS_PREFIX = "sms:";
+  @NonNls private static final String[] PREFIXES = new String[] {
+    "mailto:", "tel:", "sms:", "skype:", "data:"
+  };
+
+  private static boolean startsWithAllowedPrefix(String s) {
+    for (String prefix : PREFIXES) {
+      if (s.startsWith(prefix)) {
+        return true;
+      }
+    }
+    return false;
+  }
 
   public boolean createReferences(@NotNull PsiElement psiElement, final @NotNull List<PsiReference> references, final boolean soft) {
     final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(psiElement);
@@ -40,7 +49,7 @@ public class GlobalPathReferenceProvider implements PathReferenceProvider {
     }
     final TextRange range = manipulator.getRangeInElement(psiElement);
     final String s = range.substring(psiElement.getText());
-    if (s.contains("://") || s.startsWith(MAILTO_PREFIX) || s.startsWith(TEL_PREFIX) || s.startsWith(SMS_PREFIX) || s.startsWith("//")) {
+    if (s.contains("://") || s.startsWith("//") || startsWithAllowedPrefix(s)) {
       final PsiReference reference = PsiReferenceBase.createSelfReference(psiElement, psiElement);
       references.add(reference);
       return true;
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocOrderRootType.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocOrderRootType.java
new file mode 100644 (file)
index 0000000..f35dfe2
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.libraries.doc;
+
+import com.intellij.openapi.roots.OrderRootType;
+import com.intellij.openapi.roots.PersistentOrderRootType;
+
+public class DocOrderRootType extends PersistentOrderRootType {
+  
+  private DocOrderRootType() {
+    super("DOCUMENTATION", "docPath", "doc-paths", "docPathEntry");
+  }
+
+  public static OrderRootType getInstance() {
+    return getOrderRootType(DocOrderRootType.class);
+  }
+
+  public boolean collectFromDependentModules() {
+    return true;
+  }
+}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocOrderRootTypeUIFactory.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocOrderRootTypeUIFactory.java
new file mode 100644 (file)
index 0000000..9ba6a01
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.libraries.doc;
+
+import com.intellij.openapi.project.ProjectBundle;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.projectRoots.ui.PathEditor;
+import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory;
+import com.intellij.openapi.util.IconLoader;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+/**
+ * @author Rustam Vishnyakov
+ */
+public class DocOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
+  private static final Icon ICON = IconLoader.getIcon("/nodes/javaDocFolder.png");
+
+  @Nullable
+  public PathEditor createPathEditor(Sdk sdk) {
+    return null;
+  }
+
+  @Override
+  public Icon getIcon() {
+    return ICON;
+  }
+
+  @Override
+  public String getNodeText() {
+    return ProjectBundle.message("library.docs.node");
+  }
+
+}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocUrlChooser.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/doc/DocUrlChooser.java
new file mode 100644 (file)
index 0000000..2555806
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.libraries.doc;
+
+import com.intellij.openapi.project.ProjectBundle;
+import com.intellij.openapi.ui.InputValidator;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author Rustam Vishnyakov
+ */
+public class DocUrlChooser {
+
+  private DocUrlChooser() {
+  }
+
+  @Nullable
+  public static VirtualFile showSpecifyDocUrlDialog(JComponent parent) {
+    return showSpecifyDocUrlDialog(parent, "");
+  }
+
+  @Nullable
+  public static VirtualFile showSpecifyDocUrlDialog(JComponent parent, String initialValue) {
+    final String url = Messages.showInputDialog(parent, ProjectBundle.message("sdk.configure.javadoc.url.prompt"),
+                                                ProjectBundle.message("sdk.configure.javadoc.url.title"), Messages.getQuestionIcon(),
+                                                initialValue, new InputValidator() {
+        public boolean checkInput(String inputString) {
+          return true;
+        }
+
+        public boolean canClose(String inputString) {
+          try {
+            new URL(inputString);
+            return true;
+          }
+          catch (MalformedURLException e1) {
+            Messages.showErrorDialog(e1.getMessage(), ProjectBundle.message("sdk.configure.javadoc.url.title"));
+          }
+          return false;
+        }
+      });
+    if (url == null) {
+      return null;
+    }
+    return VirtualFileManager.getInstance().findFileByUrl(url);
+  }
+}
index 2787547bc91128a8b51b31cb295b8b355515515a..21f87d865d8e071a3581d85e116247acf690221b 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
 import com.intellij.openapi.roots.libraries.LibraryType;
+//import com.intellij.openapi.roots.libraries.doc.DocOrderRootType;
 import com.intellij.openapi.util.EmptyRunnable;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.Nullable;
@@ -61,8 +62,7 @@ public class ScriptingLibraryManager {
       LibraryTable libTable = getLibraryTable();
       if (libTable != null) {
         LibraryTable.ModifiableModel libTableModel = libTable.getModifiableModel();
-        updateLibraries(libTableModel, OrderRootType.SOURCES);
-        updateLibraries(libTableModel, OrderRootType.CLASSES);
+        updateLibraries(libTableModel);
         libTableModel.commit();
       }
       myLibTable = null;
@@ -80,7 +80,8 @@ public class ScriptingLibraryManager {
     });
   }
 
-  private void updateLibraries(LibraryTable.ModifiableModel libTableModel, OrderRootType rootType) {
+  private void updateLibraries(LibraryTable.ModifiableModel libTableModel) {
+    //final OrderRootType docRootType = DocOrderRootType.getInstance(); 
     for (Library library : libTableModel.getLibraries()) {
       ScriptingLibraryTable.LibraryModel scriptingLibModel = myLibTable.getLibraryByName(library.getName());
       if (scriptingLibModel == null) {
@@ -88,12 +89,14 @@ public class ScriptingLibraryManager {
       }
       else {
         Library.ModifiableModel libModel = library.getModifiableModel();
-        for (VirtualFile libRoot : libModel.getFiles(rootType)) {
-          libModel.removeRoot(libRoot.getUrl(), rootType);
-        }
-        for (VirtualFile newRoot : scriptingLibModel.getFiles(rootType)) {
-          libModel.addRoot(newRoot, rootType);
+        removeRoots(libModel, OrderRootType.CLASSES);
+        removeRoots(libModel, OrderRootType.SOURCES);
+        /*
+        for (String docUrl : libModel.getUrls(DocOrderRootType.getInstance())) {
+          libModel.removeRoot(docUrl, docRootType);
         }
+        */
+        addAllRoots(libModel, scriptingLibModel);
         libModel.commit();
       }
     }
@@ -102,22 +105,48 @@ public class ScriptingLibraryManager {
       if (library == null && libTableModel instanceof LibraryTableBase.ModifiableModelEx) {
         library = ((LibraryTableBase.ModifiableModelEx)libTableModel).createLibrary(scriptingLibModel.getName(), myLibraryType);
         Library.ModifiableModel libModel = library.getModifiableModel();
-        for (VirtualFile newRoot : scriptingLibModel.getFiles(rootType)) {
-          libModel.addRoot(newRoot, rootType);
-        }
+        addAllRoots(libModel, scriptingLibModel);
         libModel.commit();
       }
     }
   }
+  
+  private static void removeRoots(Library.ModifiableModel libModel, OrderRootType rootType) {
+    for (VirtualFile libRoot : libModel.getFiles(rootType)) {
+      libModel.removeRoot(libRoot.getUrl(), rootType);
+    }
+  }
+
+  private static void addAllRoots(Library.ModifiableModel libModel, ScriptingLibraryTable.LibraryModel srcModel) {
+    //final OrderRootType docRootType = DocOrderRootType.getInstance();
+    addRoots(libModel, srcModel, OrderRootType.CLASSES);
+    addRoots(libModel, srcModel, OrderRootType.SOURCES);
+    /*
+    for (String docUrl : srcModel.getDocUrls()) {
+      libModel.addRoot(docUrl, docRootType);
+    }
+    */
+  }
+
+  private static void addRoots(Library.ModifiableModel libModel,
+                                  ScriptingLibraryTable.LibraryModel srcModel,
+                                  OrderRootType rootType) {    
+    for (VirtualFile newRoot : srcModel.getFiles(rootType)) {
+      libModel.addRoot(newRoot, rootType);
+    }
+  }
 
   public void reset() {
     myLibTable = null;
   }
 
   @Nullable
-  public ScriptingLibraryTable.LibraryModel createLibrary(String name, VirtualFile[] sourceFiles, VirtualFile[] compactFiles) {
+  public ScriptingLibraryTable.LibraryModel createLibrary(String name,
+                                                          VirtualFile[] sourceFiles,
+                                                          VirtualFile[] compactFiles,
+                                                          String[] docUrls) {
     if (ensureModel()) {
-      return myLibTable.createLibrary(name, sourceFiles, compactFiles);
+      return myLibTable.createLibrary(name, sourceFiles, compactFiles, docUrls);
     }
     return null;
   }
@@ -146,13 +175,14 @@ public class ScriptingLibraryManager {
     }
   }
 
-  public void updateLibrary(String oldName, String name, VirtualFile[] sourceFiles, VirtualFile[] compactFiles) {
+  public void updateLibrary(String oldName, String name, VirtualFile[] sourceFiles, VirtualFile[] compactFiles, String[] docUrls) {
     if (ensureModel()) {
       ScriptingLibraryTable.LibraryModel libModel = myLibTable.getLibraryByName(oldName);
       if (libModel != null) {
         libModel.setName(name);
         libModel.setSourceFiles(sourceFiles);
         libModel.setCompactFiles(compactFiles);
+        libModel.setDocUrls(docUrls);
         myLibTable.invalidateCache();
       }
     }
@@ -230,4 +260,10 @@ public class ScriptingLibraryManager {
     assert myLibTable != null;
     return myLibTable.isLibraryFile(file);
   }
+  
+  public String[] getDocUrlsFor(VirtualFile file) {
+    ensureModel();
+    assert myLibTable != null;
+    return myLibTable.getDocUrlsFor(file);
+  }
 }
index a6affe84ad320830c01eca141e29fb00e90c4d67..bb03f0f9e727a241c7bd98b026df31ed56c52668 100644 (file)
@@ -20,7 +20,9 @@ import com.intellij.openapi.roots.impl.libraries.LibraryEx;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
 import com.intellij.openapi.roots.libraries.LibraryType;
+import com.intellij.openapi.roots.libraries.doc.DocOrderRootType;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.ArrayUtil;
 import com.intellij.util.containers.HashSet;
 import com.intellij.util.containers.hash.HashMap;
 import org.jetbrains.annotations.NotNull;
@@ -28,6 +30,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Set;
 
 /**
  * @author Rustam Vishnyakov
@@ -49,6 +52,7 @@ public class ScriptingLibraryTable {
           LibraryModel libModel = new LibraryModel(library.getName());
           libModel.setSourceFiles(library.getFiles(SOURCE_ROOT_TYPE));
           libModel.setCompactFiles(library.getFiles(COMPACT_ROOT_TYPE));
+          //libModel.setDocUrls(library.getUrls(DocOrderRootType.getInstance()));  // TODO: Rustam, write tests first!
           myLibraryModels.add(libModel);
         }
       }
@@ -62,6 +66,16 @@ public class ScriptingLibraryTable {
     return false;
   }
 
+  public String[] getDocUrlsFor(VirtualFile file) {
+    Set<String> urls = new HashSet<String>();
+    for (LibraryModel libraryModel : myLibraryModels) {
+      if (libraryModel.containsFile(file)) {
+        urls.addAll(Arrays.asList(libraryModel.getDocUrls()));
+      }
+    }
+    return ArrayUtil.toStringArray(urls);
+  }
+
   public boolean isCompactFile(VirtualFile file) {
     if (myCompactFilesCache == null) {
       myCompactFilesCache = new HashSet<VirtualFile>();
@@ -113,8 +127,8 @@ public class ScriptingLibraryTable {
     return libModel;
   }
 
-  public LibraryModel createLibrary(String libName, VirtualFile[] sourceFiles, VirtualFile[] compactFiles) {
-    LibraryModel libModel = new LibraryModel(libName, sourceFiles, compactFiles);
+  public LibraryModel createLibrary(String libName, VirtualFile[] sourceFiles, VirtualFile[] compactFiles, String[] docUrls) {
+    LibraryModel libModel = new LibraryModel(libName, sourceFiles, compactFiles, docUrls);
     myLibraryModels.add(libModel);
     invalidateCache();
     return libModel;
@@ -138,11 +152,13 @@ public class ScriptingLibraryTable {
     private String myName;
     private ArrayList<VirtualFile> mySourceFiles = new ArrayList<VirtualFile>();
     private ArrayList<VirtualFile> myCompactFiles = new ArrayList<VirtualFile>();
+    private ArrayList<String> myDocUrls = new ArrayList<String>(); 
 
-    public LibraryModel(String name, VirtualFile[] sourceFiles, VirtualFile[] compactFiles) {
+    public LibraryModel(String name, VirtualFile[] sourceFiles, VirtualFile[] compactFiles, String[] docUrls) {
       this(name);
       mySourceFiles.addAll(Arrays.asList(sourceFiles));
       myCompactFiles.addAll(Arrays.asList(compactFiles));
+      myDocUrls.addAll(Arrays.asList(docUrls));
     }
 
     public LibraryModel(String name) {
@@ -162,6 +178,11 @@ public class ScriptingLibraryTable {
       myCompactFiles.clear();
       myCompactFiles.addAll(Arrays.asList(files));
     }
+    
+    public void setDocUrls(String[] docUrls) {
+      myDocUrls.clear();
+      myDocUrls.addAll(Arrays.asList(docUrls));
+    }
 
     public VirtualFile[] getSourceFiles() {
       return mySourceFiles.toArray(new VirtualFile[mySourceFiles.size()]);
@@ -170,6 +191,10 @@ public class ScriptingLibraryTable {
     public VirtualFile[] getCompactFiles() {
       return myCompactFiles.toArray(new VirtualFile[myCompactFiles.size()]);
     }
+    
+    public String[] getDocUrls() {
+      return ArrayUtil.toStringArray(myDocUrls);
+    }
 
     @NotNull
     public VirtualFile[] getFiles(OrderRootType rootType) {
index 87173afe0f7e7282cebbff7f58698aed493a47ce..ee68ffffac2ebe2eff02af29c03b0be17fae44e8 100644 (file)
@@ -604,7 +604,9 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
     final IElementType contentElementType = getContentElementType();
     if (!(contentElementType instanceof IStubFileElementType)) {
       throw new AssertionError("A stub in a non-stub file '" + vFile +"'; isValid()=" + vFile.isValid() +
-                               " type: "+contentElementType+"; content:<<<\n"+
+                               " type: "+contentElementType+";" +
+                               " StubUpdatingIndex.canHaveStub(vFile)=" + StubUpdatingIndex.canHaveStub(vFile) + 
+                               " content:<<<\n"+
                                StringUtil.first(getViewProvider().getContents(),200,true)+
                                "\n>>>; stubs=" + stubHolder.getPlainList());
     }
index 6de47a442bf51e362577bd20b0a05947c15f12d3..af780a7e45358009d03bdcafc40a0679201bfaa8 100644 (file)
@@ -139,8 +139,7 @@ public class FileReferenceSet {
   public FileReferenceSet(final @NotNull PsiElement element) {
 
     myElement = element;
-    final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(element);
-    final TextRange range = manipulator.getRangeInElement(element);
+    TextRange range = ElementManipulators.getValueTextRange(element);
     myStartInElement = range.getStartOffset();
     final String s = range.substring(element.getText());
     myPathString = s.trim();
index 0ce4f8939d2755c3d3a75667c5f474b5507b482b..b8ae62e88c84c18ae2e150ff2535c3fee498f69d 100644 (file)
@@ -30,7 +30,11 @@ public class AstBufferUtil {
   }
 
   public static int toBuffer(ASTNode element, char[] buffer, int offset, TokenSet skipTypes) {
-    if (element instanceof ForeignLeafPsiElement || skipTypes != null && skipTypes.contains(element.getElementType())) return offset;
+    if (element instanceof ForeignLeafPsiElement ||
+        skipTypes != null && skipTypes.contains(element.getElementType())) {
+      return offset;
+    }
+
     if (element instanceof LeafElement) {
       return ((LeafElement)element).copyTo(buffer, offset);
     }
index 527b438002e86aeba341e40867bb101053d5a07a..5d3a7f9af145043d84df23b69a5977741531b954 100644 (file)
@@ -196,7 +196,7 @@ public class CompositeElement extends TreeElement {
   @NotNull
   public char[] textToCharArray() {
     char[] buffer = new char[getTextLength()];
-    AstBufferUtil.toBuffer(this, buffer, 0);
+    walkCopyingText(buffer);
     return buffer;
   }
 
@@ -404,10 +404,10 @@ public class CompositeElement extends TreeElement {
     if (myCachedLength != NOT_CACHED) {
       throw new AssertionError("Before walking: cached="+myCachedLength);
     }
-    TreeElement cur = this;
 
+    TreeElement cur = this;
     while (cur != null) {
-      cur = next(cur, cur.getCachedLength() == NOT_CACHED);
+      cur = next(cur, cur.getCachedLength() == NOT_CACHED, true);
     }
 
     if (myCachedLength < 0) {
@@ -415,8 +415,23 @@ public class CompositeElement extends TreeElement {
     }
   }
 
+  private void walkCopyingText(char[] buffer) {
+    if (TreeUtil.isCollapsedChameleon(this)) {
+      AstBufferUtil.toBuffer(this, buffer, 0);
+      return;
+    }
+
+    int offset = 0;
+    TreeElement cur = this;
+    while ((cur = next(cur, cur instanceof CompositeElement && !TreeUtil.isCollapsedChameleon(cur), false)) != null) {
+      if (cur instanceof LeafElement || TreeUtil.isCollapsedChameleon(cur)) {
+        offset = AstBufferUtil.toBuffer(cur, buffer, offset);
+      }
+    }
+  }
+
   @Nullable
-  private TreeElement next(TreeElement cur, boolean down) {
+  private TreeElement next(TreeElement cur, boolean down, boolean update) {
     if (down) {
       CompositeElement composite = (CompositeElement)cur; // It's a composite or we won't be going down
       TreeElement child = composite.firstChild;
@@ -425,15 +440,19 @@ public class CompositeElement extends TreeElement {
         return child;
       }
 
-      composite.myCachedLength = 0;
+      if (update) {
+        composite.myCachedLength = 0;
+      }
     }
 
     // up
     while (cur != this) {
       CompositeElement parent = cur.getTreeParent();
       int curLength = cur.getCachedLength();
-      LOG.assertTrue(curLength != NOT_CACHED, cur);
-      parent.myCachedLength -= curLength;
+      if (update) {
+        LOG.assertTrue(curLength != NOT_CACHED, cur);
+        parent.myCachedLength -= curLength;
+      }
 
       TreeElement next = cur.getTreeNext();
       if (next != null) {
@@ -442,7 +461,9 @@ public class CompositeElement extends TreeElement {
       }
 
       LOG.assertTrue(parent.lastChild == cur, parent);
-      parent.myCachedLength = -parent.myCachedLength + NOT_CACHED;
+      if (update) {
+        parent.myCachedLength = -parent.myCachedLength + NOT_CACHED;
+      }
 
       cur = parent;
     }
@@ -450,7 +471,6 @@ public class CompositeElement extends TreeElement {
     return null;
   }
 
-
   public TreeElement getFirstChildNode() {
     return firstChild;
   }
index 0182f9bb65f136463c65cfa9497ab4a47aa09b4d..61ff917339221c4ba2a6e92b59c0ab56b6174940 100644 (file)
@@ -186,15 +186,13 @@ public class LazyParseableElement extends CompositeElement {
     if (parsedNode != null) {
       rawAddChildren((TreeElement)parsedNode);
 
-      /*
-      if (getTextLength() != text.length()) {
-        if (ApplicationManagerEx.getApplicationEx().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) {
-          LOG.error("Inconsistent reparse: type=" + getElementType() + "; text=" + text + "; treeText=" + getText());
-        } else {
-          LOG.error("Inconsistent reparse: type=" + getElementType());
-        }
-      }
-      */
+      //if (getNotCachedLength() != text.length()) {
+      //  if (ApplicationManagerEx.getApplicationEx().isInternal()) {
+      //    LOG.error("Inconsistent reparse: type=" + getElementType() + "; text=" + text + "; treeText=" + getText());
+      //  } else {
+      //    LOG.error("Inconsistent reparse: type=" + getElementType());
+      //  }
+      //}
 
       //ensure PSI is created all at once, to reduce contention of PsiLock in CompositeElement.getPsi()
       ((TreeElement)parsedNode).acceptTree(CREATE_PSI);
index 0c5124caf70b69d9f2b86d3e104bc616858cd0c8..841019a7b91fab03c44cfe5ed3493a8e15285bcc 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.openapi.editor.colors.EditorColors;
 import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.ex.EditorEx;
 import com.intellij.openapi.editor.markup.TextAttributes;
-import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.progress.ProcessCanceledException;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.DialogWrapper;
@@ -65,16 +64,18 @@ public abstract class CallerChooserBase<M extends PsiElement> extends DialogWrap
   private Editor myCallerEditor;
   private Editor myCalleeEditor;
   private boolean myInitDone;
+  private final String myFileName;
 
   protected abstract MethodNodeBase<M> createTreeNode(M method, HashSet<M> called, Runnable cancelCallback);
 
   protected abstract M[] findDeepestSuperMethods(M method);
 
-  public CallerChooserBase(M method, Project project, String title, Tree previousTree, Consumer<Set<M>> callback) {
+  public CallerChooserBase(M method, Project project, String title, Tree previousTree, String fileName, Consumer<Set<M>> callback) {
     super(true);
     myMethod = method;
     myProject = project;
     myTree = previousTree;
+    myFileName = fileName;
     myCallback = callback;
     setTitle(title);
     init();
@@ -204,7 +205,7 @@ public abstract class CallerChooserBase<M extends PsiElement> extends DialogWrap
     final EditorFactory editorFactory = EditorFactory.getInstance();
     final Document document = editorFactory.createDocument("");
     final Editor editor = editorFactory.createViewer(document, myProject);
-    ((EditorEx)editor).setHighlighter(HighlighterFactory.createHighlighter(myProject, StdFileTypes.JAVA));
+    ((EditorEx)editor).setHighlighter(HighlighterFactory.createHighlighter(myProject, myFileName));
     return editor;
   }
 
index c03611f3fc18d759cd4f53a0dd4cc676dc1064a0..1252c7940f2db70224c4f0178005136279cd9bb7 100644 (file)
@@ -280,7 +280,7 @@ public class RenameDialog extends RefactoringDialog {
   @Override
   protected void canRun() throws ConfigurationException {
     if (!areButtonsValid()) {
-      throw new ConfigurationException("\'" + StringUtil.first(getNewName(), 10, true) + "\' is invalid identifier");
+      throw new ConfigurationException("\'" + getNewName() + "\' is invalid identifier");
     }
   }
 
index 3e6b1d5ede864be2eb77a0e0a1cea721836010ee..adb4f94525e7458a0381c15fe0096990cc703330 100644 (file)
@@ -60,7 +60,6 @@ import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.TextOccurrencesUtil;
 import com.intellij.usageView.UsageInfo;
-import com.intellij.util.Consumer;
 import com.intellij.util.PairProcessor;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.util.containers.Stack;
@@ -77,13 +76,13 @@ import java.util.*;
  */
 public class VariableInplaceRenamer {
   public static final Key<VariableInplaceRenamer> INPLACE_RENAMER = Key.create("EditorInplaceRenamer");
-  private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.inplace.VariableInplaceRenamer");
+  protected static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.inplace.VariableInplaceRenamer");
   public static final LanguageExtension<ResolveSnapshotProvider> INSTANCE = new LanguageExtension<ResolveSnapshotProvider>(
     "com.intellij.rename.inplace.resolveSnapshotProvider"
   );
 
   private final PsiNamedElement myElementToRename;
-  @NonNls private static final String PRIMARY_VARIABLE_NAME = "PrimaryVariable";
+  @NonNls protected static final String PRIMARY_VARIABLE_NAME = "PrimaryVariable";
   @NonNls private static final String OTHER_VARIABLE_NAME = "OtherVariable";
   private ArrayList<RangeHighlighter> myHighlighters;
   private final Editor myEditor;
@@ -104,10 +103,10 @@ public class VariableInplaceRenamer {
   }
 
   public boolean performInplaceRename() {
-    return performInplaceRename(true, null, null);
+    return performInplaceRename(true, null);
   }
 
-  public boolean performInplaceRename(boolean processTextOccurrences, LinkedHashSet<String> nameSuggestions, final Consumer<Boolean> moveOffsetAfterr) {
+  public boolean performInplaceRename(boolean processTextOccurrences, LinkedHashSet<String> nameSuggestions) {
     if (InjectedLanguageUtil.isInInjectedLanguagePrefixSuffix(myElementToRename)) {
       return false;
     }
@@ -231,16 +230,12 @@ public class VariableInplaceRenamer {
                 if (myNewName != null) {
                   performAutomaticRename(myNewName, PsiTreeUtil.getParentOfType(containingFile.findElementAt(renameOffset), PsiNameIdentifierOwner.class));
                 }
-                if (moveOffsetAfterr != null) {
-                  moveOffsetAfterr.consume(true);
-                }
+                moveOffsetAfter(true);
               }
 
               public void templateCancelled(Template template) {
                 finish();
-                if (moveOffsetAfterr != null) {
-                  moveOffsetAfterr.consume(false);
-                }
+                moveOffsetAfter(false);
               }
             });
 
@@ -272,6 +267,9 @@ public class VariableInplaceRenamer {
     return true;
   }
 
+  protected void moveOffsetAfter(boolean success) {
+  }
+
   protected void addAdditionalVariables(TemplateBuilderImpl builder) {
   }
 
@@ -444,6 +442,10 @@ public class VariableInplaceRenamer {
     }
   }
 
+  protected LookupElement[] createLookupItems(final LookupElement[] lookupItems, final String name) {
+    return lookupItems;
+  }
+
   private class MyExpression extends Expression {
     private final String myName;
     private final LookupElement[] myLookupItems;
@@ -464,7 +466,7 @@ public class VariableInplaceRenamer {
     }
 
     public LookupElement[] calculateLookupItems(ExpressionContext context) {
-      return myLookupItems;
+      return createLookupItems(myLookupItems, myName);
     }
 
     public Result calculateQuickResult(ExpressionContext context) {
index d642879ca7068caaf6e9095774b1622d2631edb8..6a291c62749a35e3cb7d6d3fcec8cb34fbdbeac9 100644 (file)
@@ -1034,6 +1034,7 @@ public class PluginManager {
         printWriter.close();
       }
     }
+    ourDisabledPlugins = null;
   }
 
   public static List<String> getDisabledPlugins() {
index fd9cd175e1d7dded93347da455a166bad5732688..fa0ee6ac53575694406a6ff874a32b9e355f9d41 100644 (file)
 package com.intellij.openapi.actionSystem.ex;
 
 import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.ui.popup.ListPopup;
 import com.intellij.openapi.util.IconLoader;
@@ -37,6 +34,7 @@ import java.beans.PropertyChangeListener;
 public abstract class ComboBoxAction extends AnAction implements CustomComponentAction {
   private static final Icon ARROW_ICON = IconLoader.getIcon("/general/comboArrow.png");
   private static final Icon DISABLED_ARROW_ICON = IconLoader.getDisabledIcon(ARROW_ICON);
+  private DataContext myDataContext;
 
   protected ComboBoxAction() {
   }
@@ -52,6 +50,12 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
     return panel;
   }
 
+  @Override
+  public void update(AnActionEvent e) {
+    super.update(e);
+    myDataContext = e.getDataContext();
+  }
+
   @NotNull
   protected abstract DefaultActionGroup createPopupActionGroup(JComponent button);
 
@@ -120,7 +124,10 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
 
     protected ListPopup createPopup(Runnable onDispose) {
       DefaultActionGroup group = createPopupActionGroup(this);
-      final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(),
+
+      DataContext context = myDataContext == null ? DataManager.getInstance().getDataContext() : myDataContext;
+      myDataContext = null;
+      final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, context,
                                                                                   JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false,
                                                                                   onDispose,
                                                                                   getMaxRows());
index 093cb03e0fbdf67dbd3314f7bfc6999d16460668..b02fd0a3624ac3e24e28b99a60602745b50b2832 100644 (file)
  */
 package com.intellij.openapi.fileChooser;
 
+import com.intellij.openapi.actionSystem.DataKey;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 public interface FileChooserDialog {
+  DataKey<Boolean> PREFER_LAST_OVER_TO_SELECT = DataKey.create("PREFER_LAST_OVER_TO_SELECT");
+  
   @NotNull
   VirtualFile[] choose(@Nullable VirtualFile toSelect, @Nullable Project project);
 }
\ No newline at end of file
index de996b51f16e4c8e9f71afac37a69b9c64a4fe2e..9afc2823fda90544f03e40176f850b884d8bc0e0 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.ui;
 
-import com.intellij.openapi.wm.impl.content.GraphicsConfig;
 import com.intellij.util.ui.UIUtil;
 
 import javax.swing.*;
@@ -82,13 +81,9 @@ public class SeparatorWithText extends JComponent {
       g.drawLine(0, lineY, lineX, lineY);
       g.drawLine(lineX + fontWidth, lineY, getWidth() - 1, lineY);
 
-      final GraphicsConfig config = new GraphicsConfig(g);
-      config.setAntialiasing(true);
-
+      UIUtil.applyRenderingHints(g);
       g.setColor(GroupedElementsRenderer.POPUP_SEPARATOR_TEXT_FOREGROUND);
       g.drawString(myCaption, lineX + HGAP, baseline);
-
-      config.restore();
     }
     else {
       g.drawLine(0, VGAP, getWidth() - 1, VGAP);
index c8cf28106d5857cae96a2caef257c6d05a7a7534..73c9c83df60371278fecb0657acd90656efda3ed 100644 (file)
@@ -758,6 +758,12 @@ public class HintManagerImpl extends HintManager implements Disposable {
       final HintInfo info = myHintsStack.get(i);
       if (!info.hint.isVisible()) {
         myHintsStack.remove(i);
+        
+        // We encountered situation when 'hint' instances use 'hide()' method as object destruction callback
+        // (e.g. LineTooltipRenderer creates hint that overrides keystroke of particular action that produces hint and
+        // de-registers it inside 'hide()'. That means that the hint can 'stuck' to old editor location if we just remove
+        // it but don't call hide())
+        info.hint.hide();
         continue;
       }
 
@@ -777,6 +783,12 @@ public class HintManagerImpl extends HintManager implements Disposable {
         final HintInfo info = myHintsStack.get(i);
         if (!info.hint.isVisible()) {
           myHintsStack.remove(i);
+          
+          // We encountered situation when 'hint' instances use 'hide()' method as object destruction callback
+          // (e.g. LineTooltipRenderer creates hint that overrides keystroke of particular action that produces hint and
+          // de-registers it inside 'hide()'. That means that the hint can 'stuck' to old editor location if we just remove
+          // it but don't call hide())
+          info.hint.hide();
           continue;
         }
 
index 1e1c86eb743b8fdb2b33ef4c5cd18dbb3368ef7e..de8004badbe484cf1031b4bd888754f4dfc300b5 100644 (file)
@@ -24,13 +24,13 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.application.ApplicationInfo;
 import com.intellij.openapi.application.ApplicationNamesInfo;
 import com.intellij.openapi.application.ex.ApplicationInfoEx;
+import com.intellij.openapi.application.impl.ApplicationInfoImpl;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.openapi.wm.WindowManager;
-import com.intellij.openapi.wm.impl.content.GraphicsConfig;
 import com.intellij.ui.LicenseeInfoProvider;
 import com.intellij.util.ImageLoader;
 import com.intellij.util.ui.UIUtil;
@@ -101,7 +101,7 @@ public class AboutAction extends AnAction implements DumbAware {
 
     final long showTime = System.currentTimeMillis();
     //final long delta = Patches.APPLE_BUG_ID_3716865 ? 100 : 0;
-    final long delta = 100; //reproducible on Windows too
+    final long delta = 500; //reproducible on Windows too
 
     dialog.addWindowFocusListener(new WindowFocusListener() {
       public void windowGainedFocus(WindowEvent e) {
@@ -182,7 +182,7 @@ public class AboutAction extends AnAction implements DumbAware {
       setOpaque(false);
       //col = new Color(0xfa, 0xfa, 0xfa, 200);
       col = Color.white;
-      linkCol = Color.blue;
+      linkCol = ApplicationInfoImpl.getInstanceEx().getLogoTextColor();
       setBackground(col);
       ApplicationInfoEx ideInfo = (ApplicationInfoEx)ApplicationInfo.getInstance();
       Calendar cal = ideInfo.getBuildDate();
@@ -249,8 +249,7 @@ public class AboutAction extends AnAction implements DumbAware {
     protected void paintChildren(Graphics g) {
       super.paintChildren(g);
       Graphics2D g2 = (Graphics2D)g;
-      GraphicsConfig config = new GraphicsConfig(g2);
-      config.setAntialiasing(true);
+      UIUtil.applyRenderingHints(g);
 
       Font labelFont = UIUtil.getLabelFont();
       for (int labelSize = 10; labelSize != 6; labelSize -= 1) {
@@ -269,8 +268,6 @@ public class AboutAction extends AnAction implements DumbAware {
         catch (TextRenderer.OverflowException ignore) {
         }
       }
-
-      config.restore();
     }
 
     public class TextRenderer {
index c15a469c89154b16973b5a73a2e7264280b87654..b1c9ac1ed33b82c2c383d99be93872eca5a0c2fb 100644 (file)
@@ -159,7 +159,10 @@ public class DnDManagerImpl extends DnDManager implements DnDEvent.DropTargetHig
 
     if (currentEvent == null) return currentEvent;
 
-    currentEvent.updateAction(getDnDActionForPlatformAction(nativeAction));
+    final DnDAction dndAction = getDnDActionForPlatformAction(nativeAction);
+    if (dndAction == null) return null;
+
+    currentEvent.updateAction(dndAction);
     currentEvent.setPoint(aPoint);
     currentEvent.setHandlerComponent(aComponentOverDragging);
 
index cc6be708344bb011d80c4fa114eb51483c09be67..3183a619b1ff95692336f7c8af9bf0abf964a9ef 100644 (file)
@@ -66,6 +66,7 @@ public class IgnoreWhiteSpacesAction extends ComboBoxAction implements DumbAware
   }
 
   public void update(AnActionEvent e) {
+    super.update(e);
     Presentation presentation = e.getPresentation();
     DiffPanelEx diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
     if (diffPanel != null && diffPanel.getComponent().isDisplayable()) {
index 148286f8984cc72786f05bd24133fc7df88976a5..595aaebb4ffdb82132685334c8c4eb31eac3fcad 100644 (file)
@@ -87,7 +87,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
   private Color myBackgroundColor = null;
   private GutterDraggableObject myGutterDraggableObject;
   private String myLastGutterToolTip = null;
-
+  private int myLastPreferredHeight = -1;
 
   public EditorGutterComponentImpl(EditorImpl editor) {
     myEditor = editor;
@@ -105,7 +105,8 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
 
   public Dimension getPreferredSize() {
     int w = getLineNumberAreaWidth() + getLineMarkerAreaWidth() + getFoldingAreaWidth() + getAnnotationsAreaWidth();
-    return new Dimension(w, myEditor.getPreferredHeight());
+    myLastPreferredHeight = myEditor.getPreferredHeight();
+    return new Dimension(w, myLastPreferredHeight);
   }
 
   protected void setUI(ComponentUI newUI) {
@@ -421,7 +422,9 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
     int oldAnnotationsWidth = myTextAnnotationGuttersSize;
     calcIconAreaWidth();
     calcAnnotationsSize();
-    if (oldIconsWidth != myLineMarkerAreaWidth || oldAnnotationsWidth != myTextAnnotationGuttersSize) {
+    if (oldIconsWidth != myLineMarkerAreaWidth || oldAnnotationsWidth != myTextAnnotationGuttersSize
+        || myLastPreferredHeight != myEditor.getPreferredHeight()) 
+    {
       fireResized();
     }
     repaint();
index c679aa02718b3c8248217d27789bc3f212d4e742..6ee2170e30973a934cac6f53cbe5d49f8d6d4892 100644 (file)
@@ -1071,6 +1071,14 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
 
   // optimization: do not do column calculations here since we are interested in line number only
   public int offsetToVisualLine(int offset) {
+    int textLength = getDocument().getTextLength();
+    if (offset >= textLength) {
+      int result = getVisibleLineCount();
+      if (textLength > 0 && getDocument().getCharsSequence().charAt(textLength - 1) == '\n') {
+        result++;
+      }
+      return result;
+    }
     int line = calcLogicalLineNumber(offset);
     int lineStartOffset = myDocument.getLineStartOffset(line);
     int result = logicalToVisualLine(line);
@@ -4476,6 +4484,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
           getFoldingModel().runBatchFoldingOperation(processor);
           y = myGutterComponent.getHeadCenterY(range);
           getScrollingModel().scrollVertically(y - scrollShift);
+          myGutterComponent.updateSize();
           return;
         }
       }
index c0c81b1e9976592b9adaae763caa40a012354c25..7799c6888ebe8a4fc34739397aca5323cf7c7f8e 100644 (file)
@@ -56,9 +56,6 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
 
   private static final Logger LOG = Logger.getInstance("#" + SoftWrapModelImpl.class.getName());
 
-  /** Upper boundary of time interval to check editor settings. */
-  private static final long EDITOR_SETTINGS_CHECK_PERIOD_MILLIS = 10000;
-
   private final OffsetToLogicalTask   myOffsetToLogicalTask   = new OffsetToLogicalTask();
   private final VisualToLogicalTask   myVisualToLogicalTask   = new VisualToLogicalTask();
   private final LogicalToVisualTask   myLogicalToVisualTask   = new LogicalToVisualTask();
@@ -77,9 +74,7 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
   private final EditorEx myEditor;
   /** Holds number of 'active' calls, i.e. number of methods calls of the current object within the current call stack. */
   private int myActive;
-  /** Holds timestamp of the last editor settings check. */
-  private long myLastSettingsCheckTimeMillis;
-  private Boolean myLastUseSoftWraps;
+  private boolean myUseSoftWraps;
 
   public SoftWrapModelImpl(@NotNull EditorEx editor) {
     this(editor, new SoftWrapsStorage(), new CompositeSoftWrapPainter(editor));
@@ -115,13 +110,18 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
     myDocumentListeners.add(myApplianceManager);
     myFoldListeners.add(myApplianceManager);
     applianceManager.addListener(myVisualSizeManager);
+    myUseSoftWraps = myEditor.getSettings().isUseSoftWraps();
   }
 
   /**
    * Called on editor settings change. Current model is expected to drop all cached information about the settings if any.
    */
   public void reinitSettings() {
-    myLastUseSoftWraps = null;
+    boolean softWrapsUsedBefore = myUseSoftWraps;
+    myUseSoftWraps = myEditor.getSettings().isUseSoftWraps();
+    if (myUseSoftWraps && !softWrapsUsedBefore) {
+      myApplianceManager.reset();
+    }
   }
 
   public boolean isSoftWrappingEnabled() {
@@ -140,13 +140,7 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
       return false;
     }
 
-    // Profiling shows that editor settings lookup have impact at overall performance if called often.
-    // Hence, we cache value used last time.
-    if (myLastUseSoftWraps != null && System.currentTimeMillis() - myLastSettingsCheckTimeMillis <= EDITOR_SETTINGS_CHECK_PERIOD_MILLIS) {
-      return myLastUseSoftWraps == Boolean.TRUE;
-    }
-    myLastSettingsCheckTimeMillis = System.currentTimeMillis();
-    return myLastUseSoftWraps = myEditor.getSettings().isUseSoftWraps();
+    return myUseSoftWraps;
   }
 
   @Nullable
@@ -523,10 +517,6 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
     myStorage.removeAll();
   }
 
-  public void refreshSettings() {
-    myLastSettingsCheckTimeMillis = 0;
-  }
-
   public SoftWrapApplianceManager getApplianceManager() {
     return myApplianceManager;
   }
@@ -553,7 +543,8 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
           task, myDataMapper, myEditor.getDocument().getText(), Arrays.toString(myEditor.getFoldingModel().fetchTopLevel())), e);
       }
       myDataMapper.release();
-      myApplianceManager.release();
+      myApplianceManager.reset();
+      myStorage.removeAll();
       try {
         task.run(true);
       }
index 59f85397958436f46bbd0ec035619b9b68c7152f..3feff609a59cf5c84d84f9ee52c9b814245ee8d2 100644 (file)
@@ -110,14 +110,14 @@ abstract class AbstractMappingStrategy<T> implements MappingStrategy<T> {
   }
 
   @Nullable
-  protected FoldingData getFoldRegionData(FoldRegion foldRegion) {
+  protected FoldingData getFoldRegionData(@NotNull FoldRegion foldRegion) {
     int i = MappingUtil.getCacheEntryIndexForOffset(foldRegion.getStartOffset(), myEditor.getDocument(), myCache);
     if (i < 0 || i >= myCache.size()) {
       return null;
     }
 
     CacheEntry cacheEntry = myCache.get(i);
-    return cacheEntry.getFoldingData().get(foldRegion.getStartOffset());
+    return cacheEntry.getFoldingData(foldRegion);
   }
 
   @Override
@@ -155,7 +155,7 @@ abstract class AbstractMappingStrategy<T> implements MappingStrategy<T> {
   protected abstract T buildIfExceeds(EditorPosition position, int offset);
 
   @Override
-  public T processFoldRegion(EditorPosition position, FoldRegion foldRegion) {
+  public T processFoldRegion(EditorPosition position, @NotNull FoldRegion foldRegion) {
     T result = buildIfExceeds(position, foldRegion);
     if (result != null) {
       return result;
index 93c32cfcf8d3682e93310906e3df69a7069cbcf8..4c0d8590905b1e6548a3ee3fbaeb11dcf2495ef2 100644 (file)
@@ -18,9 +18,12 @@ package com.intellij.openapi.editor.impl.softwrap.mapping;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.FoldRegion;
 import com.intellij.openapi.editor.impl.EditorTextRepresentationHelper;
+import com.intellij.openapi.util.Ref;
 import gnu.trove.TIntObjectHashMap;
 import gnu.trove.TIntObjectProcedure;
+import gnu.trove.TObjectProcedure;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -129,8 +132,29 @@ class CacheEntry implements Comparable<CacheEntry>, Cloneable {
     return result;
   }
 
-  public TIntObjectHashMap<FoldingData> getFoldingData() {
-    return myFoldingData;
+  @Nullable
+  public FoldingData getFoldingData(@NotNull final FoldRegion region) {
+    FoldingData candidate = myFoldingData.get(region.getStartOffset());
+    if (candidate != null) {
+      return candidate;
+    }
+    
+    // Folding implementation is known to postpone actual fold region offsets update on document change, i.e. it performs
+    // fold data caching with its further replace by up-to-date info. Hence, there is a possible case that soft wraps processing
+    // advances fold region offset but folding model still provides old cached values. Hence, we're trying to match exact given
+    // fold region against the cached data here.
+    final Ref<FoldingData> result = new Ref<FoldingData>();
+    myFoldingData.forEachValue(new TObjectProcedure<FoldingData>() {
+      @Override
+      public boolean execute(FoldingData data) {
+        if (data.getFoldRegion().equals(region)) {
+          result.set(data);
+          return false;
+        }
+        return true;
+      }
+    });
+    return result.get();
   }
   
   public void store(FoldRegion foldRegion, int startX) {
index 821958c115a7477eb6e6aaa80cd763160d73fd81..871ac6f811143fe9e0670cf0fc9eaa105d85286d 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.FoldRegion;
 import com.intellij.openapi.editor.impl.EditorTextRepresentationHelper;
+import org.jetbrains.annotations.NotNull;
 
 /**
  * Caches information about number of logical columns inside the collapsed single line folding.
@@ -31,7 +32,9 @@ class FoldingData {
   private final EditorTextRepresentationHelper myRepresentationHelper;
   private final FoldRegion myFoldRegion;
 
-  FoldingData(FoldRegion foldRegion, int startX, EditorTextRepresentationHelper representationHelper, Editor editor) {
+  FoldingData(@NotNull FoldRegion foldRegion, int startX, @NotNull EditorTextRepresentationHelper representationHelper,
+              @NotNull Editor editor) 
+  {
     myFoldRegion = foldRegion;
     this.startX = startX;
     myRepresentationHelper = representationHelper;
@@ -48,4 +51,9 @@ class FoldingData {
 
     return widthInColumns;
   }
+
+  @NotNull
+  public FoldRegion getFoldRegion() {
+    return myFoldRegion;
+  }
 }
index dd8e67bc13ae886c077f8bf9919aae3a53d925b3..3c2fae1645a99c26454d5c505c7ce804712662aa 100644 (file)
@@ -92,7 +92,7 @@ interface MappingStrategy<T> {
    *                      <code>null</code> otherwise
    */
   @Nullable
-  T processFoldRegion(EditorPosition position, FoldRegion foldRegion);
+  T processFoldRegion(EditorPosition position, @NotNull FoldRegion foldRegion);
 
   /**
    * Notifies current strategy that tabulation symbols is encountered during the processing. Tabulation symbols
index 46ade313a82dc4cd3f727dfb866370457bbad036..1e1f076c5044757240ca47d660b16de88b175965 100644 (file)
@@ -80,7 +80,6 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
   private boolean myCustomIndentUsedLastTime;
   private int myCustomIndentValueUsedLastTime;
   private int myVisibleAreaWidth;
-  private long myLastDocumentStamp;
   private boolean myInProgress;
 
   public SoftWrapApplianceManager(@NotNull SoftWrapsStorage storage,
@@ -100,9 +99,13 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
     recalculateIfNecessary();
   }
 
-  public void release() {
+  public void reset() {
     myEventsStorage.release();
     myEventsStorage.add(myEditor.getDocument(), new IncrementalCacheUpdateEvent(myEditor.getDocument()));
+  }
+  
+  public void release() {
+    myEventsStorage.release();
     myLineWrapPositionStrategy = null;
   }
 
@@ -112,7 +115,6 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
       return;
     }
 
-    myLastDocumentStamp = myEditor.getDocument().getModificationStamp();
     // There is a possible case that new dirty regions are encountered during processing, hence, we iterate on regions snapshot here.
     List<IncrementalCacheUpdateEvent> events = new ArrayList<IncrementalCacheUpdateEvent>(myEventsStorage.getEvents());
     myEventsStorage.release();
@@ -586,18 +588,12 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
     myContext.softWrapStartOffset = softWrap.getStart() + 1;
   }
 
-  public void recalculateIfNecessary() {
-    recalculateIfNecessary(myEditor.getDocument().getModificationStamp());
-  }
-
   /**
    * There is a possible case that we need to reparse the whole document (e.g. visible area width is changed or user-defined
    * soft wrap indent is changed etc). This method encapsulates that logic, i.e. it checks if necessary conditions are satisfied
    * and updates internal state as necessary.
-   *
-   * @param documentStamp     document modification stamp to use if document was changed while soft wrapping was off
    */
-  public void recalculateIfNecessary(long documentStamp) {
+  public void recalculateIfNecessary() {
     if (myInProgress) {
       return;
     }
@@ -615,14 +611,13 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
 
     // Check if we need to recalculate soft wraps due to visible area width change.
     int currentVisibleAreaWidth = myWidthProvider.getVisibleAreaWidth();
-    if (!indentChanged && myVisibleAreaWidth == currentVisibleAreaWidth && documentStamp == myLastDocumentStamp) {
+    if (!indentChanged && myVisibleAreaWidth == currentVisibleAreaWidth) {
       recalculateSoftWraps(); // Recalculate existing dirty regions if any.
       return;
     }
 
     // Drop information about processed lines then.
-    myEventsStorage.release();
-    myEventsStorage.add(myEditor.getDocument(), new IncrementalCacheUpdateEvent(myEditor.getDocument()));
+    reset();
     myStorage.removeAll();
     myVisibleAreaWidth = currentVisibleAreaWidth;
     recalculateSoftWraps();
@@ -748,7 +743,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
 
   @Override
   public void documentChanged(DocumentEvent event) {
-    recalculateIfNecessary(event.getOldTimeStamp());
+    recalculateIfNecessary();
   }
 
   /**
index c14395735dd360e1b4f1c89b1ab6f8b9fd33d287..6c2e09619520fddd578d00c2d50a5264ce808c96 100644 (file)
@@ -60,8 +60,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
-public class FileChooserDialogImpl extends DialogWrapper implements FileChooserDialog, FileLookup {
-  public static final DataKey<Boolean> PREFER_LAST_OVER_TO_SELECT = DataKey.create("PREFER_LAST_OVER_TO_SELECT");
+public class FileChooserDialogImpl extends DialogWrapper implements FileChooserDialog, FileLookup {  
 
   private final FileChooserDescriptor myChooserDescriptor;
   protected FileSystemTreeImpl myFileSystemTree;
index a7d0e33cc23c8d1ca17e9370e2ef89de79625225..0e5ddb0581de935db41c87c802c9e82e6f08eb3a 100644 (file)
@@ -22,10 +22,10 @@ import com.intellij.openapi.components.RoamingType;
 import com.intellij.openapi.components.ServiceBean;
 import com.intellij.openapi.components.SettingsSavingComponent;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 
@@ -33,7 +33,7 @@ public class SchemesManagerFactoryImpl extends SchemesManagerFactory implements
 
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.options.SchemesManagerFactoryImpl");
 
-  private final Collection<SchemesManagerImpl> myRegisteredManagers = new ArrayList<SchemesManagerImpl>();
+  private final Collection<SchemesManagerImpl> myRegisteredManagers = ContainerUtil.createEmptyCOWList();
 
   public <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(final String fileSpec,
                                                                    final SchemeProcessor<E> processor, final RoamingType roamingType) {
index e278ac8bf522130fda4f830fbe3a4347ab814090..a3b6a47d239d978b6a25c6c3d1fe22d746f3945c 100644 (file)
@@ -21,11 +21,9 @@ import com.intellij.openapi.components.ApplicationComponent;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.impl.win32.Win32LocalFileSystem;
 import com.intellij.openapi.vfs.newvfs.ManagingFS;
 import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
 import com.intellij.openapi.vfs.newvfs.RefreshQueue;
@@ -122,14 +120,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
     if (myWatcher.isOperational()) {
       new StoreRefreshStatusThread().start();
     }
-    if (SystemInfo.isWindows &&
-        Win32LocalFileSystem.isAvailable() &&
-        Registry.is("filesystem.useNative")) {
-      myNativeFileSystem = null; //Win32LocalFileSystem.getWin32Instance();
-    }
-    else {
-      myNativeFileSystem = null;
-    }
+    myNativeFileSystem = null;
   }
 
   public void initComponent() {
@@ -153,11 +144,12 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
       }
     }
 
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
-      public void run() {
-        refresh(false);
-      }
-    });
+    // grand VFS refresh significantly slows down local tests and generally not needed
+    //ApplicationManager.getApplication().runWriteAction(new Runnable() {
+    //  public void run() {
+    //    refresh(false);
+    //  }
+    //});
 
     myRootsToWatch.clear();
 
index a563348289de93065016334896373f28c26e8cdd..f99c7a08f57d9404243f8bab2ab406b6eb2f799a 100644 (file)
@@ -53,8 +53,7 @@ public class Splash extends JDialog {
 
   public static boolean showLicenseeInfo(Graphics g, int x, int y, final int height, final Color textColor) {
     if (ApplicationInfoImpl.getShadowInstance().showLicenseeInfo()) {
-      GraphicsConfig config = new GraphicsConfig(g);
-      config.setAntialiasing(true);
+      UIUtil.applyRenderingHints(g);
       g.setFont(new Font(UIUtil.ARIAL_FONT_NAME, Font.BOLD, 11));
       g.setColor(textColor);
       LicenseeInfoProvider provider = LicenseeInfoProvider.getInstance();
@@ -64,7 +63,6 @@ public class Splash extends JDialog {
         g.drawString(licensedToMessage, x + 21, y + height - 49);
         g.drawString(licenseRestrictionsMessage, x + 21, y + height - 33);
       }
-      config.restore();
       return true;
     }
     return false;
diff --git a/platform/platform-impl/src/com/intellij/util/io/ByteBufferIntObjectMap.java b/platform/platform-impl/src/com/intellij/util/io/ByteBufferIntObjectMap.java
deleted file mode 100644 (file)
index 1b5a16b..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-import gnu.trove.TIntArrayList;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.IOException;
-
-public class ByteBufferIntObjectMap<V> {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.ByteBufferMap");
-
-  private final RandomAccessDataInput myBuffer;
-  private final int myStartOffset;
-  private final ByteBufferMap.ValueProvider<V> myValueProvider;
-  private int myMod;
-  private final int myEndOffset;
-
-  public ByteBufferIntObjectMap(@NotNull MappedBufferWrapper buffer,
-                       int startOffset,
-                       int endOffset,
-                       @NotNull ByteBufferMap.ValueProvider<V> valueProvider) {
-    assert startOffset < endOffset;
-
-    myBuffer = new ByteBufferRADataInput(buffer);
-    myStartOffset = startOffset;
-    myEndOffset = endOffset;
-    myValueProvider = valueProvider;
-
-    myBuffer.setPosition(startOffset);
-    try {
-      myMod = myBuffer.readInt();
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-  }
-
-  public V get(int key) {
-    int hash = hash(key);
-    int keyGroupOffset = readKeyGroupOffset(hash);
-    if (keyGroupOffset == -1) return null;
-    if (!(myStartOffset < keyGroupOffset && keyGroupOffset < myEndOffset)){
-      LOG.error("keyGroupOffset = " + keyGroupOffset + " myStartOffset = " + myStartOffset + " myEndOffset = " + myEndOffset);
-    }
-
-    try {
-      myBuffer.setPosition(keyGroupOffset);
-      int keyGroupSize = myBuffer.readInt();
-      assert (keyGroupSize > 0);
-      for (int i = 0; i < keyGroupSize; i++) {
-        if (key == myBuffer.readInt()) {
-          int valueOffset = myBuffer.readInt();
-          assert (valueOffset > 0);
-
-          myBuffer.setPosition(myStartOffset + valueOffset);
-          return myValueProvider.get(myBuffer);
-        }
-        else {
-          myBuffer.readInt(); //read offset;
-        }
-      }
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-
-    return null;
-  }
-
-  public TIntArrayList getKeys() {
-    TIntArrayList result = new TIntArrayList();
-    getKeys(result);
-    return result;
-  }
-
-  public void getKeys(TIntArrayList dst) {
-    try {
-      myBuffer.setPosition(myStartOffset + 4 /* mod */);
-
-      int firstKeyGroupOffset = -1;
-      int lastKeyGroupOffset = -1;
-      for (int i = 0; i < myMod; i++) {
-        int value = myBuffer.readInt();
-        if (value != -1) {
-          int offset = value + myStartOffset;
-          if (firstKeyGroupOffset == -1) firstKeyGroupOffset = offset;
-          lastKeyGroupOffset = offset;
-        }
-      }
-      if (firstKeyGroupOffset == -1) {
-        return;
-      }
-      assert (firstKeyGroupOffset > myStartOffset);
-      assert (lastKeyGroupOffset > myStartOffset);
-      assert (lastKeyGroupOffset >= firstKeyGroupOffset);
-
-      int firstValueOffset = -1;
-
-      myBuffer.setPosition(firstKeyGroupOffset);
-      while (myBuffer.getPosition() <= lastKeyGroupOffset) {
-        int groupSize = myBuffer.readInt();
-        for (int i = 0; i < groupSize; i++) {
-          dst.add(myBuffer.readInt());
-
-          int valueOffset = myBuffer.readInt(); /* value offset */
-          if( firstValueOffset == -1 ) firstValueOffset = valueOffset + myStartOffset;
-        }
-      }
-      assert myBuffer.getPosition() == firstValueOffset;
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-  }
-
-  private int readKeyGroupOffset(int hash) {
-    myBuffer.setPosition(myStartOffset + 4 /* mod */ + 4 * hash);
-    int offset = -1;
-    try {
-      offset = myBuffer.readInt();
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-    if (offset == -1) return -1;
-    return offset + myStartOffset;
-  }
-
-  private int hash(int hashCode) {
-    return Math.abs(hashCode) % myMod;
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/ByteBufferMap.java b/platform/platform-impl/src/com/intellij/util/io/ByteBufferMap.java
deleted file mode 100644 (file)
index 1068e8d..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class ByteBufferMap<K,V> {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.ByteBufferMap");
-
-  private final RandomAccessDataInput myBuffer;
-  private final int myStartOffset;
-  private final KeyProvider<K> myKeyProvider;
-  private final ValueProvider<V> myValueProvider;
-  private int myMod;
-  private final int myEndOffset;
-
-  public static interface KeyProvider<K> {
-    int hashCode(K key);
-
-    void write(DataOutput out, K key) throws IOException;
-
-    int length(K key);
-
-    K get(DataInput in) throws IOException;
-
-    /**
-     * Should move the buffer pointer to the key end.
-     */
-    boolean equals(DataInput in, K key) throws IOException;
-  }
-
-  public static interface ValueProvider<V> {
-    void write(DataOutput out, V value) throws IOException;
-
-    int length(V value);
-
-    V get(DataInput in) throws IOException;
-  }
-
-  public static <V> void writeMap(DataOutput stream,
-                              ValueProvider<V> valueProvider,
-                              WriteableMap<V> map,
-                              double searchFactor) throws IOException {
-    new ByteBufferMapWriteHandler<V>(stream, valueProvider, map, searchFactor).execute();
-  }
-
-  public static <V> int calcMapLength(ValueProvider<V> valueProvider,
-                                  WriteableMap<V> map,
-                                  double searchFactor) throws IOException {
-    return new ByteBufferMapWriteHandler<V>(null, valueProvider, map, searchFactor).calcLength();
-  }
-
-  public ByteBufferMap(@NotNull MappedBufferWrapper holder,
-                       int startOffset,
-                       int endOffset,
-                       @NotNull KeyProvider<K> keyProvider,
-                       @NotNull ValueProvider<V> valueProvider) {
-    this(new ByteBufferRADataInput(holder), startOffset, endOffset, keyProvider, valueProvider);
-  }
-
-  public ByteBufferMap(@NotNull RandomAccessDataInput buffer,
-                       int startOffset,
-                       int endOffset,
-                       @NotNull KeyProvider<K> keyProvider,
-                       @NotNull ValueProvider<V> valueProvider) {
-    assert startOffset < endOffset;
-
-    myBuffer = buffer;
-    myStartOffset = startOffset;
-    myEndOffset = endOffset;
-    myKeyProvider = keyProvider;
-    myValueProvider = valueProvider;
-
-    buffer.setPosition(startOffset);
-    try {
-      myMod = buffer.readInt();
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-  }
-
-  public V get(K key) {
-    int hash = hash(myKeyProvider.hashCode(key));
-    int keyGroupOffset = readKeyGroupOffset(hash);
-    if (keyGroupOffset == -1) return null;
-    if (!(myStartOffset < keyGroupOffset && keyGroupOffset < myEndOffset)){
-      LOG.error("keyGroupOffset = " + keyGroupOffset + " myStartOffset = " + myStartOffset + " myEndOffset = " + myEndOffset);
-    }
-
-    try {
-      myBuffer.setPosition(keyGroupOffset);
-      int keyGroupSize = myBuffer.readInt();
-      assert (keyGroupSize > 0);
-      for (int i = 0; i < keyGroupSize; i++) {
-        if (myKeyProvider.equals(myBuffer, key)) {
-          int valueOffset = myBuffer.readInt();
-          assert (valueOffset > 0);
-
-          myBuffer.setPosition(myStartOffset + valueOffset);
-          return myValueProvider.get(myBuffer);
-        }
-        else {
-          myBuffer.readInt(); //read offset;
-        }
-      }
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-
-    return null;
-  }
-
-  @SuppressWarnings({"unchecked"})
-  public K[] getKeys(Class<K> keyClass) {
-    ArrayList<K> result = new ArrayList<K>();
-    getKeys(keyClass, result);
-    return result.toArray((K[])Array.newInstance(keyClass, result.size()));
-  }
-
-  public void getKeys(Class<K> keyClass, Collection<K> dst) {
-    try {
-      myBuffer.setPosition(myStartOffset + 4 /* mod */);
-
-      int firstKeyGroupOffset = -1;
-      int lastKeyGroupOffset = -1;
-      for (int i = 0; i < myMod; i++) {
-        int value = myBuffer.readInt();
-        if (value != -1) {
-          int offset = value + myStartOffset;
-          if (firstKeyGroupOffset == -1) firstKeyGroupOffset = offset;
-          lastKeyGroupOffset = offset;
-        }
-      }
-      if (firstKeyGroupOffset == -1) {
-        return;
-      }
-      assert (firstKeyGroupOffset > myStartOffset);
-      assert (lastKeyGroupOffset > myStartOffset);
-      assert (lastKeyGroupOffset >= firstKeyGroupOffset);
-
-      int firstValueOffset = -1;
-
-      myBuffer.setPosition(firstKeyGroupOffset);
-      while (myBuffer.getPosition() <= lastKeyGroupOffset) {
-        int groupSize = myBuffer.readInt();
-        for (int i = 0; i < groupSize; i++) {
-          dst.add(myKeyProvider.get(myBuffer));
-
-          int valueOffset = myBuffer.readInt(); /* value offset */
-          if( firstValueOffset == -1 ) firstValueOffset = valueOffset + myStartOffset;
-        }
-      }
-      assert myBuffer.getPosition() == firstValueOffset;
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-  }
-
-  private int readKeyGroupOffset(int hash) {
-    myBuffer.setPosition(myStartOffset + 4 /* mod */ + 4 * hash);
-    int offset = -1;
-    try {
-      offset = myBuffer.readInt();
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-    if (offset == -1) return -1;
-    return offset + myStartOffset;
-  }
-
-  private int hash(int hashCode) {
-    return Math.abs(hashCode) % myMod;
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/ByteBufferMapWriteHandler.java b/platform/platform-impl/src/com/intellij/util/io/ByteBufferMapWriteHandler.java
deleted file mode 100644 (file)
index 3987c02..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Arrays;
-
-class ByteBufferMapWriteHandler<V> {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.ByteBufferMapWriteHandler");
-
-  private final ByteBufferMap.ValueProvider<V> myValueProvider;
-  private final WriteableMap<V> myMap;
-
-  private final int[] myKeyHashes;
-  private final int myMod;
-  private final DataOutput myOut;
-
-  public ByteBufferMapWriteHandler(DataOutput stream, /*ByteBufferMap.KeyProvider keyProvider, */ByteBufferMap.ValueProvider<V> valueProvider, WriteableMap<V> map, double searchFactor) {
-    myValueProvider = valueProvider;
-    myMap = map;
-
-    myKeyHashes = myMap.getHashCodesArray();
-    int mod = (int)(myKeyHashes.length / searchFactor);
-    myMod = mod != 0 ? mod : 1;
-    myOut = stream;
-  }
-
-  public void execute() throws IOException {
-
-    executeImpl( true );
-  }
-
-  public int calcLength() throws IOException {
-    return executeImpl( false );
-  }
-
-  public int executeImpl( boolean write ) throws IOException {
-    if( write ) myOut.writeInt(myMod);
-    int offset = 4;
-
-    int[] overflowList = new int[myKeyHashes.length];
-    int[] firstOverflowElem = new int[myMod];
-    int[] occurs = new int[myMod];
-    Arrays.fill(firstOverflowElem, -1);
-
-    // Creating hash table and overflow lists
-    for( int i = myKeyHashes.length-1; i >= 0; i-- ) {
-      int hashhash = hash(myKeyHashes[i]);
-      overflowList[i] = firstOverflowElem[hashhash];
-      firstOverflowElem[hashhash] = i;
-      occurs[hashhash]++;
-    }
-
-    offset += 4 * myMod; // hash table size
-    // writing hash table
-    for( int i = 0; i < myMod; i++ ) {
-      if( write ) myOut.writeInt( occurs[i] != 0 ? offset : -1 );
-      if( occurs[i] != 0 ) offset += 4; // key group size, if key group present
-      int occurs_i = 0;
-      for( int j = firstOverflowElem[i]; j != -1; j = overflowList[j] ) {
-        offset += myMap.getKeyLength( j ) + 4 /* value offset */;
-        occurs_i++;
-      }
-      LOG.assertTrue( occurs_i == occurs[i] );
-    }
-
-    // writing key table
-    for( int i = 0; i < myMod; i++ ) {
-      if( occurs[i] == 0 ) continue;
-
-      if( write ) myOut.writeInt( occurs[i] );
-      for( int j = firstOverflowElem[i]; j != -1; j = overflowList[j] ) {
-        if( write ) {
-          myMap.writeKey( myOut, j );
-          myOut.writeInt( offset );
-        }
-        V value = myMap.getValue(j);
-        offset += myValueProvider.length(value);
-      }
-    }
-
-    // writing value table
-    for( int i = 0; i < myMod; i++ ) {
-      for( int j = firstOverflowElem[i]; j != -1; j = overflowList[j] ) {
-        V value = myMap.getValue(j);
-        if( write ) myValueProvider.write( myOut, value );
-      }
-    }
-
-    return offset; // total resulting length
-  }
-
-  private int hash(int hashCode){
-    return Math.abs(hashCode) % myMod;
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/ByteBufferRADataInput.java b/platform/platform-impl/src/com/intellij/util/io/ByteBufferRADataInput.java
deleted file mode 100644 (file)
index 65d5474..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * @author max
- */
-public class ByteBufferRADataInput implements RandomAccessDataInput {
-  private static final Logger LOG = Logger.getInstance("com.intellij.util.io.ByteBufferRADataInput");
-
-  private final MappedBufferWrapper myBuffer;
-
-  public ByteBufferRADataInput(MappedBufferWrapper buffer) {
-    myBuffer = buffer;
-  }
-
-  public void setPosition(int pos) {
-    getBuffer().position(pos);
-  }
-
-  public int getPosition() {
-    return getBuffer().position();
-  }
-
-  public void readFully(byte[] b) throws IOException {
-    getBuffer().get(b);
-  }
-
-  public void readFully(byte[] b, int off, int len) throws IOException {
-    getBuffer().get(b, off, len);
-  }
-
-  public int skipBytes(int n) throws IOException {
-    int newPos = getPosition() + n;
-    setPosition(newPos);
-    return newPos;
-  }
-
-  public boolean readBoolean() throws IOException {
-    return getBuffer().get() == 1;
-  }
-
-  public byte readByte() throws IOException {
-    return getBuffer().get();
-  }
-
-  public int readUnsignedByte() throws IOException {
-    return 0xFF & ((int)getBuffer().get());
-  }
-
-  public short readShort() throws IOException {
-    return getBuffer().getShort();
-  }
-
-  public int readUnsignedShort() throws IOException {
-    return 0xFFFF & ((int)getBuffer().getShort());
-  }
-
-  public char readChar() throws IOException {
-    return getBuffer().getChar();
-  }
-
-  public int readInt() throws IOException {
-    return getBuffer().getInt();
-  }
-
-  public long readLong() throws IOException {
-    return getBuffer().getLong();
-  }
-
-  public float readFloat() throws IOException {
-    return getBuffer().getFloat();
-  }
-
-  public double readDouble() throws IOException {
-    return getBuffer().getDouble();
-  }
-
-  public String readLine() throws IOException {
-    LOG.error("Not implemented");
-    return null;
-  }
-
-  public String readUTF() throws IOException {
-    return DataInputStream.readUTF(this);
-  }
-
-  public ByteBuffer getBuffer() {
-    return myBuffer.buf();
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/FileKeyProvider.java b/platform/platform-impl/src/com/intellij/util/io/FileKeyProvider.java
deleted file mode 100644 (file)
index 5bffe1b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.vfs.VirtualFile;
-import gnu.trove.TObjectIntHashMap;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-public class FileKeyProvider implements ByteBufferMap.KeyProvider<VirtualFile>{
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.FileKeyProvider");
-
-  private final VirtualFile[] myFileIndex;
-  private final TObjectIntHashMap<VirtualFile> myFileToIndexMap;
-
-  public FileKeyProvider(VirtualFile[] fileIndex, TObjectIntHashMap<VirtualFile> fileToIndexMap) {
-    myFileIndex = fileIndex;
-    myFileToIndexMap = fileToIndexMap;
-  }
-
-  public int hashCode(VirtualFile key) {
-    int index = myFileToIndexMap.get(key) - 1;
-    return index;
-  }
-
-  public void write(DataOutput out, VirtualFile key) throws IOException {
-    int index = myFileToIndexMap.get(key) - 1;
-    LOG.assertTrue(index >= 0);
-    out.writeInt(index);
-  }
-
-  public int length(VirtualFile key) {
-    return 4;
-  }
-
-  public VirtualFile get(DataInput in) throws IOException {
-    int index = in.readInt();
-    return myFileIndex[index];
-  }
-
-  public boolean equals(DataInput in, VirtualFile key) throws IOException {
-    int index = in.readInt();
-    return key.equals(myFileIndex[index]);
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/IntArrayValueProvider.java b/platform/platform-impl/src/com/intellij/util/io/IntArrayValueProvider.java
deleted file mode 100644 (file)
index 1a395c0..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.util.ArrayUtil;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-public class IntArrayValueProvider implements ByteBufferMap.ValueProvider<int[]> {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.IntArrayValueProvider");
-  public static final IntArrayValueProvider INSTANCE = new IntArrayValueProvider(-1);
-
-  private final int myArraySize;
-
-  public IntArrayValueProvider(int arraySize) {
-    myArraySize = arraySize;
-  }
-
-  public void write(DataOutput out, int[] value) throws IOException {
-    //if (value instanceof IntArrayList) {
-    //  IntArrayList list = (IntArrayList) value;
-    //  LOG.assertTrue(myArraySize == -1 || list.size() == myArraySize);
-    //  if (myArraySize == -1) out.writeInt(list.size());
-    //  for (int i = 0; i < list.size(); i++) {
-    //    out.writeInt(list.get(i));
-    //  }
-    //} else if (value instanceof TIntArrayList) {
-    //  TIntArrayList list = (TIntArrayList) value;
-    //  LOG.assertTrue(myArraySize == -1 || list.size() == myArraySize);
-    //  if (myArraySize == -1) out.writeInt(list.size());
-    //  for (int i = 0; i < list.size(); i++) {
-    //    out.writeInt(list.get(i));
-    //  }
-    //} else {
-      int[] array = (int[])value;
-      LOG.assertTrue(myArraySize == -1 || array.length == myArraySize);
-      if (myArraySize == -1) out.writeInt(array.length);
-      for(int i = 0; i < array.length; i++){
-        out.writeInt(array[i]);
-      }
-    //}
-  }
-
-  public int length(int[] value) {
-    //if (value instanceof IntArrayList) {
-    //  IntArrayList list = (IntArrayList) value;
-    //  LOG.assertTrue(myArraySize == -1 || list.size() == myArraySize);
-    //
-    //  if (myArraySize == -1) return 4 * (list.size() + 1);
-    //
-    //  return 4 * myArraySize;
-    //} else if (value instanceof TIntArrayList) {
-    //  TIntArrayList list = (TIntArrayList) value;
-    //  LOG.assertTrue(myArraySize == -1 || list.size() == myArraySize);
-    //
-    //  if (myArraySize == -1) return 4 * (list.size() + 1);
-    //
-    //  return 4 * myArraySize;
-    //} else {
-      int[] array = (int[])value;
-      LOG.assertTrue(myArraySize == -1 || array.length == myArraySize);
-
-      if (myArraySize == -1) return 4 * (array.length + 1);
-
-      return 4 * myArraySize;
-    //}
-  }
-
-  public int[] get(DataInput in) throws IOException {
-    final int[] result;
-
-    if (myArraySize >= 0) {
-      result = ArrayUtil.newIntArray(myArraySize);
-    } else {
-      result = ArrayUtil.newIntArray(in.readInt());
-    }
-
-    for(int i = 0; i < result.length; i++){
-      result[i] = in.readInt();
-    }
-    return result;
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/IntValueProvider.java b/platform/platform-impl/src/com/intellij/util/io/IntValueProvider.java
deleted file mode 100644 (file)
index 8c30fd8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.util.io;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-/**
- * @author max
- */
-public class IntValueProvider implements ByteBufferMap.ValueProvider<Integer> {
-  public static IntValueProvider INSTANCE = new IntValueProvider();
-
-  private IntValueProvider() {
-  }
-
-  public void write(DataOutput out, Integer value) throws IOException {
-    out.writeInt(((Integer)value).intValue());
-  }
-
-  public int length(Integer value) {
-    return 4;
-  }
-
-  public Integer get(DataInput in) throws IOException {
-    return new Integer(in.readInt());
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/IntegerKeyProvider.java b/platform/platform-impl/src/com/intellij/util/io/IntegerKeyProvider.java
deleted file mode 100644 (file)
index ff10086..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-/**
-   * @deprecated use {@link ByteBufferIntObjectMap} instead
- */
-public class IntegerKeyProvider implements ByteBufferMap.KeyProvider<Integer> {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.StringKeyProvider");
-
-  public static final IntegerKeyProvider INSTANCE = new IntegerKeyProvider();
-
-  private IntegerKeyProvider() {
-  }
-
-  public int hashCode(Integer key) {
-    return key.hashCode();
-  }
-
-  public void write(DataOutput out, Integer key) throws IOException {
-    out.writeInt(key.intValue());
-  }
-
-  public int length(Integer key) {
-    return 4;
-  }
-
-  public Integer get(DataInput in) throws IOException {
-    return new Integer(in.readInt());
-  }
-
-  public boolean equals(DataInput in, Integer key) throws IOException {
-    return key.intValue() == in.readInt();
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/StringKeyProvider.java b/platform/platform-impl/src/com/intellij/util/io/StringKeyProvider.java
deleted file mode 100644 (file)
index f3a7e64..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.diagnostic.Logger;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import org.jetbrains.annotations.NonNls;
-
-public class StringKeyProvider implements ByteBufferMap.KeyProvider<String>{
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.StringKeyProvider");
-
-  public static final StringKeyProvider INSTANCE = new StringKeyProvider();
-  @NonNls public static final String UTF_8_CHARSET_NAME = "UTF-8";
-
-  private StringKeyProvider() {
-  }
-
-  public int hashCode(String key) {
-    return key.hashCode();
-  }
-
-  public void write(DataOutput out, String key) throws IOException {
-    String keyString = (String)key;
-    byte[] keyBytes = keyString.getBytes(UTF_8_CHARSET_NAME);
-    out.writeInt(keyBytes.length);
-    out.write(keyBytes);
-  }
-
-  public int length(String key) {
-    try{
-      String keyString = (String)key;
-      byte[] keyBytes = keyString.getBytes(UTF_8_CHARSET_NAME);
-      return 4 + keyBytes.length;
-    }
-    catch(UnsupportedEncodingException e){
-      LOG.error(e);
-      return 0;
-    }
-  }
-
-  public String get(DataInput in) throws IOException {
-    int length = in.readInt();
-    byte[] bytes = new byte[length];
-    in.readFully(bytes);
-    try {
-      return new String(bytes, UTF_8_CHARSET_NAME);
-    }
-    catch (UnsupportedEncodingException e) {
-      LOG.error(e);
-      return null;
-    }
-  }
-
-  public boolean equals(DataInput in, String key) throws IOException {
-    try {
-      String keyString = (String)key;
-      byte[] keyBytes = keyString.getBytes(UTF_8_CHARSET_NAME);
-
-      int length = in.readInt();
-      byte[] inputBytes = new byte[length];
-      in.readFully(inputBytes);
-      if (length != keyBytes.length) return false;
-      for (int i = 0; i < length; i++) {
-        if (keyBytes[i] != inputBytes[i]) return false;
-      }
-
-      return true;
-    }
-    catch (UnsupportedEncodingException e) {
-      LOG.error(e);
-      return false;
-    }
-  }
-}
diff --git a/platform/platform-impl/src/com/intellij/util/io/WriteableMapAdapter.java b/platform/platform-impl/src/com/intellij/util/io/WriteableMapAdapter.java
deleted file mode 100644 (file)
index 2375d37..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.util.io;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * @author max
- */
-public class WriteableMapAdapter<K,V> implements WriteableMap<V> {
-  private final Map<K,V> myMap;
-  private final ByteBufferMap.KeyProvider myKeyProvider;
-  private final K[] myKeys;
-
-  public WriteableMapAdapter(Map<K,V> map, ByteBufferMap.KeyProvider provider) {
-    myMap = map;
-    myKeyProvider = provider;
-    myKeys = (K[]) myMap.keySet().toArray();
-  }
-
-  public int[] getHashCodesArray() {
-    int[] keyHashCodes = new int[ myKeys.length ];
-    for( int i = 0; i < myKeys.length; i++ )
-      keyHashCodes[i] = myKeyProvider.hashCode(myKeys[i]);
-    return keyHashCodes;
-  }
-
-  public V getValue( int n ) {
-    return myMap.get( myKeys[n] );
-  }
-
-  public int getKeyLength( int n ) {
-    return myKeyProvider.length( myKeys[n] );
-  }
-
-  public void writeKey( DataOutput out, int n ) throws IOException {
-    myKeyProvider.write( out, myKeys[n] );
-  }
-}
index b839612b85e870b4db898fb9540a68f297186337..3f1faa390fbb5f23a10a3dc7101c697c1baf5f67 100644 (file)
@@ -596,7 +596,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorP
     init(fileText);
     myEditor.getSettings().setUseSoftWraps(true);
     SoftWrapModelImpl model = (SoftWrapModelImpl)myEditor.getSoftWrapModel();
-    model.refreshSettings();
+    model.reinitSettings();
 
     SoftWrapApplianceManager applianceManager = model.getApplianceManager();
     applianceManager.setWidthProvider(new SoftWrapApplianceManager.VisibleAreaWidthProvider() {
index 64eb5340b33e0242232ac6c805aad759249598d2..97b83f71b0d1a782455bbe6d29ab46d67ca89280 100644 (file)
@@ -268,8 +268,8 @@ aboutbox.vm=VM: {0}
 aboutbox.vendor=Vendor: {0}
 aboutbox.maintenance.due=Entitled for free updates and upgrades until {0,date,MMMM dd,yyyy}
 title.warning=Warning
-message.upgrade.from.previous.required=Your license is not valid for use with this version of {0}. <br/> For information on how to upgrade your license please go to {1}
-title.upgrade.needed=Upgrade Needed
+message.upgrade.from.previous.required=Your license is not valid for use with this version of {0}. <br/> For information on how to upgrade your license please go to {1} <br/> You can also opt for a free time-limited evaluation.
+title.upgrade.needed=License Upgrade Needed
 message.evaluation.has.expired=Your {0} evaluation has expired. Your session will be limited to 30 minutes.<br>{1}
 title.evaluation.license.expired=Evaluation License Expired
 message.evaluation.license.expired=Your evaluation license has expired. {0} will now exit.
@@ -1094,4 +1094,4 @@ scripting.lib.usageScope=Usage Scope
 scripting.lib.usageScope.caption=Specify which libraries are used in specific files and/or directories.
 scripting.lib.usageScope.tableTitle=Library
 scripting.lib.usageScope.override.question=Override library settings for child directories and files?
-scripting.lib.usageScope.override.title=Override Library Settings
\ No newline at end of file
+scripting.lib.usageScope.override.title=Override Library Settings
index c252bf904bae0362d0df867ee6deaabeac6c6ec0..daeb0acdff8a4dddb7cdbdb29b5b0e02144e6e35 100644 (file)
@@ -480,3 +480,5 @@ external.annotations.external.option=Add &externally
 project.new.wizard.import.footnote=Import from external model is available from New Project Wizard only
 loading.components.for=Loading components for ''{0}''
 initializing.components=Initializing components
+
+library.docs.node=Documentation
\ No newline at end of file
index 29f104eb392695967b0b55a2aecd86e95910f4c2..a47d2d76d7e61a488d7ccf92e3d4821a3c2d6b3f 100644 (file)
@@ -54,7 +54,6 @@ import com.intellij.openapi.util.EmptyRunnable;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileManager;
 import com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl;
 import com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl;
 import com.intellij.openapi.vfs.newvfs.ManagingFS;
@@ -144,8 +143,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
   protected void setUp() throws Exception {
     super.setUp();
     if (ourTestCase != null) {
-      String message = "Previous test " + ourTestCase +
-                       " hasn't called tearDown(). Probably overriden without super call.";
+      String message = "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.";
       ourTestCase = null;
       fail(message);
     }
@@ -597,12 +595,6 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
   public static File createTempDir(@NonNls final String prefix) throws IOException {
     final File tempDirectory = FileUtil.createTempDirectory(TEST_DIR_PREFIX + prefix, null);
     myFilesToDelete.add(tempDirectory);
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
-      @Override
-      public void run() {
-        VirtualFileManager.getInstance().refresh(false);
-      }
-    });
     return tempDirectory;
   }
 
index 3cb485406189639986f4b559ec0c022d73708e52..73c1d52013367850230cc2e8f620b19291ffdd57 100644 (file)
@@ -121,7 +121,7 @@ public class CompositePrintable implements Printable, Disposable {
     private synchronized File getFile() {
       if (myFile == null) {
         try {
-          final File tempFile = FileUtil.createTempFile("frst", "scd");
+          final File tempFile = FileUtil.createTempFile("idea_test_", ".out");
           if (tempFile.exists()) {
             myFile = tempFile;
             return myFile;
@@ -139,6 +139,10 @@ public class CompositePrintable implements Printable, Disposable {
       if (myFile != null) FileUtil.delete(myFile);
     }
 
+    public synchronized boolean hasOutput() {
+      return myFile != null;
+    }
+
     public void flush(final List<Printable> printables) {
       if (printables.isEmpty()) return;
       final ArrayList<Printable> currentPrintables = new ArrayList<Printable>(printables);
@@ -156,8 +160,7 @@ public class CompositePrintable implements Printable, Disposable {
     }
 
     public void printOn(final Printer console, final List<Printable> printables) {
-      final File file = getFile();
-      if (file == null) return;
+      final File file = hasOutput() ? getFile() : null;
       final Runnable request = new Runnable() {
         @Override
         public void run() {
@@ -247,52 +250,36 @@ public class CompositePrintable implements Printable, Disposable {
 
     private class MyFileContentPrinter {
 
-      public void printFileContent(Printer printer, File file, List<Printable> nestedPrintables) {
-        DataInputStream reader = null;
-        try {
-          reader = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
-          int lineNum = 0;
-          while (reader.available() > 0 && !wasPrintableChanged(printer)) {
-            if (lineNum == CompositePrintable.this.getExceptionMark() && lineNum > 0) printer.mark();
-            final String line = IOUtil.readString(reader);
-            boolean printed = false;
-            for (ConsoleViewContentType contentType : ConsoleViewContentType.OUTPUT_TYPES) {
-              final String prefix = contentType.toString();
-              if (line.startsWith(prefix)) {
-                printer.print(line.substring(prefix.length()), contentType);
-                myLastSelected = contentType;
-                printed = true;
-                break;
-              }
-            }
-            if (!printed) {
-              if (line.startsWith(HYPERLINK)) {
-                new DiffHyperlink(IOUtil.readString(reader), IOUtil.readString(reader), IOUtil.readString(reader)).printOn(printer);
+      public void printFileContent(Printer printer, @Nullable File file, List<Printable> nestedPrintables) {
+        if (file != null) {
+          DataInputStream reader = null;
+          try {
+            reader = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+            int lineNum = 0;
+            while (reader.available() > 0 && !wasPrintableChanged(printer)) {
+              if (lineNum == CompositePrintable.this.getExceptionMark() && lineNum > 0) printer.mark();
+              final String line = IOUtil.readString(reader);
+              boolean printed = false;
+              for (ConsoleViewContentType contentType : ConsoleViewContentType.OUTPUT_TYPES) {
+                final String prefix = contentType.toString();
+                if (line.startsWith(prefix)) {
+                  printer.print(line.substring(prefix.length()), contentType);
+                  myLastSelected = contentType;
+                  printed = true;
+                  break;
+                }
               }
-              else {
-                printer.print(line, myLastSelected != null ? myLastSelected : ConsoleViewContentType.NORMAL_OUTPUT);
+              if (!printed) {
+                if (line.startsWith(HYPERLINK)) {
+                  new DiffHyperlink(IOUtil.readString(reader), IOUtil.readString(reader), IOUtil.readString(reader)).printOn(printer);
+                }
+                else {
+                  printer.print(line, myLastSelected != null ? myLastSelected : ConsoleViewContentType.NORMAL_OUTPUT);
+                }
               }
+              lineNum++;
             }
-            lineNum++;
-          }
-
-          for (int i = 0; i < nestedPrintables.size(); i++) {
-            if (i == getExceptionMark() && i > 0) printer.mark();
-            nestedPrintables.get(i).printOn(printer);
-          }
 
-        }
-        catch (FileNotFoundException e) {
-          LOG.info(e);
-        }
-        catch (IOException e) {
-          LOG.error(e);
-        }
-        finally {
-          try {
-            if (reader != null) {
-              reader.close();
-            }
           }
           catch (FileNotFoundException e) {
             LOG.info(e);
@@ -300,6 +287,23 @@ public class CompositePrintable implements Printable, Disposable {
           catch (IOException e) {
             LOG.error(e);
           }
+          finally {
+            try {
+              if (reader != null) {
+                reader.close();
+              }
+            }
+            catch (FileNotFoundException e) {
+              LOG.info(e);
+            }
+            catch (IOException e) {
+              LOG.error(e);
+            }
+          }
+        }
+        for (int i = 0; i < nestedPrintables.size(); i++) {
+          if (i == getExceptionMark() && i > 0) printer.mark();
+          nestedPrintables.get(i).printOn(printer);
         }
       }
 
index 8114f53e3a3ba61825fdf14e6534a1b4600e865b..0cf5923e87d54edd4e7088828e571c03d952e974 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NonNls;
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
@@ -48,7 +49,7 @@ public abstract class MappedBufferWrapper {
     myLength = length;
   }
 
-  protected abstract MappedByteBuffer map();
+  protected abstract MappedByteBuffer map() throws IOException;
 
   private static final int MAX_FORCE_ATTEMPTS = 10;
 
@@ -63,7 +64,7 @@ public abstract class MappedBufferWrapper {
     return myBuffer;
   }
 
-  public ByteBuffer buf() {
+  public ByteBuffer buf() throws IOException {
     if (myBuffer == null) {
       myBuffer = map();
     }
diff --git a/platform/util/src/com/intellij/util/io/MappedFile.java b/platform/util/src/com/intellij/util/io/MappedFile.java
deleted file mode 100644 (file)
index 494ffe9..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * 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.util.io;
-
-import com.intellij.openapi.Forceable;
-import com.intellij.openapi.diagnostic.Logger;
-import org.jetbrains.annotations.NonNls;
-
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.nio.MappedByteBuffer;
-
-/**
- * @author max
- */
-public class MappedFile implements Forceable {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.MappedFile");
-
-  private MappedBufferWrapper myHolder;
-  private final File myFile;
-
-  private long myRealSize;
-  private long mySize;
-  private long myPosition;
-  private boolean myIsDirty = false;
-
-  @NonNls private static final String UTF_8_CHARSET_NAME = "UTF-8";
-  @NonNls private static final String RW = "rw";
-  private final byte[] buffer = new byte[8];
-
-  public MappedFile(File file, int initialSize) throws IOException {
-    myFile = file;
-    if (!file.exists() || file.length() == 0) {
-      writeLength(0);
-    }
-
-    myPosition = 0;
-    map();
-
-    mySize = readLength();
-    if (mySize == 0) {
-      resize(initialSize);
-    }
-  }
-
-  private long readLength() {
-    File lengthFile = getLengthFile();
-    DataInputStream stream = null;
-    try {
-      stream = new DataInputStream(new FileInputStream(lengthFile));
-      return stream.readLong();
-    }
-    catch (IOException e) {
-      writeLength(myRealSize);
-      return myRealSize;
-    }
-    finally {
-      if (stream != null) {
-        try {
-          stream.close();
-        }
-        catch (IOException e) {
-          LOG.error(e);
-        }
-      }
-    }
-  }
-
-  private File getLengthFile() {
-    return new File(myFile.getPath() + ".len");
-  }
-
-  private void writeLength(final long len) {
-    File lengthFile = getLengthFile();
-    DataOutputStream stream = null;
-    try {
-      stream = new DataOutputStream(new FileOutputStream(lengthFile));
-      stream.writeLong(len);
-    }
-    catch (FileNotFoundException e) {
-      LOG.error(e);
-    }
-    catch (IOException e) {
-      LOG.error(e);
-    }
-    finally {
-      if (stream != null) {
-        try {
-          stream.close();
-        }
-        catch (IOException e) {
-          LOG.error(e);
-        }
-      }
-    }
-  }
-
-  private void map() {
-    myHolder = new ReadWriteMappedBufferWrapper(myFile);
-    myRealSize = myFile.length();
-    if (LOG.isDebugEnabled()) {
-      LOG.assertTrue(myPosition > 0L && myPosition < myRealSize || myPosition == 0 && myRealSize == 0, "myPosition=" + myPosition + ", myRealSize=" + myRealSize);
-    }
-    myHolder.buf().position((int)myPosition);
-  }
-
-  public short getShort(int index) throws IOException {
-    seek(index);
-    return readShort();
-  }
-
-  public short readShort() throws IOException {
-    get(buffer, 0, 2);
-
-    return Bits.getShort(buffer, 0);
-  }
-
-  public void putShort(int index, short value) throws IOException {
-    seek(index);
-    writeShort(value);
-  }
-
-  public void writeShort(int value) throws IOException {
-    Bits.putShort(buffer, 0, (short)value);
-    put(buffer, 0, 2);
-  }
-
-  public int getInt(int index) throws IOException {
-    seek(index);
-    return readInt();
-  }
-
-  public long getLong(final int index) throws IOException {
-    seek(index);
-    return readLong();
-  }
-
-  public void putInt(int index, int value) throws IOException {
-    seek(index);
-    writeInt(value);
-  }
-
-  public void putLong(final int index, final long value) throws IOException {
-    seek(index);
-    writeLong(value);
-  }
-
-  public byte get(int index) throws IOException {
-    seek(index);
-    return readByte();
-  }
-
-  public void put(int index, byte value) throws IOException {
-    seek(index);
-    writeByte(value);
-  }
-
-  public void get(int index, byte[] dst, int offset, int length) throws IOException {
-    seek(index);
-    get(dst, offset, length);
-  }
-
-  public void get(final byte[] dst, final int offset, final int length) throws IOException {
-    if (myPosition + length > mySize) {
-      throw new EOFException();
-    }
-
-    buf().get(dst, offset, length);
-    myPosition += length;
-  }
-
-  public void put(int index, byte[] src, int offset, int length) throws IOException {
-    seek(index);
-    put(src, offset, length);
-  }
-
-  public void seek(long pos) throws IOException {
-    ensureSize(pos);
-    buf().position((int)pos);
-    myPosition = pos;
-    if (pos > mySize) {
-      mySize = pos;
-    }
-  }
-
-  private ByteBuffer buf() {
-    if (!isMapped()) {
-      map();
-    }
-
-    return myHolder.buf();
-  }
-
-  private void ensureSize(final long pos) throws IOException {
-    while (pos >= myRealSize) {
-      expand();
-    }
-  }
-
-  private void expand() throws IOException {
-    resize((int)((myRealSize + 1) * 13) >> 3);
-  }
-
-  public void put(final byte[] src, final int offset, final int length) throws IOException {
-    ensureSize(myPosition + length);
-    myIsDirty = true;
-    buf().put(src, offset, length);
-    myPosition += length;
-    if (myPosition > mySize) {
-      mySize = myPosition;
-    }
-  }
-
-  public void flush() {
-    if (myIsDirty) {
-      writeLength(mySize);
-      final ByteBuffer buf = buf();
-      if (buf instanceof MappedByteBuffer) {
-        MappedBufferWrapper.tryForce(buf);
-      }
-      myIsDirty = false;
-    }
-  }
-
-  public void force() {
-    flush();
-  }
-
-  public boolean isDirty() {
-    return myIsDirty;
-  }
-
-  public void close() {
-    if (myIsDirty) {
-      writeLength(mySize);
-    }
-    unmap();
-  }
-
-  public void resize(int size) throws IOException {
-    final int current = (int)myRealSize;
-    if (current == size) return;
-    unmap();
-    RandomAccessFile raf = new RandomAccessFile(myFile, RW);
-    try {
-      raf.setLength(size);
-    }
-    finally {
-      raf.close();
-    }
-    map();
-  }
-
-  public final long length() {
-    return mySize;
-  }
-
-  public long getFilePointer() {
-    return myPosition;
-  }
-
-  public int readInt() throws IOException {
-    get(buffer, 0, 4);
-    return Bits.getInt(buffer, 0);
-  }
-
-  public long readLong() throws IOException {
-    get(buffer, 0, 8);
-    return Bits.getLong(buffer, 0);
-  }
-
-  public void writeInt(int value) throws IOException {
-    Bits.putInt(buffer, 0, value);
-    put(buffer, 0, 4);
-  }
-
-  public void writeLong(long value) throws IOException {
-    Bits.putLong(buffer, 0, value);
-    put(buffer, 0, 8);
-  }
-
-  public String readUTF() throws IOException {
-    try {
-      int len = readInt();
-      byte[] bytes = new byte[ len ];
-      get(bytes, 0, len);
-      return new String(bytes, UTF_8_CHARSET_NAME);
-    }
-    catch (UnsupportedEncodingException e) {
-      // Can't be
-      return "";
-    }
-  }
-
-  public void writeUTF(String value) throws IOException {
-    try {
-      final byte[] bytes = value.getBytes(UTF_8_CHARSET_NAME);
-      writeInt(bytes.length);
-      put(bytes, 0, bytes.length);
-    }
-    catch (UnsupportedEncodingException e) {
-      // Can't be
-    }
-  }
-
-  public int readUnsignedShort() throws IOException {
-    get(buffer, 0, 2);
-
-    int ch1 = buffer[0] & 0xff;
-    int ch2 = buffer[1] & 0xff;
-    return (ch1 << 8) + ch2;
-  }
-
-  public char readChar() throws IOException {
-    return (char)readUnsignedShort();
-  }
-
-  public void writeChar(char value) throws IOException {
-    writeShort(value);
-  }
-
-  public byte readByte() throws IOException {
-    get(buffer, 0, 1);
-    return buffer[0];
-  }
-
-  public void writeByte(byte value) throws IOException {
-    buffer[0] = value;
-    put(buffer, 0, 1);
-  }
-
-  private void unmap() {
-    if (myHolder != null) {
-     /* flush(); TODO: Don't commit... */
-      myHolder.unmap();
-    }
-  }
-
-  public boolean isMapped() {
-    return myHolder.isMapped();
-  }
-}
index 5a985cceabf769b3283979723e7157228748ff0f..a3954c1b16cead490e659b7d4aebf7341269661e 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.util.io;
 
 import com.intellij.openapi.Forceable;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.util.containers.hash.LinkedHashMap;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -33,7 +34,12 @@ import java.util.Set;
  * @author max
  */
 public class PagedFileStorage implements Forceable {
-  private final static int BUFFER_SIZE = 10 * 1024 * 1024; // 10M
+
+  protected static final Logger LOG = Logger.getInstance("#com.intellij.util.io.PagedFileStorage");
+  private static final int MEGABYTE = 1024 * 1024;
+  private final static int BUFFER_SIZE = 10 * MEGABYTE;
+  private final static int UPPER_LIMIT = 200 * MEGABYTE;
+  private final static int LOWER_LIMIT = 100 * MEGABYTE;
 
   private final StorageLock myLock;
 
@@ -51,8 +57,9 @@ public class PagedFileStorage implements Forceable {
     final BuffersCache myBuffersCache = new BuffersCache();
 
     private class BuffersCache extends MyCache {
+
       public BuffersCache() {
-        super(20 * BUFFER_SIZE);
+        super(UPPER_LIMIT);
       }
 
       @NotNull
@@ -65,7 +72,40 @@ public class PagedFileStorage implements Forceable {
         if (off > key.owner.length()) {
           throw new IndexOutOfBoundsException("off=" + off + " key.owner.length()=" + key.owner.length());
         }
-        return new ReadWriteMappedBufferWrapper(key.owner.myFile, off, Math.min((int)(key.owner.length() - off), BUFFER_SIZE));
+        ReadWriteMappedBufferWrapper wrapper =
+          new ReadWriteMappedBufferWrapper(key.owner.myFile, off, Math.min((int)(key.owner.length() - off), BUFFER_SIZE));
+        IOException oome = null;
+        while (true) {
+          try {
+            // ensure it's allocated
+            wrapper.buf();
+            if (oome != null) {
+              LOG.error("Successfully recovered OOME in memory mapping: -Xmx=" + Runtime.getRuntime().maxMemory() / MEGABYTE + "MB " +
+                        "new size limit: " + mySizeLimit / MEGABYTE + "MB " +
+                        "trying to allocate " + wrapper.myLength + " block");
+            }
+            return wrapper;
+          }
+          catch (IOException e) {
+            if (e.getCause() instanceof OutOfMemoryError) {
+              oome = e;
+              if (mySizeLimit > LOWER_LIMIT) {
+                mySizeLimit -= BUFFER_SIZE;
+              }
+              long newSize = getSize() - BUFFER_SIZE;
+              if (newSize >= 0) {
+                ensureSize(newSize);
+                continue; // next try
+              }
+              else {
+                throw new MappingFailedException("Cannot recover from OOME in memory mapping: -Xmx=" + Runtime.getRuntime().maxMemory() / MEGABYTE + "MB " +
+                        "new size limit: " + mySizeLimit / MEGABYTE + "MB " +
+                        "trying to allocate " + wrapper.myLength + " block", e);
+              }
+            }
+            throw new MappingFailedException("Cannot map buffer", e);
+          }
+        }
       }
 
       public void onDropFromCache(PageKey key, MappedBufferWrapper buf) {
@@ -106,7 +146,7 @@ public class PagedFileStorage implements Forceable {
   private final byte[] myTypedIOBuffer = new byte[8];
   private boolean isDirty = false;
   private final File myFile;
-  private long mySize = -1;
+  protected long mySize = -1;
   @NonNls private static final String RW = "rw";
 
   public PagedFileStorage(File file, StorageLock lock) throws IOException {
@@ -133,6 +173,7 @@ public class PagedFileStorage implements Forceable {
     put(addr, myTypedIOBuffer, 0, 8);
   }
 
+  @SuppressWarnings({"UnusedDeclaration"})
   public void putByte(final int addr, final byte b) {
     myTypedIOBuffer[0] = b;
     put(addr, myTypedIOBuffer, 0, 1);
@@ -277,7 +318,12 @@ public class PagedFileStorage implements Forceable {
   }
 
   private ByteBuffer getBuffer(int page) {
-    return myLock.myBuffersCache.get(new PageKey(this, page)).buf();
+    try {
+      return myLock.myBuffersCache.get(new PageKey(this, page)).buf();
+    }
+    catch (IOException e) {
+      throw new MappingFailedException("Cannot map buffer", e);
+    }
   }
 
   public void force() {
@@ -296,7 +342,7 @@ public class PagedFileStorage implements Forceable {
   private static abstract class MyCache {
 
     privat