Skip to content

Commit e265ed1

Browse files
lippy
1 parent e4ee797 commit e265ed1

File tree

3 files changed

+61
-64
lines changed

3 files changed

+61
-64
lines changed

crates/djls-ide/src/snippets.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,10 @@ mod tests {
183183
end_tag: Some(EndTag {
184184
name: "endblock".into(),
185185
required: true,
186-
args: vec![TagArg::var("name", false)]
187-
.into(),
186+
args: vec![TagArg::var("name", false)].into(),
188187
}),
189188
intermediate_tags: Cow::Borrowed(&[]),
190-
args: vec![TagArg::var("name", true)]
191-
.into(),
189+
args: vec![TagArg::var("name", true)].into(),
192190
};
193191

194192
let snippet = generate_snippet_for_tag_with_end("block", &spec);

crates/djls-semantic/src/templatetags/builtins.rs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ static DEFAULTTAGS_PAIRS: &[(&str, &TagSpec)] = &[
192192
IntermediateTag {
193193
name: B("elif"),
194194
args: B(&[TagArg::Any {
195-
name: B("condition"),
196-
required: true,
197-
count: TokenCount::Greedy,
198-
}]),
195+
name: B("condition"),
196+
required: true,
197+
count: TokenCount::Greedy,
198+
}]),
199199
},
200200
IntermediateTag {
201201
name: B("else"),
@@ -477,10 +477,10 @@ static LOADER_TAGS_PAIRS: &[(&str, &TagSpec)] = &[
477477
}),
478478
intermediate_tags: B(&[]),
479479
args: B(&[TagArg::Variable {
480-
name: B("name"),
481-
required: true,
482-
count: TokenCount::Exact(1),
483-
}]),
480+
name: B("name"),
481+
required: true,
482+
count: TokenCount::Exact(1),
483+
}]),
484484
},
485485
),
486486
(
@@ -538,15 +538,15 @@ static CACHE_PAIRS: &[(&str, &TagSpec)] = &[(
538538
intermediate_tags: B(&[]),
539539
args: B(&[
540540
TagArg::Variable {
541-
name: B("timeout"),
542-
required: true,
543-
count: TokenCount::Exact(1),
544-
},
541+
name: B("timeout"),
542+
required: true,
543+
count: TokenCount::Exact(1),
544+
},
545545
TagArg::Variable {
546-
name: B("cache_key"),
547-
required: true,
548-
count: TokenCount::Exact(1),
549-
},
546+
name: B("cache_key"),
547+
required: true,
548+
count: TokenCount::Exact(1),
549+
},
550550
TagArg::VarArgs {
551551
name: B("variables"),
552552
required: false,
@@ -595,35 +595,35 @@ static I18N_PAIRS: &[(&str, &TagSpec)] = &[
595595
const BLOCKTRANS_INTERMEDIATE_TAGS: &[IntermediateTag] = &[IntermediateTag {
596596
name: B("plural"),
597597
args: B(&[TagArg::Variable {
598-
name: B("count"),
599-
required: false,
600-
count: TokenCount::Exact(1),
601-
}]),
598+
name: B("count"),
599+
required: false,
600+
count: TokenCount::Exact(1),
601+
}]),
602602
}];
603603
const BLOCKTRANS_ARGS: &[TagArg] = &[
604604
TagArg::String {
605605
name: B("context"),
606606
required: false,
607607
},
608608
TagArg::Literal {
609-
lit: B("with"),
610-
required: false,
611-
kind: LiteralKind::Syntax,
612-
},
609+
lit: B("with"),
610+
required: false,
611+
kind: LiteralKind::Syntax,
612+
},
613613
TagArg::VarArgs {
614614
name: B("assignments"),
615615
required: false,
616616
},
617617
TagArg::Literal {
618-
lit: B("asvar"),
619-
required: false,
620-
kind: LiteralKind::Literal,
621-
},
618+
lit: B("asvar"),
619+
required: false,
620+
kind: LiteralKind::Literal,
621+
},
622622
TagArg::Variable {
623-
name: B("varname"),
624-
required: false,
625-
count: TokenCount::Exact(1),
626-
},
623+
name: B("varname"),
624+
required: false,
625+
count: TokenCount::Exact(1),
626+
},
627627
];
628628
const TRANS_SPEC: TagSpec = TagSpec {
629629
module: B(I18N_MOD),
@@ -639,20 +639,20 @@ const TRANS_SPEC: TagSpec = TagSpec {
639639
required: false,
640640
},
641641
TagArg::Literal {
642-
lit: B("as"),
643-
required: false,
644-
kind: LiteralKind::Syntax,
645-
},
642+
lit: B("as"),
643+
required: false,
644+
kind: LiteralKind::Syntax,
645+
},
646646
TagArg::Variable {
647-
name: B("varname"),
648-
required: false,
649-
count: TokenCount::Exact(1),
650-
},
647+
name: B("varname"),
648+
required: false,
649+
count: TokenCount::Exact(1),
650+
},
651651
TagArg::Literal {
652-
lit: B("noop"),
653-
required: false,
654-
kind: LiteralKind::Literal,
655-
},
652+
lit: B("noop"),
653+
required: false,
654+
kind: LiteralKind::Literal,
655+
},
656656
]),
657657
};
658658

@@ -724,10 +724,10 @@ static TZ_PAIRS: &[(&str, &TagSpec)] = &[
724724
}),
725725
intermediate_tags: B(&[]),
726726
args: B(&[TagArg::Variable {
727-
name: B("timezone"),
728-
required: true,
729-
count: TokenCount::Exact(1),
730-
}]),
727+
name: B("timezone"),
728+
required: true,
729+
count: TokenCount::Exact(1),
730+
}]),
731731
},
732732
),
733733
];

crates/djls-semantic/src/templatetags/specs.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum TokenCount {
2424

2525
/// Semantic classification for literal arguments.
2626
///
27-
/// All three map to TagArg::Literal but provide semantic hints
27+
/// All three map to `TagArg::Literal` but provide semantic hints
2828
/// for better diagnostics and IDE features.
2929
#[derive(Debug, Clone, PartialEq)]
3030
pub enum LiteralKind {
@@ -271,10 +271,7 @@ pub enum TagArg {
271271
count: TokenCount,
272272
},
273273
/// String literal argument (no direct v0.6.0 equivalent, implementation detail)
274-
String {
275-
name: S,
276-
required: bool,
277-
},
274+
String { name: S, required: bool },
278275
/// Literal token with semantic classification (kind = "literal", "syntax", or "modifier")
279276
Literal {
280277
lit: S,
@@ -294,10 +291,7 @@ pub enum TagArg {
294291
count: TokenCount,
295292
},
296293
/// Consumes all remaining tokens (implementation detail)
297-
VarArgs {
298-
name: S,
299-
required: bool,
300-
},
294+
VarArgs { name: S, required: bool },
301295
/// Choice from specific literals (kind = "choice")
302296
Choice {
303297
name: S,
@@ -341,7 +335,7 @@ impl TagArg {
341335
}
342336
}
343337

344-
/// Create an Any argument with greedy token consumption (replaces old expr())
338+
/// Create an Any argument with greedy token consumption (replaces old `expr()`)
345339
pub fn expr(name: impl Into<S>, required: bool) -> Self {
346340
Self::Any {
347341
name: name.into(),
@@ -384,7 +378,7 @@ impl TagArg {
384378
}
385379
}
386380

387-
/// Create a Variable argument with single token consumption (replaces old var())
381+
/// Create a Variable argument with single token consumption (replaces old `var()`)
388382
pub fn var(name: impl Into<S>, required: bool) -> Self {
389383
Self::Variable {
390384
name: name.into(),
@@ -890,7 +884,12 @@ mod tests {
890884
};
891885
let arg = TagArg::from(var_arg_def);
892886
assert!(matches!(arg, TagArg::Variable { .. }));
893-
if let TagArg::Variable { name, required, count } = arg {
887+
if let TagArg::Variable {
888+
name,
889+
required,
890+
count,
891+
} = arg
892+
{
894893
assert_eq!(name.as_ref(), "test_arg");
895894
assert!(required);
896895
// count is None in spec, so should be Greedy

0 commit comments

Comments
 (0)