open capture reverted

This commit is contained in:
anna
2013-05-06 12:20:10 +02:00
parent f960fa1839
commit 9980be6961
3 changed files with 10 additions and 5 deletions
@@ -235,6 +235,11 @@ public class GenericsUtil {
@Nullable
public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type) {
return getVariableTypeByExpressionType(type, true);
}
@Nullable
public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type, final boolean openCaptured) {
if (type == null) return null;
if (type instanceof PsiCapturedWildcardType) {
type = ((PsiCapturedWildcardType)type).getWildcard();
@@ -274,7 +279,7 @@ public class GenericsUtil {
@Override
public PsiType visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
return capturedWildcardType;
return openCaptured ? capturedWildcardType.getWildcard().accept(this) : capturedWildcardType;
}
@Override
@@ -46,7 +46,7 @@ public class PsiArrayAccessExpressionImpl extends ExpressionPsiElement implement
public PsiType getType() {
PsiType arrayType = getArrayExpression().getType();
if (!(arrayType instanceof PsiArrayType)) return null;
return GenericsUtil.getVariableTypeByExpressionType(((PsiArrayType)arrayType).getComponentType());
return GenericsUtil.getVariableTypeByExpressionType(((PsiArrayType)arrayType).getComponentType(), false);
}
@Override
@@ -177,7 +177,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
}
public void testSCR40281() throws Exception {
doTest(new MockIntroduceVariableHandler("temp", false, false, false, "Set<? extends Map<?,java.lang.String>.Entry<capture<?>,java.lang.String>>"));
doTest(new MockIntroduceVariableHandler("temp", false, false, false, "Set<? extends Map<?,java.lang.String>.Entry<?,java.lang.String>>"));
}
public void testWithIfBranches() throws Exception {
@@ -189,7 +189,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
}
public void testDuplicateGenericExpressions() throws Exception {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "Foo2<capture<? extends java.lang.Runnable>>"));
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "Foo2<? extends java.lang.Runnable>"));
}
public void testStaticImport() throws Exception {
@@ -308,7 +308,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
}
public void testAssignmentToUnresolvedReference() throws Exception {
doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List<? extends java.util.Collection<capture<?>>>"));
doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List<? extends java.util.Collection<?>>"));
}
public void testNameSuggestion() throws Exception {