Interface RtParsingContext


public interface RtParsingContext
The context used while parsing. Provides various methods to access the source file input stream, the parser configuration, link and element builders and the logging facility.
Since:
3.17.0
  • Method Details

    • getParserId

      @NotNull String getParserId()
      Gets the parser id currently used for parsing. The parser id is unique within the resource traceability configuration scope.
      Returns:
      parser id
    • getProjectId

      @NotNull String getProjectId()
      Gets the project id that is related to parsed source file. A project is considered related to source file if source file`s repository is set up under that project.
      Returns:
      project id
    • getParserProperties

      @NotNull RtParserProperties getParserProperties()
      Returns:
      the parser configuration properties.
    • getFile

      @NotNull RtFile getFile()
      Returns:
      the RtFile to be parsed.
    • create

      @NotNull RtParsingModelFactory create()
      Returns:
      the factory for creating parsing model entities.
    • parseLinks

      @NotNull List<RtLink> parseLinks(@NotNull String text, @NotNull RtPosition position)
      Parses links from specified text. For parsers that work with source file links are typically placed in comment blocks, so this method should be called with comment text. Position of found link is calculated as the given position plus position of the link in the given text. The links parser accepts links in the following format:
      @wi[.ROLEID] [ProjectID/]WID[:revision]
      {@wi[.ROLEID] [ProjectID/]WID[:revision] MESSAGE
      CONTINUE}

      @wi[.ROLEID] WORKITEMURL
      {@wi[.ROLEID] WORKITEMURL MESSAGE...}

      WORKITEMURL is an absolute url with # or 'redirect' parts.
      Examples:
      http://polarion.server/polarion/redirect/project/someProject/workitem?id=TST-10001
      http://polarion.server/polarion/#/project/someProject/workitem?id=TST-10001
      http://polarion.server/polarion/#/project/someProject/workitem?id=TST-10001&revision=876650
      Where ProjectID, revision, ROLEID and MESSAGE elements are optional.
      Parameters:
      text - the text to be processed which starts in the source file at the given position.
      position - the position of the given text in the source file.
      Returns:
      a list of link objects.
    • logParseError

      void logParseError(@NotNull RtPosition position, @NotNull String errorMessage, @NotNull Class forClass)
      Logs errors that occurred during the parsing process.
      Parameters:
      position - the position that caused the error.
      errorMessage - the error message text.
      forClass - the class from where the parse error came from. Debug level logging for this class must be enabled to see these errors in the log.