Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON Lines language definition #183035

Merged
merged 2 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions extensions/json/build/update-grammars.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

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

function adaptJSON(grammar, replacementScope) {
grammar.name = 'JSON with comments';
function adaptJSON(grammar, name, replacementScope) {
grammar.name = name;
grammar.scopeName = `source${replacementScope}`;

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

var tsGrammarRepo = 'microsoft/vscode-JSON.tmLanguage';
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSON.tmLanguage.json');
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONC.tmLanguage.json', grammar => adaptJSON(grammar, '.json.comments'));





updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONC.tmLanguage.json', grammar => adaptJSON(grammar, 'JSON with Comments', '.json.comments'));
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONL.tmLanguage.json', grammar => adaptJSON(grammar, 'JSON Lines', '.json.lines'));
18 changes: 17 additions & 1 deletion extensions/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
".jslintrc",
".jsonld",
".geojson",
".ipynb"
".ipynb"
],
"filenames": [
"composer.lock",
Expand Down Expand Up @@ -65,6 +65,17 @@
"typedoc.json"
],
"configuration": "./language-configuration.json"
},
{
"id": "jsonl",
"aliases": [
"JSON Lines"
],
"extensions": [
".jsonl"
],
"filenames": [],
"configuration": "./language-configuration.json"
}
],
"grammars": [
Expand All @@ -77,6 +88,11 @@
"language": "jsonc",
"scopeName": "source.json.comments",
"path": "./syntaxes/JSONC.tmLanguage.json"
},
{
"language": "jsonl",
"scopeName": "source.json.lines",
"path": "./syntaxes/JSONL.tmLanguage.json"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion extensions/json/syntaxes/JSONC.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/microsoft/vscode-JSON.tmLanguage/commit/9bd83f1c252b375e957203f21793316203f61f70",
"name": "JSON with comments",
"name": "JSON with Comments",
"scopeName": "source.json.comments",
"patterns": [
{
Expand Down
213 changes: 213 additions & 0 deletions extensions/json/syntaxes/JSONL.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
{
"information_for_contributors": [
"This file has been converted from https://github.com/microsoft/vscode-JSON.tmLanguage/blob/master/JSON.tmLanguage",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/microsoft/vscode-JSON.tmLanguage/commit/9bd83f1c252b375e957203f21793316203f61f70",
"name": "JSON Lines",
"scopeName": "source.json.lines",
"patterns": [
{
"include": "#value"
}
],
"repository": {
"array": {
"begin": "\\[",
"beginCaptures": {
"0": {
"name": "punctuation.definition.array.begin.json.lines"
}
},
"end": "\\]",
"endCaptures": {
"0": {
"name": "punctuation.definition.array.end.json.lines"
}
},
"name": "meta.structure.array.json.lines",
"patterns": [
{
"include": "#value"
},
{
"match": ",",
"name": "punctuation.separator.array.json.lines"
},
{
"match": "[^\\s\\]]",
"name": "invalid.illegal.expected-array-separator.json.lines"
}
]
},
"comments": {
"patterns": [
{
"begin": "/\\*\\*(?!/)",
"captures": {
"0": {
"name": "punctuation.definition.comment.json.lines"
}
},
"end": "\\*/",
"name": "comment.block.documentation.json.lines"
},
{
"begin": "/\\*",
"captures": {
"0": {
"name": "punctuation.definition.comment.json.lines"
}
},
"end": "\\*/",
"name": "comment.block.json.lines"
},
{
"captures": {
"1": {
"name": "punctuation.definition.comment.json.lines"
}
},
"match": "(//).*$\\n?",
"name": "comment.line.double-slash.js"
}
]
},
"constant": {
"match": "\\b(?:true|false|null)\\b",
"name": "constant.language.json.lines"
},
"number": {
"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",
"name": "constant.numeric.json.lines"
},
"object": {
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.definition.dictionary.begin.json.lines"
}
},
"end": "\\}",
"endCaptures": {
"0": {
"name": "punctuation.definition.dictionary.end.json.lines"
}
},
"name": "meta.structure.dictionary.json.lines",
"patterns": [
{
"comment": "the JSON object key",
"include": "#objectkey"
},
{
"include": "#comments"
},
{
"begin": ":",
"beginCaptures": {
"0": {
"name": "punctuation.separator.dictionary.key-value.json.lines"
}
},
"end": "(,)|(?=\\})",
"endCaptures": {
"1": {
"name": "punctuation.separator.dictionary.pair.json.lines"
}
},
"name": "meta.structure.dictionary.value.json.lines",
"patterns": [
{
"comment": "the JSON object value",
"include": "#value"
},
{
"match": "[^\\s,]",
"name": "invalid.illegal.expected-dictionary-separator.json.lines"
}
]
},
{
"match": "[^\\s\\}]",
"name": "invalid.illegal.expected-dictionary-separator.json.lines"
}
]
},
"string": {
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.json.lines"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.json.lines"
}
},
"name": "string.quoted.double.json.lines",
"patterns": [
{
"include": "#stringcontent"
}
]
},
"objectkey": {
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.support.type.property-name.begin.json.lines"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.support.type.property-name.end.json.lines"
}
},
"name": "string.json.lines support.type.property-name.json.lines",
"patterns": [
{
"include": "#stringcontent"
}
]
},
"stringcontent": {
"patterns": [
{
"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",
"name": "constant.character.escape.json.lines"
},
{
"match": "\\\\.",
"name": "invalid.illegal.unrecognized-string-escape.json.lines"
}
]
},
"value": {
"patterns": [
{
"include": "#constant"
},
{
"include": "#number"
},
{
"include": "#string"
},
{
"include": "#array"
},
{
"include": "#object"
},
{
"include": "#comments"
}
]
}
}
}
1 change: 1 addition & 0 deletions extensions/theme-seti/build/update-icon-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const nonBuiltInLanguages = { // { fileNames, extensions }
// list of languagesId that inherit the icon from another language
const inheritIconFromLanguage = {
"jsonc": 'json',
"jsonl": 'json',
"postcss": 'css',
"django-html": 'html',
"blade": 'php'
Expand Down
2 changes: 2 additions & 0 deletions extensions/theme-seti/icons/vs-seti-icon-theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,7 @@
"todo": "_todo",
"vala": "_vala",
"vue": "_vue",
"jsonl": "_json",
"postcss": "_css",
"django-html": "_html_3",
"blade": "_php"
Expand Down Expand Up @@ -2257,6 +2258,7 @@
"terraform": "_terraform_light",
"vala": "_vala_light",
"vue": "_vue_light",
"jsonl": "_json_light",
"postcss": "_css_light",
"django-html": "_html_3_light",
"blade": "_php_light"
Expand Down