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 booleanIs an instance variable or a class variable.private final StringThe name of the variable.private final DetailASTThe scope of variable is determined by the ast of typeTokenTypes.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich is enclosing the variable.private final DetailASTAst of typeTokenTypes.TYPE.private booleanIs the variable used. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateVariableDesc(String name) Create a new VariableDesc instance.privateVariableDesc(String name, DetailAST scope) Create a new VariableDesc instance.privateVariableDesc(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.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich is enclosing the variable i.e. its scope.Get the associated ast node of typeTokenTypes.TYPE.booleanIs an instance variable or a class variable.booleanisUsed()Is the variable used or not.voidRegister the variable as an instance variable or class variable.voidRegister 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.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich 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.TYPEscope- ast of typeTokenTypes.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich 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.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich 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.SLISTorTokenTypes.LITERAL_FORorTokenTypes.OBJBLOCKwhich 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
-