use of com.intellij.psi.impl.cache.TypeInfo in project intellij-community by JetBrains.
the class StubBuildingVisitor method visitMethod.
@Override
@Nullable
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// See IDEA-78649
if (isSet(access, Opcodes.ACC_SYNTHETIC))
return null;
if (name == null)
return null;
if (SYNTHETIC_CLASS_INIT_METHOD.equals(name))
return null;
// skip semi-synthetic enum methods
boolean isEnum = myResult.isEnum();
if (isEnum) {
if ("values".equals(name) && desc.startsWith("()"))
return null;
//noinspection SpellCheckingInspection
if ("valueOf".equals(name) && desc.startsWith("(Ljava/lang/String;)"))
return null;
}
boolean isConstructor = SYNTHETIC_INIT_METHOD.equals(name);
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 generic = false;
if (signature != null) {
try {
info = parseMethodSignature(signature, exceptions);
generic = 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, TypeInfo.fromString(info.returnType, false), flags, null);
PsiModifierListStub modList = new PsiModifierListStubImpl(stub, packMethodFlags(access, myResult.isInterface()));
PsiTypeParameterListStub list = new PsiTypeParameterListStubImpl(stub);
for (Pair<String, String[]> parameter : info.typeParameters) {
PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(list, StringRef.fromString(parameter.first));
newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, parameter.second);
}
boolean isEnumConstructor = isEnum && isConstructor;
boolean isInnerClassConstructor = isConstructor && !(myParent instanceof PsiFileStub) && !isSet(myModList.getModifiersMask(), Opcodes.ACC_STATIC);
List<String> args = info.argTypes;
if (!generic && isEnumConstructor && args.size() >= 2 && CommonClassNames.JAVA_LANG_STRING.equals(args.get(0)) && "int".equals(args.get(1))) {
// omit synthetic enum constructor parameters
args = args.subList(2, args.size());
}
PsiParameterListStubImpl parameterList = new PsiParameterListStubImpl(stub);
int paramCount = args.size();
PsiParameterStubImpl[] paramStubs = new PsiParameterStubImpl[paramCount];
for (int i = 0; i < paramCount; i++) {
// omit synthetic inner class constructor parameter
if (i == 0 && !generic && isInnerClassConstructor)
continue;
String arg = args.get(i);
boolean isEllipsisParam = isVarargs && i == paramCount - 1;
TypeInfo typeInfo = TypeInfo.fromString(arg, isEllipsisParam);
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, ArrayUtil.toStringArray(info.throwTypes));
int localVarIgnoreCount = isStatic ? 0 : isEnumConstructor ? 3 : 1;
int paramIgnoreCount = isEnumConstructor ? 2 : isInnerClassConstructor ? 1 : 0;
return new MethodAnnotationCollectingVisitor(stub, modList, localVarIgnoreCount, paramIgnoreCount, paramCount, paramStubs, myMapping);
}
use of com.intellij.psi.impl.cache.TypeInfo in project intellij-community by JetBrains.
the class JavaFieldStubElementType method deserialize.
@NotNull
@Override
public PsiFieldStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
StringRef name = dataStream.readName();
TypeInfo type = TypeInfo.readTYPE(dataStream);
StringRef initializerText = dataStream.readName();
byte flags = dataStream.readByte();
return new PsiFieldStubImpl(parentStub, StringRef.toString(name), type, StringRef.toString(initializerText), flags);
}
use of com.intellij.psi.impl.cache.TypeInfo in project intellij-community by JetBrains.
the class JavaParameterElementType method createStub.
@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, JavaTokenType.IDENTIFIER);
String name = RecordUtil.intern(tree.getCharTable(), id);
return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis, false);
}
use of com.intellij.psi.impl.cache.TypeInfo in project intellij-community by JetBrains.
the class JavaParameterElementType method deserialize.
@NotNull
@Override
public PsiParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
StringRef name = dataStream.readName();
if (name == null)
throw new IOException("corrupted indices");
TypeInfo type = TypeInfo.readTYPE(dataStream);
byte flags = dataStream.readByte();
return new PsiParameterStubImpl(parentStub, name.toString(), type, flags);
}
use of com.intellij.psi.impl.cache.TypeInfo in project intellij-community by JetBrains.
the class StubBuildingVisitor method visitField.
@Override
@Nullable
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
if (isSet(access, Opcodes.ACC_SYNTHETIC))
return null;
if (name == null)
return null;
byte flags = PsiFieldStubImpl.packFlags(isSet(access, Opcodes.ACC_ENUM), isSet(access, Opcodes.ACC_DEPRECATED), false, false);
TypeInfo type = fieldType(desc, signature);
String initializer = constToString(value, type.text, false, myMapping);
PsiFieldStub stub = new PsiFieldStubImpl(myResult, name, type, initializer, flags);
PsiModifierListStub modList = new PsiModifierListStubImpl(stub, packFieldFlags(access));
return new FieldAnnotationCollectingVisitor(modList, myMapping);
}
Aggregations