Skip to content

Commit

Permalink
[JSON] Remove special handling of empty arrays/objects
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Dec 4, 2021
1 parent 5202263 commit d6a5b30
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
16 changes: 0 additions & 16 deletions JSON/JSON (Basic).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ contexts:
####[ Sequence ]########################################################################################################

arrays:
- include: empty-arrays
- match: \[
scope: punctuation.definition.sequence.begin.json
push:
Expand Down Expand Up @@ -263,31 +262,16 @@ contexts:
- match: (?=\S)
pop: 1

empty-arrays:
- match: (\[)\s*(\])
scope: meta.sequence.list.empty.json
captures:
1: punctuation.definition.sequence.begin.json
2: punctuation.definition.sequence.end.json

####[ Mapping ]#########################################################################################################

# FIXME: leading separators
# FIXME: trailing commas

objects:
- include: empty-object
- match: \{
scope: punctuation.definition.mapping.begin.json
push: object-body

empty-object:
- match: (\{)\s*(\})
scope: meta.mapping.empty.json
captures:
1: punctuation.definition.mapping.begin.json
2: punctuation.definition.mapping.end.json

object-body:
- meta_scope: meta.mapping.json
- match: \}
Expand Down
8 changes: 4 additions & 4 deletions JSON/tests/syntax/syntax_test_json5.meta.mapping.json5
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^ meta.mapping.value
// ^^ - meta.mapping meta.mapping.value
// ^^ meta.mapping.value meta.sequence.list.empty
// ^^ meta.mapping.value meta.sequence.list
// ^ punctuation.definition.sequence.begin
// ^ punctuation.definition.sequence.end

Expand All @@ -73,7 +73,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^ meta.mapping.value
// ^^^ - meta.mapping meta.mapping.value
// ^^^ meta.mapping.value meta.sequence.list.empty
// ^^^ meta.mapping.value meta.sequence.list
// ^ punctuation.definition.sequence.begin
// ^ punctuation.definition.sequence.end

Expand All @@ -92,7 +92,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^ meta.mapping.value
// ^^ - meta.mapping meta.mapping.value
// ^^ meta.mapping.value meta.mapping.empty
// ^^ meta.mapping.value meta.mapping
// ^ punctuation.definition.mapping.begin
// ^ punctuation.definition.mapping.end

Expand All @@ -102,7 +102,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^ meta.mapping.value
// ^^^ - meta.mapping meta.mapping.value
// ^^^ meta.mapping.value meta.mapping.empty
// ^^^ meta.mapping.value meta.mapping
// ^ punctuation.definition.mapping.begin
// ^ punctuation.definition.mapping.end

Expand Down
8 changes: 4 additions & 4 deletions JSON/tests/syntax/syntax_test_json5.meta.sequence.json5
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
// ^^^^^^^ string.quoted.single

[],
// ^^ meta.sequence.list.empty
// ^^ meta.sequence.list

[ ],
// ^^^ meta.sequence.list.empty
// ^^^ meta.sequence.list

[1, 2, 3],
// ^^^^^^^^^ meta.sequence.list
Expand All @@ -44,10 +44,10 @@
// ^ punctuation.definition.sequence.end
// ^ punctuation.separator.sequence
{},
// ^^ meta.mapping.empty
// ^^ meta.mapping

{ },
// ^^^ meta.mapping.empty
// ^^^ meta.mapping

{ "a": 1, "b": 2, "c": 3 },
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping
Expand Down
8 changes: 4 additions & 4 deletions JSON/tests/syntax/syntax_test_jsonc.meta.mapping.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^ meta.mapping.value
// ^^ - meta.mapping meta.mapping.value
// ^^ meta.mapping.value meta.sequence.list.empty
// ^^ meta.mapping.value meta.sequence.list
// ^ punctuation.definition.sequence.begin
// ^ punctuation.definition.sequence.end

Expand All @@ -39,7 +39,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^ meta.mapping.value
// ^^^ - meta.mapping meta.mapping.value
// ^^^ meta.mapping.value meta.sequence.list.empty
// ^^^ meta.mapping.value meta.sequence.list
// ^ punctuation.definition.sequence.begin
// ^ punctuation.definition.sequence.end

Expand All @@ -63,7 +63,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^ meta.mapping.value
// ^^ - meta.mapping meta.mapping.value
// ^^ meta.mapping.value meta.mapping.empty
// ^^ meta.mapping.value meta.mapping
// ^ punctuation.definition.mapping.begin
// ^ punctuation.definition.mapping.end

Expand All @@ -73,7 +73,7 @@
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^ meta.mapping.value
// ^^^ - meta.mapping meta.mapping.value
// ^^^ meta.mapping.value meta.mapping.empty
// ^^^ meta.mapping.value meta.mapping
// ^ punctuation.definition.mapping.begin
// ^ punctuation.definition.mapping.end

Expand Down
8 changes: 4 additions & 4 deletions JSON/tests/syntax/syntax_test_jsonc.meta.sequence.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
// ^^^^^^^ string.quoted.double

[],
// ^^ meta.sequence.list.empty
// ^^ meta.sequence.list

[ ],
// ^^^ meta.sequence.list.empty
// ^^^ meta.sequence.list

[1, 2
// ^ meta.sequence.list punctuation.definition.sequence.begin
Expand All @@ -45,10 +45,10 @@
// ^ meta.sequence.list punctuation.separator.sequence

{},
// ^^ meta.mapping.empty
// ^^ meta.mapping

{ },
// ^^^ meta.mapping.empty
// ^^^ meta.mapping

{ "a": 1, "b": 2
// ^^^^^^^^^^^^^^^^ meta.mapping
Expand Down

0 comments on commit d6a5b30

Please sign in to comment.