@@ -95,20 +95,26 @@ private void visitMemberValuePair(DetailAST annotationValue) {
95
95
}
96
96
97
97
private void visitValueExpression (DetailAST valueExpression , DetailAST annotation , String attributeName ) {
98
- if (valueExpression != null && valueExpression .getChildCount () == 1 ) {
99
- List <String > expressionComponents = dotSeparatedComponents (valueExpression .getFirstChild ());
100
- if (expressionComponents != null && expressionComponents .size () > 2 ) {
101
- String outerTypeName = expressionComponents .get (0 );
102
- String annotationName = annotation .findFirstToken (TokenTypes .IDENT ).getText ();
103
- if (outerTypeName .equals (annotationName )) {
104
- String innerTypeName = expressionComponents .get (1 );
105
- if (!existingClashingImport (outerTypeName , innerTypeName )) {
106
- String toImport = outerTypeName + "." + innerTypeName ;
107
- String replacement = String .join ("." , expressionComponents .subList (1 , expressionComponents .size ()));
108
- log (valueExpression .getLineNo (), valueExpression .getColumnNo (),
109
- "annotation.attribute.overlyVerboseValue" , attributeName , toImport , replacement );
110
- }
111
- }
98
+ if (valueExpression == null || valueExpression .getChildCount () != 1 ) {
99
+ return ;
100
+ }
101
+ List <String > expressionComponents = dotSeparatedComponents (valueExpression .getFirstChild ());
102
+ if (expressionComponents == null || expressionComponents .size () <= 2 ) {
103
+ return ;
104
+ }
105
+ String outerTypeName = expressionComponents .get (0 );
106
+ DetailAST annotationIdent = annotation .findFirstToken (TokenTypes .IDENT );
107
+ if (annotationIdent == null ) {
108
+ return ;
109
+ }
110
+ String annotationName = annotationIdent .getText ();
111
+ if (outerTypeName .equals (annotationName )) {
112
+ String innerTypeName = expressionComponents .get (1 );
113
+ if (!existingClashingImport (outerTypeName , innerTypeName )) {
114
+ String toImport = outerTypeName + "." + innerTypeName ;
115
+ String replacement = String .join ("." , expressionComponents .subList (1 , expressionComponents .size ()));
116
+ log (valueExpression .getLineNo (), valueExpression .getColumnNo (),
117
+ "annotation.attribute.overlyVerboseValue" , attributeName , toImport , replacement );
112
118
}
113
119
}
114
120
}
0 commit comments