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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom Modifier 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:lombok.eclipse.agent.PatchValEclipse.java

License:Open Source License

public static Modifier createModifier(AST ast, ModifierKeyword keyword, int start, int end) {
    Modifier modifier = null;
    try {/*w w w  .j av  a 2  s .  com*/
        modifier = Reflection.modifierConstructor.newInstance(ast);
    } catch (InstantiationException e) {
        throw Lombok.sneakyThrow(e);
    } catch (IllegalAccessException e) {
        throw Lombok.sneakyThrow(e);
    } catch (InvocationTargetException e) {
        throw Lombok.sneakyThrow(e);
    }

    if (modifier != null) {
        modifier.setKeyword(keyword);
        modifier.setSourceRange(start, end - start + 1);
    }
    return modifier;
}

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

License:Open Source License

/**
 * @return a new modifier//from www.j  a va  2  s  . c o m
 */
private Modifier createModifier(ModifierKeyword keyword) {
    final Modifier modifier = new Modifier(this.ast);
    modifier.setKeyword(keyword);
    int start = this.scanner.getCurrentTokenStartPosition();
    int end = this.scanner.getCurrentTokenEndPosition();
    modifier.setSourceRange(start, end - start + 1);
    return modifier;
}