Example usage for org.eclipse.jdt.core.dom Expression accept

List of usage examples for org.eclipse.jdt.core.dom Expression accept

Introduction

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

Prototype

public final void accept(ASTVisitor visitor) 

Source Link

Document

Accepts the given visitor on a visit of the current node.

Usage

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

License:Open Source License

@Override
public boolean visit(ArrayCreation node) {
    this.fBuffer.append("new ");//$NON-NLS-1$
    ArrayType at = node.getType();
    int dims = at.getDimensions();
    Type elementType = at.getElementType();
    elementType.accept(this);
    for (Iterator<Expression> it = node.dimensions().iterator(); it.hasNext();) {
        this.fBuffer.append("[");//$NON-NLS-1$
        Expression e = it.next();
        e.accept(this);
        this.fBuffer.append("]");//$NON-NLS-1$
        dims--;/*from ww w.  j a v  a2s. c om*/
    }
    // add empty "[]" for each extra array dimension
    for (int i = 0; i < dims; i++) {
        this.fBuffer.append("[]");//$NON-NLS-1$
    }
    if (node.getInitializer() != null) {
        node.getInitializer().accept(this);
    }
    return false;
}

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

License:Open Source License

@Override
public boolean visit(ArrayInitializer node) {
    this.fBuffer.append("{");//$NON-NLS-1$
    for (Iterator<Expression> it = node.expressions().iterator(); it.hasNext();) {
        Expression e = it.next();
        e.accept(this);
        if (it.hasNext()) {
            this.fBuffer.append(",");//$NON-NLS-1$
        }//from www . j a va2 s .c  om
    }
    this.fBuffer.append("}");//$NON-NLS-1$
    return false;
}

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

License:Open Source License

@Override
public boolean visit(ClassInstanceCreation node) {
    if (node.getExpression() != null) {
        node.getExpression().accept(this);
        this.fBuffer.append(".");//$NON-NLS-1$
    }/*from w w  w . j  ava  2 s.  c o  m*/
    this.fBuffer.append("new ");//$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.getType().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$
    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}

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

License:Open Source License

@Override
public boolean visit(ConstructorInvocation node) {
    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$
                }//from   w  w  w. ja va2  s . co  m
            }
            this.fBuffer.append(">");//$NON-NLS-1$
        }
    }
    this.fBuffer.append("this(");//$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:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(EnumConstantDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }/*from  w w  w  .ja v a 2 s  .c  om*/
    printModifiers(node.modifiers());
    node.getName().accept(this);
    if (!node.arguments().isEmpty()) {
        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$
    }
    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}

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

License:Open Source License

@Override
public boolean visit(ForStatement node) {
    this.fBuffer.append("for (");//$NON-NLS-1$
    for (Iterator<Expression> it = node.initializers().iterator(); it.hasNext();) {
        Expression e = it.next();
        e.accept(this);
    }/*from  w ww .  ja  va2  s  .c o m*/
    this.fBuffer.append("; ");//$NON-NLS-1$
    if (node.getExpression() != null) {
        node.getExpression().accept(this);
    }
    this.fBuffer.append("; ");//$NON-NLS-1$
    for (Iterator<Expression> it = node.updaters().iterator(); it.hasNext();) {
        Expression e = it.next();
        e.accept(this);
    }
    this.fBuffer.append(") ");//$NON-NLS-1$
    node.getBody().accept(this);
    return false;
}

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

License:Open Source License

@Override
public boolean visit(InfixExpression node) {
    node.getLeftOperand().accept(this);
    this.fBuffer.append(' '); // for cases like x= i - -1; or x= i++ + ++i;
    this.fBuffer.append(node.getOperator().toString());
    this.fBuffer.append(' ');
    node.getRightOperand().accept(this);
    final List<Expression> extendedOperands = node.extendedOperands();
    if (extendedOperands.size() != 0) {
        this.fBuffer.append(' ');
        for (Iterator<Expression> it = extendedOperands.iterator(); it.hasNext();) {
            this.fBuffer.append(node.getOperator().toString()).append(' ');
            Expression e = it.next();
            e.accept(this);
        }//  ww w. j av  a2s. c  om
    }
    return false;
}

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

License:Open Source License

@Override
public boolean visit(MethodInvocation node) {
    if (node.getExpression() != null) {
        node.getExpression().accept(this);
        this.fBuffer.append(".");//$NON-NLS-1$
    }//from  w ww .  j  a v a  2 s  .  com
    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:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(SuperConstructorInvocation node) {
    if (node.getExpression() != null) {
        node.getExpression().accept(this);
        this.fBuffer.append(".");//$NON-NLS-1$
    }/*from   ww  w  . j  a va2  s.  c  o m*/
    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$
        }
    }
    this.fBuffer.append("super(");//$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: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$
    }//from   ww  w .java2  s.  co 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;
}