use of com.sun.tools.javac.code.TypeAnnotationPosition in project checker-framework by typetools.
the class TypesIntoElements method storeMethod.
private static void storeMethod(ProcessingEnvironment processingEnv, Types types, AnnotatedTypeFactory atypeFactory, MethodTree meth) {
AnnotatedExecutableType mtype = atypeFactory.getAnnotatedType(meth);
MethodSymbol sym = (MethodSymbol) TreeUtils.elementFromDeclaration(meth);
TypeAnnotationPosition tapos;
List<Attribute.TypeCompound> tcs = List.nil();
storeTypeParameters(processingEnv, types, atypeFactory, meth.getTypeParameters(), sym);
{
// return type
JCTree ret = ((JCTree.JCMethodDecl) meth).getReturnType();
if (ret != null) {
tapos = TypeAnnotationUtils.methodReturnTAPosition(ret.pos);
tcs = tcs.appendList(generateTypeCompounds(processingEnv, mtype.getReturnType(), tapos));
}
}
{
// receiver
JCTree recv = ((JCTree.JCMethodDecl) meth).getReceiverParameter();
if (recv != null) {
tapos = TypeAnnotationUtils.methodReceiverTAPosition(recv.pos);
tcs = tcs.appendList(generateTypeCompounds(processingEnv, mtype.getReceiverType(), tapos));
}
}
{
// parameters
int pidx = 0;
java.util.List<AnnotatedTypeMirror> ptypes = mtype.getParameterTypes();
for (JCTree param : ((JCTree.JCMethodDecl) meth).getParameters()) {
tapos = TypeAnnotationUtils.methodParameterTAPosition(pidx, param.pos);
tcs = tcs.appendList(generateTypeCompounds(processingEnv, ptypes.get(pidx), tapos));
++pidx;
}
}
{
// throws clauses
int tidx = 0;
java.util.List<AnnotatedTypeMirror> ttypes = mtype.getThrownTypes();
for (JCTree thr : ((JCTree.JCMethodDecl) meth).getThrows()) {
tapos = TypeAnnotationUtils.methodThrowsTAPosition(tidx, thr.pos);
tcs = tcs.appendList(generateTypeCompounds(processingEnv, ttypes.get(tidx), tapos));
++tidx;
}
}
addUniqueTypeCompounds(types, sym, tcs);
}
use of com.sun.tools.javac.code.TypeAnnotationPosition in project checker-framework by typetools.
the class TypesIntoElements method storeClassExtends.
// TODO: see usage in comments above
@SuppressWarnings("unused")
private static void storeClassExtends(ProcessingEnvironment processingEnv, Types types, AnnotatedTypeFactory atypeFactory, Tree ext, Symbol.ClassSymbol csym, int implidx) {
AnnotatedTypeMirror type;
int pos;
if (ext == null) {
// The implicit superclass is always java.lang.Object.
// TODO: is this a good way to get the type?
type = atypeFactory.fromElement(csym.getSuperclass().asElement());
pos = -1;
} else {
type = atypeFactory.getAnnotatedTypeFromTypeTree(ext);
pos = ((JCTree) ext).pos;
}
TypeAnnotationPosition tapos = TypeAnnotationUtils.classExtendsTAPosition(implidx, pos);
List<Attribute.TypeCompound> tcs;
tcs = generateTypeCompounds(processingEnv, type, tapos);
addUniqueTypeCompounds(types, csym, tcs);
}
use of com.sun.tools.javac.code.TypeAnnotationPosition in project checker-framework by typetools.
the class TypeAnnotationUtils method methodTypeParameterTAPosition.
public static TypeAnnotationPosition methodTypeParameterTAPosition(final int tpidx, final int pos) {
TypeAnnotationPosition tapos = new TypeAnnotationPosition();
tapos.type = TargetType.METHOD_TYPE_PARAMETER;
tapos.parameter_index = tpidx;
tapos.pos = pos;
return tapos;
}
use of com.sun.tools.javac.code.TypeAnnotationPosition in project checker-framework by typetools.
the class TypeAnnotationUtils method methodThrowsTAPosition.
public static TypeAnnotationPosition methodThrowsTAPosition(final int tidx, final int pos) {
TypeAnnotationPosition tapos = new TypeAnnotationPosition();
tapos.type = TargetType.THROWS;
tapos.type_index = tidx;
tapos.pos = pos;
return tapos;
}
use of com.sun.tools.javac.code.TypeAnnotationPosition in project checker-framework by typetools.
the class TypeAnnotationUtils method methodReceiverTAPosition.
public static TypeAnnotationPosition methodReceiverTAPosition(final int pos) {
TypeAnnotationPosition tapos = new TypeAnnotationPosition();
tapos.type = TargetType.METHOD_RECEIVER;
tapos.pos = pos;
return tapos;
}
Aggregations