java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCNode
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCAttribute
All Implemented Interfaces:
RNCRange

public class RNCAttribute extends RNCNode
Represents an attribute pattern in an RNC document.

An attribute pattern declares an XML attribute with a name class and a content pattern enclosed in braces. The content pattern typically constrains the attribute value (e.g., text, a datatype, or a specific string).

Use case: the parser creates an RNCAttribute node when it encounters the attribute keyword. This node tracks the attribute name and brace offsets for diagnostics (unclosed blocks, missing names) and folding.

Example RNC:

 element root {
   attribute id { text },      ← RNCAttribute(name="id")
   attribute class { text }    ← RNCAttribute(name="class")
 }
 
  • Constructor Details

    • RNCAttribute

      public RNCAttribute(int start, int end)
      Creates a new attribute node spanning the given offsets.
      Parameters:
      start - the inclusive start offset (the attribute keyword).
      end - the exclusive end offset (adjusted when parsing completes).
  • Method Details

    • getNodeType

      public RNCNodeType getNodeType()
      Specified by:
      getNodeType in class RNCNode
    • setName

      public void setName(int start, int end)
      Sets the source offsets of the attribute name.
      Parameters:
      start - the inclusive start offset of the name.
      end - the exclusive end offset of the name.
    • getName

      public String getName()
      Returns the attribute name extracted from the source text.

      Example: for attribute id { text }, returns "id".

      Returns:
      the name string, or null if not set.
    • getNameStart

      public int getNameStart()
      Returns the inclusive start offset of the attribute name.
      Returns:
      the name start offset, or -1 if not set.
    • getNameEnd

      public int getNameEnd()
      Returns the exclusive end offset of the attribute name.
      Returns:
      the name end offset, or -1 if not set.
    • getBodyOpenOffset

      public int getBodyOpenOffset()
      Returns the offset of the opening brace invalid input: '{@code \{}. @return the brace offset, or {@code -1} if no opening brace was found.'
    • setBodyOpenOffset

      public void setBodyOpenOffset(int offset)
      Sets the offset of the opening brace.
      Parameters:
      offset - the offset of
      invalid @code
      {@code \{} in the source text.
    • getBodyCloseOffset

      public int getBodyCloseOffset()
      Returns the offset of the closing brace \}.
      Returns:
      the brace offset, or -1 if the block is unclosed.
    • setBodyCloseOffset

      public void setBodyCloseOffset(int offset)
      Sets the offset of the closing brace.
      Parameters:
      offset - the offset of \} in the source text.