From 9023d19d4d1d20a76fa498c0d33e165b1a4df79d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 12:24:35 +0100 Subject: [PATCH] Extend meta.expression scope This commit adds `.expression` sub-scope name to distinguish embedded interpolation expressions from control flow statements. --- NgxHTML.sublime-syntax | 10 +-- tests/syntax_test_scopes.component.html | 100 ++++++++++++------------ 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/NgxHTML.sublime-syntax b/NgxHTML.sublime-syntax index 2fa7686..f1fea55 100644 --- a/NgxHTML.sublime-syntax +++ b/NgxHTML.sublime-syntax @@ -85,7 +85,7 @@ contexts: - match: \" scope: meta.string.ngx string.quoted.double.ngx punctuation.definition.string.begin.ngx embed: ng-directive-expressions - embed_scope: meta.directive.value.ngx meta.string.ngx meta.interpolation.ngx source.ngx.embedded.html + embed_scope: meta.directive.value.ngx meta.string.ngx meta.embedded.expression.ngx source.ngx.embedded.html escape: \" escape_captures: 0: meta.string.ngx string.quoted.double.ngx punctuation.definition.string.end.ngx @@ -93,7 +93,7 @@ contexts: - match: \' scope: meta.string.ngx string.quoted.single.ngx punctuation.definition.string.begin.ngx embed: ng-directive-expressions - embed_scope: meta.directive.value.ngx meta.string.ngx meta.interpolation.ngx source.ngx.embedded.html + embed_scope: meta.directive.value.ngx meta.string.ngx meta.embedded.expression.ngx source.ngx.embedded.html escape: \' escape_captures: 0: meta.string.ngx string.quoted.single.ngx punctuation.definition.string.end.ngx @@ -297,14 +297,14 @@ contexts: ng-interpolations: - match: '{{' - scope: meta.embedded.ngx.html punctuation.section.embedded.begin.ngx.html + scope: meta.embedded.expression.ngx.html punctuation.section.embedded.begin.ngx.html push: ng-interpolation-body ng-interpolation-body: - meta_include_prototype: false - - meta_content_scope: meta.embedded.ngx.html source.ngx.embedded.html + - meta_content_scope: meta.embedded.expression.ngx.html source.ngx.embedded.html - match: '}}' - scope: meta.embedded.ngx.html punctuation.section.embedded.end.ngx.html + scope: meta.embedded.expression.ngx.html punctuation.section.embedded.end.ngx.html pop: 1 - include: ng-expressions diff --git a/tests/syntax_test_scopes.component.html b/tests/syntax_test_scopes.component.html index 0449ccb..ef3ebe1 100644 --- a/tests/syntax_test_scopes.component.html +++ b/tests/syntax_test_scopes.component.html @@ -160,9 +160,9 @@ {{ a }} is greater than {{ b }} - - - + + + @@ -184,9 +184,9 @@ {{ a() }} is less than {{ b.c() }} - - - + + + @@ -206,9 +206,9 @@ {{ a }} is equal to {{ b }} - - - + + + @@ -235,7 +235,7 @@ {{ startDate }} - + @@ -357,12 +357,12 @@ Item #{{ idx }}: {{ item.name }} - + - + @@ -390,7 +390,7 @@ - + @@ -489,7 +489,7 @@ {{ "\xAF \u2AFF \n \"" }} - + @@ -534,7 +534,7 @@ {{ { name: 'Alice', 'object': { array + "name": [0, 2, 3] } } }} - + @@ -607,7 +607,7 @@ {{ foo ? bar : baz }} - + @@ -618,7 +618,7 @@ {{ foo = null ?? 'default' }} - + @@ -631,7 +631,7 @@ {{ person['name'][0] = "Mirabel" }} - + @@ -650,20 +650,20 @@ {{ obj?.member }} - - - - + + + + {{ obj.member [5] }} - - - - + + + + @@ -672,10 +672,10 @@ {{ obj.method() }} - - - - + + + + @@ -685,10 +685,10 @@ {{ orders.value()?.[0]?.$extra?.#currency }} - - - - + + + + @@ -709,7 +709,7 @@ {{ func(arg, "value") }} - + @@ -723,7 +723,7 @@ {{ var | filter | annimation ("forward") }} - + @@ -757,7 +757,7 @@ - + @@ -776,7 +776,7 @@ - + @@ -801,7 +801,7 @@ - + @@ -820,7 +820,7 @@ - + @@ -845,7 +845,7 @@ - + @@ -868,7 +868,7 @@ - + @@ -892,7 +892,7 @@ - + @@ -916,7 +916,7 @@ - + @@ -932,7 +932,7 @@ - + @@ -949,7 +949,7 @@ - + @@ -971,7 +971,7 @@ - + @@ -987,7 +987,7 @@ - + @@ -999,7 +999,7 @@ - + @@ -1016,6 +1016,6 @@ - +