Example usage for org.eclipse.jdt.core.dom SuperMethodInvocation getName

List of usage examples for org.eclipse.jdt.core.dom SuperMethodInvocation getName

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom SuperMethodInvocation getName.

Prototype

public SimpleName getName() 

Source Link

Document

Returns the name of the method invoked in this expression.

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(SuperMethodInvocation node) {
    if (node.getQualifier() != null) {
        node.getQualifier().accept(this);
        this.fBuffer.append(".");//$NON-NLS-1$
    }/*  w  w w .jav a  2 s  . c o  m*/
    this.fBuffer.append("super.");//$NON-NLS-1$
    if (node.getAST().apiLevel() >= JLS3) {
        if (!node.typeArguments().isEmpty()) {
            this.fBuffer.append("<");//$NON-NLS-1$
            for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) {
                Type t = it.next();
                t.accept(this);
                if (it.hasNext()) {
                    this.fBuffer.append(",");//$NON-NLS-1$
                }
            }
            this.fBuffer.append(">");//$NON-NLS-1$
        }
    }
    node.getName().accept(this);
    this.fBuffer.append("(");//$NON-NLS-1$
    for (Iterator<Expression> it = node.arguments().iterator(); it.hasNext();) {
        Expression e = it.next();
        e.accept(this);
        if (it.hasNext()) {
            this.fBuffer.append(",");//$NON-NLS-1$
        }
    }
    this.fBuffer.append(")");//$NON-NLS-1$
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(SuperMethodInvocation node) {
    boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder();
    //      b.setPosition(pos.build());
    b.setKind(boa.types.Ast.Expression.ExpressionKind.METHODCALL);
    String name = "super." + node.getName().getFullyQualifiedName();
    if (node.getQualifier() != null)
        name = node.getQualifier().getFullyQualifiedName() + "." + name;
    b.setMethod(name);//from w  ww. j ava2  s .c  om
    for (Object a : node.arguments()) {
        ((org.eclipse.jdt.core.dom.Expression) a).accept(this);
        b.addMethodArgs(expressions.pop());
    }
    for (Object t : node.typeArguments()) {
        boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder();
        tb.setName(getIndex(typeName((org.eclipse.jdt.core.dom.Type) t)));
        tb.setKind(boa.types.Ast.TypeKind.GENERIC);
        b.addGenericParameters(tb.build());
    }
    expressions.push(b.build());
    return false;
}

From source file:changetypes.ASTVisitorAtomicChange.java

License:Open Source License

public boolean visit(SuperMethodInvocation node) {
    IMethodBinding mmtb = node.resolveMethodBinding();
    if (this.mtbStack.isEmpty()) {
        return true;
    }//from   w  w w .jav  a2 s.co  m
    try {
        this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding) this.mtbStack.peek()),
                getQualifiedName(mmtb)));
    } catch (Exception localException) {
        System.err.println("Cannot resolve method invocation \"" + node.getName().toString() + "\"");
    }
    return true;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(SuperMethodInvocation node) {
    if (node.getQualifier() != null) {
        node.getQualifier().accept(this);
        this.buffer.append(".");//$NON-NLS-1$
    }//from w  ww.  j av a  2  s.  c o m
    this.buffer.append("super.");//$NON-NLS-1$
    if (node.getAST().apiLevel() >= AST.JLS3) {
        if (!node.typeArguments().isEmpty()) {
            this.buffer.append("<");//$NON-NLS-1$
            for (Iterator it = node.typeArguments().iterator(); it.hasNext();) {
                Type t = (Type) it.next();
                t.accept(this);
                if (it.hasNext()) {
                    this.buffer.append(",");//$NON-NLS-1$
                }
            }
            this.buffer.append(">");//$NON-NLS-1$
        }
    }
    node.getName().accept(this);
    this.buffer.append("(");//$NON-NLS-1$
    for (Iterator it = node.arguments().iterator(); it.hasNext();) {
        Expression e = (Expression) it.next();
        e.accept(this);
        if (it.hasNext()) {
            this.buffer.append(",");//$NON-NLS-1$
        }
    }
    this.buffer.append(")");//$NON-NLS-1$
    return false;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java

License:Open Source License

@Override
public boolean visit(SuperMethodInvocation node) {
    handleTypeArguments(node.typeArguments());
    handleInvocation(node, node.getName());
    handleCommas(node.arguments(), this.options.insert_space_before_comma_in_method_invocation_arguments,
            this.options.insert_space_after_comma_in_method_invocation_arguments);
    return true;//from  w  w w  .ja  v a 2s.c  om
}

From source file:com.google.dart.java2dart.SyntaxTranslator.java

License:Open Source License

@Override
public boolean visit(org.eclipse.jdt.core.dom.SuperMethodInvocation node) {
    IMethodBinding binding = node.resolveMethodBinding();
    Expression target = new SuperExpression(null);
    List<Expression> arguments = translateArguments(binding, node.arguments());
    SimpleIdentifier name = translateSimpleName(node.getName());
    return done(methodInvocation(target, name, arguments));
}

From source file:com.google.devtools.j2cpp.translate.DestructorGenerator.java

License:Open Source License

@Override
public boolean visit(SuperMethodInvocation node) {
    if (needsRenaming(node.getName())) {
        NameTable.rename(Types.getBinding(node), destructorName);
    }//from  w ww .  j av a2  s .  c o m
    return true;
}

From source file:com.google.devtools.j2cpp.translate.DestructorGenerator.java

License:Open Source License

@SuppressWarnings("unchecked")
private void addReleaseStatements(MethodDeclaration method, List<IVariableBinding> fields) {
    // Find existing super.finalize(), if any.
    final boolean[] hasSuperFinalize = new boolean[1];
    method.accept(new ASTVisitor() {
        @Override/*from   w ww.  ja v a  2s .c  o  m*/
        public void endVisit(SuperMethodInvocation node) {
            if (FINALIZE_METHOD.equals(node.getName().getIdentifier())) {
                hasSuperFinalize[0] = true;
            }
        }
    });

    List<Statement> statements = method.getBody().statements(); // safe by definition
    if (!statements.isEmpty() && statements.get(0) instanceof TryStatement) {
        TryStatement tryStatement = ((TryStatement) statements.get(0));
        if (tryStatement.getBody() != null) {
            statements = tryStatement.getBody().statements(); // safe by definition
        }
    }
    AST ast = method.getAST();
    int index = statements.size();
    for (IVariableBinding field : fields) {
        if (!field.getType().isPrimitive() && !Types.isWeakReference(field)) {
            Assignment assign = ast.newAssignment();
            SimpleName receiver = ast.newSimpleName(field.getName());
            Types.addBinding(receiver, field);
            assign.setLeftHandSide(receiver);
            assign.setRightHandSide(Types.newNullLiteral());
            Types.addBinding(assign, field.getDeclaringClass());
            ExpressionStatement stmt = ast.newExpressionStatement(assign);
            statements.add(index, stmt);
        }
    }
    if (Options.useReferenceCounting() && !hasSuperFinalize[0]) {
        SuperMethodInvocation call = ast.newSuperMethodInvocation();
        IMethodBinding methodBinding = Types.getMethodBinding(method);
        GeneratedMethodBinding binding = new GeneratedMethodBinding(destructorName, Modifier.PUBLIC,
                Types.mapTypeName("void"), methodBinding.getDeclaringClass(), false, false, true);
        Types.addBinding(call, binding);
        call.setName(ast.newSimpleName(destructorName));
        Types.addBinding(call.getName(), binding);
        ExpressionStatement stmt = ast.newExpressionStatement(call);
        statements.add(stmt);
    }
}

From source file:com.google.devtools.j2cpp.translate.JavaToIOSMethodTranslator.java

License:Open Source License

@Override
public boolean visit(SuperMethodInvocation node) {
    // translate any embedded method invocations
    @SuppressWarnings("unchecked")
    List<Expression> args = node.arguments(); // safe by definition
    for (Expression e : args) {
        e.accept(this);
    }//ww w . j  av a  2 s.c om

    IMethodBinding binding = Types.getMethodBinding(node);
    JavaMethod md = descriptions.get(binding);
    if (md != null) {
        String key = md.getKey();
        String value = methodMappings.get(key);
        if (value == null) {
            // Method has same name as a mapped method's, but it's ignored since
            // it doesn't override it.
            return super.visit(node);
        }
        IOSMethod iosMethod = new IOSMethod(value, binding, ast);
        node.setName(NameTable.unsafeSimpleName(iosMethod.getName(), ast));
        SimpleName name = node.getName();
        if (name.getIdentifier().equals(binding.getDeclaringClass().getName())
                || name.getIdentifier().equals(binding.getDeclaringClass().getQualifiedName())) {
            node.setName(NameTable.unsafeSimpleName(iosMethod.getDeclaringClass(), ast));
        }
        Types.addMappedIOSMethod(binding, iosMethod);
        IMethodBinding newBinding = iosMethod.resolveBinding();
        Types.addMappedInvocation(node, newBinding);
        Types.addBinding(node, newBinding);
        Types.addBinding(name, newBinding);
    } else {
        // Not mapped, check if it overrides a mapped method.
        for (IMethodBinding methodBinding : mappedMethods) {
            if (binding.overrides(methodBinding)) {
                JavaMethod desc = getDescription(methodBinding);
                String value = methodMappings.get(desc.getKey());
                if (value != null) {
                    IOSMethod iosMethod = new IOSMethod(value, binding, ast);
                    node.setName(NameTable.unsafeSimpleName(iosMethod.getName(), ast));
                    Types.addMappedIOSMethod(binding, iosMethod);
                    IMethodBinding newBinding = iosMethod.resolveBinding();
                    Types.addBinding(node, newBinding);
                    Types.addBinding(node.getName(), newBinding);
                }
            }
        }
    }
    return false;
}

From source file:com.google.devtools.j2cpp.translate.Rewriter.java

License:Open Source License

@Override
public boolean visit(SuperMethodInvocation node) {
    renameReservedNames(node.getName().getIdentifier(), Types.getMethodBinding(node));
    return true;/*from  w ww .  j a  v a 2s  .  c  o  m*/
}