pub struct Annotation {
pub data: Data,
pub children: GeneralContainer,
pub location: Range,
}Expand description
An annotation represents some metadata about an AST element.
§Reserved label namespace
Labels starting with lex. (the lex.* namespace, Annotation::RESERVED_NAMESPACE_PREFIX)
are reserved for core-defined semantics. Third-party tooling must not author labels in
this namespace; the core may add new lex.* labels without a coordinating versioning
concern. Non-reserved labels remain freely available for extensions
(mycompany.include, docs.embed, etc.).
The current set of reserved labels:
Annotation::INCLUDE_LABEL("lex.include") — seecomms/specs/proposals/includes.lex.
Fields§
§data: Data§children: GeneralContainer§location: RangeImplementations§
Source§impl Annotation
impl Annotation
Sourcepub const RESERVED_NAMESPACE_PREFIX: &'static str = "lex."
pub const RESERVED_NAMESPACE_PREFIX: &'static str = "lex."
Reserved label prefix for core-defined annotation semantics.
Any annotation whose label starts with this prefix is owned by the Lex core and may carry behavior in the resolver / analysis layers. External authors should pick a different namespace.
Sourcepub const INCLUDE_LABEL: &'static str = "lex.include"
pub const INCLUDE_LABEL: &'static str = "lex.include"
Reserved label for the include directive.
An annotation with this label and a src= parameter is interpreted by
lex_core::includes as a request to splice another Lex file’s content
into the parent container at the annotation’s position. See
comms/specs/proposals/includes.lex for the full design.
pub fn new( label: Label, parameters: Vec<Parameter>, children: Vec<ContentElement>, ) -> Self
pub fn marker(label: Label) -> Self
pub fn with_parameters(label: Label, parameters: Vec<Parameter>) -> Self
pub fn from_data(data: Data, children: Vec<ContentElement>) -> Self
Sourcepub fn header_location(&self) -> &Range
pub fn header_location(&self) -> &Range
Range covering only the annotation header (label + parameters).
Sourcepub fn body_location(&self) -> Option<Range>
pub fn body_location(&self) -> Option<Range>
Bounding range covering only the annotation’s children.
Sourcepub fn is_reserved(&self) -> bool
pub fn is_reserved(&self) -> bool
Whether this annotation’s label is in the reserved lex.* namespace.
Sourcepub fn is_include(&self) -> bool
pub fn is_include(&self) -> bool
Whether this annotation is the include directive (label lex.include).
Hides the string-match on the reserved label so callers don’t sprinkle
annotation.label == "lex.include" throughout the codebase. Also serves
as the migration boundary if a future version models includes as a
distinct AST node type.
Sourcepub fn include_src(&self) -> Option<String>
pub fn include_src(&self) -> Option<String>
The src= parameter value with surrounding quotes stripped and
escape sequences resolved, if present.
Useful on its own for any annotation that uses a src parameter
(verbatim-via-annotation, future lex.* directives, etc.). For
the include-specific case, callers typically pair this with
Annotation::is_include.
Returns an owned String rather than &str because escape
resolution may need to allocate. For quote-free values (the common
case) the returned string is the same as parameter.value minus
the leading/trailing ".
Trait Implementations§
Source§impl AstNode for Annotation
impl AstNode for Annotation
Source§impl Clone for Annotation
impl Clone for Annotation
Source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Container for Annotation
impl Container for Annotation
fn label(&self) -> &str
fn children(&self) -> &[ContentItem]
fn children_mut(&mut self) -> &mut Vec<ContentItem>
Source§impl Debug for Annotation
impl Debug for Annotation
Source§impl Display for Annotation
impl Display for Annotation
Source§impl PartialEq for Annotation
impl PartialEq for Annotation
Source§fn eq(&self, other: &Annotation) -> bool
fn eq(&self, other: &Annotation) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Annotation
Source§impl VisualStructure for Annotation
impl VisualStructure for Annotation
Source§fn is_source_line_node(&self) -> bool
fn is_source_line_node(&self) -> bool
Source§fn has_visual_header(&self) -> bool
fn has_visual_header(&self) -> bool
Source§fn collapses_with_children(&self) -> bool
fn collapses_with_children(&self) -> bool
Auto Trait Implementations§
impl Freeze for Annotation
impl RefUnwindSafe for Annotation
impl Send for Annotation
impl Sync for Annotation
impl Unpin for Annotation
impl UnsafeUnpin for Annotation
impl UnwindSafe for Annotation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more