Class AbstractClassCouplingCheck.ClassContext
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.metrics.AbstractClassCouplingCheck.ClassContext
- Enclosing class:
- AbstractClassCouplingCheck
Encapsulates information about class coupling.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ClassContext
(String className, DetailAST ast) Create new context associated with given class. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Adds new referenced class.private void
addReferencedClassName
(String referencedClassName) Adds new referenced class.void
Checks if coupling less than allowed or not.getClassNameWithPackage
(String examineClassName) Retrieves class name with packages.private boolean
isExcludedClassRegexp
(String candidateClassName) Checks if given class should be ignored as it belongs to excluded class regexp.private boolean
isFromExcludedPackage
(String candidateClassName) Checks if given class should be ignored as it belongs to excluded package.private boolean
isSignificant
(String candidateClassName) Checks if given class shouldn't be ignored and not from java.lang.void
visitLiteralNew
(DetailAST ast) Visits NEW.void
visitLiteralThrows
(DetailAST literalThrows) Visits throws clause and collects all exceptions we throw.void
Visits type.
-
Field Details
-
referencedClassNames
Set of referenced classes. Sorted by name for predictable violation messages in unit tests. -
className
Own class name. -
classAst
AST of class definition.
-
-
Constructor Details
-
ClassContext
Create new context associated with given class.- Parameters:
className
- name of the given class.ast
- ast of class definition.
-
-
Method Details
-
visitLiteralThrows
Visits throws clause and collects all exceptions we throw.- Parameters:
literalThrows
- throws to process.
-
visitType
Visits type.- Parameters:
ast
- type to process.
-
visitLiteralNew
Visits NEW.- Parameters:
ast
- NEW to process.
-
addReferencedClassName
Adds new referenced class.- Parameters:
ast
- a node which represents referenced class.
-
addReferencedClassName
Adds new referenced class.- Parameters:
referencedClassName
- class name of the referenced class.
-
checkCoupling
Checks if coupling less than allowed or not. -
isSignificant
Checks if given class shouldn't be ignored and not from java.lang.- Parameters:
candidateClassName
- class to check.- Returns:
- true if we should count this class.
-
isFromExcludedPackage
Checks if given class should be ignored as it belongs to excluded package.- Parameters:
candidateClassName
- class to check- Returns:
- true if we should not count this class.
-
getClassNameWithPackage
Retrieves class name with packages. Uses previously registered imports to get the full class name.- Parameters:
examineClassName
- Class name to be retrieved.- Returns:
- Class name with package name, if found,
Optional.empty()
otherwise.
-
isExcludedClassRegexp
Checks if given class should be ignored as it belongs to excluded class regexp.- Parameters:
candidateClassName
- class to check.- Returns:
- true if we should not count this class.
-