@@ -32,41 +32,45 @@ public MethodsFirstChecker(Context context, Factory factory) {
3232
3333 @ Override
3434 public <T > void visitCtClass (CtClass <T > ctClass ) {
35- context .reinitializeContext ();
3635 if (visitedClasses .contains (ctClass .getQualifiedName ()))
3736 return ;
3837 else
3938 visitedClasses .add (ctClass .getQualifiedName ());
40- // visitInterfaces
41- if (!ctClass .getSuperInterfaces ().isEmpty ())
42- for (CtTypeReference <?> t : ctClass .getSuperInterfaces ()) {
43- if (t .isInterface ()) {
44- CtType <?> ct = t .getDeclaration ();
45- if (ct instanceof CtInterface )
46- visitCtInterface ((CtInterface <?>) ct );
39+ Context .ClassScope scope = context .enterClassScope ();
40+ try {
41+ // visitInterfaces
42+ if (!ctClass .getSuperInterfaces ().isEmpty ())
43+ for (CtTypeReference <?> t : ctClass .getSuperInterfaces ()) {
44+ if (t .isInterface ()) {
45+ CtType <?> ct = t .getDeclaration ();
46+ if (ct instanceof CtInterface )
47+ visitCtInterface ((CtInterface <?>) ct );
48+ }
4749 }
50+ // visitSubclasses
51+ CtTypeReference <?> sup = ctClass .getSuperclass ();
52+ if (sup != null && sup .isClass ()) {
53+ CtType <?> ct = sup .getDeclaration ();
54+ if (ct instanceof CtClass )
55+ visitCtClass ((CtClass <?>) ct );
4856 }
49- // visitSubclasses
50- CtTypeReference <?> sup = ctClass .getSuperclass ();
51- if (sup != null && sup .isClass ()) {
52- CtType <?> ct = sup .getDeclaration ();
53- if (ct instanceof CtClass )
54- visitCtClass ((CtClass <?>) ct );
55- }
56- // first try-catch: process class-level annotations)
57- // errors here should not prevent visiting methods, constructors or fields of the class
58- try {
59- getRefinementFromAnnotation (ctClass );
60- handleStateSetsFromAnnotation (ctClass );
61- } catch (LJError e ) {
62- diagnostics .add (e );
63- }
64- // second try-catch: visit class children (methods, constructors, fields)
65- // errors from one child should not prevent visiting sibling elements
66- try {
67- super .visitCtClass (ctClass );
68- } catch (LJError e ) {
69- diagnostics .add (e );
57+ // first try-catch: process class-level annotations)
58+ // errors here should not prevent visiting methods, constructors or fields of the class
59+ try {
60+ getRefinementFromAnnotation (ctClass );
61+ handleStateSetsFromAnnotation (ctClass );
62+ } catch (LJError e ) {
63+ diagnostics .add (e );
64+ }
65+ // second try-catch: visit class children (methods, constructors, fields)
66+ // errors from one child should not prevent visiting sibling elements
67+ try {
68+ super .visitCtClass (ctClass );
69+ } catch (LJError e ) {
70+ diagnostics .add (e );
71+ }
72+ } finally {
73+ context .exitClassScope (scope );
7074 }
7175 }
7276
0 commit comments