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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom VariableDeclarationFragment 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(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//w ww . j av a  2  s. c  om
    if (node.getAST().apiLevel() >= JLS3) {
        printModifiers(node.modifiers());
    }
    node.getType().accept(this);
    this.fBuffer.append(" ");//$NON-NLS-1$
    for (Iterator<VariableDeclarationFragment> it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = it.next();
        f.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(VariableDeclarationExpression node) {
    if (node.getAST().apiLevel() >= JLS3) {
        printModifiers(node.modifiers());
    }//from w  w w .  ja  v a 2 s  .co  m
    node.getType().accept(this);
    this.fBuffer.append(" ");//$NON-NLS-1$
    for (Iterator<VariableDeclarationFragment> it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = it.next();
        f.accept(this);
        if (it.hasNext()) {
            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(VariableDeclarationStatement node) {
    if (node.getAST().apiLevel() >= JLS3) {
        printModifiers(node.modifiers());
    }/*from www  .ja v a  2s.c  o m*/
    node.getType().accept(this);
    this.fBuffer.append(" ");//$NON-NLS-1$
    for (Iterator<VariableDeclarationFragment> it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.fBuffer.append(", ");//$NON-NLS-1$
        }
    }
    this.fBuffer.append(";");//$NON-NLS-1$
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }/*from   w ww  . j  a  v  a2 s .c  o  m*/
    printIndent();
    if (node.getAST().apiLevel() >= AST.JLS3) {
        printModifiers(node.modifiers());
    }
    node.getType().accept(this);
    this.buffer.append(" ");//$NON-NLS-1$
    for (Iterator it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.buffer.append(", ");//$NON-NLS-1$
        }
    }
    this.buffer.append(";\n");//$NON-NLS-1$
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(VariableDeclarationExpression node) {
    if (node.getAST().apiLevel() >= AST.JLS3) {
        printModifiers(node.modifiers());
    }/*from w  w  w. j  av  a2 s. c om*/
    node.getType().accept(this);
    this.buffer.append(" ");//$NON-NLS-1$
    for (Iterator it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.buffer.append(", ");//$NON-NLS-1$
        }
    }
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(VariableDeclarationStatement node) {
    printIndent();/*w w w. j  a v a 2  s  . c  om*/
    if (node.getAST().apiLevel() >= AST.JLS3) {
        printModifiers(node.modifiers());
    }
    node.getType().accept(this);
    this.buffer.append(" ");//$NON-NLS-1$
    for (Iterator it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.buffer.append(", ");//$NON-NLS-1$
        }
    }
    this.buffer.append(";\n");//$NON-NLS-1$
    return false;
}

From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java

License:Open Source License

@Override
public boolean visit(VariableDeclarationExpression node) {
    buffer.append(NameTable.javaRefToCpp(node.getType()));
    buffer.append(" ");
    for (Iterator<?> it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
        f.accept(this);
        if (it.hasNext()) {
            buffer.append(", ");
        }/* w w  w  .j a va2  s  .  c  om*/
    }
    return false;
}

From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java

License:Open Source License

@Override
public boolean visit(VariableDeclarationStatement node) {
    @SuppressWarnings("unchecked")
    List<VariableDeclarationFragment> vars = node.fragments(); // safe by definition
    assert !vars.isEmpty();
    ITypeBinding binding = Types.getTypeBinding(vars.get(0));
    String objcType = NameTable.javaRefToCpp(binding);
    boolean needsAsterisk = !binding.isPrimitive()
            && !(objcType.equals(NameTable.ID_TYPE) || objcType.matches("id<.*>"));
    if (needsAsterisk && objcType.endsWith(" *")) {
        // Strip pointer from type, as it will be added when appending fragment.
        // This is necessary to create "Foo *one, *two;" declarations.
        objcType = objcType.substring(0, objcType.length() - 2);
    }// w ww .  j a v  a 2  s .  c  o m
    buffer.append(objcType);
    buffer.append(" ");
    for (Iterator<VariableDeclarationFragment> it = vars.iterator(); it.hasNext();) {
        VariableDeclarationFragment f = it.next();
        if (needsAsterisk) {
            buffer.append('*');
        }
        f.accept(this);
        if (it.hasNext()) {
            buffer.append(", ");
        }
    }
    buffer.append(";\n");
    return false;
}

From source file:edu.uci.ics.sourcerer.extractor.ast.ReferenceExtractorVisitor.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*ww w.ja  v  a2  s  .c om*/
public boolean visit(FieldDeclaration node) {
    for (VariableDeclarationFragment fragment : (List<VariableDeclarationFragment>) node.fragments()) {
        fragment.accept(this);
    }
    return false;
}

From source file:org.codemucker.jmutate.ast.JAstFlattener.java

License:Open Source License

public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }/*from ww w . ja  v a  2  s . c om*/
    printIndent();
    if (node.getAST().apiLevel() == JLS2) {
        printModifiers(node.getModifiers());
    }
    if (node.getAST().apiLevel() >= JLS3) {
        printModifiers(node.modifiers());
    }
    node.getType().accept(this);
    this.buffer.append(" ");//$NON-NLS-1$
    for (Iterator it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.buffer.append(", ");//$NON-NLS-1$
        }
    }
    this.buffer.append(";\n");//$NON-NLS-1$
    return false;
}