Search in sources :

Example 1 with CreationReference

use of com.google.devtools.j2objc.ast.CreationReference in project j2objc by google.

the class TreeConverter method convertMemberReference.

private TreeNode convertMemberReference(JCTree.JCMemberReference node) {
    Element element = node.sym;
    SourcePosition pos = getPosition(node);
    if (ElementUtil.isConstructor(element)) {
        CreationReference newNode = new CreationReference();
        convertMethodReference(node, newNode);
        return newNode.setType(Type.newType(nameType(node.expr)));
    }
    if (node.hasKind(JCTree.JCMemberReference.ReferenceKind.SUPER)) {
        SuperMethodReference newNode = new SuperMethodReference();
        convertMethodReference(node, newNode);
        if (node.getQualifierExpression().getKind() == Kind.IDENTIFIER) {
            // super::foo
            return newNode;
        } else {
            // Qualifier expression is <name>."super", so it's always a JCFieldAccess.
            JCTree.JCFieldAccess expr = (JCTree.JCFieldAccess) node.getQualifierExpression();
            return newNode.setQualifier(convertSimpleName(nameSymbol(expr.selected), expr.type, getPosition(expr.selected)));
        }
    }
    if (node.hasKind(JCTree.JCMemberReference.ReferenceKind.UNBOUND) || node.hasKind(JCTree.JCMemberReference.ReferenceKind.STATIC)) {
        TypeMethodReference newNode = new TypeMethodReference();
        convertMethodReference(node, newNode);
        return newNode.setName(convertSimpleName(node.sym, node.type, pos)).setType(convertType(node.type, pos, false));
    }
    ExpressionMethodReference newNode = new ExpressionMethodReference();
    convertMethodReference(node, newNode);
    return newNode.setName(convertSimpleName(node.sym, node.type, pos)).setExpression((Expression) convert(node.getQualifierExpression()));
}
Also used : ExpressionMethodReference(com.google.devtools.j2objc.ast.ExpressionMethodReference) Element(javax.lang.model.element.Element) PackageElement(javax.lang.model.element.PackageElement) VariableElement(javax.lang.model.element.VariableElement) ExecutableElement(javax.lang.model.element.ExecutableElement) SourcePosition(com.google.devtools.j2objc.ast.SourcePosition) CreationReference(com.google.devtools.j2objc.ast.CreationReference) JCTree(com.sun.tools.javac.tree.JCTree) TypeMethodReference(com.google.devtools.j2objc.ast.TypeMethodReference) SuperMethodReference(com.google.devtools.j2objc.ast.SuperMethodReference)

Example 2 with CreationReference

use of com.google.devtools.j2objc.ast.CreationReference in project j2objc by google.

the class TreeConverter method convertCreationReference.

private static TreeNode convertCreationReference(org.eclipse.jdt.core.dom.CreationReference node) {
    CreationReference newNode = new CreationReference();
    convertMethodReference(node, newNode, node.resolveMethodBinding(), false);
    return newNode.setType((Type) TreeConverter.convert(node.getType()));
}
Also used : CreationReference(com.google.devtools.j2objc.ast.CreationReference)

Aggregations

CreationReference (com.google.devtools.j2objc.ast.CreationReference)2 ExpressionMethodReference (com.google.devtools.j2objc.ast.ExpressionMethodReference)1 SourcePosition (com.google.devtools.j2objc.ast.SourcePosition)1 SuperMethodReference (com.google.devtools.j2objc.ast.SuperMethodReference)1 TypeMethodReference (com.google.devtools.j2objc.ast.TypeMethodReference)1 JCTree (com.sun.tools.javac.tree.JCTree)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 PackageElement (javax.lang.model.element.PackageElement)1 VariableElement (javax.lang.model.element.VariableElement)1