Class ScopeUtil
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.utils.ScopeUtil
-
public final class ScopeUtil extends java.lang.ObjectContains utility methods for working on scope.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ScopegetScopeFromMods(DetailAST aMods)Returns the Scope specified by the modifier set.static ScopegetSurroundingScope(DetailAST node)Returns the scope of the surrounding "block".static booleanisClassFieldDef(DetailAST node)Determines whether a node is a class field definition.static booleanisInAnnotationBlock(DetailAST node)Returns whether a node is directly contained within an annotation block.static booleanisInClassBlock(DetailAST node)Returns whether a node is directly contained within a class block.static booleanisInCodeBlock(DetailAST node)Returns whether the scope of a node is restricted to a code block.static booleanisInEnumBlock(DetailAST node)Returns whether a node is directly contained within an enum block.static booleanisInInterfaceBlock(DetailAST node)Returns whether a node is directly contained within an interface block.static booleanisInInterfaceOrAnnotationBlock(DetailAST node)Returns whether a node is directly contained within an interface or annotation block.static booleanisInRecordBlock(DetailAST node)Returns whether a node is directly contained within a record block.static booleanisInScope(DetailAST ast, Scope scope)Checks whether ast node is in a specific scope.static booleanisLocalVariableDef(DetailAST node)Determines whether a node is a local variable definition.static booleanisOuterMostType(DetailAST node)Returns whether a node is contained in the outer most type block.
-
-
-
Method Detail
-
getScopeFromMods
public static Scope getScopeFromMods(DetailAST aMods)
Returns the Scope specified by the modifier set.- Parameters:
aMods- root node of a modifier set- Returns:
- a
Scopevalue
-
getSurroundingScope
public static Scope getSurroundingScope(DetailAST node)
Returns the scope of the surrounding "block".- Parameters:
node- the node to return the scope for- Returns:
- the Scope of the surrounding block
-
isInClassBlock
public static boolean isInClassBlock(DetailAST node)
Returns whether a node is directly contained within a class block.- Parameters:
node- the node to check if directly contained within a class block.- Returns:
- a
booleanvalue
-
isInRecordBlock
public static boolean isInRecordBlock(DetailAST node)
Returns whether a node is directly contained within a record block.- Parameters:
node- the node to check if directly contained within a record block.- Returns:
- a
booleanvalue
-
isInInterfaceBlock
public static boolean isInInterfaceBlock(DetailAST node)
Returns whether a node is directly contained within an interface block.- Parameters:
node- the node to check if directly contained within an interface block.- Returns:
- a
booleanvalue
-
isInAnnotationBlock
public static boolean isInAnnotationBlock(DetailAST node)
Returns whether a node is directly contained within an annotation block.- Parameters:
node- the node to check if directly contained within an annotation block.- Returns:
- a
booleanvalue
-
isInInterfaceOrAnnotationBlock
public static boolean isInInterfaceOrAnnotationBlock(DetailAST node)
Returns whether a node is directly contained within an interface or annotation block.- Parameters:
node- the node to check if directly contained within an interface or annotation block.- Returns:
- a
booleanvalue
-
isInEnumBlock
public static boolean isInEnumBlock(DetailAST node)
Returns whether a node is directly contained within an enum block.- Parameters:
node- the node to check if directly contained within an enum block.- Returns:
- a
booleanvalue
-
isInCodeBlock
public static boolean isInCodeBlock(DetailAST node)
Returns whether the scope of a node is restricted to a code block. A code block is a method or constructor body, an initializer block, or lambda body.- Parameters:
node- the node to check- Returns:
- a
booleanvalue
-
isOuterMostType
public static boolean isOuterMostType(DetailAST node)
Returns whether a node is contained in the outer most type block.- Parameters:
node- the node to check- Returns:
- a
booleanvalue
-
isLocalVariableDef
public static boolean isLocalVariableDef(DetailAST node)
Determines whether a node is a local variable definition. I.e. if it is declared in a code block, a for initializer, or a catch parameter.- Parameters:
node- the node to check.- Returns:
- whether aAST is a local variable definition.
-
isClassFieldDef
public static boolean isClassFieldDef(DetailAST node)
Determines whether a node is a class field definition. I.e. if a variable is not declared in a code block, a for initializer, or a catch parameter.- Parameters:
node- the node to check.- Returns:
- whether a node is a class field definition.
-
-