org.thewonderlemming.c4plantuml.linter.rules

## Class AbstractLintingRule

- java.lang.Object
- - org.thewonderlemming.c4plantuml.linter.rules.AbstractLintingRule

- Direct Known Subclasses:
    AbstractC4Rule, AbstractCustomLintingRule

      public abstract class AbstractLintingRule
      extends Object

  Represents a linting rule and exposes the methods to be implemented/customized by concrete linting rules.
  Author:
    thewonderlemming

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractLintingRule(RuleParameters parameters)` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract Set<Class<? extends org.antlr.v4.runtime.Parser>>` | `acceptableParsersTypes()` Returns a list of supported ANTLR4 `Parser`.
    `protected void` | `clearSyntaxErrors()` Clears the reported `SyntaxError` within the rule.
    `abstract Optional<? extends org.antlr.v4.runtime.tree.ParseTreeListener>` | `createParseTreeListener(org.thewonderlemming.c4plantuml.commons.Reporter reporter, Class<? extends org.antlr.v4.runtime.Parser> parserType)` Returns a `ParseTreeListener` given a `Parser` type.
    `org.slf4j.Logger` | `getLogger()` Returns the logger to be used within custom `AbstractLintingRule`.
    `protected RuleParameters` | `getParameters()` Returns the current `AbstractLintingRule` parameters.
    `List<SyntaxError>` | `getSyntaxErrors()` Returns a list of reported `SyntaxError`.
    `void` | `reportSyntaxError(SyntaxError parseError)` Collects a new `SyntaxError`.
    `abstract Optional<org.antlr.v4.runtime.tree.ParseTree>` | `selectParseTree(org.antlr.v4.runtime.Parser parser)` Selects a `ParseTree` to process, given a `Parser` grammar.
    `abstract void` | `wrapUp()` A call that takes place after the parsing process of a file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractLintingRule

          protected AbstractLintingRule(RuleParameters parameters)

      Default constructor.
      Parameters:
        `parameters` - the `RuleParameters` to pass to control the behavior of the rule.

  - ### Method Detail

    - #### acceptableParsersTypes

          public abstract Set<Class<? extends org.antlr.v4.runtime.Parser>> acceptableParsersTypes()

      Returns a list of supported ANTLR4 `Parser`.
      Returns:
        the list of supported `Parser`.

    - #### createParseTreeListener

          public abstract Optional<? extends org.antlr.v4.runtime.tree.ParseTreeListener> createParseTreeListener(org.thewonderlemming.c4plantuml.commons.Reporter reporter,
                                                                                                                  Class<? extends org.antlr.v4.runtime.Parser> parserType)

      Returns a `ParseTreeListener` given a `Parser` type.

      The `Reporter` can be passed at the `ParseTreeListener` if needed.

      Parameters:
        `reporter` - the `Reporter` to pass to the new `ParseTreeListener`.
        `parserType` - the `Parser` for the current C4 grammar.
      Returns:
        the `ParseTreeListener` that matches the `Parser` grammar.

    - #### getLogger

          public final org.slf4j.Logger getLogger()

      Returns the logger to be used within custom `AbstractLintingRule`.
      Returns:
        the logger to be used within the rules.

    - #### getSyntaxErrors

          public List<SyntaxError> getSyntaxErrors()

      Returns a list of reported `SyntaxError`.
      Returns:
        a list of `SyntaxError`.

    - #### reportSyntaxError

          public final void reportSyntaxError(SyntaxError parseError)

      Collects a new `SyntaxError`.
      Parameters:
        `parseError` - the `SyntaxError` to report.

    - #### selectParseTree

          public abstract Optional<org.antlr.v4.runtime.tree.ParseTree> selectParseTree(org.antlr.v4.runtime.Parser parser)

      Selects a `ParseTree` to process, given a `Parser` grammar.
      Parameters:
        `parser` - the `Parser` instance to parse the current grammar.
      Returns:
        the `ParseTree` that matches the current grammar.

    - #### wrapUp

          public abstract void wrapUp()

      A call that takes place after the parsing process of a file.

      Implements that call if you need post processing at the end of the linting operation.

    - #### clearSyntaxErrors

          protected final void clearSyntaxErrors()

      Clears the reported `SyntaxError` within the rule.

    - #### getParameters

          protected final RuleParameters getParameters()

      Returns the current `AbstractLintingRule` parameters.
      Returns:
        the rule `RuleParameters`.

Copyright © 2020. All rights reserved.