MethodVisitor (int access, String name, String desc, String signature, String[] exceptions) { if (isSet(access, Opcodes.ACC_SYNTHETIC) || name == null || SYNTHETIC_CLASS_INIT_METHOD.equals(name)) return null; boolean isConstructor = SYNTHETIC_INIT_METHOD.equals(name); if (isConstructor && myAnonymousInner) return null; 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; } if (myFirstPassData.isSyntheticRecordMethod(name, desc)) return null; boolean isDeprecated = isSet(access, Opcodes.ACC_DEPRECATED); boolean isVarargs = isSet(access, Opcodes.ACC_VARARGS); boolean isStatic = isSet(access, Opcodes.ACC_STATIC); boolean isAnnotationMethod = myResult.isAnnotationType(); byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false, false); String canonicalMethodName = isConstructor ? myResult.getName() : name; MethodInfo info = null; boolean hasSignature = false; if (signature != null) { try { info = parseMethodSignature(signature, exceptions); hasSignature = true; } catch (ClsFormatException e) { if (LOG.isDebugEnabled()) LOG.debug("source=" + mySource + " signature=" + signature, e); } } if (info == null) { info = parseMethodDescription(desc, exceptions); } PsiMethodStubImpl stub = new PsiMethodStubImpl(myResult, canonicalMethodName, info.returnType, flags, null); PsiModifierListStub modList = new PsiModifierListStubImpl(stub, packMethodFlags(access, myResult.isInterface())); new PsiTypeParameterListStubImpl(stub); boolean isEnumConstructor = isConstructor && isEnum; boolean isInnerClassConstructor = isConstructor && !isEnum && isInner() && !isGroovyClosure(canonicalMethodName); List<TypeInfo> args = info.argTypes; if (!hasSignature) { if (isEnumConstructor && args.size() >= 2 && args.get(0).getKind() == TypeInfo.TypeKind.JAVA_LANG_STRING && args.get(1).getKind() == TypeInfo.TypeKind.INT) { args = args.subList(2, args.size()); // omit synthetic enum constructor parameters } else if (isInnerClassConstructor && !args.isEmpty()) { args = args.subList(1, args.size()); // omit synthetic inner class constructor parameter } } PsiParameterListStubImpl parameterList = new PsiParameterListStubImpl(stub); int paramCount = args.size(); PsiParameterStubImpl[] paramStubs = new PsiParameterStubImpl[paramCount]; for (int i = 0; i < paramCount; i++) { TypeInfo typeInfo = args.get(i); boolean isEllipsisParam = isVarargs && i == paramCount - 1; if (isEllipsisParam) { typeInfo = typeInfo.withEllipsis(); } String paramName = i < parameterNames.length ? parameterNames[i] : "p" + (i + 1); PsiParameterStubImpl parameterStub = new PsiParameterStubImpl(parameterList, paramName, typeInfo, isEllipsisParam, true); paramStubs[i] = parameterStub; new PsiModifierListStubImpl(parameterStub, 0); } newReferenceList(JavaStubElementTypes.THROWS_LIST, stub, info.throwTypes); int paramIgnoreCount = isEnumConstructor ? 2 : isInnerClassConstructor ? 1 : 0; int localVarIgnoreCount = isEnumConstructor ? 3 : isInnerClassConstructor ? 2 : !isStatic ? 1 : 0; return new MethodAnnotationCollectingVisitor(stub, info, modList, paramStubs, paramIgnoreCount, localVarIgnoreCount, myFirstPassData); }