Skip to content

Commit 7fde24a

Browse files
Support more binary assignment operators in templates (#39)
* Support more binary assignment operators in templates angular/angular#62064 @deathaxe does this look about right? * add test * update precedence * Update NgxHTML.sublime-syntax Co-authored-by: deathaxe <[email protected]> * Update NgxHTML.sublime-syntax * augmented * test augmented * test output with assignment * fix test * test output with augmented assignment * expand selection --------- Co-authored-by: deathaxe <[email protected]>
1 parent 6947919 commit 7fde24a

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

NgxHTML.sublime-syntax

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ contexts:
552552
scope: punctuation.separator.sequence.ngx
553553
- match: ';'
554554
scope: punctuation.terminator.expression.ngx
555+
- match: (?:\*\*|&&|\|\||\?\?|[-+*/%])=
556+
scope: keyword.operator.assignment.augmented.ngx
555557
- match: '[!=]==?|[<>]=?'
556558
scope: keyword.operator.comparison.ngx
557559
- match: '\*\*|[-+*/%]'

tests/syntax_test_scopes.component.html

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@
752752
https://angular.dev/guide/templates/expression-syntax#what-operators-are-supported
753753
-->
754754

755-
{{ - + * / % === !== == != = < <= >= > && || ! ?? ** }}
755+
{{ - + * / % === !== == != = < <= >= > && || ! ?? ** += -= *= /= &&= ||= ??= **= }}
756756
<!-- ^ keyword.operator.arithmetic.ngx -->
757757
<!-- ^ keyword.operator.arithmetic.ngx -->
758758
<!-- ^ keyword.operator.arithmetic.ngx -->
@@ -772,6 +772,14 @@
772772
<!-- ^ keyword.operator.logical.ngx -->
773773
<!-- ^^ keyword.operator.null-coalescing.ngx -->
774774
<!-- ^^ keyword.operator.arithmetic.ngx -->
775+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
776+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
777+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
778+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
779+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
780+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
781+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
782+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
775783

776784
<!-- ternary -->
777785
{{ foo ? bar : baz }}
@@ -1092,6 +1100,62 @@
10921100
<!-- ^ string.quoted.double.ngx punctuation.definition.string.end.ngx -->
10931101
<!-- ^ punctuation.definition.tag.end.html -->
10941102

1103+
<div (output)="var = exp" >
1104+
<!--^^^^^^^^^^^^^^^^^^^^^^^ meta.tag -->
1105+
<!-- ^^^^^^^^ meta.directive.on.ngx -->
1106+
<!-- ^ meta.directive.ngx -->
1107+
<!-- ^^^^^^^^^^^ meta.directive.value.ngx meta.string.ngx -->
1108+
<!-- ^ punctuation.definition.on.begin.ngx -->
1109+
<!-- ^^^^^^ entity.other.attribute-name.on.ngx -->
1110+
<!-- ^ punctuation.definition.on.end.ngx -->
1111+
<!-- ^ punctuation.separator.key-value.ngx -->
1112+
<!-- ^ string.quoted.double.ngx punctuation.definition.string.begin.ngx -->
1113+
<!-- ^^^^^^^^^ meta.embedded.expression.ngx source.ngx.embedded.html - string -->
1114+
<!-- ^^^ variable.other.readwrite.ngx -->
1115+
<!-- ^ keyword.operator.assignment.ngx -->
1116+
<!-- ^^^ variable.other.readwrite.ngx -->
1117+
<!-- ^ string.quoted.double.ngx punctuation.definition.string.end.ngx -->
1118+
<!-- ^ punctuation.definition.tag.end.html -->
1119+
1120+
1121+
<div (output)="var += exp" >
1122+
<!--^^^^^^^^^^^^^^^^^^^^^^^ meta.tag -->
1123+
<!-- ^^^^^^^^ meta.directive.on.ngx -->
1124+
<!-- ^ meta.directive.ngx -->
1125+
<!-- ^^^^^^^^^^^^ meta.directive.value.ngx meta.string.ngx -->
1126+
<!-- ^ punctuation.definition.on.begin.ngx -->
1127+
<!-- ^^^^^^ entity.other.attribute-name.on.ngx -->
1128+
<!-- ^ punctuation.definition.on.end.ngx -->
1129+
<!-- ^ punctuation.separator.key-value.ngx -->
1130+
<!-- ^ string.quoted.double.ngx punctuation.definition.string.begin.ngx -->
1131+
<!-- ^^^^^^^^^^ meta.embedded.expression.ngx source.ngx.embedded.html - string -->
1132+
<!-- ^^^ variable.other.readwrite.ngx -->
1133+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
1134+
<!-- ^^^ variable.other.readwrite.ngx -->
1135+
<!-- ^ string.quoted.double.ngx punctuation.definition.string.end.ngx -->
1136+
<!-- ^ punctuation.definition.tag.end.html -->
1137+
1138+
<div (output)="var -= exp" >
1139+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
1140+
1141+
<div (output)="var *= exp" >
1142+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
1143+
1144+
<div (output)="var /= exp" >
1145+
<!-- ^^ keyword.operator.assignment.augmented.ngx -->
1146+
1147+
<div (output)="var &&= exp" >
1148+
<!-- ^^^ keyword.operator.assignment.augmented.ngx -->
1149+
1150+
<div (output)="var ||= exp" >
1151+
<!-- ^^^ keyword.operator.assignment.augmented.ngx -->
1152+
1153+
<div (output)="var ??= exp" >
1154+
<!-- ^^^ keyword.operator.assignment.augmented.ngx -->
1155+
1156+
<div (output)="var **= exp" >
1157+
<!-- ^^^ keyword.operator.assignment.augmented.ngx -->
1158+
10951159
<div (@animation.event)="exp + res / ion" >
10961160
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag -->
10971161
<!-- ^^^^^^^^^^^^^^^^^^ meta.directive.on.ngx -->

0 commit comments

Comments
 (0)