vscode-json-languageservice 4.1.9 → 4.1.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.
- package/lib/esm/parser/jsonParser.js +2 -2
- package/lib/esm/services/jsonCompletion.js +1 -1
- package/lib/esm/services/jsonSchemaService.js +1 -1
- package/lib/esm/utils/strings.js +15 -3
- package/lib/umd/parser/jsonParser.js +2 -2
- package/lib/umd/services/jsonCompletion.js +1 -1
- package/lib/umd/services/jsonSchemaService.js +1 -1
- package/lib/umd/utils/strings.js +15 -3
- package/package.json +1 -4
|
@@ -617,7 +617,7 @@ function validate(n, schema, validationResult, matchingSchemas) {
|
|
|
617
617
|
}
|
|
618
618
|
if (isString(schema.pattern)) {
|
|
619
619
|
var regex = extendedRegExp(schema.pattern);
|
|
620
|
-
if (!regex.test(node.value)) {
|
|
620
|
+
if (!(regex === null || regex === void 0 ? void 0 : regex.test(node.value))) {
|
|
621
621
|
validationResult.problems.push({
|
|
622
622
|
location: { offset: node.offset, length: node.length },
|
|
623
623
|
message: schema.patternErrorMessage || schema.errorMessage || localize('patternWarning', 'String does not match the pattern of "{0}".', schema.pattern)
|
|
@@ -811,7 +811,7 @@ function validate(n, schema, validationResult, matchingSchemas) {
|
|
|
811
811
|
var regex = extendedRegExp(propertyPattern);
|
|
812
812
|
for (var _h = 0, _j = unprocessedProperties.slice(0); _h < _j.length; _h++) {
|
|
813
813
|
var propertyName = _j[_h];
|
|
814
|
-
if (regex.test(propertyName)) {
|
|
814
|
+
if (regex === null || regex === void 0 ? void 0 : regex.test(propertyName)) {
|
|
815
815
|
propertyProcessed(propertyName);
|
|
816
816
|
var child = seenKeys[propertyName];
|
|
817
817
|
if (child) {
|
|
@@ -440,7 +440,7 @@ var JSONCompletion = /** @class */ (function () {
|
|
|
440
440
|
for (var _a = 0, _b = Object.keys(s.schema.patternProperties); _a < _b.length; _a++) {
|
|
441
441
|
var pattern = _b[_a];
|
|
442
442
|
var regex = extendedRegExp(pattern);
|
|
443
|
-
if (regex.test(parentKey)) {
|
|
443
|
+
if (regex === null || regex === void 0 ? void 0 : regex.test(parentKey)) {
|
|
444
444
|
propertyMatched = true;
|
|
445
445
|
var propertySchema = s.schema.patternProperties[pattern];
|
|
446
446
|
this.addSchemaValueCompletions(propertySchema, separatorAfter, collector, types);
|
|
@@ -119,7 +119,7 @@ var ResolvedSchema = /** @class */ (function () {
|
|
|
119
119
|
for (var _i = 0, _a = Object.keys(schema.patternProperties); _i < _a.length; _i++) {
|
|
120
120
|
var pattern = _a[_i];
|
|
121
121
|
var regex = Strings.extendedRegExp(pattern);
|
|
122
|
-
if (regex.test(next)) {
|
|
122
|
+
if (regex === null || regex === void 0 ? void 0 : regex.test(next)) {
|
|
123
123
|
return this.getSectionRecursive(path, schema.patternProperties[pattern]);
|
|
124
124
|
}
|
|
125
125
|
}
|
package/lib/esm/utils/strings.js
CHANGED
|
@@ -43,10 +43,22 @@ export function repeat(value, count) {
|
|
|
43
43
|
return s;
|
|
44
44
|
}
|
|
45
45
|
export function extendedRegExp(pattern) {
|
|
46
|
+
var flags = '';
|
|
46
47
|
if (startsWith(pattern, '(?i)')) {
|
|
47
|
-
|
|
48
|
+
pattern = pattern.substring(4);
|
|
49
|
+
flags = 'i';
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
return new RegExp(pattern, 'u');
|
|
51
|
+
try {
|
|
52
|
+
return new RegExp(pattern, flags + 'u');
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
// could be an exception due to the 'u ' flag
|
|
56
|
+
try {
|
|
57
|
+
return new RegExp(pattern, flags);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
// invalid pattern
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
64
|
}
|
|
@@ -634,7 +634,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
634
634
|
}
|
|
635
635
|
if (objects_1.isString(schema.pattern)) {
|
|
636
636
|
var regex = strings_1.extendedRegExp(schema.pattern);
|
|
637
|
-
if (!regex.test(node.value)) {
|
|
637
|
+
if (!(regex === null || regex === void 0 ? void 0 : regex.test(node.value))) {
|
|
638
638
|
validationResult.problems.push({
|
|
639
639
|
location: { offset: node.offset, length: node.length },
|
|
640
640
|
message: schema.patternErrorMessage || schema.errorMessage || localize('patternWarning', 'String does not match the pattern of "{0}".', schema.pattern)
|
|
@@ -828,7 +828,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
828
828
|
var regex = strings_1.extendedRegExp(propertyPattern);
|
|
829
829
|
for (var _h = 0, _j = unprocessedProperties.slice(0); _h < _j.length; _h++) {
|
|
830
830
|
var propertyName = _j[_h];
|
|
831
|
-
if (regex.test(propertyName)) {
|
|
831
|
+
if (regex === null || regex === void 0 ? void 0 : regex.test(propertyName)) {
|
|
832
832
|
propertyProcessed(propertyName);
|
|
833
833
|
var child = seenKeys[propertyName];
|
|
834
834
|
if (child) {
|
|
@@ -452,7 +452,7 @@
|
|
|
452
452
|
for (var _a = 0, _b = Object.keys(s.schema.patternProperties); _a < _b.length; _a++) {
|
|
453
453
|
var pattern = _b[_a];
|
|
454
454
|
var regex = strings_1.extendedRegExp(pattern);
|
|
455
|
-
if (regex.test(parentKey)) {
|
|
455
|
+
if (regex === null || regex === void 0 ? void 0 : regex.test(parentKey)) {
|
|
456
456
|
propertyMatched = true;
|
|
457
457
|
var propertySchema = s.schema.patternProperties[pattern];
|
|
458
458
|
this.addSchemaValueCompletions(propertySchema, separatorAfter, collector, types);
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
for (var _i = 0, _a = Object.keys(schema.patternProperties); _i < _a.length; _i++) {
|
|
132
132
|
var pattern = _a[_i];
|
|
133
133
|
var regex = Strings.extendedRegExp(pattern);
|
|
134
|
-
if (regex.test(next)) {
|
|
134
|
+
if (regex === null || regex === void 0 ? void 0 : regex.test(next)) {
|
|
135
135
|
return this.getSectionRecursive(path, schema.patternProperties[pattern]);
|
|
136
136
|
}
|
|
137
137
|
}
|
package/lib/umd/utils/strings.js
CHANGED
|
@@ -59,11 +59,23 @@
|
|
|
59
59
|
}
|
|
60
60
|
exports.repeat = repeat;
|
|
61
61
|
function extendedRegExp(pattern) {
|
|
62
|
+
var flags = '';
|
|
62
63
|
if (startsWith(pattern, '(?i)')) {
|
|
63
|
-
|
|
64
|
+
pattern = pattern.substring(4);
|
|
65
|
+
flags = 'i';
|
|
64
66
|
}
|
|
65
|
-
|
|
66
|
-
return new RegExp(pattern, 'u');
|
|
67
|
+
try {
|
|
68
|
+
return new RegExp(pattern, flags + 'u');
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
// could be an exception due to the 'u ' flag
|
|
72
|
+
try {
|
|
73
|
+
return new RegExp(pattern, flags);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
// invalid pattern
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
81
|
exports.extendedRegExp = extendedRegExp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-json-languageservice",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.10",
|
|
4
4
|
"description": "Language service for JSON",
|
|
5
5
|
"main": "./lib/umd/jsonLanguageService.js",
|
|
6
6
|
"typings": "./lib/umd/jsonLanguageService",
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/Microsoft/vscode-json-languageservice"
|
|
16
16
|
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"npm": ">=7.0.0"
|
|
19
|
-
},
|
|
20
17
|
"devDependencies": {
|
|
21
18
|
"@types/mocha": "^9.0.0",
|
|
22
19
|
"@types/node": "^10.12.21",
|