Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vassiliy Kudryashov
2013-02-27 17:45:06 +04:00
9 changed files with 66 additions and 32 deletions
@@ -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);
@@ -224,4 +224,17 @@ public abstract class SdkType implements SdkTypeId {
*/
public void showCustomCreateUI(SdkModel sdkModel, JComponent parentComponent, Consumer<Sdk> 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();
}
}
@@ -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);
}
}
@@ -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<T> extends THashSet<T> {
@@ -66,6 +69,9 @@ public class OpenTHashSet<T> extends THashSet<T> {
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);
@@ -77,6 +77,9 @@ public class GradleProjectStructureNodeComparator implements Comparator<GradlePr
if (id.getType() == GradleEntityType.SYNTHETIC) {
return SYNTHETIC_WEIGHT;
}
else if (id.getType() == GradleEntityType.JAR) {
return JAR_WEIGHT;
}
Object entity = id.mapToEntity(myContext);
if (entity instanceof AbstractGradleCompositeEntity) {
entity = ((AbstractGradleCompositeEntity)entity).getIdeEntity();
@@ -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();
@@ -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();
@@ -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("<selection>println a</selection>")
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 <selection>a</selection>")
assertOrderedEquals names, "(expr)", "((Type) expr)"
assertOrderedEquals names, "(expr)", "!(expr)", "((Type) expr)"
}
public void testOuterExpressionSurrounders() {
def names = getSurrounders("boolean a; <selection>a</selection>")
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<String> getSurrounders(final String fileText) {
@@ -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();
}
}
}
}