vscode-json-languageservice 4.1.5 → 4.1.9

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,8 @@
1
+
2
+ 4.1.6 / 2021-07-16
3
+ ================
4
+ * Replace minimatch with glob-to-regexp
5
+
1
6
  4.1.0 / 2021-04-24
2
7
  ================
3
8
  * `SchemaConfiguration.fileMatch` now supports glob patterns (e.g. /foo/**/bar.json')
package/LICENSE.md CHANGED
@@ -19,3 +19,29 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
23
+ Glob matching is based on code from https://github.com/fitzgen/glob-to-regexp
24
+
25
+ Copyright (c) 2013, Nick Fitzgerald
26
+
27
+ All rights reserved.
28
+
29
+ Redistribution and use in source and binary forms, with or without modification,
30
+ are permitted provided that the following conditions are met:
31
+
32
+ Redistributions of source code must retain the above copyright notice, this list
33
+ of conditions and the following disclaimer.
34
+
35
+ Redistributions in binary form must reproduce the above copyright notice, this list
36
+ of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
37
+
38
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
39
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
41
+ SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
42
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
44
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47
+ OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,8 +1,8 @@
1
1
  import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
2
2
  import { JSONSchema } from './jsonSchema';
3
- import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
3
+ import { Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
4
4
  import { TextDocument } from 'vscode-languageserver-textdocument';
5
- export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
5
+ export { TextDocument, Range, Position, DocumentUri, MarkupContent, MarkupKind, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
6
6
  /**
7
7
  * Error codes used by diagnostics
8
8
  */
@@ -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 { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString } from 'vscode-languageserver-types';
5
+ import { Range, Position, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
6
6
  import { TextDocument } from 'vscode-languageserver-textdocument';
7
- export { TextDocument, Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
7
+ export { TextDocument, Range, Position, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
8
8
  /**
9
9
  * Error codes used by diagnostics
10
10
  */
@@ -13,7 +13,6 @@ export var schemaContributions = {
13
13
  },
14
14
  // bundle the schema-schema to include (localized) descriptions
15
15
  'http://json-schema.org/draft-04/schema#': {
16
- 'title': localize('schema.json', 'Describes a JSON file using a schema. See json-schema.org for more info.'),
17
16
  '$schema': 'http://json-schema.org/draft-04/schema#',
18
17
  'definitions': {
19
18
  'schemaArray': {
@@ -297,7 +296,6 @@ export var schemaContributions = {
297
296
  'default': {}
298
297
  },
299
298
  'http://json-schema.org/draft-07/schema#': {
300
- 'title': localize('schema.json', 'Describes a JSON file using a schema. See json-schema.org for more info.'),
301
299
  'definitions': {
302
300
  'schemaArray': {
303
301
  'type': 'array',
@@ -6,14 +6,14 @@ import * as Json from 'jsonc-parser';
6
6
  import { URI } from 'vscode-uri';
7
7
  import * as Strings from '../utils/strings';
8
8
  import * as Parser from '../parser/jsonParser';
9
- import { Minimatch } from 'minimatch';
10
9
  import * as nls from 'vscode-nls';
10
+ import { createRegex } from '../utils/glob';
11
11
  var localize = nls.loadMessageBundle();
12
12
  var BANG = '!';
13
13
  var PATH_SEP = '/';
14
14
  var FilePatternAssociation = /** @class */ (function () {
15
15
  function FilePatternAssociation(pattern, uris) {
16
- this.minimatchWrappers = [];
16
+ this.globWrappers = [];
17
17
  try {
18
18
  for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
19
19
  var patternString = pattern_1[_i];
@@ -25,8 +25,8 @@ var FilePatternAssociation = /** @class */ (function () {
25
25
  if (patternString[0] === PATH_SEP) {
26
26
  patternString = patternString.substring(1);
27
27
  }
28
- this.minimatchWrappers.push({
29
- minimatch: new Minimatch("**/" + patternString, { dot: true }),
28
+ this.globWrappers.push({
29
+ regexp: createRegex('**/' + patternString, { extended: true, globstar: true }),
30
30
  include: include,
31
31
  });
32
32
  }
@@ -35,15 +35,15 @@ var FilePatternAssociation = /** @class */ (function () {
35
35
  this.uris = uris;
36
36
  }
37
37
  catch (e) {
38
- this.minimatchWrappers.length = 0;
38
+ this.globWrappers.length = 0;
39
39
  this.uris = [];
40
40
  }
41
41
  }
42
42
  FilePatternAssociation.prototype.matchesPattern = function (fileName) {
43
43
  var match = false;
44
- for (var _i = 0, _a = this.minimatchWrappers; _i < _a.length; _i++) {
45
- var _b = _a[_i], minimatch = _b.minimatch, include = _b.include;
46
- if (minimatch.match(fileName)) {
44
+ for (var _i = 0, _a = this.globWrappers; _i < _a.length; _i++) {
45
+ var _b = _a[_i], regexp = _b.regexp, include = _b.include;
46
+ if (regexp.test(fileName)) {
47
47
  match = include;
48
48
  }
49
49
  }
@@ -175,6 +175,8 @@ var JSONSchemaService = /** @class */ (function () {
175
175
  };
176
176
  JSONSchemaService.prototype.onResourceChange = function (uri) {
177
177
  var _this = this;
178
+ // always clear this local cache when a resource changes
179
+ this.cachedSchemaForResource = undefined;
178
180
  var hasChanges = false;
179
181
  uri = normalizeId(uri);
180
182
  var toWalk = [uri];
@@ -231,7 +233,7 @@ var JSONSchemaService = /** @class */ (function () {
231
233
  this.registeredSchemasIds[id] = true;
232
234
  this.cachedSchemaForResource = undefined;
233
235
  if (filePatterns) {
234
- this.addFilePatternAssociation(filePatterns, [uri]);
236
+ this.addFilePatternAssociation(filePatterns, [id]);
235
237
  }
236
238
  return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
237
239
  };
@@ -0,0 +1,124 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Copyright (c) 2013, Nick Fitzgerald
4
+ * Licensed under the MIT License. See LICENCE.md in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ export function createRegex(glob, opts) {
7
+ if (typeof glob !== 'string') {
8
+ throw new TypeError('Expected a string');
9
+ }
10
+ var str = String(glob);
11
+ // The regexp we are building, as a string.
12
+ var reStr = "";
13
+ // Whether we are matching so called "extended" globs (like bash) and should
14
+ // support single character matching, matching ranges of characters, group
15
+ // matching, etc.
16
+ var extended = opts ? !!opts.extended : false;
17
+ // When globstar is _false_ (default), '/foo/*' is translated a regexp like
18
+ // '^\/foo\/.*$' which will match any string beginning with '/foo/'
19
+ // When globstar is _true_, '/foo/*' is translated to regexp like
20
+ // '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
21
+ // which does not have a '/' to the right of it.
22
+ // E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
23
+ // these will not '/foo/bar/baz', '/foo/bar/baz.txt'
24
+ // Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
25
+ // globstar is _false_
26
+ var globstar = opts ? !!opts.globstar : false;
27
+ // If we are doing extended matching, this boolean is true when we are inside
28
+ // a group (eg {*.html,*.js}), and false otherwise.
29
+ var inGroup = false;
30
+ // RegExp flags (eg "i" ) to pass in to RegExp constructor.
31
+ var flags = opts && typeof (opts.flags) === "string" ? opts.flags : "";
32
+ var c;
33
+ for (var i = 0, len = str.length; i < len; i++) {
34
+ c = str[i];
35
+ switch (c) {
36
+ case "/":
37
+ case "$":
38
+ case "^":
39
+ case "+":
40
+ case ".":
41
+ case "(":
42
+ case ")":
43
+ case "=":
44
+ case "!":
45
+ case "|":
46
+ reStr += "\\" + c;
47
+ break;
48
+ case "?":
49
+ if (extended) {
50
+ reStr += ".";
51
+ break;
52
+ }
53
+ case "[":
54
+ case "]":
55
+ if (extended) {
56
+ reStr += c;
57
+ break;
58
+ }
59
+ case "{":
60
+ if (extended) {
61
+ inGroup = true;
62
+ reStr += "(";
63
+ break;
64
+ }
65
+ case "}":
66
+ if (extended) {
67
+ inGroup = false;
68
+ reStr += ")";
69
+ break;
70
+ }
71
+ case ",":
72
+ if (inGroup) {
73
+ reStr += "|";
74
+ break;
75
+ }
76
+ reStr += "\\" + c;
77
+ break;
78
+ case "*":
79
+ // Move over all consecutive "*"'s.
80
+ // Also store the previous and next characters
81
+ var prevChar = str[i - 1];
82
+ var starCount = 1;
83
+ while (str[i + 1] === "*") {
84
+ starCount++;
85
+ i++;
86
+ }
87
+ var nextChar = str[i + 1];
88
+ if (!globstar) {
89
+ // globstar is disabled, so treat any number of "*" as one
90
+ reStr += ".*";
91
+ }
92
+ else {
93
+ // globstar is enabled, so determine if this is a globstar segment
94
+ var isGlobstar = starCount > 1 // multiple "*"'s
95
+ && (prevChar === "/" || prevChar === undefined || prevChar === '{' || prevChar === ',') // from the start of the segment
96
+ && (nextChar === "/" || nextChar === undefined || nextChar === ',' || nextChar === '}'); // to the end of the segment
97
+ if (isGlobstar) {
98
+ if (nextChar === "/") {
99
+ i++; // move over the "/"
100
+ }
101
+ else if (prevChar === '/' && reStr.endsWith('\\/')) {
102
+ reStr = reStr.substr(0, reStr.length - 2);
103
+ }
104
+ // it's a globstar, so match zero or more path segments
105
+ reStr += "((?:[^/]*(?:\/|$))*)";
106
+ }
107
+ else {
108
+ // it's not a globstar, so only match one path segment
109
+ reStr += "([^/]*)";
110
+ }
111
+ }
112
+ break;
113
+ default:
114
+ reStr += c;
115
+ }
116
+ }
117
+ // When regexp 'g' flag is specified don't
118
+ // constrain the regular expression with ^ & $
119
+ if (!flags || !~flags.indexOf('g')) {
120
+ reStr = "^" + reStr + "$";
121
+ }
122
+ return new RegExp(reStr, flags);
123
+ }
124
+ ;
@@ -44,9 +44,9 @@ export function repeat(value, count) {
44
44
  }
45
45
  export function extendedRegExp(pattern) {
46
46
  if (startsWith(pattern, '(?i)')) {
47
- return new RegExp(pattern.substring(4), 'i');
47
+ return new RegExp(pattern.substring(4), 'iu');
48
48
  }
49
49
  else {
50
- return new RegExp(pattern);
50
+ return new RegExp(pattern, 'u');
51
51
  }
52
52
  }
@@ -1,8 +1,8 @@
1
1
  import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
2
2
  import { JSONSchema } from './jsonSchema';
3
- import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink } from 'vscode-languageserver-types';
3
+ import { Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
4
4
  import { TextDocument } from 'vscode-languageserver-textdocument';
5
- export { TextDocument, Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, Position, InsertTextFormat, MarkupContent, MarkupKind, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString };
5
+ export { TextDocument, Range, Position, DocumentUri, MarkupContent, MarkupKind, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
6
6
  /**
7
7
  * Error codes used by diagnostics
8
8
  */
@@ -13,31 +13,42 @@
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ClientCapabilities = exports.ErrorCode = exports.MarkedString = exports.Hover = exports.Location = exports.DocumentSymbol = exports.SymbolKind = exports.SymbolInformation = exports.MarkupKind = exports.MarkupContent = exports.InsertTextFormat = exports.Position = exports.CompletionList = exports.CompletionItemKind = exports.CompletionItem = exports.DiagnosticSeverity = exports.Diagnostic = exports.SelectionRange = exports.FoldingRangeKind = exports.FoldingRange = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.TextEdit = exports.Range = exports.TextDocument = void 0;
16
+ exports.ClientCapabilities = exports.ErrorCode = exports.DocumentHighlightKind = exports.VersionedTextDocumentIdentifier = exports.TextDocumentEdit = exports.CodeActionKind = exports.TextEdit = exports.WorkspaceEdit = exports.DocumentLink = exports.DocumentHighlight = exports.CodeAction = exports.Command = exports.CodeActionContext = exports.MarkedString = exports.Hover = exports.Location = exports.DocumentSymbol = exports.SymbolKind = exports.SymbolInformation = exports.InsertTextFormat = exports.CompletionItemTag = exports.CompletionList = exports.CompletionItemKind = exports.CompletionItem = exports.DiagnosticSeverity = exports.Diagnostic = exports.SelectionRange = exports.FoldingRangeKind = exports.FoldingRange = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.MarkupKind = exports.MarkupContent = exports.Position = exports.Range = exports.TextDocument = void 0;
17
17
  var vscode_languageserver_types_1 = require("vscode-languageserver-types");
18
18
  Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return vscode_languageserver_types_1.Range; } });
19
- Object.defineProperty(exports, "TextEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.TextEdit; } });
19
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return vscode_languageserver_types_1.Position; } });
20
+ Object.defineProperty(exports, "MarkupContent", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupContent; } });
21
+ Object.defineProperty(exports, "MarkupKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupKind; } });
20
22
  Object.defineProperty(exports, "Color", { enumerable: true, get: function () { return vscode_languageserver_types_1.Color; } });
21
23
  Object.defineProperty(exports, "ColorInformation", { enumerable: true, get: function () { return vscode_languageserver_types_1.ColorInformation; } });
22
24
  Object.defineProperty(exports, "ColorPresentation", { enumerable: true, get: function () { return vscode_languageserver_types_1.ColorPresentation; } });
23
25
  Object.defineProperty(exports, "FoldingRange", { enumerable: true, get: function () { return vscode_languageserver_types_1.FoldingRange; } });
24
26
  Object.defineProperty(exports, "FoldingRangeKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.FoldingRangeKind; } });
25
- Object.defineProperty(exports, "MarkupKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupKind; } });
26
27
  Object.defineProperty(exports, "SelectionRange", { enumerable: true, get: function () { return vscode_languageserver_types_1.SelectionRange; } });
27
28
  Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return vscode_languageserver_types_1.Diagnostic; } });
28
29
  Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return vscode_languageserver_types_1.DiagnosticSeverity; } });
29
30
  Object.defineProperty(exports, "CompletionItem", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionItem; } });
30
31
  Object.defineProperty(exports, "CompletionItemKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionItemKind; } });
31
32
  Object.defineProperty(exports, "CompletionList", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionList; } });
32
- Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return vscode_languageserver_types_1.Position; } });
33
+ Object.defineProperty(exports, "CompletionItemTag", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionItemTag; } });
33
34
  Object.defineProperty(exports, "InsertTextFormat", { enumerable: true, get: function () { return vscode_languageserver_types_1.InsertTextFormat; } });
34
- Object.defineProperty(exports, "MarkupContent", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupContent; } });
35
35
  Object.defineProperty(exports, "SymbolInformation", { enumerable: true, get: function () { return vscode_languageserver_types_1.SymbolInformation; } });
36
36
  Object.defineProperty(exports, "SymbolKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.SymbolKind; } });
37
37
  Object.defineProperty(exports, "DocumentSymbol", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentSymbol; } });
38
38
  Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return vscode_languageserver_types_1.Location; } });
39
39
  Object.defineProperty(exports, "Hover", { enumerable: true, get: function () { return vscode_languageserver_types_1.Hover; } });
40
40
  Object.defineProperty(exports, "MarkedString", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkedString; } });
41
+ Object.defineProperty(exports, "CodeActionContext", { enumerable: true, get: function () { return vscode_languageserver_types_1.CodeActionContext; } });
42
+ Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return vscode_languageserver_types_1.Command; } });
43
+ Object.defineProperty(exports, "CodeAction", { enumerable: true, get: function () { return vscode_languageserver_types_1.CodeAction; } });
44
+ Object.defineProperty(exports, "DocumentHighlight", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentHighlight; } });
45
+ Object.defineProperty(exports, "DocumentLink", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentLink; } });
46
+ Object.defineProperty(exports, "WorkspaceEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.WorkspaceEdit; } });
47
+ Object.defineProperty(exports, "TextEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.TextEdit; } });
48
+ Object.defineProperty(exports, "CodeActionKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.CodeActionKind; } });
49
+ Object.defineProperty(exports, "TextDocumentEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.TextDocumentEdit; } });
50
+ Object.defineProperty(exports, "VersionedTextDocumentIdentifier", { enumerable: true, get: function () { return vscode_languageserver_types_1.VersionedTextDocumentIdentifier; } });
51
+ Object.defineProperty(exports, "DocumentHighlightKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentHighlightKind; } });
41
52
  var vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
42
53
  Object.defineProperty(exports, "TextDocument", { enumerable: true, get: function () { return vscode_languageserver_textdocument_1.TextDocument; } });
43
54
  /**
@@ -25,7 +25,6 @@
25
25
  },
26
26
  // bundle the schema-schema to include (localized) descriptions
27
27
  'http://json-schema.org/draft-04/schema#': {
28
- 'title': localize('schema.json', 'Describes a JSON file using a schema. See json-schema.org for more info.'),
29
28
  '$schema': 'http://json-schema.org/draft-04/schema#',
30
29
  'definitions': {
31
30
  'schemaArray': {
@@ -309,7 +308,6 @@
309
308
  'default': {}
310
309
  },
311
310
  'http://json-schema.org/draft-07/schema#': {
312
- 'title': localize('schema.json', 'Describes a JSON file using a schema. See json-schema.org for more info.'),
313
311
  'definitions': {
314
312
  'schemaArray': {
315
313
  'type': 'array',
@@ -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", "minimatch", "vscode-nls"], factory);
11
+ define(["require", "exports", "jsonc-parser", "vscode-uri", "../utils/strings", "../parser/jsonParser", "vscode-nls", "../utils/glob"], factory);
12
12
  }
13
13
  })(function (require, exports) {
14
14
  "use strict";
@@ -18,14 +18,14 @@
18
18
  var vscode_uri_1 = require("vscode-uri");
19
19
  var Strings = require("../utils/strings");
20
20
  var Parser = require("../parser/jsonParser");
21
- var minimatch_1 = require("minimatch");
22
21
  var nls = require("vscode-nls");
22
+ var glob_1 = require("../utils/glob");
23
23
  var localize = nls.loadMessageBundle();
24
24
  var BANG = '!';
25
25
  var PATH_SEP = '/';
26
26
  var FilePatternAssociation = /** @class */ (function () {
27
27
  function FilePatternAssociation(pattern, uris) {
28
- this.minimatchWrappers = [];
28
+ this.globWrappers = [];
29
29
  try {
30
30
  for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
31
31
  var patternString = pattern_1[_i];
@@ -37,8 +37,8 @@
37
37
  if (patternString[0] === PATH_SEP) {
38
38
  patternString = patternString.substring(1);
39
39
  }
40
- this.minimatchWrappers.push({
41
- minimatch: new minimatch_1.Minimatch("**/" + patternString, { dot: true }),
40
+ this.globWrappers.push({
41
+ regexp: glob_1.createRegex('**/' + patternString, { extended: true, globstar: true }),
42
42
  include: include,
43
43
  });
44
44
  }
@@ -47,15 +47,15 @@
47
47
  this.uris = uris;
48
48
  }
49
49
  catch (e) {
50
- this.minimatchWrappers.length = 0;
50
+ this.globWrappers.length = 0;
51
51
  this.uris = [];
52
52
  }
53
53
  }
54
54
  FilePatternAssociation.prototype.matchesPattern = function (fileName) {
55
55
  var match = false;
56
- for (var _i = 0, _a = this.minimatchWrappers; _i < _a.length; _i++) {
57
- var _b = _a[_i], minimatch = _b.minimatch, include = _b.include;
58
- if (minimatch.match(fileName)) {
56
+ for (var _i = 0, _a = this.globWrappers; _i < _a.length; _i++) {
57
+ var _b = _a[_i], regexp = _b.regexp, include = _b.include;
58
+ if (regexp.test(fileName)) {
59
59
  match = include;
60
60
  }
61
61
  }
@@ -187,6 +187,8 @@
187
187
  };
188
188
  JSONSchemaService.prototype.onResourceChange = function (uri) {
189
189
  var _this = this;
190
+ // always clear this local cache when a resource changes
191
+ this.cachedSchemaForResource = undefined;
190
192
  var hasChanges = false;
191
193
  uri = normalizeId(uri);
192
194
  var toWalk = [uri];
@@ -243,7 +245,7 @@
243
245
  this.registeredSchemasIds[id] = true;
244
246
  this.cachedSchemaForResource = undefined;
245
247
  if (filePatterns) {
246
- this.addFilePatternAssociation(filePatterns, [uri]);
248
+ this.addFilePatternAssociation(filePatterns, [id]);
247
249
  }
248
250
  return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
249
251
  };
@@ -0,0 +1,138 @@
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
+ exports.createRegex = void 0;
13
+ /*---------------------------------------------------------------------------------------------
14
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15
+ * Copyright (c) 2013, Nick Fitzgerald
16
+ * Licensed under the MIT License. See LICENCE.md in the project root for license information.
17
+ *--------------------------------------------------------------------------------------------*/
18
+ function createRegex(glob, opts) {
19
+ if (typeof glob !== 'string') {
20
+ throw new TypeError('Expected a string');
21
+ }
22
+ var str = String(glob);
23
+ // The regexp we are building, as a string.
24
+ var reStr = "";
25
+ // Whether we are matching so called "extended" globs (like bash) and should
26
+ // support single character matching, matching ranges of characters, group
27
+ // matching, etc.
28
+ var extended = opts ? !!opts.extended : false;
29
+ // When globstar is _false_ (default), '/foo/*' is translated a regexp like
30
+ // '^\/foo\/.*$' which will match any string beginning with '/foo/'
31
+ // When globstar is _true_, '/foo/*' is translated to regexp like
32
+ // '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
33
+ // which does not have a '/' to the right of it.
34
+ // E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
35
+ // these will not '/foo/bar/baz', '/foo/bar/baz.txt'
36
+ // Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
37
+ // globstar is _false_
38
+ var globstar = opts ? !!opts.globstar : false;
39
+ // If we are doing extended matching, this boolean is true when we are inside
40
+ // a group (eg {*.html,*.js}), and false otherwise.
41
+ var inGroup = false;
42
+ // RegExp flags (eg "i" ) to pass in to RegExp constructor.
43
+ var flags = opts && typeof (opts.flags) === "string" ? opts.flags : "";
44
+ var c;
45
+ for (var i = 0, len = str.length; i < len; i++) {
46
+ c = str[i];
47
+ switch (c) {
48
+ case "/":
49
+ case "$":
50
+ case "^":
51
+ case "+":
52
+ case ".":
53
+ case "(":
54
+ case ")":
55
+ case "=":
56
+ case "!":
57
+ case "|":
58
+ reStr += "\\" + c;
59
+ break;
60
+ case "?":
61
+ if (extended) {
62
+ reStr += ".";
63
+ break;
64
+ }
65
+ case "[":
66
+ case "]":
67
+ if (extended) {
68
+ reStr += c;
69
+ break;
70
+ }
71
+ case "{":
72
+ if (extended) {
73
+ inGroup = true;
74
+ reStr += "(";
75
+ break;
76
+ }
77
+ case "}":
78
+ if (extended) {
79
+ inGroup = false;
80
+ reStr += ")";
81
+ break;
82
+ }
83
+ case ",":
84
+ if (inGroup) {
85
+ reStr += "|";
86
+ break;
87
+ }
88
+ reStr += "\\" + c;
89
+ break;
90
+ case "*":
91
+ // Move over all consecutive "*"'s.
92
+ // Also store the previous and next characters
93
+ var prevChar = str[i - 1];
94
+ var starCount = 1;
95
+ while (str[i + 1] === "*") {
96
+ starCount++;
97
+ i++;
98
+ }
99
+ var nextChar = str[i + 1];
100
+ if (!globstar) {
101
+ // globstar is disabled, so treat any number of "*" as one
102
+ reStr += ".*";
103
+ }
104
+ else {
105
+ // globstar is enabled, so determine if this is a globstar segment
106
+ var isGlobstar = starCount > 1 // multiple "*"'s
107
+ && (prevChar === "/" || prevChar === undefined || prevChar === '{' || prevChar === ',') // from the start of the segment
108
+ && (nextChar === "/" || nextChar === undefined || nextChar === ',' || nextChar === '}'); // to the end of the segment
109
+ if (isGlobstar) {
110
+ if (nextChar === "/") {
111
+ i++; // move over the "/"
112
+ }
113
+ else if (prevChar === '/' && reStr.endsWith('\\/')) {
114
+ reStr = reStr.substr(0, reStr.length - 2);
115
+ }
116
+ // it's a globstar, so match zero or more path segments
117
+ reStr += "((?:[^/]*(?:\/|$))*)";
118
+ }
119
+ else {
120
+ // it's not a globstar, so only match one path segment
121
+ reStr += "([^/]*)";
122
+ }
123
+ }
124
+ break;
125
+ default:
126
+ reStr += c;
127
+ }
128
+ }
129
+ // When regexp 'g' flag is specified don't
130
+ // constrain the regular expression with ^ & $
131
+ if (!flags || !~flags.indexOf('g')) {
132
+ reStr = "^" + reStr + "$";
133
+ }
134
+ return new RegExp(reStr, flags);
135
+ }
136
+ exports.createRegex = createRegex;
137
+ ;
138
+ });
@@ -60,10 +60,10 @@
60
60
  exports.repeat = repeat;
61
61
  function extendedRegExp(pattern) {
62
62
  if (startsWith(pattern, '(?i)')) {
63
- return new RegExp(pattern.substring(4), 'i');
63
+ return new RegExp(pattern.substring(4), 'iu');
64
64
  }
65
65
  else {
66
- return new RegExp(pattern);
66
+ return new RegExp(pattern, 'u');
67
67
  }
68
68
  }
69
69
  exports.extendedRegExp = extendedRegExp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-json-languageservice",
3
- "version": "4.1.5",
3
+ "version": "4.1.9",
4
4
  "description": "Language service for JSON",
5
5
  "main": "./lib/umd/jsonLanguageService.js",
6
6
  "typings": "./lib/umd/jsonLanguageService",
@@ -18,19 +18,17 @@
18
18
  "npm": ">=7.0.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@types/minimatch": "^3.0.3",
22
- "@types/mocha": "^8.2.0",
21
+ "@types/mocha": "^9.0.0",
23
22
  "@types/node": "^10.12.21",
24
- "@typescript-eslint/eslint-plugin": "^4.14.0",
25
- "@typescript-eslint/parser": "^4.14.0",
26
- "eslint": "^7.18.0",
27
- "mocha": "^8.2.1",
23
+ "@typescript-eslint/eslint-plugin": "^4.32.0",
24
+ "@typescript-eslint/parser": "^4.32.0",
25
+ "eslint": "^7.32.0",
26
+ "mocha": "^9.1.2",
28
27
  "rimraf": "^3.0.2",
29
28
  "typescript": "^4.1.3"
30
29
  },
31
30
  "dependencies": {
32
31
  "jsonc-parser": "^3.0.0",
33
- "minimatch": "^3.0.4",
34
32
  "vscode-languageserver-textdocument": "^1.0.1",
35
33
  "vscode-languageserver-types": "^3.16.0",
36
34
  "vscode-nls": "^5.0.0",