syntax::ast::syntax_factory

Struct SyntaxFactory

Source
pub struct SyntaxFactory { /* private fields */ }

Implementations§

Source§

impl SyntaxFactory

Source

pub fn name(&self, name: &str) -> Name

Source

pub fn name_ref(&self, name: &str) -> NameRef

Source

pub fn lifetime(&self, text: &str) -> Lifetime

Source

pub fn ty(&self, text: &str) -> Type

Source

pub fn ty_infer(&self) -> InferType

Source

pub fn ty_path(&self, path: Path) -> PathType

Source

pub fn type_param(&self, name: Name, bounds: Option<TypeBoundList>) -> TypeParam

Source

pub fn path_segment(&self, name_ref: NameRef) -> PathSegment

Source

pub fn path_segment_generics( &self, name_ref: NameRef, generic_arg_list: GenericArgList, ) -> PathSegment

Source

pub fn path_unqualified(&self, segment: PathSegment) -> Path

Source

pub fn path_from_segments( &self, segments: impl IntoIterator<Item = PathSegment>, is_abs: bool, ) -> Path

Source

pub fn ident_pat(&self, ref_: bool, mut_: bool, name: Name) -> IdentPat

Source

pub fn wildcard_pat(&self) -> WildcardPat

Source

pub fn literal_pat(&self, text: &str) -> LiteralPat

Source

pub fn tuple_struct_pat( &self, path: Path, fields: impl IntoIterator<Item = Pat>, ) -> TupleStructPat

Source

pub fn block_expr( &self, statements: impl IntoIterator<Item = Stmt>, tail_expr: Option<Expr>, ) -> BlockExpr

Source

pub fn expr_empty_block(&self) -> BlockExpr

Source

pub fn expr_tuple(&self, fields: impl IntoIterator<Item = Expr>) -> TupleExpr

Source

pub fn expr_bin(&self, lhs: Expr, op: BinaryOp, rhs: Expr) -> BinExpr

Source

pub fn expr_literal(&self, text: &str) -> Literal

Source

pub fn expr_path(&self, path: Path) -> Expr

Source

pub fn expr_prefix(&self, op: SyntaxKind, expr: Expr) -> PrefixExpr

Source

pub fn expr_call(&self, expr: Expr, arg_list: ArgList) -> CallExpr

Source

pub fn arg_list(&self, args: impl IntoIterator<Item = Expr>) -> ArgList

Source

pub fn expr_ref(&self, expr: Expr, exclusive: bool) -> Expr

Source

pub fn expr_return(&self, expr: Option<Expr>) -> ReturnExpr

Source

pub fn expr_if( &self, condition: Expr, then_branch: BlockExpr, else_branch: Option<ElseBranch>, ) -> IfExpr

Source

pub fn expr_let(&self, pattern: Pat, expr: Expr) -> LetExpr

Source

pub fn expr_stmt(&self, expr: Expr) -> ExprStmt

Source

pub fn expr_match(&self, expr: Expr, match_arm_list: MatchArmList) -> MatchExpr

Source

pub fn match_arm( &self, pat: Pat, guard: Option<MatchGuard>, expr: Expr, ) -> MatchArm

Source

pub fn match_guard(&self, condition: Expr) -> MatchGuard

Source

pub fn match_arm_list( &self, match_arms: impl IntoIterator<Item = MatchArm>, ) -> MatchArmList

Source

pub fn let_stmt( &self, pattern: Pat, ty: Option<Type>, initializer: Option<Expr>, ) -> LetStmt

Source

pub fn type_arg(&self, ty: Type) -> TypeArg

Source

pub fn lifetime_arg(&self, lifetime: Lifetime) -> LifetimeArg

Source

pub fn item_const( &self, visibility: Option<Visibility>, name: Name, ty: Type, expr: Expr, ) -> Const

Source

pub fn item_static( &self, visibility: Option<Visibility>, is_unsafe: bool, is_mut: bool, name: Name, ty: Type, expr: Option<Expr>, ) -> Static

Source

pub fn generic_arg_list( &self, generic_args: impl IntoIterator<Item = GenericArg>, is_turbo: bool, ) -> GenericArgList

Source

pub fn record_field_list( &self, fields: impl IntoIterator<Item = RecordField>, ) -> RecordFieldList

Source

pub fn record_field( &self, visibility: Option<Visibility>, name: Name, ty: Type, ) -> RecordField

Source

pub fn tuple_field_list( &self, fields: impl IntoIterator<Item = TupleField>, ) -> TupleFieldList

Source

pub fn tuple_field( &self, visibility: Option<Visibility>, ty: Type, ) -> TupleField

Source

pub fn item_enum( &self, visibility: Option<Visibility>, name: Name, generic_param_list: Option<GenericParamList>, where_clause: Option<WhereClause>, variant_list: VariantList, ) -> Enum

Source

pub fn variant_list( &self, variants: impl IntoIterator<Item = Variant>, ) -> VariantList

Source

pub fn variant( &self, visibility: Option<Visibility>, name: Name, field_list: Option<FieldList>, discriminant: Option<Expr>, ) -> Variant

Source

pub fn token_tree( &self, delimiter: SyntaxKind, tt: impl IntoIterator<Item = NodeOrToken<TokenTree, SyntaxToken>>, ) -> TokenTree

Source

pub fn token(&self, kind: SyntaxKind) -> SyntaxToken

Source

pub fn whitespace(&self, text: &str) -> SyntaxToken

Source§

impl SyntaxFactory

Source

pub fn ident_path(&self, ident: &str) -> Path

Source

pub fn expr_unit(&self) -> Expr

Source

pub fn ty_option(&self, t: Type) -> PathType

Source

pub fn ty_result(&self, t: Type, e: Type) -> PathType

Source§

impl SyntaxFactory

Source

pub fn new() -> Self

Creates a new SyntaxFactory, generating mappings between input nodes and generated nodes.

Source

pub fn without_mappings() -> Self

Creates a SyntaxFactory without generating mappings.

Source

pub fn finish_with_mappings(self) -> SyntaxMapping

Gets all of the tracked syntax mappings, if any.

Trait Implementations§

Source§

impl Default for SyntaxFactory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more