public class AnnotationOnSameLineCheck extends AbstractCheck
The check does verifying that annotations are located on the same line with their targets. Verifying with this check is not good practice, but it is using by some style guides.
tokens
- tokens to check
Default value is:
CLASS_DEF,
INTERFACE_DEF,
ENUM_DEF,
METHOD_DEF,
CTOR_DEF,
VARIABLE_DEF.
To configure the check:
<module name="AnnotationOnSameLine"/>
Example to allow annotations on the same line
@Override public int toString() { ... } // no violations @Before @Override public void set() { ... } // no violation
Example to disallow annotations on previous line
@SuppressWarnings("deprecation") // violation @Override // violation public int foo() { ... }
AutomaticBean.OutputStreamOptions
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MSG_KEY_ANNOTATION_ON_SAME_LINE
A key is pointing to the warning message text in "messages.properties" file.
|
Constructor and Description |
---|
AnnotationOnSameLineCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
public static final java.lang.String MSG_KEY_ANNOTATION_ON_SAME_LINE
public AnnotationOnSameLineCheck()
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processCopyright © 2001-2019. All Rights Reserved.