29 |
29 |
30 import com.sun.tools.javac.tree.*; |
30 import com.sun.tools.javac.tree.*; |
31 import com.sun.tools.javac.util.*; |
31 import com.sun.tools.javac.util.*; |
32 import com.sun.tools.javac.util.List; |
32 import com.sun.tools.javac.util.List; |
33 import com.sun.tools.javac.tree.JCTree.*; |
33 import com.sun.tools.javac.tree.JCTree.*; |
|
34 import com.sun.tools.javac.parser.EndPosTable; |
34 |
35 |
35 /** This class contains the CharacterRangeTable for some method |
36 /** This class contains the CharacterRangeTable for some method |
36 * and the hashtable for mapping trees or lists of trees to their |
37 * and the hashtable for mapping trees or lists of trees to their |
37 * ending positions. |
38 * ending positions. |
38 * |
39 * |
52 |
53 |
53 /** The hashtable for source positions. |
54 /** The hashtable for source positions. |
54 */ |
55 */ |
55 private Map<Object,SourceRange> positions = new HashMap<Object,SourceRange>(); |
56 private Map<Object,SourceRange> positions = new HashMap<Object,SourceRange>(); |
56 |
57 |
57 /** The hashtable for ending positions stored in the parser. |
58 /** The object for ending positions stored in the parser. |
58 */ |
59 */ |
59 private Map<JCTree, Integer> endPositions; |
60 private EndPosTable endPosTable; |
60 |
61 |
61 /** The tree of the method this table is intended for. |
62 /** The tree of the method this table is intended for. |
62 * We should traverse this tree to get source ranges. |
63 * We should traverse this tree to get source ranges. |
63 */ |
64 */ |
64 JCTree.JCMethodDecl methodTree; |
65 JCTree.JCMethodDecl methodTree; |
65 |
66 |
66 /** Constructor |
67 /** Constructor |
67 */ |
68 */ |
68 public CRTable(JCTree.JCMethodDecl tree, Map<JCTree, Integer> endPositions) { |
69 public CRTable(JCTree.JCMethodDecl tree, EndPosTable endPosTable) { |
69 this.methodTree = tree; |
70 this.methodTree = tree; |
70 this.endPositions = endPositions; |
71 this.endPosTable = endPosTable; |
71 } |
72 } |
72 |
73 |
73 /** Create a new CRTEntry and add it to the entries. |
74 /** Create a new CRTEntry and add it to the entries. |
74 * @param tree The tree or the list of trees for which |
75 * @param tree The tree or the list of trees for which |
75 * we are storing the code pointers. |
76 * we are storing the code pointers. |
532 */ |
533 */ |
533 public int endPos(JCTree tree) { |
534 public int endPos(JCTree tree) { |
534 if (tree == null) return Position.NOPOS; |
535 if (tree == null) return Position.NOPOS; |
535 if (tree.hasTag(JCTree.Tag.BLOCK)) |
536 if (tree.hasTag(JCTree.Tag.BLOCK)) |
536 return ((JCBlock) tree).endpos; |
537 return ((JCBlock) tree).endpos; |
537 Integer endpos = endPositions.get(tree); |
538 return endPosTable.getEndPos(tree); |
538 if (endpos != null) |
|
539 return endpos.intValue(); |
|
540 return Position.NOPOS; |
|
541 } |
539 } |
542 } |
540 } |
543 |
541 |
544 /** This class contains a CharacterRangeTableEntry. |
542 /** This class contains a CharacterRangeTableEntry. |
545 */ |
543 */ |