java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck
com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck
- All Implemented Interfaces:
- com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable
- public class LeftCurlyCheck
- extends com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck
Checks the placement of left curly braces on types, methods and other the
other blocks:
LITERAL_CATCH 55 , LITERAL_DO 55 , LITERAL_ELSE 55 , LITERAL_FINALLY 55 , LITERAL_FOR 55 , LITERAL_IF 55 , LITERAL_SWITCH 55 , LITERAL_SYNCHRONIZED 55 , LITERAL_TRY 55 , LITERAL_WHILE 55 .
The policy to verify is specified using the LeftCurlyOption class and
defaults to LeftCurlyOption.EOL 55 . Policies LeftCurlyOption.EOL 55
and LeftCurlyOption.NLOW 55 take into account property maxLineLength.
The default value for maxLineLength is 80.
An example of how to configure the check is:
<module name="LeftCurly"/>
An example of how to configure the check with policy
LeftCurlyOption.NLOW 55 and maxLineLength 120 is:
<module name="LeftCurly">
<property name="option"
value="nlow"/> <property name="maxLineLength" value="120"/> <
/module>
- Version:
- 1.0
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check |
|
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
|
|
Constructor Summary |
LeftCurlyCheck()
Creates a default instance and sets the policy to EOL. |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check |
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_MAX_LINE_LENGTH
private static final int DEFAULT_MAX_LINE_LENGTH
- default maximum line length
- See Also:
- Constant Field Values
mMaxLineLength
private int mMaxLineLength
- TODO: replace this ugly hack
LeftCurlyCheck
public LeftCurlyCheck()
- Creates a default instance and sets the policy to EOL.
setMaxLineLength
public void setMaxLineLength(int aMaxLineLength)
- Sets the maximum line length used in calculating the placement of the
left curly brace.
getDefaultTokens
public int[] getDefaultTokens()
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- Returns the default token a check is interested in. Only used if the
configuration for a check does not define the tokens.
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- Called to process a token.
verifyBrace
private void verifyBrace(com.puppycrawl.tools.checkstyle.api.DetailAST aBrace,
com.puppycrawl.tools.checkstyle.api.DetailAST aStartToken)
- Verifies that a specified left curly brace is placed correctly
according to policy.