#[non_exhaustive]pub enum UniversalElementRole {
Show 19 variants
Root,
Container,
Definition,
Binding,
Reference,
Typing,
Documentation,
Metadata,
Attribute,
AttributeKey,
Detail,
Name,
Statement,
Expression,
Call,
Value,
Embedded,
Error,
None,
}Expand description
Represents the general structural role of a syntax tree element.
Elements are categorized by their role to enable generic analysis across diverse language families. For example, highlighters and symbol extractors can use these roles to identify definitions, references, or containers without knowing the specific grammar of each language.
§Structural Groups
- Flow Control:
UniversalElementRole::Statement,UniversalElementRole::Expression,UniversalElementRole::Call, andUniversalElementRole::Root. - Symbol Management:
UniversalElementRole::Definition,UniversalElementRole::Binding, andUniversalElementRole::Reference. - Hierarchy:
UniversalElementRole::Container. - Metadata:
UniversalElementRole::Typing,UniversalElementRole::Metadata,UniversalElementRole::Attribute,UniversalElementRole::Documentation.
When a node could fit multiple roles, choose the one that represents its primary structural intent.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Root
The top-level root of the syntax tree, representing the entire document or source file.
Container
A high-level structural container that defines a scope or logical grouping.
Definition
A node that represents the entire declaration or definition of a symbol.
This role identifies the “whole” entity that defines something in the code, which is crucial for building symbol trees and navigation outlines.
§Examples
- Rust: The entire
Fndeclaration block,Structitem, orEnum. - Markdown:
HeadingorLinkDefinition. - SQL: The whole
CREATE TABLEorCREATE PROCEDUREstatement. - ASM: A
Proc(procedure) block or a multi-line data definition. - YAML: A schema-defined object or a complex configuration block.
Binding
A node that specifically performs the act of binding a name to an entity.
Unlike Definition, which represents the entire construct, Binding targets
the specific part (usually the identifier) that introduces the name.
§Examples
- Rust: The identifier node in a
letpattern or function name. - Markdown:
LinkLabelin a reference link definition. - SQL: The
Tablename identifier inCREATE TABLE. - ASM: A
Labelnode (e.g.,main:). - YAML: The
Keyin a key-value mapping.
Reference
A node that refers to an existing name or entity defined elsewhere.
§Examples
- Rust:
PathExpr(variable usage) orMethodCall. - Markdown:
LinkReferenceorFootnoteReference. - SQL:
ColumnNamein aSELECTclause orTableNameinFROM. - ASM: A
Labelreference in a jump (e.g.,JMP main). - YAML: An
Aliasanchor (e.g.,*anchor_name).
Typing
A node representing a type signature, constraint, or type reference.
This role distinguishes type information from general logic or values, which is essential for type checking and intelligent completion.
§Examples
- Rust:
TypePath(e.g.,: i32),GenericArgument, orWhereClause. - SQL:
DataType(e.g.,VARCHAR(255)orINT). - ASM: Size specifiers (e.g.,
DWORD,PTR). - TypeScript:
TypeAnnotationorInterfaceDeclaration.
Documentation
Structured comments or documentation nodes attached to other elements.
Unlike raw Comment tokens, these are syntax nodes that may contain
their own internal structure (like Markdown or Tagged parameters).
§Examples
- Rust:
DocComment(e.g.,/// ...). - Java:
Javadocblocks. - Python:
Docstringliterals.
Metadata
High-level annotations, decorators, or macros that provide extra semantic info.
§Metadata vs Attribute
- Metadata: Usually refers to language-level extensions that “decorate” an element from the outside, often affecting compilation or runtime behavior (e.g., Rust attributes).
- Attribute: Usually refers to built-in, structural properties that are part of the element’s native definition (e.g., HTML attributes).
§Examples
- Rust:
Attribute(e.g.,#[derive(...)]) orMacroCall. - Markdown:
Frontmatter(YAML/TOML header). - Java/TS:
@Decoratoror@Annotation. - Python:
@decoratorsyntax.
Attribute
A specific property, flag, or attribute-value pair.
Unlike Metadata, which decorates an element with external logic, Attribute
represents intrinsic properties defined by the language’s schema or structure.
§Examples
- HTML/XML: An
Attribute(e.g.,id="main"). - Markdown:
LinkTitleorImageAlttext. - YAML: A specific configuration property.
- ASM: Segment attributes (e.g.,
READONLY,EXECUTE).
AttributeKey
The key part of an attribute, property, or configuration entry.
This role is distinct because:
- It is not a Reference (it doesn’t refer to an external symbol).
- It is not a traditional Binding (it doesn’t define a symbol in a global or lexical scope).
- It is not a Keyword (it is typically a user-defined or schema-defined identifier).
§Examples
- HTML: The
idinid="main". - Markdown:
AttributeName(in Pandoc-style{ #id .class };). - YAML: The key in a property mapping.
- TOML: The key in a table entry.
Detail
A node that provides additional details or secondary information for another element.
§Examples
- Rust:
GenericParameterlist,FunctionParameterlist. - SQL:
Constraintdetails.
Name
A node that represents the name of an element, typically used in declarations.
§Examples
- Rust: The name identifier in a function or struct definition.
- HTML: The tag name in an element.
Statement
A discrete syntactic unit within a container, representing a single logical entry or instruction.
This typically maps to a Statement in programming languages, or a standalone instruction in assembly. In markup, it could represent a list item or a table row.
§Examples
- Rust: A
Stmtinside a block. - Markdown:
ListItemorTableCell. - SQL: A standalone
Statementor aClause(likeWHERE). - ASM: A single
Instruction(e.g.,NOP).
Expression
A node representing a computed result or a complex logical operation.
Unlike a simple Value (which is an atomic literal), an Expression involves
operators or logic that must be evaluated.
§Examples
- Rust:
BinaryExpr,UnaryExpr, orRangeExpr. - SQL:
BinaryOpin aWHEREclause. - Python:
ListComprehensionorLambda.
Call
A node that performs an invocation or call to a function, method, or macro.
This role identifies the active execution of a named entity with optional arguments.
§Examples
- Rust:
CallExpr,MethodCallExpr, orMacroInvocation. - SQL:
FunctionCall(e.g.,COUNT(*)). - Excel: A formula call.
Value
A node representing an atomic data value or a primitive constant.
This role is strictly for atomic values like numbers, strings, or booleans.
It does not include composite structures like arrays [] or objects {},
which should be categorized as UniversalElementRole::Container.
§Examples
- Rust:
Literal(strings, numbers, booleans). - Markdown:
InlineCode,Emphasis, orStrong. - SQL:
Literalvalues. - JSON/YAML: Atomic
Scalarvalues (strings, integers, nulls).
Embedded
A node that acts as a host for content in a different language or a raw fragment requiring a separate parsing pass (Language Injection).
§Examples
- HTML: A
<script>or<style>block containing JS/CSS. - Markdown:
CodeBlock(host for other languages). - Rust/Java: A string literal containing SQL (if marked for injection).
- PHP: Raw HTML fragments outside of
<?php ... ?>tags.
Error
A node specifically created to represent a syntax error or recovery point in the source code.
None
No specific structural role assigned or recognized for this element.
Trait Implementations§
Source§impl Clone for UniversalElementRole
impl Clone for UniversalElementRole
Source§fn clone(&self) -> UniversalElementRole
fn clone(&self) -> UniversalElementRole
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more