Class UnusedLocalVariableCheck.TypeDeclDesc
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck.TypeDeclDesc
- Enclosing class:
- UnusedLocalVariableCheck
Maintains information about the type declaration.
Any ast node of type
TokenTypes.CLASS_DEF
or TokenTypes.INTERFACE_DEF
or TokenTypes.ENUM_DEF
or TokenTypes.ANNOTATION_DEF
or TokenTypes.RECORD_DEF
is considered as a type declaration.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
Depth of nesting of type declaration.private final Deque<UnusedLocalVariableCheck.VariableDesc>
A stack of type declaration's instance and static variables.private final String
Complete type declaration name with package name and outer type declaration name.private final DetailAST
Type declaration ast node. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TypeDeclDesc
(String qualifiedName, int depth, DetailAST typeDeclAst) Create a new TypeDeclDesc instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInstOrClassVar
(UnusedLocalVariableCheck.VariableDesc variableDesc) Add an instance variable or class variable to the stack.int
getDepth()
Get the depth of type declaration.Get the complete type declaration name i.e. type declaration name with package name and outer type declaration name.Get the type declaration ast node.getUpdatedCopyOfVarStack
(DetailAST literalNewAst) Get the copy of variables in instanceAndClassVar stack with updated scope.
-
Field Details
-
qualifiedName
Complete type declaration name with package name and outer type declaration name. -
depth
Depth of nesting of type declaration. -
typeDeclAst
Type declaration ast node. -
instanceAndClassVarStack
A stack of type declaration's instance and static variables.
-
-
Constructor Details
-
TypeDeclDesc
Create a new TypeDeclDesc instance.- Parameters:
qualifiedName
- qualified namedepth
- depth of nestingtypeDeclAst
- type declaration ast node
-
-
Method Details
-
getQualifiedName
Get the complete type declaration name i.e. type declaration name with package name and outer type declaration name.- Returns:
- qualified class name
-
getDepth
Get the depth of type declaration.- Returns:
- the depth of nesting of type declaration
-
getTypeDeclAst
Get the type declaration ast node.- Returns:
- ast node of the type declaration
-
getUpdatedCopyOfVarStack
public Deque<UnusedLocalVariableCheck.VariableDesc> getUpdatedCopyOfVarStack(DetailAST literalNewAst) Get the copy of variables in instanceAndClassVar stack with updated scope.- Parameters:
literalNewAst
- ast node of typeTokenTypes.LITERAL_NEW
- Returns:
- copy of variables in instanceAndClassVar stack with updated scope.
-
addInstOrClassVar
Add an instance variable or class variable to the stack.- Parameters:
variableDesc
- variable to be added
-