Skip to content

Commit 0adddd8

Browse files
authored
Add JSON Lines language definition (microsoft#183035)
* Add `JSON Lines` language definition * Fix ident
1 parent 8ff8af5 commit 0adddd8

File tree

6 files changed

+238
-10
lines changed

6 files changed

+238
-10
lines changed

extensions/json/build/update-grammars.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
var updateGrammar = require('vscode-grammar-updater');
88

9-
function adaptJSON(grammar, replacementScope) {
10-
grammar.name = 'JSON with comments';
9+
function adaptJSON(grammar, name, replacementScope) {
10+
grammar.name = name;
1111
grammar.scopeName = `source${replacementScope}`;
1212

1313
var fixScopeNames = function (rule) {
@@ -33,9 +33,5 @@ function adaptJSON(grammar, replacementScope) {
3333

3434
var tsGrammarRepo = 'microsoft/vscode-JSON.tmLanguage';
3535
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSON.tmLanguage.json');
36-
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONC.tmLanguage.json', grammar => adaptJSON(grammar, '.json.comments'));
37-
38-
39-
40-
41-
36+
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONC.tmLanguage.json', grammar => adaptJSON(grammar, 'JSON with Comments', '.json.comments'));
37+
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONL.tmLanguage.json', grammar => adaptJSON(grammar, 'JSON Lines', '.json.lines'));

extensions/json/package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
".jslintrc",
3232
".jsonld",
3333
".geojson",
34-
".ipynb"
34+
".ipynb"
3535
],
3636
"filenames": [
3737
"composer.lock",
@@ -65,6 +65,17 @@
6565
"typedoc.json"
6666
],
6767
"configuration": "./language-configuration.json"
68+
},
69+
{
70+
"id": "jsonl",
71+
"aliases": [
72+
"JSON Lines"
73+
],
74+
"extensions": [
75+
".jsonl"
76+
],
77+
"filenames": [],
78+
"configuration": "./language-configuration.json"
6879
}
6980
],
7081
"grammars": [
@@ -77,6 +88,11 @@
7788
"language": "jsonc",
7889
"scopeName": "source.json.comments",
7990
"path": "./syntaxes/JSONC.tmLanguage.json"
91+
},
92+
{
93+
"language": "jsonl",
94+
"scopeName": "source.json.lines",
95+
"path": "./syntaxes/JSONL.tmLanguage.json"
8096
}
8197
]
8298
},

extensions/json/syntaxes/JSONC.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Once accepted there, we are happy to receive an update request."
66
],
77
"version": "https://github.com/microsoft/vscode-JSON.tmLanguage/commit/9bd83f1c252b375e957203f21793316203f61f70",
8-
"name": "JSON with comments",
8+
"name": "JSON with Comments",
99
"scopeName": "source.json.comments",
1010
"patterns": [
1111
{
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
{
2+
"information_for_contributors": [
3+
"This file has been converted from https://github.com/microsoft/vscode-JSON.tmLanguage/blob/master/JSON.tmLanguage",
4+
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
5+
"Once accepted there, we are happy to receive an update request."
6+
],
7+
"version": "https://github.com/microsoft/vscode-JSON.tmLanguage/commit/9bd83f1c252b375e957203f21793316203f61f70",
8+
"name": "JSON Lines",
9+
"scopeName": "source.json.lines",
10+
"patterns": [
11+
{
12+
"include": "#value"
13+
}
14+
],
15+
"repository": {
16+
"array": {
17+
"begin": "\\[",
18+
"beginCaptures": {
19+
"0": {
20+
"name": "punctuation.definition.array.begin.json.lines"
21+
}
22+
},
23+
"end": "\\]",
24+
"endCaptures": {
25+
"0": {
26+
"name": "punctuation.definition.array.end.json.lines"
27+
}
28+
},
29+
"name": "meta.structure.array.json.lines",
30+
"patterns": [
31+
{
32+
"include": "#value"
33+
},
34+
{
35+
"match": ",",
36+
"name": "punctuation.separator.array.json.lines"
37+
},
38+
{
39+
"match": "[^\\s\\]]",
40+
"name": "invalid.illegal.expected-array-separator.json.lines"
41+
}
42+
]
43+
},
44+
"comments": {
45+
"patterns": [
46+
{
47+
"begin": "/\\*\\*(?!/)",
48+
"captures": {
49+
"0": {
50+
"name": "punctuation.definition.comment.json.lines"
51+
}
52+
},
53+
"end": "\\*/",
54+
"name": "comment.block.documentation.json.lines"
55+
},
56+
{
57+
"begin": "/\\*",
58+
"captures": {
59+
"0": {
60+
"name": "punctuation.definition.comment.json.lines"
61+
}
62+
},
63+
"end": "\\*/",
64+
"name": "comment.block.json.lines"
65+
},
66+
{
67+
"captures": {
68+
"1": {
69+
"name": "punctuation.definition.comment.json.lines"
70+
}
71+
},
72+
"match": "(//).*$\\n?",
73+
"name": "comment.line.double-slash.js"
74+
}
75+
]
76+
},
77+
"constant": {
78+
"match": "\\b(?:true|false|null)\\b",
79+
"name": "constant.language.json.lines"
80+
},
81+
"number": {
82+
"match": "(?x) # turn on extended mode\n -? # an optional minus\n (?:\n 0 # a zero\n | # ...or...\n [1-9] # a 1-9 character\n \\d* # followed by zero or more digits\n )\n (?:\n (?:\n \\. # a period\n \\d+ # followed by one or more digits\n )?\n (?:\n [eE] # an e character\n [+-]? # followed by an option +/-\n \\d+ # followed by one or more digits\n )? # make exponent optional\n )? # make decimal portion optional",
83+
"name": "constant.numeric.json.lines"
84+
},
85+
"object": {
86+
"begin": "\\{",
87+
"beginCaptures": {
88+
"0": {
89+
"name": "punctuation.definition.dictionary.begin.json.lines"
90+
}
91+
},
92+
"end": "\\}",
93+
"endCaptures": {
94+
"0": {
95+
"name": "punctuation.definition.dictionary.end.json.lines"
96+
}
97+
},
98+
"name": "meta.structure.dictionary.json.lines",
99+
"patterns": [
100+
{
101+
"comment": "the JSON object key",
102+
"include": "#objectkey"
103+
},
104+
{
105+
"include": "#comments"
106+
},
107+
{
108+
"begin": ":",
109+
"beginCaptures": {
110+
"0": {
111+
"name": "punctuation.separator.dictionary.key-value.json.lines"
112+
}
113+
},
114+
"end": "(,)|(?=\\})",
115+
"endCaptures": {
116+
"1": {
117+
"name": "punctuation.separator.dictionary.pair.json.lines"
118+
}
119+
},
120+
"name": "meta.structure.dictionary.value.json.lines",
121+
"patterns": [
122+
{
123+
"comment": "the JSON object value",
124+
"include": "#value"
125+
},
126+
{
127+
"match": "[^\\s,]",
128+
"name": "invalid.illegal.expected-dictionary-separator.json.lines"
129+
}
130+
]
131+
},
132+
{
133+
"match": "[^\\s\\}]",
134+
"name": "invalid.illegal.expected-dictionary-separator.json.lines"
135+
}
136+
]
137+
},
138+
"string": {
139+
"begin": "\"",
140+
"beginCaptures": {
141+
"0": {
142+
"name": "punctuation.definition.string.begin.json.lines"
143+
}
144+
},
145+
"end": "\"",
146+
"endCaptures": {
147+
"0": {
148+
"name": "punctuation.definition.string.end.json.lines"
149+
}
150+
},
151+
"name": "string.quoted.double.json.lines",
152+
"patterns": [
153+
{
154+
"include": "#stringcontent"
155+
}
156+
]
157+
},
158+
"objectkey": {
159+
"begin": "\"",
160+
"beginCaptures": {
161+
"0": {
162+
"name": "punctuation.support.type.property-name.begin.json.lines"
163+
}
164+
},
165+
"end": "\"",
166+
"endCaptures": {
167+
"0": {
168+
"name": "punctuation.support.type.property-name.end.json.lines"
169+
}
170+
},
171+
"name": "string.json.lines support.type.property-name.json.lines",
172+
"patterns": [
173+
{
174+
"include": "#stringcontent"
175+
}
176+
]
177+
},
178+
"stringcontent": {
179+
"patterns": [
180+
{
181+
"match": "(?x) # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n [\"\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4}) # and four hex digits",
182+
"name": "constant.character.escape.json.lines"
183+
},
184+
{
185+
"match": "\\\\.",
186+
"name": "invalid.illegal.unrecognized-string-escape.json.lines"
187+
}
188+
]
189+
},
190+
"value": {
191+
"patterns": [
192+
{
193+
"include": "#constant"
194+
},
195+
{
196+
"include": "#number"
197+
},
198+
{
199+
"include": "#string"
200+
},
201+
{
202+
"include": "#array"
203+
},
204+
{
205+
"include": "#object"
206+
},
207+
{
208+
"include": "#comments"
209+
}
210+
]
211+
}
212+
}
213+
}

extensions/theme-seti/build/update-icon-theme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const nonBuiltInLanguages = { // { fileNames, extensions }
4444
// list of languagesId that inherit the icon from another language
4545
const inheritIconFromLanguage = {
4646
"jsonc": 'json',
47+
"jsonl": 'json',
4748
"postcss": 'css',
4849
"django-html": 'html',
4950
"blade": 'php'

extensions/theme-seti/icons/vs-seti-icon-theme.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,7 @@
19431943
"todo": "_todo",
19441944
"vala": "_vala",
19451945
"vue": "_vue",
1946+
"jsonl": "_json",
19461947
"postcss": "_css",
19471948
"django-html": "_html_3",
19481949
"blade": "_php"
@@ -2257,6 +2258,7 @@
22572258
"terraform": "_terraform_light",
22582259
"vala": "_vala_light",
22592260
"vue": "_vue_light",
2261+
"jsonl": "_json_light",
22602262
"postcss": "_css_light",
22612263
"django-html": "_html_3_light",
22622264
"blade": "_php_light"

0 commit comments

Comments
 (0)