Class LocationReferenceCheck
- 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
-
- com.thomasjensen.checkstyle.addons.checks.AbstractMethodCallCheck
-
- com.thomasjensen.checkstyle.addons.checks.misc.LocationReferenceCheck
-
- All Implemented Interfaces:
Configurable,Contextualizable
public class LocationReferenceCheck extends AbstractMethodCallCheck
This check compares specified method arguments to the names of the current method or class.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description LocationReferenceCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Integer>getRelevantTokens()The tokens which this check is interested in.protected booleanisCheckActive()Determines if the check is configured to do anything at all.protected booleanisRelevantCall(String pQualifier, String pMethodName)Filter method which determines if the given method call is considered relevant.voidsetArgumentPosition(int pArgumentPosition)voidsetLocation(String pLocation)voidsetMethodCalls(String... pMethodCalls)Setter.voidsetVariableNames(String... pVariableNames)Setter.protected voidvisitMethodCall(String pMethodName, DetailAST pMethodCallAst)Visitor method called when a relevant method call is encountered.protected voidvisitToken(BinaryName pBinaryClassName, DetailAST pAst)Called to process a token.-
Methods inherited from class com.thomasjensen.checkstyle.addons.checks.AbstractMethodCallCheck
beginTree, getCurrentMethodName, leaveToken
-
Methods inherited from class com.thomasjensen.checkstyle.addons.checks.AbstractAddonsCheck
finishTree, finishTree, getAcceptableTokens, getApiFixer, getClassDeclarationPosition, getCurrentBinaryName, getCurrentSimpleName, getDefaultTokens, getMyPackage, getRequiredTokens, leaveKnownType, leaveToken, visitKnownType, visitToken
-
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 Set<Integer> getRelevantTokens()
Description copied from class:AbstractAddonsCheckThe tokens which this check is interested in. Will be added to the tokens of the base class.- Overrides:
getRelevantTokensin classAbstractMethodCallCheck- Returns:
- the relevant tokens
-
isCheckActive
protected boolean isCheckActive()
Description copied from class:AbstractMethodCallCheckDetermines if the check is configured to do anything at all.- Specified by:
isCheckActivein classAbstractMethodCallCheck- Returns:
trueif processing should be performed
-
isRelevantCall
protected boolean isRelevantCall(@Nullable String pQualifier, @Nonnull String pMethodName)
Description copied from class:AbstractMethodCallCheckFilter method which determines if the given method call is considered relevant.- Specified by:
isRelevantCallin classAbstractMethodCallCheck- Parameters:
pQualifier- the qualifier of the method call (for a call likeFoo.Bar.call(), the qualifier isFoo.Bar)pMethodName- the simple name of the called method- Returns:
- indication of whether the call is relevant (
true) or not (false)
-
visitMethodCall
protected void visitMethodCall(@Nonnull String pMethodName, @Nonnull DetailAST pMethodCallAst)
Description copied from class:AbstractMethodCallCheckVisitor method called when a relevant method call is encountered. This method is called in addition to the other visitor methods.- Specified by:
visitMethodCallin classAbstractMethodCallCheck- Parameters:
pMethodName- the simple name of the called methodpMethodCallAst- AST of the call, useful for logging issues ( this is a METHOD_DEF, CTOR_CALL, or a SUPER_CTOR_CALL token)
-
visitToken
protected void visitToken(@Nullable BinaryName pBinaryClassName, @Nonnull DetailAST pAst)
Description copied from class:AbstractAddonsCheckCalled to process a token.- Overrides:
visitTokenin classAbstractMethodCallCheck- Parameters:
pBinaryClassName- the currently active binary class namepAst- the token to process
-
setMethodCalls
public void setMethodCalls(String... pMethodCalls)
Setter.- Parameters:
pMethodCalls- list of qualified method calls to cover
-
setVariableNames
public void setVariableNames(String... pVariableNames)
Setter.- Parameters:
pVariableNames- list of variable names to cover
-
setLocation
public void setLocation(String pLocation)
-
setArgumentPosition
public void setArgumentPosition(int pArgumentPosition)
-
-