public class UncommentedMainCheck extends AbstractCheck
<module name="UncommentedMain"/>
| Modifier and Type | Field and Description |
|---|---|
private int |
classDepth
Class definition depth.
|
private java.lang.String |
currentClass
Current class name.
|
private java.util.regex.Pattern |
excludedClasses
Compiled regexp to exclude classes from check.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
private FullIdent |
packageName
Current package.
|
| Constructor and Description |
|---|
UncommentedMainCheck() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
private boolean |
checkClassName()
Checks that current class is not excluded.
|
private static boolean |
checkModifiers(DetailAST method)
Checks that method has final and static modifiers.
|
private static boolean |
checkName(DetailAST method)
Checks that method name is @quot;main@quot;.
|
private static boolean |
checkParams(DetailAST method)
Checks that method has only
String[] or only String... param. |
private static boolean |
checkType(DetailAST method)
Checks that return type is
void. |
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.
|
private static boolean |
isStringType(DetailAST typeAst)
Whether the type is java.lang.String.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
setExcludedClasses(java.util.regex.Pattern excludedClasses)
Set the excluded classes pattern.
|
private void |
visitClassDef(DetailAST classDef)
If not inner class then change current class name.
|
private void |
visitMethodDef(DetailAST method)
Checks method definition if this is
public static void main(String[]). |
private void |
visitPackageDef(DetailAST packageDef)
Sets current package.
|
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, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverityconfigure, contextualize, finishLocalSetup, getConfiguration, setupChildpublic static final java.lang.String MSG_KEY
private java.util.regex.Pattern excludedClasses
private java.lang.String currentClass
private FullIdent packageName
private int classDepth
public void setExcludedClasses(java.util.regex.Pattern excludedClasses)
excludedClasses - a patternpublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void beginTree(DetailAST rootAST)
AbstractCheckbeginTree in class AbstractCheckrootAST - the root of the treepublic void leaveToken(DetailAST ast)
AbstractCheckleaveToken in class AbstractCheckast - the token leavingpublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processprivate void visitPackageDef(DetailAST packageDef)
packageDef - node for package definitionprivate void visitClassDef(DetailAST classDef)
classDef - node for class definitionprivate void visitMethodDef(DetailAST method)
public static void main(String[]).method - method definition nodeprivate boolean checkClassName()
private static boolean checkName(DetailAST method)
method - the METHOD_DEF nodeprivate static boolean checkModifiers(DetailAST method)
method - the METHOD_DEF nodeprivate static boolean checkType(DetailAST method)
void.method - the METHOD_DEF nodeprivate static boolean checkParams(DetailAST method)
String[] or only String... param.method - the METHOD_DEF nodeprivate static boolean isStringType(DetailAST typeAst)
typeAst - the type to check.