@@ -367,14 +367,15 @@ public void visit(ClassDeclaration cldec) {
367
367
}
368
368
addToPath (cldec );
369
369
typeInfo = new TypeDeclarationTypeInfo (cldec );
370
- scan (cldec .getAttributes ());
371
370
scan (cldec .getSuperClass ());
372
371
scan (cldec .getInterfaces ());
373
372
Identifier name = cldec .getName ();
374
373
addColoringForNode (name , createTypeNameColoring (cldec ));
375
374
needToScan .put (typeInfo , new ArrayList <>());
376
375
if (cldec .getBody () != null ) {
377
376
cldec .getBody ().accept (this );
377
+ // GH-8244 scan attributes after constant declarations are scanned
378
+ scan (cldec .getAttributes ());
378
379
379
380
// find all usages in the method bodies
380
381
scanMethodBodies ();
@@ -513,13 +514,14 @@ public void visit(ClassInstanceCreation node) {
513
514
// GH-5551 keep original type info to scan parent blocks
514
515
TypeInfo originalTypeInfo = typeInfo ;
515
516
typeInfo = new ClassInstanceCreationTypeInfo (node );
516
- scan (node .getAttributes ());
517
517
scan (node .getSuperClass ());
518
518
scan (node .getInterfaces ());
519
519
needToScan .put (typeInfo , new ArrayList <>());
520
520
Block body = node .getBody ();
521
521
if (body != null ) {
522
522
body .accept (this );
523
+ // GH-8244 scan attributes after constant declarations are scanned
524
+ scan (node .getAttributes ());
523
525
524
526
// find all usages in the method bodies
525
527
scanMethodBodies ();
@@ -571,14 +573,15 @@ public void visit(EnumDeclaration node) {
571
573
return ;
572
574
}
573
575
addToPath (node );
574
- scan (node .getAttributes ());
575
576
scan (node .getInterfaces ());
576
577
typeInfo = new TypeDeclarationTypeInfo (node );
577
578
Identifier name = node .getName ();
578
579
addColoringForNode (name , createTypeNameColoring (node ));
579
580
needToScan .put (typeInfo , new ArrayList <>());
580
581
if (node .getBody () != null ) {
581
582
node .getBody ().accept (this );
583
+ // GH-8244 scan attributes after constant declarations are scanned
584
+ scan (node .getAttributes ());
582
585
scanMethodBodies ();
583
586
addColoringForUnusedPrivateConstants ();
584
587
}
0 commit comments