vscode-json-languageservice 5.5.0 → 5.6.0

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 5.6.0 / 2025-05-28
2
+ ================
3
+ * added `Schema.enumSortTexts`and `Schema.enumDetails` to control the sort order and presentation of suggestions for enaums
4
+
1
5
  5.5.0 / 2025-03-25
2
6
  ================
3
7
  * `newJSONDocument` API now also accepts undefined as ASTRoots an optionally comment ranges.
@@ -77,6 +77,8 @@ export interface JSONSchema {
77
77
  patternErrorMessage?: string;
78
78
  deprecationMessage?: string;
79
79
  enumDescriptions?: string[];
80
+ enumSortTexts?: string[];
81
+ enumDetails?: string[];
80
82
  markdownEnumDescriptions?: string[];
81
83
  markdownDescription?: string;
82
84
  doNotSuggest?: boolean;
@@ -6,6 +6,7 @@ import * as Json from 'jsonc-parser';
6
6
  import { isNumber, equals, isBoolean, isString, isDefined, isObject } from '../utils/objects';
7
7
  import { extendedRegExp, stringLength } from '../utils/strings';
8
8
  import { ErrorCode, Diagnostic, DiagnosticSeverity, Range, SchemaDraft } from '../jsonLanguageTypes';
9
+ import { URI } from 'vscode-uri';
9
10
  import * as l10n from '@vscode/l10n';
10
11
  const formats = {
11
12
  'color-hex': { errorMessage: l10n.t('Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.'), pattern: /^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$/ },
@@ -101,11 +102,30 @@ export var EnumMatch;
101
102
  EnumMatch[EnumMatch["Key"] = 0] = "Key";
102
103
  EnumMatch[EnumMatch["Enum"] = 1] = "Enum";
103
104
  })(EnumMatch || (EnumMatch = {}));
105
+ const httpPrefix = `http://json-schema.org/`;
106
+ const httpsPrefix = `https://json-schema.org/`;
107
+ export function normalizeId(id) {
108
+ // use the https prefix for the old json-schema.org meta schemas
109
+ // See https://github.com/microsoft/vscode/issues/195189
110
+ if (id.startsWith(httpPrefix)) {
111
+ id = httpsPrefix + id.substring(httpPrefix.length);
112
+ }
113
+ // remove trailing '#', normalize drive capitalization
114
+ try {
115
+ return URI.parse(id).toString(true);
116
+ }
117
+ catch (e) {
118
+ return id;
119
+ }
120
+ }
121
+ export function getSchemaDraftFromId(schemaId) {
122
+ return schemaDraftFromId[normalizeId(schemaId)] ?? undefined;
123
+ }
104
124
  const schemaDraftFromId = {
105
- 'http://json-schema.org/draft-03/schema#': SchemaDraft.v3,
106
- 'http://json-schema.org/draft-04/schema#': SchemaDraft.v4,
107
- 'http://json-schema.org/draft-06/schema#': SchemaDraft.v6,
108
- 'http://json-schema.org/draft-07/schema#': SchemaDraft.v7,
125
+ 'https://json-schema.org/draft-03/schema': SchemaDraft.v3,
126
+ 'https://json-schema.org/draft-04/schema': SchemaDraft.v4,
127
+ 'https://json-schema.org/draft-06/schema': SchemaDraft.v6,
128
+ 'https://json-schema.org/draft-07/schema': SchemaDraft.v7,
109
129
  'https://json-schema.org/draft/2019-09/schema': SchemaDraft.v2019_09,
110
130
  'https://json-schema.org/draft/2020-12/schema': SchemaDraft.v2020_12
111
131
  };
@@ -269,7 +289,7 @@ export class JSONDocument {
269
289
  function getSchemaDraft(schema, fallBack = SchemaDraft.v2020_12) {
270
290
  let schemaId = schema.$schema;
271
291
  if (schemaId) {
272
- return schemaDraftFromId[schemaId] ?? fallBack;
292
+ return getSchemaDraftFromId(schemaId) ?? fallBack;
273
293
  }
274
294
  return fallBack;
275
295
  }
@@ -7,8 +7,7 @@ export const schemaContributions = {
7
7
  schemaAssociations: [],
8
8
  schemas: {
9
9
  // bundle the schema-schema to include (localized) descriptions
10
- 'http://json-schema.org/draft-04/schema#': {
11
- '$schema': 'http://json-schema.org/draft-04/schema#',
10
+ 'https://json-schema.org/draft-04/schema': {
12
11
  'definitions': {
13
12
  'schemaArray': {
14
13
  'type': 'array',
@@ -290,7 +289,7 @@ export const schemaContributions = {
290
289
  },
291
290
  'default': {}
292
291
  },
293
- 'http://json-schema.org/draft-07/schema#': {
292
+ 'https://json-schema.org/draft-07/schema': {
294
293
  'definitions': {
295
294
  'schemaArray': {
296
295
  'type': 'array',
@@ -225,21 +225,17 @@ export class JSONCompletion {
225
225
  }
226
226
  const schemaPropertyNames = s.schema.propertyNames;
227
227
  if (typeof schemaPropertyNames === 'object' && !schemaPropertyNames.deprecationMessage && !schemaPropertyNames.doNotSuggest) {
228
- const propertyNameCompletionItem = (name, enumDescription = undefined) => {
228
+ const propertyNameCompletionItem = (name, documentation, detail, sortText) => {
229
229
  const proposal = {
230
230
  kind: CompletionItemKind.Property,
231
231
  label: name,
232
232
  insertText: this.getInsertTextForProperty(name, undefined, addValue, separatorAfter),
233
233
  insertTextFormat: InsertTextFormat.Snippet,
234
234
  filterText: this.getFilterTextForValue(name),
235
- documentation: enumDescription || this.fromMarkup(schemaPropertyNames.markdownDescription) || schemaPropertyNames.description || ''
235
+ documentation: documentation || this.fromMarkup(schemaPropertyNames.markdownDescription) || schemaPropertyNames.description || '',
236
+ sortText,
237
+ detail
236
238
  };
237
- if (schemaPropertyNames.completionDetail !== undefined) {
238
- proposal.detail = schemaPropertyNames.completionDetail;
239
- }
240
- if (schemaPropertyNames.suggestSortText !== undefined) {
241
- proposal.sortText = schemaPropertyNames.suggestSortText;
242
- }
243
239
  if (proposal.insertText && endsWith(proposal.insertText, `$1${separatorAfter}`)) {
244
240
  proposal.command = {
245
241
  title: 'Suggest',
@@ -257,11 +253,13 @@ export class JSONCompletion {
257
253
  else if (schemaPropertyNames.enumDescriptions && i < schemaPropertyNames.enumDescriptions.length) {
258
254
  enumDescription = schemaPropertyNames.enumDescriptions[i];
259
255
  }
260
- propertyNameCompletionItem(schemaPropertyNames.enum[i], enumDescription);
256
+ const enumSortText = schemaPropertyNames.enumSortTexts?.[i];
257
+ const enumDetails = schemaPropertyNames.enumDetails?.[i];
258
+ propertyNameCompletionItem(schemaPropertyNames.enum[i], enumDescription, enumDetails, enumSortText);
261
259
  }
262
260
  }
263
261
  if (schemaPropertyNames.const) {
264
- propertyNameCompletionItem(schemaPropertyNames.const);
262
+ propertyNameCompletionItem(schemaPropertyNames.const, undefined, schemaPropertyNames.completionDetail, schemaPropertyNames.suggestSortText);
265
263
  }
266
264
  }
267
265
  }
@@ -633,6 +631,8 @@ export class JSONCompletion {
633
631
  label: this.getLabelForValue(enm),
634
632
  insertText: this.getInsertTextForValue(enm, separatorAfter),
635
633
  insertTextFormat: InsertTextFormat.Snippet,
634
+ sortText: schema.enumSortTexts?.[i],
635
+ detail: schema.enumDetails?.[i],
636
636
  documentation
637
637
  });
638
638
  }
@@ -693,7 +693,7 @@ export class JSONCompletion {
693
693
  addDollarSchemaCompletions(separatorAfter, collector) {
694
694
  const schemaIds = this.schemaService.getRegisteredSchemaIds(schema => schema === 'http' || schema === 'https');
695
695
  schemaIds.forEach(schemaId => {
696
- if (schemaId.startsWith('http://json-schema.org/draft-')) {
696
+ if (schemaId.startsWith('https://json-schema.org/draft-')) {
697
697
  schemaId = schemaId + '#';
698
698
  }
699
699
  collector.add({
@@ -5,7 +5,8 @@
5
5
  import * as Json from 'jsonc-parser';
6
6
  import { URI } from 'vscode-uri';
7
7
  import * as Strings from '../utils/strings';
8
- import * as Parser from '../parser/jsonParser';
8
+ import { asSchema, getSchemaDraftFromId, normalizeId } from '../parser/jsonParser';
9
+ import { SchemaDraft } from '../jsonLanguageTypes';
9
10
  import * as l10n from '@vscode/l10n';
10
11
  import { createRegex } from '../utils/glob';
11
12
  import { isObject, isString } from '../utils/objects';
@@ -111,7 +112,7 @@ export class ResolvedSchema {
111
112
  getSection(path) {
112
113
  const schemaRef = this.getSectionRecursive(path, this.schema);
113
114
  if (schemaRef) {
114
- return Parser.asSchema(schemaRef);
115
+ return asSchema(schemaRef);
115
116
  }
116
117
  return undefined;
117
118
  }
@@ -263,9 +264,6 @@ export class JSONSchemaService {
263
264
  const errorMessage = l10n.t('Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
264
265
  return this.promise.resolve(new UnresolvedSchema({}, [errorMessage]));
265
266
  }
266
- if (url.startsWith('http://json-schema.org/')) {
267
- url = 'https' + url.substring(4); // always access json-schema.org with https. See https://github.com/microsoft/vscode/issues/195189
268
- }
269
267
  return this.requestService(url).then(content => {
270
268
  if (!content) {
271
269
  const errorMessage = l10n.t('Unable to load schema from \'{0}\': No content.', toDisplayString(url));
@@ -299,8 +297,8 @@ export class JSONSchemaService {
299
297
  resolveSchemaContent(schemaToResolve, handle) {
300
298
  const resolveErrors = schemaToResolve.errors.slice(0);
301
299
  const schema = schemaToResolve.schema;
302
- let schemaDraft = schema.$schema ? normalizeId(schema.$schema) : undefined;
303
- if (schemaDraft === 'http://json-schema.org/draft-03/schema') {
300
+ const schemaDraft = schema.$schema ? getSchemaDraftFromId(schema.$schema) : undefined;
301
+ if (schemaDraft === SchemaDraft.v3) {
304
302
  return this.promise.resolve(new ResolvedSchema({}, [l10n.t("Draft-03 schemas are not supported.")], [], schemaDraft));
305
303
  }
306
304
  let usesUnsupportedFeatures = new Set();
@@ -574,15 +572,6 @@ export class JSONSchemaService {
574
572
  }
575
573
  }
576
574
  let idCounter = 0;
577
- function normalizeId(id) {
578
- // remove trailing '#', normalize drive capitalization
579
- try {
580
- return URI.parse(id).toString(true);
581
- }
582
- catch (e) {
583
- return id;
584
- }
585
- }
586
575
  function normalizeResourceForMatching(resource) {
587
576
  // remove queries and fragments, normalize drive capitalization
588
577
  try {
@@ -77,6 +77,8 @@ export interface JSONSchema {
77
77
  patternErrorMessage?: string;
78
78
  deprecationMessage?: string;
79
79
  enumDescriptions?: string[];
80
+ enumSortTexts?: string[];
81
+ enumDetails?: string[];
80
82
  markdownEnumDescriptions?: string[];
81
83
  markdownDescription?: string;
82
84
  doNotSuggest?: boolean;
@@ -8,13 +8,15 @@
8
8
  if (v !== undefined) module.exports = v;
9
9
  }
10
10
  else if (typeof define === "function" && define.amd) {
11
- define(["require", "exports", "jsonc-parser", "../utils/objects", "../utils/strings", "../jsonLanguageTypes", "@vscode/l10n"], factory);
11
+ define(["require", "exports", "jsonc-parser", "../utils/objects", "../utils/strings", "../jsonLanguageTypes", "vscode-uri", "@vscode/l10n"], factory);
12
12
  }
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
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
17
  exports.asSchema = asSchema;
18
+ exports.normalizeId = normalizeId;
19
+ exports.getSchemaDraftFromId = getSchemaDraftFromId;
18
20
  exports.newJSONDocument = newJSONDocument;
19
21
  exports.getNodeValue = getNodeValue;
20
22
  exports.getNodePath = getNodePath;
@@ -24,6 +26,7 @@
24
26
  const objects_1 = require("../utils/objects");
25
27
  const strings_1 = require("../utils/strings");
26
28
  const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
29
+ const vscode_uri_1 = require("vscode-uri");
27
30
  const l10n = require("@vscode/l10n");
28
31
  const formats = {
29
32
  'color-hex': { errorMessage: l10n.t('Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.'), pattern: /^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$/ },
@@ -127,11 +130,30 @@
127
130
  EnumMatch[EnumMatch["Key"] = 0] = "Key";
128
131
  EnumMatch[EnumMatch["Enum"] = 1] = "Enum";
129
132
  })(EnumMatch || (exports.EnumMatch = EnumMatch = {}));
133
+ const httpPrefix = `http://json-schema.org/`;
134
+ const httpsPrefix = `https://json-schema.org/`;
135
+ function normalizeId(id) {
136
+ // use the https prefix for the old json-schema.org meta schemas
137
+ // See https://github.com/microsoft/vscode/issues/195189
138
+ if (id.startsWith(httpPrefix)) {
139
+ id = httpsPrefix + id.substring(httpPrefix.length);
140
+ }
141
+ // remove trailing '#', normalize drive capitalization
142
+ try {
143
+ return vscode_uri_1.URI.parse(id).toString(true);
144
+ }
145
+ catch (e) {
146
+ return id;
147
+ }
148
+ }
149
+ function getSchemaDraftFromId(schemaId) {
150
+ return schemaDraftFromId[normalizeId(schemaId)] ?? undefined;
151
+ }
130
152
  const schemaDraftFromId = {
131
- 'http://json-schema.org/draft-03/schema#': jsonLanguageTypes_1.SchemaDraft.v3,
132
- 'http://json-schema.org/draft-04/schema#': jsonLanguageTypes_1.SchemaDraft.v4,
133
- 'http://json-schema.org/draft-06/schema#': jsonLanguageTypes_1.SchemaDraft.v6,
134
- 'http://json-schema.org/draft-07/schema#': jsonLanguageTypes_1.SchemaDraft.v7,
153
+ 'https://json-schema.org/draft-03/schema': jsonLanguageTypes_1.SchemaDraft.v3,
154
+ 'https://json-schema.org/draft-04/schema': jsonLanguageTypes_1.SchemaDraft.v4,
155
+ 'https://json-schema.org/draft-06/schema': jsonLanguageTypes_1.SchemaDraft.v6,
156
+ 'https://json-schema.org/draft-07/schema': jsonLanguageTypes_1.SchemaDraft.v7,
135
157
  'https://json-schema.org/draft/2019-09/schema': jsonLanguageTypes_1.SchemaDraft.v2019_09,
136
158
  'https://json-schema.org/draft/2020-12/schema': jsonLanguageTypes_1.SchemaDraft.v2020_12
137
159
  };
@@ -297,7 +319,7 @@
297
319
  function getSchemaDraft(schema, fallBack = jsonLanguageTypes_1.SchemaDraft.v2020_12) {
298
320
  let schemaId = schema.$schema;
299
321
  if (schemaId) {
300
- return schemaDraftFromId[schemaId] ?? fallBack;
322
+ return getSchemaDraftFromId(schemaId) ?? fallBack;
301
323
  }
302
324
  return fallBack;
303
325
  }
@@ -19,8 +19,7 @@
19
19
  schemaAssociations: [],
20
20
  schemas: {
21
21
  // bundle the schema-schema to include (localized) descriptions
22
- 'http://json-schema.org/draft-04/schema#': {
23
- '$schema': 'http://json-schema.org/draft-04/schema#',
22
+ 'https://json-schema.org/draft-04/schema': {
24
23
  'definitions': {
25
24
  'schemaArray': {
26
25
  'type': 'array',
@@ -302,7 +301,7 @@
302
301
  },
303
302
  'default': {}
304
303
  },
305
- 'http://json-schema.org/draft-07/schema#': {
304
+ 'https://json-schema.org/draft-07/schema': {
306
305
  'definitions': {
307
306
  'schemaArray': {
308
307
  'type': 'array',
@@ -237,21 +237,17 @@
237
237
  }
238
238
  const schemaPropertyNames = s.schema.propertyNames;
239
239
  if (typeof schemaPropertyNames === 'object' && !schemaPropertyNames.deprecationMessage && !schemaPropertyNames.doNotSuggest) {
240
- const propertyNameCompletionItem = (name, enumDescription = undefined) => {
240
+ const propertyNameCompletionItem = (name, documentation, detail, sortText) => {
241
241
  const proposal = {
242
242
  kind: jsonLanguageTypes_1.CompletionItemKind.Property,
243
243
  label: name,
244
244
  insertText: this.getInsertTextForProperty(name, undefined, addValue, separatorAfter),
245
245
  insertTextFormat: jsonLanguageTypes_1.InsertTextFormat.Snippet,
246
246
  filterText: this.getFilterTextForValue(name),
247
- documentation: enumDescription || this.fromMarkup(schemaPropertyNames.markdownDescription) || schemaPropertyNames.description || ''
247
+ documentation: documentation || this.fromMarkup(schemaPropertyNames.markdownDescription) || schemaPropertyNames.description || '',
248
+ sortText,
249
+ detail
248
250
  };
249
- if (schemaPropertyNames.completionDetail !== undefined) {
250
- proposal.detail = schemaPropertyNames.completionDetail;
251
- }
252
- if (schemaPropertyNames.suggestSortText !== undefined) {
253
- proposal.sortText = schemaPropertyNames.suggestSortText;
254
- }
255
251
  if (proposal.insertText && (0, strings_1.endsWith)(proposal.insertText, `$1${separatorAfter}`)) {
256
252
  proposal.command = {
257
253
  title: 'Suggest',
@@ -269,11 +265,13 @@
269
265
  else if (schemaPropertyNames.enumDescriptions && i < schemaPropertyNames.enumDescriptions.length) {
270
266
  enumDescription = schemaPropertyNames.enumDescriptions[i];
271
267
  }
272
- propertyNameCompletionItem(schemaPropertyNames.enum[i], enumDescription);
268
+ const enumSortText = schemaPropertyNames.enumSortTexts?.[i];
269
+ const enumDetails = schemaPropertyNames.enumDetails?.[i];
270
+ propertyNameCompletionItem(schemaPropertyNames.enum[i], enumDescription, enumDetails, enumSortText);
273
271
  }
274
272
  }
275
273
  if (schemaPropertyNames.const) {
276
- propertyNameCompletionItem(schemaPropertyNames.const);
274
+ propertyNameCompletionItem(schemaPropertyNames.const, undefined, schemaPropertyNames.completionDetail, schemaPropertyNames.suggestSortText);
277
275
  }
278
276
  }
279
277
  }
@@ -645,6 +643,8 @@
645
643
  label: this.getLabelForValue(enm),
646
644
  insertText: this.getInsertTextForValue(enm, separatorAfter),
647
645
  insertTextFormat: jsonLanguageTypes_1.InsertTextFormat.Snippet,
646
+ sortText: schema.enumSortTexts?.[i],
647
+ detail: schema.enumDetails?.[i],
648
648
  documentation
649
649
  });
650
650
  }
@@ -705,7 +705,7 @@
705
705
  addDollarSchemaCompletions(separatorAfter, collector) {
706
706
  const schemaIds = this.schemaService.getRegisteredSchemaIds(schema => schema === 'http' || schema === 'https');
707
707
  schemaIds.forEach(schemaId => {
708
- if (schemaId.startsWith('http://json-schema.org/draft-')) {
708
+ if (schemaId.startsWith('https://json-schema.org/draft-')) {
709
709
  schemaId = schemaId + '#';
710
710
  }
711
711
  collector.add({
@@ -8,7 +8,7 @@
8
8
  if (v !== undefined) module.exports = v;
9
9
  }
10
10
  else if (typeof define === "function" && define.amd) {
11
- define(["require", "exports", "jsonc-parser", "vscode-uri", "../utils/strings", "../parser/jsonParser", "@vscode/l10n", "../utils/glob", "../utils/objects"], factory);
11
+ define(["require", "exports", "jsonc-parser", "vscode-uri", "../utils/strings", "../parser/jsonParser", "../jsonLanguageTypes", "@vscode/l10n", "../utils/glob", "../utils/objects"], factory);
12
12
  }
13
13
  })(function (require, exports) {
14
14
  "use strict";
@@ -17,7 +17,8 @@
17
17
  const Json = require("jsonc-parser");
18
18
  const vscode_uri_1 = require("vscode-uri");
19
19
  const Strings = require("../utils/strings");
20
- const Parser = require("../parser/jsonParser");
20
+ const jsonParser_1 = require("../parser/jsonParser");
21
+ const jsonLanguageTypes_1 = require("../jsonLanguageTypes");
21
22
  const l10n = require("@vscode/l10n");
22
23
  const glob_1 = require("../utils/glob");
23
24
  const objects_1 = require("../utils/objects");
@@ -124,7 +125,7 @@
124
125
  getSection(path) {
125
126
  const schemaRef = this.getSectionRecursive(path, this.schema);
126
127
  if (schemaRef) {
127
- return Parser.asSchema(schemaRef);
128
+ return (0, jsonParser_1.asSchema)(schemaRef);
128
129
  }
129
130
  return undefined;
130
131
  }
@@ -192,7 +193,7 @@
192
193
  // always clear this local cache when a resource changes
193
194
  this.cachedSchemaForResource = undefined;
194
195
  let hasChanges = false;
195
- uri = normalizeId(uri);
196
+ uri = (0, jsonParser_1.normalizeId)(uri);
196
197
  const toWalk = [uri];
197
198
  const all = Object.keys(this.schemasById).map(key => this.schemasById[key]);
198
199
  while (toWalk.length) {
@@ -216,14 +217,14 @@
216
217
  if (schemaContributions.schemas) {
217
218
  const schemas = schemaContributions.schemas;
218
219
  for (const id in schemas) {
219
- const normalizedId = normalizeId(id);
220
+ const normalizedId = (0, jsonParser_1.normalizeId)(id);
220
221
  this.contributionSchemas[normalizedId] = this.addSchemaHandle(normalizedId, schemas[id]);
221
222
  }
222
223
  }
223
224
  if (Array.isArray(schemaContributions.schemaAssociations)) {
224
225
  const schemaAssociations = schemaContributions.schemaAssociations;
225
226
  for (let schemaAssociation of schemaAssociations) {
226
- const uris = schemaAssociation.uris.map(normalizeId);
227
+ const uris = schemaAssociation.uris.map(jsonParser_1.normalizeId);
227
228
  const association = this.addFilePatternAssociation(schemaAssociation.pattern, schemaAssociation.folderUri, uris);
228
229
  this.contributionAssociations.push(association);
229
230
  }
@@ -243,7 +244,7 @@
243
244
  return fpa;
244
245
  }
245
246
  registerExternalSchema(config) {
246
- const id = normalizeId(config.uri);
247
+ const id = (0, jsonParser_1.normalizeId)(config.uri);
247
248
  this.registeredSchemasIds[id] = true;
248
249
  this.cachedSchemaForResource = undefined;
249
250
  if (config.fileMatch && config.fileMatch.length) {
@@ -265,7 +266,7 @@
265
266
  }
266
267
  }
267
268
  getResolvedSchema(schemaId) {
268
- const id = normalizeId(schemaId);
269
+ const id = (0, jsonParser_1.normalizeId)(schemaId);
269
270
  const schemaHandle = this.schemasById[id];
270
271
  if (schemaHandle) {
271
272
  return schemaHandle.getResolvedSchema();
@@ -277,9 +278,6 @@
277
278
  const errorMessage = l10n.t('Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
278
279
  return this.promise.resolve(new UnresolvedSchema({}, [errorMessage]));
279
280
  }
280
- if (url.startsWith('http://json-schema.org/')) {
281
- url = 'https' + url.substring(4); // always access json-schema.org with https. See https://github.com/microsoft/vscode/issues/195189
282
- }
283
281
  return this.requestService(url).then(content => {
284
282
  if (!content) {
285
283
  const errorMessage = l10n.t('Unable to load schema from \'{0}\': No content.', toDisplayString(url));
@@ -313,8 +311,8 @@
313
311
  resolveSchemaContent(schemaToResolve, handle) {
314
312
  const resolveErrors = schemaToResolve.errors.slice(0);
315
313
  const schema = schemaToResolve.schema;
316
- let schemaDraft = schema.$schema ? normalizeId(schema.$schema) : undefined;
317
- if (schemaDraft === 'http://json-schema.org/draft-03/schema') {
314
+ const schemaDraft = schema.$schema ? (0, jsonParser_1.getSchemaDraftFromId)(schema.$schema) : undefined;
315
+ if (schemaDraft === jsonLanguageTypes_1.SchemaDraft.v3) {
318
316
  return this.promise.resolve(new ResolvedSchema({}, [l10n.t("Draft-03 schemas are not supported.")], [], schemaDraft));
319
317
  }
320
318
  let usesUnsupportedFeatures = new Set();
@@ -369,7 +367,7 @@
369
367
  if (contextService && !/^[A-Za-z][A-Za-z0-9+\-.+]*:\/.*/.test(uri)) {
370
368
  uri = contextService.resolveRelativePath(uri, parentHandle.uri);
371
369
  }
372
- uri = normalizeId(uri);
370
+ uri = (0, jsonParser_1.normalizeId)(uri);
373
371
  const referencedHandle = this.getOrAddSchemaHandle(uri);
374
372
  return referencedHandle.getUnresolvedSchema().then(unresolvedSchema => {
375
373
  parentHandle.dependencies.add(uri);
@@ -547,7 +545,7 @@
547
545
  // first use $schema if present
548
546
  let schemeId = this.getSchemaFromProperty(resource, document);
549
547
  if (schemeId) {
550
- const id = normalizeId(schemeId);
548
+ const id = (0, jsonParser_1.normalizeId)(schemeId);
551
549
  return this.getOrAddSchemaHandle(id).getResolvedSchema();
552
550
  }
553
551
  }
@@ -589,15 +587,6 @@
589
587
  }
590
588
  exports.JSONSchemaService = JSONSchemaService;
591
589
  let idCounter = 0;
592
- function normalizeId(id) {
593
- // remove trailing '#', normalize drive capitalization
594
- try {
595
- return vscode_uri_1.URI.parse(id).toString(true);
596
- }
597
- catch (e) {
598
- return id;
599
- }
600
- }
601
590
  function normalizeResourceForMatching(resource) {
602
591
  // remove queries and fragments, normalize drive capitalization
603
592
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "5.5.0",
3
+ "version": "5.6.0",
4
4
  "description": "Language service for JSON",
5
5
  "main": "./lib/umd/jsonLanguageService.js",
6
6
  "typings": "./lib/umd/jsonLanguageService",
@@ -17,9 +17,9 @@
17
17
  "devDependencies": {
18
18
  "@types/mocha": "^10.0.10",
19
19
  "@types/node": "18.x",
20
- "@typescript-eslint/eslint-plugin": "^8.31.0",
21
- "@typescript-eslint/parser": "^8.31.0",
22
- "eslint": "^9.25.1",
20
+ "@typescript-eslint/eslint-plugin": "^8.33.0",
21
+ "@typescript-eslint/parser": "^8.33.0",
22
+ "eslint": "^9.27.0",
23
23
  "json-schema-test-suite": "https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#69acf52990b004240839ae19b4bec8fb01d50876",
24
24
  "mocha": "^11.1.0",
25
25
  "rimraf": "^6.0.1",