File tree Expand file tree Collapse file tree 1 file changed +10
-16
lines changed
core/src/main/java/com/google/errorprone/bugpatterns/inlineme Expand file tree Collapse file tree 1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change 69
69
import com .sun .tools .javac .parser .ParserFactory ;
70
70
import com .sun .tools .javac .tree .EndPosTable ;
71
71
import com .sun .tools .javac .tree .JCTree ;
72
+ import java .lang .reflect .Proxy ;
72
73
import java .util .ArrayList ;
73
74
import java .util .List ;
74
75
import java .util .Objects ;
@@ -572,21 +573,14 @@ private boolean matchesApiPrefixes(Api api) {
572
573
}
573
574
574
575
private static EndPosTable asEndPosTable (JavacParser parser ) {
575
- return new EndPosTable () {
576
- @ Override
577
- public int getEndPos (JCTree tree ) {
578
- return parser .getEndPos (tree );
579
- }
580
-
581
- @ Override
582
- public void storeEnd (JCTree tree , int endpos ) {
583
- throw new AssertionError ();
584
- }
585
-
586
- @ Override
587
- public int replaceTree (JCTree oldtree , JCTree newtree ) {
588
- throw new AssertionError ();
589
- }
590
- };
576
+ return (EndPosTable )
577
+ Proxy .newProxyInstance (
578
+ EndPosTable .class .getClassLoader (),
579
+ new Class <?>[] {EndPosTable .class },
580
+ (proxy , method , args ) ->
581
+ switch (method .getName ()) {
582
+ case "getEndPos" -> parser .getEndPos ((JCTree ) args [0 ]);
583
+ default -> throw new AssertionError ("Unexpected method: " + method .getName ());
584
+ });
591
585
}
592
586
}
You can’t perform that action at this time.
0 commit comments