1-
2- use djls_semantic:: specs:: TagArg ;
3- use djls_semantic:: specs:: TagSpec ;
1+ use djls_semantic:: TagArg ;
2+ use djls_semantic:: TagSpec ;
43
54/// Generate an LSP snippet pattern from an array of arguments
65#[ must_use]
@@ -52,7 +51,7 @@ pub fn generate_snippet_from_args(args: &[TagArg]) -> String {
5251 }
5352 TagArg :: Choice { choices, .. } => {
5453 // Choice placeholders with options
55- let options: Vec < _ > = choices. iter ( ) . map ( |s| s . as_ref ( ) ) . collect ( ) ;
54+ let options: Vec < _ > = choices. iter ( ) . map ( std :: convert :: AsRef :: as_ref) . collect ( ) ;
5655 let result = format ! ( "${{{}|{}|}}" , placeholder_index, options. join( "," ) ) ;
5756 placeholder_index += 1 ;
5857 result
@@ -119,9 +118,8 @@ pub fn generate_partial_snippet(spec: &TagSpec, starting_from_position: usize) -
119118
120119#[ cfg( test) ]
121120mod tests {
122- use djls_semantic:: specs:: EndTag ;
123-
124121 use super :: * ;
122+ use djls_semantic:: EndTag ;
125123
126124 #[ test]
127125 fn test_snippet_for_for_tag ( ) {
@@ -192,20 +190,25 @@ mod tests {
192190
193191 #[ test]
194192 fn test_snippet_for_block_tag ( ) {
193+ use std:: borrow:: Cow ;
194+
195195 let spec = TagSpec {
196+ module : "django.template.loader_tags" . into ( ) ,
196197 end_tag : Some ( EndTag {
197198 name : "endblock" . into ( ) ,
198199 optional : false ,
199200 args : vec ! [ TagArg :: Var {
200201 name: "name" . into( ) ,
201202 required: false ,
202- } ] . into ( ) ,
203+ } ]
204+ . into ( ) ,
203205 } ) ,
204206 intermediate_tags : Cow :: Borrowed ( & [ ] ) ,
205207 args : vec ! [ TagArg :: Var {
206208 name: "name" . into( ) ,
207209 required: true ,
208- } ] . into ( ) ,
210+ } ]
211+ . into ( ) ,
209212 } ;
210213
211214 let snippet = generate_snippet_for_tag_with_end ( "block" , & spec) ;
@@ -214,7 +217,10 @@ mod tests {
214217
215218 #[ test]
216219 fn test_snippet_with_end_tag ( ) {
220+ use std:: borrow:: Cow ;
221+
217222 let spec = TagSpec {
223+ module : "django.template.defaulttags" . into ( ) ,
218224 end_tag : Some ( EndTag {
219225 name : "endautoescape" . into ( ) ,
220226 optional : false ,
@@ -225,7 +231,8 @@ mod tests {
225231 name: "mode" . into( ) ,
226232 required: true ,
227233 choices: vec![ "on" . into( ) , "off" . into( ) ] . into( ) ,
228- } ] . into ( ) ,
234+ } ]
235+ . into ( ) ,
229236 } ;
230237
231238 let snippet = generate_snippet_for_tag_with_end ( "autoescape" , & spec) ;
0 commit comments