monaco-json
Advanced tools
Comparing version 3.1.0 to 3.2.0
{ | ||
"name": "monaco-json", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "JSON plugin for the Monaco Editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -445,7 +445,12 @@ /*--------------------------------------------------------------------------------------------- | ||
case 11 /* NumericLiteral */: | ||
var tokenValue = _scanner.getTokenValue(); | ||
var value = Number(tokenValue); | ||
if (isNaN(value)) { | ||
var value = 0; | ||
try { | ||
value = JSON.parse(_scanner.getTokenValue()); | ||
if (typeof value !== 'number') { | ||
handleError(2 /* InvalidNumberFormat */); | ||
value = 0; | ||
} | ||
} | ||
catch (e) { | ||
handleError(2 /* InvalidNumberFormat */); | ||
value = 0; | ||
} | ||
@@ -452,0 +457,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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -12,0 +12,0 @@ }; |
@@ -317,18 +317,2 @@ /* -------------------------------------------------------------------------------------------- | ||
/** | ||
* 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 | ||
@@ -601,5 +585,2 @@ * [Diagnostic](#Diagnostic) literals. | ||
get: function () { | ||
if (this._workspaceEdit === undefined) { | ||
return { documentChanges: [] }; | ||
} | ||
return this._workspaceEdit; | ||
@@ -834,3 +815,3 @@ }, | ||
* | ||
* See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax | ||
* See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md | ||
*/ | ||
@@ -853,25 +834,2 @@ 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 | ||
@@ -1123,4 +1081,3 @@ * completion items. | ||
(candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && | ||
(candidate.children === void 0 || Array.isArray(candidate.children)) && | ||
(candidate.tags === void 0 || Array.isArray(candidate.tags)); | ||
(candidate.children === void 0 || Array.isArray(candidate.children)); | ||
} | ||
@@ -1127,0 +1084,0 @@ DocumentSymbol.is = is; |
@@ -8,3 +8,3 @@ /*--------------------------------------------------------------------------------------------- | ||
return { | ||
getInitialState: function () { return new JSONState(null, null); }, | ||
getInitialState: function () { return new JSONState(null, null, false, null); }, | ||
tokenize: function (line, state, offsetDelta, stopAtOffset) { | ||
@@ -26,9 +26,46 @@ return tokenize(supportComments, line, state, offsetDelta, stopAtOffset); | ||
export var TOKEN_COMMENT_LINE = 'comment.line.json'; | ||
var ParentsStack = /** @class */ (function () { | ||
function ParentsStack(parent, type) { | ||
this.parent = parent; | ||
this.type = type; | ||
} | ||
ParentsStack.pop = function (parents) { | ||
if (parents) { | ||
return parents.parent; | ||
} | ||
return null; | ||
}; | ||
ParentsStack.push = function (parents, type) { | ||
return new ParentsStack(parents, type); | ||
}; | ||
ParentsStack.equals = function (a, b) { | ||
if (!a && !b) { | ||
return true; | ||
} | ||
if (!a || !b) { | ||
return false; | ||
} | ||
while (a && b) { | ||
if (a === b) { | ||
return true; | ||
} | ||
if (a.type !== b.type) { | ||
return false; | ||
} | ||
a = a.parent; | ||
b = b.parent; | ||
} | ||
return true; | ||
}; | ||
return ParentsStack; | ||
}()); | ||
var JSONState = /** @class */ (function () { | ||
function JSONState(state, scanError) { | ||
function JSONState(state, scanError, lastWasColon, parents) { | ||
this._state = state; | ||
this.scanError = scanError; | ||
this.lastWasColon = lastWasColon; | ||
this.parents = parents; | ||
} | ||
JSONState.prototype.clone = function () { | ||
return new JSONState(this._state, this.scanError); | ||
return new JSONState(this._state, this.scanError, this.lastWasColon, this.parents); | ||
}; | ||
@@ -42,3 +79,5 @@ JSONState.prototype.equals = function (other) { | ||
} | ||
return this.scanError === other.scanError; | ||
return (this.scanError === other.scanError && | ||
this.lastWasColon === other.lastWasColon && | ||
ParentsStack.equals(this.parents, other.parents)); | ||
}; | ||
@@ -69,2 +108,4 @@ JSONState.prototype.getStateData = function () { | ||
var scanner = json.createScanner(line); | ||
var lastWasColon = state.lastWasColon; | ||
var parents = state.parents; | ||
var ret = { | ||
@@ -94,29 +135,28 @@ tokens: [], | ||
case 1 /* OpenBraceToken */: | ||
parents = ParentsStack.push(parents, 0 /* Object */); | ||
type = TOKEN_DELIM_OBJECT; | ||
lastWasColon = false; | ||
break; | ||
case 2 /* CloseBraceToken */: | ||
parents = ParentsStack.pop(parents); | ||
type = TOKEN_DELIM_OBJECT; | ||
lastWasColon = false; | ||
break; | ||
case 3 /* OpenBracketToken */: | ||
parents = ParentsStack.push(parents, 1 /* Array */); | ||
type = TOKEN_DELIM_ARRAY; | ||
lastWasColon = false; | ||
break; | ||
case 4 /* CloseBracketToken */: | ||
parents = ParentsStack.pop(parents); | ||
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; | ||
@@ -126,11 +166,18 @@ case 8 /* TrueKeyword */: | ||
type = TOKEN_VALUE_BOOLEAN; | ||
lastWasColon = false; | ||
break; | ||
case 7 /* NullKeyword */: | ||
type = TOKEN_VALUE_NULL; | ||
lastWasColon = false; | ||
break; | ||
case 10 /* StringLiteral */: | ||
type = TOKEN_VALUE_STRING; | ||
var currentParent = parents ? parents.type : 0 /* Object */; | ||
var inArray = currentParent === 1 /* Array */; | ||
type = | ||
lastWasColon || inArray ? TOKEN_VALUE_STRING : TOKEN_PROPERTY_NAME; | ||
lastWasColon = false; | ||
break; | ||
case 11 /* NumericLiteral */: | ||
type = TOKEN_VALUE_NUMBER; | ||
lastWasColon = false; | ||
break; | ||
@@ -149,3 +196,3 @@ } | ||
} | ||
ret.endState = new JSONState(state.getStateData(), scanner.getTokenError()); | ||
ret.endState = new JSONState(state.getStateData(), scanner.getTokenError(), lastWasColon, parents); | ||
ret.tokens.push({ | ||
@@ -152,0 +199,0 @@ startIndex: offset, |
/*!----------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* monaco-json version: 3.1.0(2372a593b3cebb1de147044916d187c3cd4d1dbe) | ||
* monaco-json version: 3.2.0(acb1bb306c06350f6f85a9c239f9382392b2df09) | ||
* 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
1584810
28380