Class UnusedLocalVariableCheck.VariableDesc
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck.VariableDesc
-
- Enclosing class:
- UnusedLocalVariableCheck
private static final class UnusedLocalVariableCheck.VariableDesc extends java.lang.Object
Maintains information about the variable.
-
-
Field Summary
Fields Modifier and Type Field Description private booleaninstVarOrClassVarIs an instance variable or a class variable.private java.lang.StringnameThe name of the variable.private DetailASTscopeThe scope of variable is determined by the ast of typeTokenTypes.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich is enclosing the variable.private DetailASTtypeAstAst of typeTokenTypes.TYPE.private booleanusedIs the variable used.
-
Constructor Summary
Constructors Constructor Description VariableDesc(java.lang.String name, DetailAST typeAst, DetailAST scope)Create a new VariableDesc instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()Get the name of variable.DetailASTgetScope()Get ast of typeTokenTypes.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich is enclosing the variable i.e.DetailASTgetTypeAst()Get the associated ast node of typeTokenTypes.TYPE.booleanisInstVarOrClassVar()Is an instance variable or a class variable.booleanisUsed()Is the variable used or not.voidregisterAsInstOrClassVar()Register the variable as an instance variable or class variable.voidregisterAsUsed()Register the variable as used.
-
-
-
Field Detail
-
name
private final java.lang.String name
The name of the variable.
-
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.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich 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
VariableDesc(java.lang.String name, DetailAST typeAst, DetailAST scope)
Create a new VariableDesc instance.- Parameters:
name- name of the variabletypeAst- ast of typeTokenTypes.TYPEscope- ast of typeTokenTypes.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich is enclosing the variable
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of variable.- Returns:
- name of variable
-
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.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich 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
-
-