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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom WhileStatement 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(WhileStatement 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());

    Statement body = node.getBody();
    if (body != null) {

        int beginLineBody = cu.getLineNumber(body.getStartPosition());
        int endLineBody = cu.getLineNumber(body.getStartPosition() + body.getLength());
        int beginColumnBody = cu.getColumnNumber(body.getStartPosition());
        int endColumnBody = cu.getColumnNumber(body.getStartPosition() + body.getLength());

        languageConstructs.add(new LanguageConstruct(node.getClass().getSimpleName(), beginLine, endLine,
                beginColumn, endColumn, beginLineBody, endLineBody, beginColumnBody, endColumnBody, null));
    } else {/*w  w w  .  ja  v a2s. com*/
        languageConstructs.add(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(WhileStatement node) {
    String hint = GetNodeText(node.getExpression());
    int startLoc = node.getStartPosition();
    int endLoc = startLoc + node.getLength() - 1;
    hint = "while( " + hint + " )"; //$NON-NLS-1$ //$NON-NLS-2$ 
    _scopeStack.push(new ScopeInfo(hint, startLoc, node));
    try {//  w  ww.jav a2 s  .  c o m
        _container.add(new Hint("while", startLoc, endLoc, hint)); //$NON-NLS-1$ 
    } catch (BadLocationException e) {
        _cancelProcessing.set(true);
    }
    return shouldContinue();
}

From source file:org.evolizer.changedistiller.jdt.JavaASTBodyTransformer.java

License:Apache License

/**
 * {@inheritDoc}/*from ww  w  .ja  v  a2s .c  om*/
 */
@Override
public boolean visit(WhileStatement node) {
    push(fASTHelper.convertNode(node), node.getExpression().toString(), node.getStartPosition(),
            node.getLength());
    return true;
}