Skip to content

Commit 63fa6e9

Browse files
authored
Merge pull request #91 from SublimeText/pr/various
Some illegal highlighting and comment fixes in JSON content
2 parents 09472d9 + 36124ea commit 63fa6e9

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

JSON (Terraform).sublime-syntax

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ contexts:
1515
- meta_prepend: true
1616
- include: Packages/Terraform/Terraform.sublime-syntax#string-interpolation
1717
- include: Packages/Terraform/Terraform.sublime-syntax#aws-acl
18+
19+
line-comments:
20+
- meta_append: true
21+
- include: Packages/Terraform/Terraform.sublime-syntax#inline-comments

Terraform.sublime-syntax

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ contexts:
160160
- include: functions
161161
- include: parens
162162
- include: identifiers
163+
- include: illegal-strays
163164

164165
comma:
165166
- match: \,
@@ -279,6 +280,9 @@ contexts:
279280
- match: \"
280281
scope: punctuation.definition.string.end.terraform
281282
pop: 1
283+
- match: \n
284+
scope: invalid.illegal.unclosed-string.terraform
285+
pop: 1
282286
- include: character-escapes
283287
- include: string-interpolation
284288
- include: aws-acl
@@ -514,7 +518,6 @@ contexts:
514518
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#collection-values
515519
object-value:
516520
- include: comments
517-
- include: expressions
518521
- match: \,
519522
comment: Pop scope on comma.
520523
scope: punctuation.separator.terraform
@@ -526,6 +529,7 @@ contexts:
526529
comment: Lookahead (don't consume) and pop scope on a bracket.
527530
scope: punctuation.section.braces.end.terraform
528531
pop: 1
532+
- include: expressions
529533

530534
# Attribute Access: "." Identifier
531535
#
@@ -689,6 +693,10 @@ contexts:
689693
- match: '{{identifier}}'
690694
scope: variable.other.readwrite.terraform
691695

696+
illegal-strays:
697+
- match: '[\])}]'
698+
scope: invalid.illegal.stray.python
699+
692700
# Blocks: Identifier (StringLit|Identifier)* "{" Newline Body "}" Newline;
693701
#
694702
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#structural-elements

tests/syntax_test_scope.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@
256256
# ^^^^^^^^^^ constant.character.escape.terraform
257257
# ^ punctuation.definition.string.end.terraform
258258

259+
/////
260+
// Unclosed strings
261+
/////
262+
263+
"
264+
# ^ meta.string.terraform string.quoted.double.terraform punctuation.definition.string.begin.terraform
265+
# ^ invalid.illegal.unclosed-string.terraform
266+
259267
/////////////////////////////////////////////////////////////////////
260268
// Identifiers
261269
/////////////////////////////////////////////////////////////////////
@@ -3386,6 +3394,8 @@ resource "aws_iam_role_policy" "attach-inline-policy-1" {
33863394
# ^^^^^^^^^^^^ meta.string.terraform string.quoted.double.terraform
33873395
# ^ punctuation.definition.string.begin.terraform
33883396
# ^ punctuation.definition.string.end.terraform
3397+
# comment
3398+
# ^^^^^^^^^^ comment.line.terraform
33893399
"Statement": [
33903400
#^^^^^^^^^^^^^^^^^^^^^ meta.block.body.terraform meta.function-call.arguments.terraform
33913401
#^^^^^^^ meta.braces.terraform
@@ -3395,6 +3405,8 @@ resource "aws_iam_role_policy" "attach-inline-policy-1" {
33953405
# ^^ meta.braces.terraform
33963406
# ^ punctuation.separator.key-value.json
33973407
# ^ meta.mapping.value.json meta.sequence.json punctuation.section.sequence.begin.json
3408+
# comment
3409+
# ^^^^^^^^^^ comment.line.terraform
33983410
{
33993411
"Action": [
34003412
"lambda:InvokeFunction",
@@ -3427,3 +3439,12 @@ resource "aws_iam_role_policy" "attach-inline-policy-1" {
34273439
]
34283440
})
34293441
}
3442+
3443+
]
3444+
# <- invalid.illegal.stray.python
3445+
3446+
}
3447+
# <- invalid.illegal.stray.python
3448+
3449+
)
3450+
# <- invalid.illegal.stray.python

0 commit comments

Comments
 (0)