Class AbstractAddonsCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.thomasjensen.checkstyle.addons.checks.AbstractAddonsCheck
-
- All Implemented Interfaces:
Configurable,Contextualizable
- Direct Known Subclasses:
AbstractMethodCallCheck,LostInstanceCheck,PropertyCatalogCheck,RegexpOnStringCheck
public abstract class AbstractAddonsCheck extends AbstractCheck
Base class of all Checkstyle Addons checks.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAddonsCheck()protectedAbstractAddonsCheck(String pMockfile)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidbeginTree(DetailAST pRootAst)voidfinishTree(DetailAST pRootAst)protected voidfinishTree(BinaryName pOuterClassName, DetailAST pRootAst)Called after a tree is fully processed.int[]getAcceptableTokens()protected CheckstyleApiFixergetApiFixer()protected DetailASTgetClassDeclarationPosition(BinaryName pBinaryName)protected BinaryNamegetCurrentBinaryName()Gets the binary name of the class currently being traversed on the AST.protected StringgetCurrentSimpleName()Gets the simple name of the current class, interface, annotation, or enum.int[]getDefaultTokens()protected StringgetMyPackage()abstract Set<Integer>getRelevantTokens()The tokens which this check is interested in.int[]getRequiredTokens()protected voidleaveKnownType(BinaryName pBinaryClassName, DetailAST pAst)Called after leaving a CLASS_DEF, INTERFACE_DEF, ANNOTATION_DEF, or ENUM_DEF token and the type's binary class name is known.voidleaveToken(DetailAST pAst)protected voidleaveToken(BinaryName pBinaryClassName, DetailAST pAst)Called after all the child nodes have been processed.protected voidvisitKnownType(BinaryName pBinaryClassName, DetailAST pAst)Called after visiting a CLASS_DEF, INTERFACE_DEF, ANNOTATION_DEF, or ENUM_DEF token and successfully determining the type's binary class name.voidvisitToken(DetailAST pAst)protected voidvisitToken(BinaryName pBinaryClassName, DetailAST pAst)Called to process a token.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, destroy, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, log, log, log, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Method Detail
-
getRelevantTokens
public abstract Set<Integer> getRelevantTokens()
The tokens which this check is interested in. Will be added to the tokens of the base class.- Returns:
- the relevant tokens
-
getRequiredTokens
public final int[] getRequiredTokens()
- Specified by:
getRequiredTokensin classAbstractCheck
-
getAcceptableTokens
public final int[] getAcceptableTokens()
- Specified by:
getAcceptableTokensin classAbstractCheck
-
getDefaultTokens
public final int[] getDefaultTokens()
- Specified by:
getDefaultTokensin classAbstractCheck
-
beginTree
public void beginTree(DetailAST pRootAst)
- Overrides:
beginTreein classAbstractCheck
-
finishTree
public final void finishTree(DetailAST pRootAst)
- Overrides:
finishTreein classAbstractCheck
-
finishTree
protected void finishTree(@Nonnull BinaryName pOuterClassName, @Nonnull DetailAST pRootAst)
Called after a tree is fully processed. Ideal place to report on information collected whilst processing a tree.- Parameters:
pOuterClassName- the fully qualified class name of the outer classpRootAst- the root of the tree
-
visitToken
protected void visitToken(@Nullable BinaryName pBinaryClassName, @Nonnull DetailAST pAst)
Called to process a token.- Parameters:
pBinaryClassName- the currently active binary class namepAst- the token to process
-
leaveToken
protected void leaveToken(@Nullable BinaryName pBinaryClassName, @Nonnull DetailAST pAst)
Called after all the child nodes have been processed.- Parameters:
pBinaryClassName- the currently active binary class namepAst- the token being completed
-
visitKnownType
protected void visitKnownType(@Nonnull BinaryName pBinaryClassName, @Nonnull DetailAST pAst)
Called after visiting a CLASS_DEF, INTERFACE_DEF, ANNOTATION_DEF, or ENUM_DEF token and successfully determining the type's binary class name. This is useful in a Java source file with nested inner classes. If the implementing check registers for any of the above tokens, the regular call tovisitToken(BinaryName, DetailAST)will be performed in addition to (after) this one.- Parameters:
pBinaryClassName- the binary class name of the visited typepAst- the token to process
-
leaveKnownType
protected void leaveKnownType(@Nonnull BinaryName pBinaryClassName, @Nonnull DetailAST pAst)
Called after leaving a CLASS_DEF, INTERFACE_DEF, ANNOTATION_DEF, or ENUM_DEF token and the type's binary class name is known. This is useful in a Java source file with nested inner classes. If the implementing check registers for any of the above tokens, the regular call toleaveToken(BinaryName, DetailAST)will be performed in addition to (before) this one.- Parameters:
pBinaryClassName- the binary class name of the visited typepAst- the token being completed
-
visitToken
public final void visitToken(DetailAST pAst)
- Overrides:
visitTokenin classAbstractCheck
-
getClassDeclarationPosition
@CheckForNull protected DetailAST getClassDeclarationPosition(@Nonnull BinaryName pBinaryName)
-
leaveToken
public final void leaveToken(DetailAST pAst)
- Overrides:
leaveTokenin classAbstractCheck
-
getCurrentBinaryName
@CheckForNull protected BinaryName getCurrentBinaryName()
Gets the binary name of the class currently being traversed on the AST. Normally, this is the single class in the .java file, but it could also be a (nested) named inner class. Whenever a new CLASS_DEF or similar token is visited, the result of this method would change.- Returns:
- current binary name, or
nullif no CLASS_DEF or similar token has been encountered yet (e.g. while we are still going through theimportstatements)
-
getCurrentSimpleName
@CheckForNull protected String getCurrentSimpleName()
Gets the simple name of the current class, interface, annotation, or enum.- Returns:
- the simple class name, or
nullif we are outside of a type definition
-
getMyPackage
protected String getMyPackage()
-
getApiFixer
@Nonnull protected CheckstyleApiFixer getApiFixer()
-
-