Class RNCElement
java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCNode
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCElement
- All Implemented Interfaces:
RNCRange
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 Summary
ConstructorsConstructorDescriptionRNCElement(int start, int end) Creates a new element node spanning the given offsets. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the offset of the closing brace\}.intReturns the offset of the opening brace invalid input: '{@code \{}. @return the brace offset, or {@code -1} if no opening brace was found.'getName()Returns the element name extracted from the source text.intReturns the exclusive end offset of the element name.intReturns the inclusive start offset of the element name.voidsetBodyCloseOffset(int offset) Sets the offset of the closing brace.voidsetBodyOpenOffset(int offset) Sets the offset of the opening brace.voidsetName(int start, int end) Sets the source offsets of the element name.Methods inherited from class org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCNode
addChild, findNodeAt, getChildren, getEnd, getOwnerDocument, getParent, getStart, getText, hasChildren, isClosed, setClosed, setEnd, setStart
-
Constructor Details
-
RNCElement
public RNCElement(int start, int end) Creates a new element node spanning the given offsets.- Parameters:
start- the inclusive start offset (theelementkeyword).end- the exclusive end offset (adjusted when parsing completes).
-
-
Method Details
-
getNodeType
- Specified by:
getNodeTypein classRNCNode
-
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
Returns the element name extracted from the source text.Example: for
element root { text }, returns"root".- Returns:
- the name string, or
nullif not set.
-
getNameStart
public int getNameStart()Returns the inclusive start offset of the element name.- Returns:
- the name start offset, or
-1if not set.
-
getNameEnd
public int getNameEnd()Returns the exclusive end offset of the element name.- Returns:
- the name end offset, or
-1if 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 ofinvalid @code
{@code \{} in the source text.
-
getBodyCloseOffset
public int getBodyCloseOffset()Returns the offset of the closing brace\}.- Returns:
- the brace offset, or
-1if 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.
-