@@ -148,6 +148,40 @@ impl<'c, 'a: 'c> RuleFixer<'c, 'a> {
148
148
Fix :: new ( replacement, target)
149
149
}
150
150
151
+ /// Creates a fix command that inserts text before the given node.
152
+ pub fn insert_text_before < T : GetSpan , S : Into < Cow < ' a , str > > > (
153
+ self ,
154
+ target : & T ,
155
+ text : S ,
156
+ ) -> Fix < ' a > {
157
+ self . insert_text_before_range ( target. span ( ) , text)
158
+ }
159
+
160
+ /// Creates a fix command that inserts text before the specified range in the source text.
161
+ pub fn insert_text_before_range < S : Into < Cow < ' a , str > > > ( self , span : Span , text : S ) -> Fix < ' a > {
162
+ self . insert_text_at ( span. start , text)
163
+ }
164
+
165
+ /// Creates a fix command that inserts text after the given node.
166
+ pub fn insert_text_after < T : GetSpan , S : Into < Cow < ' a , str > > > (
167
+ self ,
168
+ target : & T ,
169
+ text : S ,
170
+ ) -> Fix < ' a > {
171
+ self . insert_text_after_range ( target. span ( ) , text)
172
+ }
173
+
174
+ /// Creates a fix command that inserts text after the specified range in the source text.
175
+ pub fn insert_text_after_range < S : Into < Cow < ' a , str > > > ( self , span : Span , text : S ) -> Fix < ' a > {
176
+ self . insert_text_at ( span. end , text)
177
+ }
178
+
179
+ /// Creates a fix command that inserts text at the specified index in the source text.
180
+ #[ allow( clippy:: unused_self) ]
181
+ fn insert_text_at < S : Into < Cow < ' a , str > > > ( self , index : u32 , text : S ) -> Fix < ' a > {
182
+ Fix :: new ( text, Span :: new ( index, index) )
183
+ }
184
+
151
185
#[ allow( clippy:: unused_self) ]
152
186
pub fn codegen ( self ) -> Codegen < ' a , false > {
153
187
Codegen :: < false > :: new ( )
0 commit comments