@Override public String getText(Interval interval) { return input.getText(interval); }
@Override public String getText(Interval interval) { return input.getText(interval); }
/** * Retrieves content for constructs of type Method, Constructor and Class. * @param ctx - ParseRuleContex * @return Extracted construct Body */ private final String getConstructContent(ParserRuleContext ctx){ final int a = ctx.start.getStartIndex(); final int b = ctx.stop.getStopIndex(); final Interval interval = new Interval(a,b); final String text = this.input.getText(interval); return text; }
public SourceRef createSourceRef(ParserRuleContext rule, Token start, Token stop) { // antlr's position in line is zero-based, but humans think in 1-based SourcePosition begin = new SourcePosition(start.getLine(), start.getCharPositionInLine() + 1, start.getStartIndex()); // stop index is inclusive -- we want it exclusive int stopIndex = stop.getStopIndex() + 1; int length = stopIndex - start.getStartIndex(); /** // the stop index actually is correct but uses an inclusive value // and we want to think in where the next token starts as the end int endPosInFile = stop.getStopIndex() + 1; stop.getTokenSource(). SourcePosition end = new SourcePosition(stop.getLine(), stop.getCharPositionInLine(), endPosInFile); */ String text = input.getText(new Interval(begin.getPosInFile(), stop.getStopIndex())); return new SourceRef(begin, length, text); }
public SourceRef createSourceRef(ParserRuleContext rule, Token start, Token stop) { // antlr's position in line is zero-based, but humans think in 1-based SourcePosition begin = new SourcePosition(start.getLine(), start.getCharPositionInLine() + 1, start.getStartIndex()); // stop index is inclusive -- we want it exclusive int stopIndex = stop.getStopIndex() + 1; int length = stopIndex - start.getStartIndex(); /** // the stop index actually is correct but uses an inclusive value // and we want to think in where the next token starts as the end int endPosInFile = stop.getStopIndex() + 1; stop.getTokenSource(). SourcePosition end = new SourcePosition(stop.getLine(), stop.getCharPositionInLine(), endPosInFile); */ String text = input.getText(new Interval(begin.getPosInFile(), stop.getStopIndex())); return new SourceRef(begin, length, text); }