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

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

Introduction

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

    Block body = node.getBody();/*from w w  w.  j a  v a  2 s .c o m*/

    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 {
        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(SynchronizedStatement node) {
    String hint = GetNodeText(node.getExpression());
    int startLoc = node.getStartPosition();
    int endLoc = startLoc + node.getLength() - 1;
    try {/*from w  w  w . j a va  2  s. co  m*/
        _container.add(new Hint("synchronized", startLoc, endLoc, "synchronized( " + hint + " )")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    } catch (BadLocationException e) {
        _cancelProcessing.set(true);
    }
    return shouldContinue();
}