monaco-json
Advanced tools
Comparing version 3.0.2 to 3.1.0
{ | ||
"name": "monaco-json", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "JSON plugin for the Monaco Editor", | ||
"scripts": { | ||
"compile": "mrmdir ./out && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json && node ./scripts/dts", | ||
"compile": "mrmdir ./out && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json && node ./scripts/dts && prettier --write ./monaco.d.ts", | ||
"watch": "tsc -p ./src --watch", | ||
@@ -26,12 +26,12 @@ "prepublishOnly": "mrmdir ./release && npm run compile && node ./scripts/release.js && node ./scripts/bundle && mcopy ./monaco.d.ts ./release/monaco.d.ts && mcopy ./out/esm/monaco.contribution.d.ts ./release/esm/monaco.contribution.d.ts && mcopy ./out/esm/fillers/monaco-editor-core.d.ts ./release/esm/fillers/monaco-editor-core.d.ts", | ||
"husky": "^4.3.0", | ||
"jsonc-parser": "^2.3.0", | ||
"monaco-editor-core": "0.20.0", | ||
"monaco-languages": "1.10.0", | ||
"jsonc-parser": "^2.3.1", | ||
"monaco-editor-core": "0.21.0", | ||
"monaco-languages": "2.1.0", | ||
"monaco-plugin-helpers": "^1.0.3", | ||
"prettier": "^2.1.1", | ||
"pretty-quick": "^3.0.0", | ||
"prettier": "^2.1.2", | ||
"pretty-quick": "^3.0.2", | ||
"requirejs": "^2.3.6", | ||
"typescript": "4.0.2", | ||
"terser": "^5.3.0", | ||
"vscode-json-languageservice": "3.8.3" | ||
"typescript": "4.0.3", | ||
"terser": "^5.3.2", | ||
"vscode-json-languageservice": "3.8.4" | ||
}, | ||
@@ -38,0 +38,0 @@ "husky": { |
@@ -89,11 +89,3 @@ /*--------------------------------------------------------------------------------------------- | ||
id: 'json', | ||
extensions: [ | ||
'.json', | ||
'.bowerrc', | ||
'.jshintrc', | ||
'.jscsrc', | ||
'.eslintrc', | ||
'.babelrc', | ||
'.har' | ||
], | ||
extensions: ['.json', '.bowerrc', '.jshintrc', '.jscsrc', '.eslintrc', '.babelrc', '.har'], | ||
aliases: ['JSON', 'json'], | ||
@@ -100,0 +92,0 @@ mimetypes: ['application/json'] |
@@ -445,12 +445,7 @@ /*--------------------------------------------------------------------------------------------- | ||
case 11 /* NumericLiteral */: | ||
var value = 0; | ||
try { | ||
value = JSON.parse(_scanner.getTokenValue()); | ||
if (typeof value !== 'number') { | ||
handleError(2 /* InvalidNumberFormat */); | ||
value = 0; | ||
} | ||
} | ||
catch (e) { | ||
var tokenValue = _scanner.getTokenValue(); | ||
var value = Number(tokenValue); | ||
if (isNaN(value)) { | ||
handleError(2 /* InvalidNumberFormat */); | ||
value = 0; | ||
} | ||
@@ -457,0 +452,0 @@ onLiteralValue(value); |
@@ -9,3 +9,3 @@ /*--------------------------------------------------------------------------------------------- | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -12,0 +12,0 @@ }; |
@@ -317,2 +317,18 @@ /* -------------------------------------------------------------------------------------------- | ||
/** | ||
* The DiagnosticCode namespace provides functions to deal with complex diagnostic codes. | ||
* | ||
* @since 3.16.0 - Proposed state | ||
*/ | ||
export var DiagnosticCode; | ||
(function (DiagnosticCode) { | ||
/** | ||
* Checks whether the given liternal conforms to the [DiagnosticCode](#DiagnosticCode) interface. | ||
*/ | ||
function is(value) { | ||
var candidate = value; | ||
return candidate !== undefined && candidate !== null && (Is.number(candidate.value) || Is.string(candidate.value)) && Is.string(candidate.target); | ||
} | ||
DiagnosticCode.is = is; | ||
})(DiagnosticCode || (DiagnosticCode = {})); | ||
/** | ||
* The Diagnostic namespace provides helper functions to work with | ||
@@ -585,2 +601,5 @@ * [Diagnostic](#Diagnostic) literals. | ||
get: function () { | ||
if (this._workspaceEdit === undefined) { | ||
return { documentChanges: [] }; | ||
} | ||
return this._workspaceEdit; | ||
@@ -815,3 +834,3 @@ }, | ||
* | ||
* See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md | ||
* See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax | ||
*/ | ||
@@ -834,2 +853,25 @@ InsertTextFormat.Snippet = 2; | ||
/** | ||
* The InsertReplaceEdit namespace provides functions to deal with insert / replace edits. | ||
* | ||
* @since 3.16.0 - Proposed state | ||
*/ | ||
export var InsertReplaceEdit; | ||
(function (InsertReplaceEdit) { | ||
/** | ||
* Creates a new insert / replace edit | ||
*/ | ||
function create(newText, insert, replace) { | ||
return { newText: newText, insert: insert, replace: replace }; | ||
} | ||
InsertReplaceEdit.create = create; | ||
/** | ||
* Checks whether the given liternal conforms to the [InsertReplaceEdit](#InsertReplaceEdit) interface. | ||
*/ | ||
function is(value) { | ||
var candidate = value; | ||
return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace); | ||
} | ||
InsertReplaceEdit.is = is; | ||
})(InsertReplaceEdit || (InsertReplaceEdit = {})); | ||
/** | ||
* The CompletionItem namespace provides functions to deal with | ||
@@ -1081,3 +1123,4 @@ * completion items. | ||
(candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && | ||
(candidate.children === void 0 || Array.isArray(candidate.children)); | ||
(candidate.children === void 0 || Array.isArray(candidate.children)) && | ||
(candidate.tags === void 0 || Array.isArray(candidate.tags)); | ||
} | ||
@@ -1084,0 +1127,0 @@ DocumentSymbol.is = is; |
@@ -143,2 +143,6 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
function isInsertReplaceEdit(edit) { | ||
return (typeof edit.insert !== 'undefined' && | ||
typeof edit.replace !== 'undefined'); | ||
} | ||
function toCompletionItemKind(kind) { | ||
@@ -272,3 +276,11 @@ var mItemKind = languages.CompletionItemKind; | ||
if (entry.textEdit) { | ||
item.range = toRange(entry.textEdit.range); | ||
if (isInsertReplaceEdit(entry.textEdit)) { | ||
item.range = { | ||
insert: toRange(entry.textEdit.insert), | ||
replace: toRange(entry.textEdit.replace) | ||
}; | ||
} | ||
else { | ||
item.range = toRange(entry.textEdit.range); | ||
} | ||
item.insertText = entry.textEdit.newText; | ||
@@ -280,4 +292,3 @@ } | ||
if (entry.insertTextFormat === jsonService.InsertTextFormat.Snippet) { | ||
item.insertTextRules = | ||
languages.CompletionItemInsertTextRule.InsertAsSnippet; | ||
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet; | ||
} | ||
@@ -563,5 +574,3 @@ return item; | ||
return this._worker(resource) | ||
.then(function (worker) { | ||
return worker.getSelectionRanges(resource.toString(), positions.map(fromPosition)); | ||
}) | ||
.then(function (worker) { return worker.getSelectionRanges(resource.toString(), positions.map(fromPosition)); }) | ||
.then(function (selectionRanges) { | ||
@@ -568,0 +577,0 @@ if (!selectionRanges) { |
@@ -78,11 +78,3 @@ /*--------------------------------------------------------------------------------------------- | ||
id: 'json', | ||
extensions: [ | ||
'.json', | ||
'.bowerrc', | ||
'.jshintrc', | ||
'.jscsrc', | ||
'.eslintrc', | ||
'.babelrc', | ||
'.har' | ||
], | ||
extensions: ['.json', '.bowerrc', '.jshintrc', '.jscsrc', '.eslintrc', '.babelrc', '.har'], | ||
aliases: ['JSON', 'json'], | ||
@@ -89,0 +81,0 @@ mimetypes: ['application/json'] |
@@ -8,3 +8,3 @@ /*--------------------------------------------------------------------------------------------- | ||
return { | ||
getInitialState: function () { return new JSONState(null, null, false); }, | ||
getInitialState: function () { return new JSONState(null, null); }, | ||
tokenize: function (line, state, offsetDelta, stopAtOffset) { | ||
@@ -27,9 +27,8 @@ return tokenize(supportComments, line, state, offsetDelta, stopAtOffset); | ||
var JSONState = /** @class */ (function () { | ||
function JSONState(state, scanError, lastWasColon) { | ||
function JSONState(state, scanError) { | ||
this._state = state; | ||
this.scanError = scanError; | ||
this.lastWasColon = lastWasColon; | ||
} | ||
JSONState.prototype.clone = function () { | ||
return new JSONState(this._state, this.scanError, this.lastWasColon); | ||
return new JSONState(this._state, this.scanError); | ||
}; | ||
@@ -43,4 +42,3 @@ JSONState.prototype.equals = function (other) { | ||
} | ||
return (this.scanError === other.scanError && | ||
this.lastWasColon === other.lastWasColon); | ||
return this.scanError === other.scanError; | ||
}; | ||
@@ -58,3 +56,4 @@ JSONState.prototype.getStateData = function () { | ||
// handle multiline strings and block comments | ||
var numberOfInsertedCharacters = 0, adjustOffset = false; | ||
var numberOfInsertedCharacters = 0; | ||
var adjustOffset = false; | ||
switch (state.scanError) { | ||
@@ -70,4 +69,4 @@ case 2 /* UnexpectedEndOfString */: | ||
} | ||
var scanner = json.createScanner(line), kind, ret, lastWasColon = state.lastWasColon; | ||
ret = { | ||
var scanner = json.createScanner(line); | ||
var ret = { | ||
tokens: [], | ||
@@ -77,4 +76,5 @@ endState: state.clone() | ||
while (true) { | ||
var offset = offsetDelta + scanner.getPosition(), type = ''; | ||
kind = scanner.scan(); | ||
var offset = offsetDelta + scanner.getPosition(); | ||
var type = ''; | ||
var kind = scanner.scan(); | ||
if (kind === 17 /* EOF */) { | ||
@@ -85,4 +85,3 @@ break; | ||
if (offset === offsetDelta + scanner.getPosition()) { | ||
throw new Error('Scanner did not advance, next 3 characters are: ' + | ||
line.substr(scanner.getPosition(), 3)); | ||
throw new Error('Scanner did not advance, next 3 characters are: ' + line.substr(scanner.getPosition(), 3)); | ||
} | ||
@@ -99,23 +98,28 @@ // In case we inserted /* or " character, we need to | ||
type = TOKEN_DELIM_OBJECT; | ||
lastWasColon = false; | ||
break; | ||
case 2 /* CloseBraceToken */: | ||
type = TOKEN_DELIM_OBJECT; | ||
lastWasColon = false; | ||
break; | ||
case 3 /* OpenBracketToken */: | ||
type = TOKEN_DELIM_ARRAY; | ||
lastWasColon = false; | ||
break; | ||
case 4 /* CloseBracketToken */: | ||
type = TOKEN_DELIM_ARRAY; | ||
lastWasColon = false; | ||
break; | ||
case 6 /* ColonToken */: | ||
for (var i = ret.tokens.length - 1; i >= 0; i--) { | ||
var token = ret.tokens[i]; | ||
if (token.scopes === '' || token.scopes === TOKEN_COMMENT_BLOCK) { | ||
continue; | ||
} | ||
if (token.scopes === TOKEN_VALUE_STRING) { | ||
// !change previous token to property name! | ||
token.scopes = TOKEN_PROPERTY_NAME; | ||
} | ||
break; | ||
} | ||
type = TOKEN_DELIM_COLON; | ||
lastWasColon = true; | ||
break; | ||
case 5 /* CommaToken */: | ||
type = TOKEN_DELIM_COMMA; | ||
lastWasColon = false; | ||
break; | ||
@@ -125,15 +129,11 @@ case 8 /* TrueKeyword */: | ||
type = TOKEN_VALUE_BOOLEAN; | ||
lastWasColon = false; | ||
break; | ||
case 7 /* NullKeyword */: | ||
type = TOKEN_VALUE_NULL; | ||
lastWasColon = false; | ||
break; | ||
case 10 /* StringLiteral */: | ||
type = lastWasColon ? TOKEN_VALUE_STRING : TOKEN_PROPERTY_NAME; | ||
lastWasColon = false; | ||
type = TOKEN_VALUE_STRING; | ||
break; | ||
case 11 /* NumericLiteral */: | ||
type = TOKEN_VALUE_NUMBER; | ||
lastWasColon = false; | ||
break; | ||
@@ -152,3 +152,3 @@ } | ||
} | ||
ret.endState = new JSONState(state.getStateData(), scanner.getTokenError(), lastWasColon); | ||
ret.endState = new JSONState(state.getStateData(), scanner.getTokenError()); | ||
ret.tokens.push({ | ||
@@ -155,0 +155,0 @@ startIndex: offset, |
@@ -14,5 +14,3 @@ /*--------------------------------------------------------------------------------------------- | ||
this._lastUsedTime = 0; | ||
this._configChangeListener = this._defaults.onDidChange(function () { | ||
return _this._stopWorker(); | ||
}); | ||
this._configChangeListener = this._defaults.onDidChange(function () { return _this._stopWorker(); }); | ||
} | ||
@@ -51,4 +49,3 @@ WorkerManager.prototype._stopWorker = function () { | ||
languageId: this._defaults.languageId, | ||
enableSchemaRequest: this._defaults.diagnosticsOptions | ||
.enableSchemaRequest | ||
enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest | ||
} | ||
@@ -55,0 +52,0 @@ }); |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-json version: 3.0.2(fe14e563ba5a4b2391599a0e8411c6625335cb01) | ||
* monaco-json version: 3.1.0(2372a593b3cebb1de147044916d187c3cd4d1dbe) | ||
* Released under the MIT license | ||
@@ -5,0 +5,0 @@ * https://github.com/Microsoft/monaco-json/blob/master/LICENSE.md |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1582292
28402
46