EA-40613 (mirror extends list should equal to stub's one)

This commit is contained in:
Roman Shevchenko
2012-11-06 19:04:29 +01:00
parent d9068e6bf1
commit 279bdb8548
6 changed files with 33 additions and 23 deletions
@@ -52,6 +52,6 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder {
@Override
public int getStubVersion() {
return JavaFileElementType.STUB_VERSION + 5;
return JavaFileElementType.STUB_VERSION + 6;
}
}
@@ -317,9 +317,7 @@ public class ClsClassImpl extends ClsMemberImpl<PsiClassStub<?>> implements PsiE
buffer.append(isEnum() ? "enum " : isAnnotationType() ? "@interface " : isInterface() ? "interface " : "class ");
appendText(getNameIdentifier(), indentLevel, buffer, " ");
appendText(getTypeParameterList(), indentLevel, buffer, " ");
if (!isEnum() && !isAnnotationType()) {
appendText(getExtendsList(), indentLevel, buffer, " ");
}
appendText(getExtendsList(), indentLevel, buffer, " ");
appendText(getImplementsList(), indentLevel, buffer, " ");
buffer.append('{');
@@ -405,9 +403,7 @@ public class ClsClassImpl extends ClsMemberImpl<PsiClassStub<?>> implements PsiE
setMirror(getModifierList(), mirror.getModifierList());
setMirror(getNameIdentifier(), mirror.getNameIdentifier());
setMirror(getTypeParameterList(), mirror.getTypeParameterList());
if (!isEnum() && !isAnnotationType()) {
setMirror(getExtendsList(), mirror.getExtendsList());
}
setMirror(getExtendsList(), mirror.getExtendsList());
setMirror(getImplementsList(), mirror.getImplementsList());
setMirrors(getOwnFields(), mirror.getFields());
@@ -132,21 +132,35 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
}
}
String[] interfacesArray = ArrayUtil.toStringArray(convertedInterfaces);
if (isInterface) {
new PsiClassReferenceListStubImpl(JavaStubElementTypes.EXTENDS_LIST, myResult, interfacesArray, PsiReferenceList.Role.EXTENDS_LIST);
new PsiClassReferenceListStubImpl(JavaStubElementTypes.IMPLEMENTS_LIST, myResult, ArrayUtil.EMPTY_STRING_ARRAY,
PsiReferenceList.Role.IMPLEMENTS_LIST);
} else {
if (convertedSuper != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(convertedSuper)) {
new PsiClassReferenceListStubImpl(JavaStubElementTypes.EXTENDS_LIST, myResult, new String[]{convertedSuper},
PsiReferenceList.Role.EXTENDS_LIST);
} else {
new PsiClassReferenceListStubImpl(JavaStubElementTypes.EXTENDS_LIST, myResult, ArrayUtil.EMPTY_STRING_ARRAY, PsiReferenceList.Role.EXTENDS_LIST);
if (isAnnotationType) {
convertedInterfaces.remove(CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION);
}
new PsiClassReferenceListStubImpl(JavaStubElementTypes.IMPLEMENTS_LIST, myResult, interfacesArray,
PsiReferenceList.Role.IMPLEMENTS_LIST);
newReferenceList(JavaStubElementTypes.EXTENDS_LIST, myResult, ArrayUtil.toStringArray(convertedInterfaces));
newReferenceList(JavaStubElementTypes.IMPLEMENTS_LIST, myResult);
}
else {
if (convertedSuper == null ||
CommonClassNames.JAVA_LANG_OBJECT.equals(convertedSuper) ||
isEnum && (CommonClassNames.JAVA_LANG_ENUM.equals(convertedSuper) ||
(CommonClassNames.JAVA_LANG_ENUM + "<" + fqn + ">").equals(convertedSuper))) {
newReferenceList(JavaStubElementTypes.EXTENDS_LIST, myResult);
}
else {
newReferenceList(JavaStubElementTypes.EXTENDS_LIST, myResult, convertedSuper);
}
newReferenceList(JavaStubElementTypes.IMPLEMENTS_LIST, myResult, ArrayUtil.toStringArray(convertedInterfaces));
}
}
private static void newReferenceList(JavaClassReferenceListElementType type, StubElement parent, String... types) {
PsiReferenceList.Role role;
if (type == JavaStubElementTypes.EXTENDS_LIST) role = PsiReferenceList.Role.EXTENDS_LIST;
else if (type == JavaStubElementTypes.IMPLEMENTS_LIST) role = PsiReferenceList.Role.IMPLEMENTS_LIST;
else if (type == JavaStubElementTypes.THROWS_LIST) role = PsiReferenceList.Role.THROWS_LIST;
else throw new IllegalArgumentException("Unknown type: " + type);
new PsiClassReferenceListStubImpl(type, parent, types, role);
}
@Nullable
@@ -424,7 +438,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
}
String[] thrownTypes = buildThrowsList(exceptions, throwables, parsedViaGenericSignature);
new PsiClassReferenceListStubImpl(JavaStubElementTypes.THROWS_LIST, stub, thrownTypes, PsiReferenceList.Role.THROWS_LIST);
newReferenceList(JavaStubElementTypes.THROWS_LIST, stub, thrownTypes);
final int localVarIgnoreCount = (access & Opcodes.ACC_STATIC) != 0 ? 0 : isConstructor && myResult.isEnum() ? 3 : 1;
final int paramIgnoreCount = isConstructor && myResult.isEnum() ? 2 : isNonStaticInnerClassConstructor ? 1 : 0;
@@ -2,7 +2,7 @@ PsiJavaFileStub []
PsiClassStub[enum name=AnnotatedEnumConstructor fqn=AnnotatedEnumConstructor]
PsiModifierListStub[mask=17]
PsiTypeParameterListStub
PsiRefListStub[EXTENDS_LIST:java.lang.Enum<AnnotatedEnumConstructor>]
PsiRefListStub[EXTENDS_LIST:]
PsiRefListStub[IMPLEMENTS_LIST:]
PsiFieldStub[enumconst A:AnnotatedEnumConstructor]
PsiModifierListStub[mask=25]
@@ -5,7 +5,7 @@ PsiJavaFileStub [org.jetbrains.annotations]
PsiAnnotationStub[@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS)]
PsiAnnotationStub[@java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE})]
PsiTypeParameterListStub
PsiRefListStub[EXTENDS_LIST:java.lang.annotation.Annotation]
PsiRefListStub[EXTENDS_LIST:]
PsiRefListStub[IMPLEMENTS_LIST:]
PsiMethodStub[annotation value:java.lang.String default=""]
PsiModifierListStub[mask=1025]
@@ -2,7 +2,7 @@ PsiJavaFileStub [java.util.concurrent]
PsiClassStub[enum name=TimeUnit fqn=java.util.concurrent.TimeUnit]
PsiModifierListStub[mask=17]
PsiTypeParameterListStub
PsiRefListStub[EXTENDS_LIST:java.lang.Enum<java.util.concurrent.TimeUnit>]
PsiRefListStub[EXTENDS_LIST:]
PsiRefListStub[IMPLEMENTS_LIST:]
PsiFieldStub[enumconst NANOSECONDS:java.util.concurrent.TimeUnit]
PsiModifierListStub[mask=25]