Skip to content

Commit 3036fca

Browse files
committed
Permit fully-qualified refs in concise annotation attribute check
Closes gh-452
1 parent b4a9b01 commit 3036fca

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringAnnotationAttributeConciseValueCheck.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void visitValueExpression(DetailAST valueExpression, DetailAST annotatio
9999
return;
100100
}
101101
List<String> expressionComponents = dotSeparatedComponents(valueExpression.getFirstChild());
102-
if (expressionComponents == null || expressionComponents.size() <= 2) {
102+
if (expressionComponents == null || expressionComponents.size() <= 2 || fullyQualifiedTypeName(expressionComponents)) {
103103
return;
104104
}
105105
String outerTypeName = expressionComponents.get(0);
@@ -136,6 +136,10 @@ private List<String> dotSeparatedComponents(DetailAST ast) {
136136
return null;
137137
}
138138

139+
private boolean fullyQualifiedTypeName(List<String> expressionComponents) {
140+
return Character.isLowerCase(expressionComponents.get(0).charAt(0));
141+
}
142+
139143
private boolean existingClashingImport(String outer, String inner) {
140144
return this.imports.stream().filter((imported) -> imported.clashesWith(outer, inner)).findFirst().isPresent();
141145
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
+0 errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2017-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@ConditionalOnWebApplicationType(com.example.ConditionalOnWebApplicationType.WebApplicationType.SERVLET)
18+
public class AnnotationAttributeWithValueThatHasFullyQualifiedReferenceToContainedEnumValue {
19+
20+
}

0 commit comments

Comments
 (0)