|
1 | 1 | /*
|
2 |
| - * Copyright 2017-2021 the original author or authors. |
| 2 | + * Copyright 2017-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 |
|
23 | 23 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.ASTNode;
|
24 | 24 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.ASTVisitor;
|
| 25 | +import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.AbstractTypeDeclaration; |
25 | 26 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.Comment;
|
26 | 27 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.CompilationUnit;
|
27 | 28 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.Javadoc;
|
28 | 29 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.TagElement;
|
29 | 30 | import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.TextElement;
|
30 |
| -import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.TypeDeclaration; |
31 | 31 | import io.spring.javaformat.eclipse.jdt.jdk11.core.formatter.CodeFormatter;
|
32 | 32 | import io.spring.javaformat.eclipse.jdt.jdk11.internal.compiler.parser.TerminalTokens;
|
33 | 33 | import io.spring.javaformat.eclipse.jdt.jdk11.internal.formatter.Preparator;
|
34 | 34 | import io.spring.javaformat.eclipse.jdt.jdk11.internal.formatter.Token;
|
35 | 35 | import io.spring.javaformat.eclipse.jdt.jdk11.internal.formatter.TokenManager;
|
36 | 36 |
|
37 | 37 | /**
|
38 |
| - * {@link Preparator} to fine tune Javadoc whitespace. |
| 38 | + * {@link Preparator} to finetune Javadoc whitespace. |
39 | 39 | *
|
40 | 40 | * @author Phillip Webb
|
41 | 41 | */
|
@@ -112,15 +112,15 @@ public boolean visit(TagElement node) {
|
112 | 112 | int startIndex = this.commentTokenManager.findIndex(node.getStartPosition(), -1, false);
|
113 | 113 | Token token = this.commentTokenManager.get(startIndex);
|
114 | 114 | token.clearLineBreaksBefore();
|
115 |
| - token.putLineBreaksBefore( |
116 |
| - this.declaration instanceof TypeDeclaration && this.firstTagElement && this.hasText ? 2 : 1); |
| 115 | + boolean isTypeDeclaration = this.declaration instanceof AbstractTypeDeclaration; |
| 116 | + token.putLineBreaksBefore(isTypeDeclaration && this.firstTagElement && this.hasText ? 2 : 1); |
117 | 117 | this.firstTagElement = false;
|
118 | 118 | }
|
119 | 119 | return true;
|
120 | 120 | }
|
121 | 121 |
|
122 | 122 | private boolean isSquashRequired(TagElement node, ASTNode declaration) {
|
123 |
| - if (declaration instanceof TypeDeclaration) { |
| 123 | + if (declaration instanceof AbstractTypeDeclaration) { |
124 | 124 | String tagName = node.getTagName();
|
125 | 125 | return (!node.isNested() && tagName != null && tagName.startsWith("@"));
|
126 | 126 | }
|
|
0 commit comments