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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom ImportDeclaration 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(CompilationUnit node) {
    if (node.getPackage() != null) {
        node.getPackage().accept(this);
    }//from   w w w  . j  a  v a2 s  . c  o  m
    for (Iterator<ImportDeclaration> it = node.imports().iterator(); it.hasNext();) {
        ImportDeclaration d = it.next();
        d.accept(this);
    }
    for (Iterator<AbstractTypeDeclaration> it = node.types().iterator(); it.hasNext();) {
        AbstractTypeDeclaration d = it.next();
        d.accept(this);
    }
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(CompilationUnit node) {
    if (node.getPackage() != null) {
        node.getPackage().accept(this);
    }//from  w w w.  j  ava2 s .co  m
    for (Iterator it = node.imports().iterator(); it.hasNext();) {
        ImportDeclaration d = (ImportDeclaration) it.next();
        d.accept(this);
    }
    for (Iterator it = node.types().iterator(); it.hasNext();) {
        AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
        d.accept(this);
    }
    return false;
}

From source file:de.ovgu.cide.export.physical.ahead.ast.JakCompilationUnit.java

License:Open Source License

private void acceptInner(JakClassRefinement innerClass, ASTVisitor visitor) {
    assert visitor instanceof IJakASTVisitor;
    if (visitor instanceof IJakASTVisitor) {
        boolean visitChildren = ((IJakASTVisitor) visitor).visit(this);
        if (visitChildren) {
            // visit children in normal left to right reading order
            if (package_ != null)
                getPackage().accept(visitor);
            for (ImportDeclaration import_ : (List<ImportDeclaration>) this.imports())
                import_.accept(visitor);
            if (innerClass != null)
                innerClass.accept(visitor);
        }//from  ww w. j av a 2 s . c o  m
        ((IJakASTVisitor) visitor).endVisit(this);
    }
}

From source file:org.mybatis.generator.eclipse.tests.harness.summary.support.CompilationUnitSummerizer.java

License:Apache License

private void visitImports(List<ImportDeclaration> imports) {
    for (ImportDeclaration importDeclaration : imports) {
        importDeclaration.accept(visitor);
    }/*w  w  w .ja  va 2 s .  c om*/
}

From source file:org.mybatis.generator.eclipse.tests.harness.summary.support.ImportGatheringVisitor.java

License:Apache License

@Override
public boolean visit(ImportDeclaration node) {
    ImportDeclarationStringifier visitor = new ImportDeclarationStringifier();
    node.accept(visitor);
    imports.add(visitor.toString());/*from  w  w  w .jav a  2s . com*/
    return false;
}

From source file:ptolemy.backtrack.eclipse.ast.ASTFormatter.java

License:Open Source License

/** Visit an ast node, and return whether its children should be further
 *  visited./*from   www.j a v  a  2  s  .  co m*/
 *
 *  @param node The AST node.
 *  @return Whether its children should be further visited.
 */
public boolean visit(CompilationUnit node) {
    // Set up the comment iterator.
    List comments = node.getCommentList();

    if (!comments.isEmpty()) {
        _commentIterator = comments.iterator();

        try {
            _nextComment();
        } catch (IOException e) {
            throw new ASTIORuntimeException(e);
        }
    }

    // Sort all the importations.
    List imports = node.imports();
    int length = imports.size();
    AST ast = node.getAST();

    for (int i = 0; i < (length - 1); i++) {
        for (int j = i + 1; j < length; j++) {
            ImportDeclaration import1 = (ImportDeclaration) imports.get(i);
            ImportDeclaration import2 = (ImportDeclaration) imports.get(j);

            if (import1.toString().compareTo(import2.toString()) > 0) {
                // Swap.
                imports.remove(j);
                imports.remove(i);
                imports.add(i, ASTNode.copySubtree(ast, import2));
                imports.add(j, ASTNode.copySubtree(ast, import1));
            }
        }
    }

    if (node.getPackage() != null) {
        node.getPackage().accept(this);
    }

    for (Iterator it = node.imports().iterator(); it.hasNext();) {
        ImportDeclaration d = (ImportDeclaration) it.next();
        d.accept(this);
    }

    _output("\n");

    for (Iterator it = node.types().iterator(); it.hasNext();) {
        AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
        d.accept(this);
    }

    return false;
}