pub struct SyntaxFactory { /* private fields */ }Implementations§
Source§impl SyntaxFactory
impl SyntaxFactory
pub fn name(&self, name: &str) -> Name
pub fn name_ref(&self, name: &str) -> NameRef
pub fn name_ref_self_ty(&self) -> NameRef
pub fn expr_todo(&self) -> Expr
pub fn expr_self(&self) -> Expr
pub fn expr_const_value(&self, text: &str) -> ConstArg
pub fn lifetime(&self, text: &str) -> Lifetime
pub fn ty(&self, text: &str) -> Type
pub fn ty_infer(&self) -> InferType
pub fn ty_path(&self, path: Path) -> PathType
pub fn ty_path_from_segments( &self, segments: impl IntoIterator<Item = PathSegment>, is_abs: bool, ) -> Type
pub fn type_bound(&self, bound: Type) -> TypeBound
pub fn type_bound_text(&self, bound: &str) -> TypeBound
pub fn use_tree_list( &self, use_trees: impl IntoIterator<Item = UseTree>, ) -> UseTreeList
pub fn type_bound_list( &self, bounds: impl IntoIterator<Item = TypeBound>, ) -> Option<TypeBoundList>
pub fn type_param(&self, name: Name, bounds: Option<TypeBoundList>) -> TypeParam
pub fn path_from_text(&self, text: &str) -> Path
pub fn path_from_text_with_edition(&self, text: &str, edition: Edition) -> Path
pub fn path_concat(&self, first: Path, second: Path) -> Path
pub fn visibility_pub_crate(&self) -> Visibility
pub fn visibility_pub(&self) -> Visibility
pub fn struct_( &self, visibility: Option<Visibility>, strukt_name: Name, generic_param_list: Option<GenericParamList>, field_list: FieldList, ) -> Struct
pub fn unnamed_param(&self, ty: Type) -> Param
pub fn untyped_param(&self, pat: Pat) -> Param
pub fn ty_fn_ptr<I>( &self, is_unsafe: bool, abi: Option<Abi>, params: I, ret_type: Option<RetType>, ) -> FnPtrType
pub fn where_pred( &self, path: Either<Lifetime, Type>, bounds: impl IntoIterator<Item = TypeBound>, ) -> WherePred
pub fn where_clause( &self, predicates: impl IntoIterator<Item = WherePred>, ) -> WhereClause
pub fn impl_trait_type(&self, bounds: TypeBoundList) -> ImplTraitType
pub fn expr_field(&self, receiver: Expr, field: &str) -> FieldExpr
pub fn impl_trait( &self, attrs: impl IntoIterator<Item = Attr>, is_unsafe: bool, trait_gen_params: Option<GenericParamList>, trait_gen_args: Option<GenericArgList>, type_gen_params: Option<GenericParamList>, type_gen_args: Option<GenericArgList>, is_negative: bool, path_type: Type, ty: Type, trait_where_clause: Option<WhereClause>, ty_where_clause: Option<WhereClause>, body: Option<AssocItemList>, ) -> Impl
pub fn ty_alias( &self, attrs: impl IntoIterator<Item = Attr>, ident: &str, generic_param_list: Option<GenericParamList>, type_param_bounds: Option<TypeParam>, where_clause: Option<WhereClause>, assignment: Option<(Type, Option<WhereClause>)>, ) -> TypeAlias
pub fn param_list( &self, self_param: Option<SelfParam>, params: impl IntoIterator<Item = Param>, ) -> ParamList
pub fn const_param(&self, name: Name, ty: Type) -> ConstParam
pub fn lifetime_param(&self, lifetime: Lifetime) -> LifetimeParam
pub fn generic_param_list( &self, params: impl IntoIterator<Item = GenericParam>, ) -> GenericParamList
pub fn path_segment(&self, name_ref: NameRef) -> PathSegment
pub fn path_segment_self(&self) -> PathSegment
pub fn path_segment_super(&self) -> PathSegment
pub fn path_segment_crate(&self) -> PathSegment
pub fn generic_ty_path_segment( &self, name_ref: NameRef, generic_args: impl IntoIterator<Item = GenericArg>, ) -> PathSegment
pub fn tail_only_block_expr(&self, tail_expr: Expr) -> BlockExpr
pub fn expr_bin_op(&self, lhs: Expr, op: BinaryOp, rhs: Expr) -> Expr
pub fn ty_placeholder(&self) -> Type
pub fn ty_unit(&self) -> Type
pub fn ty_tuple(&self, types: impl IntoIterator<Item = Type>) -> Type
pub fn path_segment_generics( &self, name_ref: NameRef, generic_arg_list: GenericArgList, ) -> PathSegment
pub fn use_( &self, attrs: impl IntoIterator<Item = Attr>, visibility: Option<Visibility>, use_tree: UseTree, ) -> Use
pub fn use_tree( &self, path: Path, use_tree_list: Option<UseTreeList>, alias: Option<Rename>, add_star: bool, ) -> UseTree
pub fn use_tree_glob(&self) -> UseTree
pub fn path_unqualified(&self, segment: PathSegment) -> Path
pub fn path_qualified(&self, qual: Path, segment: PathSegment) -> Path
pub fn path_from_segments( &self, segments: impl IntoIterator<Item = PathSegment>, is_abs: bool, ) -> Path
pub fn ident_pat(&self, ref_: bool, mut_: bool, name: Name) -> IdentPat
pub fn simple_ident_pat(&self, name: Name) -> IdentPat
pub fn wildcard_pat(&self) -> WildcardPat
pub fn literal_pat(&self, text: &str) -> LiteralPat
pub fn slice_pat(&self, pats: impl IntoIterator<Item = Pat>) -> SlicePat
pub fn tuple_pat(&self, pats: impl IntoIterator<Item = Pat>) -> TuplePat
pub fn tuple_struct_pat( &self, path: Path, fields: impl IntoIterator<Item = Pat>, ) -> TupleStructPat
pub fn record_pat_with_fields( &self, path: Path, fields: RecordPatFieldList, ) -> RecordPat
pub fn record_pat_field_list( &self, fields: impl IntoIterator<Item = RecordPatField>, rest_pat: Option<RestPat>, ) -> RecordPatFieldList
pub fn record_pat_field(&self, name_ref: NameRef, pat: Pat) -> RecordPatField
pub fn record_pat_field_shorthand(&self, pat: Pat) -> RecordPatField
pub fn path_pat(&self, path: Path) -> Pat
pub fn rest_pat(&self) -> RestPat
pub fn or_pat( &self, pats: impl IntoIterator<Item = Pat>, leading_pipe: bool, ) -> OrPat
pub fn box_pat(&self, pat: Pat) -> BoxPat
pub fn deref_pat(&self, pat: Pat) -> Pat
pub fn paren_pat(&self, pat: Pat) -> ParenPat
pub fn range_pat(&self, start: Option<Pat>, end: Option<Pat>) -> RangePat
pub fn ref_pat(&self, pat: Pat) -> RefPat
pub fn block_expr( &self, statements: impl IntoIterator<Item = Stmt>, tail_expr: Option<Expr>, ) -> BlockExpr
pub fn async_move_block_expr( &self, statements: impl IntoIterator<Item = Stmt>, tail_expr: Option<Expr>, ) -> BlockExpr
pub fn expr_empty_block(&self) -> BlockExpr
pub fn expr_paren(&self, expr: Expr) -> ParenExpr
pub fn expr_tuple(&self, fields: impl IntoIterator<Item = Expr>) -> TupleExpr
pub fn expr_assignment(&self, lhs: Expr, rhs: Expr) -> BinExpr
pub fn expr_bin(&self, lhs: Expr, op: BinaryOp, rhs: Expr) -> BinExpr
pub fn expr_literal(&self, text: &str) -> Literal
pub fn expr_path(&self, path: Path) -> Expr
pub fn expr_prefix(&self, op: SyntaxKind, expr: Expr) -> PrefixExpr
pub fn expr_call(&self, expr: Expr, arg_list: ArgList) -> CallExpr
pub fn expr_method_call( &self, receiver: Expr, method: NameRef, arg_list: ArgList, ) -> MethodCallExpr
pub fn arg_list(&self, args: impl IntoIterator<Item = Expr>) -> ArgList
pub fn expr_ref(&self, expr: Expr, exclusive: bool) -> Expr
pub fn expr_reborrow(&self, expr: Expr) -> Expr
pub fn expr_raw_ref(&self, expr: Expr, exclusive: bool) -> Expr
pub fn expr_closure( &self, pats: impl IntoIterator<Item = Param>, expr: Expr, ) -> ClosureExpr
pub fn expr_return(&self, expr: Option<Expr>) -> ReturnExpr
pub fn expr_underscore(&self) -> UnderscoreExpr
pub fn expr_if( &self, condition: Expr, then_branch: BlockExpr, else_branch: Option<ElseBranch>, ) -> IfExpr
pub fn expr_loop(&self, body: BlockExpr) -> LoopExpr
pub fn expr_while_loop(&self, condition: Expr, body: BlockExpr) -> WhileExpr
pub fn expr_for_loop( &self, pat: Pat, iterable: Expr, body: BlockExpr, ) -> ForExpr
pub fn expr_let(&self, pattern: Pat, expr: Expr) -> LetExpr
pub fn expr_stmt(&self, expr: Expr) -> ExprStmt
pub fn expr_match(&self, expr: Expr, match_arm_list: MatchArmList) -> MatchExpr
pub fn expr_macro(&self, path: Path, tt: TokenTree) -> MacroExpr
pub fn match_arm( &self, pat: Pat, guard: Option<MatchGuard>, expr: Expr, ) -> MatchArm
pub fn match_guard(&self, condition: Expr) -> MatchGuard
pub fn match_arm_list( &self, match_arms: impl IntoIterator<Item = MatchArm>, ) -> MatchArmList
pub fn let_stmt( &self, pattern: Pat, ty: Option<Type>, initializer: Option<Expr>, ) -> LetStmt
pub fn let_else_stmt( &self, pattern: Pat, ty: Option<Type>, initializer: Expr, diverging: BlockExpr, ) -> LetStmt
pub fn type_arg(&self, ty: Type) -> TypeArg
pub fn lifetime_arg(&self, lifetime: Lifetime) -> LifetimeArg
pub fn item_const( &self, attrs: impl IntoIterator<Item = Attr>, visibility: Option<Visibility>, name: Name, ty: Type, expr: Expr, ) -> Const
pub fn item_static( &self, visibility: Option<Visibility>, is_unsafe: bool, is_mut: bool, name: Name, ty: Type, expr: Option<Expr>, ) -> Static
pub fn param(&self, pat: Pat, ty: Type) -> Param
pub fn generic_arg_list( &self, generic_args: impl IntoIterator<Item = GenericArg>, is_turbo: bool, ) -> GenericArgList
pub fn record_expr(&self, path: Path, fields: RecordExprFieldList) -> RecordExpr
pub fn record_expr_field_list( &self, fields: impl IntoIterator<Item = RecordExprField>, ) -> RecordExprFieldList
pub fn record_expr_field( &self, name: NameRef, expr: Option<Expr>, ) -> RecordExprField
pub fn record_field_list( &self, fields: impl IntoIterator<Item = RecordField>, ) -> RecordFieldList
pub fn record_field( &self, visibility: Option<Visibility>, name: Name, ty: Type, ) -> RecordField
pub fn tuple_field_list( &self, fields: impl IntoIterator<Item = TupleField>, ) -> TupleFieldList
pub fn tuple_field( &self, visibility: Option<Visibility>, ty: Type, ) -> TupleField
pub fn item_enum( &self, attrs: impl IntoIterator<Item = Attr>, visibility: Option<Visibility>, name: Name, generic_param_list: Option<GenericParamList>, where_clause: Option<WhereClause>, variant_list: VariantList, ) -> Enum
pub fn variant_list( &self, variants: impl IntoIterator<Item = Variant>, ) -> VariantList
pub fn variant( &self, visibility: Option<Visibility>, name: Name, field_list: Option<FieldList>, discriminant: Option<Expr>, ) -> Variant
pub fn fn_( &self, attrs: impl IntoIterator<Item = Attr>, visibility: Option<Visibility>, fn_name: Name, type_params: Option<GenericParamList>, where_clause: Option<WhereClause>, params: ParamList, body: BlockExpr, ret_type: Option<RetType>, is_async: bool, is_const: bool, is_unsafe: bool, is_gen: bool, ) -> Fn
pub fn assoc_item_list( &self, items: impl IntoIterator<Item = AssocItem>, ) -> AssocItemList
pub fn assoc_item_list_empty(&self) -> AssocItemList
pub fn item_list(&self, items: impl IntoIterator<Item = Item>) -> ItemList
pub fn mod_(&self, name: Name, body: Option<ItemList>) -> Module
pub fn attr_outer(&self, meta: Meta) -> Attr
pub fn attr_inner(&self, meta: Meta) -> Attr
pub fn meta_token_tree(&self, path: Path, tt: TokenTree) -> Meta
pub fn cfg_flag(&self, flag: &str) -> CfgPredicate
pub fn cfg_attr_meta( &self, predicate: CfgPredicate, inner: impl IntoIterator<Item = Meta>, ) -> CfgAttrMeta
pub fn token_tree( &self, delimiter: SyntaxKind, tt: impl IntoIterator<Item = NodeOrToken<TokenTree, SyntaxToken<RustLanguage>>>, ) -> TokenTree
pub fn token(&self, kind: SyntaxKind) -> SyntaxToken<RustLanguage>
pub fn whitespace(&self, text: &str) -> SyntaxToken<RustLanguage>
pub fn ident(&self, text: &str) -> SyntaxToken<RustLanguage>
pub fn mut_self_param(&self) -> SelfParam
pub fn self_param(&self) -> SelfParam
pub fn impl_( &self, attrs: impl IntoIterator<Item = Attr>, generic_params: Option<GenericParamList>, generic_args: Option<GenericArgList>, path_type: Type, where_clause: Option<WhereClause>, body: Option<AssocItemList>, ) -> Impl
pub fn trait_( &self, is_unsafe: bool, ident: &str, generic_param_list: Option<GenericParamList>, where_clause: Option<WhereClause>, assoc_items: AssocItemList, ) -> Trait
pub fn ret_type(&self, ty: Type) -> RetType
pub fn ty_ref(&self, ty: Type, is_mut: bool) -> Type
pub fn field_from_idents<'a>( &self, parts: impl IntoIterator<Item = &'a str>, ) -> Option<Expr>
pub fn ty_name(&self, name: Name) -> Type
pub fn expr_await(&self, expr: Expr) -> AwaitExpr
pub fn expr_try(&self, expr: Expr) -> Expr
pub fn hacky_block_expr( &self, elements: impl IntoIterator<Item = NodeOrToken<SyntaxNode<RustLanguage>, SyntaxToken<RustLanguage>>>, tail_expr: Option<Expr>, ) -> BlockExpr
pub fn expr_break( &self, label: Option<Lifetime>, expr: Option<Expr>, ) -> BreakExpr
pub fn expr_continue(&self, label: Option<Lifetime>) -> ContinueExpr
Source§impl SyntaxFactory
impl SyntaxFactory
pub fn ident_path(&self, ident: &str) -> Path
pub fn path_from_idents<'a>( &self, parts: impl IntoIterator<Item = &'a str>, ) -> Option<Path>
pub fn token_tree_from_node(&self, node: &SyntaxNode<RustLanguage>) -> TokenTree
pub fn expr_unit(&self) -> Expr
pub fn ty_option(&self, t: Type) -> PathType
pub fn ty_result(&self, t: Type, e: Type) -> PathType
Source§impl SyntaxFactory
impl SyntaxFactory
Sourcepub fn without_mappings() -> SyntaxFactory
pub fn without_mappings() -> SyntaxFactory
Creates a SyntaxFactory without generating mappings.
Trait Implementations§
Source§impl Debug for SyntaxFactory
impl Debug for SyntaxFactory
Source§impl Default for SyntaxFactory
impl Default for SyntaxFactory
Source§fn default() -> SyntaxFactory
fn default() -> SyntaxFactory
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for SyntaxFactory
impl !RefUnwindSafe for SyntaxFactory
impl !Send for SyntaxFactory
impl !Sync for SyntaxFactory
impl !UnwindSafe for SyntaxFactory
impl Unpin for SyntaxFactory
impl UnsafeUnpin for SyntaxFactory
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
Mutably borrows from an owned value. Read more
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>
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 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>
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