From e07eac5d466def884a09d25dbb2229b87110cb24 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 24 Nov 2010 13:16:45 +0300 Subject: [PATCH 01/10] Local History: do not try to update diff panels after dialog was closed --- .../history/integration/ui/views/HistoryDialog.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java index 59030d9c0f71..3fbf95bf8a47 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java @@ -264,11 +264,11 @@ public abstract class HistoryDialog extends FrameW } public void run() { - if (myProject.isDisposed()) return; + if (isDisposed() || myProject.isDisposed()) return; invokeAndWait(new Runnable() { public void run() { - if (myProject.isDisposed()) return; + if (isDisposed() || myProject.isDisposed()) return; isUpdating = true; updateActions(); @@ -287,7 +287,7 @@ public abstract class HistoryDialog extends FrameW final Runnable finalApply = apply; invokeAndWait(new Runnable() { public void run() { - if (myProject.isDisposed()) return; + if (isDisposed() || myProject.isDisposed()) return; isUpdating = false; if (finalApply != null) { From 5078a759d0c0e087fdb02d13e35aa72bafbd34f6 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 24 Nov 2010 14:32:21 +0300 Subject: [PATCH 02/10] Maven: do not highlight LATEST/RELEASE versions as errors --- ...enArtifactCoordinatesVersionConverter.java | 6 +++--- ...alVersionsCompletionAndResolutionTest.java | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesVersionConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesVersionConverter.java index 22194e67adeb..b7afdd34061a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesVersionConverter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesVersionConverter.java @@ -31,13 +31,13 @@ public class MavenArtifactCoordinatesVersionConverter extends MavenArtifactCoord || StringUtil.isEmpty(id.getVersion())) { return false; } - if (isVersionRange(id)) return true; // todo handle ranges more sensibly + if (isMagicVersion(id)) return true; // todo handle ranges more sensibly return manager.hasVersion(id.getGroupId(), id.getArtifactId(), id.getVersion()); } - private boolean isVersionRange(MavenId id) { + private boolean isMagicVersion(MavenId id) { String version = id.getVersion().trim(); - return version.startsWith("(") || version.startsWith("["); + return version.equals("LATEST") || version.equals("RELEASE") || version.startsWith("(") || version.startsWith("["); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySpecialVersionsCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySpecialVersionsCompletionAndResolutionTest.java index 1326d42bc202..688be099a964 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySpecialVersionsCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySpecialVersionsCompletionAndResolutionTest.java @@ -57,4 +57,25 @@ public class MavenDependencySpecialVersionsCompletionAndResolutionTest extends M checkHighlighting(); } + + public void testDoNotHighlightLatestAndReleaseDependencies() throws Throwable { + createProjectPom("test" + + "project" + + "1" + + + "" + + " " + + " jmock" + + " jmock" + + " LATEST" + + " " + + " " + + " jmock" + + " jmock" + + " RELEASE" + + " " + + ""); + + checkHighlighting(); + } } From f20c913a7a96b3fe3d94ef99e34e3928349549da Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Thu, 25 Nov 2010 13:34:55 +0300 Subject: [PATCH 03/10] Maven: search for pom files by artifact id --- .../maven/utils/MavenGotoFileContributor.java | 52 +++++++++++++++++++ ... => MavenGotoSettingsFileContributor.java} | 2 +- ... => MavenGotoPropertyFileContributor.java} | 2 +- .../src/main/resources/META-INF/plugin.xml | 5 +- 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoFileContributor.java rename plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/{MavenGotoSettingsFileContibutor.java => MavenGotoSettingsFileContributor.java} (95%) rename plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/{MavenGotoPropertyFileContibutor.java => MavenGotoPropertyFileContributor.java} (95%) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoFileContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoFileContributor.java new file mode 100644 index 000000000000..5fb43df0b448 --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoFileContributor.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.utils; + +import com.intellij.navigation.ChooseByNameContributor; +import com.intellij.navigation.NavigationItem; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import org.jetbrains.idea.maven.project.MavenProject; +import org.jetbrains.idea.maven.project.MavenProjectsManager; + +import java.util.ArrayList; +import java.util.List; + +public class MavenGotoFileContributor implements ChooseByNameContributor { + public String[] getNames(Project project, boolean includeNonProjectItems) { + List result = new ArrayList(); + + for (MavenProject each : MavenProjectsManager.getInstance(project).getProjects()) { + result.add(each.getMavenId().getArtifactId()); + } + + return result.toArray(new String[result.size()]); + } + + public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { + List result = new ArrayList(); + + for (final MavenProject each : MavenProjectsManager.getInstance(project).getProjects()) { + if (name.equals(each.getMavenId().getArtifactId())) { + PsiFile psiFile = PsiManager.getInstance(project).findFile(each.getFile()); + if (psiFile != null) result.add(psiFile); + } + } + + return result.toArray(new NavigationItem[result.size()]); + } +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContibutor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContributor.java similarity index 95% rename from plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContibutor.java rename to plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContributor.java index 6ae9412af293..c37e5eeb86d7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContibutor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenGotoSettingsFileContributor.java @@ -30,7 +30,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -public class MavenGotoSettingsFileContibutor implements ChooseByNameContributor, DumbAware { +public class MavenGotoSettingsFileContributor implements ChooseByNameContributor, DumbAware { public String[] getNames(Project project, boolean includeNonProjectItems) { if (!includeNonProjectItems) return ArrayUtil.EMPTY_STRING_ARRAY; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenGotoPropertyFileContibutor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenGotoPropertyFileContributor.java similarity index 95% rename from plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenGotoPropertyFileContibutor.java rename to plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenGotoPropertyFileContributor.java index 051736b17c78..300149c8d9cf 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenGotoPropertyFileContibutor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenGotoPropertyFileContributor.java @@ -23,7 +23,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.util.ArrayUtil; -public class MavenGotoPropertyFileContibutor implements ChooseByNameContributor { +public class MavenGotoPropertyFileContributor implements ChooseByNameContributor { public String[] getNames(Project project, boolean includeNonProjectItems) { if (!includeNonProjectItems) return ArrayUtil.EMPTY_STRING_ARRAY; return MavenPropertiesVirtualFileSystem.PROPERTIES_FILES; diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index d41f41b66e4c..efa1d0cf0c68 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -95,8 +95,9 @@ - - + + + From 6d51c9b02e99fdc6a5c1d0c18e748f549e8747ec Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Thu, 25 Nov 2010 13:15:41 +0300 Subject: [PATCH 04/10] IDEA-49650 javadoc class name completion: don't use FQN if the class is imported --- .../completion/DefaultInsertHandler.java | 9 ------- .../JavaClassNameCompletionContributor.java | 27 +++++++++++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java b/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java index f36da9923d22..743f0b1482cc 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java @@ -107,14 +107,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } - if (completionChar == '#') { - context.setLaterRunnable(new Runnable() { - public void run() { - new CodeCompletionHandlerBase(CompletionType.BASIC).invoke(project, editor, file); - } - }); - } - if (annotation) { // Check if someone inserts annotation class that require @ PsiElement elementAt = file.findElementAt(context.getStartOffset()); @@ -324,7 +316,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone case ':': return TailType.CASE_COLON; //? case '<': case '>': - case '#': case '\"': case '[': return TailType.createSimpleTailType(completionChar); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java index 2a487a5ae069..0e2cd86abad8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java @@ -17,6 +17,7 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.ExpectedTypeInfo; import com.intellij.codeInsight.ExpectedTypesProvider; +import com.intellij.codeInsight.TailType; import com.intellij.lang.LangBundle; import com.intellij.lang.StdLanguages; import com.intellij.openapi.actionSystem.IdeActions; @@ -32,6 +33,7 @@ import com.intellij.psi.filters.TrueFilter; import com.intellij.psi.filters.classes.ThisOrAnyInnerFilter; import com.intellij.psi.filters.element.ExcludeDeclaredFilter; import com.intellij.psi.filters.types.AssignableFromFilter; +import com.intellij.psi.javadoc.PsiDocTag; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.Consumer; @@ -66,8 +68,29 @@ public class JavaClassNameCompletionContributor extends CompletionContributor { return; } - if (completingRawConstructor(context, item) && !JavaCompletionUtil.hasAccessibleInnerClass(item.getObject(), file)) { - ConstructorInsertHandler.insertParentheses(context, item, item.getObject()); + PsiElement position = file.findElementAt(offset); + PsiClass psiClass = item.getObject(); + + if (context.getCompletionChar() == '#') { + context.setLaterRunnable(new Runnable() { + public void run() { + new CodeCompletionHandlerBase(CompletionType.BASIC).invoke(context.getProject(), context.getEditor(), file); + } + }); + TailType.insertChar(context.getEditor(), context.getTailOffset(), '#'); + } + + if (position != null) { + PsiElement parent = position.getParent(); + if (parent instanceof PsiJavaCodeReferenceElement && PsiTreeUtil.getParentOfType(position, PsiDocTag.class) != null) { + if (((PsiJavaCodeReferenceElement)parent).isReferenceTo(psiClass)) { + return; + } + } + } + + if (completingRawConstructor(context, item) && !JavaCompletionUtil.hasAccessibleInnerClass(psiClass, file)) { + ConstructorInsertHandler.insertParentheses(context, item, psiClass); DefaultInsertHandler.addImportForItem(context.getFile(), context.getStartOffset(), item); } else { new DefaultInsertHandler().handleInsert(context, item); From 42706b4ce60be4150108ad04e08096c2d1c82460 Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Thu, 25 Nov 2010 13:24:58 +0300 Subject: [PATCH 05/10] focus autopopup in javadoc --- .../completion/FocusInJavadoc.java | 35 +++++++++++++++++++ .../completion/JavaAutoPopupTest.groovy | 12 +++++++ resources/src/META-INF/IdeaPlugin.xml | 1 + 3 files changed, 48 insertions(+) create mode 100644 java/java-impl/src/com/intellij/codeInsight/completion/FocusInJavadoc.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/FocusInJavadoc.java b/java/java-impl/src/com/intellij/codeInsight/completion/FocusInJavadoc.java new file mode 100644 index 000000000000..95a99a37d912 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/completion/FocusInJavadoc.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.completion; + +import com.intellij.psi.javadoc.PsiDocTag; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ThreeState; +import org.jetbrains.annotations.NotNull; + +/** + * @author peter + */ +public class FocusInJavadoc extends CompletionConfidence { + @NotNull + @Override + public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) { + if (PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiDocTag.class) != null) { + return ThreeState.YES; + } + return ThreeState.UNSURE; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index d00fcbdc4c4a..a3aaf232d1ae 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -217,4 +217,16 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assert lookup } + public void testFocusInJavadoc() { + myFixture.configureByText("a.java", """ + /** + * {@link ArrLi} + */ + class Foo {} + """) + type 's' + assert lookup.focused + + } + } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index a0117012fb44..a11a1480624e 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -231,6 +231,7 @@ id="excludeFromCompletion" order="last"/> + From b77e199a2f599603dbba68d97c483dc54ea3396b Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Thu, 25 Nov 2010 14:11:07 +0300 Subject: [PATCH 06/10] more on *Impl sorting in completion --- .../codeInsight/completion/style/after15.java | 2 +- .../codeInsight/completion/style/after17.java | 2 +- .../codeInsight/completion/JavaAutoPopupTest.groovy | 12 ++++++++++++ .../impl/JavaCodeInsightTestFixtureImpl.java | 11 +++++++++-- .../completion/PrefixMatchingWeigher.java | 3 +-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/java/java-tests/testData/codeInsight/completion/style/after15.java b/java/java-tests/testData/codeInsight/completion/style/after15.java index 681bed8c16b8..1ba026a30775 100644 --- a/java/java-tests/testData/codeInsight/completion/style/after15.java +++ b/java/java-tests/testData/codeInsight/completion/style/after15.java @@ -1,6 +1,6 @@ class A{ { String str; - str.toCharArray(); + str.toString(); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/style/after17.java b/java/java-tests/testData/codeInsight/completion/style/after17.java index 3017047611de..6b9c70503bbc 100644 --- a/java/java-tests/testData/codeInsight/completion/style/after17.java +++ b/java/java-tests/testData/codeInsight/completion/style/after17.java @@ -1,7 +1,7 @@ class A{ { final String path = BASE_PATH; - path.toCharArray(); + path.toString(); sdkfjsdkhjfh(); } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index a3aaf232d1ae..34ad3cf9d0ad 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -229,4 +229,16 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } + public void testPrefixLengthDependentSorting() { + myFixture.addClass("package foo; public class PsiJavaCodeReferenceElement {}") + myFixture.configureByText("a.java", """ + class PsiJavaCodeReferenceElementImpl { + { } + } + """) + type 'PJCR' + assertOrderedEquals myFixture.lookupElementStrings, 'PsiJavaCodeReferenceElement', 'PsiJavaCodeReferenceElementImpl' + + } + } diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java b/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java index 03ac938431a5..363caf601ddf 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/impl/JavaCodeInsightTestFixtureImpl.java @@ -15,6 +15,8 @@ */ package com.intellij.testFramework.fixtures.impl; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.search.ProjectScope; @@ -49,12 +51,17 @@ public class JavaCodeInsightTestFixtureImpl extends CodeInsightTestFixtureImpl i return psiClass; } - private PsiClass addClass(@NonNls String rootPath, @NotNull @NonNls final String classText) throws IOException { + private PsiClass addClass(@NonNls final String rootPath, @NotNull @NonNls final String classText) throws IOException { final PsiClass aClass = ((PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("a.java", classText)).getClasses()[0]; final String qName = aClass.getQualifiedName(); assert qName != null; - final PsiFile psiFile = addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText); + final PsiFile psiFile = new WriteCommandAction(getProject()) { + @Override + protected void run(Result result) throws Throwable { + result.setResult(addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText)); + } + }.execute().getResultObject(); return ((PsiJavaFile)psiFile).getClasses()[0]; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java index c106d8c771a6..1d2b74f65354 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java @@ -35,8 +35,7 @@ public class PrefixMatchingWeigher extends CompletionWeigher { final String prefixHumps = StringUtil.capitalsOnly(prefix); final String itemHumps = StringUtil.capitalsOnly(lookupString); - if (itemHumps.equals(prefixHumps)) return 20; - if (itemHumps.startsWith(prefixHumps)) return 10; + if (itemHumps.startsWith(prefixHumps)) return 100 - itemHumps.length(); if (lookupString.startsWith(prefix)) return 5; if (StringUtil.startsWithIgnoreCase(lookupString, prefix)) return 1; From c9313f8a57093052d4ab81db88fca62480da8e9b Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Thu, 25 Nov 2010 14:15:01 +0300 Subject: [PATCH 07/10] IDEA-61061 MXML: Live template $END$ not ending in proper location Additional check for the given offset validness is added --- .../psi/impl/source/codeStyle/CodeStyleManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java index 9f729a8d4b8f..83491d3a0715 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java @@ -452,7 +452,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager { @Nullable private static TextRange insertNewLineIndentMarker(@NotNull Document document, final int offset) { CharSequence text = document.getCharsSequence(); - if (!isWhiteSpaceSymbol(text.charAt(offset))) { + if (offset < 0 || offset >= text.length() || !isWhiteSpaceSymbol(text.charAt(offset))) { return null; } From fec23269ab84ccb2cb1cc195e4b52ebef02613ee Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 25 Nov 2010 14:11:26 +0300 Subject: [PATCH 08/10] more accurate criterion for "corrupted" and "versionChanged" flags --- .../src/com/intellij/util/indexing/FileBasedIndex.java | 3 ++- .../openapi/vfs/newvfs/persistent/FSRecords.java | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index 531dce74dd47..2d5b574b611d 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -356,8 +356,9 @@ public class FileBasedIndex implements ApplicationComponent { } myIndexIdToVersionMap.put(name, version); final File versionFile = IndexInfrastructure.getVersionFile(name); + final boolean versionFileExisted = versionFile.exists(); if (isCurrentVersionCorrupted || IndexInfrastructure.versionDiffers(versionFile, version)) { - if (!isCurrentVersionCorrupted) { + if (!isCurrentVersionCorrupted && versionFileExisted) { versionChanged = true; LOG.info("Version has changed for index " + extension.getName() + ". The index will be rebuilt."); } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index 312ba258a2f9..45f859f031c5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -247,7 +247,15 @@ public class FSRecords implements Forceable { private static void invalidateIndex() { LOG.info("Marking VFS as corrupted"); - FileUtil.createIfDoesntExist(new File(PathManager.getIndexRoot(), "corruption.marker")); + final File indexRoot = PathManager.getIndexRoot(); + if (indexRoot.exists()) { + final String[] children = indexRoot.list(); + if (children != null && children.length > 0) { + // create index corruption marker only if index directory exists and is non-empty + // It is incorrect to consider non-existing indices "corrupted" + FileUtil.createIfDoesntExist(new File(PathManager.getIndexRoot(), "corruption.marker")); + } + } } private static File basePath() { From 753e5ec1cb512cfa69d5b5086577a9a4438ded58 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Thu, 25 Nov 2010 14:13:59 +0300 Subject: [PATCH 09/10] Maven: erroneous 'file is to big' warning from maven resource compiler fixed (IDEA-56673) --- .../jetbrains/idea/maven/compiler/MavenResourceCompiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java index 6448129cfbad..8eaa2ccd3478 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java @@ -391,7 +391,7 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler { outputFile.getParentFile().mkdirs(); boolean shouldFilter = eachItem.isFiltered(); - if (sourceFile.length() > 10 * 1024 * 1024) { + if (shouldFilter && sourceFile.length() > 10 * 1024 * 1024) { context.addMessage(CompilerMessageCategory.WARNING, "Maven: File is too big to be filtered. Most likely it is a binary file and should be excluded from filtering.", sourceVirtualFile.getUrl(), -1, -1); From c860105b1496c8ada57d060eddbd865375309b48 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Thu, 25 Nov 2010 14:37:08 +0300 Subject: [PATCH 10/10] IDEA-61798 After using RM for a while, I sometimes lose part of the chrome Added check for the logical line number correctness --- .../src/com/intellij/openapi/editor/ex/util/SegmentArray.java | 4 ++-- .../src/com/intellij/openapi/editor/impl/EditorImpl.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java index 520e2b9c8da1..9e37fb62028a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java @@ -238,14 +238,14 @@ public class SegmentArray { public int getSegmentStart(int index) { if (index < 0 || index >= mySegmentCount) { - throw new IndexOutOfBoundsException("Wrong line: " + index); + throw new IndexOutOfBoundsException("Wrong line: " + index + ". Available lines count: " + mySegmentCount); } return myStarts[index]; } public int getSegmentEnd(int index) { if (index < 0 || index >= mySegmentCount) { - throw new IndexOutOfBoundsException("Wrong line: " + index); + throw new IndexOutOfBoundsException("Wrong line: " + index + ". Available lines count: " + mySegmentCount); } return myEnds[index]; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index b2db014039fe..3aa700fda5d4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1603,6 +1603,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi if (!getFoldingModel().isOffsetCollapsed(startOffset)) { if (visibleStartLine >= startLineNumber && visibleStartLine <= endLineNumber) { int logStartLine = offsetToLogicalPosition(startOffset).line; + if (logStartLine >= myDocument.getLineCount()) { + return; + } LogicalPosition logPosition = offsetToLogicalPosition(myDocument.getLineEndOffset(logStartLine)); Point end = logicalPositionToXY(logPosition); int charWidth = EditorUtil.getSpaceWidth(Font.PLAIN, this);