@@ -612,11 +612,16 @@ private VariableFinder(VisitorState state) {
612
612
613
613
@ Override
614
614
public Void visitVariable (VariableTree variableTree , Void unused ) {
615
+ handleVariable (variableTree );
616
+ return super .visitVariable (variableTree , null );
617
+ }
618
+
619
+ private void handleVariable (VariableTree variableTree ) {
615
620
if (exemptedByName (variableTree .getName ())) {
616
- return null ;
621
+ return ;
617
622
}
618
623
if (isSuppressed (variableTree , state )) {
619
- return null ;
624
+ return ;
620
625
}
621
626
VarSymbol symbol = getSymbol (variableTree );
622
627
var parent = getCurrentPath ().getParentPath ().getLeaf ();
@@ -626,22 +631,22 @@ public Void visitVariable(VariableTree variableTree, Void unused) {
626
631
unusedElements .put (symbol , getCurrentPath ());
627
632
usageSites .put (symbol , getCurrentPath ());
628
633
}
629
- return null ;
634
+ return ;
630
635
}
631
636
if (symbol .getKind () == ElementKind .FIELD
632
637
&& symbol .getSimpleName ().contentEquals ("CREATOR" )
633
638
&& isSubtype (symbol .type , PARCELABLE_CREATOR .get (state ), state )) {
634
- return null ;
639
+ return ;
635
640
}
636
641
if (symbol .getKind () == ElementKind .FIELD
637
642
&& exemptedFieldBySuperType (getType (variableTree ), state )) {
638
- return null ;
643
+ return ;
639
644
}
640
645
super .visitVariable (variableTree , null );
641
646
// Return if the element is exempted by an annotation.
642
647
if (exemptedByAnnotation (variableTree .getModifiers ().getAnnotations ())
643
648
|| shouldKeep (variableTree )) {
644
- return null ;
649
+ return ;
645
650
}
646
651
switch (symbol .getKind ()) {
647
652
case FIELD :
@@ -658,14 +663,14 @@ && exemptedFieldBySuperType(getType(variableTree), state)) {
658
663
case PARAMETER :
659
664
// ignore the receiver parameter
660
665
if (variableTree .getName ().contentEquals ("this" )) {
661
- return null ;
666
+ return ;
662
667
}
663
668
// Ignore if parameter is part of canonical record constructor; tree does not seem
664
669
// to contain usage in that case, but parameter is always used implicitly
665
670
// For compact canonical constructor parameters don't have record flag so need to
666
671
// check constructor flags (`symbol.owner`) instead
667
672
if (hasRecordFlag (symbol .owner )) {
668
- return null ;
673
+ return ;
669
674
}
670
675
unusedElements .put (symbol , getCurrentPath ());
671
676
if (!isParameterSubjectToAnalysis (symbol )) {
@@ -675,7 +680,6 @@ && exemptedFieldBySuperType(getType(variableTree), state)) {
675
680
default :
676
681
break ;
677
682
}
678
- return null ;
679
683
}
680
684
681
685
private boolean exemptedFieldBySuperType (Type type , VisitorState state ) {
0 commit comments