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 6969import com .sun .tools .javac .parser .ParserFactory ;
7070import com .sun .tools .javac .tree .EndPosTable ;
7171import com .sun .tools .javac .tree .JCTree ;
72+ import java .lang .reflect .Proxy ;
7273import java .util .ArrayList ;
7374import java .util .List ;
7475import java .util .Objects ;
@@ -572,21 +573,14 @@ private boolean matchesApiPrefixes(Api api) {
572573 }
573574
574575 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+ });
591585 }
592586}
You can’t perform that action at this time.
0 commit comments