java.lang.Object
java.lang.Enum<RNCErrorCode>
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.validator.RNCErrorCode
All Implemented Interfaces:
Serializable, Comparable<RNCErrorCode>, Constable, IXMLErrorCode

public enum RNCErrorCode extends Enum<RNCErrorCode> implements IXMLErrorCode
Error codes for RNC (RELAX NG Compact Syntax) diagnostics.

Each error code maps to a specific type of problem detected during parsing or validation of an RNC document. The codes are divided into:

  • Parser errors — detected by RNCParser during Phase 1 validation (e.g., missing braces, unclosed blocks).
  • Jing validation errors — detected by Jing during Phase 2 validation (e.g., undefined patterns, duplicate definitions).

Use case: error codes are used to match diagnostics with their corresponding IRNCCodeActionParticipant for quick fixes.

See Also:
  • Enum Constant Details

    • MissingName

      public static final RNCErrorCode MissingName
      An element, attribute, or namespace keyword is missing its name.
    • MissingOpenBrace

      public static final RNCErrorCode MissingOpenBrace
      An element or attribute definition is missing the opening &#123;.
    • MissingAssign

      public static final RNCErrorCode MissingAssign
      A define is missing its assignment operator (=, |=, or &=).
    • MissingUri

      public static final RNCErrorCode MissingUri
      An include or external directive is missing the quoted URI.
    • UnclosedBlock

      public static final RNCErrorCode UnclosedBlock
      A &#123; brace was opened but never closed.
    • FileNotFound

      public static final RNCErrorCode FileNotFound
      An included or external file does not exist on disk.
    • UndefinedPattern

      public static final RNCErrorCode UndefinedPattern
      A pattern references a define name that is not declared.
    • DuplicateDefinition

      public static final RNCErrorCode DuplicateDefinition
      Two or more defines share the same name without compatible combine modes.
    • MissingPattern

      public static final RNCErrorCode MissingPattern
      An element or attribute block is empty (no content pattern).
    • MissingStartElement

      public static final RNCErrorCode MissingStartElement
      The grammar has defines but no start declaration.
    • SyntaxError

      public static final RNCErrorCode SyntaxError
      A generic syntax error reported by Jing.
    • ExpectedToken

      public static final RNCErrorCode ExpectedToken
      Jing expected a specific token (e.g. ""}) but found something else.
    • InterleaveContainsText

      public static final RNCErrorCode InterleaveContainsText
      Both operands of an interleave (&) contain text.
    • IncludeNotOverriding

      public static final RNCErrorCode IncludeNotOverriding
      An include body overrides a define that does not exist in the included file.
    • UnusedDefine

      public static final RNCErrorCode UnusedDefine
      A define is declared but never referenced (shown with DiagnosticTag.Unnecessary).
  • Method Details

    • values

      public static RNCErrorCode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static RNCErrorCode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getCode

      public String getCode()
      Returns the kebab-case diagnostic code string (e.g. "undefined-pattern").
      Specified by:
      getCode in interface IXMLErrorCode
      Returns:
      the code used as the Diagnostic.code in LSP responses.
    • fromCode

      public static RNCErrorCode fromCode(String code)
      Looks up an error code by its kebab-case string.

      Use case: when resolving code actions, the diagnostic code is matched to its enum constant to find the corresponding code action participant.

      Parameters:
      code - the kebab-case code string.
      Returns:
      the matching enum constant, or null if not found.
    • fromMessage

      public static RNCErrorCode fromMessage(String message)
      Determines the error code from a Jing validation error message by matching known message prefixes.

      Use case: Jing reports errors as free-text messages. This method maps messages like "reference to undefined pattern \"foo\"" to UndefinedPattern so that diagnostics get structured codes and matching code actions.

      Parameters:
      message - the Jing error message.
      Returns:
      the matching error code, or null if the message is not recognized.
    • extractName

      public static String extractName(org.eclipse.lsp4j.Diagnostic diagnostic)
      Extracts the quoted name from a diagnostic message (e.g. the pattern name from "reference to undefined pattern \"foo\"").

      Use case: code actions like "Did you mean" and "Create define" need the offending name to generate fix suggestions.

      Parameters:
      diagnostic - the LSP diagnostic whose message to parse.
      Returns:
      the extracted name, or null if the message format is not recognized.
    • extractName

      public static String extractName(String message)
      Extracts the quoted name from a raw error message string.
      Parameters:
      message - the error message text.
      Returns:
      the extracted name, or null if no known prefix matches.