Class RequireThisCheck.AbstractFrame
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.AbstractFrame
-
- Direct Known Subclasses:
RequireThisCheck.BlockFrame,RequireThisCheck.CatchFrame,RequireThisCheck.ClassFrame,RequireThisCheck.ConstructorFrame,RequireThisCheck.ForFrame,RequireThisCheck.MethodFrame
- Enclosing class:
- RequireThisCheck
private abstract static class RequireThisCheck.AbstractFrame extends java.lang.Object
A declaration frame.
-
-
Field Summary
Fields Modifier and Type Field Description private DetailASTframeNameIdentName identifier token.private RequireThisCheck.AbstractFrameparentParent frame.private java.util.Set<DetailAST>varIdentsSet of name of variables declared in this frame.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFrame(RequireThisCheck.AbstractFrame parent, DetailAST ident)Constructor -- invocable only via super() from subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidaddIdent(DetailAST identToAdd)Add a name to the frame.protected booleancontainsFieldOrVariable(DetailAST nameToFind)Check whether the frame contains a field or a variable with the given name.protected booleancontainsFieldOrVariableDef(java.util.Set<DetailAST> set, DetailAST ident)Whether the set contains a declaration with the text of the specified IDENT ast and it is declared in a proper position.protected java.lang.StringgetFrameName()Returns the name identifier text.DetailASTgetFrameNameIdent()Returns the name identifier token.protected RequireThisCheck.AbstractFramegetIfContains(DetailAST nameToFind, boolean lookForMethod)Check whether the frame contains a given name.protected RequireThisCheck.AbstractFramegetParent()Returns the parent frame.protected abstract RequireThisCheck.FrameTypegetType()Get the type of the frame.protected booleanisProperDefinition(DetailAST ident, DetailAST ast)Whether the definition is correspondent to the IDENT.
-
-
-
Field Detail
-
varIdents
private final java.util.Set<DetailAST> varIdents
Set of name of variables declared in this frame.
-
parent
private final RequireThisCheck.AbstractFrame parent
Parent frame.
-
frameNameIdent
private final DetailAST frameNameIdent
Name identifier token.
-
-
Constructor Detail
-
AbstractFrame
protected AbstractFrame(RequireThisCheck.AbstractFrame parent, DetailAST ident)
Constructor -- invocable only via super() from subclasses.- Parameters:
parent- parent frame.ident- frame name ident.
-
-
Method Detail
-
getType
protected abstract RequireThisCheck.FrameType getType()
Get the type of the frame.- Returns:
- a FrameType.
-
addIdent
private void addIdent(DetailAST identToAdd)
Add a name to the frame.- Parameters:
identToAdd- the name we're adding.
-
getParent
protected RequireThisCheck.AbstractFrame getParent()
Returns the parent frame.- Returns:
- the parent frame
-
getFrameName
protected java.lang.String getFrameName()
Returns the name identifier text.- Returns:
- the name identifier text
-
getFrameNameIdent
public DetailAST getFrameNameIdent()
Returns the name identifier token.- Returns:
- the name identifier token
-
containsFieldOrVariable
protected boolean containsFieldOrVariable(DetailAST nameToFind)
Check whether the frame contains a field or a variable with the given name.- Parameters:
nameToFind- the IDENT ast of the name we're looking for.- Returns:
- whether it was found.
-
getIfContains
protected RequireThisCheck.AbstractFrame getIfContains(DetailAST nameToFind, boolean lookForMethod)
Check whether the frame contains a given name.- Parameters:
nameToFind- IDENT ast of the name we're looking for.lookForMethod- whether we are looking for a method name.- Returns:
- whether it was found.
-
containsFieldOrVariableDef
protected boolean containsFieldOrVariableDef(java.util.Set<DetailAST> set, DetailAST ident)
Whether the set contains a declaration with the text of the specified IDENT ast and it is declared in a proper position.- Parameters:
set- the set of declarations.ident- the specified IDENT ast.- Returns:
- true if the set contains a declaration with the text of the specified IDENT ast and it is declared in a proper position.
-
isProperDefinition
protected boolean isProperDefinition(DetailAST ident, DetailAST ast)
Whether the definition is correspondent to the IDENT.- Parameters:
ident- the IDENT ast to check.ast- the IDENT ast of the definition to check.- Returns:
- true if ast is correspondent to ident.
-
-