public abstract class AbstractSuperCheck extends AbstractCheck
Abstract class for checking that an overriding method with no parameters invokes the super method.
Modifier and Type | Class and Description |
---|---|
private static class |
AbstractSuperCheck.MethodNode
Stack node for a method definition and a record of
whether the method has a call to the super method.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Deque<AbstractSuperCheck.MethodNode> |
methodStack
Stack of methods.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
AbstractSuperCheck() |
Modifier and Type | Method and Description |
---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
protected abstract java.lang.String |
getMethodName()
Returns the name of the overriding method.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
private static boolean |
hasArguments(DetailAST methodCallDotAst)
Does method have any arguments.
|
private boolean |
isOverridingMethod(DetailAST ast)
Determines whether an AST is a method definition for this check,
with 0 parameters.
|
private boolean |
isSameNameMethod(DetailAST ast)
Is same name of method.
|
private boolean |
isSuperCall(DetailAST literalSuperAst)
Determines whether a 'super' literal is a call to the super method
for this check.
|
private boolean |
isSuperCallInOverridingMethod(DetailAST ast)
Determines whether a super call in overriding method.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final java.lang.String MSG_KEY
private final java.util.Deque<AbstractSuperCheck.MethodNode> methodStack
protected abstract java.lang.String getMethodName()
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void beginTree(DetailAST rootAST)
AbstractCheck
beginTree
in class AbstractCheck
rootAST
- the root of the treepublic void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processprivate boolean isSuperCall(DetailAST literalSuperAst)
literalSuperAst
- the AST node of a 'super' literal.private boolean isSuperCallInOverridingMethod(DetailAST ast)
ast
- The AST node of a 'dot operator' in 'super' call.private static boolean hasArguments(DetailAST methodCallDotAst)
methodCallDotAst
- DOT DetailASTprivate boolean isSameNameMethod(DetailAST ast)
ast
- method ASTpublic void leaveToken(DetailAST ast)
AbstractCheck
leaveToken
in class AbstractCheck
ast
- the token leavingprivate boolean isOverridingMethod(DetailAST ast)
ast
- the method definition AST.