Package io.debezium.checkstyle
Class UnusedImports
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck
-
- io.debezium.checkstyle.UnusedImports
-
- All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable,com.puppycrawl.tools.checkstyle.api.Contextualizable
public class UnusedImports extends com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheckThis is a specialization of theUnusedImportsCheckthat fixes a couple of problems, including correctly processing@linkexpressions that are not properly terminated on the same line, correctly processing JavaDoc@paramlines, and correctly processing method parameters contained with@linkexpressions.Unfortunately, the base class is not easily overwritten, and thus a fair amount of the logic has to be incorporated here.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancollectprivate static String[]DEBUG_CLASSNAMESprivate static Set<String>DEBUG_CLASSNAMES_SETprivate Set<com.puppycrawl.tools.checkstyle.api.FullIdent>importsprivate static PatternLINK_VALUE_IN_TEXT_PATTERNA regular expression for finding the first word within a JavaDoc "@link" text.private static PatternLINK_VALUE_PATTERNA regular expression for finding the first classname referenced in a "@link" reference.private static PatternPARTS_OF_CLASS_OR_REFERENCE_PATTERNA regular expression for finding the class name (group 1) and the method parameters (group 2) within a JavaDoc "@link" reference.private booleanprintprivate booleanprocessJavaDocprivate Set<String>referenced
-
Constructor Summary
Constructors Constructor Description UnusedImports()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginTree(com.puppycrawl.tools.checkstyle.api.DetailAST aRootAST)voidfinishTree(com.puppycrawl.tools.checkstyle.api.DetailAST aRootAST)private voidprint(Object... messages)protected voidprocessClassOrMethodReference(String text)protected voidprocessIdent(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)Collects references made by IDENT.private voidprocessImport(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)Collects the details of imports.protected voidprocessJavaDocLinkParameters(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)protected voidprocessJavaDocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag tag)private voidprocessStaticImport(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)Collects the details of static imports.voidsetProcessJavadoc(boolean aValue)voidvisitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)-
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck
getAcceptableTokens, getDefaultTokens, getRequiredTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearMessages, destroy, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
-
-
-
Field Detail
-
DEBUG_CLASSNAMES
private static final String[] DEBUG_CLASSNAMES
-
LINK_VALUE_IN_TEXT_PATTERN
private static final Pattern LINK_VALUE_IN_TEXT_PATTERN
A regular expression for finding the first word within a JavaDoc "@link" text.(.*?)(?:\s+|#|\$)(.*)
-
PARTS_OF_CLASS_OR_REFERENCE_PATTERN
private static final Pattern PARTS_OF_CLASS_OR_REFERENCE_PATTERN
A regular expression for finding the class name (group 1) and the method parameters (group 2) within a JavaDoc "@link" reference.([\w.]+)(?:\#?\w+)?(?:\(([^\)]+)\))?.*
-
LINK_VALUE_PATTERN
private static final Pattern LINK_VALUE_PATTERN
A regular expression for finding the first classname referenced in a "@link" reference.\{\@link\s+([^}]*)
-
collect
private boolean collect
-
processJavaDoc
private boolean processJavaDoc
-
imports
private final Set<com.puppycrawl.tools.checkstyle.api.FullIdent> imports
-
print
private boolean print
-
-
Method Detail
-
setProcessJavadoc
public void setProcessJavadoc(boolean aValue)
- Overrides:
setProcessJavadocin classcom.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck
-
beginTree
public void beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST aRootAST)
- Overrides:
beginTreein classcom.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck
-
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Overrides:
visitTokenin classcom.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck
-
processIdent
protected void processIdent(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Collects references made by IDENT.- Parameters:
aAST- the IDENT node to processstuff
-
processJavaDocLinkParameters
protected void processJavaDocLinkParameters(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
-
processJavaDocTag
protected void processJavaDocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag tag)
-
processClassOrMethodReference
protected void processClassOrMethodReference(String text)
-
processImport
private void processImport(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Collects the details of imports.- Parameters:
aAST- node containing the import details
-
processStaticImport
private void processStaticImport(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Collects the details of static imports.- Parameters:
aAST- node containing the static import details
-
finishTree
public void finishTree(com.puppycrawl.tools.checkstyle.api.DetailAST aRootAST)
- Overrides:
finishTreein classcom.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck
-
print
private void print(Object... messages)
-
-