1616 */
1717public class InstanceOfScanner extends CommonScanner {
1818
19- /**
20- * Computes the index of the given instanceof tree amongst all instanceof tree inside its method,
21- * using 0-based indexing.
22- *
23- * @param origpath the path ending in the given instanceof tree
24- * @param tree the instanceof tree to search for
25- * @return the index of the given instanceof tree
26- */
27- public static int indexOfInstanceOfTree (TreePath origpath , Tree tree ) {
28- TreePath path = TreePathUtil .findCountingContext (origpath );
29- if (path == null ) {
30- return -1 ;
31- }
32-
33- InstanceOfScanner ios = new InstanceOfScanner (tree );
34- ios .scan (path , null );
35- return ios .index ;
36- }
37-
3819 private int index = -1 ;
3920 private boolean done = false ;
4021 private final Tree tree ;
@@ -61,6 +42,25 @@ public Void visitInstanceOf(InstanceOfTree node, Void p) {
6142 return super .visitInstanceOf (node , null );
6243 }
6344
45+ /**
46+ * Computes the index of the given instanceof tree amongst all instanceof tree inside its method,
47+ * using 0-based indexing.
48+ *
49+ * @param origpath the path ending in the given instanceof tree
50+ * @param tree the instanceof tree to search for
51+ * @return the index of the given instanceof tree
52+ */
53+ public static int indexOfInstanceOfTree (TreePath origpath , Tree tree ) {
54+ TreePath path = TreePathUtil .findCountingContext (origpath );
55+ if (path == null ) {
56+ return -1 ;
57+ }
58+
59+ InstanceOfScanner ios = new InstanceOfScanner (tree );
60+ ios .scan (path , null );
61+ return ios .index ;
62+ }
63+
6464 // Map from name of a method to a list of bytecode offsets of all
6565 // instanceof checks in that method.
6666 private static Map <String , List <Integer >> methodNameToInstanceOfOffsets = new HashMap <>();
0 commit comments