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

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

Introduction

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

Prototype

public final int getLength() 

Source Link

Document

Returns the length in characters of the original source file indicating where the source fragment corresponding to this node ends.

Usage

From source file:br.uff.ic.gems.resources.ast.Visitor.java

@Override
public boolean visit(SwitchStatement node) {
    int beginLine = cu.getLineNumber(node.getStartPosition());
    int endLine = cu.getLineNumber(node.getStartPosition() + node.getLength());
    int beginColumn = cu.getColumnNumber(node.getStartPosition());
    int endColumn = cu.getColumnNumber(node.getStartPosition() + node.getLength());

    languageConstructs.add(/* ww w .j  a  v  a  2  s. c o  m*/
            new LanguageConstruct(node.getClass().getSimpleName(), beginLine, endLine, beginColumn, endColumn));

    return true;
}

From source file:com.chookapp.org.bracketeer.jdt.ClosingBracketHintVisitor.java

License:Open Source License

@Override
public boolean visit(SwitchStatement node) {
    String hint = GetNodeText(node.getExpression());
    int startLoc = node.getStartPosition();
    int endLoc = startLoc + node.getLength() - 1;
    hint = "switch( " + hint + " )"; //$NON-NLS-1$ //$NON-NLS-2$ 
    _scopeStack.push(new ScopeInfo(hint, startLoc, node));
    try {/*from   w  w  w. j a  va 2s .c om*/
        _container.add(new Hint("switch", startLoc, endLoc, hint)); //$NON-NLS-1$
    } catch (BadLocationException e) {
        _cancelProcessing.set(true);
    }
    return shouldContinue();
}

From source file:padl.creator.javafile.eclipse.astVisitors.ConditionalModelAnnotator.java

License:Open Source License

@Override
public boolean visit(final SwitchStatement node) {
    if (this.myCurrentOperation != null) {
        this.myCurrentOperation.addConstituent(((StatementFactory) StatementFactory.getInstance())
                .createSwitchInstruction(node.toString().toCharArray(), node.getLength()));
    }//from   www. j a  v  a  2 s  .com
    return super.visit(node);
}

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 w  w  w  .  j  a  v  a2 s . c o  m*/
 *
 *  @param node The AST node.
 *  @return Whether its children should be further visited.
 */
public boolean visit(SwitchStatement node) {
    _output(_indent);
    _output("switch (");
    node.getExpression().accept(this);
    _output(") ");
    _openBrace();

    for (Iterator it = node.statements().iterator(); it.hasNext();) {
        Statement s = (Statement) it.next();

        if (!(s instanceof SwitchCase)) {
            _increaseIndent();
        }

        s.accept(this);

        if (!(s instanceof SwitchCase)) {
            _decreaseIndent();
        }
    }

    _checkComments((node.getStartPosition() + node.getLength()) - 1);
    _closeBrace();
    return false;
}