vscode-json-languageservice 5.3.3 → 5.3.5
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.
|
@@ -8,8 +8,13 @@ export interface JSONWorkerContribution {
|
|
|
8
8
|
}
|
|
9
9
|
export type Segment = string | number;
|
|
10
10
|
export type JSONPath = Segment[];
|
|
11
|
+
export type JSONCompletionItem = CompletionItem & {
|
|
12
|
+
insertText: string;
|
|
13
|
+
};
|
|
11
14
|
export interface CompletionsCollector {
|
|
12
|
-
add(suggestion:
|
|
15
|
+
add(suggestion: JSONCompletionItem & {
|
|
16
|
+
insertText: string;
|
|
17
|
+
}): void;
|
|
13
18
|
error(message: string): void;
|
|
14
19
|
setAsIncomplete(): void;
|
|
15
20
|
getNumberOfProposals(): number;
|
|
@@ -74,9 +74,7 @@ export class JSONCompletion {
|
|
|
74
74
|
label = shortendedLabel;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
suggestion.textEdit = TextEdit.replace(overwriteRange, suggestion.insertText);
|
|
79
|
-
}
|
|
77
|
+
suggestion.textEdit = TextEdit.replace(overwriteRange, suggestion.insertText);
|
|
80
78
|
if (supportsCommitCharacters) {
|
|
81
79
|
suggestion.commitCharacters = suggestion.kind === CompletionItemKind.Property ? propertyCommitCharacters : valueCommitCharacters;
|
|
82
80
|
}
|
|
@@ -407,26 +405,31 @@ export class JSONCompletion {
|
|
|
407
405
|
for (const s of matchingSchemas) {
|
|
408
406
|
if (s.node === node && !s.inverted && s.schema) {
|
|
409
407
|
if (node.type === 'array' && s.schema.items) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (s.schema.uniqueItems === true && arrayValues.includes(value)) {
|
|
417
|
-
return;
|
|
408
|
+
let c = collector;
|
|
409
|
+
if (s.schema.uniqueItems) {
|
|
410
|
+
const existingValues = new Set();
|
|
411
|
+
node.children.forEach(n => {
|
|
412
|
+
if (n.type !== 'array' && n.type !== 'object') {
|
|
413
|
+
existingValues.add(this.getLabelForValue(Parser.getNodeValue(n)));
|
|
418
414
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
415
|
+
});
|
|
416
|
+
c = {
|
|
417
|
+
...collector,
|
|
418
|
+
add(suggestion) {
|
|
419
|
+
if (!existingValues.has(suggestion.label)) {
|
|
420
|
+
collector.add(suggestion);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
422
425
|
if (Array.isArray(s.schema.items)) {
|
|
423
426
|
const index = this.findItemAtOffset(node, document, offset);
|
|
424
427
|
if (index < s.schema.items.length) {
|
|
425
|
-
this.addSchemaValueCompletions(s.schema.items[index], separatorAfter,
|
|
428
|
+
this.addSchemaValueCompletions(s.schema.items[index], separatorAfter, c, types);
|
|
426
429
|
}
|
|
427
430
|
}
|
|
428
431
|
else {
|
|
429
|
-
this.addSchemaValueCompletions(s.schema.items, separatorAfter,
|
|
432
|
+
this.addSchemaValueCompletions(s.schema.items, separatorAfter, c, types);
|
|
430
433
|
}
|
|
431
434
|
}
|
|
432
435
|
if (parentKey !== undefined) {
|
|
@@ -527,7 +530,7 @@ export class JSONCompletion {
|
|
|
527
530
|
insertTextFormat: InsertTextFormat.Snippet
|
|
528
531
|
};
|
|
529
532
|
if (this.doesSupportsLabelDetails()) {
|
|
530
|
-
completionItem.labelDetails = {
|
|
533
|
+
completionItem.labelDetails = { description: l10n.t('Default value') };
|
|
531
534
|
}
|
|
532
535
|
else {
|
|
533
536
|
completionItem.detail = l10n.t('Default value');
|
|
@@ -8,8 +8,13 @@ export interface JSONWorkerContribution {
|
|
|
8
8
|
}
|
|
9
9
|
export type Segment = string | number;
|
|
10
10
|
export type JSONPath = Segment[];
|
|
11
|
+
export type JSONCompletionItem = CompletionItem & {
|
|
12
|
+
insertText: string;
|
|
13
|
+
};
|
|
11
14
|
export interface CompletionsCollector {
|
|
12
|
-
add(suggestion:
|
|
15
|
+
add(suggestion: JSONCompletionItem & {
|
|
16
|
+
insertText: string;
|
|
17
|
+
}): void;
|
|
13
18
|
error(message: string): void;
|
|
14
19
|
setAsIncomplete(): void;
|
|
15
20
|
getNumberOfProposals(): number;
|
|
@@ -86,9 +86,7 @@
|
|
|
86
86
|
label = shortendedLabel;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
suggestion.textEdit = jsonLanguageTypes_1.TextEdit.replace(overwriteRange, suggestion.insertText);
|
|
91
|
-
}
|
|
89
|
+
suggestion.textEdit = jsonLanguageTypes_1.TextEdit.replace(overwriteRange, suggestion.insertText);
|
|
92
90
|
if (supportsCommitCharacters) {
|
|
93
91
|
suggestion.commitCharacters = suggestion.kind === jsonLanguageTypes_1.CompletionItemKind.Property ? propertyCommitCharacters : valueCommitCharacters;
|
|
94
92
|
}
|
|
@@ -419,26 +417,31 @@
|
|
|
419
417
|
for (const s of matchingSchemas) {
|
|
420
418
|
if (s.node === node && !s.inverted && s.schema) {
|
|
421
419
|
if (node.type === 'array' && s.schema.items) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (s.schema.uniqueItems === true && arrayValues.includes(value)) {
|
|
429
|
-
return;
|
|
420
|
+
let c = collector;
|
|
421
|
+
if (s.schema.uniqueItems) {
|
|
422
|
+
const existingValues = new Set();
|
|
423
|
+
node.children.forEach(n => {
|
|
424
|
+
if (n.type !== 'array' && n.type !== 'object') {
|
|
425
|
+
existingValues.add(this.getLabelForValue(Parser.getNodeValue(n)));
|
|
430
426
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
427
|
+
});
|
|
428
|
+
c = {
|
|
429
|
+
...collector,
|
|
430
|
+
add(suggestion) {
|
|
431
|
+
if (!existingValues.has(suggestion.label)) {
|
|
432
|
+
collector.add(suggestion);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
434
437
|
if (Array.isArray(s.schema.items)) {
|
|
435
438
|
const index = this.findItemAtOffset(node, document, offset);
|
|
436
439
|
if (index < s.schema.items.length) {
|
|
437
|
-
this.addSchemaValueCompletions(s.schema.items[index], separatorAfter,
|
|
440
|
+
this.addSchemaValueCompletions(s.schema.items[index], separatorAfter, c, types);
|
|
438
441
|
}
|
|
439
442
|
}
|
|
440
443
|
else {
|
|
441
|
-
this.addSchemaValueCompletions(s.schema.items, separatorAfter,
|
|
444
|
+
this.addSchemaValueCompletions(s.schema.items, separatorAfter, c, types);
|
|
442
445
|
}
|
|
443
446
|
}
|
|
444
447
|
if (parentKey !== undefined) {
|
|
@@ -539,7 +542,7 @@
|
|
|
539
542
|
insertTextFormat: jsonLanguageTypes_1.InsertTextFormat.Snippet
|
|
540
543
|
};
|
|
541
544
|
if (this.doesSupportsLabelDetails()) {
|
|
542
|
-
completionItem.labelDetails = {
|
|
545
|
+
completionItem.labelDetails = { description: l10n.t('Default value') };
|
|
543
546
|
}
|
|
544
547
|
else {
|
|
545
548
|
completionItem.detail = l10n.t('Default value');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-json-languageservice",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.5",
|
|
4
4
|
"description": "Language service for JSON",
|
|
5
5
|
"main": "./lib/umd/jsonLanguageService.js",
|
|
6
6
|
"typings": "./lib/umd/jsonLanguageService",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/mocha": "^10.0.1",
|
|
19
19
|
"@types/node": "16.x",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
21
|
-
"@typescript-eslint/parser": "^5.59.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
|
21
|
+
"@typescript-eslint/parser": "^5.59.1",
|
|
22
22
|
"eslint": "^8.39.0",
|
|
23
23
|
"json-schema-test-suite": "https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#69acf52990b004240839ae19b4bec8fb01d50876",
|
|
24
24
|
"mocha": "^10.2.0",
|