Skip to content
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

fix(syntaxes): inject template tags to top-level source.ts #2058

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
.npmrc=974837034
pnpm-lock.yaml=1988059937
yarn.lock=448809282
package.json=-1818990980
package.json=-1372627236
pnpm-workspace.yaml=1711114604
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"source.ts"
],
"embeddedLanguages": {
"text.html": "html",
"text.html.derivative": "html",
"source.css": "css",
"source.js": "javascript"
}
Expand Down Expand Up @@ -174,12 +174,15 @@
{
"path": "./syntaxes/let-declaration.json",
"scopeName": "template.let.ng",
"injectTo": [ "text.html.derivative" ]
"injectTo": ["text.html.derivative"]
},
{
"path": "./syntaxes/template-tag.json",
"scopeName": "template.tag.ng",
"injectTo": ["text.html.derivative"]
"injectTo": [
"text.html.derivative",
"source.ts"
]
},
{
"path": "./syntaxes/expression.json",
Expand Down
5 changes: 1 addition & 4 deletions syntaxes/inline-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"name": "string"
}
},
"contentName": "text.html",
"contentName": "text.html.derivative",
"patterns": [
{
"include": "text.html.derivative"
Expand All @@ -73,9 +73,6 @@
{
"include": "template.blocks.ng"
},
{
"include": "template.tag.ng"
},
{
"include": "template.let.ng"
}
Expand Down
15 changes: 9 additions & 6 deletions syntaxes/src/inline-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ export const InlineTemplate: GrammarDefinition = {
// @ts-ignore
end: /\1/,
endCaptures: {0: {name: 'string'}},
contentName: 'text.html',
contentName: 'text.html.derivative',
patterns: [
{include: 'text.html.derivative'},
{include: 'template.ng'},
{include: 'template.blocks.ng'},
{include: 'template.tag.ng'},
{include: 'template.let.ng'},
{include: 'text.html.derivative'}, {include: 'template.ng'},
{include: 'template.blocks.ng'}, {include: 'template.let.ng'},
// note: template.tag.ng isn't used here and needs to be directly injected into source.ts
// scopes at the top level because it relies entirely on the injectionSelector to filter its
// matching out of non-html tag contexts. Since we don't have any scopes that match HTML
// tags, we rely entirely on the text.html.derivative pattern matching and apply the tag
// scope via injectionSelector only rather than being able to include it in a pattern list
// of another match.
]
}
}
Expand Down
18 changes: 9 additions & 9 deletions syntaxes/test/data/inline-template.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^^^^^^^^^^ inline-template.ng text.html
# ^^^^^^^^^^^ inline-template.ng text.html.derivative
# ^ inline-template.ng string
# ^^ inline-template.ng
>
Expand All @@ -25,7 +25,7 @@
# ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^^^^^^^^^^ inline-template.ng text.html
# ^^^^^^^^^^^ inline-template.ng text.html.derivative
# ^ inline-template.ng string
# ^^ inline-template.ng
> template: "<div></div>",
Expand All @@ -34,7 +34,7 @@
# ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^^^^^^^^^^ inline-template.ng text.html
# ^^^^^^^^^^^ inline-template.ng text.html.derivative
# ^ inline-template.ng string
# ^^ inline-template.ng
> template: '<div></div>',
Expand All @@ -43,7 +43,7 @@
# ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^^^^^^^^^^ inline-template.ng text.html
# ^^^^^^^^^^^ inline-template.ng text.html.derivative
# ^ inline-template.ng string
# ^^ inline-template.ng
>
Expand All @@ -60,7 +60,7 @@
# ^ inline-template.ng meta.brace.round.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^^^^^^^^^^ inline-template.ng text.html
# ^^^^^^^^^^^ inline-template.ng text.html.derivative
# ^ inline-template.ng string
# ^ inline-template.ng
# ^ inline-template.ng meta.brace.round.ts
Expand All @@ -77,7 +77,7 @@
# ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^^^^^^^^^^ inline-template.ng text.html
# ^^^^^^^^^^^ inline-template.ng text.html.derivative
# ^ inline-template.ng string
> /*
#^^^^^ inline-template.ng
Expand Down Expand Up @@ -108,9 +108,9 @@
# ^ inline-template.ng meta.object-literal.key.ts punctuation.separator.key-value.ts
# ^ inline-template.ng
# ^ inline-template.ng string
# ^^ inline-template.ng text.html punctuation.definition.block.ts
# ^^^^^^^^ inline-template.ng text.html expression.ng variable.other.readwrite.ts
# ^^ inline-template.ng text.html punctuation.definition.block.ts
# ^^ inline-template.ng text.html.derivative punctuation.definition.block.ts
# ^^^^^^^^ inline-template.ng text.html.derivative expression.ng variable.other.readwrite.ts
# ^^ inline-template.ng text.html.derivative punctuation.definition.block.ts
# ^ inline-template.ng string
# ^^ inline-template.ng
>})
Expand Down
Loading