Method from com.sun.tools.javac.jvm.CRTable$SourceComputer Detail: |
public SourceRange csp(JCTree tree) {
if (tree == null) return null;
tree.accept(this);
if (result != null) {
positions.put(tree, result);
}
return result;
}
Visitor method: compute source positions for a single node. |
public SourceRange csp(List<JCTree> trees) {
if ((trees == null) || !(trees.nonEmpty())) return null;
SourceRange list_sr = new SourceRange();
for (List< ? extends JCTree > l = trees; l.nonEmpty(); l = l.tail) {
list_sr.mergeWith(csp(l.head));
}
positions.put(trees, list_sr);
return list_sr;
}
Visitor method: compute source positions for a list of nodes. |
public SourceRange cspCases(List<JCCase> trees) {
if ((trees == null) || !(trees.nonEmpty())) return null;
SourceRange list_sr = new SourceRange();
for (List< JCCase > l = trees; l.nonEmpty(); l = l.tail) {
list_sr.mergeWith(csp(l.head));
}
positions.put(trees, list_sr);
return list_sr;
}
Visitor method: compute source positions for
a list of case blocks of switch statements. |
public SourceRange cspCatchers(List<JCCatch> trees) {
if ((trees == null) || !(trees.nonEmpty())) return null;
SourceRange list_sr = new SourceRange();
for (List< JCCatch > l = trees; l.nonEmpty(); l = l.tail) {
list_sr.mergeWith(csp(l.head));
}
positions.put(trees, list_sr);
return list_sr;
}
Visitor method: compute source positions for
a list of catch clauses in try statements. |
public int endPos(JCTree tree) {
if (tree == null) return Position.NOPOS;
if (tree.getTag() == JCTree.BLOCK)
return ((JCBlock) tree).endpos;
Integer endpos = endPositions.get(tree);
if (endpos != null)
return endpos.intValue();
return Position.NOPOS;
}
The end position of given tree, if it has
defined endpos, NOPOS otherwise. |
public int startPos(JCTree tree) {
if (tree == null) return Position.NOPOS;
return tree.pos;
}
The start position of given tree. |
public void visitApply(JCMethodInvocation tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.meth));
sr.mergeWith(csp(tree.args));
result = sr;
}
|
public void visitAssert(JCAssert tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.detail));
result = sr;
}
|
public void visitAssign(JCAssign tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lhs));
sr.mergeWith(csp(tree.rhs));
result = sr;
}
|
public void visitAssignop(JCAssignOp tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lhs));
sr.mergeWith(csp(tree.rhs));
result = sr;
}
|
public void visitBinary(JCBinary tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lhs));
sr.mergeWith(csp(tree.rhs));
result = sr;
}
|
public void visitBlock(JCBlock tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
csp(tree.stats); // doesn't compare because block's ending position is defined
result = sr;
}
|
public void visitBreak(JCBreak tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
|
public void visitCase(JCCase tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.pat));
sr.mergeWith(csp(tree.stats));
result = sr;
}
|
public void visitCatch(JCCatch tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.param));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitConditional(JCConditional tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.truepart));
sr.mergeWith(csp(tree.falsepart));
result = sr;
}
|
public void visitContinue(JCContinue tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
|
public void visitDoLoop(JCDoWhileLoop tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.body));
sr.mergeWith(csp(tree.cond));
result = sr;
}
|
public void visitErroneous(JCErroneous tree) {
result = null;
}
|
public void visitExec(JCExpressionStatement tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
|
public void visitForLoop(JCForLoop tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.init));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.step));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitForeachLoop(JCEnhancedForLoop tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.var));
sr.mergeWith(csp(tree.expr));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitIdent(JCIdent tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
|
public void visitIf(JCIf tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.thenpart));
sr.mergeWith(csp(tree.elsepart));
result = sr;
}
|
public void visitIndexed(JCArrayAccess tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.indexed));
sr.mergeWith(csp(tree.index));
result = sr;
}
|
public void visitLabelled(JCLabeledStatement tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitLiteral(JCLiteral tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
|
public void visitMethodDef(JCMethodDecl tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitNewArray(JCNewArray tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.elemtype));
sr.mergeWith(csp(tree.dims));
sr.mergeWith(csp(tree.elems));
result = sr;
}
|
public void visitNewClass(JCNewClass tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.encl));
sr.mergeWith(csp(tree.clazz));
sr.mergeWith(csp(tree.args));
sr.mergeWith(csp(tree.def));
result = sr;
}
|
public void visitParens(JCParens tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
|
public void visitReturn(JCReturn tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
|
public void visitSelect(JCFieldAccess tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.selected));
result = sr;
}
|
public void visitSkip(JCSkip tree) {
// endPos is the same as startPos for the empty statement
SourceRange sr = new SourceRange(startPos(tree), startPos(tree));
result = sr;
}
|
public void visitSwitch(JCSwitch tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.selector));
sr.mergeWith(cspCases(tree.cases));
result = sr;
}
|
public void visitSynchronized(JCSynchronized tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lock));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitThrow(JCThrow tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
|
public void visitTree(JCTree tree) {
Assert.error();
}
|
public void visitTry(JCTry tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.resources));
sr.mergeWith(csp(tree.body));
sr.mergeWith(cspCatchers(tree.catchers));
sr.mergeWith(csp(tree.finalizer));
result = sr;
}
|
public void visitTypeApply(JCTypeApply tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.clazz));
sr.mergeWith(csp(tree.arguments));
result = sr;
}
|
public void visitTypeArray(JCArrayTypeTree tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.elemtype));
result = sr;
}
|
public void visitTypeCast(JCTypeCast tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.clazz));
sr.mergeWith(csp(tree.expr));
result = sr;
}
|
public void visitTypeIdent(JCPrimitiveTypeTree tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
|
public void visitTypeParameter(JCTypeParameter tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.bounds));
result = sr;
}
|
public void visitTypeTest(JCInstanceOf tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
sr.mergeWith(csp(tree.clazz));
result = sr;
}
|
public void visitUnary(JCUnary tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.arg));
result = sr;
}
|
public void visitVarDef(JCVariableDecl tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
csp(tree.vartype);
sr.mergeWith(csp(tree.init));
result = sr;
}
|
public void visitWhileLoop(JCWhileLoop tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.body));
result = sr;
}
|
public void visitWildcard(JCWildcard tree) {
result = null;
}
|