SyntaxFeature

Trait SyntaxFeature 

Source
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§

Source

type Parser<'source>: Parser

Required Methods§

Source

fn is_supported(&self, p: &Self::Parser<'_>) -> bool

Returns true if the current parsing context supports this syntax feature.

Provided Methods§

Source

fn is_unsupported(&self, p: &Self::Parser<'_>) -> bool

Returns true if the current parsing context doesn’t support this syntax feature.

Source

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>>,

Adds a diagnostic and changes the kind of the node to SyntaxKind::to_bogus if this feature isn’t supported.

Returns the parsed syntax.

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,

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.

Source

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,

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.

Implementors§