Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Aug 13, 2024
1 parent ab2ecf7 commit 9eeeee1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,18 @@ private void visitMethodDef(DetailAST ast) {
}

private boolean containsAnnotation(DetailAST ast, List<Annotation> annotations) {
List<String> annotationNames = annotations.stream().flatMap((annotation) ->
Stream.of(annotation.simpleName, annotation.fullyQualifiedName())).collect(Collectors.toList());
List<String> annotationNames = annotations.stream()
.flatMap((annotation) -> Stream.of(annotation.simpleName, annotation.fullyQualifiedName()))
.collect(Collectors.toList());
try {
return AnnotationUtil.containsAnnotation(ast, annotationNames);
}
catch (NoSuchMethodError ex) {
// Checkstyle >= 10.3 (https://github.com/checkstyle/checkstyle/issues/14134)
Set<String> annotationNamesSet = new HashSet<>(annotationNames);
try {
return (boolean) AnnotationUtil.class.getMethod("containsAnnotation", DetailAST.class, Set.class)
.invoke(null, ast, annotationNamesSet);
return (boolean) AnnotationUtil.class.getMethod("containsAnnotation", DetailAST.class, Set.class)
.invoke(null, ast, annotationNamesSet);
}
catch (Exception ex2) {
throw new RuntimeException("containsAnnotation failed", ex2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

/**
* Checks that test class filenames end {@literal Tests.java} and not {@literal Test.java}.
* Checks that test class filenames end {@literal Tests.java} and not
* {@literal Test.java}.
*
* @author Phillip Webb
* @author Andy Wilkinson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ public void loadShouldLoadChecks() {

@Test
public void loadWithExcludeShouldExcludeChecks() {
Set<String> excludes = new HashSet<String>(Arrays.asList("com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck",
"com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck"));
Set<String> excludes = new HashSet<String>(
Arrays.asList("com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck",
"com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck"));
Collection<FileSetCheck> checks = load(excludes);
assertThat(checks).hasSize(5);
TreeWalker treeWalker = (TreeWalker) checks.toArray()[4];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public boolean visit(Javadoc node) {
int commentIndex = this.tokenManager.firstIndexIn(node, TerminalTokens.TokenNameCOMMENT_JAVADOC);
Token commentToken = this.tokenManager.get(commentIndex);
this.commentTokenManager = (commentToken.getInternalStructure() != null)
? new TokenManager(commentToken.getInternalStructure(), this.tokenManager)
: null;
? new TokenManager(commentToken.getInternalStructure(), this.tokenManager) : null;
this.declaration = node.getParent();
this.firstTagElement = true;
this.hasText = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public boolean visit(Javadoc node) {
int commentIndex = this.tokenManager.firstIndexIn(node, TerminalTokens.TokenNameCOMMENT_JAVADOC);
Token commentToken = this.tokenManager.get(commentIndex);
this.commentTokenManager = (commentToken.getInternalStructure() != null)
? new TokenManager(commentToken.getInternalStructure(), this.tokenManager)
: null;
? new TokenManager(commentToken.getInternalStructure(), this.tokenManager) : null;
this.declaration = node.getParent();
this.firstTagElement = true;
this.hasText = false;
Expand Down

0 comments on commit 9eeeee1

Please sign in to comment.