mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: correct stub for enums compiled by Groovy
This commit is contained in:
@@ -409,7 +409,8 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
if (SYNTHETIC_CLASS_INIT_METHOD.equals(name)) return null;
|
||||
|
||||
// skip semi-synthetic enum methods
|
||||
if (myResult.isEnum()) {
|
||||
boolean isEnum = myResult.isEnum();
|
||||
if (isEnum) {
|
||||
if ("values".equals(name) && desc.startsWith("()")) return null;
|
||||
if ("valueOf".equals(name) && desc.startsWith("(Ljava/lang/String;)")) return null;
|
||||
}
|
||||
@@ -423,9 +424,9 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false);
|
||||
|
||||
final String canonicalMethodName = isConstructor ? myResult.getName() : name;
|
||||
final List<String> args = new ArrayList<String>();
|
||||
final List<String> throwables = exceptions != null ? new ArrayList<String>() : null;
|
||||
String canonicalMethodName = isConstructor ? myResult.getName() : name;
|
||||
List<String> args = new ArrayList<String>();
|
||||
List<String> throwables = exceptions != null ? new ArrayList<String>() : null;
|
||||
|
||||
final PsiMethodStubImpl stub = new PsiMethodStubImpl(myResult, StringRef.fromString(canonicalMethodName), flags, null);
|
||||
|
||||
@@ -446,6 +447,11 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
|
||||
stub.setReturnType(TypeInfo.fromString(returnType));
|
||||
|
||||
if (isEnum && isConstructor && signature == null && args.size() >= 2 && JAVA_LANG_STRING.equals(args.get(0)) && "int".equals(args.get(1))) {
|
||||
// exclude synthetic enum constructor parameters
|
||||
args = args.subList(2, args.size());
|
||||
}
|
||||
|
||||
final boolean isNonStaticInnerClassConstructor =
|
||||
isConstructor && !(myParent instanceof PsiFileStub) && (myModList.getModifiersMask() & Opcodes.ACC_STATIC) == 0;
|
||||
final boolean shouldSkipFirstParamForNonStaticInnerClassConstructor = !parsedViaGenericSignature && isNonStaticInnerClassConstructor;
|
||||
@@ -469,8 +475,8 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
String[] thrownTypes = buildThrowsList(exceptions, throwables, parsedViaGenericSignature);
|
||||
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;
|
||||
int localVarIgnoreCount = (access & Opcodes.ACC_STATIC) != 0 ? 0 : isConstructor && isEnum ? 3 : 1;
|
||||
int paramIgnoreCount = isConstructor && isEnum ? 2 : isNonStaticInnerClassConstructor ? 1 : 0;
|
||||
return new AnnotationParamCollectingVisitor(stub, modList, localVarIgnoreCount, paramIgnoreCount, paramCount, paramStubs);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package pkg;
|
||||
|
||||
public enum GrEnum implements groovy.lang.GroovyObject {
|
||||
E1, E2;
|
||||
|
||||
public final java.lang.String name;
|
||||
public static final pkg.GrEnum MIN_VALUE;
|
||||
public static final pkg.GrEnum MAX_VALUE;
|
||||
|
||||
public GrEnum(java.lang.String _name) { /* compiled code */ }
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
package pkg
|
||||
|
||||
enum GrEnum {
|
||||
E1("e1"), E2("e2")
|
||||
|
||||
public final String name
|
||||
|
||||
GrEnum(String _name) {
|
||||
name = _name
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
|
||||
public void testDefaultPackage() { doTest(); }
|
||||
public void testLocalClass() { doTest(); }
|
||||
public void testBounds() { doTest(); }
|
||||
public void testGrEnum() { doTest(); }
|
||||
|
||||
public void testTextPsiMismatch() {
|
||||
CommonCodeStyleSettings.IndentOptions options =
|
||||
|
||||
Reference in New Issue
Block a user