-
-
Notifications
You must be signed in to change notification settings - Fork 4
finish migrating to tagspec v0.6.0 #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -163,7 +163,8 @@ | |||||||||||||||||||||||||||
| args_consumed = arg_index + 1; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| match arg { | ||||||||||||||||||||||||||||
| TagArg::Literal { lit, required } => { | ||||||||||||||||||||||||||||
| TagArg::Literal { lit, required, .. } => { | ||||||||||||||||||||||||||||
| // kind field is ignored for validation - it's only for semantic hints | ||||||||||||||||||||||||||||
| let matches_literal = bits[bit_index] == lit.as_ref(); | ||||||||||||||||||||||||||||
| if *required { | ||||||||||||||||||||||||||||
| if matches_literal { | ||||||||||||||||||||||||||||
|
|
@@ -257,6 +258,11 @@ | |||||||||||||||||||||||||||
| if token.contains('=') { | ||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| crate::templatetags::TokenCount::Greedy => { | ||||||||||||||||||||||||||||
| // Assignment arguments can appear as: | ||||||||||||||||||||||||||||
| // 1. Single token: var=value | ||||||||||||||||||||||||||||
| // 2. Multi-token: expr as varname | ||||||||||||||||||||||||||||
| // Consume until we find = or "as", or hit next literal | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
258
to
266
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the stray The inserted - if token.contains('=') {
- break;
- }
- crate::templatetags::TokenCount::Greedy => {
- // Assignment arguments can appear as:
- // 1. Single token: var=value
- // 2. Multi-token: expr as varname
- // Consume until we find = or "as", or hit next literal
-
- // If we hit "as", consume one more token (the variable name)
+ if token.contains('=') {
+ break;
+ }
+
+ // If we hit "as", consume one more token (the variable name)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| // If we hit "as", consume one more token (the variable name) | ||||||||||||||||||||||||||||
| if token == "as" { | ||||||||||||||||||||||||||||
|
|
@@ -449,16 +455,13 @@ | |||||||||||||||||||||||||||
| fn test_if_tag_with_comparison_operator() { | ||||||||||||||||||||||||||||
| // Issue #1: {% if message.input_tokens > 0 %} | ||||||||||||||||||||||||||||
| // Parser tokenizes as: ["message.input_tokens", ">", "0"] | ||||||||||||||||||||||||||||
| // Spec expects: [Expr{name="condition"}] | ||||||||||||||||||||||||||||
| // Spec expects: [Any{name="condition", count=Greedy}] | ||||||||||||||||||||||||||||
| let bits = vec![ | ||||||||||||||||||||||||||||
| "message.input_tokens".to_string(), | ||||||||||||||||||||||||||||
| ">".to_string(), | ||||||||||||||||||||||||||||
| "0".to_string(), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| let args = vec![TagArg::Expr { | ||||||||||||||||||||||||||||
| name: "condition".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }]; | ||||||||||||||||||||||||||||
| let args = vec![TagArg::expr("condition", true)]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let errors = check_validation_errors("if", &bits, &args); | ||||||||||||||||||||||||||||
| assert!( | ||||||||||||||||||||||||||||
|
|
@@ -494,22 +497,10 @@ | |||||||||||||||||||||||||||
| "reversed".to_string(), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| let args = vec![ | ||||||||||||||||||||||||||||
| TagArg::Var { | ||||||||||||||||||||||||||||
| name: "item".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::Literal { | ||||||||||||||||||||||||||||
| lit: "in".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::Var { | ||||||||||||||||||||||||||||
| name: "items".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::Literal { | ||||||||||||||||||||||||||||
| lit: "reversed".into(), | ||||||||||||||||||||||||||||
| required: false, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::var("item", true), | ||||||||||||||||||||||||||||
| TagArg::syntax("in", true), | ||||||||||||||||||||||||||||
| TagArg::var("items", true), | ||||||||||||||||||||||||||||
| TagArg::modifier("reversed", false), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let errors = check_validation_errors("for", &bits, &args); | ||||||||||||||||||||||||||||
|
|
@@ -527,10 +518,7 @@ | |||||||||||||||||||||||||||
| "and".to_string(), | ||||||||||||||||||||||||||||
| "user.is_staff".to_string(), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| let args = vec![TagArg::Expr { | ||||||||||||||||||||||||||||
| name: "condition".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }]; | ||||||||||||||||||||||||||||
| let args = vec![TagArg::expr("condition", true)]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let errors = check_validation_errors("if", &bits, &args); | ||||||||||||||||||||||||||||
| assert!( | ||||||||||||||||||||||||||||
|
|
@@ -567,10 +555,7 @@ | |||||||||||||||||||||||||||
| fn test_with_assignment() { | ||||||||||||||||||||||||||||
| // {% with total=items|length %} | ||||||||||||||||||||||||||||
| let bits = vec!["total=items|length".to_string()]; | ||||||||||||||||||||||||||||
| let args = vec![TagArg::Assignment { | ||||||||||||||||||||||||||||
| name: "bindings".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }]; | ||||||||||||||||||||||||||||
| let args = vec![TagArg::assignment("bindings", true)]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let errors = check_validation_errors("with", &bits, &args); | ||||||||||||||||||||||||||||
| assert!( | ||||||||||||||||||||||||||||
|
|
@@ -602,14 +587,8 @@ | |||||||||||||||||||||||||||
| "reversed".to_string(), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| let args = vec![ | ||||||||||||||||||||||||||||
| TagArg::Expr { | ||||||||||||||||||||||||||||
| name: "condition".into(), | ||||||||||||||||||||||||||||
| required: true, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::Literal { | ||||||||||||||||||||||||||||
| lit: "reversed".into(), | ||||||||||||||||||||||||||||
| required: false, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::expr("condition", true), | ||||||||||||||||||||||||||||
| TagArg::modifier("reversed", false), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let errors = check_validation_errors("if", &bits, &args); | ||||||||||||||||||||||||||||
|
|
@@ -769,18 +748,9 @@ | |||||||||||||||||||||||||||
| "library".to_string(), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| let args = vec![ | ||||||||||||||||||||||||||||
| TagArg::VarArgs { | ||||||||||||||||||||||||||||
| name: "tags".into(), | ||||||||||||||||||||||||||||
| required: false, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::Literal { | ||||||||||||||||||||||||||||
| lit: "from".into(), | ||||||||||||||||||||||||||||
| required: false, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::Var { | ||||||||||||||||||||||||||||
| name: "library".into(), | ||||||||||||||||||||||||||||
| required: false, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| TagArg::varargs("tags", false), | ||||||||||||||||||||||||||||
| TagArg::syntax("from", false), | ||||||||||||||||||||||||||||
| TagArg::var("library", false), | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let errors = check_validation_errors("load", &bits, &args); | ||||||||||||||||||||||||||||
|
|
@@ -810,4 +780,4 @@ | |||||||||||||||||||||||||||
| "Should error on extra argument after complete regroup args" | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Check failure on line 783 in crates/djls-semantic/src/semantic/args.rs
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ pub(crate) use specs::IntermediateTag; | |
| pub use specs::TagArg; | ||
| pub use specs::TagSpec; | ||
| pub use specs::TagSpecs; | ||
| pub use specs::TokenCount; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expose
pub use specs::TagArg;
pub use specs::TagSpec;
pub use specs::TagSpecs;
+pub use specs::LiteralKind;
pub use specs::TokenCount;
🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the
cargo fmtregression.CI’s
cargo fmtcheck is failing here because the newline before.into()doesn’t match rustfmt output. Please runcargo fmt(or collapse.into()onto the same line) so the lint job passes.📝 Committable suggestion
🤖 Prompt for AI Agents