Search in sources :

Example 1 with SuperMethodReference

use of com.google.devtools.j2objc.ast.SuperMethodReference 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 SuperMethodReference

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

the class TreeConverter method convertSuperMethodReference.

private static TreeNode convertSuperMethodReference(org.eclipse.jdt.core.dom.SuperMethodReference node) {
    SuperMethodReference newNode = new SuperMethodReference();
    convertMethodReference(node, newNode, node.resolveMethodBinding(), false);
    return newNode.setQualifier((Name) TreeConverter.convert(node.getQualifier()));
}
Also used : SuperMethodReference(com.google.devtools.j2objc.ast.SuperMethodReference)

Aggregations

SuperMethodReference (com.google.devtools.j2objc.ast.SuperMethodReference)2 CreationReference (com.google.devtools.j2objc.ast.CreationReference)1 ExpressionMethodReference (com.google.devtools.j2objc.ast.ExpressionMethodReference)1 SourcePosition (com.google.devtools.j2objc.ast.SourcePosition)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