vscode-json-languageservice 4.2.0-next.0 → 4.2.0-next.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.
|
@@ -439,13 +439,17 @@ var JSONSchemaService = /** @class */ (function () {
|
|
|
439
439
|
};
|
|
440
440
|
return resolveRefs(schema, schema, schemaURL, dependencies).then(function (_) { return new ResolvedSchema(schema, resolveErrors); });
|
|
441
441
|
};
|
|
442
|
-
JSONSchemaService.prototype.
|
|
442
|
+
JSONSchemaService.prototype.getSchemaFromProperty = function (resource, document) {
|
|
443
443
|
var _a, _b;
|
|
444
444
|
if (((_a = document.root) === null || _a === void 0 ? void 0 : _a.type) === 'object') {
|
|
445
445
|
for (var _i = 0, _c = document.root.properties; _i < _c.length; _i++) {
|
|
446
446
|
var p = _c[_i];
|
|
447
447
|
if (p.keyNode.value === '$schema' && ((_b = p.valueNode) === null || _b === void 0 ? void 0 : _b.type) === 'string') {
|
|
448
|
-
|
|
448
|
+
var schemaId = p.valueNode.value;
|
|
449
|
+
if (this.contextService && !/^\w[\w\d+.-]*:/.test(schemaId)) { // has scheme
|
|
450
|
+
schemaId = this.contextService.resolveRelativePath(schemaId, resource);
|
|
451
|
+
}
|
|
452
|
+
return schemaId;
|
|
449
453
|
}
|
|
450
454
|
}
|
|
451
455
|
}
|
|
@@ -470,7 +474,7 @@ var JSONSchemaService = /** @class */ (function () {
|
|
|
470
474
|
return schemas;
|
|
471
475
|
};
|
|
472
476
|
JSONSchemaService.prototype.getSchemaURIsForResource = function (resource, document) {
|
|
473
|
-
var schemeId = document && this.
|
|
477
|
+
var schemeId = document && this.getSchemaFromProperty(resource, document);
|
|
474
478
|
if (schemeId) {
|
|
475
479
|
return [schemeId];
|
|
476
480
|
}
|
|
@@ -479,10 +483,7 @@ var JSONSchemaService = /** @class */ (function () {
|
|
|
479
483
|
JSONSchemaService.prototype.getSchemaForResource = function (resource, document) {
|
|
480
484
|
if (document) {
|
|
481
485
|
// first use $schema if present
|
|
482
|
-
var schemeId = this.
|
|
483
|
-
if (schemeId && Strings.startsWith(schemeId, '.') && this.contextService) {
|
|
484
|
-
schemeId = this.contextService.resolveRelativePath(schemeId, resource);
|
|
485
|
-
}
|
|
486
|
+
var schemeId = this.getSchemaFromProperty(resource, document);
|
|
486
487
|
if (schemeId) {
|
|
487
488
|
var id = normalizeId(schemeId);
|
|
488
489
|
return this.getOrAddSchemaHandle(id).getResolvedSchema();
|
|
@@ -451,13 +451,17 @@
|
|
|
451
451
|
};
|
|
452
452
|
return resolveRefs(schema, schema, schemaURL, dependencies).then(function (_) { return new ResolvedSchema(schema, resolveErrors); });
|
|
453
453
|
};
|
|
454
|
-
JSONSchemaService.prototype.
|
|
454
|
+
JSONSchemaService.prototype.getSchemaFromProperty = function (resource, document) {
|
|
455
455
|
var _a, _b;
|
|
456
456
|
if (((_a = document.root) === null || _a === void 0 ? void 0 : _a.type) === 'object') {
|
|
457
457
|
for (var _i = 0, _c = document.root.properties; _i < _c.length; _i++) {
|
|
458
458
|
var p = _c[_i];
|
|
459
459
|
if (p.keyNode.value === '$schema' && ((_b = p.valueNode) === null || _b === void 0 ? void 0 : _b.type) === 'string') {
|
|
460
|
-
|
|
460
|
+
var schemaId = p.valueNode.value;
|
|
461
|
+
if (this.contextService && !/^\w[\w\d+.-]*:/.test(schemaId)) { // has scheme
|
|
462
|
+
schemaId = this.contextService.resolveRelativePath(schemaId, resource);
|
|
463
|
+
}
|
|
464
|
+
return schemaId;
|
|
461
465
|
}
|
|
462
466
|
}
|
|
463
467
|
}
|
|
@@ -482,7 +486,7 @@
|
|
|
482
486
|
return schemas;
|
|
483
487
|
};
|
|
484
488
|
JSONSchemaService.prototype.getSchemaURIsForResource = function (resource, document) {
|
|
485
|
-
var schemeId = document && this.
|
|
489
|
+
var schemeId = document && this.getSchemaFromProperty(resource, document);
|
|
486
490
|
if (schemeId) {
|
|
487
491
|
return [schemeId];
|
|
488
492
|
}
|
|
@@ -491,10 +495,7 @@
|
|
|
491
495
|
JSONSchemaService.prototype.getSchemaForResource = function (resource, document) {
|
|
492
496
|
if (document) {
|
|
493
497
|
// first use $schema if present
|
|
494
|
-
var schemeId = this.
|
|
495
|
-
if (schemeId && Strings.startsWith(schemeId, '.') && this.contextService) {
|
|
496
|
-
schemeId = this.contextService.resolveRelativePath(schemeId, resource);
|
|
497
|
-
}
|
|
498
|
+
var schemeId = this.getSchemaFromProperty(resource, document);
|
|
498
499
|
if (schemeId) {
|
|
499
500
|
var id = normalizeId(schemeId);
|
|
500
501
|
return this.getOrAddSchemaHandle(id).getResolvedSchema();
|