pub trait SyntaxFeature: Sized {
type Parser<'source>: Parser;
// Required method
fn is_supported(&self, p: &Self::Parser<'_>) -> bool;
// Provided methods
fn is_unsupported(&self, p: &Self::Parser<'_>) -> bool { ... }
fn exclusive_syntax<'source, S, E, D>(
&self,
p: &mut Self::Parser<'source>,
syntax: S,
error_builder: E,
) -> ParsedSyntax
where S: Into<ParsedSyntax>,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> D,
D: ToDiagnostic<Self::Parser<'source>> { ... }
fn parse_exclusive_syntax<'source, P, E>(
&self,
p: &mut Self::Parser<'source>,
parse: P,
error_builder: E,
) -> ParsedSyntax
where P: FnOnce(&mut Self::Parser<'source>) -> ParsedSyntax,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> ParseDiagnostic { ... }
fn excluding_syntax<'source, S, E>(
&self,
p: &mut Self::Parser<'source>,
syntax: S,
error_builder: E,
) -> ParsedSyntax
where S: Into<ParsedSyntax>,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> ParseDiagnostic { ... }
}Expand description
A syntax feature that may or may not be supported depending on the file type and parser configuration
Required Associated Types§
Required Methods§
Sourcefn is_supported(&self, p: &Self::Parser<'_>) -> bool
fn is_supported(&self, p: &Self::Parser<'_>) -> bool
Returns true if the current parsing context supports this syntax feature.
Provided Methods§
Sourcefn is_unsupported(&self, p: &Self::Parser<'_>) -> bool
fn is_unsupported(&self, p: &Self::Parser<'_>) -> bool
Returns true if the current parsing context doesn’t support this syntax feature.
Sourcefn exclusive_syntax<'source, S, E, D>(
&self,
p: &mut Self::Parser<'source>,
syntax: S,
error_builder: E,
) -> ParsedSyntaxwhere
S: Into<ParsedSyntax>,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> D,
D: ToDiagnostic<Self::Parser<'source>>,
fn exclusive_syntax<'source, S, E, D>(
&self,
p: &mut Self::Parser<'source>,
syntax: S,
error_builder: E,
) -> ParsedSyntaxwhere
S: Into<ParsedSyntax>,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> D,
D: ToDiagnostic<Self::Parser<'source>>,
Adds a diagnostic and changes the kind of the node to SyntaxKind::to_bogus if this feature isn’t supported.
Returns the parsed syntax.
Sourcefn parse_exclusive_syntax<'source, P, E>(
&self,
p: &mut Self::Parser<'source>,
parse: P,
error_builder: E,
) -> ParsedSyntaxwhere
P: FnOnce(&mut Self::Parser<'source>) -> ParsedSyntax,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> ParseDiagnostic,
fn parse_exclusive_syntax<'source, P, E>(
&self,
p: &mut Self::Parser<'source>,
parse: P,
error_builder: E,
) -> ParsedSyntaxwhere
P: FnOnce(&mut Self::Parser<'source>) -> ParsedSyntax,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> ParseDiagnostic,
Parses a syntax and adds a diagnostic and changes the kind of the node to SyntaxKind::to_bogus if this feature isn’t supported.
Returns the parsed syntax.
Sourcefn excluding_syntax<'source, S, E>(
&self,
p: &mut Self::Parser<'source>,
syntax: S,
error_builder: E,
) -> ParsedSyntaxwhere
S: Into<ParsedSyntax>,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> ParseDiagnostic,
fn excluding_syntax<'source, S, E>(
&self,
p: &mut Self::Parser<'source>,
syntax: S,
error_builder: E,
) -> ParsedSyntaxwhere
S: Into<ParsedSyntax>,
E: FnOnce(&Self::Parser<'source>, &CompletedMarker) -> ParseDiagnostic,
Adds a diagnostic and changes the kind of the node to SyntaxKind::to_bogus if this feature is supported.
Returns the parsed syntax.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.