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
ConstructorsModifierConstructorDescriptionprivateClassContext(String className, DetailAST ast) Create new context associated with given class. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAdds new referenced class.private voidaddReferencedClassName(String referencedClassName) Adds new referenced class.voidChecks if coupling less than allowed or not.getClassNameWithPackage(String examineClassName) Retrieves class name with packages.private booleanisExcludedClassRegexp(String candidateClassName) Checks if given class should be ignored as it belongs to excluded class regexp.private booleanisFromExcludedPackage(String candidateClassName) Checks if given class should be ignored as it belongs to excluded package.private booleanisSignificant(String candidateClassName) Checks if given class shouldn't be ignored and not from java.lang.voidvisitLiteralNew(DetailAST ast) Visits NEW.voidvisitLiteralThrows(DetailAST literalThrows) Visits throws clause and collects all exceptions we throw.voidVisits 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.
-