Closed cushon closed 9 years ago
Original comment posted by supertri@google.com on 2013-11-21 at 08:18 PM
(No comment entered for this change.)
Owner: cushon@google.com
Original comment posted by cushon@google.com on 2014-01-22 at 01:20 AM
(No comment entered for this change.)
Status: Fixed
Original issue created by fuyaoz@google.com on 2013-11-20 at 08:13 AM
If a CU have multiple class definitions, the way we currently doing is scan the CU after all classes have been seen
https://github.com/cushon/issues-import/blob/master/core/src/main/java/com/google/errorprone/ErrorProneAnalyzer.java#L85
this is not right, because javac (at least 1.7) is parsing, analyzing and generating code for classes one by one, and after done with one class, it will remove its AST internal structure. So, if I have a file:
class A { int a; }
class B { int b; }
class C { int c; }
then at the time we do analysis, the entire AST is like: class A { }
class B { }
class C { int c; }
I suggest the fix would be:
replace the entire block with:
try { errorProneScanner.scan(env.tree, createVisitorState(env)); } ....