Skip to content

Commit

Permalink
Issue #7413: remove obsolete import handling from JavadocMethodCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and pbludov committed Dec 29, 2019
1 parent 787f065 commit f4d032d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
2 changes: 0 additions & 2 deletions .ci/pitest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ pitest-javadoc)
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> if (child.getType() == TokenTypes.TYPE_PARAMETER) {</span></pre></td></tr>"
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> if (classInfo != null) {</span></pre></td></tr>"
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> if (dotIdx == -1) {</span></pre></td></tr>"
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> imports.clear();</span></pre></td></tr>"
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> currentTypeParams.clear();</span></pre></td></tr>"
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> processImport(ast);</span></pre></td></tr>"
"JavadocMethodCheck.java.html:<td class='covered'><pre><span class='survived'> while (iterator.hasNext()) {</span></pre></td></tr>"
"JavadocTagInfo.java.html:<td class='covered'><pre><span class='survived'> .collect(Collectors.toMap(JavadocTagInfo::getName, tagName -&#62; tagName)));</span></pre></td></tr>"
"JavadocTagInfo.java.html:<td class='covered'><pre><span class='survived'> .collect(Collectors.toMap(JavadocTagInfo::getText, tagText -&#62; tagText)));</span></pre></td></tr>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,6 @@ public class JavadocMethodCheck extends AbstractCheck {
/** Stack of maps for type params. */
private final Deque<Map<String, ClassInfo>> currentTypeParams = new ArrayDeque<>();

/**
* Imports details.
* @noinspection MismatchedQueryAndUpdateOfCollection
*/
private final Set<String> imports = new HashSet<>();

/** Name of current class. */
private String currentClassName;

Expand Down Expand Up @@ -361,7 +355,6 @@ public void setAllowMissingReturnTag(boolean flag) {
@Override
public final int[] getRequiredTokens() {
return new int[] {
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
Expand All @@ -376,7 +369,6 @@ public int[] getDefaultTokens() {
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.INTERFACE_DEF,
Expand All @@ -388,19 +380,13 @@ public int[] getAcceptableTokens() {

@Override
public void beginTree(DetailAST rootAST) {
imports.clear();
// add java.lang.* since it's always imported
imports.add("java.lang.*");
currentClassName = "";
currentTypeParams.clear();
}

@Override
public final void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.IMPORT) {
processImport(ast);
}
else if (ast.getType() == TokenTypes.CLASS_DEF
if (ast.getType() == TokenTypes.CLASS_DEF
|| ast.getType() == TokenTypes.INTERFACE_DEF
|| ast.getType() == TokenTypes.ENUM_DEF) {
processClass(ast);
Expand Down Expand Up @@ -1014,15 +1000,6 @@ private static boolean isClassNamesSame(String class1, String class2) {
return result;
}

/**
* Collects the details of imports.
* @param ast node containing the import details
*/
private void processImport(DetailAST ast) {
final FullIdent name = FullIdent.createFullIdentBelow(ast);
imports.add(name.getText());
}

/**
* Process type params (if any) for given class, enum or method.
* @param ast class, enum or method to process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void testGetAcceptableTokens() {

final int[] actual = javadocMethodCheck.getAcceptableTokens();
final int[] expected = {
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.INTERFACE_DEF,
Expand Down Expand Up @@ -477,7 +476,6 @@ public void testConstructor() throws Exception {
@Test
public void testGetRequiredTokens() {
final int[] expected = {
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
Expand Down

0 comments on commit f4d032d

Please sign in to comment.