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
public abstract class AbstractSharedAstVisitorRule extends AbstractAstVisitorRule
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 Constructor Description AbstractSharedAstVisitorRule()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidapplyTo(SourceCode sourceCode, java.util.List<Violation> violations)Apply this rule to the specified source and return a list of violations (or an empty List)protected voidapplyVisitor(AstVisitor visitor, SourceCode sourceCode)protected AstVisitorgetAstVisitor(SourceCode sourceCode)Subclasses can override to provide an AstVisitor with SourceCode or AST-specific initialization.protected abstract java.util.List<Violation>getViolations(AstVisitor astVisitor, SourceCode sourceCode)private java.util.List<Violation>removeSuppressedViolations(java.util.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
-
-
-
-
Method Detail
-
getViolations
protected abstract java.util.List<Violation> getViolations(AstVisitor astVisitor, SourceCode sourceCode)
-
applyTo
public void applyTo(SourceCode sourceCode, java.util.List<Violation> violations)
Description copied from class:AbstractRuleApply this rule to the specified source and return a list of violations (or an empty List)- Overrides:
applyToin 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
protected AstVisitor getAstVisitor(SourceCode sourceCode)
Subclasses can override to provide an AstVisitor with SourceCode or AST-specific initialization.
-
applyVisitor
protected void applyVisitor(AstVisitor visitor, SourceCode sourceCode)
-
removeSuppressedViolations
private java.util.List<Violation> removeSuppressedViolations(java.util.List<Violation> violations, SourceCode sourceCode)
-
-