Search in sources :

Example 6 with ClassInstanceCreation

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

the class TreeConverter method convertClassInstanceCreation.

private static TreeNode convertClassInstanceCreation(org.eclipse.jdt.core.dom.ClassInstanceCreation node) {
    ClassInstanceCreation newNode = new ClassInstanceCreation();
    convertExpression(node, newNode);
    for (Object argument : node.arguments()) {
        newNode.addArgument((Expression) TreeConverter.convert(argument));
    }
    IMethodBinding binding = node.resolveConstructorBinding();
    JdtExecutableElement element = (JdtExecutableElement) BindingConverter.getExecutableElement(binding);
    JdtExecutableType type = BindingConverter.getType(binding);
    newNode.setExecutablePair(new ExecutablePair(element, type)).setVarargsType(getVarargsType(binding, node.arguments())).setType((Type) TreeConverter.convert(node.getType()));
    Expression expression = (Expression) TreeConverter.convert(node.getExpression());
    org.eclipse.jdt.core.dom.AnonymousClassDeclaration anonymousClassDecl = node.getAnonymousClassDeclaration();
    if (anonymousClassDecl != null && expression != null) {
        VariableElement superOuterParam = GeneratedVariableElement.newParameter("superOuter$", expression.getTypeMirror(), element);
        element.setSuperOuterParam(superOuterParam);
        type.setSuperOuterParamType(superOuterParam.asType());
        newNode.addArgument(0, expression);
    } else {
        newNode.setExpression(expression);
    }
    if (anonymousClassDecl != null) {
        newNode.setAnonymousClassDeclaration(convertAnonymousClassDeclaration(anonymousClassDecl, element, binding));
    }
    return newNode;
}
Also used : ClassInstanceCreation(com.google.devtools.j2objc.ast.ClassInstanceCreation) IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) ExecutablePair(com.google.devtools.j2objc.types.ExecutablePair) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) InstanceofExpression(com.google.devtools.j2objc.ast.InstanceofExpression) Expression(com.google.devtools.j2objc.ast.Expression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) LambdaExpression(com.google.devtools.j2objc.ast.LambdaExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) FunctionalExpression(com.google.devtools.j2objc.ast.FunctionalExpression) CastExpression(com.google.devtools.j2objc.ast.CastExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) VariableElement(javax.lang.model.element.VariableElement) GeneratedVariableElement(com.google.devtools.j2objc.types.GeneratedVariableElement)

Aggregations

ClassInstanceCreation (com.google.devtools.j2objc.ast.ClassInstanceCreation)6 VariableElement (javax.lang.model.element.VariableElement)5 Expression (com.google.devtools.j2objc.ast.Expression)4 InfixExpression (com.google.devtools.j2objc.ast.InfixExpression)4 PostfixExpression (com.google.devtools.j2objc.ast.PostfixExpression)4 SimpleName (com.google.devtools.j2objc.ast.SimpleName)4 EnumConstantDeclaration (com.google.devtools.j2objc.ast.EnumConstantDeclaration)2 TypeDeclaration (com.google.devtools.j2objc.ast.TypeDeclaration)2 VariableDeclarationStatement (com.google.devtools.j2objc.ast.VariableDeclarationStatement)2 GeneratedVariableElement (com.google.devtools.j2objc.types.GeneratedVariableElement)2 Assignment (com.google.devtools.j2objc.ast.Assignment)1 CastExpression (com.google.devtools.j2objc.ast.CastExpression)1 ConditionalExpression (com.google.devtools.j2objc.ast.ConditionalExpression)1 ExpressionStatement (com.google.devtools.j2objc.ast.ExpressionStatement)1 FieldDeclaration (com.google.devtools.j2objc.ast.FieldDeclaration)1 ForStatement (com.google.devtools.j2objc.ast.ForStatement)1 FunctionalExpression (com.google.devtools.j2objc.ast.FunctionalExpression)1 InstanceofExpression (com.google.devtools.j2objc.ast.InstanceofExpression)1 LambdaExpression (com.google.devtools.j2objc.ast.LambdaExpression)1 NativeStatement (com.google.devtools.j2objc.ast.NativeStatement)1