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

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

Introduction

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

public StringLiteral convert(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral expression) {
    expression.computeConstant();/*from   w  w  w .  j av  a2s . co  m*/
    StringLiteral literal = new StringLiteral(this.ast);
    if (this.resolveBindings) {
        this.recordNodes(literal, expression);
    }
    literal.setLiteralValue(expression.constant.stringValue());
    literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
    return literal;
}

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

License:Open Source License

public Expression convert(org.eclipse.jdt.internal.compiler.ast.StringLiteral expression) {
    if (expression instanceof StringLiteralConcatenation) {
        return convert((StringLiteralConcatenation) expression);
    }// w w w.j  a  v  a2 s  .  co m
    int length = expression.sourceEnd - expression.sourceStart + 1;
    int sourceStart = expression.sourceStart;
    StringLiteral literal = new StringLiteral(this.ast);
    if (this.resolveBindings) {
        this.recordNodes(literal, expression);
    }
    literal.internalSetEscapedValue(new String(this.compilationUnitSource, sourceStart, length));
    literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
    return literal;
}