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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom TypeLiteral 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:org.wloka.reflectify.tests.assist.ClassAccessTest.java

License:Open Source License

/** 
 * @return selection (offset,length) of first simple type node within statement given by <code>statementIndex</code>
 *///from   www . ja va 2  s .  c om
private int[] getTypeLiteralSelection(int statementIndex, IMethod target) {
    MethodDeclaration targetNode = compileTargetMethod(target);
    Statement stmt = (Statement) targetNode.getBody().statements().get(statementIndex);
    final int[] selection = new int[2];
    stmt.accept(new ASTVisitor() {
        @Override
        public boolean visit(TypeLiteral node) {
            if (selection[1] == 0) {
                selection[0] = node.getStartPosition();
                selection[1] = node.getLength();
            }
            return false;
        }
    });
    return selection;
}