vscode-json-languageservice 5.4.0 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService';
1
+ import { MarkedString, CompletionItem } from './jsonLanguageService';
2
2
  export interface JSONWorkerContribution {
3
- getInfoContribution(uri: string, location: JSONPath): Thenable<MarkedString[]>;
4
- collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any>;
5
- collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): Thenable<any>;
6
- collectDefaultCompletions(uri: string, result: CompletionsCollector): Thenable<any>;
7
- resolveCompletion?(item: CompletionItem): Thenable<CompletionItem>;
3
+ getInfoContribution(uri: string, location: JSONPath): PromiseLike<MarkedString[]>;
4
+ collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): PromiseLike<any>;
5
+ collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): PromiseLike<any>;
6
+ collectDefaultCompletions(uri: string, result: CompletionsCollector): PromiseLike<any>;
7
+ resolveCompletion?(item: CompletionItem): PromiseLike<CompletionItem>;
8
8
  }
9
9
  export type Segment = string | number;
10
10
  export type JSONPath = Segment[];
@@ -1,4 +1,4 @@
1
- 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, SortOptions } from './jsonLanguageTypes';
1
+ import { 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, SortOptions } from './jsonLanguageTypes';
2
2
  import { DocumentLink } from 'vscode-languageserver-types';
3
3
  export type JSONDocument = {
4
4
  root: ASTNode | undefined;
@@ -7,23 +7,23 @@ export type JSONDocument = {
7
7
  export * from './jsonLanguageTypes';
8
8
  export interface LanguageService {
9
9
  configure(settings: LanguageSettings): void;
10
- doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): Thenable<Diagnostic[]>;
10
+ doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): PromiseLike<Diagnostic[]>;
11
11
  parseJSONDocument(document: TextDocument): JSONDocument;
12
12
  newJSONDocument(rootNode: ASTNode, syntaxDiagnostics?: Diagnostic[]): JSONDocument;
13
13
  resetSchema(uri: string): boolean;
14
- getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): Thenable<MatchingSchema[]>;
14
+ getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): PromiseLike<MatchingSchema[]>;
15
15
  getLanguageStatus(document: TextDocument, jsonDocument: JSONDocument): JSONLanguageStatus;
16
- doResolve(item: CompletionItem): Thenable<CompletionItem>;
17
- doComplete(document: TextDocument, position: Position, doc: JSONDocument): Thenable<CompletionList | null>;
16
+ doResolve(item: CompletionItem): PromiseLike<CompletionItem>;
17
+ doComplete(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<CompletionList | null>;
18
18
  findDocumentSymbols(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): SymbolInformation[];
19
19
  findDocumentSymbols2(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
20
- findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): Thenable<ColorInformation[]>;
20
+ findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): PromiseLike<ColorInformation[]>;
21
21
  getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[];
22
- doHover(document: TextDocument, position: Position, doc: JSONDocument): Thenable<Hover | null>;
22
+ doHover(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<Hover | null>;
23
23
  getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
24
24
  getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
25
- findDefinition(document: TextDocument, position: Position, doc: JSONDocument): Thenable<DefinitionLink[]>;
26
- findLinks(document: TextDocument, doc: JSONDocument): Thenable<DocumentLink[]>;
25
+ findDefinition(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<DefinitionLink[]>;
26
+ findLinks(document: TextDocument, doc: JSONDocument): PromiseLike<DocumentLink[]>;
27
27
  format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
28
28
  sort(document: TextDocument, options: SortOptions): TextEdit[];
29
29
  }
@@ -156,7 +156,7 @@ export interface WorkspaceContextService {
156
156
  * In case of an error, returns a rejected promise with a displayable error string.
157
157
  */
158
158
  export interface SchemaRequestService {
159
- (uri: string): Thenable<string>;
159
+ (uri: string): PromiseLike<string>;
160
160
  }
161
161
  export interface PromiseConstructor {
162
162
  /**
@@ -165,36 +165,33 @@ export interface PromiseConstructor {
165
165
  * a resolve callback used resolve the promise with a value or the result of another promise,
166
166
  * and a reject callback used to reject the promise with a provided reason or error.
167
167
  */
168
- new <T>(executor: (resolve: (value?: T | Thenable<T | undefined>) => void, reject: (reason?: any) => void) => void): Thenable<T | undefined>;
168
+ new <T>(executor: (resolve: (value?: T | PromiseLike<T | undefined>) => void, reject: (reason?: any) => void) => void): PromiseLike<T | undefined>;
169
169
  /**
170
170
  * Creates a Promise that is resolved with an array of results when all of the provided Promises
171
171
  * resolve, or rejected when any Promise is rejected.
172
172
  * @param values An array of Promises.
173
173
  * @returns A new Promise.
174
174
  */
175
- all<T>(values: Array<T | Thenable<T>>): Thenable<T[]>;
175
+ all<T>(values: Array<T | PromiseLike<T>>): PromiseLike<T[]>;
176
176
  /**
177
177
  * Creates a new rejected promise for the provided reason.
178
178
  * @param reason The reason the promise was rejected.
179
179
  * @returns A new rejected Promise.
180
180
  */
181
- reject<T>(reason: any): Thenable<T>;
181
+ reject<T>(reason: any): PromiseLike<T>;
182
182
  /**
183
183
  * Creates a new resolved promise for the provided value.
184
184
  * @param value A promise.
185
185
  * @returns A promise whose internal state matches the provided promise.
186
186
  */
187
- resolve<T>(value: T | Thenable<T>): Thenable<T>;
187
+ resolve<T>(value: T | PromiseLike<T>): PromiseLike<T>;
188
188
  }
189
- export interface Thenable<R> {
190
- /**
191
- * Attaches callbacks for the resolution and/or rejection of the Promise.
192
- * @param onfulfilled The callback to execute when the Promise is resolved.
193
- * @param onrejected The callback to execute when the Promise is rejected.
194
- * @returns A Promise for the completion of which ever callback is executed.
195
- */
196
- then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
197
- then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
189
+ /**
190
+ * A deprecated alias of {@link PromiseLike}
191
+ *
192
+ * @deprecated
193
+ */
194
+ export interface Thenable<R> extends PromiseLike<R> {
198
195
  }
199
196
  export interface LanguageServiceParams {
200
197
  /**
@@ -2,7 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- // import { TextEdit} from 'vscode-languageserver-textdocument';
6
5
  import { createScanner } from 'jsonc-parser';
7
6
  import { TextDocument, TextEdit, Position, Range } from '../jsonLanguageTypes';
8
7
  import { format } from './format';
@@ -322,6 +321,13 @@ function sortJsoncDocument(jsonDocument, propertyTree) {
322
321
  }
323
322
  return sortedJsonDocument;
324
323
  }
324
+ function sortPropertiesCaseSensitive(properties) {
325
+ properties.sort((a, b) => {
326
+ const aName = a.propertyName ?? '';
327
+ const bName = b.propertyName ?? '';
328
+ return aName < bName ? -1 : aName > bName ? 1 : 0;
329
+ });
330
+ }
325
331
  function updateSortingQueue(queue, propertyTree, beginningLineNumber) {
326
332
  if (propertyTree.childrenProperties.length === 0) {
327
333
  return;
@@ -335,6 +341,7 @@ function updateSortingQueue(queue, propertyTree, beginningLineNumber) {
335
341
  }
336
342
  const diff = minimumBeginningLineNumber - propertyTree.beginningLineNumber;
337
343
  beginningLineNumber = beginningLineNumber + diff;
344
+ sortPropertiesCaseSensitive(propertyTree.childrenProperties);
338
345
  queue.push(new SortingRange(beginningLineNumber, propertyTree.childrenProperties));
339
346
  }
340
347
  else if (propertyTree.type === Container.Array) {
@@ -1,10 +1,10 @@
1
- import { Thenable, MarkedString, CompletionItem } from './jsonLanguageService';
1
+ import { MarkedString, CompletionItem } from './jsonLanguageService';
2
2
  export interface JSONWorkerContribution {
3
- getInfoContribution(uri: string, location: JSONPath): Thenable<MarkedString[]>;
4
- collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any>;
5
- collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): Thenable<any>;
6
- collectDefaultCompletions(uri: string, result: CompletionsCollector): Thenable<any>;
7
- resolveCompletion?(item: CompletionItem): Thenable<CompletionItem>;
3
+ getInfoContribution(uri: string, location: JSONPath): PromiseLike<MarkedString[]>;
4
+ collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): PromiseLike<any>;
5
+ collectValueCompletions(uri: string, location: JSONPath, propertyKey: string, result: CompletionsCollector): PromiseLike<any>;
6
+ collectDefaultCompletions(uri: string, result: CompletionsCollector): PromiseLike<any>;
7
+ resolveCompletion?(item: CompletionItem): PromiseLike<CompletionItem>;
8
8
  }
9
9
  export type Segment = string | number;
10
10
  export type JSONPath = Segment[];
@@ -1,4 +1,4 @@
1
- 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, SortOptions } from './jsonLanguageTypes';
1
+ import { 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, SortOptions } from './jsonLanguageTypes';
2
2
  import { DocumentLink } from 'vscode-languageserver-types';
3
3
  export type JSONDocument = {
4
4
  root: ASTNode | undefined;
@@ -7,23 +7,23 @@ export type JSONDocument = {
7
7
  export * from './jsonLanguageTypes';
8
8
  export interface LanguageService {
9
9
  configure(settings: LanguageSettings): void;
10
- doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): Thenable<Diagnostic[]>;
10
+ doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): PromiseLike<Diagnostic[]>;
11
11
  parseJSONDocument(document: TextDocument): JSONDocument;
12
12
  newJSONDocument(rootNode: ASTNode, syntaxDiagnostics?: Diagnostic[]): JSONDocument;
13
13
  resetSchema(uri: string): boolean;
14
- getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): Thenable<MatchingSchema[]>;
14
+ getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): PromiseLike<MatchingSchema[]>;
15
15
  getLanguageStatus(document: TextDocument, jsonDocument: JSONDocument): JSONLanguageStatus;
16
- doResolve(item: CompletionItem): Thenable<CompletionItem>;
17
- doComplete(document: TextDocument, position: Position, doc: JSONDocument): Thenable<CompletionList | null>;
16
+ doResolve(item: CompletionItem): PromiseLike<CompletionItem>;
17
+ doComplete(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<CompletionList | null>;
18
18
  findDocumentSymbols(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): SymbolInformation[];
19
19
  findDocumentSymbols2(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
20
- findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): Thenable<ColorInformation[]>;
20
+ findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): PromiseLike<ColorInformation[]>;
21
21
  getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[];
22
- doHover(document: TextDocument, position: Position, doc: JSONDocument): Thenable<Hover | null>;
22
+ doHover(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<Hover | null>;
23
23
  getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
24
24
  getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
25
- findDefinition(document: TextDocument, position: Position, doc: JSONDocument): Thenable<DefinitionLink[]>;
26
- findLinks(document: TextDocument, doc: JSONDocument): Thenable<DocumentLink[]>;
25
+ findDefinition(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<DefinitionLink[]>;
26
+ findLinks(document: TextDocument, doc: JSONDocument): PromiseLike<DocumentLink[]>;
27
27
  format(document: TextDocument, range: Range, options: FormattingOptions): TextEdit[];
28
28
  sort(document: TextDocument, options: SortOptions): TextEdit[];
29
29
  }
@@ -27,7 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
27
  })(function (require, exports) {
28
28
  "use strict";
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.getLanguageService = void 0;
30
+ exports.getLanguageService = getLanguageService;
31
31
  const jsonCompletion_1 = require("./services/jsonCompletion");
32
32
  const jsonHover_1 = require("./services/jsonHover");
33
33
  const jsonValidation_1 = require("./services/jsonValidation");
@@ -76,5 +76,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
76
76
  sort: (document, options) => (0, sort_1.sort)(document, options)
77
77
  };
78
78
  }
79
- exports.getLanguageService = getLanguageService;
80
79
  });
@@ -156,7 +156,7 @@ export interface WorkspaceContextService {
156
156
  * In case of an error, returns a rejected promise with a displayable error string.
157
157
  */
158
158
  export interface SchemaRequestService {
159
- (uri: string): Thenable<string>;
159
+ (uri: string): PromiseLike<string>;
160
160
  }
161
161
  export interface PromiseConstructor {
162
162
  /**
@@ -165,36 +165,33 @@ export interface PromiseConstructor {
165
165
  * a resolve callback used resolve the promise with a value or the result of another promise,
166
166
  * and a reject callback used to reject the promise with a provided reason or error.
167
167
  */
168
- new <T>(executor: (resolve: (value?: T | Thenable<T | undefined>) => void, reject: (reason?: any) => void) => void): Thenable<T | undefined>;
168
+ new <T>(executor: (resolve: (value?: T | PromiseLike<T | undefined>) => void, reject: (reason?: any) => void) => void): PromiseLike<T | undefined>;
169
169
  /**
170
170
  * Creates a Promise that is resolved with an array of results when all of the provided Promises
171
171
  * resolve, or rejected when any Promise is rejected.
172
172
  * @param values An array of Promises.
173
173
  * @returns A new Promise.
174
174
  */
175
- all<T>(values: Array<T | Thenable<T>>): Thenable<T[]>;
175
+ all<T>(values: Array<T | PromiseLike<T>>): PromiseLike<T[]>;
176
176
  /**
177
177
  * Creates a new rejected promise for the provided reason.
178
178
  * @param reason The reason the promise was rejected.
179
179
  * @returns A new rejected Promise.
180
180
  */
181
- reject<T>(reason: any): Thenable<T>;
181
+ reject<T>(reason: any): PromiseLike<T>;
182
182
  /**
183
183
  * Creates a new resolved promise for the provided value.
184
184
  * @param value A promise.
185
185
  * @returns A promise whose internal state matches the provided promise.
186
186
  */
187
- resolve<T>(value: T | Thenable<T>): Thenable<T>;
187
+ resolve<T>(value: T | PromiseLike<T>): PromiseLike<T>;
188
188
  }
189
- export interface Thenable<R> {
190
- /**
191
- * Attaches callbacks for the resolution and/or rejection of the Promise.
192
- * @param onfulfilled The callback to execute when the Promise is resolved.
193
- * @param onrejected The callback to execute when the Promise is rejected.
194
- * @returns A Promise for the completion of which ever callback is executed.
195
- */
196
- then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
197
- then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
189
+ /**
190
+ * A deprecated alias of {@link PromiseLike}
191
+ *
192
+ * @deprecated
193
+ */
194
+ export interface Thenable<R> extends PromiseLike<R> {
198
195
  }
199
196
  export interface LanguageServiceParams {
200
197
  /**
@@ -13,7 +13,13 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.parse = exports.JSONDocument = exports.contains = exports.getNodePath = exports.getNodeValue = exports.newJSONDocument = exports.ValidationResult = exports.EnumMatch = exports.asSchema = exports.ObjectASTNodeImpl = exports.PropertyASTNodeImpl = exports.StringASTNodeImpl = exports.NumberASTNodeImpl = exports.ArrayASTNodeImpl = exports.BooleanASTNodeImpl = exports.NullASTNodeImpl = exports.ASTNodeImpl = void 0;
16
+ exports.JSONDocument = exports.ValidationResult = exports.EnumMatch = exports.ObjectASTNodeImpl = exports.PropertyASTNodeImpl = exports.StringASTNodeImpl = exports.NumberASTNodeImpl = exports.ArrayASTNodeImpl = exports.BooleanASTNodeImpl = exports.NullASTNodeImpl = exports.ASTNodeImpl = void 0;
17
+ exports.asSchema = asSchema;
18
+ exports.newJSONDocument = newJSONDocument;
19
+ exports.getNodeValue = getNodeValue;
20
+ exports.getNodePath = getNodePath;
21
+ exports.contains = contains;
22
+ exports.parse = parse;
17
23
  const Json = require("jsonc-parser");
18
24
  const objects_1 = require("../utils/objects");
19
25
  const strings_1 = require("../utils/strings");
@@ -116,7 +122,6 @@
116
122
  }
117
123
  return schema;
118
124
  }
119
- exports.asSchema = asSchema;
120
125
  var EnumMatch;
121
126
  (function (EnumMatch) {
122
127
  EnumMatch[EnumMatch["Key"] = 0] = "Key";
@@ -226,19 +231,15 @@
226
231
  function newJSONDocument(root, diagnostics = []) {
227
232
  return new JSONDocument(root, diagnostics, []);
228
233
  }
229
- exports.newJSONDocument = newJSONDocument;
230
234
  function getNodeValue(node) {
231
235
  return Json.getNodeValue(node);
232
236
  }
233
- exports.getNodeValue = getNodeValue;
234
237
  function getNodePath(node) {
235
238
  return Json.getNodePath(node);
236
239
  }
237
- exports.getNodePath = getNodePath;
238
240
  function contains(node, offset, includeRightBound = false) {
239
241
  return offset >= node.offset && offset < (node.offset + node.length) || includeRightBound && offset === (node.offset + node.length);
240
242
  }
241
- exports.contains = contains;
242
243
  class JSONDocument {
243
244
  constructor(root, syntaxErrors = [], comments = []) {
244
245
  this.root = root;
@@ -1269,5 +1270,4 @@
1269
1270
  }
1270
1271
  return new JSONDocument(_root, problems, commentRanges);
1271
1272
  }
1272
- exports.parse = parse;
1273
1273
  });
@@ -13,7 +13,7 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.getFoldingRanges = void 0;
16
+ exports.getFoldingRanges = getFoldingRanges;
17
17
  const jsonc_parser_1 = require("jsonc-parser");
18
18
  const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
19
19
  function getFoldingRanges(document, context) {
@@ -130,5 +130,4 @@
130
130
  }
131
131
  return result;
132
132
  }
133
- exports.getFoldingRanges = getFoldingRanges;
134
133
  });
@@ -13,7 +13,7 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.findLinks = void 0;
16
+ exports.findLinks = findLinks;
17
17
  const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
18
18
  function findLinks(document, doc) {
19
19
  const links = [];
@@ -33,7 +33,6 @@
33
33
  });
34
34
  return Promise.resolve(links);
35
35
  }
36
- exports.findLinks = findLinks;
37
36
  function createRange(document, node) {
38
37
  return jsonLanguageTypes_1.Range.create(document.positionAt(node.offset + 1), document.positionAt(node.offset + node.length - 1));
39
38
  }
@@ -13,7 +13,7 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.getSelectionRanges = void 0;
16
+ exports.getSelectionRanges = getSelectionRanges;
17
17
  const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
18
18
  const jsonc_parser_1 = require("jsonc-parser");
19
19
  function getSelectionRanges(document, positions, doc) {
@@ -71,5 +71,4 @@
71
71
  }
72
72
  return positions.map(getSelectionRange);
73
73
  }
74
- exports.getSelectionRanges = getSelectionRanges;
75
74
  });
@@ -13,7 +13,9 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = void 0;
16
+ exports.hexDigit = hexDigit;
17
+ exports.colorFromHex = colorFromHex;
18
+ exports.colorFrom256RGB = colorFrom256RGB;
17
19
  const Digit0 = 48;
18
20
  const Digit9 = 57;
19
21
  const A = 65;
@@ -34,7 +36,6 @@
34
36
  }
35
37
  return 0;
36
38
  }
37
- exports.hexDigit = hexDigit;
38
39
  function colorFromHex(text) {
39
40
  if (text[0] !== '#') {
40
41
  return undefined;
@@ -71,7 +72,6 @@
71
72
  }
72
73
  return undefined;
73
74
  }
74
- exports.colorFromHex = colorFromHex;
75
75
  function colorFrom256RGB(red, green, blue, alpha = 1.0) {
76
76
  return {
77
77
  red: red / 255.0,
@@ -80,5 +80,4 @@
80
80
  alpha
81
81
  };
82
82
  }
83
- exports.colorFrom256RGB = colorFrom256RGB;
84
83
  });
@@ -9,7 +9,7 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.format = void 0;
12
+ exports.format = format;
13
13
  const jsonc_parser_1 = require("jsonc-parser");
14
14
  const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
15
15
  function format(documentToFormat, formattingOptions, formattingRange) {
@@ -30,5 +30,4 @@
30
30
  return jsonLanguageTypes_1.TextEdit.replace(jsonLanguageTypes_1.Range.create(documentToFormat.positionAt(edit.offset), documentToFormat.positionAt(edit.offset + edit.length)), edit.content);
31
31
  });
32
32
  }
33
- exports.format = format;
34
33
  });
@@ -9,7 +9,7 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createRegex = void 0;
12
+ exports.createRegex = createRegex;
13
13
  /*---------------------------------------------------------------------------------------------
14
14
  * Copyright (c) Microsoft Corporation. All rights reserved.
15
15
  * Copyright (c) 2013, Nick Fitzgerald
@@ -133,6 +133,5 @@
133
133
  }
134
134
  return new RegExp(reStr, flags);
135
135
  }
136
- exports.createRegex = createRegex;
137
136
  ;
138
137
  });
@@ -13,7 +13,7 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.stringifyObject = void 0;
16
+ exports.stringifyObject = stringifyObject;
17
17
  function stringifyObject(obj, indent, stringifyLiteral) {
18
18
  if (obj !== null && typeof obj === 'object') {
19
19
  const newIndent = indent + '\t';
@@ -52,5 +52,4 @@
52
52
  }
53
53
  return stringifyLiteral(obj);
54
54
  }
55
- exports.stringifyObject = stringifyObject;
56
55
  });
@@ -13,7 +13,12 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.isObject = exports.isString = exports.isBoolean = exports.isDefined = exports.isNumber = exports.equals = void 0;
16
+ exports.equals = equals;
17
+ exports.isNumber = isNumber;
18
+ exports.isDefined = isDefined;
19
+ exports.isBoolean = isBoolean;
20
+ exports.isString = isString;
21
+ exports.isObject = isObject;
17
22
  function equals(one, other) {
18
23
  if (one === other) {
19
24
  return true;
@@ -63,25 +68,19 @@
63
68
  }
64
69
  return true;
65
70
  }
66
- exports.equals = equals;
67
71
  function isNumber(val) {
68
72
  return typeof val === 'number';
69
73
  }
70
- exports.isNumber = isNumber;
71
74
  function isDefined(val) {
72
75
  return typeof val !== 'undefined';
73
76
  }
74
- exports.isDefined = isDefined;
75
77
  function isBoolean(val) {
76
78
  return typeof val === 'boolean';
77
79
  }
78
- exports.isBoolean = isBoolean;
79
80
  function isString(val) {
80
81
  return typeof val === 'string';
81
82
  }
82
- exports.isString = isString;
83
83
  function isObject(val) {
84
84
  return typeof val === 'object' && val !== null && !Array.isArray(val);
85
85
  }
86
- exports.isObject = isObject;
87
86
  });
@@ -13,8 +13,7 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.sort = void 0;
17
- // import { TextEdit} from 'vscode-languageserver-textdocument';
16
+ exports.sort = sort;
18
17
  const jsonc_parser_1 = require("jsonc-parser");
19
18
  const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
20
19
  const format_1 = require("./format");
@@ -32,7 +31,6 @@
32
31
  const sortedAndFormattedJsonDocument = jsonLanguageTypes_1.TextDocument.applyEdits(sortedJsonDocument, edits);
33
32
  return [jsonLanguageTypes_1.TextEdit.replace(jsonLanguageTypes_1.Range.create(jsonLanguageTypes_1.Position.create(0, 0), documentToSort.positionAt(documentToSort.getText().length)), sortedAndFormattedJsonDocument)];
34
33
  }
35
- exports.sort = sort;
36
34
  function findJsoncPropertyTree(formattedDocument) {
37
35
  const formattedString = formattedDocument.getText();
38
36
  const scanner = (0, jsonc_parser_1.createScanner)(formattedString, false);
@@ -335,6 +333,13 @@
335
333
  }
336
334
  return sortedJsonDocument;
337
335
  }
336
+ function sortPropertiesCaseSensitive(properties) {
337
+ properties.sort((a, b) => {
338
+ const aName = a.propertyName ?? '';
339
+ const bName = b.propertyName ?? '';
340
+ return aName < bName ? -1 : aName > bName ? 1 : 0;
341
+ });
342
+ }
338
343
  function updateSortingQueue(queue, propertyTree, beginningLineNumber) {
339
344
  if (propertyTree.childrenProperties.length === 0) {
340
345
  return;
@@ -348,6 +353,7 @@
348
353
  }
349
354
  const diff = minimumBeginningLineNumber - propertyTree.beginningLineNumber;
350
355
  beginningLineNumber = beginningLineNumber + diff;
356
+ sortPropertiesCaseSensitive(propertyTree.childrenProperties);
351
357
  queue.push(new SortingRange(beginningLineNumber, propertyTree.childrenProperties));
352
358
  }
353
359
  else if (propertyTree.type === propertyTree_1.Container.Array) {
@@ -13,7 +13,12 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.stringLength = exports.extendedRegExp = exports.repeat = exports.convertSimple2RegExpPattern = exports.endsWith = exports.startsWith = void 0;
16
+ exports.startsWith = startsWith;
17
+ exports.endsWith = endsWith;
18
+ exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
19
+ exports.repeat = repeat;
20
+ exports.extendedRegExp = extendedRegExp;
21
+ exports.stringLength = stringLength;
17
22
  function startsWith(haystack, needle) {
18
23
  if (haystack.length < needle.length) {
19
24
  return false;
@@ -25,7 +30,6 @@
25
30
  }
26
31
  return true;
27
32
  }
28
- exports.startsWith = startsWith;
29
33
  /**
30
34
  * Determines if haystack ends with needle.
31
35
  */
@@ -41,11 +45,9 @@
41
45
  return false;
42
46
  }
43
47
  }
44
- exports.endsWith = endsWith;
45
48
  function convertSimple2RegExpPattern(pattern) {
46
49
  return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
47
50
  }
48
- exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
49
51
  function repeat(value, count) {
50
52
  let s = '';
51
53
  while (count > 0) {
@@ -57,7 +59,6 @@
57
59
  }
58
60
  return s;
59
61
  }
60
- exports.repeat = repeat;
61
62
  function extendedRegExp(pattern) {
62
63
  let flags = '';
63
64
  if (startsWith(pattern, '(?i)')) {
@@ -78,7 +79,6 @@
78
79
  }
79
80
  }
80
81
  }
81
- exports.extendedRegExp = extendedRegExp;
82
82
  // from https://tanishiking.github.io/posts/count-unicode-codepoint/#work-hard-with-for-statements
83
83
  function stringLength(str) {
84
84
  let count = 0;
@@ -94,5 +94,4 @@
94
94
  }
95
95
  return count;
96
96
  }
97
- exports.stringLength = stringLength;
98
97
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "5.4.0",
3
+ "version": "5.4.1",
4
4
  "description": "Language service for JSON",
5
5
  "main": "./lib/umd/jsonLanguageService.js",
6
6
  "typings": "./lib/umd/jsonLanguageService",
@@ -17,17 +17,17 @@
17
17
  "devDependencies": {
18
18
  "@types/mocha": "^10.0.7",
19
19
  "@types/node": "18.x",
20
- "@typescript-eslint/eslint-plugin": "^7.7.0",
21
- "@typescript-eslint/parser": "^7.13.1",
20
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
21
+ "@typescript-eslint/parser": "^7.18.0",
22
22
  "eslint": "^8.57.0",
23
23
  "json-schema-test-suite": "https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#69acf52990b004240839ae19b4bec8fb01d50876",
24
- "mocha": "^10.4.0",
25
- "rimraf": "^5.0.7",
26
- "typescript": "^5.4.5"
24
+ "mocha": "^10.7.3",
25
+ "rimraf": "^6.0.1",
26
+ "typescript": "^5.5.4"
27
27
  },
28
28
  "dependencies": {
29
- "jsonc-parser": "^3.3.0",
30
- "vscode-languageserver-textdocument": "^1.0.11",
29
+ "jsonc-parser": "^3.3.1",
30
+ "vscode-languageserver-textdocument": "^1.0.12",
31
31
  "vscode-languageserver-types": "^3.17.5",
32
32
  "vscode-uri": "^3.0.8",
33
33
  "@vscode/l10n": "^0.0.18"