Example usage for org.eclipse.jdt.core.dom VariableDeclarationStatement setSourceRange

List of usage examples for org.eclipse.jdt.core.dom VariableDeclarationStatement setSourceRange

Introduction

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

Prototype

public final void setSourceRange(int startPosition, int length) 

Source Link

Document

Sets the source range of the original source file where the source fragment corresponding to this node was found.

Usage

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

protected VariableDeclarationStatement convertToVariableDeclarationStatement(
        org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
    final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(
            localDeclaration);//from ww w .ja va  2  s.  c om
    final VariableDeclarationStatement variableDeclarationStatement = new VariableDeclarationStatement(
            this.ast);
    variableDeclarationStatement.fragments().add(variableDeclarationFragment);
    if (this.resolveBindings) {
        recordNodes(variableDeclarationFragment, localDeclaration);
    }
    variableDeclarationStatement.setSourceRange(localDeclaration.declarationSourceStart,
            localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
    Type type = convertType(localDeclaration.type);
    setTypeForVariableDeclarationStatement(variableDeclarationStatement, type,
            variableDeclarationFragment.getExtraDimensions());
    if (localDeclaration.modifiersSourceStart != -1) {
        setModifiers(variableDeclarationStatement, localDeclaration);
    }
    return variableDeclarationStatement;
}