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(); + } } 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); } } 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); 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 Comparatorprintln 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) { 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(); + } } } }