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

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

Introduction

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

Prototype

public final int getStartPosition() 

Source Link

Document

Returns the character index into the original source file indicating where the source fragment corresponding to this node begins.

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>
 */// ww  w.  j ava2  s  .  co  m
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;
}