From f00c415300c81337c1e3d411ac5a49464527b11a Mon Sep 17 00:00:00 2001
From: Konstantin Bulenkov
Date: Wed, 2 May 2012 12:59:53 +0200
Subject: [PATCH 01/23] IDEA-84881 Don't autoscroll to very large files
---
.../src/com/intellij/openapi/vfs}/PersistentFSConstants.java | 2 +-
.../src/com/intellij/psi/SingleRootFileViewProvider.java | 2 +-
.../com/intellij/util/indexing/FileBasedIndexExtension.java | 2 +-
.../src/com/intellij/ui/AutoScrollToSourceHandler.java | 4 ++++
4 files changed, 7 insertions(+), 3 deletions(-)
rename platform/{core-impl/src/com/intellij/openapi/vfs/newvfs/persistent => core-api/src/com/intellij/openapi/vfs}/PersistentFSConstants.java (97%)
diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSConstants.java b/platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java
similarity index 97%
rename from platform/core-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSConstants.java
rename to platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java
index 1f95ac54d3d7..40dc925bb3b1 100644
--- a/platform/core-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSConstants.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.openapi.vfs.newvfs.persistent;
+package com.intellij.openapi.vfs;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.NonNls;
diff --git a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
index af2a1cab97f5..c2fdc2a229f2 100644
--- a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
+++ b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
@@ -34,7 +34,7 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSConstants;
+import com.intellij.openapi.vfs.PersistentFSConstants;
import com.intellij.psi.impl.PsiFileEx;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.PsiManagerImpl;
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java
index a1b7a8831724..51dc7cc449d0 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java
@@ -64,7 +64,7 @@ public abstract class FileBasedIndexExtension {
*
* Use carefully, because indexing large files may influence index update speed dramatically.
*
- * @see com.intellij.openapi.vfs.newvfs.persistent.PersistentFSConstants#MAX_INTELLISENSE_FILESIZE
+ * @see com.intellij.openapi.vfs.PersistentFSConstants#MAX_INTELLISENSE_FILESIZE
*/
@NotNull
public Collection getFileTypesWithSizeLimitNotApplicable() {
diff --git a/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java b/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java
index 51e35d615f93..63b41d6aa027 100644
--- a/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java
+++ b/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java
@@ -26,6 +26,7 @@ import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.IconLoader;
+import com.intellij.openapi.vfs.PersistentFSConstants;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.pom.Navigatable;
@@ -179,6 +180,9 @@ public abstract class AutoScrollToSourceHandler {
// Attempt to navigate to the virtual file with unknown file type will show a modal dialog
// asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
if (vFile.getFileType() == FileTypes.UNKNOWN) return;
+
+ //IDEA-84881 Don't autoscroll to very large files
+ if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return;
}
Navigatable[] navigatables = PlatformDataKeys.NAVIGATABLE_ARRAY.getData(context);
if (navigatables != null) {
From ddfe5696d3d47ab2a2c73d4576b0402c4ee253d3 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Wed, 2 May 2012 13:01:50 +0400
Subject: [PATCH 02/23] typo
---
.../src/com/intellij/openapi/fileEditor/FileEditor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java
index 9d4b1f4c4315..f22010baa31a 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java
@@ -77,7 +77,7 @@ public interface FileEditor extends UserDataHolder, Disposable {
void setState(@NotNull FileEditorState state);
/**
- * @return whether the editor's content is modified in comparision with its file.
+ * @return whether the editor's content is modified in comparison with its file.
*/
boolean isModified();
From ddcdd7b8e49a941ef6823db02ae225e9766116e8 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Wed, 2 May 2012 13:11:46 +0400
Subject: [PATCH 03/23] EA-35790 - assert:
PsiDocumentManagerImpl.commitAllDocuments async editor initialization
---
.../ide/util/treeView/smartTree/SmartTreeStructure.java | 3 ---
.../lang/properties/editor/ResourceBundleEditor.java | 7 ++++++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java
index c8bde1879bce..7db150821b82 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java
@@ -32,11 +32,9 @@ public class SmartTreeStructure extends AbstractTreeStructure {
public SmartTreeStructure(@NotNull Project project, @NotNull TreeModel model) {
myModel = model;
myProject = project;
-
}
public void commit() {
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
}
@NotNull
@@ -54,7 +52,6 @@ public class SmartTreeStructure extends AbstractTreeStructure {
public Object getRootElement() {
if (myRootElementWrapper == null){
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
myRootElementWrapper = createTree();
}
return myRootElementWrapper;
diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
index 78b8859f0af9..7ddb4d84ba25 100644
--- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
@@ -300,7 +300,12 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
private final Alarm myUpdateEditorAlarm = new Alarm();
private void selectionChanged() {
myBackSlashPressed.clear();
- updateEditorsFromProperties();
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ updateEditorsFromProperties();
+ }
+ });
}
private void updateEditorsFromProperties() {
From f10c58a9d7ba15008b743a9ef412ca1e94c20d8f Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Wed, 2 May 2012 13:29:27 +0400
Subject: [PATCH 04/23] EA-35782 - assert: GuiEditor. async editor
opening
---
.../src/com/intellij/uiDesigner/designSurface/GuiEditor.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java
index b19d46b823ac..6216e97af76e 100644
--- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java
+++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java
@@ -210,10 +210,9 @@ public final class GuiEditor extends JPanel implements DataProvider {
* @param file file to be edited
* @throws java.lang.IllegalArgumentException
* if the file
- * is null or file is not falid PsiFile
+ * is null or file is not valid PsiFile
*/
public GuiEditor(@NotNull final Module module, @NotNull final VirtualFile file) {
- ApplicationManager.getApplication().assertIsDispatchThread();
LOG.assertTrue(file.isValid());
myModule = module;
From 8ac3739ab3511351550d5a27eb5bc30302c3dd13 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Wed, 2 May 2012 13:34:34 +0400
Subject: [PATCH 05/23] AE fixed
---
.../src/com/intellij/uiDesigner/designSurface/GuiEditor.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java
index 6216e97af76e..e829de30dae4 100644
--- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java
+++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java
@@ -473,7 +473,9 @@ public final class GuiEditor extends JPanel implements DataProvider {
}
// Standard Swing cut/copy/paste actions should work if user is editing something inside property inspector
- final UIDesignerToolWindowManager manager = UIDesignerToolWindowManager.getInstance(getProject());
+ Project project = getProject();
+ if (project.isDisposed()) return null;
+ final UIDesignerToolWindowManager manager = UIDesignerToolWindowManager.getInstance(project);
final PropertyInspector inspector = manager.getPropertyInspector();
if (inspector != null && inspector.isEditing()) {
return null;
From 3f049592aab634b43264eb7df38ab93783e17b13 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Wed, 2 May 2012 15:31:47 +0400
Subject: [PATCH 06/23] default highlight level
---
.../lang-api/src/com/intellij/codeInspection/InspectionEP.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java
index 1e121ba7e1ff..1169bf53bc02 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java
+++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java
@@ -107,6 +107,7 @@ public class InspectionEP extends LanguageExtensionPoint {
public String level;
public HighlightDisplayLevel getDefaultLevel() {
+ if (level == null) return HighlightDisplayLevel.WARNING;
HighlightDisplayLevel displayLevel = HighlightDisplayLevel.find(level);
if (displayLevel == null) {
LOG.error("Can't find highlight display level: " + level);
From af378a02e473776eb98cf3f4af24768bab3571dc Mon Sep 17 00:00:00 2001
From: peter
Date: Wed, 2 May 2012 13:44:14 +0200
Subject: [PATCH 07/23] preselect X instead of XImpl, again
---
.../completion/JavaCompletionSorting.java | 36 +++++++++++++++++--
.../NormalCompletionOrderingTest.groovy | 6 ++--
.../SmartTypeCompletionOrderingTest.groovy | 2 +-
.../impl/CompletionServiceImpl.java | 2 +-
.../impl/LiftShorterItemsClassifier.java | 17 +++++----
5 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index 32c1716645b4..44701a3ab0de 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -17,10 +17,13 @@ package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.ExpectedTypeInfo;
import com.intellij.codeInsight.ExpectedTypeInfoImpl;
-import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInsight.lookup.LookupElementWeigher;
-import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
+import com.intellij.codeInsight.completion.impl.CompletionSorterImpl;
+import com.intellij.codeInsight.completion.impl.LiftShorterItemsClassifier;
+import com.intellij.codeInsight.lookup.*;
+import com.intellij.openapi.roots.ProjectFileIndex;
+import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.patterns.PsiJavaPatterns;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
@@ -31,6 +34,7 @@ import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.util.ProcessingContext;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
@@ -75,6 +79,32 @@ public class JavaCompletionSorting {
CompletionSorter sorter = CompletionSorter.defaultSorter(parameters, result.getPrefixMatcher());
if (!smart && afterNew) {
sorter = sorter.weighBefore("liftShorter", new PreferExpected(true, expectedTypes));
+ } else {
+ final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(position.getProject()).getFileIndex();
+ sorter = ((CompletionSorterImpl)sorter).withClassifier("liftShorter", true, new ClassifierFactory("liftShorterClasses") {
+ @Override
+ public Classifier createClassifier(Classifier next) {
+ return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition() {
+ @Override
+ public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement, ProcessingContext context) {
+ if (super.shouldLift(shorterElement, longerElement, context)) {
+ return true;
+ }
+ Object object = shorterElement.getObject();
+ if (object instanceof PsiClass) {
+ PsiFile file = ((PsiClass)object).getContainingFile();
+ if (file != null) {
+ VirtualFile vFile = file.getOriginalFile().getVirtualFile();
+ if (vFile != null && fileIndex.isInSource(vFile)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ });
+ }
+ });
}
if (smart) {
sorter = sorter.weighBefore("negativeStats", new PreferDefaultTypeWeigher(expectedTypes, parameters));
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
index 4148143c9fce..a3c6273a587a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
@@ -101,7 +101,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
public void testDispreferImpls() throws Throwable {
myFixture.addClass("package foo; public class Xxx {}");
configureSecondCompletion();
- assertPreferredItems(1, "Xxx", "XxxEx", "XxxImpl", "Xxy");
+ assertPreferredItems(0, "Xxx", "XxxEx", "XxxImpl", "Xxy");
}
public void testPreferOwnInnerClasses() throws Throwable {
@@ -128,7 +128,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
myFixture.addClass("package foo; public interface XaYa {}");
myFixture.addClass("package foo; public interface XyYa {}");
configureSecondCompletion();
- assertPreferredItems(1, "XaYa", "XaYaEx", "XaYaImpl", "XyYa", "XyYaXa");
+ assertPreferredItems(0, "XaYa", "XaYaEx", "XaYaImpl", "XyYa", "XyYaXa");
}
public void testPreferLessParameters() throws Throwable {
@@ -219,7 +219,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testPreferClassStaticMembers() {
- checkPreferredItems(1, "Zoo", "Zoo.A", "Zoo.B", "Zoo.C", "Zoo.D", "Zoo.E", "Zoo.F", "Zoo.G", "Zoo.H");
+ checkPreferredItems(0, "Zoo", "Zoo.A", "Zoo.B", "Zoo.C", "Zoo.D", "Zoo.E", "Zoo.F", "Zoo.G", "Zoo.H");
}
public void testPreferFinallyToFinal() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy
index e8002a8be6c4..cddb71d9e6bc 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy
@@ -21,7 +21,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testJComponentAdd() throws Throwable {
- checkPreferredItems(0, "name", "b", "fooBean239", "this", "getName");
+ checkPreferredItems(0, "name", "b", "foo", "fooBean239", "this", "getName");
}
public void testJComponentAddNew() throws Throwable {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java
index aa3a9510ae46..4854888bfc60 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java
@@ -292,7 +292,7 @@ public class CompletionServiceImpl extends CompletionService{
return sorter.withClassifier("priority", true, new ClassifierFactory("liftShorter") {
@Override
public Classifier createClassifier(final Classifier next) {
- return new LiftShorterItemsClassifier(next);
+ return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition());
}
});
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java
index 4a05b7758acf..65391ce8e046 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java
@@ -30,14 +30,16 @@ import java.util.*;
/**
* @author peter
*/
-class LiftShorterItemsClassifier extends Classifier {
+public class LiftShorterItemsClassifier extends Classifier {
private final TreeSet mySortedStrings;
private final MultiMap myElements;
private final MultiMap myPrefixes;
private final Classifier myNext;
+ private final LiftingCondition myCondition;
- public LiftShorterItemsClassifier(Classifier next) {
+ public LiftShorterItemsClassifier(Classifier next, LiftingCondition condition) {
myNext = next;
+ myCondition = condition;
mySortedStrings = new TreeSet();
myElements = new MultiMap();
myPrefixes = new MultiMap();
@@ -76,9 +78,6 @@ class LiftShorterItemsClassifier extends Classifier {
@Override
public Iterable classify(Iterable source, ProcessingContext context) {
- if (context.get(CompletionLookupArranger.PURE_RELEVANCE) == Boolean.TRUE) {
- return myNext.classify(source, context);
- }
return liftShorterElements(source, new THashSet(TObjectHashingStrategy.IDENTITY), context);
}
@@ -99,7 +98,7 @@ class LiftShorterItemsClassifier extends Classifier {
for (String prefix : prefixes) {
List shorter = new SmartList();
for (LookupElement shorterElement : myElements.get(prefix)) {
- if (srcSet.contains(shorterElement) && processed.add(shorterElement)) {
+ if (srcSet.contains(shorterElement) && myCondition.shouldLift(shorterElement, element, context) && processed.add(shorterElement)) {
shorter.add(shorterElement);
}
}
@@ -134,4 +133,10 @@ class LiftShorterItemsClassifier extends Classifier {
}
myNext.describeItems(map, context);
}
+
+ public static class LiftingCondition {
+ public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement, ProcessingContext context) {
+ return context.get(CompletionLookupArranger.PURE_RELEVANCE) != Boolean.TRUE;
+ }
+ }
}
From 763eba0f106f84a7501f1ffb1581d5410e362ec4 Mon Sep 17 00:00:00 2001
From: Dmitry Jemerov
Date: Wed, 2 May 2012 13:57:58 +0200
Subject: [PATCH 08/23] PY-6478
---
.../impl/UniqueNameEditorTabTitleProvider.java | 18 +++++++++++++++++-
.../impl/UniqueVFilePathBuilderImpl.java | 2 +-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java
index 529d7be987b2..183183ed4bea 100644
--- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java
+++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2012 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.fileEditor.impl;
import com.intellij.ide.ui.UISettings;
@@ -15,6 +30,7 @@ public class UniqueNameEditorTabTitleProvider implements EditorTabTitleProvider
if (!UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES || DumbService.isDumb(project)) {
return null;
}
- return UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file);
+ final String uniqueName = UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file);
+ return uniqueName.equals(file.getName()) ? null : uniqueName;
}
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java
index c79e68c04bd6..d9ee50ab9104 100644
--- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java
@@ -35,7 +35,7 @@ public class UniqueVFilePathBuilderImpl extends UniqueVFilePathBuilder {
public String getUniqueVirtualFilePath(Project project, VirtualFile file) {
final Collection filesWithSameName = FilenameIndex.getVirtualFilesByName(project, file.getName(),
ProjectScope.getProjectScope(project));
- if (filesWithSameName.size() > 1) {
+ if (filesWithSameName.size() > 1 && filesWithSameName.contains(file)) {
String path = project.getBasePath();
path = path == null ? "" : FileUtil.toSystemIndependentName(path);
UniqueNameBuilder builder = new UniqueNameBuilder(path, File.separator, 25);
From 2ddf48709bc8f1e5b83e4fae04e1e29d08da2f2e Mon Sep 17 00:00:00 2001
From: Vassiliy Kudryashov
Date: Wed, 2 May 2012 16:19:53 +0400
Subject: [PATCH 09/23] IDEA-73339 Add a 'Restart' button & shortcut to the Run
pane
---
platform/icons/src/actions/restart.png | Bin 0 -> 639 bytes
.../intellij/execution/runners/RestartAction.java | 11 +++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
create mode 100644 platform/icons/src/actions/restart.png
diff --git a/platform/icons/src/actions/restart.png b/platform/icons/src/actions/restart.png
new file mode 100644
index 0000000000000000000000000000000000000000..beb592feb05db60678b1c90a28489346a5552edd
GIT binary patch
literal 639
zcmV-_0)YLAP)o@VxQNB^sD|F3ZUplJW3YyQNY@L@IirGfEpMdd;n
z-!~2ScS!!BX#JOBLXkQ~!ZGMa9{Y}4?o%x9RW0sTEbL7r^n*`5j5zjqN$*}V=|t
zMjhuu8S;ETJBl@5=0)H+4?NQ~Ima_DlPLR*TH!hn;5ZKMbSgQBG*R9`Ij1ref*2o=
zAm>RQ@L)9mt#3DnGDz7xB9|c{k{>C5B>$*x|EFy=hB86cI3tN9{hem_dP^>UE&r)+
z=|~?&z(o9yTO*Gm{E}Y#j$HeQR{O4rMZQG+on`KCHTQN&^lCr%mvBIiIdAMyN4!O#
zgGx)hL_?4|c=1+Ax=Lb&J=Jd||EzD|Jq`PjU1jG?RK!d)s5w5eK=$tgJ^%m!6m(Kf
zQvl`w{{Hg*0N5t}(k1==0KgdVUNo$7gDzA{e!my;)b}ryMK6GKl24!usfVCx98{g
z?|&i`QDF54f}wB(L6BHHL4i1hrZd@GzEGS=q|9|$wN`I5Pfh`gsnhM9odd9k;l(AO
Z+5i^Z9L*`J!(0FW002ovPDHLkV1h)uA=v-`
literal 0
HcmV?d00001
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java
index e995243dd5c5..9571d8ca97da 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java
@@ -24,6 +24,7 @@ import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
@@ -31,10 +32,13 @@ import javax.swing.*;
* @author dyoma
*/
public class RestartAction extends AnAction implements DumbAware {
+ private static final Icon STOP_AND_START_ICON = IconLoader.getIcon("/actions/restart.png");
+
private ProcessHandler myProcessHandler;
private final ProgramRunner myRunner;
private final RunContentDescriptor myDescriptor;
private final Executor myExecutor;
+ private final Icon myIcon;
private final ExecutionEnvironment myEnvironment;
public RestartAction(final Executor executor,
@@ -44,6 +48,7 @@ public class RestartAction extends AnAction implements DumbAware {
final RunContentDescriptor descritor,
final ExecutionEnvironment env) {
super(null, null, icon);
+ myIcon = icon;
myEnvironment = env;
getTemplatePresentation().setEnabled(false);
myProcessHandler = processHandler;
@@ -55,6 +60,7 @@ public class RestartAction extends AnAction implements DumbAware {
public void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
+ ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM).actionPerformed(e);
doRestart(dataContext);
}
@@ -65,7 +71,7 @@ public class RestartAction extends AnAction implements DumbAware {
private void doRestart(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId())) {
- return;
+ return;
}
try {
final ExecutionEnvironment old = myEnvironment;
@@ -86,8 +92,9 @@ public class RestartAction extends AnAction implements DumbAware {
if (myProcessHandler != null && !isRunning) {
myProcessHandler = null; // already terminated
}
+ presentation.setIcon(isRunning ? STOP_AND_START_ICON : myIcon);
- presentation.setEnabled(!isRunning /*&& myRunner.canRun(, myProfile)*/ && !ExecutorRegistry.getInstance().isStarting(myEnvironment.getProject(), myExecutor.getId(), myRunner.getRunnerId()));
+ presentation.setEnabled(true);
}
public void registerShortcut(final JComponent component) {
From edd506825b90eea5f1f667344e797515b21f0c2d Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 2 May 2012 14:01:06 +0400
Subject: [PATCH 10/23] Remove unused methods.
---
.../repo/GitUntrackedFilesHolder.java | 24 +------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
index feabdb62c367..7acbebab702e 100644
--- a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
+++ b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
@@ -39,7 +39,7 @@ import java.util.Set;
/**
*
* Stores files which are untracked by the Git repository.
- * Should be updated by calling {@link #add(com.intellij.openapi.vfs.VirtualFile)} and {@link #remove(com.intellij.openapi.vfs.VirtualFile)}
+ * Should be updated by calling {@link #add(com.intellij.openapi.vfs.VirtualFile)} and {@link #remove(java.util.Collection)}
* whenever the list of unversioned files changes.
* Able to get the list of unversioned files from Git.
*
@@ -130,28 +130,6 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
}
}
- /**
- * Adds several files to the list of untracked.
- */
- public void add(@NotNull Collection files) {
- synchronized (LOCK) {
- if (myReady) {
- myDefinitelyUntrackedFiles.addAll(files);
- }
- }
- }
-
- /**
- * Removes the file from untracked.
- */
- public void remove(@NotNull VirtualFile file) {
- synchronized (LOCK) {
- if (myReady) {
- myDefinitelyUntrackedFiles.remove(file);
- }
- }
- }
-
/**
* Removes several files from untracked.
*/
From a3ddc5d210f8130673077cb94e717df6ea1aa156 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 2 May 2012 14:16:42 +0400
Subject: [PATCH 11/23] GitUntrackedFilesHolder: remove myPossiblyTrackedFiles:
the collection is not updated and not used.
---
.../git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java | 5 -----
1 file changed, 5 deletions(-)
diff --git a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
index 7acbebab702e..cd91d5aa2c02 100644
--- a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
+++ b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
@@ -86,7 +86,6 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
private Set myDefinitelyUntrackedFiles = new HashSet();
private Set myPossiblyUntrackedFiles = new HashSet();
- private Set myPossiblyTrackedFiles = new HashSet();
private boolean myReady; // if false, total refresh is needed
private final Object LOCK = new Object();
private final GitRepositoryManager myRepositoryManager;
@@ -115,7 +114,6 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
synchronized (LOCK) {
myDefinitelyUntrackedFiles.clear();
myPossiblyUntrackedFiles.clear();
- myPossiblyTrackedFiles.clear();
}
}
@@ -173,7 +171,6 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
synchronized (LOCK) {
myDefinitelyUntrackedFiles = untrackedFiles;
myPossiblyUntrackedFiles.clear();
- myPossiblyTrackedFiles.clear();
myReady = true;
}
}
@@ -194,7 +191,6 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
Set suspiciousFiles = new HashSet();
synchronized (LOCK) {
suspiciousFiles.addAll(myPossiblyUntrackedFiles);
- suspiciousFiles.addAll(myPossiblyTrackedFiles);
}
Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, suspiciousFiles);
@@ -204,7 +200,6 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
synchronized (LOCK) {
myPossiblyUntrackedFiles.clear();
- myPossiblyTrackedFiles.clear();
myDefinitelyUntrackedFiles.addAll(untrackedFiles);
myDefinitelyUntrackedFiles.removeAll(trackedFiles);
}
From 4738fe33f9869fa6246a1f799c3abd8656a6d200 Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 2 May 2012 17:04:40 +0400
Subject: [PATCH 12/23] IDEA-85521 Sometimes file appear both as ADDED and
UNVERSIONED
Root cause:
Race condition around verifyPossiblyUntrackedFiles():
1) AWT: File created. Added to myPossiblyUntrackedFiles.
2) T2: starts background thread T2 to check file for ignorance and add it to Git.
3) T1: File is marked dirty, its status is queried by GitChangeProvider in T1.
4) T1: verifyPossiblyUntrackedFiles asks the state of the file, it is untracked, and it is put into untrackedFiles temp variable.
5) T2: File is added to Git.
6) T2: File is removed from myDUF, it is not there, but nobody cares.
7) T1: File is added to myDUF from verifyPossiblyUntrackedFiles.
Solution:
Check untracked files under the lock.
The LOCK is used in after() => not to lock the AWT, use a separate lock for myDefinitelyUntrackedFiles, leaving the LOCK for myReady and myPossiblyUntrackedFiles.
Don't check for myReady in add()/remove() - it is not necessary.
---
.../repo/GitUntrackedFilesHolder.java | 49 +++++++++++--------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
index cd91d5aa2c02..c748728f852e 100644
--- a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
+++ b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
@@ -68,10 +68,18 @@ import java.util.Set;
* In some cases (file creation/deletion) the file is not silently added/removed from the list - instead the file is marked as
* "possibly untracked" and Git is asked for the exact status of this file.
* It is needed, since the file may be created and added to the index independently, and events may race.
- *
+ *
+ *
* Also, if .git/index changes, then a full refresh is initiated. The reason is not only untracked files tracking, but also handling
* committing outside IDEA, etc.
*
+ *
+ * Synchronization policy used in this class:
+ * myDefinitelyUntrackedFiles is accessed under the myDefinitelyUntrackedFiles lock.
+ * myPossiblyUntrackedFiles and myReady is accessed under the LOCK lock.
+ * This is done so, because the latter two variables are accessed from the AWT in after() and we don't want to lock the AWT long,
+ * while myDefinitelyUntrackedFiles is modified along with native request to Git.
+ *
*
* @author Kirill Likhodedov
*/
@@ -84,8 +92,8 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
private final GitRepositoryFiles myRepositoryFiles;
private final Git myGit;
- private Set myDefinitelyUntrackedFiles = new HashSet();
- private Set myPossiblyUntrackedFiles = new HashSet();
+ private final Set myDefinitelyUntrackedFiles = new HashSet();
+ private final Set myPossiblyUntrackedFiles = new HashSet();
private boolean myReady; // if false, total refresh is needed
private final Object LOCK = new Object();
private final GitRepositoryManager myRepositoryManager;
@@ -111,8 +119,10 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
@Override
public void dispose() {
- synchronized (LOCK) {
+ synchronized (myDefinitelyUntrackedFiles) {
myDefinitelyUntrackedFiles.clear();
+ }
+ synchronized (LOCK) {
myPossiblyUntrackedFiles.clear();
}
}
@@ -121,10 +131,8 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
* Adds the file to the list of untracked.
*/
public void add(@NotNull VirtualFile file) {
- synchronized (LOCK) {
- if (myReady) {
- myDefinitelyUntrackedFiles.add(file);
- }
+ synchronized (myDefinitelyUntrackedFiles) {
+ myDefinitelyUntrackedFiles.add(file);
}
}
@@ -132,10 +140,8 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
* Removes several files from untracked.
*/
public void remove(@NotNull Collection files) {
- synchronized (LOCK) {
- if (myReady) {
- myDefinitelyUntrackedFiles.removeAll(files);
- }
+ synchronized (myDefinitelyUntrackedFiles) {
+ myDefinitelyUntrackedFiles.removeAll(files);
}
}
@@ -152,7 +158,7 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
} else {
rescanAll();
}
- synchronized (LOCK) {
+ synchronized (myDefinitelyUntrackedFiles) {
return myDefinitelyUntrackedFiles;
}
}
@@ -168,8 +174,11 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
*/
public void rescanAll() throws VcsException {
Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, null);
+ synchronized (myDefinitelyUntrackedFiles) {
+ myDefinitelyUntrackedFiles.clear();
+ myDefinitelyUntrackedFiles.addAll(untrackedFiles);
+ }
synchronized (LOCK) {
- myDefinitelyUntrackedFiles = untrackedFiles;
myPossiblyUntrackedFiles.clear();
myReady = true;
}
@@ -191,15 +200,15 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
Set suspiciousFiles = new HashSet();
synchronized (LOCK) {
suspiciousFiles.addAll(myPossiblyUntrackedFiles);
+ myPossiblyUntrackedFiles.clear();
}
- Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, suspiciousFiles);
- suspiciousFiles.removeAll(untrackedFiles);
- // files that were suspicious (and thus passed to 'git ls-files'), but are not untracked, are definitely tracked.
- Set trackedFiles = suspiciousFiles;
+ synchronized (myDefinitelyUntrackedFiles) {
+ Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, suspiciousFiles);
+ suspiciousFiles.removeAll(untrackedFiles);
+ // files that were suspicious (and thus passed to 'git ls-files'), but are not untracked, are definitely tracked.
+ Set trackedFiles = suspiciousFiles;
- synchronized (LOCK) {
- myPossiblyUntrackedFiles.clear();
myDefinitelyUntrackedFiles.addAll(untrackedFiles);
myDefinitelyUntrackedFiles.removeAll(trackedFiles);
}
From 38d4a494af1dc35de59deabb762811b5c08d3c7d Mon Sep 17 00:00:00 2001
From: Kirill Likhodedov
Date: Wed, 2 May 2012 18:06:20 +0400
Subject: [PATCH 13/23] Don't allow duplicates in the "author" field of Git
commit dialog.
---
.../git4idea/src/git4idea/checkin/GitCheckinEnvironment.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
index 19c3319527da..1f3fc88dd2a2 100644
--- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
+++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
@@ -608,9 +608,9 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
final List usersList = getUsersList(project, roots);
- final List authors = usersList == null ? new ArrayList() : new ArrayList(usersList);
+ final Set authors = usersList == null ? new HashSet() : new HashSet(usersList);
ContainerUtil.addAll(authors, mySettings.getCommitAuthors());
- Collections.sort(authors);
+ Collections.sort(new ArrayList(authors));
myAuthor = new JComboBox(ArrayUtil.toObjectArray(authors));
myAuthor.insertItemAt("", 0);
myAuthor.setSelectedItem("");
From 2f2c45017f00df1bc0b6f43699619d6ca3dd09aa Mon Sep 17 00:00:00 2001
From: Anton Makeev
Date: Wed, 2 May 2012 16:22:51 +0200
Subject: [PATCH 14/23] Platform: do not reset tool window's size to the
default when project reload is triggered during project opening (OC-3716)
---
.../src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
index 416e46a6c719..8a75838fcdaf 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
@@ -2069,6 +2069,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
* tool window depending on decoration type.
*/
public void resized(final InternalDecorator source) {
+ if (!source.isShowing()) return; // do not recalculate the tool window size if it is not yet shown (and, therefore, has 0,0,0,0 bounds)
+
final WindowInfoImpl info = getInfo(source.getToolWindow().getId());
if (info.isFloating()) {
final Window owner = SwingUtilities.getWindowAncestor(source);
From 01b70772661cde82980c752ee0886e7ded8e0c80 Mon Sep 17 00:00:00 2001
From: Eugene Zhuravlev
Date: Wed, 2 May 2012 16:23:04 +0200
Subject: [PATCH 15/23] drop obsolete "compile in background" option
---
.../intellij/compiler/impl/CompileDriver.java | 4 ++--
.../compiler/options/CompilerOptionsPanel.form | 18 +++++-------------
.../options/CompilerUIConfigurable.java | 4 ----
.../CompilerWorkspaceConfiguration.java | 1 -
.../jetbrains/idea/maven/MavenTestCase.java | 6 ------
5 files changed, 7 insertions(+), 26 deletions(-)
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index 6c32c762ce30..9f2f04988fed 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -647,7 +647,7 @@ public class CompileDriver {
final String contentName =
forceCompile ? CompilerBundle.message("compiler.content.name.compile") : CompilerBundle.message("compiler.content.name.make");
- final boolean compileInBackground = useServer? true : CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND;
+ final boolean compileInBackground = true;
final CompilerTask compileTask =
new CompilerTask(myProject, compileInBackground, contentName, ApplicationManager.getApplication().isUnitTestMode());
@@ -2250,7 +2250,7 @@ public class CompileDriver {
public void executeCompileTask(final CompileTask task, final CompileScope scope, final String contentName, final Runnable onTaskFinished) {
final CompilerTask progressManagerTask =
- new CompilerTask(myProject, CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND, contentName, false);
+ new CompilerTask(myProject, true, contentName, false);
final CompileContextImpl compileContext = new CompileContextImpl(myProject, progressManagerTask, scope, null, false, false);
FileDocumentManager.getInstance().saveAllDocuments();
diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form
index fceb7255b549..64a4db5bc0ac 100644
--- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form
+++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form
@@ -1,6 +1,6 @@