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

public class RNCElement extends RNCNode
Represents an element pattern in an RNC document.

An element pattern declares an XML element with a name class and a content pattern enclosed in braces.

Use case: the parser creates an RNCElement node when it encounters the element keyword. This node is typically a child of an RNCDefine and tracks the element name and brace offsets for diagnostics (unclosed blocks, missing names) and folding.

Example RNC:

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

    • RNCElement

      public RNCElement(int start, int end)
      Creates a new element node spanning the given offsets.
      Parameters:
      start - the inclusive start offset (the element 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 element name.
      Parameters:
      start - the inclusive start offset of the name.
      end - the exclusive end offset of the name.
    • getName

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

      Example: for element root { text }, returns "root".

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

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

      public int getNameEnd()
      Returns the exclusive end offset of the element 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.