vscode-json-languageservice
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -0,4 +1,8 @@ | ||
5.1.0 / 2022-07-11 | ||
================ | ||
* new API option `FormattingOptions.keepLines` to indicate the formatter should keep the initial line positions | ||
5.0.0 / 2022-05-17 | ||
================ | ||
* Update to `vscode-languageserver-types@3.16` | ||
* Update to `vscode-languageserver-types@3.17` | ||
* Add more schema support | ||
@@ -8,3 +12,2 @@ * Schema 2019-09: unevaluatedProperties, unevaluatedItems, minContains, maxContains, deprecated, dependentRequired, dependentSchemas, $defs, $anchor | ||
4.2.0 / 2022-01-25 | ||
@@ -11,0 +14,0 @@ ================ |
@@ -0,0 +0,0 @@ import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService'; |
export {}; |
@@ -0,0 +0,0 @@ import { Thenable, ASTNode, Color, ColorInformation, ColorPresentation, LanguageServiceParams, LanguageSettings, DocumentLanguageSettings, FoldingRange, JSONSchema, SelectionRange, FoldingRangesContext, DocumentSymbolsContext, ColorInformationContext as DocumentColorsContext, TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, FormattingOptions, DocumentSymbol, DefinitionLink, MatchingSchema, JSONLanguageStatus } from './jsonLanguageTypes'; |
@@ -60,3 +60,3 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n' }; | ||
const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n', keepLines: o?.keepLines === true }; | ||
return formatJSON(d.getText(), range, options).map(e => { | ||
@@ -63,0 +63,0 @@ return TextEdit.replace(Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content); |
@@ -279,2 +279,3 @@ import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions'; | ||
insertFinalNewline?: boolean; | ||
keepLines?: boolean; | ||
} |
@@ -5,5 +5,5 @@ /*--------------------------------------------------------------------------------------------- | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { Range, Position, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types'; | ||
import { Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export { TextDocument, Range, Position, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind }; | ||
export { TextDocument, Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind }; | ||
/** | ||
@@ -10,0 +10,0 @@ * Error codes used by diagnostics |
@@ -0,0 +0,0 @@ export declare type JSONSchemaRef = JSONSchema | boolean; |
export {}; |
@@ -944,4 +944,4 @@ /*--------------------------------------------------------------------------------------------- | ||
switch (token) { | ||
case 12 /* LineCommentTrivia */: | ||
case 13 /* BlockCommentTrivia */: | ||
case 12 /* Json.SyntaxKind.LineCommentTrivia */: | ||
case 13 /* Json.SyntaxKind.BlockCommentTrivia */: | ||
if (Array.isArray(commentRanges)) { | ||
@@ -951,4 +951,4 @@ commentRanges.push(Range.create(textDocument.positionAt(scanner.getTokenOffset()), textDocument.positionAt(scanner.getTokenOffset() + scanner.getTokenLength()))); | ||
break; | ||
case 15 /* Trivia */: | ||
case 14 /* LineBreakTrivia */: | ||
case 15 /* Json.SyntaxKind.Trivia */: | ||
case 14 /* Json.SyntaxKind.LineBreakTrivia */: | ||
break; | ||
@@ -990,3 +990,3 @@ default: | ||
let token = scanner.getToken(); | ||
while (token !== 17 /* EOF */) { | ||
while (token !== 17 /* Json.SyntaxKind.EOF */) { | ||
if (skipUntilAfter.indexOf(token) !== -1) { | ||
@@ -1006,18 +1006,18 @@ _scanNext(); | ||
switch (scanner.getTokenError()) { | ||
case 4 /* InvalidUnicode */: | ||
case 4 /* Json.ScanError.InvalidUnicode */: | ||
_error(localize('InvalidUnicode', 'Invalid unicode sequence in string.'), ErrorCode.InvalidUnicode); | ||
return true; | ||
case 5 /* InvalidEscapeCharacter */: | ||
case 5 /* Json.ScanError.InvalidEscapeCharacter */: | ||
_error(localize('InvalidEscapeCharacter', 'Invalid escape character in string.'), ErrorCode.InvalidEscapeCharacter); | ||
return true; | ||
case 3 /* UnexpectedEndOfNumber */: | ||
case 3 /* Json.ScanError.UnexpectedEndOfNumber */: | ||
_error(localize('UnexpectedEndOfNumber', 'Unexpected end of number.'), ErrorCode.UnexpectedEndOfNumber); | ||
return true; | ||
case 1 /* UnexpectedEndOfComment */: | ||
case 1 /* Json.ScanError.UnexpectedEndOfComment */: | ||
_error(localize('UnexpectedEndOfComment', 'Unexpected end of comment.'), ErrorCode.UnexpectedEndOfComment); | ||
return true; | ||
case 2 /* UnexpectedEndOfString */: | ||
case 2 /* Json.ScanError.UnexpectedEndOfString */: | ||
_error(localize('UnexpectedEndOfString', 'Unexpected end of string.'), ErrorCode.UnexpectedEndOfString); | ||
return true; | ||
case 6 /* InvalidCharacter */: | ||
case 6 /* Json.ScanError.InvalidCharacter */: | ||
_error(localize('InvalidCharacter', 'Invalid characters in string. Control characters must be escaped.'), ErrorCode.InvalidCharacter); | ||
@@ -1036,3 +1036,3 @@ return true; | ||
function _parseArray(parent) { | ||
if (scanner.getToken() !== 3 /* OpenBracketToken */) { | ||
if (scanner.getToken() !== 3 /* Json.SyntaxKind.OpenBracketToken */) { | ||
return undefined; | ||
@@ -1044,4 +1044,4 @@ } | ||
let needsComma = false; | ||
while (scanner.getToken() !== 4 /* CloseBracketToken */ && scanner.getToken() !== 17 /* EOF */) { | ||
if (scanner.getToken() === 5 /* CommaToken */) { | ||
while (scanner.getToken() !== 4 /* Json.SyntaxKind.CloseBracketToken */ && scanner.getToken() !== 17 /* Json.SyntaxKind.EOF */) { | ||
if (scanner.getToken() === 5 /* Json.SyntaxKind.CommaToken */) { | ||
if (!needsComma) { | ||
@@ -1052,3 +1052,3 @@ _error(localize('ValueExpected', 'Value expected'), ErrorCode.ValueExpected); | ||
_scanNext(); // consume comma | ||
if (scanner.getToken() === 4 /* CloseBracketToken */) { | ||
if (scanner.getToken() === 4 /* Json.SyntaxKind.CloseBracketToken */) { | ||
if (needsComma) { | ||
@@ -1065,3 +1065,3 @@ _errorAtRange(localize('TrailingComma', 'Trailing comma'), ErrorCode.TrailingComma, commaOffset, commaOffset + 1); | ||
if (!item) { | ||
_error(localize('PropertyExpected', 'Value expected'), ErrorCode.ValueExpected, undefined, [], [4 /* CloseBracketToken */, 5 /* CommaToken */]); | ||
_error(localize('PropertyExpected', 'Value expected'), ErrorCode.ValueExpected, undefined, [], [4 /* Json.SyntaxKind.CloseBracketToken */, 5 /* Json.SyntaxKind.CommaToken */]); | ||
} | ||
@@ -1073,3 +1073,3 @@ else { | ||
} | ||
if (scanner.getToken() !== 4 /* CloseBracketToken */) { | ||
if (scanner.getToken() !== 4 /* Json.SyntaxKind.CloseBracketToken */) { | ||
return _error(localize('ExpectedCloseBracket', 'Expected comma or closing bracket'), ErrorCode.CommaOrCloseBacketExpected, node); | ||
@@ -1084,3 +1084,3 @@ } | ||
if (!key) { | ||
if (scanner.getToken() === 16 /* Unknown */) { | ||
if (scanner.getToken() === 16 /* Json.SyntaxKind.Unknown */) { | ||
// give a more helpful error message | ||
@@ -1098,14 +1098,18 @@ _error(localize('DoubleQuotesExpected', 'Property keys must be doublequoted'), ErrorCode.Undefined); | ||
node.keyNode = key; | ||
const seen = keysSeen[key.value]; | ||
if (seen) { | ||
_errorAtRange(localize('DuplicateKeyWarning', "Duplicate object key"), ErrorCode.DuplicateKey, node.keyNode.offset, node.keyNode.offset + node.keyNode.length, DiagnosticSeverity.Warning); | ||
if (isObject(seen)) { | ||
_errorAtRange(localize('DuplicateKeyWarning', "Duplicate object key"), ErrorCode.DuplicateKey, seen.keyNode.offset, seen.keyNode.offset + seen.keyNode.length, DiagnosticSeverity.Warning); | ||
// For JSON files that forbid code comments, there is a convention to use the key name "//" to add comments. | ||
// Multiple instances of "//" are okay. | ||
if (key.value !== "//") { | ||
const seen = keysSeen[key.value]; | ||
if (seen) { | ||
_errorAtRange(localize('DuplicateKeyWarning', "Duplicate object key"), ErrorCode.DuplicateKey, node.keyNode.offset, node.keyNode.offset + node.keyNode.length, DiagnosticSeverity.Warning); | ||
if (isObject(seen)) { | ||
_errorAtRange(localize('DuplicateKeyWarning', "Duplicate object key"), ErrorCode.DuplicateKey, seen.keyNode.offset, seen.keyNode.offset + seen.keyNode.length, DiagnosticSeverity.Warning); | ||
} | ||
keysSeen[key.value] = true; // if the same key is duplicate again, avoid duplicate error reporting | ||
} | ||
keysSeen[key.value] = true; // if the same key is duplicate again, avoid duplicate error reporting | ||
else { | ||
keysSeen[key.value] = node; | ||
} | ||
} | ||
else { | ||
keysSeen[key.value] = node; | ||
} | ||
if (scanner.getToken() === 6 /* ColonToken */) { | ||
if (scanner.getToken() === 6 /* Json.SyntaxKind.ColonToken */) { | ||
node.colonOffset = scanner.getTokenOffset(); | ||
@@ -1116,3 +1120,3 @@ _scanNext(); // consume ColonToken | ||
_error(localize('ColonExpected', 'Colon expected'), ErrorCode.ColonExpected); | ||
if (scanner.getToken() === 10 /* StringLiteral */ && textDocument.positionAt(key.offset + key.length).line < textDocument.positionAt(scanner.getTokenOffset()).line) { | ||
if (scanner.getToken() === 10 /* Json.SyntaxKind.StringLiteral */ && textDocument.positionAt(key.offset + key.length).line < textDocument.positionAt(scanner.getTokenOffset()).line) { | ||
node.length = key.length; | ||
@@ -1124,3 +1128,3 @@ return node; | ||
if (!value) { | ||
return _error(localize('ValueExpected', 'Value expected'), ErrorCode.ValueExpected, node, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]); | ||
return _error(localize('ValueExpected', 'Value expected'), ErrorCode.ValueExpected, node, [], [2 /* Json.SyntaxKind.CloseBraceToken */, 5 /* Json.SyntaxKind.CommaToken */]); | ||
} | ||
@@ -1132,3 +1136,3 @@ node.valueNode = value; | ||
function _parseObject(parent) { | ||
if (scanner.getToken() !== 1 /* OpenBraceToken */) { | ||
if (scanner.getToken() !== 1 /* Json.SyntaxKind.OpenBraceToken */) { | ||
return undefined; | ||
@@ -1140,4 +1144,4 @@ } | ||
let needsComma = false; | ||
while (scanner.getToken() !== 2 /* CloseBraceToken */ && scanner.getToken() !== 17 /* EOF */) { | ||
if (scanner.getToken() === 5 /* CommaToken */) { | ||
while (scanner.getToken() !== 2 /* Json.SyntaxKind.CloseBraceToken */ && scanner.getToken() !== 17 /* Json.SyntaxKind.EOF */) { | ||
if (scanner.getToken() === 5 /* Json.SyntaxKind.CommaToken */) { | ||
if (!needsComma) { | ||
@@ -1148,3 +1152,3 @@ _error(localize('PropertyExpected', 'Property expected'), ErrorCode.PropertyExpected); | ||
_scanNext(); // consume comma | ||
if (scanner.getToken() === 2 /* CloseBraceToken */) { | ||
if (scanner.getToken() === 2 /* Json.SyntaxKind.CloseBraceToken */) { | ||
if (needsComma) { | ||
@@ -1161,3 +1165,3 @@ _errorAtRange(localize('TrailingComma', 'Trailing comma'), ErrorCode.TrailingComma, commaOffset, commaOffset + 1); | ||
if (!property) { | ||
_error(localize('PropertyExpected', 'Property expected'), ErrorCode.PropertyExpected, undefined, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]); | ||
_error(localize('PropertyExpected', 'Property expected'), ErrorCode.PropertyExpected, undefined, [], [2 /* Json.SyntaxKind.CloseBraceToken */, 5 /* Json.SyntaxKind.CommaToken */]); | ||
} | ||
@@ -1169,3 +1173,3 @@ else { | ||
} | ||
if (scanner.getToken() !== 2 /* CloseBraceToken */) { | ||
if (scanner.getToken() !== 2 /* Json.SyntaxKind.CloseBraceToken */) { | ||
return _error(localize('ExpectedCloseBrace', 'Expected comma or closing brace'), ErrorCode.CommaOrCloseBraceExpected, node); | ||
@@ -1176,3 +1180,3 @@ } | ||
function _parseString(parent) { | ||
if (scanner.getToken() !== 10 /* StringLiteral */) { | ||
if (scanner.getToken() !== 10 /* Json.SyntaxKind.StringLiteral */) { | ||
return undefined; | ||
@@ -1185,7 +1189,7 @@ } | ||
function _parseNumber(parent) { | ||
if (scanner.getToken() !== 11 /* NumericLiteral */) { | ||
if (scanner.getToken() !== 11 /* Json.SyntaxKind.NumericLiteral */) { | ||
return undefined; | ||
} | ||
const node = new NumberASTNodeImpl(parent, scanner.getTokenOffset()); | ||
if (scanner.getTokenError() === 0 /* None */) { | ||
if (scanner.getTokenError() === 0 /* Json.ScanError.None */) { | ||
const tokenValue = scanner.getTokenValue(); | ||
@@ -1209,7 +1213,7 @@ try { | ||
switch (scanner.getToken()) { | ||
case 7 /* NullKeyword */: | ||
case 7 /* Json.SyntaxKind.NullKeyword */: | ||
return _finalize(new NullASTNodeImpl(parent, scanner.getTokenOffset()), true); | ||
case 8 /* TrueKeyword */: | ||
case 8 /* Json.SyntaxKind.TrueKeyword */: | ||
return _finalize(new BooleanASTNodeImpl(parent, true, scanner.getTokenOffset()), true); | ||
case 9 /* FalseKeyword */: | ||
case 9 /* Json.SyntaxKind.FalseKeyword */: | ||
return _finalize(new BooleanASTNodeImpl(parent, false, scanner.getTokenOffset()), true); | ||
@@ -1225,3 +1229,3 @@ default: | ||
const token = _scanNext(); | ||
if (token !== 17 /* EOF */) { | ||
if (token !== 17 /* Json.SyntaxKind.EOF */) { | ||
_root = _parseValue(_root); | ||
@@ -1231,3 +1235,3 @@ if (!_root) { | ||
} | ||
else if (scanner.getToken() !== 17 /* EOF */) { | ||
else if (scanner.getToken() !== 17 /* Json.SyntaxKind.EOF */) { | ||
_error(localize('End of file expected', 'End of file expected.'), ErrorCode.Undefined); | ||
@@ -1234,0 +1238,0 @@ } |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -793,2 +793,8 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
if (isDefined(propertySchema.const)) { | ||
if (!value) { | ||
value = this.getInsertTextForGuessedValue(propertySchema.const, ''); | ||
} | ||
nValueProposals++; | ||
} | ||
if (isDefined(propertySchema.default)) { | ||
@@ -859,6 +865,6 @@ if (!value) { | ||
switch (token) { | ||
case 5 /* CommaToken */: | ||
case 2 /* CloseBraceToken */: | ||
case 4 /* CloseBracketToken */: | ||
case 17 /* EOF */: | ||
case 5 /* Json.SyntaxKind.CommaToken */: | ||
case 2 /* Json.SyntaxKind.CloseBraceToken */: | ||
case 4 /* Json.SyntaxKind.CloseBracketToken */: | ||
case 17 /* Json.SyntaxKind.EOF */: | ||
return ''; | ||
@@ -877,3 +883,3 @@ default: | ||
const token = scanner.scan(); | ||
if (token === 5 /* CommaToken */ && offset >= scanner.getTokenOffset() + scanner.getTokenLength()) { | ||
if (token === 5 /* Json.SyntaxKind.CommaToken */ && offset >= scanner.getTokenOffset() + scanner.getTokenLength()) { | ||
return i + 1; | ||
@@ -893,6 +899,6 @@ } | ||
let token = scanner.scan(); | ||
while (token !== 17 /* EOF */ && (scanner.getTokenOffset() + scanner.getTokenLength() < offset)) { | ||
while (token !== 17 /* Json.SyntaxKind.EOF */ && (scanner.getTokenOffset() + scanner.getTokenLength() < offset)) { | ||
token = scanner.scan(); | ||
} | ||
return (token === 12 /* LineCommentTrivia */ || token === 13 /* BlockCommentTrivia */) && scanner.getTokenOffset() <= offset; | ||
return (token === 12 /* Json.SyntaxKind.LineCommentTrivia */ || token === 13 /* Json.SyntaxKind.BlockCommentTrivia */) && scanner.getTokenOffset() <= offset; | ||
} | ||
@@ -899,0 +905,0 @@ fromMarkup(markupString) { |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -18,14 +18,14 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
while (token !== 17 /* EOF */) { | ||
while (token !== 17 /* SyntaxKind.EOF */) { | ||
switch (token) { | ||
case 1 /* OpenBraceToken */: | ||
case 3 /* OpenBracketToken */: { | ||
case 1 /* SyntaxKind.OpenBraceToken */: | ||
case 3 /* SyntaxKind.OpenBracketToken */: { | ||
const startLine = document.positionAt(scanner.getTokenOffset()).line; | ||
const range = { startLine, endLine: startLine, kind: token === 1 /* OpenBraceToken */ ? 'object' : 'array' }; | ||
const range = { startLine, endLine: startLine, kind: token === 1 /* SyntaxKind.OpenBraceToken */ ? 'object' : 'array' }; | ||
stack.push(range); | ||
break; | ||
} | ||
case 2 /* CloseBraceToken */: | ||
case 4 /* CloseBracketToken */: { | ||
const kind = token === 2 /* CloseBraceToken */ ? 'object' : 'array'; | ||
case 2 /* SyntaxKind.CloseBraceToken */: | ||
case 4 /* SyntaxKind.CloseBracketToken */: { | ||
const kind = token === 2 /* SyntaxKind.CloseBraceToken */ ? 'object' : 'array'; | ||
if (stack.length > 0 && stack[stack.length - 1].kind === kind) { | ||
@@ -42,6 +42,6 @@ const range = stack.pop(); | ||
} | ||
case 13 /* BlockCommentTrivia */: { | ||
case 13 /* SyntaxKind.BlockCommentTrivia */: { | ||
const startLine = document.positionAt(scanner.getTokenOffset()).line; | ||
const endLine = document.positionAt(scanner.getTokenOffset() + scanner.getTokenLength()).line; | ||
if (scanner.getTokenError() === 1 /* UnexpectedEndOfComment */ && startLine + 1 < document.lineCount) { | ||
if (scanner.getTokenError() === 1 /* ScanError.UnexpectedEndOfComment */ && startLine + 1 < document.lineCount) { | ||
scanner.setPosition(document.offsetAt(Position.create(startLine + 1, 0))); | ||
@@ -57,3 +57,3 @@ } | ||
} | ||
case 12 /* LineCommentTrivia */: { | ||
case 12 /* SyntaxKind.LineCommentTrivia */: { | ||
const text = document.getText().substr(scanner.getTokenOffset(), scanner.getTokenLength()); | ||
@@ -60,0 +60,0 @@ const m = text.match(/^\/\/\s*#(region\b)|(endregion\b)/); |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -32,3 +32,3 @@ /*--------------------------------------------------------------------------------------------- | ||
if (node.type === 'property' || node.parent && node.parent.type === 'array') { | ||
const afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* CommaToken */); | ||
const afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* SyntaxKind.CommaToken */); | ||
if (afterCommaOffset !== -1) { | ||
@@ -35,0 +35,0 @@ result.push(newRange(node.offset, afterCommaOffset)); |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService'; |
@@ -0,0 +0,0 @@ (function (factory) { |
@@ -0,0 +0,0 @@ import { Thenable, ASTNode, Color, ColorInformation, ColorPresentation, LanguageServiceParams, LanguageSettings, DocumentLanguageSettings, FoldingRange, JSONSchema, SelectionRange, FoldingRangesContext, DocumentSymbolsContext, ColorInformationContext as DocumentColorsContext, TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, FormattingOptions, DocumentSymbol, DefinitionLink, MatchingSchema, JSONLanguageStatus } from './jsonLanguageTypes'; |
@@ -7,3 +7,7 @@ /*--------------------------------------------------------------------------------------------- | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -83,3 +87,3 @@ if (k2 === undefined) k2 = k; | ||
} | ||
const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n' }; | ||
const options = { tabSize: o ? o.tabSize : 4, insertSpaces: o?.insertSpaces === true, insertFinalNewline: o?.insertFinalNewline === true, eol: '\n', keepLines: o?.keepLines === true }; | ||
return (0, jsonc_parser_1.format)(d.getText(), range, options).map(e => { | ||
@@ -86,0 +90,0 @@ return jsonLanguageTypes_1.TextEdit.replace(jsonLanguageTypes_1.Range.create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content); |
@@ -279,2 +279,3 @@ import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions'; | ||
insertFinalNewline?: boolean; | ||
keepLines?: boolean; | ||
} |
@@ -16,6 +16,7 @@ /*--------------------------------------------------------------------------------------------- | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClientCapabilities = exports.ErrorCode = exports.DocumentHighlightKind = exports.VersionedTextDocumentIdentifier = exports.TextDocumentEdit = exports.CodeActionKind = exports.TextEdit = exports.WorkspaceEdit = exports.DocumentLink = exports.DocumentHighlight = exports.CodeAction = exports.Command = exports.CodeActionContext = exports.MarkedString = exports.Hover = exports.Location = exports.DocumentSymbol = exports.SymbolKind = exports.SymbolInformation = exports.InsertTextFormat = exports.CompletionItemTag = exports.CompletionList = exports.CompletionItemKind = exports.CompletionItem = exports.DiagnosticSeverity = exports.Diagnostic = exports.SelectionRange = exports.FoldingRangeKind = exports.FoldingRange = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.MarkupKind = exports.MarkupContent = exports.Position = exports.Range = exports.TextDocument = void 0; | ||
exports.ClientCapabilities = exports.ErrorCode = exports.DocumentHighlightKind = exports.VersionedTextDocumentIdentifier = exports.TextDocumentEdit = exports.CodeActionKind = exports.TextEdit = exports.WorkspaceEdit = exports.DocumentLink = exports.DocumentHighlight = exports.CodeAction = exports.Command = exports.CodeActionContext = exports.MarkedString = exports.Hover = exports.Location = exports.DocumentSymbol = exports.SymbolKind = exports.SymbolInformation = exports.InsertTextFormat = exports.CompletionItemTag = exports.CompletionList = exports.CompletionItemKind = exports.CompletionItem = exports.DiagnosticSeverity = exports.Diagnostic = exports.SelectionRange = exports.FoldingRangeKind = exports.FoldingRange = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.MarkupKind = exports.MarkupContent = exports.DocumentUri = exports.Position = exports.Range = exports.TextDocument = void 0; | ||
const vscode_languageserver_types_1 = require("vscode-languageserver-types"); | ||
Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return vscode_languageserver_types_1.Range; } }); | ||
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return vscode_languageserver_types_1.Position; } }); | ||
Object.defineProperty(exports, "DocumentUri", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentUri; } }); | ||
Object.defineProperty(exports, "MarkupContent", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupContent; } }); | ||
@@ -22,0 +23,0 @@ Object.defineProperty(exports, "MarkupKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupKind; } }); |
@@ -0,0 +0,0 @@ export declare type JSONSchemaRef = JSONSchema | boolean; |
@@ -0,0 +0,0 @@ (function (factory) { |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -805,2 +805,8 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
if ((0, objects_1.isDefined)(propertySchema.const)) { | ||
if (!value) { | ||
value = this.getInsertTextForGuessedValue(propertySchema.const, ''); | ||
} | ||
nValueProposals++; | ||
} | ||
if ((0, objects_1.isDefined)(propertySchema.default)) { | ||
@@ -871,6 +877,6 @@ if (!value) { | ||
switch (token) { | ||
case 5 /* CommaToken */: | ||
case 2 /* CloseBraceToken */: | ||
case 4 /* CloseBracketToken */: | ||
case 17 /* EOF */: | ||
case 5 /* Json.SyntaxKind.CommaToken */: | ||
case 2 /* Json.SyntaxKind.CloseBraceToken */: | ||
case 4 /* Json.SyntaxKind.CloseBracketToken */: | ||
case 17 /* Json.SyntaxKind.EOF */: | ||
return ''; | ||
@@ -889,3 +895,3 @@ default: | ||
const token = scanner.scan(); | ||
if (token === 5 /* CommaToken */ && offset >= scanner.getTokenOffset() + scanner.getTokenLength()) { | ||
if (token === 5 /* Json.SyntaxKind.CommaToken */ && offset >= scanner.getTokenOffset() + scanner.getTokenLength()) { | ||
return i + 1; | ||
@@ -905,6 +911,6 @@ } | ||
let token = scanner.scan(); | ||
while (token !== 17 /* EOF */ && (scanner.getTokenOffset() + scanner.getTokenLength() < offset)) { | ||
while (token !== 17 /* Json.SyntaxKind.EOF */ && (scanner.getTokenOffset() + scanner.getTokenLength() < offset)) { | ||
token = scanner.scan(); | ||
} | ||
return (token === 12 /* LineCommentTrivia */ || token === 13 /* BlockCommentTrivia */) && scanner.getTokenOffset() <= offset; | ||
return (token === 12 /* Json.SyntaxKind.LineCommentTrivia */ || token === 13 /* Json.SyntaxKind.BlockCommentTrivia */) && scanner.getTokenOffset() <= offset; | ||
} | ||
@@ -911,0 +917,0 @@ fromMarkup(markupString) { |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -30,14 +30,14 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
while (token !== 17 /* EOF */) { | ||
while (token !== 17 /* SyntaxKind.EOF */) { | ||
switch (token) { | ||
case 1 /* OpenBraceToken */: | ||
case 3 /* OpenBracketToken */: { | ||
case 1 /* SyntaxKind.OpenBraceToken */: | ||
case 3 /* SyntaxKind.OpenBracketToken */: { | ||
const startLine = document.positionAt(scanner.getTokenOffset()).line; | ||
const range = { startLine, endLine: startLine, kind: token === 1 /* OpenBraceToken */ ? 'object' : 'array' }; | ||
const range = { startLine, endLine: startLine, kind: token === 1 /* SyntaxKind.OpenBraceToken */ ? 'object' : 'array' }; | ||
stack.push(range); | ||
break; | ||
} | ||
case 2 /* CloseBraceToken */: | ||
case 4 /* CloseBracketToken */: { | ||
const kind = token === 2 /* CloseBraceToken */ ? 'object' : 'array'; | ||
case 2 /* SyntaxKind.CloseBraceToken */: | ||
case 4 /* SyntaxKind.CloseBracketToken */: { | ||
const kind = token === 2 /* SyntaxKind.CloseBraceToken */ ? 'object' : 'array'; | ||
if (stack.length > 0 && stack[stack.length - 1].kind === kind) { | ||
@@ -54,6 +54,6 @@ const range = stack.pop(); | ||
} | ||
case 13 /* BlockCommentTrivia */: { | ||
case 13 /* SyntaxKind.BlockCommentTrivia */: { | ||
const startLine = document.positionAt(scanner.getTokenOffset()).line; | ||
const endLine = document.positionAt(scanner.getTokenOffset() + scanner.getTokenLength()).line; | ||
if (scanner.getTokenError() === 1 /* UnexpectedEndOfComment */ && startLine + 1 < document.lineCount) { | ||
if (scanner.getTokenError() === 1 /* ScanError.UnexpectedEndOfComment */ && startLine + 1 < document.lineCount) { | ||
scanner.setPosition(document.offsetAt(jsonLanguageTypes_1.Position.create(startLine + 1, 0))); | ||
@@ -69,3 +69,3 @@ } | ||
} | ||
case 12 /* LineCommentTrivia */: { | ||
case 12 /* SyntaxKind.LineCommentTrivia */: { | ||
const text = document.getText().substr(scanner.getTokenOffset(), scanner.getTokenLength()); | ||
@@ -72,0 +72,0 @@ const m = text.match(/^\/\/\s*#(region\b)|(endregion\b)/); |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -44,3 +44,3 @@ /*--------------------------------------------------------------------------------------------- | ||
if (node.type === 'property' || node.parent && node.parent.type === 'array') { | ||
const afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* CommaToken */); | ||
const afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* SyntaxKind.CommaToken */); | ||
if (afterCommaOffset !== -1) { | ||
@@ -47,0 +47,0 @@ result.push(newRange(node.offset, afterCommaOffset)); |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ (function (factory) { |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ /*--------------------------------------------------------------------------------------------- |
{ | ||
"name": "vscode-json-languageservice", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Language service for JSON", | ||
@@ -20,11 +20,11 @@ "main": "./lib/umd/jsonLanguageService.js", | ||
"@types/node": "16.x", | ||
"@typescript-eslint/eslint-plugin": "^5.24.0", | ||
"@typescript-eslint/parser": "^5.24.0", | ||
"eslint": "^8.15.0", | ||
"@typescript-eslint/eslint-plugin": "^5.30.6", | ||
"@typescript-eslint/parser": "^5.30.6", | ||
"eslint": "^8.19.0", | ||
"mocha": "^10.0.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.5.5" | ||
"typescript": "^4.7.4" | ||
}, | ||
"dependencies": { | ||
"jsonc-parser": "^3.0.0", | ||
"jsonc-parser": "^3.1.0", | ||
"vscode-languageserver-textdocument": "^1.0.4", | ||
@@ -31,0 +31,0 @@ "vscode-languageserver-types": "^3.17.1", |
Sorry, the diff of this file is too big to display
10226
500514
Updatedjsonc-parser@^3.1.0