Package org.codenarc.rule
Class AbstractSharedAstVisitorRule
java.lang.Object
org.codenarc.rule.AbstractRule
org.codenarc.rule.AbstractAstVisitorRule
org.codenarc.rule.AbstractSharedAstVisitorRule
- All Implemented Interfaces:
Rule
- Direct Known Subclasses:
PrivateFieldCouldBeFinalRule
,UnusedPrivateFieldRule
,UnusedPrivateMethodRule
Abstract superclass for Rules that use a single, shared AstVisitor across all ClassNodes in a source (file).
-
Field Summary
Fields inherited from class org.codenarc.rule.AbstractAstVisitorRule
CLOSURE_TEXT, DEFAULT_CONST_NAME, DEFAULT_FIELD_NAME, DEFAULT_TEST_CLASS_NAMES, DEFAULT_TEST_FILES, DEFAULT_VAR_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyTo
(SourceCode sourceCode, List<Violation> violations) Apply this rule to the specified source and return a list of violations (or an empty List)protected void
applyVisitor
(AstVisitor visitor, SourceCode sourceCode) protected AstVisitor
getAstVisitor
(SourceCode sourceCode) Subclasses can override to provide an AstVisitor with SourceCode or AST-specific initialization.getViolations
(AstVisitor astVisitor, SourceCode sourceCode) removeSuppressedViolations
(List<Violation> violations, SourceCode sourceCode) Methods inherited from class org.codenarc.rule.AbstractAstVisitorRule
getApplyToClassNames, getAstVisitor, getAstVisitorClass, getDoNotApplyToClassNames, setApplyToClassNames, setDoNotApplyToClassNames, shouldApplyThisRuleTo
Methods inherited from class org.codenarc.rule.AbstractRule
applyTo, createViolation, createViolation, createViolationForImport, createViolationForImport, getApplyToFileNames, getApplyToFilesMatching, getCompilerPhase, getDescription, getDoNotApplyToFileNames, getDoNotApplyToFilesMatching, getName, getPriority, getViolationMessage, isEnabled, isReady, setApplyToFileNames, setApplyToFilesMatching, setDescription, setDoNotApplyToFileNames, setDoNotApplyToFilesMatching, setEnabled, setName, setPriority, setViolationMessage, toString, validate
-
Constructor Details
-
AbstractSharedAstVisitorRule
public AbstractSharedAstVisitorRule()
-
-
Method Details
-
getViolations
-
applyTo
Description copied from class:AbstractRule
Apply this rule to the specified source and return a list of violations (or an empty List)- Overrides:
applyTo
in classAbstractAstVisitorRule
- Parameters:
sourceCode
- - the source to apply this rule toviolations
- - the List of violations to which new violations from this rule are to be added
-
getAstVisitor
Subclasses can override to provide an AstVisitor with SourceCode or AST-specific initialization. -
applyVisitor
-
removeSuppressedViolations
private List<Violation> removeSuppressedViolations(List<Violation> violations, SourceCode sourceCode)
-