public class AnnotationOnSameLineCheck extends AbstractCheck
Checks 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, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final java.lang.String MSG_KEY_ANNOTATION_ON_SAME_LINE
public AnnotationOnSameLineCheck()
public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processCopyright © 2001-2020. All Rights Reserved.