From a0c1b45505f48a5a77f73c84e1d55b56e97ded91 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 27 Feb 2013 13:50:09 +0100 Subject: [PATCH 1/8] some OpenTHashSet doc --- .../util/src/com/intellij/util/containers/OpenTHashSet.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/util/src/com/intellij/util/containers/OpenTHashSet.java b/platform/util/src/com/intellij/util/containers/OpenTHashSet.java index 40e5a7d1ab31..9f201b6c7f05 100644 --- a/platform/util/src/com/intellij/util/containers/OpenTHashSet.java +++ b/platform/util/src/com/intellij/util/containers/OpenTHashSet.java @@ -22,6 +22,9 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; /** + * Makes some THashSet methods open to the public. + * Adds {@link #get(Object)} method useful to intern objects. + * * @author gregsh */ public class OpenTHashSet extends THashSet { @@ -66,6 +69,9 @@ public class OpenTHashSet extends THashSet { return (T)_set[index]; } + /** + * Returns an element of this set equal to the give one. Can be used for interning objects to save memory. + */ @Nullable public T get(final T obj) { final int index = index(obj); From ee30e3c80abd2888eb949dea920f705ca3201848 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 27 Feb 2013 14:57:51 +0400 Subject: [PATCH 2/8] cleanup --- .../convertToJava/ExpressionGenerator.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java index 9288368d2486..3feab9d73313 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -21,7 +21,6 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.light.LightElement; -import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; @@ -455,14 +454,11 @@ public class ExpressionGenerator extends Generator { getRValue(expression) }; GroovyResolveResult[] candidates = type != null - ? ResolveUtil - .getMethodCandidates(type, "setProperty", expression, args[0].getType(), args[1].getType()) + ? ResolveUtil.getMethodCandidates(type, "setProperty", expression, args[0].getType(), args[1].getType()) : GroovyResolveResult.EMPTY_ARRAY; - final PsiElement method = PsiImplUtil.extractUniqueElement(candidates); - - if (method instanceof PsiMethod) { - writeAssignmentWithSetter(qualifier, (PsiMethod)method, args, GrNamedArgument.EMPTY_ARRAY, EMPTY_ARRAY, PsiSubstitutor.EMPTY, - expression); + final PsiMethod method = PsiImplUtil.extractUniqueElement(candidates); + if (method != null) { + writeAssignmentWithSetter(qualifier, method, args, GrNamedArgument.EMPTY_ARRAY, EMPTY_ARRAY, PsiSubstitutor.EMPTY, expression); return; } } @@ -1017,10 +1013,9 @@ public class ExpressionGenerator extends Generator { } else { //unresolved reference - final String refName = referenceName; - if (refName != null) { + if (referenceName != null) { if (PsiUtil.isAccessedForWriting(referenceExpression)) { - builder.append(refName); + builder.append(referenceName); } else { PsiType stringType = PsiType.getJavaLangString(referenceExpression.getManager(), referenceExpression.getResolveScope()); @@ -1031,10 +1026,10 @@ public class ExpressionGenerator extends Generator { : GroovyResolveResult.EMPTY_ARRAY; final PsiElement method = PsiImplUtil.extractUniqueElement(candidates); if (method != null) { - builder.append("getProperty(\"").append(refName).append("\")"); + builder.append("getProperty(\"").append(referenceName).append("\")"); } else { - builder.append(refName); + builder.append(referenceName); } } } @@ -1256,8 +1251,6 @@ public class ExpressionGenerator extends Generator { } } final PsiType[] argTypes = PsiUtil.getArgumentTypes(argList); - final PsiManager manager = expression.getManager(); - final GlobalSearchScope resolveScope = expression.getResolveScope(); final GrExpression[] exprArgs = argList.getExpressionArguments(); final GrNamedArgument[] namedArgs = argList.getNamedArguments(); From ea917a3db4a2fe6407c58130c8ec4cd5f4849fea Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 27 Feb 2013 17:08:01 +0400 Subject: [PATCH 3/8] fix surrounder tests --- .../surroundWith/SurrounderOrderTest.groovy | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurrounderOrderTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurrounderOrderTest.groovy index 76c884173a6f..c6df083b3e36 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurrounderOrderTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurrounderOrderTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -15,10 +15,10 @@ */ package org.jetbrains.plugins.groovy.lang.surroundWith -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler import com.intellij.openapi.actionSystem.Separator import com.intellij.openapi.application.WriteAction +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase /** * @author peter @@ -28,11 +28,16 @@ class SurrounderOrderTest extends LightCodeInsightFixtureTestCase { public void testStatementSurrounders() { def names = getSurrounders("println a") assertOrderedEquals names, - "if", "if / else", "while", + "if", "if / else", + "while", "{ -> ... }.call()", - "for", "try / catch", "try / finally", "try / catch / finally", + "for", "try / catch", + "try / finally", + "try / catch / finally", "shouldFail () {...}", - "(expr)", "((Type) expr)", + "(expr)", + "!(expr)", + "((Type) expr)", "with () {...}" } @@ -61,19 +66,29 @@ println c /*also important */ public void testInnerExpressionSurrounders() { def names = getSurrounders("boolean a; println a") - assertOrderedEquals names, "(expr)", "((Type) expr)" + assertOrderedEquals names, "(expr)", "!(expr)", "((Type) expr)" } public void testOuterExpressionSurrounders() { def names = getSurrounders("boolean a; a") assertOrderedEquals names, - "if", "if / else", "while", + "if", + "if / else", + "while", "{ -> ... }.call()", - "for", "try / catch", "try / finally", "try / catch / finally", + "for", + "try / catch", + "try / finally", + "try / catch / finally", "shouldFail () {...}", - "(expr)", "((Type) expr)", + "(expr)", + "!(expr)", + "((Type) expr)", "with () {...}", - "if (expr)", "if (expr) / else", "while (expr)", "with (expr)" + "if (expr)", + "if (expr) / else", + "while (expr)", + "with (expr)" } private List getSurrounders(final String fileText) { From 72f87c065ef7cdede9ef5908ac3cfbe795b167e0 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 27 Feb 2013 17:08:16 +0400 Subject: [PATCH 4/8] fix typo --- .../groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 96d4e0c41b4a..ff4eeb01b68a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -421,7 +421,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { } public PsiElement createModifierFromText(String name) { - final GroovyFileBase file = createGroovyFileChecked(name + "foo() {}"); + final GroovyFileBase file = createGroovyFileChecked(name + " foo() {}"); final GrTopLevelDefinition[] definitions = file.getTopLevelDefinitions(); if (definitions.length != 1) throw new IncorrectOperationException(name); return definitions[0].getFirstChild().getFirstChild(); From 9b729351c07040304c54edd962281bf0f9fef02a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 27 Feb 2013 13:43:04 +0100 Subject: [PATCH 5/8] API to allow SDK type to check if the SDK path is valid, so that remote SDKs can be highlighted as valid even if they don't have a valid home directory (required for PY-8079) --- .../roots/ui/OrderEntryAppearanceServiceImpl.java | 6 +++--- .../com/intellij/openapi/projectRoots/SdkType.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/OrderEntryAppearanceServiceImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/OrderEntryAppearanceServiceImpl.java index 154a03534105..7ce323537d05 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/OrderEntryAppearanceServiceImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/OrderEntryAppearanceServiceImpl.java @@ -122,9 +122,9 @@ public class OrderEntryAppearanceServiceImpl extends OrderEntryAppearanceService String name = jdk.getName(); CompositeAppearance appearance = new CompositeAppearance(); - appearance.setIcon(((SdkType) jdk.getSdkType()).getIcon()); - VirtualFile homeDirectory = jdk.getHomeDirectory(); - SimpleTextAttributes attributes = getTextAttributes(homeDirectory != null && homeDirectory.isValid(), selected); + SdkType sdkType = (SdkType)jdk.getSdkType(); + appearance.setIcon(sdkType.getIcon()); + SimpleTextAttributes attributes = getTextAttributes(sdkType.sdkHasValidPath(jdk), selected); CompositeAppearance.DequeEnd ending = appearance.getEnding(); ending.addText(name, attributes); diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java index 31072561f21f..32f9a1673395 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/SdkType.java @@ -224,4 +224,17 @@ public abstract class SdkType implements SdkTypeId { */ public void showCustomCreateUI(SdkModel sdkModel, JComponent parentComponent, Consumer sdkCreatedCallback) { } + + /** + * Checks if the home directory of the specified SDK is valid. By default, checks that the directory points to a valid local + * path. Can be overridden for remote SDKs. + * + * @param sdk the SDK to validate the path for. + * @return true if the home path is valid, false otherwise. + * @since 12.1 + */ + public boolean sdkHasValidPath(@NotNull Sdk sdk) { + VirtualFile homeDir = sdk.getHomeDirectory(); + return homeDir != null && homeDir.isValid(); + } } From b2f7501579a25fd780beedb47656eee7a7033f42 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Wed, 27 Feb 2013 17:19:57 +0400 Subject: [PATCH 6/8] IDEA-101776 Gradle: Avoid ide hang on auto-import Don't call to LibraryImpl.getFiles() as that takes too much time for libraries with huge number of jars --- .../gradle/ui/GradleProjectStructureNodeComparator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeComparator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeComparator.java index 021b790398d2..1981199cf4ea 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeComparator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/ui/GradleProjectStructureNodeComparator.java @@ -77,6 +77,9 @@ public class GradleProjectStructureNodeComparator implements Comparator Date: Wed, 27 Feb 2013 14:23:49 +0100 Subject: [PATCH 7/8] IDEA-101989 Darcula: red color in editor tab is too bright --- .../com/intellij/openapi/fileEditor/impl/EditorsSplitters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java index cb82d467761b..2d99cfbe5443 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java @@ -461,7 +461,7 @@ public class EditorsSplitters extends JBPanel { final int index = window.findEditorIndex(window.findFileComposite(file)); LOG.assertTrue(index != -1); window.setForegroundAt(index, getManager().getFileColor(file)); - window.setWaveColor(index, getManager().isProblem(file) ? Color.red : null); + window.setWaveColor(index, getManager().isProblem(file) ? JBColor.red : null); } } From 8c1de3f8eed7ce9518b5f73819c087b839cf4993 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 27 Feb 2013 17:29:35 +0400 Subject: [PATCH 8/8] EA-39139 - CCE: DomServiceImpl.calcXmlFileHeader --- .../src/com/intellij/util/xml/impl/DomServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java index 00c13e716610..b2c5ca5915ce 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java @@ -31,6 +31,7 @@ import com.intellij.psi.PsiManager; import com.intellij.psi.impl.PsiFileEx; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.stubs.ObjectStubTree; +import com.intellij.psi.stubs.Stub; import com.intellij.psi.stubs.StubTreeLoader; import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValueProvider; @@ -76,7 +77,10 @@ public class DomServiceImpl extends DomService { if (virtualFile instanceof VirtualFileWithId) { ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile); if (tree != null) { - return ((FileStub)tree.getRoot()).getHeader(); + Stub root = tree.getRoot(); + if (root instanceof FileStub) { + return ((FileStub)root).getHeader(); + } } } }