Example usage for org.eclipse.jdt.core.dom SwitchStatement getAST

List of usage examples for org.eclipse.jdt.core.dom SwitchStatement getAST

Introduction

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

Prototype

public final AST getAST() 

Source Link

Document

Returns this node's AST.

Usage

From source file:net.sf.eclipsecs.ui.quickfixes.coding.MissingSwitchDefaultQuickfix.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w ww  .j av a2  s  . co  m*/
 */
protected ASTVisitor handleGetCorrectingASTVisitor(final IRegion lineInfo, final int markerStartOffset) {

    return new ASTVisitor() {

        public boolean visit(SwitchStatement node) {
            if (containsPosition(lineInfo, node.getStartPosition())) {
                SwitchCase defNode = node.getAST().newSwitchCase();
                defNode.setExpression(null);
                node.statements().add(defNode);
                node.statements().add(node.getAST().newBreakStatement());
            }
            return true; // also visit children
        }
    };
}