Class UnusedLocalVariableCheck.VariableDesc
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck.VariableDesc
-
- Enclosing class:
- UnusedLocalVariableCheck
private static final class UnusedLocalVariableCheck.VariableDesc extends Object
Maintains information about the variable.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
instVarOrClassVar
Is an instance variable or a class variable.private String
name
The name of the variable.private DetailAST
scope
The scope of variable is determined by the ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable.private DetailAST
typeAst
Ast of typeTokenTypes.TYPE
.private boolean
used
Is the variable used.
-
Constructor Summary
Constructors Modifier Constructor Description private
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
Get the name of variable.DetailAST
getScope()
Get ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable i.e. its scope.DetailAST
getTypeAst()
Get the associated ast node of typeTokenTypes.TYPE
.boolean
isInstVarOrClassVar()
Is an instance variable or a class variable.boolean
isUsed()
Is the variable used or not.void
registerAsInstOrClassVar()
Register the variable as an instance variable or class variable.void
registerAsUsed()
Register the variable as used.
-
-
-
Field Detail
-
typeAst
private final DetailAST typeAst
Ast of typeTokenTypes.TYPE
.
-
scope
private final DetailAST scope
The scope of variable is determined by the ast of typeTokenTypes.SLIST
orTokenTypes.LITERAL_FOR
orTokenTypes.OBJBLOCK
which is enclosing the variable.
-
instVarOrClassVar
private boolean instVarOrClassVar
Is an instance variable or a class variable.
-
used
private boolean used
Is the variable used.
-
-
Constructor Detail
-
VariableDesc
private VariableDesc(String name, DetailAST typeAst, DetailAST scope)
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
private VariableDesc(String name)
Create a new VariableDesc instance.- Parameters:
name
- name of the variable
-
VariableDesc
private VariableDesc(String name, DetailAST scope)
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 Detail
-
getTypeAst
public DetailAST getTypeAst()
Get the associated ast node of typeTokenTypes.TYPE
.- Returns:
- the associated ast node of type
TokenTypes.TYPE
-
getScope
public DetailAST 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
public void registerAsUsed()
Register the variable as used.
-
registerAsInstOrClassVar
public void registerAsInstOrClassVar()
Register the variable as an instance variable or class variable.
-
isUsed
public boolean isUsed()
Is the variable used or not.- Returns:
- true if variable is used
-
isInstVarOrClassVar
public boolean isInstVarOrClassVar()
Is an instance variable or a class variable.- Returns:
- true if is an instance variable or a class variable
-
-