Class FullIdent
java.lang.Object
com.puppycrawl.tools.checkstyle.api.FullIdent
Represents a full identifier, including dots, with associated
position information.
Identifiers such as java.util.HashMap are spread across
multiple AST nodes in the syntax tree (three IDENT nodes, two DOT nodes).
A FullIdent represents the whole String (excluding any intermediate
whitespace), which is often easier to work with in Checks.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAppend the specified token and also recalibrate the first line and column.private voidAppend the specified text.private static voidappendBrackets(FullIdent full, DetailAST ast) Appends the brackets of an array type to aFullIdent.private static intappendToFull(FullIdent full, DetailAST ast, int dotCounter, boolean bracketsExist, boolean isArrayTypeDeclarationStart) Populates the FullIdent node.static FullIdentcreateFullIdent(DetailAST ast) Creates a new FullIdent starting from the specified node.static FullIdentCreates a new FullIdent starting from the child of the specified node.private static voidextractFullIdent(FullIdent full, DetailAST ast) Extracts a FullIdent.intGets the column number.Gets the topmost leftmost DetailAST for this FullIdent.intGets the line number.getText()Gets the text.private static booleanisArrayTypeDeclaration(DetailAST arrayDeclarator) Checks an `ARRAY_DECLARATOR` ast to verify that it is not an array initialization, i.e.private static voidpushToIdentStack(Deque<DetailAST> stack, DetailAST ast) Pushes to stack if ast is not null.toString()
-
Field Details
-
elements
-
detailAst
The topmost and leftmost AST of the full identifier.
-
-
Constructor Details
-
FullIdent
private FullIdent()Hide default constructor.
-
-
Method Details
-
createFullIdentBelow
-
createFullIdent
-
extractFullIdent
-
appendToFull
private static int appendToFull(FullIdent full, DetailAST ast, int dotCounter, boolean bracketsExist, boolean isArrayTypeDeclarationStart) Populates the FullIdent node.- Parameters:
full- the FullIdent to add toast- the nodedotCounter- no of dotsbracketsExist- yes if trueisArrayTypeDeclarationStart- true if array type declaration start- Returns:
- updated value of dotCounter
-
pushToIdentStack
-
isArrayTypeDeclaration
Checks an `ARRAY_DECLARATOR` ast to verify that it is not an array initialization, i.e. 'new int [2][2]'. We do this by making sure that no 'EXPR' token exists in this branch.- Parameters:
arrayDeclarator- the first ARRAY_DECLARATOR token in the ast- Returns:
- true if ast is an array type declaration
-
appendBrackets
-
getText
-
getDetailAst
Gets the topmost leftmost DetailAST for this FullIdent.- Returns:
- the topmost leftmost ast
-
getLineNo
public int getLineNo()Gets the line number.- Returns:
- the line number
-
getColumnNo
public int getColumnNo()Gets the column number.- Returns:
- the column number
-
toString
-
append
-
append
Append the specified token and also recalibrate the first line and column.- Parameters:
ast- the token to append
-