Class UnusedImportsCheck.Frame
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck.Frame
-
- Enclosing class:
- UnusedImportsCheck
private static final class UnusedImportsCheck.Frame extends java.lang.Object
Holds the names of referenced types and names of declared inner types.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>declaredTypesNested types declared in the current scope.private UnusedImportsCheck.FrameparentParent frame.private java.util.Set<java.lang.String>referencedTypesSet of references - possibly to imports or locally declared types.
-
Constructor Summary
Constructors Modifier Constructor Description privateFrame(UnusedImportsCheck.Frame parent)Private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDeclaredType(java.lang.String type)Adds new inner type.voidaddReferencedType(java.lang.String type)Adds new type reference to the current frame.voidaddReferencedTypes(java.util.Collection<java.lang.String> types)Adds new inner types.static UnusedImportsCheck.FramecompilationUnit()Creates a new top-level frame for the compilation unit.voidfinish()Filters out all references to locally defined types.booleanisReferencedType(java.lang.String type)Checks whether this type name is used in this frame.UnusedImportsCheck.Framepop()Pulls all referenced types up, except those that are declared in this scope.UnusedImportsCheck.Framepush()Creates new inner frame.
-
-
-
Field Detail
-
parent
private final UnusedImportsCheck.Frame parent
Parent frame.
-
declaredTypes
private final java.util.Set<java.lang.String> declaredTypes
Nested types declared in the current scope.
-
referencedTypes
private final java.util.Set<java.lang.String> referencedTypes
Set of references - possibly to imports or locally declared types.
-
-
Constructor Detail
-
Frame
private Frame(UnusedImportsCheck.Frame parent)
Private constructor. UsecompilationUnit()to create a new top-level frame.- Parameters:
parent- the parent frame
-
-
Method Detail
-
addDeclaredType
public void addDeclaredType(java.lang.String type)
Adds new inner type.- Parameters:
type- the type name
-
addReferencedType
public void addReferencedType(java.lang.String type)
Adds new type reference to the current frame.- Parameters:
type- the type name
-
addReferencedTypes
public void addReferencedTypes(java.util.Collection<java.lang.String> types)
Adds new inner types.- Parameters:
types- the type names
-
finish
public void finish()
Filters out all references to locally defined types.
-
push
public UnusedImportsCheck.Frame push()
Creates new inner frame.- Returns:
- a new frame.
-
pop
public UnusedImportsCheck.Frame pop()
Pulls all referenced types up, except those that are declared in this scope.- Returns:
- the parent frame
-
isReferencedType
public boolean isReferencedType(java.lang.String type)
Checks whether this type name is used in this frame.- Parameters:
type- the type name- Returns:
trueif the type is used
-
compilationUnit
public static UnusedImportsCheck.Frame compilationUnit()
Creates a new top-level frame for the compilation unit.- Returns:
- a new frame.
-
-