vscode-json-languageservice 5.7.2 → 6.0.0-next.2

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/esm/jsonContributions.d.ts +1 -1
  3. package/lib/esm/jsonLanguageService.d.ts +2 -2
  4. package/lib/esm/jsonLanguageService.js +13 -13
  5. package/lib/esm/jsonLanguageTypes.d.ts +10 -2
  6. package/lib/esm/jsonSchema.d.ts +71 -2
  7. package/lib/esm/parser/jsonParser.js +224 -93
  8. package/lib/esm/services/configuration.js +2 -2
  9. package/lib/esm/services/jsonCompletion.js +5 -5
  10. package/lib/esm/services/jsonDocumentSymbols.js +4 -4
  11. package/lib/esm/services/jsonFolding.js +1 -1
  12. package/lib/esm/services/jsonHover.js +2 -2
  13. package/lib/esm/services/jsonLinks.js +94 -3
  14. package/lib/esm/services/jsonSchemaService.js +639 -100
  15. package/lib/esm/services/jsonSelectionRanges.js +1 -1
  16. package/lib/esm/services/jsonValidation.js +4 -4
  17. package/lib/esm/services/schemas/draft-2019-09-flat.d.ts +1 -1
  18. package/lib/esm/services/schemas/draft-2020-12-flat.d.ts +1 -1
  19. package/lib/esm/services/vocabularies.js +139 -0
  20. package/lib/esm/utils/format.js +1 -1
  21. package/lib/esm/utils/sort.js +3 -3
  22. package/package.json +23 -20
  23. package/lib/umd/jsonContributions.d.ts +0 -21
  24. package/lib/umd/jsonContributions.js +0 -12
  25. package/lib/umd/jsonLanguageService.d.ts +0 -30
  26. package/lib/umd/jsonLanguageService.js +0 -79
  27. package/lib/umd/jsonLanguageTypes.d.ts +0 -305
  28. package/lib/umd/jsonLanguageTypes.js +0 -109
  29. package/lib/umd/jsonSchema.d.ts +0 -92
  30. package/lib/umd/jsonSchema.js +0 -12
  31. package/lib/umd/parser/jsonParser.js +0 -1365
  32. package/lib/umd/services/configuration.js +0 -536
  33. package/lib/umd/services/jsonCompletion.js +0 -982
  34. package/lib/umd/services/jsonDocumentSymbols.js +0 -285
  35. package/lib/umd/services/jsonFolding.js +0 -133
  36. package/lib/umd/services/jsonHover.js +0 -125
  37. package/lib/umd/services/jsonLinks.js +0 -85
  38. package/lib/umd/services/jsonSchemaService.js +0 -631
  39. package/lib/umd/services/jsonSelectionRanges.js +0 -74
  40. package/lib/umd/services/jsonValidation.js +0 -165
  41. package/lib/umd/services/schemas/draft-2019-09-flat.d.ts +0 -278
  42. package/lib/umd/services/schemas/draft-2019-09-flat.js +0 -314
  43. package/lib/umd/services/schemas/draft-2020-12-flat.d.ts +0 -276
  44. package/lib/umd/services/schemas/draft-2020-12-flat.js +0 -307
  45. package/lib/umd/utils/colors.js +0 -83
  46. package/lib/umd/utils/format.js +0 -33
  47. package/lib/umd/utils/glob.js +0 -137
  48. package/lib/umd/utils/json.js +0 -55
  49. package/lib/umd/utils/objects.js +0 -86
  50. package/lib/umd/utils/propertyTree.js +0 -90
  51. package/lib/umd/utils/sort.js +0 -384
  52. package/lib/umd/utils/strings.js +0 -97
@@ -2,7 +2,7 @@
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 { Range, SelectionRange } from '../jsonLanguageTypes';
5
+ import { Range, SelectionRange } from '../jsonLanguageTypes.js';
6
6
  import { createScanner } from 'jsonc-parser';
7
7
  export function getSelectionRanges(document, positions, doc) {
8
8
  function getSelectionRange(position) {
@@ -2,9 +2,9 @@
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 { ErrorCode, Diagnostic, DiagnosticSeverity, Range } from '../jsonLanguageTypes';
5
+ import { ErrorCode, Diagnostic, DiagnosticSeverity, Range } from '../jsonLanguageTypes.js';
6
6
  import * as l10n from '@vscode/l10n';
7
- import { isBoolean } from '../utils/objects';
7
+ import { isBoolean } from '../utils/objects.js';
8
8
  export class JSONValidation {
9
9
  constructor(jsonSchemaService, promiseConstructor) {
10
10
  this.jsonSchemaService = jsonSchemaService;
@@ -60,7 +60,7 @@ export class JSONValidation {
60
60
  for (const warning of schema.warnings) {
61
61
  addSchemaProblem(warning.message, warning.code, warning.relatedInformation);
62
62
  }
63
- const semanticErrors = jsonDocument.validate(textDocument, schema.schema, schemaValidation, documentSettings?.schemaDraft);
63
+ const semanticErrors = jsonDocument.validate(textDocument, schema.schema, schemaValidation, documentSettings?.schemaDraft, schema.activeVocabularies);
64
64
  if (semanticErrors) {
65
65
  semanticErrors.forEach(addProblem);
66
66
  }
@@ -90,7 +90,7 @@ export class JSONValidation {
90
90
  return diagnostics;
91
91
  };
92
92
  if (schema) {
93
- const uri = schema.id || ('schemaservice://untitled/' + idCounter++);
93
+ const uri = schema.$id || schema.id || ('schemaservice://untitled/' + idCounter++);
94
94
  const handle = this.jsonSchemaService.registerExternalSchema({ uri, schema });
95
95
  return handle.getResolvedSchema().then(resolvedSchema => {
96
96
  return getDiagnostics(resolvedSchema);
@@ -271,7 +271,7 @@ declare const _default: {
271
271
  type: string;
272
272
  };
273
273
  uniqueItems: boolean;
274
- default: any[];
274
+ default: never[];
275
275
  };
276
276
  };
277
277
  };
@@ -269,7 +269,7 @@ declare const _default: {
269
269
  type: string;
270
270
  };
271
271
  uniqueItems: boolean;
272
- default: any[];
272
+ default: never[];
273
273
  };
274
274
  };
275
275
  };
@@ -0,0 +1,139 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { SchemaDraft } from '../jsonLanguageTypes.js';
6
+ const CORE_201909 = 'https://json-schema.org/draft/2019-09/vocab/core';
7
+ const CORE_202012 = 'https://json-schema.org/draft/2020-12/vocab/core';
8
+ const vocabularyKeywords = {
9
+ [CORE_201909]: [
10
+ '$id', '$schema', '$ref', '$anchor', '$recursiveRef',
11
+ '$recursiveAnchor', '$defs', '$comment', '$vocabulary'
12
+ ],
13
+ 'https://json-schema.org/draft/2019-09/vocab/applicator': [
14
+ 'prefixItems', 'items', 'contains', 'additionalProperties',
15
+ 'properties', 'patternProperties', 'dependentSchemas',
16
+ 'propertyNames', 'if', 'then', 'else', 'allOf', 'anyOf', 'oneOf', 'not'
17
+ ],
18
+ 'https://json-schema.org/draft/2019-09/vocab/validation': [
19
+ 'type', 'enum', 'const', 'multipleOf', 'maximum', 'exclusiveMaximum',
20
+ 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern',
21
+ 'maxItems', 'minItems', 'uniqueItems', 'maxContains', 'minContains',
22
+ 'maxProperties', 'minProperties', 'required', 'dependentRequired'
23
+ ],
24
+ 'https://json-schema.org/draft/2019-09/vocab/meta-data': [
25
+ 'title', 'description', 'default', 'deprecated',
26
+ 'readOnly', 'writeOnly', 'examples'
27
+ ],
28
+ 'https://json-schema.org/draft/2019-09/vocab/format': [
29
+ 'format'
30
+ ],
31
+ 'https://json-schema.org/draft/2019-09/vocab/content': [
32
+ 'contentEncoding', 'contentMediaType', 'contentSchema'
33
+ ],
34
+ [CORE_202012]: [
35
+ '$id', '$schema', '$ref', '$anchor', '$dynamicRef',
36
+ '$dynamicAnchor', '$defs', '$comment', '$vocabulary'
37
+ ],
38
+ 'https://json-schema.org/draft/2020-12/vocab/applicator': [
39
+ 'prefixItems', 'items', 'contains', 'additionalProperties',
40
+ 'properties', 'patternProperties', 'dependentSchemas',
41
+ 'propertyNames', 'if', 'then', 'else', 'allOf', 'anyOf', 'oneOf', 'not'
42
+ ],
43
+ 'https://json-schema.org/draft/2020-12/vocab/unevaluated': [
44
+ 'unevaluatedItems', 'unevaluatedProperties'
45
+ ],
46
+ 'https://json-schema.org/draft/2020-12/vocab/validation': [
47
+ 'type', 'enum', 'const', 'multipleOf', 'maximum', 'exclusiveMaximum',
48
+ 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern',
49
+ 'maxItems', 'minItems', 'uniqueItems', 'maxContains', 'minContains',
50
+ 'maxProperties', 'minProperties', 'required', 'dependentRequired'
51
+ ],
52
+ 'https://json-schema.org/draft/2020-12/vocab/meta-data': [
53
+ 'title', 'description', 'default', 'deprecated',
54
+ 'readOnly', 'writeOnly', 'examples'
55
+ ],
56
+ 'https://json-schema.org/draft/2020-12/vocab/format-annotation': [
57
+ 'format'
58
+ ],
59
+ 'https://json-schema.org/draft/2020-12/vocab/format-assertion': [
60
+ 'format'
61
+ ],
62
+ 'https://json-schema.org/draft/2020-12/vocab/content': [
63
+ 'contentEncoding', 'contentMediaType', 'contentSchema'
64
+ ]
65
+ };
66
+ /*
67
+ * Checks if a keyword is enabled based on the active vocabularies.
68
+ * If no vocabulary constraints are present, all keywords are enabled.
69
+ * Core keywords are always enabled regardless of vocabulary settings.
70
+ *
71
+ * @param keyword The keyword to check (e.g., 'type', 'properties', '$ref')
72
+ * @param activeVocabularies Set of active vocabulary URIs, or undefined if no constraints
73
+ * @returns true if the keyword should be processed, false otherwise
74
+ */
75
+ export function isKeywordEnabled(keyword, activeVocabularies) {
76
+ // If no vocabulary constraints, treat all keywords as enabled
77
+ if (!activeVocabularies) {
78
+ return true;
79
+ }
80
+ // Check if this keyword belongs to any active vocabulary
81
+ for (const [vocabUri, keywords] of Object.entries(vocabularyKeywords)) {
82
+ if (keywords.includes(keyword) && activeVocabularies.has(vocabUri)) {
83
+ return true;
84
+ }
85
+ }
86
+ // Core keywords are always enabled per JSON Schema spec.
87
+ // Check both 2019-09 and 2020-12 core vocabularies.
88
+ if (vocabularyKeywords[CORE_201909].includes(keyword) ||
89
+ vocabularyKeywords[CORE_202012].includes(keyword)) {
90
+ return true;
91
+ }
92
+ // Keyword not found in any vocabulary - disable it
93
+ return false;
94
+ }
95
+ /*
96
+ * Checks if format validation should produce assertion errors.
97
+ *
98
+ * According to JSON Schema 2020-12:
99
+ * - format-annotation: format is purely informational, no validation errors
100
+ * - format-assertion: format must be validated and can produce errors
101
+ *
102
+ * For backwards compatibility:
103
+ * - If no vocabularies are specified and no explicit 2019-09+ draft, format asserts
104
+ * - 2019-09 format vocabulary asserts when required, annotation-only when optional
105
+ * - 2020-12 format-assertion vocabulary asserts
106
+ * - 2020-12 format-annotation vocabulary does not assert
107
+ *
108
+ * @param activeVocabularies Map of active vocabulary URIs to required flag, or undefined if no constraints
109
+ * @param schemaDraft The explicitly declared schema draft (only set when $schema was present), or undefined
110
+ * @returns true if format validation should produce errors, false if annotation-only
111
+ */
112
+ export function isFormatAssertionEnabled(activeVocabularies, schemaDraft) {
113
+ // If vocabulary constraints are present, use them to determine format assertion
114
+ if (activeVocabularies && activeVocabularies.size > 0) {
115
+ // 2020-12 format-assertion explicitly enables format validation errors
116
+ if (activeVocabularies.has('https://json-schema.org/draft/2020-12/vocab/format-assertion')) {
117
+ return true;
118
+ }
119
+ // 2019-09 uses the format vocabulary value to control assertions:
120
+ // true enables assertion, false leaves format as annotation-only.
121
+ const format201909 = activeVocabularies.get('https://json-schema.org/draft/2019-09/vocab/format');
122
+ if (format201909 !== undefined) {
123
+ return format201909;
124
+ }
125
+ // 2020-12 format-annotation is annotation-only, no assertion
126
+ if (activeVocabularies.has('https://json-schema.org/draft/2020-12/vocab/format-annotation')) {
127
+ return false;
128
+ }
129
+ // No format vocabulary active - no assertion
130
+ return false;
131
+ }
132
+ // No vocabulary constraints:
133
+ // For explicitly declared 2019-09+ schemas, format is annotation-only by default per spec.
134
+ // For older drafts or no explicit $schema, format asserts for backward compatibility.
135
+ if (schemaDraft !== undefined && schemaDraft >= SchemaDraft.v2019_09) {
136
+ return false;
137
+ }
138
+ return true;
139
+ }
@@ -1,5 +1,5 @@
1
1
  import { format as formatJSON } from 'jsonc-parser';
2
- import { Range, TextEdit } from '../jsonLanguageTypes';
2
+ import { Range, TextEdit } from '../jsonLanguageTypes.js';
3
3
  export function format(documentToFormat, formattingOptions, formattingRange) {
4
4
  let range = undefined;
5
5
  if (formattingRange) {
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { createScanner } from 'jsonc-parser';
6
- import { TextDocument, TextEdit, Position, Range } from '../jsonLanguageTypes';
7
- import { format } from './format';
8
- import { PropertyTree, Container } from './propertyTree';
6
+ import { TextDocument, TextEdit, Position, Range } from '../jsonLanguageTypes.js';
7
+ import { format } from './format.js';
8
+ import { PropertyTree, Container } from './propertyTree.js';
9
9
  export function sort(documentToSort, formattingOptions) {
10
10
  const options = {
11
11
  ...formattingOptions,
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "5.7.2",
3
+ "version": "6.0.0-next.2",
4
4
  "description": "Language service for JSON",
5
- "main": "./lib/umd/jsonLanguageService.js",
6
- "typings": "./lib/umd/jsonLanguageService",
7
- "module": "./lib/esm/jsonLanguageService.js",
5
+ "type": "module",
6
+ "types": "./lib/esm/jsonLanguageService.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./lib/esm/jsonLanguageService.d.ts",
10
+ "import": "./lib/esm/jsonLanguageService.js"
11
+ }
12
+ },
8
13
  "author": "Microsoft Corporation",
9
14
  "repository": {
10
15
  "type": "git",
@@ -15,36 +20,34 @@
15
20
  "url": "https://github.com/Microsoft/vscode-json-languageservice"
16
21
  },
17
22
  "devDependencies": {
18
- "@types/mocha": "^10.0.10",
19
- "@types/node": "22.x",
20
- "@typescript-eslint/eslint-plugin": "^8.56.0",
21
- "@typescript-eslint/parser": "^8.56.0",
22
- "eslint": "^9.39.3",
23
- "json-schema-test-suite": "https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#69acf52990b004240839ae19b4bec8fb01d50876",
24
- "mocha": "^11.7.5",
23
+ "@types/node": "^22.20.1",
24
+ "@typescript-eslint/eslint-plugin": "^8.63.0",
25
+ "@typescript-eslint/parser": "^8.63.0",
26
+ "eslint": "10.6.0",
27
+ "json-schema-test-suite": "https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#92acb61eb772a932c077d5ffa634ded719d2d738",
25
28
  "rimraf": "^6.1.3",
26
- "typescript": "^5.9.3"
29
+ "typescript": "6.0.x"
27
30
  },
28
31
  "dependencies": {
29
- "jsonc-parser": "^3.3.1",
32
+ "@vscode/l10n": "^0.0.18",
33
+ "jsonc-parser": "4.0.0-next.1",
30
34
  "vscode-languageserver-textdocument": "^1.0.12",
31
- "vscode-languageserver-types": "^3.17.5",
32
- "vscode-uri": "^3.1.0",
33
- "@vscode/l10n": "^0.0.18"
35
+ "vscode-languageserver-types": "^3.18.0",
36
+ "vscode-uri": "^3.1.0"
34
37
  },
35
38
  "scripts": {
36
- "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",
39
+ "prepack": "npm run clean && npm run compile && npm run test && npm run remove-sourcemap-refs",
37
40
  "compile": "tsc -p ./src",
38
- "compile-esm": "tsc -p ./src/tsconfig.esm.json",
39
41
  "clean": "rimraf lib",
42
+ "bundle-schemas": "node ./build/bundle-schemas.js",
40
43
  "remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js",
41
44
  "watch": "tsc -w -p ./src",
42
45
  "pretest": "npm run compile",
43
- "test": "mocha",
46
+ "test": "node --test ./lib/esm/test/*.test.js",
44
47
  "posttest": "npm run lint",
45
48
  "coverage": "npx nyc -r lcov npm run test",
46
49
  "lint": "eslint src/**/*.ts",
47
50
  "install-types-next": "npm install vscode-languageserver-types@next -f -S && npm install vscode-languageserver-textdocument@next -f -S",
48
- "sample": "npm run compile && node ./lib/umd/example/sample.js"
51
+ "sample": "npm run compile && node ./lib/esm/example/sample.js"
49
52
  }
50
53
  }
@@ -1,21 +0,0 @@
1
- import { MarkedString, CompletionItem } from './jsonLanguageService';
2
- export interface JSONWorkerContribution {
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
- }
9
- export type Segment = string | number;
10
- export type JSONPath = Segment[];
11
- export type JSONCompletionItem = CompletionItem & {
12
- insertText: string;
13
- };
14
- export interface CompletionsCollector {
15
- add(suggestion: JSONCompletionItem & {
16
- insertText: string;
17
- }): void;
18
- error(message: string): void;
19
- setAsIncomplete(): void;
20
- getNumberOfProposals(): number;
21
- }
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,30 +0,0 @@
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
- import { DocumentLink } from 'vscode-languageserver-types';
3
- export type JSONDocument = {
4
- root: ASTNode | undefined;
5
- getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
6
- };
7
- export * from './jsonLanguageTypes';
8
- export interface LanguageService {
9
- configure(settings: LanguageSettings): void;
10
- doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): PromiseLike<Diagnostic[]>;
11
- parseJSONDocument(document: TextDocument): JSONDocument;
12
- newJSONDocument(rootNode: ASTNode | undefined, syntaxDiagnostics?: Diagnostic[], comments?: Range[]): JSONDocument;
13
- resetSchema(uri: string): boolean;
14
- getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): PromiseLike<MatchingSchema[]>;
15
- getLanguageStatus(document: TextDocument, jsonDocument: JSONDocument): JSONLanguageStatus;
16
- doResolve(item: CompletionItem): PromiseLike<CompletionItem>;
17
- doComplete(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<CompletionList | null>;
18
- findDocumentSymbols(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): SymbolInformation[];
19
- findDocumentSymbols2(document: TextDocument, doc: JSONDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
20
- findDocumentColors(document: TextDocument, doc: JSONDocument, context?: DocumentColorsContext): PromiseLike<ColorInformation[]>;
21
- getColorPresentations(document: TextDocument, doc: JSONDocument, color: Color, range: Range): ColorPresentation[];
22
- doHover(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<Hover | null>;
23
- getFoldingRanges(document: TextDocument, context?: FoldingRangesContext): FoldingRange[];
24
- getSelectionRanges(document: TextDocument, positions: Position[], doc: JSONDocument): SelectionRange[];
25
- findDefinition(document: TextDocument, position: Position, doc: JSONDocument): PromiseLike<DefinitionLink[]>;
26
- findLinks(document: TextDocument, doc: JSONDocument): PromiseLike<DocumentLink[]>;
27
- format(document: TextDocument, range: Range | undefined, options: FormattingOptions): TextEdit[];
28
- sort(document: TextDocument, options: SortOptions): TextEdit[];
29
- }
30
- export declare function getLanguageService(params: LanguageServiceParams): LanguageService;
@@ -1,79 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
- };
19
- (function (factory) {
20
- if (typeof module === "object" && typeof module.exports === "object") {
21
- var v = factory(require, exports);
22
- if (v !== undefined) module.exports = v;
23
- }
24
- else if (typeof define === "function" && define.amd) {
25
- define(["require", "exports", "./services/jsonCompletion", "./services/jsonHover", "./services/jsonValidation", "./services/jsonDocumentSymbols", "./parser/jsonParser", "./services/configuration", "./services/jsonSchemaService", "./services/jsonFolding", "./services/jsonSelectionRanges", "./utils/sort", "./utils/format", "./services/jsonLinks", "./jsonLanguageTypes"], factory);
26
- }
27
- })(function (require, exports) {
28
- "use strict";
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.getLanguageService = getLanguageService;
31
- const jsonCompletion_1 = require("./services/jsonCompletion");
32
- const jsonHover_1 = require("./services/jsonHover");
33
- const jsonValidation_1 = require("./services/jsonValidation");
34
- const jsonDocumentSymbols_1 = require("./services/jsonDocumentSymbols");
35
- const jsonParser_1 = require("./parser/jsonParser");
36
- const configuration_1 = require("./services/configuration");
37
- const jsonSchemaService_1 = require("./services/jsonSchemaService");
38
- const jsonFolding_1 = require("./services/jsonFolding");
39
- const jsonSelectionRanges_1 = require("./services/jsonSelectionRanges");
40
- const sort_1 = require("./utils/sort");
41
- const format_1 = require("./utils/format");
42
- const jsonLinks_1 = require("./services/jsonLinks");
43
- __exportStar(require("./jsonLanguageTypes"), exports);
44
- function getLanguageService(params) {
45
- const promise = params.promiseConstructor || Promise;
46
- const jsonSchemaService = new jsonSchemaService_1.JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
47
- jsonSchemaService.setSchemaContributions(configuration_1.schemaContributions);
48
- const jsonCompletion = new jsonCompletion_1.JSONCompletion(jsonSchemaService, params.contributions, promise, params.clientCapabilities);
49
- const jsonHover = new jsonHover_1.JSONHover(jsonSchemaService, params.contributions, promise);
50
- const jsonDocumentSymbols = new jsonDocumentSymbols_1.JSONDocumentSymbols(jsonSchemaService);
51
- const jsonValidation = new jsonValidation_1.JSONValidation(jsonSchemaService, promise);
52
- return {
53
- configure: (settings) => {
54
- jsonSchemaService.clearExternalSchemas();
55
- settings.schemas?.forEach(jsonSchemaService.registerExternalSchema.bind(jsonSchemaService));
56
- jsonValidation.configure(settings);
57
- },
58
- resetSchema: (uri) => jsonSchemaService.onResourceChange(uri),
59
- doValidation: jsonValidation.doValidation.bind(jsonValidation),
60
- getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
61
- parseJSONDocument: (document) => (0, jsonParser_1.parse)(document, { collectComments: true }),
62
- newJSONDocument: (root, diagnostics, comments) => (0, jsonParser_1.newJSONDocument)(root, diagnostics, comments),
63
- getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
64
- doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
65
- doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
66
- findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
67
- findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
68
- findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
69
- getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
70
- doHover: jsonHover.doHover.bind(jsonHover),
71
- getFoldingRanges: jsonFolding_1.getFoldingRanges,
72
- getSelectionRanges: jsonSelectionRanges_1.getSelectionRanges,
73
- findDefinition: () => Promise.resolve([]),
74
- findLinks: jsonLinks_1.findLinks,
75
- format: (document, range, options) => (0, format_1.format)(document, options, range),
76
- sort: (document, options) => (0, sort_1.sort)(document, options)
77
- };
78
- }
79
- });