use of com.sun.tools.javac.tree.JCTree.JCMethodInvocation in project ceylon-compiler by ceylon.
the class AbstractTransformer method makeTypedDeclarationTypeDescriptorResolved.
private JCExpression makeTypedDeclarationTypeDescriptorResolved(TypedDeclaration declaration) {
// figure out the method name
String methodName = declaration.getPrefixedName();
List<JCExpression> arguments;
if (declaration instanceof Function)
arguments = makeReifiedTypeArgumentsResolved(getTypeArguments((Function) declaration), true);
else
arguments = List.nil();
if (declaration.isToplevel()) {
JCExpression getterClassNameExpr;
if (declaration instanceof Function) {
getterClassNameExpr = naming.makeName(declaration, Naming.NA_FQ | Naming.NA_WRAPPER);
} else {
String getterClassName = Naming.getAttrClassName(declaration, 0);
getterClassNameExpr = naming.makeUnquotedIdent(getterClassName);
}
arguments = arguments.prepend(makeSelect(getterClassNameExpr, "class"));
} else
arguments = arguments.prepend(make().Literal(methodName));
JCMethodInvocation typedDeclarationDescriptor = make().Apply(null, makeSelect(makeTypeDescriptorType(), "functionOrValue"), arguments);
// see if the declaration has a container too
Declaration enclosingDeclaration = getDeclarationContainer(declaration);
JCExpression containerType = null;
if (enclosingDeclaration instanceof TypedDeclaration)
containerType = makeTypedDeclarationTypeDescriptorResolved((TypedDeclaration) enclosingDeclaration);
else if (enclosingDeclaration instanceof TypeDeclaration) {
Type qualifyingType = ((TypeDeclaration) enclosingDeclaration).getType();
containerType = makeReifiedTypeArgumentResolved(qualifyingType, true);
}
if (containerType == null) {
return typedDeclarationDescriptor;
} else {
return make().Apply(null, makeSelect(makeTypeDescriptorType(), "member"), List.of(containerType, typedDeclarationDescriptor));
}
}
Aggregations