Class UnusedLocalVariableCheck.VariableDesc
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck.VariableDesc
- Enclosing class:
- UnusedLocalVariableCheck
Maintains information about the variable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Is an instance variable or a class variable.private final String
The name of the variable.private final DetailAST
The scope of variable is determined by the ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable.private final DetailAST
Ast of typeTokenTypes.TYPE
.private boolean
Is the variable used. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
VariableDesc
(String name) Create a new VariableDesc instance.private
VariableDesc
(String name, DetailAST scope) Create a new VariableDesc instance.private
VariableDesc
(String name, DetailAST typeAst, DetailAST scope) Create a new VariableDesc instance. -
Method Summary
Modifier and TypeMethodDescriptiongetName()
Get the name of variable.getScope()
Get ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable i.e. its scope.Get the associated ast node of typeTokenTypes.TYPE
.boolean
Is an instance variable or a class variable.boolean
isUsed()
Is the variable used or not.void
Register the variable as an instance variable or class variable.void
Register the variable as used.
-
Field Details
-
name
The name of the variable. -
typeAst
Ast of typeTokenTypes.TYPE
. -
scope
The scope of variable is determined by the ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable. -
instVarOrClassVar
Is an instance variable or a class variable. -
used
Is the variable used.
-
-
Constructor Details
-
VariableDesc
Create a new VariableDesc instance.- Parameters:
name
- name of the variabletypeAst
- ast of typeTokenTypes.TYPE
scope
- ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable
-
VariableDesc
Create a new VariableDesc instance.- Parameters:
name
- name of the variable
-
VariableDesc
Create a new VariableDesc instance.- Parameters:
name
- name of the variablescope
- ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable
-
-
Method Details
-
getName
Get the name of variable.- Returns:
- name of variable
-
getTypeAst
Get the associated ast node of typeTokenTypes.TYPE
.- Returns:
- the associated ast node of type
TokenTypes.TYPE
-
getScope
Get ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable i.e. its scope.- Returns:
- the scope associated with the variable
-
registerAsUsed
Register the variable as used. -
registerAsInstOrClassVar
Register the variable as an instance variable or class variable. -
isUsed
Is the variable used or not.- Returns:
- true if variable is used
-
isInstVarOrClassVar
Is an instance variable or a class variable.- Returns:
- true if is an instance variable or a class variable
-