rename missing_tag to missing_block

This commit is contained in:
danhanson committed 2026-09-13 05:46:41 -05:00
1 parent 2d7d0db471
commit 1648dc82f3
6 files changed
+753 -754

No files matched your search

+3 -3
View File
@@ -238,7 +238,7 @@ Fifteen external tokens, for the constraints a context-free grammar cannot expre
blocktranslate entry into its counted kind, which waits for `plural` before its end tag. `tag_groups` blocktranslate entry into its counted kind, which waits for `plural` before its end tag. `tag_groups`
holds each kind's opening name and the names that belong to it, and `group_names` **must stay in sync holds each kind's opening name and the names that belong to it, and `group_names` **must stay in sync
with `NAMES_INSIDE_A_TAG_GROUP`**. with `NAMES_INSIDE_A_TAG_GROUP`**.
- `_missing_tag` — the marker where a group's required tag is missing, aliased at each use to - `_missing_block` — the marker where a group's required tag block is missing, aliased at each use to
`missing_endX_block` or `missing_plural_block` (`MISSING_BLOCKS`). It is placed only at the end of `missing_endX_block` or `missing_plural_block` (`MISSING_BLOCKS`). It is placed only at the end of
input; before a tag whose name is reserved to some other group, which therefore cannot belong to this input; before a tag whose name is reserved to some other group, which therefore cannot belong to this
body; or before an `endblock`/`endpartialdef` naming a block further out than the innermost. It closes body; or before an `endblock`/`endpartialdef` naming a block further out than the innermost. It closes
@@ -274,7 +274,7 @@ Zero-width guards carry one hazard: `recover_with_missing` can supply one withou
during tree-sitter's mark-everything-valid recovery pass, so new guards go **below** it — and above the during tree-sitter's mark-everything-valid recovery pass, so new guards go **below** it — and above the
whitespace loop, which skips the separator the grammar still has to match. A guard must also never be valid whitespace loop, which skips the separator the grammar still has to match. A guard must also never be valid
where `content` is: a zero-width token at a content boundary preempts the internal lexer and `content` stops where `content` is: a zero-width token at a content boundary preempts the internal lexer and `content` stops
matching. `_missing_tag` is the one exception, and is safe only because it returns a token solely at the end matching. `_missing_block` is the one exception, and is safe only because it returns a token solely at the end
of input or at `{%`, where `content` cannot match. It is scanned above the raw-text scanners, which find of input or at `{%`, where `content` cannot match. It is scanned above the raw-text scanners, which find
nothing at the end of an empty body. nothing at the end of an empty body.
@@ -307,7 +307,7 @@ A branch that is also a `@local.scope` confines its bindings whichever way the b
`context.push()` as the loop body, so `empty_clause` is a scope alongside `for_clause`. `context.push()` as the loop body, so `empty_clause` is a scope alongside `for_clause`.
`queries/errors.scm` collects what an editor should report: `(ERROR)` as `@error.syntax`, `(MISSING)` as `queries/errors.scm` collects what an editor should report: `(ERROR)` as `@error.syntax`, `(MISSING)` as
`@error.missing`, and every missing-tag marker as `@error.missing_tag`. A tree holding only markers has `@error.missing`, and every missing-tag marker as `@error.missing_block`. A tree holding only markers has
no `has_error`, so a tool that checks that flag alone misses them. Adding a tag group means adding its no `has_error`, so a tool that checks that flag alone misses them. Adding a tag group means adding its
marker there, since no supertype matches them all. marker there, since no supertype matches them all.
+1 -1
View File
@@ -62,7 +62,7 @@ Five of the files in `queries/` are query files an editor loads:
the HTML around the tags can be parsed by its own grammar. It names no language, leaving the editor to the HTML around the tags can be parsed by its own grammar. It names no language, leaving the editor to
supply one. supply one.
- **`errors.scm`** — what to report as a problem: `(ERROR)` as `@error.syntax`, tree-sitter's own - **`errors.scm`** — what to report as a problem: `(ERROR)` as `@error.syntax`, tree-sitter's own
`(MISSING)` as `@error.missing`, and `@error.missing_tag` for the marker placed where a group's required `(MISSING)` as `@error.missing`, and `@error.missing_block` for the marker placed where a group's required
tag is missing. An unterminated `{% if a %}x` parses as an `if_group` ending in a zero-width tag is missing. An unterminated `{% if a %}x` parses as an `if_group` ending in a zero-width
`missing_endif_block` rather than as an `ERROR`, so completion and the scope queries keep working while `missing_endif_block` rather than as an `ERROR`, so completion and the scope queries keep working while
a template is being written — and the tree reports no error of its own, so this query is how to find a template is being written — and the tree reports no error of its own, so this query is how to find
+20 -20
View File
@@ -263,7 +263,7 @@ function blocktransRules(tag) {
optional($._translate_body), optional($._translate_body),
choice( choice(
$.plural_clause, $.plural_clause,
alias($._missing_tag, $.missing_plural_block), alias($._missing_block, $.missing_plural_block),
), ),
), ),
), ),
@@ -481,7 +481,7 @@ const django = grammar({
$._tag_open, $._tag_open,
$._bt_option, $._bt_option,
$._kwarg_name, $._kwarg_name,
$._missing_tag, $._missing_block,
$._group_open, $._group_open,
$._group_close, $._group_close,
], ],
@@ -684,7 +684,7 @@ const django = grammar({
$.autoescape_clause, $.autoescape_clause,
choice( choice(
$.endautoescape_block, $.endautoescape_block,
alias($._missing_tag, $.missing_endautoescape_block), alias($._missing_block, $.missing_endautoescape_block),
), ),
), ),
// the scanner takes the whitespace before a name it has to match itself // the scanner takes the whitespace before a name it has to match itself
@@ -696,7 +696,7 @@ const django = grammar({
$.block_clause, $.block_clause,
choice( choice(
$.endblock_block, $.endblock_block,
alias($._missing_tag, $.missing_endblock_block), alias($._missing_block, $.missing_endblock_block),
), ),
), ),
plural_block: ($) => groupBlock($._group_close, "plural"), plural_block: ($) => groupBlock($._group_close, "plural"),
@@ -709,14 +709,14 @@ const django = grammar({
$.blocktrans_clause, $.blocktrans_clause,
choice( choice(
$.endblocktrans_block, $.endblocktrans_block,
alias($._missing_tag, $.missing_endblocktrans_block), alias($._missing_block, $.missing_endblocktrans_block),
), ),
), ),
seq( seq(
$.blocktranslate_clause, $.blocktranslate_clause,
choice( choice(
$.endblocktranslate_block, $.endblocktranslate_block,
alias($._missing_tag, $.missing_endblocktranslate_block), alias($._missing_block, $.missing_endblocktranslate_block),
), ),
), ),
), ),
@@ -780,7 +780,7 @@ const django = grammar({
$.cache_clause, $.cache_clause,
choice( choice(
$.endcache_block, $.endcache_block,
alias($._missing_tag, $.missing_endcache_block), alias($._missing_block, $.missing_endcache_block),
), ),
), ),
comment_block: ($) => comment_block: ($) =>
@@ -792,7 +792,7 @@ const django = grammar({
$.comment_clause, $.comment_clause,
choice( choice(
$.endcomment_block, $.endcomment_block,
alias($._missing_tag, $.missing_endcomment_block), alias($._missing_block, $.missing_endcomment_block),
), ),
), ),
// csp_nonce_attr(context, media=None) // csp_nonce_attr(context, media=None)
@@ -835,7 +835,7 @@ const django = grammar({
$.filter_clause, $.filter_clause,
choice( choice(
$.endfilter_block, $.endfilter_block,
alias($._missing_tag, $.missing_endfilter_block), alias($._missing_block, $.missing_endfilter_block),
), ),
), ),
firstof_block: ($) => firstof_block: ($) =>
@@ -880,7 +880,7 @@ const django = grammar({
seq( seq(
$.for_clause, $.for_clause,
optional($.empty_clause), optional($.empty_clause),
choice($.endfor_block, alias($._missing_tag, $.missing_endfor_block)), choice($.endfor_block, alias($._missing_block, $.missing_endfor_block)),
), ),
/** /**
* django.templatetags.i18n. Each of these requires exactly "as <name>", * django.templatetags.i18n. Each of these requires exactly "as <name>",
@@ -924,7 +924,7 @@ const django = grammar({
$.if_clause, $.if_clause,
repeat($.elif_clause), repeat($.elif_clause),
optional($.else_clause), optional($.else_clause),
choice($.endif_block, alias($._missing_tag, $.missing_endif_block)), choice($.endif_block, alias($._missing_block, $.missing_endif_block)),
), ),
ifchanged_block: ($) => ifchanged_block: ($) =>
groupBlock($._group_open, "ifchanged", repeat(part($.filtered_value))), groupBlock($._group_open, "ifchanged", repeat(part($.filtered_value))),
@@ -936,7 +936,7 @@ const django = grammar({
optional($.else_clause), optional($.else_clause),
choice( choice(
$.endifchanged_block, $.endifchanged_block,
alias($._missing_tag, $.missing_endifchanged_block), alias($._missing_block, $.missing_endifchanged_block),
), ),
), ),
/** /**
@@ -964,7 +964,7 @@ const django = grammar({
$.language_clause, $.language_clause,
choice( choice(
$.endlanguage_block, $.endlanguage_block,
alias($._missing_tag, $.missing_endlanguage_block), alias($._missing_block, $.missing_endlanguage_block),
), ),
), ),
library: ($) => seq($.identifier, optional(seq(".", $.identifier))), library: ($) => seq($.identifier, optional(seq(".", $.identifier))),
@@ -993,7 +993,7 @@ const django = grammar({
$.localize_clause, $.localize_clause,
choice( choice(
$.endlocalize_block, $.endlocalize_block,
alias($._missing_tag, $.missing_endlocalize_block), alias($._missing_block, $.missing_endlocalize_block),
), ),
), ),
/** django.templatetags.tz, taking "on" or "off" as localize does. */ /** django.templatetags.tz, taking "on" or "off" as localize does. */
@@ -1010,7 +1010,7 @@ const django = grammar({
$.localtime_clause, $.localtime_clause,
choice( choice(
$.endlocaltime_block, $.endlocaltime_block,
alias($._missing_tag, $.missing_endlocaltime_block), alias($._missing_block, $.missing_endlocaltime_block),
), ),
), ),
lorem_block: ($) => lorem_block: ($) =>
@@ -1031,7 +1031,7 @@ const django = grammar({
$.partialdef_clause, $.partialdef_clause,
choice( choice(
$.endpartialdef_block, $.endpartialdef_block,
alias($._missing_tag, $.missing_endpartialdef_block), alias($._missing_block, $.missing_endpartialdef_block),
), ),
), ),
// querystring(context, *args, **kwargs) // querystring(context, *args, **kwargs)
@@ -1053,7 +1053,7 @@ const django = grammar({
$.spaceless_clause, $.spaceless_clause,
choice( choice(
$.endspaceless_block, $.endspaceless_block,
alias($._missing_tag, $.missing_endspaceless_block), alias($._missing_block, $.missing_endspaceless_block),
), ),
), ),
static_block: ($) => static_block: ($) =>
@@ -1084,7 +1084,7 @@ const django = grammar({
$.timezone_clause, $.timezone_clause,
choice( choice(
$.endtimezone_block, $.endtimezone_block,
alias($._missing_tag, $.missing_endtimezone_block), alias($._missing_block, $.missing_endtimezone_block),
), ),
), ),
/** /**
@@ -1129,7 +1129,7 @@ const django = grammar({
$.verbatim_clause, $.verbatim_clause,
choice( choice(
$.endverbatim_block, $.endverbatim_block,
alias($._missing_tag, $.missing_endverbatim_block), alias($._missing_block, $.missing_endverbatim_block),
), ),
), ),
widthratio_block: ($) => widthratio_block: ($) =>
@@ -1147,7 +1147,7 @@ const django = grammar({
with_group: ($) => with_group: ($) =>
seq( seq(
$.with_clause, $.with_clause,
choice($.endwith_block, alias($._missing_tag, $.missing_endwith_block)), choice($.endwith_block, alias($._missing_block, $.missing_endwith_block)),
), ),
}, },
}); });
+4 -5
View File
@@ -6,10 +6,9 @@
; Such a tree has no error of its own (ts_node_has_error is false), so a tool ; Such a tree has no error of its own (ts_node_has_error is false), so a tool
; has to run this query to find them. ; has to run this query to find them.
; ;
; @error.syntax input the grammar could not parse ; @error.syntax input the grammar could not parse
; @error.missing a token that tree-sitter's error recovery inserted ; @error.missing a token that tree-sitter's error recovery inserted
; @error.missing_tag a tag its group requires, absent where the marker is; ; @error.missing_block expected tag block is missing
; the marker's type names the tag
; ;
; The markers are listed one by one, as MISSING_BLOCKS in grammar.js: the ; The markers are listed one by one, as MISSING_BLOCKS in grammar.js: the
; generator drops a supertype whose members are aliases, so there is no single ; generator drops a supertype whose members are aliases, so there is no single
@@ -39,4 +38,4 @@
(missing_endtimezone_block) (missing_endtimezone_block)
(missing_endverbatim_block) (missing_endverbatim_block)
(missing_endwith_block) (missing_endwith_block)
(missing_plural_block)] @error.missing_tag (missing_plural_block)] @error.missing_block
+21 -21
View File
@@ -1515,7 +1515,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endautoescape_block" "value": "missing_endautoescape_block"
@@ -1665,7 +1665,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endblock_block" "value": "missing_endblock_block"
@@ -1939,7 +1939,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_plural_block" "value": "missing_plural_block"
@@ -2194,7 +2194,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_plural_block" "value": "missing_plural_block"
@@ -2275,7 +2275,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endblocktrans_block" "value": "missing_endblocktrans_block"
@@ -2302,7 +2302,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endblocktranslate_block" "value": "missing_endblocktranslate_block"
@@ -2741,7 +2741,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endcache_block" "value": "missing_endcache_block"
@@ -2908,7 +2908,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endcomment_block" "value": "missing_endcomment_block"
@@ -3631,7 +3631,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endfilter_block" "value": "missing_endfilter_block"
@@ -4152,7 +4152,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endfor_block" "value": "missing_endfor_block"
@@ -5143,7 +5143,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endif_block" "value": "missing_endif_block"
@@ -5317,7 +5317,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endifchanged_block" "value": "missing_endifchanged_block"
@@ -5666,7 +5666,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endlanguage_block" "value": "missing_endlanguage_block"
@@ -5985,7 +5985,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endlocalize_block" "value": "missing_endlocalize_block"
@@ -6161,7 +6161,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endlocaltime_block" "value": "missing_endlocaltime_block"
@@ -6587,7 +6587,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endpartialdef_block" "value": "missing_endpartialdef_block"
@@ -7057,7 +7057,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endspaceless_block" "value": "missing_endspaceless_block"
@@ -7403,7 +7403,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endtimezone_block" "value": "missing_endtimezone_block"
@@ -8765,7 +8765,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endverbatim_block" "value": "missing_endverbatim_block"
@@ -9041,7 +9041,7 @@
"type": "ALIAS", "type": "ALIAS",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
"named": true, "named": true,
"value": "missing_endwith_block" "value": "missing_endwith_block"
@@ -9179,7 +9179,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_missing_tag" "name": "_missing_block"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
+704 -704
View File
File diff suppressed because it is too large. Load diff