public final class CheckUtil extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static java.util.regex.Pattern |
ALL_NEW_LINES
Compiled pattern for all system newlines.
|
private static int |
BASE_10
Decimal radix.
|
private static int |
BASE_16
Hex radix.
|
private static int |
BASE_2
Binary radix.
|
private static int |
BASE_8
Octal radix.
|
private static int |
GETTER_BODY_SIZE
Maximum nodes allowed in a body of getter.
|
private static java.util.regex.Pattern |
GETTER_PATTERN
Pattern matching names of getter methods.
|
private static int |
SETTER_BODY_SIZE
Maximum nodes allowed in a body of setter.
|
private static int |
SETTER_GETTER_MAX_CHILDREN
Maximum children allowed in setter/getter.
|
private static java.util.regex.Pattern |
SETTER_PATTERN
Pattern matching names of setter methods.
|
private static java.util.regex.Pattern |
UNDERSCORE_PATTERN
Pattern matching underscore characters ('_').
|
| Modifier | Constructor and Description |
|---|---|
private |
CheckUtil()
Prevent instances.
|
| Modifier and Type | Method and Description |
|---|---|
static AccessModifierOption |
getAccessModifierFromModifiersToken(DetailAST ast)
Returns the access modifier of the method/constructor at the specified AST.
|
private static AccessModifierOption |
getAccessModifierFromModifiersTokenDirectly(DetailAST modifiersToken)
Returns
AccessModifierOption based on the information about access modifier
taken from the given token of type TokenTypes.MODIFIERS. |
static DetailAST |
getFirstNode(DetailAST node)
Finds sub-node for given node minimal (line, column) pair.
|
private static int |
getSmallestIndent(java.util.List<java.lang.String> lines)
Helper method for stripIndentAndInitialNewLineFromTextBlock, to determine the smallest
indent in a text block string literal.
|
static AccessModifierOption |
getSurroundingAccessModifier(DetailAST node)
Returns the access modifier of the surrounding "block".
|
static java.util.List<java.lang.String> |
getTypeParameterNames(DetailAST node)
Retrieves the names of the type parameters to the node.
|
static java.util.List<DetailAST> |
getTypeParameters(DetailAST node)
Retrieves the type parameters to the node.
|
static boolean |
isBeforeInSource(DetailAST ast1,
DetailAST ast2)
Retrieves whether ast1 is located before ast2.
|
private static boolean |
isElse(DetailAST ast)
Returns whether a token represents an ELSE.
|
static boolean |
isElseIf(DetailAST ast)
Returns whether a token represents an ELSE as part of an ELSE / IF set.
|
private static boolean |
isElseWithCurlyBraces(DetailAST ast)
Returns whether a token represents an SLIST as part of an ELSE
statement.
|
static boolean |
isEqualsMethod(DetailAST ast)
Tests whether a method definition AST defines an equals covariant.
|
static boolean |
isGetterMethod(DetailAST ast)
Returns whether an AST represents a getter method.
|
static boolean |
isNonVoidMethod(DetailAST methodDefAst)
Checks whether a method is a not void one.
|
static boolean |
isReceiverParameter(DetailAST parameterDefAst)
Checks whether a parameter is a receiver.
|
static boolean |
isSetterMethod(DetailAST ast)
Returns whether an AST represents a setter method.
|
private static int |
lastIndexOfNonWhitespace(java.lang.String line)
Helper method to find the index of the last non-whitespace character in a string.
|
static java.util.Set<java.lang.String> |
parseClassNames(java.lang.String... classNames)
Create set of class names and short class names.
|
static double |
parseDouble(java.lang.String text,
int type)
Returns the value represented by the specified string of the specified
type.
|
private static double |
parseNumber(java.lang.String text,
int radix,
int type)
Parses the string argument as an integer or a long in the radix specified by
the second argument.
|
static java.lang.String |
stripIndentAndInitialNewLineFromTextBlock(java.lang.String textBlockContent)
Strip initial newline and preceding whitespace on each line from text block content.
|
private static java.lang.String |
stripIndentAndTrailingWhitespaceFromLine(java.lang.String line,
int indent)
Helper method for stripIndentAndInitialNewLineFromTextBlock, strips correct indent
from string, and trailing whitespace, or returns empty string if no text.
|
private static final int BASE_2
private static final int BASE_8
private static final int BASE_10
private static final int BASE_16
private static final int SETTER_GETTER_MAX_CHILDREN
private static final int SETTER_BODY_SIZE
private static final int GETTER_BODY_SIZE
private static final java.util.regex.Pattern UNDERSCORE_PATTERN
private static final java.util.regex.Pattern SETTER_PATTERN
private static final java.util.regex.Pattern GETTER_PATTERN
private static final java.util.regex.Pattern ALL_NEW_LINES
private CheckUtil()
public static boolean isEqualsMethod(DetailAST ast)
ast - the method definition AST to test.
Precondition: ast is a TokenTypes.METHOD_DEF node.public static boolean isElseIf(DetailAST ast)
ast - the token to checkprivate static boolean isElse(DetailAST ast)
ast - the token to checkprivate static boolean isElseWithCurlyBraces(DetailAST ast)
ast - the token to checkpublic static double parseDouble(java.lang.String text, int type)
text - the string to be parsed.type - the token type of the text. Should be a constant of
TokenTypes.private static double parseNumber(java.lang.String text, int radix, int type)
text - the String containing the integer representation to be
parsed. Precondition: text contains a parsable int.radix - the radix to be used while parsing text.type - the token type of the text. Should be a constant of
TokenTypes.public static DetailAST getFirstNode(DetailAST node)
node - the root of tree for search.public static boolean isBeforeInSource(DetailAST ast1, DetailAST ast2)
ast1 - the first node.ast2 - the second node.public static java.util.List<java.lang.String> getTypeParameterNames(DetailAST node)
node - the parameterized AST nodepublic static java.util.List<DetailAST> getTypeParameters(DetailAST node)
node - the parameterized AST nodepublic static boolean isSetterMethod(DetailAST ast)
ast - the AST to check withpublic static boolean isGetterMethod(DetailAST ast)
ast - the AST to check withpublic static boolean isNonVoidMethod(DetailAST methodDefAst)
methodDefAst - the method node.public static boolean isReceiverParameter(DetailAST parameterDefAst)
parameterDefAst - the parameter node.public static AccessModifierOption getAccessModifierFromModifiersToken(DetailAST ast)
ast - the token of the method/constructor.private static AccessModifierOption getAccessModifierFromModifiersTokenDirectly(DetailAST modifiersToken)
AccessModifierOption based on the information about access modifier
taken from the given token of type TokenTypes.MODIFIERS.modifiersToken - token of type TokenTypes.MODIFIERS.AccessModifierOption.java.lang.IllegalArgumentException - when expected non-null modifiersToken with type 'MODIFIERS'public static AccessModifierOption getSurroundingAccessModifier(DetailAST node)
node - the node to return the access modifier forpublic static java.util.Set<java.lang.String> parseClassNames(java.lang.String... classNames)
classNames - array of class names.public static java.lang.String stripIndentAndInitialNewLineFromTextBlock(java.lang.String textBlockContent)
textBlockContent - the actual content of the text block.private static java.lang.String stripIndentAndTrailingWhitespaceFromLine(java.lang.String line, int indent)
line - the string to strip indent and trailing whitespace fromindent - the amount of indent to removeprivate static int getSmallestIndent(java.util.List<java.lang.String> lines)
lines - list of actual text block content, split by line.private static int lastIndexOfNonWhitespace(java.lang.String line)
line - the string to find the last index of a non-whitespace character for.Copyright © 2001-2022. All Rights Reserved.