@Override public int getEndPosition(EndPosTable endPositions) { return position.getEndPosition(endPositions) + endPositionAdjustment; } }
public String getRange(JCCompilationUnit unit) { try { CharSequence sequence = unit.getSourceFile().getCharContent(true); return sequence .subSequence(location.getStartPosition(), location.getEndPosition(unit.endPositions)) .toString(); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public String getRange(JCCompilationUnit unit) { try { CharSequence sequence = unit.getSourceFile().getCharContent(true); JCTree firstStatement = statements.get(0); JCTree lastStatement = Iterables.getLast(statements); return sequence .subSequence( firstStatement.getStartPosition(), lastStatement.getEndPosition(unit.endPositions)) .toString(); } catch (IOException e) { throw new RuntimeException(e); } } }
/** Returns the end position of the node, or -1 if it is not available. */ public int getEndPosition(Tree node) { JCCompilationUnit compilationUnit = (JCCompilationUnit) getPath().getCompilationUnit(); if (compilationUnit.endPositions == null) { return -1; } return ((JCTree) node).getEndPosition(compilationUnit.endPositions); }
/** * Exits the currently scanned tree. */ @Override protected void exit() { JCTree tree = stack.peek(); if (compilationUnit != null && tree instanceof JCBlock) { int endPos = tree.getEndPosition(diagnosticSource.getEndPosTable()); sourceMap.addEntry( new Position(endPos, // compilationUnit.lineMap.getLineNumber(endPos), // compilationUnit.lineMap.getColumnNumber(endPos)), new Position(getCurrentPosition(), currentLine, currentColumn)); } super.exit(); positionStack.pop(); }
@Override public int getEndPosition(EndPosTable endPositions) { return position.getEndPosition(endPositions) + endPositionAdjustment; } }
} else { int s = tree.getStartPosition(); int e = tree.getEndPosition(diagnosticSource.getEndPosTable()); if (e == -1) { e = s;
private <N extends Node> N setPos(JCTree node, N astNode) { if (astNode != null && node != null) { int start = node.pos; Integer end_ = endPosTable.get(node); if (node instanceof JCUnary) end_ = node.getEndPosition(endPosTable); int end = end_ == null ? node.getEndPosition(endPosTable) : end_; if (start != com.sun.tools.javac.util.Position.NOPOS && end != com.sun.tools.javac.util.Position.NOPOS) { astNode.setPosition(new Position(start, end)); } } return astNode; }
private Position getPosition(JCTree node) { if (node == null) return Position.UNPLACED; int start = node.pos; Integer end_ = null; if (endPosTable != null) end_ = endPosTable.get(node); int end = end_ == null ? node.getEndPosition(endPosTable) : end_; return new Position(start, end); }
private <N extends Node> N setPos(JCTree node, N astNode) { if (astNode != null && node != null) { int start = node.pos; Integer end_ = endPosTable.get(node); if (node instanceof JCUnary) end_ = node.getEndPosition(endPosTable); int end = end_ == null ? node.getEndPosition(endPosTable) : end_; if (start != com.sun.tools.javac.util.Position.NOPOS && end != com.sun.tools.javac.util.Position.NOPOS) { astNode.setPosition(new Position(start, end)); } } return astNode; }
private Position getPosition(JCTree node) { if (node == null) return Position.UNPLACED; int start = node.pos; Integer end_ = null; if (endPosTable != null) end_ = endPosTable.get(node); int end = end_ == null ? node.getEndPosition(endPosTable) : end_; return new Position(start, end); }
private <N extends Node> N setPos(JCTree node, N astNode) { if (astNode != null && node != null) { int start = node.pos; Integer end_ = endPosTable.get(node); if (node instanceof JCUnary) end_ = node.getEndPosition(endPosTable); int end = end_ == null ? node.getEndPosition(endPosTable) : end_; if (start != com.sun.tools.javac.util.Position.NOPOS && end != com.sun.tools.javac.util.Position.NOPOS) { astNode.setPosition(new Position(start, end)); } } return astNode; }
private Position getPosition(JCTree node) { if (node == null) return Position.UNPLACED; int start = node.pos; Integer end_ = null; if (endPosTable != null) end_ = endPosTable.get(node); int end = end_ == null ? node.getEndPosition(endPosTable) : end_; return new Position(start, end); }
@Override public String getRange(JCCompilationUnit unit) { try { CharSequence sequence = unit.getSourceFile().getCharContent(true); JCTree firstStatement = statements.get(0); JCTree lastStatement = statements.get(statements.size() - 1); return sequence .subSequence( firstStatement.getStartPosition(), lastStatement.getEndPosition(unit.endPositions)) .toString(); } catch (IOException e) { throw new RuntimeException(e); } } }
public String getRange(JCCompilationUnit unit) { try { CharSequence sequence = unit.getSourceFile().getCharContent(true); return sequence .subSequence(location.getStartPosition(), location.getEndPosition(unit.endPositions)) .toString(); } catch (IOException e) { throw new RuntimeException(e); } } }
/** Returns the end position of the node, or -1 if it is not available. */ public int getEndPosition(Tree node) { JCCompilationUnit compilationUnit = (JCCompilationUnit) getPath().getCompilationUnit(); if (compilationUnit.endPositions == null) { return -1; } return ((JCTree) node).getEndPosition(compilationUnit.endPositions); }
Integer endPos_ = null; if (endPosTable != null) endPos_ = endPosTable.get(tree); int endPos = endPos_ == null ? tree.getEndPosition(endPosTable) : endPos_; int startPos = tree.pos; if (tree instanceof JCTypeApply || tree instanceof JCWildcard || tree instanceof JCTypeParameter) {
Integer endPos_ = null; if (endPosTable != null) endPos_ = endPosTable.get(tree); int endPos = endPos_ == null ? tree.getEndPosition(endPosTable) : endPos_; int startPos = tree.pos; if (tree instanceof JCTypeApply || tree instanceof JCWildcard || tree instanceof JCTypeParameter) {
Integer endPos_ = null; if (endPosTable != null) endPos_ = endPosTable.get(tree); int endPos = endPos_ == null ? tree.getEndPosition(endPosTable) : endPos_; int startPos = tree.pos; if (tree instanceof JCTypeApply || tree instanceof JCWildcard || tree instanceof JCTypeParameter) {
private static void analyzeAnnotationTree( final Source src, final EndPosTable endPosTable, final AnnotationTree at) { if (at instanceof JCTree.JCAnnotation) { JCTree.JCAnnotation anno = (JCTree.JCAnnotation) at; int startPos = anno.getPreferredPosition(); int endPos = anno.getEndPosition(endPosTable); JCTree annotationType = anno.getAnnotationType(); int annotationTypeEndPosition = annotationType.getEndPosition(endPosTable); Range range; if (endPos != annotationTypeEndPosition) { startPos = annotationTypeEndPosition; } range = Range.create(src, startPos + 1, endPos); Type type = anno.type; Annotation annotation; if (nonNull(type)) { annotation = new Annotation(type.toString(), startPos, range); } else { annotation = new Annotation(annotationType.toString(), startPos, range); } src.annotationMap.put(range.begin.line, annotation); } }