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 boolean
isCheckActive()
Determines if the check is configured to do anything at all.protected boolean
isRelevantCall(String pQualifier, String pMethodName)
Filter method which determines if the given method call is considered relevant.void
setArgumentPosition(int pArgumentPosition)
void
setLocation(String pLocation)
void
setMethodCalls(String... pMethodCalls)
Setter.void
setVariableNames(String... pVariableNames)
Setter.protected void
visitMethodCall(String pMethodName, DetailAST pMethodCallAst)
Visitor method called when a relevant method call is encountered.protected void
visitToken(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:AbstractAddonsCheck
The tokens which this check is interested in. Will be added to the tokens of the base class.- Overrides:
getRelevantTokens
in classAbstractMethodCallCheck
- Returns:
- the relevant tokens
-
isCheckActive
protected boolean isCheckActive()
Description copied from class:AbstractMethodCallCheck
Determines if the check is configured to do anything at all.- Specified by:
isCheckActive
in classAbstractMethodCallCheck
- Returns:
true
if processing should be performed
-
isRelevantCall
protected boolean isRelevantCall(@Nullable String pQualifier, @Nonnull String pMethodName)
Description copied from class:AbstractMethodCallCheck
Filter method which determines if the given method call is considered relevant.- Specified by:
isRelevantCall
in 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:AbstractMethodCallCheck
Visitor method called when a relevant method call is encountered. This method is called in addition to the other visitor methods.- Specified by:
visitMethodCall
in 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:AbstractAddonsCheck
Called to process a token.- Overrides:
visitToken
in 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)
-
-