vscode-json-languageservice 5.3.7 → 5.3.10

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.
@@ -455,10 +455,11 @@ function validate(n, schema, validationResult, matchingSchemas, context) {
455
455
  validationResult.enumValues = [schema.const];
456
456
  }
457
457
  let deprecationMessage = schema.deprecationMessage;
458
- if ((deprecationMessage || schema.deprecated) && node.parent) {
458
+ if (deprecationMessage || schema.deprecated) {
459
459
  deprecationMessage = deprecationMessage || l10n.t('Value is deprecated');
460
+ let targetNode = node.parent?.type === 'property' ? node.parent : node;
460
461
  validationResult.problems.push({
461
- location: { offset: node.parent.offset, length: node.parent.length },
462
+ location: { offset: targetNode.offset, length: targetNode.length },
462
463
  severity: DiagnosticSeverity.Warning,
463
464
  message: deprecationMessage,
464
465
  code: ErrorCode.Deprecated
@@ -727,10 +728,18 @@ function validate(n, schema, validationResult, matchingSchemas, context) {
727
728
  }
728
729
  if (schema.uniqueItems === true) {
729
730
  const values = getNodeValue(node);
730
- const duplicates = values.some((value, index) => {
731
- return index !== values.lastIndexOf(value);
732
- });
733
- if (duplicates) {
731
+ function hasDuplicates() {
732
+ for (let i = 0; i < values.length - 1; i++) {
733
+ const value = values[i];
734
+ for (let j = i + 1; j < values.length; j++) {
735
+ if (equals(value, values[j])) {
736
+ return true;
737
+ }
738
+ }
739
+ }
740
+ return false;
741
+ }
742
+ if (hasDuplicates()) {
734
743
  validationResult.problems.push({
735
744
  location: { offset: node.offset, length: node.length },
736
745
  message: l10n.t('Array has duplicate items.')
@@ -263,6 +263,9 @@ export class JSONSchemaService {
263
263
  const errorMessage = l10n.t('Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
264
264
  return this.promise.resolve(new UnresolvedSchema({}, [errorMessage]));
265
265
  }
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
+ }
266
269
  return this.requestService(url).then(content => {
267
270
  if (!content) {
268
271
  const errorMessage = l10n.t('Unable to load schema from \'{0}\': No content.', toDisplayString(url));
@@ -190,15 +190,17 @@ function findJsoncPropertyTree(formattedDocument) {
190
190
  case 2 /* SyntaxKind.CloseBraceToken */: {
191
191
  endLineNumber = scanner.getTokenStartLine();
192
192
  currentContainerStack.pop();
193
- // If we are not inside of an empty object and current property end line number has not yet been defined, define it
194
- if (lastNonTriviaNonCommentToken !== 1 /* SyntaxKind.OpenBraceToken */
195
- && currentProperty.endLineNumber === undefined) {
196
- currentProperty.endLineNumber = endLineNumber - 1;
197
- // The current property is also the last property
198
- currentProperty.lastProperty = true;
199
- // The last property of an object is associated with the line and index of where to add the comma, in case after sorting, it is no longer the last property
200
- currentProperty.lineWhereToAddComma = lineOfLastNonTriviaNonCommentToken;
201
- currentProperty.indexWhereToAddComa = endIndexOfLastNonTriviaNonCommentToken;
193
+ // If we are not inside of an empty object
194
+ if (lastNonTriviaNonCommentToken !== 1 /* SyntaxKind.OpenBraceToken */) {
195
+ // If current property end line number has not yet been defined, define it
196
+ if (currentProperty.endLineNumber === undefined) {
197
+ currentProperty.endLineNumber = endLineNumber - 1;
198
+ // The current property is also the last property
199
+ currentProperty.lastProperty = true;
200
+ // The last property of an object is associated with the line and index of where to add the comma, in case after sorting, it is no longer the last property
201
+ currentProperty.lineWhereToAddComma = lineOfLastNonTriviaNonCommentToken;
202
+ currentProperty.indexWhereToAddComa = endIndexOfLastNonTriviaNonCommentToken;
203
+ }
202
204
  lastProperty = currentProperty;
203
205
  currentProperty = currentProperty ? currentProperty.parent : undefined;
204
206
  currentTree = currentProperty;
@@ -482,10 +482,11 @@
482
482
  validationResult.enumValues = [schema.const];
483
483
  }
484
484
  let deprecationMessage = schema.deprecationMessage;
485
- if ((deprecationMessage || schema.deprecated) && node.parent) {
485
+ if (deprecationMessage || schema.deprecated) {
486
486
  deprecationMessage = deprecationMessage || l10n.t('Value is deprecated');
487
+ let targetNode = node.parent?.type === 'property' ? node.parent : node;
487
488
  validationResult.problems.push({
488
- location: { offset: node.parent.offset, length: node.parent.length },
489
+ location: { offset: targetNode.offset, length: targetNode.length },
489
490
  severity: jsonLanguageTypes_1.DiagnosticSeverity.Warning,
490
491
  message: deprecationMessage,
491
492
  code: jsonLanguageTypes_1.ErrorCode.Deprecated
@@ -754,10 +755,18 @@
754
755
  }
755
756
  if (schema.uniqueItems === true) {
756
757
  const values = getNodeValue(node);
757
- const duplicates = values.some((value, index) => {
758
- return index !== values.lastIndexOf(value);
759
- });
760
- if (duplicates) {
758
+ function hasDuplicates() {
759
+ for (let i = 0; i < values.length - 1; i++) {
760
+ const value = values[i];
761
+ for (let j = i + 1; j < values.length; j++) {
762
+ if ((0, objects_1.equals)(value, values[j])) {
763
+ return true;
764
+ }
765
+ }
766
+ }
767
+ return false;
768
+ }
769
+ if (hasDuplicates()) {
761
770
  validationResult.problems.push({
762
771
  location: { offset: node.offset, length: node.length },
763
772
  message: l10n.t('Array has duplicate items.')
@@ -277,6 +277,9 @@
277
277
  const errorMessage = l10n.t('Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
278
278
  return this.promise.resolve(new UnresolvedSchema({}, [errorMessage]));
279
279
  }
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
+ }
280
283
  return this.requestService(url).then(content => {
281
284
  if (!content) {
282
285
  const errorMessage = l10n.t('Unable to load schema from \'{0}\': No content.', toDisplayString(url));
@@ -203,15 +203,17 @@
203
203
  case 2 /* SyntaxKind.CloseBraceToken */: {
204
204
  endLineNumber = scanner.getTokenStartLine();
205
205
  currentContainerStack.pop();
206
- // If we are not inside of an empty object and current property end line number has not yet been defined, define it
207
- if (lastNonTriviaNonCommentToken !== 1 /* SyntaxKind.OpenBraceToken */
208
- && currentProperty.endLineNumber === undefined) {
209
- currentProperty.endLineNumber = endLineNumber - 1;
210
- // The current property is also the last property
211
- currentProperty.lastProperty = true;
212
- // The last property of an object is associated with the line and index of where to add the comma, in case after sorting, it is no longer the last property
213
- currentProperty.lineWhereToAddComma = lineOfLastNonTriviaNonCommentToken;
214
- currentProperty.indexWhereToAddComa = endIndexOfLastNonTriviaNonCommentToken;
206
+ // If we are not inside of an empty object
207
+ if (lastNonTriviaNonCommentToken !== 1 /* SyntaxKind.OpenBraceToken */) {
208
+ // If current property end line number has not yet been defined, define it
209
+ if (currentProperty.endLineNumber === undefined) {
210
+ currentProperty.endLineNumber = endLineNumber - 1;
211
+ // The current property is also the last property
212
+ currentProperty.lastProperty = true;
213
+ // The last property of an object is associated with the line and index of where to add the comma, in case after sorting, it is no longer the last property
214
+ currentProperty.lineWhereToAddComma = lineOfLastNonTriviaNonCommentToken;
215
+ currentProperty.indexWhereToAddComa = endIndexOfLastNonTriviaNonCommentToken;
216
+ }
215
217
  lastProperty = currentProperty;
216
218
  currentProperty = currentProperty ? currentProperty.parent : undefined;
217
219
  currentTree = currentProperty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "5.3.7",
3
+ "version": "5.3.10",
4
4
  "description": "Language service for JSON",
5
5
  "main": "./lib/umd/jsonLanguageService.js",
6
6
  "typings": "./lib/umd/jsonLanguageService",
@@ -15,22 +15,22 @@
15
15
  "url": "https://github.com/Microsoft/vscode-json-languageservice"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/mocha": "^10.0.2",
18
+ "@types/mocha": "^10.0.6",
19
19
  "@types/node": "16.x",
20
- "@typescript-eslint/eslint-plugin": "^6.7.4",
21
- "@typescript-eslint/parser": "^6.7.4",
22
- "eslint": "^8.51.0",
20
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
21
+ "@typescript-eslint/parser": "^6.21.0",
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.2.0",
24
+ "mocha": "^10.3.0",
25
25
  "rimraf": "^5.0.5",
26
- "typescript": "^5.2.2"
26
+ "typescript": "^5.3.3"
27
27
  },
28
28
  "dependencies": {
29
- "jsonc-parser": "^3.2.0",
29
+ "jsonc-parser": "^3.2.1",
30
30
  "vscode-languageserver-textdocument": "^1.0.11",
31
31
  "vscode-languageserver-types": "^3.17.5",
32
32
  "vscode-uri": "^3.0.8",
33
- "@vscode/l10n": "^0.0.16"
33
+ "@vscode/l10n": "^0.0.18"
34
34
  },
35
35
  "scripts": {
36
36
  "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",