@nubase/terminal 0.0.0-stage → 0.1.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.
Files changed (119) hide show
  1. package/bin/nubase.js +11 -0
  2. package/out/main/index.js +3218 -0
  3. package/out/preload/index.cjs +23 -0
  4. package/out/renderer/assets/BinaryPreviews-Dvmgctgl.js +262 -0
  5. package/out/renderer/assets/CodeEditor-BKx61p9c.js +2034 -0
  6. package/out/renderer/assets/DocumentPreviews-BA1gL-ZJ.js +66 -0
  7. package/out/renderer/assets/DocxPreview-CiY-SNbh.js +6955 -0
  8. package/out/renderer/assets/ImagePreview-DpnKfbxj.js +120 -0
  9. package/out/renderer/assets/PdfPreview-6oeuYaqY.js +24399 -0
  10. package/out/renderer/assets/PdfPreview-BT-DZbCt.css +6483 -0
  11. package/out/renderer/assets/SpreadsheetPreviews-B4Qby88A.js +23987 -0
  12. package/out/renderer/assets/abap-Cel38df4.js +1317 -0
  13. package/out/renderer/assets/apex-DzOmV_zF.js +355 -0
  14. package/out/renderer/assets/azcli-Xvapx-7p.js +56 -0
  15. package/out/renderer/assets/bat-BGMSIlWY.js +126 -0
  16. package/out/renderer/assets/bicep-CcpV5qxk.js +228 -0
  17. package/out/renderer/assets/cameligo-BfMDXVEx.js +233 -0
  18. package/out/renderer/assets/clojure-DFgIAJGu.js +801 -0
  19. package/out/renderer/assets/codicon-DF1abBS2.ttf +0 -0
  20. package/out/renderer/assets/coffee-Db4q5aZ8.js +308 -0
  21. package/out/renderer/assets/cpp-CEvPJv6f.js +450 -0
  22. package/out/renderer/assets/csharp-CVoBr97X.js +405 -0
  23. package/out/renderer/assets/csp-Cgzd5gxo.js +49 -0
  24. package/out/renderer/assets/css-D3M-RRVi.js +287 -0
  25. package/out/renderer/assets/css.worker-AXSlELAq.js +50031 -0
  26. package/out/renderer/assets/cssMode-CrMQfSUN.js +101 -0
  27. package/out/renderer/assets/cursor-editorTextHighlight-kG3uUOwL.svg +8 -0
  28. package/out/renderer/assets/cypher-DJJgZ_3Q.js +326 -0
  29. package/out/renderer/assets/dart-Bkg7I-Qe.js +341 -0
  30. package/out/renderer/assets/dockerfile-B1r36HyK.js +194 -0
  31. package/out/renderer/assets/ecl-C1Ji6tZG.js +531 -0
  32. package/out/renderer/assets/editor-CXfYqUZ6.css +4816 -0
  33. package/out/renderer/assets/editor.api-zF37fz_e.js +127071 -0
  34. package/out/renderer/assets/elixir-D_-n8lGJ.js +526 -0
  35. package/out/renderer/assets/fileTypes-nBt-Y6NI.js +56306 -0
  36. package/out/renderer/assets/flow9-CCdkJPNN.js +179 -0
  37. package/out/renderer/assets/freemarker2-CBlvIP9I.js +733 -0
  38. package/out/renderer/assets/fsharp-D5KoOpm3.js +248 -0
  39. package/out/renderer/assets/go-B7BFdMAL.js +264 -0
  40. package/out/renderer/assets/graphql-BqIezLde.js +177 -0
  41. package/out/renderer/assets/handlebars-CG4DAk5_.js +414 -0
  42. package/out/renderer/assets/hcl-C1GQCKC0.js +222 -0
  43. package/out/renderer/assets/html-C-_R4s2w.js +335 -0
  44. package/out/renderer/assets/html.worker-vQ8gO4kF.js +30584 -0
  45. package/out/renderer/assets/htmlMode-mGTQJ-lr.js +125 -0
  46. package/out/renderer/assets/index-CQHlaLTi.js +46080 -0
  47. package/out/renderer/assets/index-DBYJcRdn.css +3124 -0
  48. package/out/renderer/assets/ini-DDFxEGYN.js +97 -0
  49. package/out/renderer/assets/java-BqvgSBNj.js +272 -0
  50. package/out/renderer/assets/javascript-BuIet4p-.js +69 -0
  51. package/out/renderer/assets/json.worker-DBhrCMTN.js +23259 -0
  52. package/out/renderer/assets/jsonMode-OAArikPQ.js +769 -0
  53. package/out/renderer/assets/julia-D30HQT3I.js +688 -0
  54. package/out/renderer/assets/kotlin-Bql4-FwM.js +303 -0
  55. package/out/renderer/assets/less-D_rhcFqZ.js +245 -0
  56. package/out/renderer/assets/lexon-CjhVPeai.js +188 -0
  57. package/out/renderer/assets/liquid-DJNDWhYP.js +277 -0
  58. package/out/renderer/assets/lspLanguageFeatures-BIH0_3rO.css +24 -0
  59. package/out/renderer/assets/lspLanguageFeatures-Bvh4jxNk.js +2583 -0
  60. package/out/renderer/assets/lua-HQuy0vuU.js +203 -0
  61. package/out/renderer/assets/m3-CIJ7obE2.js +287 -0
  62. package/out/renderer/assets/markdown-I0GroHKS.js +265 -0
  63. package/out/renderer/assets/mdx-B4We-zdi.js +330 -0
  64. package/out/renderer/assets/mips-DY_Z1uin.js +190 -0
  65. package/out/renderer/assets/msdax-YkUW9rXl.js +416 -0
  66. package/out/renderer/assets/mysql-CIm9uV8f.js +921 -0
  67. package/out/renderer/assets/objective-c-JkhNEfNv.js +233 -0
  68. package/out/renderer/assets/pascal-Dvq-PxOC.js +289 -0
  69. package/out/renderer/assets/pascaligo-A9tZTvdV.js +204 -0
  70. package/out/renderer/assets/pdf_viewer-8SNFor7s.js +7639 -0
  71. package/out/renderer/assets/perl-C2Ujz2HB.js +720 -0
  72. package/out/renderer/assets/pgsql-BHB-cYm3.js +879 -0
  73. package/out/renderer/assets/php-DkNik5Vk.js +548 -0
  74. package/out/renderer/assets/pla-DQ-RrdDE.js +149 -0
  75. package/out/renderer/assets/postiats-f1cpw-r_.js +702 -0
  76. package/out/renderer/assets/powerquery-CwYp-rYn.js +940 -0
  77. package/out/renderer/assets/powershell-DNVb682q.js +252 -0
  78. package/out/renderer/assets/protobuf-C73bXEb8.js +663 -0
  79. package/out/renderer/assets/pug-BxvM69yY.js +419 -0
  80. package/out/renderer/assets/python-Hlw9kU7X.js +389 -0
  81. package/out/renderer/assets/qsharp-BCs2AvEL.js +335 -0
  82. package/out/renderer/assets/r-B7wnzr1V.js +282 -0
  83. package/out/renderer/assets/razor-BswxUzye.js +615 -0
  84. package/out/renderer/assets/redis-BQXcxMfX.js +324 -0
  85. package/out/renderer/assets/redshift-2dZdIUPH.js +838 -0
  86. package/out/renderer/assets/restructuredtext-CVT2zSWP.js +290 -0
  87. package/out/renderer/assets/ruby-DjmMI5Dp.js +612 -0
  88. package/out/renderer/assets/rust-BhSCZj0F.js +382 -0
  89. package/out/renderer/assets/sb-DaUIZery.js +146 -0
  90. package/out/renderer/assets/scala-CYIN7D7O.js +589 -0
  91. package/out/renderer/assets/scheme-DanUmhC2.js +173 -0
  92. package/out/renderer/assets/scss-BVILLTDt.js +420 -0
  93. package/out/renderer/assets/shell-Bpairu2a.js +293 -0
  94. package/out/renderer/assets/solidity-OLm4MSRm.js +1395 -0
  95. package/out/renderer/assets/sophia-DJz2Vk1M.js +234 -0
  96. package/out/renderer/assets/sparql-Bk5uRAQt.js +237 -0
  97. package/out/renderer/assets/sql-DQBN9zz5.js +858 -0
  98. package/out/renderer/assets/st-50mV4H0S.js +657 -0
  99. package/out/renderer/assets/swift-Yc0Q28XL.js +376 -0
  100. package/out/renderer/assets/systemverilog-Du7vdcmu.js +616 -0
  101. package/out/renderer/assets/tcl-DG7u3TBj.js +312 -0
  102. package/out/renderer/assets/toggleHighContrast-CKRp-vZ7.css +3691 -0
  103. package/out/renderer/assets/toggleHighContrast-NyS1pk1Z.js +51247 -0
  104. package/out/renderer/assets/twig-C49MsNA9.js +438 -0
  105. package/out/renderer/assets/typescript-F2yeVXIn.js +382 -0
  106. package/out/renderer/assets/typespec-DA1dz9gQ.js +245 -0
  107. package/out/renderer/assets/useAsync-Bi56CNnI.js +30 -0
  108. package/out/renderer/assets/vb-BDNIgfQk.js +447 -0
  109. package/out/renderer/assets/wgsl-j-0nJ_62.js +457 -0
  110. package/out/renderer/assets/xml-BfG5_Ah8.js +131 -0
  111. package/out/renderer/assets/yaml-7gp9FQUG.js +224 -0
  112. package/out/renderer/index.html +14 -0
  113. package/package.json +66 -4
  114. package/resources/skills/nubase-extension-authoring/SKILL.md +273 -0
  115. package/resources/templates/extension/package.json.template +13 -0
  116. package/resources/templates/extension/src/host.ts.template +12 -0
  117. package/resources/templates/extension/src/ui.tsx.template +26 -0
  118. package/resources/templates/extension/tsconfig.json.template +4 -0
  119. package/README.md +0 -3
@@ -0,0 +1,2583 @@
1
+ import { Ar as ViewGpuContext, Ec as getActiveWindow, Fd as localize2, Ks as ContextKeyExpr, Ku as URI$1, Lr as GlyphRasterizer, Pd as localize, Pl as VSBuffer, Rr as ensureNonNullable, Sn as IQuickInputService, Td as isIOS, _s as ILogService, a as Range$1, ac as IInstantiationService, as as EditorAction, c as languages, fs as registerEditorContribution, i as MarkerSeverity, md as Disposable, ns as IConfigurationService, o as Uri, s as editor, us as registerEditorAction, ut as IWorkspaceContextService, yc as addDisposableListener } from "./editor.api-zF37fz_e.js";
2
+ import { t as IFileService } from "./toggleHighContrast-NyS1pk1Z.js";
3
+ //#region node_modules/monaco-editor/esm/vs/editor/contrib/gpu/browser/gpuActions.js
4
+ var DebugEditorGpuRendererAction = class extends EditorAction {
5
+ constructor() {
6
+ super({
7
+ id: "editor.action.debugEditorGpuRenderer",
8
+ label: localize2(1159, "Developer: Debug Editor GPU Renderer"),
9
+ precondition: ContextKeyExpr.true()
10
+ });
11
+ }
12
+ async run(accessor, editor) {
13
+ const instantiationService = accessor.get(IInstantiationService);
14
+ const choice = await accessor.get(IQuickInputService).pick([
15
+ {
16
+ label: localize(1156, "Log Texture Atlas Stats"),
17
+ id: "logTextureAtlasStats"
18
+ },
19
+ {
20
+ label: localize(1157, "Save Texture Atlas"),
21
+ id: "saveTextureAtlas"
22
+ },
23
+ {
24
+ label: localize(1158, "Draw Glyph"),
25
+ id: "drawGlyph"
26
+ }
27
+ ], { canPickMany: false });
28
+ if (!choice) return;
29
+ switch (choice.id) {
30
+ case "logTextureAtlasStats":
31
+ instantiationService.invokeFunction((accessor) => {
32
+ const logService = accessor.get(ILogService);
33
+ const atlas = ViewGpuContext.atlas;
34
+ if (!ViewGpuContext.atlas) {
35
+ logService.error("No texture atlas found");
36
+ return;
37
+ }
38
+ const stats = atlas.getStats();
39
+ logService.info(["Texture atlas stats", ...stats].join("\n\n"));
40
+ });
41
+ break;
42
+ case "saveTextureAtlas":
43
+ instantiationService.invokeFunction(async (accessor) => {
44
+ const workspaceContextService = accessor.get(IWorkspaceContextService);
45
+ const fileService = accessor.get(IFileService);
46
+ const folders = workspaceContextService.getWorkspace().folders;
47
+ if (folders.length > 0) {
48
+ const atlas = ViewGpuContext.atlas;
49
+ const promises = [];
50
+ for (const [layerIndex, page] of atlas.pages.entries()) promises.push(...[fileService.writeFile(URI$1.joinPath(folders[0].uri, `textureAtlasPage${layerIndex}_actual.png`), VSBuffer.wrap(new Uint8Array(await (await page.source.convertToBlob()).arrayBuffer()))), fileService.writeFile(URI$1.joinPath(folders[0].uri, `textureAtlasPage${layerIndex}_usage.png`), VSBuffer.wrap(new Uint8Array(await (await page.getUsagePreview()).arrayBuffer())))]);
51
+ await Promise.all(promises);
52
+ }
53
+ });
54
+ break;
55
+ case "drawGlyph":
56
+ instantiationService.invokeFunction(async (accessor) => {
57
+ const configurationService = accessor.get(IConfigurationService);
58
+ const fileService = accessor.get(IFileService);
59
+ const quickInputService = accessor.get(IQuickInputService);
60
+ const folders = accessor.get(IWorkspaceContextService).getWorkspace().folders;
61
+ if (folders.length === 0) return;
62
+ const atlas = ViewGpuContext.atlas;
63
+ const fontFamily = configurationService.getValue("editor.fontFamily");
64
+ const fontSize = configurationService.getValue("editor.fontSize");
65
+ const rasterizer = new GlyphRasterizer(fontSize, fontFamily, getActiveWindow().devicePixelRatio, ViewGpuContext.decorationStyleCache);
66
+ let chars = await quickInputService.input({ prompt: "Enter a character to draw (prefix with 0x for code point))" });
67
+ if (!chars) return;
68
+ const codePoint = chars.match(/0x(?<codePoint>[0-9a-f]+)/i)?.groups?.codePoint;
69
+ if (codePoint !== void 0) chars = String.fromCodePoint(parseInt(codePoint, 16));
70
+ const tokenMetadata = 0;
71
+ const rasterizedGlyph = atlas.getGlyph(rasterizer, chars, tokenMetadata, 0, 0);
72
+ if (!rasterizedGlyph) return;
73
+ const imageData = atlas.pages[rasterizedGlyph.pageIndex].source.getContext("2d")?.getImageData(rasterizedGlyph.x, rasterizedGlyph.y, rasterizedGlyph.w, rasterizedGlyph.h);
74
+ if (!imageData) return;
75
+ const canvas = new OffscreenCanvas(imageData.width, imageData.height);
76
+ ensureNonNullable(canvas.getContext("2d")).putImageData(imageData, 0, 0);
77
+ const blob = await canvas.convertToBlob({ type: "image/png" });
78
+ const resource = URI$1.joinPath(folders[0].uri, `glyph_${chars}_${tokenMetadata}_${fontSize}px_${fontFamily.replaceAll(/[,\\\/\.'\s]/g, "_")}.png`);
79
+ await fileService.writeFile(resource, VSBuffer.wrap(new Uint8Array(await blob.arrayBuffer())));
80
+ });
81
+ break;
82
+ }
83
+ }
84
+ };
85
+ registerEditorAction(DebugEditorGpuRendererAction);
86
+ //#endregion
87
+ //#region node_modules/monaco-editor/esm/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.js
88
+ var IPadShowKeyboard = class extends Disposable {
89
+ static {
90
+ this.ID = "editor.contrib.iPadShowKeyboard";
91
+ }
92
+ constructor(editor) {
93
+ super();
94
+ this.editor = editor;
95
+ this.widget = null;
96
+ if (isIOS) {
97
+ this._register(editor.onDidChangeConfiguration(() => this.update()));
98
+ this.update();
99
+ }
100
+ }
101
+ update() {
102
+ const shouldHaveWidget = !this.editor.getOption(104);
103
+ if (!this.widget && shouldHaveWidget) this.widget = new ShowKeyboardWidget(this.editor);
104
+ else if (this.widget && !shouldHaveWidget) {
105
+ this.widget.dispose();
106
+ this.widget = null;
107
+ }
108
+ }
109
+ dispose() {
110
+ super.dispose();
111
+ if (this.widget) {
112
+ this.widget.dispose();
113
+ this.widget = null;
114
+ }
115
+ }
116
+ };
117
+ var ShowKeyboardWidget = class ShowKeyboardWidget extends Disposable {
118
+ static {
119
+ this.ID = "editor.contrib.ShowKeyboardWidget";
120
+ }
121
+ constructor(editor) {
122
+ super();
123
+ this.editor = editor;
124
+ this._domNode = document.createElement("textarea");
125
+ this._domNode.className = "iPadShowKeyboard";
126
+ this._register(addDisposableListener(this._domNode, "touchstart", (e) => {
127
+ this.editor.focus();
128
+ }));
129
+ this._register(addDisposableListener(this._domNode, "focus", (e) => {
130
+ this.editor.focus();
131
+ }));
132
+ this.editor.addOverlayWidget(this);
133
+ }
134
+ dispose() {
135
+ this.editor.removeOverlayWidget(this);
136
+ super.dispose();
137
+ }
138
+ getId() {
139
+ return ShowKeyboardWidget.ID;
140
+ }
141
+ getDomNode() {
142
+ return this._domNode;
143
+ }
144
+ getPosition() {
145
+ return { preference: 1 };
146
+ }
147
+ };
148
+ registerEditorContribution(IPadShowKeyboard.ID, IPadShowKeyboard, 3);
149
+ //#endregion
150
+ //#region node_modules/monaco-editor/esm/vs/internal/common/workers.js
151
+ function createTrustedTypesPolicy(policyName, policyOptions) {
152
+ const monacoEnvironment = globalThis.MonacoEnvironment;
153
+ if (monacoEnvironment?.createTrustedTypesPolicy) try {
154
+ return monacoEnvironment.createTrustedTypesPolicy(policyName, policyOptions);
155
+ } catch (err) {
156
+ console.error(err);
157
+ return;
158
+ }
159
+ try {
160
+ return globalThis.trustedTypes?.createPolicy(policyName, policyOptions);
161
+ } catch (err) {
162
+ console.error(err);
163
+ return;
164
+ }
165
+ }
166
+ var ttPolicy;
167
+ if (typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope" && globalThis.workerttPolicy !== void 0) ttPolicy = globalThis.workerttPolicy;
168
+ else ttPolicy = createTrustedTypesPolicy("defaultWorkerFactory", { createScriptURL: (value) => value });
169
+ function getWorker(descriptor) {
170
+ const label = descriptor.label;
171
+ const monacoEnvironment = globalThis.MonacoEnvironment;
172
+ if (monacoEnvironment) {
173
+ if (typeof monacoEnvironment.getWorker === "function") return monacoEnvironment.getWorker("workerMain.js", label);
174
+ if (typeof monacoEnvironment.getWorkerUrl === "function") {
175
+ const workerUrl = monacoEnvironment.getWorkerUrl("workerMain.js", label);
176
+ return new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) : workerUrl, {
177
+ name: label,
178
+ type: "module"
179
+ });
180
+ }
181
+ }
182
+ if (descriptor.createWorker) return descriptor.createWorker();
183
+ throw new Error(`You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker`);
184
+ }
185
+ function createWebWorker(opts) {
186
+ const worker = Promise.resolve(getWorker({
187
+ label: opts.label ?? "monaco-editor-worker",
188
+ moduleId: opts.moduleId,
189
+ createWorker: opts.createWorker
190
+ })).then((w) => {
191
+ w.postMessage("ignore");
192
+ w.postMessage(opts.createData);
193
+ return w;
194
+ });
195
+ return editor.createWebWorker({
196
+ worker,
197
+ host: opts.host,
198
+ keepIdleModels: opts.keepIdleModels
199
+ });
200
+ }
201
+ //#endregion
202
+ //#region node_modules/monaco-editor/esm/external/vscode-languageserver-types/lib/esm/main.js
203
+ var DocumentUri;
204
+ (function(DocumentUri) {
205
+ function is(value) {
206
+ return typeof value === "string";
207
+ }
208
+ DocumentUri.is = is;
209
+ })(DocumentUri || (DocumentUri = {}));
210
+ var URI;
211
+ (function(URI) {
212
+ function is(value) {
213
+ return typeof value === "string";
214
+ }
215
+ URI.is = is;
216
+ })(URI || (URI = {}));
217
+ var integer;
218
+ (function(integer) {
219
+ integer.MIN_VALUE = -2147483648;
220
+ integer.MAX_VALUE = 2147483647;
221
+ function is(value) {
222
+ return typeof value === "number" && integer.MIN_VALUE <= value && value <= integer.MAX_VALUE;
223
+ }
224
+ integer.is = is;
225
+ })(integer || (integer = {}));
226
+ var uinteger;
227
+ (function(uinteger) {
228
+ uinteger.MIN_VALUE = 0;
229
+ uinteger.MAX_VALUE = 2147483647;
230
+ function is(value) {
231
+ return typeof value === "number" && uinteger.MIN_VALUE <= value && value <= uinteger.MAX_VALUE;
232
+ }
233
+ uinteger.is = is;
234
+ })(uinteger || (uinteger = {}));
235
+ /**
236
+ * The Position namespace provides helper functions to work with
237
+ * {@link Position} literals.
238
+ */
239
+ var Position;
240
+ (function(Position) {
241
+ /**
242
+ * Creates a new Position literal from the given line and character.
243
+ * @param line The position's line.
244
+ * @param character The position's character.
245
+ */
246
+ function create(line, character) {
247
+ if (line === Number.MAX_VALUE) line = uinteger.MAX_VALUE;
248
+ if (character === Number.MAX_VALUE) character = uinteger.MAX_VALUE;
249
+ return {
250
+ line,
251
+ character
252
+ };
253
+ }
254
+ Position.create = create;
255
+ /**
256
+ * Checks whether the given literal conforms to the {@link Position} interface.
257
+ */
258
+ function is(value) {
259
+ let candidate = value;
260
+ return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
261
+ }
262
+ Position.is = is;
263
+ })(Position || (Position = {}));
264
+ /**
265
+ * The Range namespace provides helper functions to work with
266
+ * {@link Range} literals.
267
+ */
268
+ var Range;
269
+ (function(Range) {
270
+ function create(one, two, three, four) {
271
+ if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) return {
272
+ start: Position.create(one, two),
273
+ end: Position.create(three, four)
274
+ };
275
+ else if (Position.is(one) && Position.is(two)) return {
276
+ start: one,
277
+ end: two
278
+ };
279
+ else throw new Error(`Range#create called with invalid arguments[${one}, ${two}, ${three}, ${four}]`);
280
+ }
281
+ Range.create = create;
282
+ /**
283
+ * Checks whether the given literal conforms to the {@link Range} interface.
284
+ */
285
+ function is(value) {
286
+ let candidate = value;
287
+ return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
288
+ }
289
+ Range.is = is;
290
+ })(Range || (Range = {}));
291
+ /**
292
+ * The Location namespace provides helper functions to work with
293
+ * {@link Location} literals.
294
+ */
295
+ var Location;
296
+ (function(Location) {
297
+ /**
298
+ * Creates a Location literal.
299
+ * @param uri The location's uri.
300
+ * @param range The location's range.
301
+ */
302
+ function create(uri, range) {
303
+ return {
304
+ uri,
305
+ range
306
+ };
307
+ }
308
+ Location.create = create;
309
+ /**
310
+ * Checks whether the given literal conforms to the {@link Location} interface.
311
+ */
312
+ function is(value) {
313
+ let candidate = value;
314
+ return Is.objectLiteral(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
315
+ }
316
+ Location.is = is;
317
+ })(Location || (Location = {}));
318
+ /**
319
+ * The LocationLink namespace provides helper functions to work with
320
+ * {@link LocationLink} literals.
321
+ */
322
+ var LocationLink;
323
+ (function(LocationLink) {
324
+ /**
325
+ * Creates a LocationLink literal.
326
+ * @param targetUri The definition's uri.
327
+ * @param targetRange The full range of the definition.
328
+ * @param targetSelectionRange The span of the symbol definition at the target.
329
+ * @param originSelectionRange The span of the symbol being defined in the originating source file.
330
+ */
331
+ function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
332
+ return {
333
+ targetUri,
334
+ targetRange,
335
+ targetSelectionRange,
336
+ originSelectionRange
337
+ };
338
+ }
339
+ LocationLink.create = create;
340
+ /**
341
+ * Checks whether the given literal conforms to the {@link LocationLink} interface.
342
+ */
343
+ function is(value) {
344
+ let candidate = value;
345
+ return Is.objectLiteral(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range.is(candidate.targetSelectionRange) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
346
+ }
347
+ LocationLink.is = is;
348
+ })(LocationLink || (LocationLink = {}));
349
+ /**
350
+ * The Color namespace provides helper functions to work with
351
+ * {@link Color} literals.
352
+ */
353
+ var Color;
354
+ (function(Color) {
355
+ /**
356
+ * Creates a new Color literal.
357
+ */
358
+ function create(red, green, blue, alpha) {
359
+ return {
360
+ red,
361
+ green,
362
+ blue,
363
+ alpha
364
+ };
365
+ }
366
+ Color.create = create;
367
+ /**
368
+ * Checks whether the given literal conforms to the {@link Color} interface.
369
+ */
370
+ function is(value) {
371
+ const candidate = value;
372
+ return Is.objectLiteral(candidate) && Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
373
+ }
374
+ Color.is = is;
375
+ })(Color || (Color = {}));
376
+ /**
377
+ * The ColorInformation namespace provides helper functions to work with
378
+ * {@link ColorInformation} literals.
379
+ */
380
+ var ColorInformation;
381
+ (function(ColorInformation) {
382
+ /**
383
+ * Creates a new ColorInformation literal.
384
+ */
385
+ function create(range, color) {
386
+ return {
387
+ range,
388
+ color
389
+ };
390
+ }
391
+ ColorInformation.create = create;
392
+ /**
393
+ * Checks whether the given literal conforms to the {@link ColorInformation} interface.
394
+ */
395
+ function is(value) {
396
+ const candidate = value;
397
+ return Is.objectLiteral(candidate) && Range.is(candidate.range) && Color.is(candidate.color);
398
+ }
399
+ ColorInformation.is = is;
400
+ })(ColorInformation || (ColorInformation = {}));
401
+ /**
402
+ * The Color namespace provides helper functions to work with
403
+ * {@link ColorPresentation} literals.
404
+ */
405
+ var ColorPresentation;
406
+ (function(ColorPresentation) {
407
+ /**
408
+ * Creates a new ColorInformation literal.
409
+ */
410
+ function create(label, textEdit, additionalTextEdits) {
411
+ return {
412
+ label,
413
+ textEdit,
414
+ additionalTextEdits
415
+ };
416
+ }
417
+ ColorPresentation.create = create;
418
+ /**
419
+ * Checks whether the given literal conforms to the {@link ColorInformation} interface.
420
+ */
421
+ function is(value) {
422
+ const candidate = value;
423
+ return Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
424
+ }
425
+ ColorPresentation.is = is;
426
+ })(ColorPresentation || (ColorPresentation = {}));
427
+ /**
428
+ * A set of predefined range kinds.
429
+ */
430
+ var FoldingRangeKind;
431
+ (function(FoldingRangeKind) {
432
+ /**
433
+ * Folding range for a comment
434
+ */
435
+ FoldingRangeKind.Comment = "comment";
436
+ /**
437
+ * Folding range for an import or include
438
+ */
439
+ FoldingRangeKind.Imports = "imports";
440
+ /**
441
+ * Folding range for a region (e.g. `#region`)
442
+ */
443
+ FoldingRangeKind.Region = "region";
444
+ })(FoldingRangeKind || (FoldingRangeKind = {}));
445
+ /**
446
+ * The folding range namespace provides helper functions to work with
447
+ * {@link FoldingRange} literals.
448
+ */
449
+ var FoldingRange;
450
+ (function(FoldingRange) {
451
+ /**
452
+ * Creates a new FoldingRange literal.
453
+ */
454
+ function create(startLine, endLine, startCharacter, endCharacter, kind, collapsedText) {
455
+ const result = {
456
+ startLine,
457
+ endLine
458
+ };
459
+ if (Is.defined(startCharacter)) result.startCharacter = startCharacter;
460
+ if (Is.defined(endCharacter)) result.endCharacter = endCharacter;
461
+ if (Is.defined(kind)) result.kind = kind;
462
+ if (Is.defined(collapsedText)) result.collapsedText = collapsedText;
463
+ return result;
464
+ }
465
+ FoldingRange.create = create;
466
+ /**
467
+ * Checks whether the given literal conforms to the {@link FoldingRange} interface.
468
+ */
469
+ function is(value) {
470
+ const candidate = value;
471
+ return Is.objectLiteral(candidate) && Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine) && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter)) && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter)) && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
472
+ }
473
+ FoldingRange.is = is;
474
+ })(FoldingRange || (FoldingRange = {}));
475
+ /**
476
+ * The DiagnosticRelatedInformation namespace provides helper functions to work with
477
+ * {@link DiagnosticRelatedInformation} literals.
478
+ */
479
+ var DiagnosticRelatedInformation;
480
+ (function(DiagnosticRelatedInformation) {
481
+ /**
482
+ * Creates a new DiagnosticRelatedInformation literal.
483
+ */
484
+ function create(location, message) {
485
+ return {
486
+ location,
487
+ message
488
+ };
489
+ }
490
+ DiagnosticRelatedInformation.create = create;
491
+ /**
492
+ * Checks whether the given literal conforms to the {@link DiagnosticRelatedInformation} interface.
493
+ */
494
+ function is(value) {
495
+ let candidate = value;
496
+ return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
497
+ }
498
+ DiagnosticRelatedInformation.is = is;
499
+ })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
500
+ /**
501
+ * The diagnostic's severity.
502
+ */
503
+ var DiagnosticSeverity;
504
+ (function(DiagnosticSeverity) {
505
+ /**
506
+ * Reports an error.
507
+ */
508
+ DiagnosticSeverity.Error = 1;
509
+ /**
510
+ * Reports a warning.
511
+ */
512
+ DiagnosticSeverity.Warning = 2;
513
+ /**
514
+ * Reports an information.
515
+ */
516
+ DiagnosticSeverity.Information = 3;
517
+ /**
518
+ * Reports a hint.
519
+ */
520
+ DiagnosticSeverity.Hint = 4;
521
+ })(DiagnosticSeverity || (DiagnosticSeverity = {}));
522
+ /**
523
+ * The diagnostic tags.
524
+ *
525
+ * @since 3.15.0
526
+ */
527
+ var DiagnosticTag;
528
+ (function(DiagnosticTag) {
529
+ /**
530
+ * Unused or unnecessary code.
531
+ *
532
+ * Clients are allowed to render diagnostics with this tag faded out instead of having
533
+ * an error squiggle.
534
+ */
535
+ DiagnosticTag.Unnecessary = 1;
536
+ /**
537
+ * Deprecated or obsolete code.
538
+ *
539
+ * Clients are allowed to rendered diagnostics with this tag strike through.
540
+ */
541
+ DiagnosticTag.Deprecated = 2;
542
+ })(DiagnosticTag || (DiagnosticTag = {}));
543
+ /**
544
+ * The CodeDescription namespace provides functions to deal with descriptions for diagnostic codes.
545
+ *
546
+ * @since 3.16.0
547
+ */
548
+ var CodeDescription;
549
+ (function(CodeDescription) {
550
+ function is(value) {
551
+ const candidate = value;
552
+ return Is.objectLiteral(candidate) && Is.string(candidate.href);
553
+ }
554
+ CodeDescription.is = is;
555
+ })(CodeDescription || (CodeDescription = {}));
556
+ /**
557
+ * The Diagnostic namespace provides helper functions to work with
558
+ * {@link Diagnostic} literals.
559
+ */
560
+ var Diagnostic;
561
+ (function(Diagnostic) {
562
+ /**
563
+ * Creates a new Diagnostic literal.
564
+ */
565
+ function create(range, message, severity, code, source, relatedInformation) {
566
+ let result = {
567
+ range,
568
+ message
569
+ };
570
+ if (Is.defined(severity)) result.severity = severity;
571
+ if (Is.defined(code)) result.code = code;
572
+ if (Is.defined(source)) result.source = source;
573
+ if (Is.defined(relatedInformation)) result.relatedInformation = relatedInformation;
574
+ return result;
575
+ }
576
+ Diagnostic.create = create;
577
+ /**
578
+ * Checks whether the given literal conforms to the {@link Diagnostic} interface.
579
+ */
580
+ function is(value) {
581
+ var _a;
582
+ let candidate = value;
583
+ return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
584
+ }
585
+ Diagnostic.is = is;
586
+ })(Diagnostic || (Diagnostic = {}));
587
+ /**
588
+ * The Command namespace provides helper functions to work with
589
+ * {@link Command} literals.
590
+ */
591
+ var Command;
592
+ (function(Command) {
593
+ /**
594
+ * Creates a new Command literal.
595
+ */
596
+ function create(title, command, ...args) {
597
+ let result = {
598
+ title,
599
+ command
600
+ };
601
+ if (Is.defined(args) && args.length > 0) result.arguments = args;
602
+ return result;
603
+ }
604
+ Command.create = create;
605
+ /**
606
+ * Checks whether the given literal conforms to the {@link Command} interface.
607
+ */
608
+ function is(value) {
609
+ let candidate = value;
610
+ return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
611
+ }
612
+ Command.is = is;
613
+ })(Command || (Command = {}));
614
+ /**
615
+ * The TextEdit namespace provides helper function to create replace,
616
+ * insert and delete edits more easily.
617
+ */
618
+ var TextEdit;
619
+ (function(TextEdit) {
620
+ /**
621
+ * Creates a replace text edit.
622
+ * @param range The range of text to be replaced.
623
+ * @param newText The new text.
624
+ */
625
+ function replace(range, newText) {
626
+ return {
627
+ range,
628
+ newText
629
+ };
630
+ }
631
+ TextEdit.replace = replace;
632
+ /**
633
+ * Creates an insert text edit.
634
+ * @param position The position to insert the text at.
635
+ * @param newText The text to be inserted.
636
+ */
637
+ function insert(position, newText) {
638
+ return {
639
+ range: {
640
+ start: position,
641
+ end: position
642
+ },
643
+ newText
644
+ };
645
+ }
646
+ TextEdit.insert = insert;
647
+ /**
648
+ * Creates a delete text edit.
649
+ * @param range The range of text to be deleted.
650
+ */
651
+ function del(range) {
652
+ return {
653
+ range,
654
+ newText: ""
655
+ };
656
+ }
657
+ TextEdit.del = del;
658
+ function is(value) {
659
+ const candidate = value;
660
+ return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
661
+ }
662
+ TextEdit.is = is;
663
+ })(TextEdit || (TextEdit = {}));
664
+ var ChangeAnnotation;
665
+ (function(ChangeAnnotation) {
666
+ function create(label, needsConfirmation, description) {
667
+ const result = { label };
668
+ if (needsConfirmation !== void 0) result.needsConfirmation = needsConfirmation;
669
+ if (description !== void 0) result.description = description;
670
+ return result;
671
+ }
672
+ ChangeAnnotation.create = create;
673
+ function is(value) {
674
+ const candidate = value;
675
+ return Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
676
+ }
677
+ ChangeAnnotation.is = is;
678
+ })(ChangeAnnotation || (ChangeAnnotation = {}));
679
+ var ChangeAnnotationIdentifier;
680
+ (function(ChangeAnnotationIdentifier) {
681
+ function is(value) {
682
+ const candidate = value;
683
+ return Is.string(candidate);
684
+ }
685
+ ChangeAnnotationIdentifier.is = is;
686
+ })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
687
+ var AnnotatedTextEdit;
688
+ (function(AnnotatedTextEdit) {
689
+ /**
690
+ * Creates an annotated replace text edit.
691
+ *
692
+ * @param range The range of text to be replaced.
693
+ * @param newText The new text.
694
+ * @param annotation The annotation.
695
+ */
696
+ function replace(range, newText, annotation) {
697
+ return {
698
+ range,
699
+ newText,
700
+ annotationId: annotation
701
+ };
702
+ }
703
+ AnnotatedTextEdit.replace = replace;
704
+ /**
705
+ * Creates an annotated insert text edit.
706
+ *
707
+ * @param position The position to insert the text at.
708
+ * @param newText The text to be inserted.
709
+ * @param annotation The annotation.
710
+ */
711
+ function insert(position, newText, annotation) {
712
+ return {
713
+ range: {
714
+ start: position,
715
+ end: position
716
+ },
717
+ newText,
718
+ annotationId: annotation
719
+ };
720
+ }
721
+ AnnotatedTextEdit.insert = insert;
722
+ /**
723
+ * Creates an annotated delete text edit.
724
+ *
725
+ * @param range The range of text to be deleted.
726
+ * @param annotation The annotation.
727
+ */
728
+ function del(range, annotation) {
729
+ return {
730
+ range,
731
+ newText: "",
732
+ annotationId: annotation
733
+ };
734
+ }
735
+ AnnotatedTextEdit.del = del;
736
+ function is(value) {
737
+ const candidate = value;
738
+ return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
739
+ }
740
+ AnnotatedTextEdit.is = is;
741
+ })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
742
+ /**
743
+ * The TextDocumentEdit namespace provides helper function to create
744
+ * an edit that manipulates a text document.
745
+ */
746
+ var TextDocumentEdit;
747
+ (function(TextDocumentEdit) {
748
+ /**
749
+ * Creates a new `TextDocumentEdit`
750
+ */
751
+ function create(textDocument, edits) {
752
+ return {
753
+ textDocument,
754
+ edits
755
+ };
756
+ }
757
+ TextDocumentEdit.create = create;
758
+ function is(value) {
759
+ let candidate = value;
760
+ return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
761
+ }
762
+ TextDocumentEdit.is = is;
763
+ })(TextDocumentEdit || (TextDocumentEdit = {}));
764
+ var CreateFile;
765
+ (function(CreateFile) {
766
+ function create(uri, options, annotation) {
767
+ let result = {
768
+ kind: "create",
769
+ uri
770
+ };
771
+ if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) result.options = options;
772
+ if (annotation !== void 0) result.annotationId = annotation;
773
+ return result;
774
+ }
775
+ CreateFile.create = create;
776
+ function is(value) {
777
+ let candidate = value;
778
+ return candidate && candidate.kind === "create" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
779
+ }
780
+ CreateFile.is = is;
781
+ })(CreateFile || (CreateFile = {}));
782
+ var RenameFile;
783
+ (function(RenameFile) {
784
+ function create(oldUri, newUri, options, annotation) {
785
+ let result = {
786
+ kind: "rename",
787
+ oldUri,
788
+ newUri
789
+ };
790
+ if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) result.options = options;
791
+ if (annotation !== void 0) result.annotationId = annotation;
792
+ return result;
793
+ }
794
+ RenameFile.create = create;
795
+ function is(value) {
796
+ let candidate = value;
797
+ return candidate && candidate.kind === "rename" && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
798
+ }
799
+ RenameFile.is = is;
800
+ })(RenameFile || (RenameFile = {}));
801
+ var DeleteFile;
802
+ (function(DeleteFile) {
803
+ function create(uri, options, annotation) {
804
+ let result = {
805
+ kind: "delete",
806
+ uri
807
+ };
808
+ if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) result.options = options;
809
+ if (annotation !== void 0) result.annotationId = annotation;
810
+ return result;
811
+ }
812
+ DeleteFile.create = create;
813
+ function is(value) {
814
+ let candidate = value;
815
+ return candidate && candidate.kind === "delete" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
816
+ }
817
+ DeleteFile.is = is;
818
+ })(DeleteFile || (DeleteFile = {}));
819
+ var WorkspaceEdit;
820
+ (function(WorkspaceEdit) {
821
+ function is(value) {
822
+ let candidate = value;
823
+ return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every((change) => {
824
+ if (Is.string(change.kind)) return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
825
+ else return TextDocumentEdit.is(change);
826
+ }));
827
+ }
828
+ WorkspaceEdit.is = is;
829
+ })(WorkspaceEdit || (WorkspaceEdit = {}));
830
+ /**
831
+ * The TextDocumentIdentifier namespace provides helper functions to work with
832
+ * {@link TextDocumentIdentifier} literals.
833
+ */
834
+ var TextDocumentIdentifier;
835
+ (function(TextDocumentIdentifier) {
836
+ /**
837
+ * Creates a new TextDocumentIdentifier literal.
838
+ * @param uri The document's uri.
839
+ */
840
+ function create(uri) {
841
+ return { uri };
842
+ }
843
+ TextDocumentIdentifier.create = create;
844
+ /**
845
+ * Checks whether the given literal conforms to the {@link TextDocumentIdentifier} interface.
846
+ */
847
+ function is(value) {
848
+ let candidate = value;
849
+ return Is.defined(candidate) && Is.string(candidate.uri);
850
+ }
851
+ TextDocumentIdentifier.is = is;
852
+ })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
853
+ /**
854
+ * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
855
+ * {@link VersionedTextDocumentIdentifier} literals.
856
+ */
857
+ var VersionedTextDocumentIdentifier;
858
+ (function(VersionedTextDocumentIdentifier) {
859
+ /**
860
+ * Creates a new VersionedTextDocumentIdentifier literal.
861
+ * @param uri The document's uri.
862
+ * @param version The document's version.
863
+ */
864
+ function create(uri, version) {
865
+ return {
866
+ uri,
867
+ version
868
+ };
869
+ }
870
+ VersionedTextDocumentIdentifier.create = create;
871
+ /**
872
+ * Checks whether the given literal conforms to the {@link VersionedTextDocumentIdentifier} interface.
873
+ */
874
+ function is(value) {
875
+ let candidate = value;
876
+ return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
877
+ }
878
+ VersionedTextDocumentIdentifier.is = is;
879
+ })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
880
+ /**
881
+ * The OptionalVersionedTextDocumentIdentifier namespace provides helper functions to work with
882
+ * {@link OptionalVersionedTextDocumentIdentifier} literals.
883
+ */
884
+ var OptionalVersionedTextDocumentIdentifier;
885
+ (function(OptionalVersionedTextDocumentIdentifier) {
886
+ /**
887
+ * Creates a new OptionalVersionedTextDocumentIdentifier literal.
888
+ * @param uri The document's uri.
889
+ * @param version The document's version.
890
+ */
891
+ function create(uri, version) {
892
+ return {
893
+ uri,
894
+ version
895
+ };
896
+ }
897
+ OptionalVersionedTextDocumentIdentifier.create = create;
898
+ /**
899
+ * Checks whether the given literal conforms to the {@link OptionalVersionedTextDocumentIdentifier} interface.
900
+ */
901
+ function is(value) {
902
+ let candidate = value;
903
+ return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
904
+ }
905
+ OptionalVersionedTextDocumentIdentifier.is = is;
906
+ })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
907
+ /**
908
+ * The TextDocumentItem namespace provides helper functions to work with
909
+ * {@link TextDocumentItem} literals.
910
+ */
911
+ var TextDocumentItem;
912
+ (function(TextDocumentItem) {
913
+ /**
914
+ * Creates a new TextDocumentItem literal.
915
+ * @param uri The document's uri.
916
+ * @param languageId The document's language identifier.
917
+ * @param version The document's version number.
918
+ * @param text The document's text.
919
+ */
920
+ function create(uri, languageId, version, text) {
921
+ return {
922
+ uri,
923
+ languageId,
924
+ version,
925
+ text
926
+ };
927
+ }
928
+ TextDocumentItem.create = create;
929
+ /**
930
+ * Checks whether the given literal conforms to the {@link TextDocumentItem} interface.
931
+ */
932
+ function is(value) {
933
+ let candidate = value;
934
+ return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
935
+ }
936
+ TextDocumentItem.is = is;
937
+ })(TextDocumentItem || (TextDocumentItem = {}));
938
+ /**
939
+ * Describes the content type that a client supports in various
940
+ * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
941
+ *
942
+ * Please note that `MarkupKinds` must not start with a `$`. This kinds
943
+ * are reserved for internal usage.
944
+ */
945
+ var MarkupKind;
946
+ (function(MarkupKind) {
947
+ /**
948
+ * Plain text is supported as a content format
949
+ */
950
+ MarkupKind.PlainText = "plaintext";
951
+ /**
952
+ * Markdown is supported as a content format
953
+ */
954
+ MarkupKind.Markdown = "markdown";
955
+ /**
956
+ * Checks whether the given value is a value of the {@link MarkupKind} type.
957
+ */
958
+ function is(value) {
959
+ const candidate = value;
960
+ return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
961
+ }
962
+ MarkupKind.is = is;
963
+ })(MarkupKind || (MarkupKind = {}));
964
+ var MarkupContent;
965
+ (function(MarkupContent) {
966
+ /**
967
+ * Checks whether the given value conforms to the {@link MarkupContent} interface.
968
+ */
969
+ function is(value) {
970
+ const candidate = value;
971
+ return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
972
+ }
973
+ MarkupContent.is = is;
974
+ })(MarkupContent || (MarkupContent = {}));
975
+ /**
976
+ * The kind of a completion entry.
977
+ */
978
+ var CompletionItemKind;
979
+ (function(CompletionItemKind) {
980
+ CompletionItemKind.Text = 1;
981
+ CompletionItemKind.Method = 2;
982
+ CompletionItemKind.Function = 3;
983
+ CompletionItemKind.Constructor = 4;
984
+ CompletionItemKind.Field = 5;
985
+ CompletionItemKind.Variable = 6;
986
+ CompletionItemKind.Class = 7;
987
+ CompletionItemKind.Interface = 8;
988
+ CompletionItemKind.Module = 9;
989
+ CompletionItemKind.Property = 10;
990
+ CompletionItemKind.Unit = 11;
991
+ CompletionItemKind.Value = 12;
992
+ CompletionItemKind.Enum = 13;
993
+ CompletionItemKind.Keyword = 14;
994
+ CompletionItemKind.Snippet = 15;
995
+ CompletionItemKind.Color = 16;
996
+ CompletionItemKind.File = 17;
997
+ CompletionItemKind.Reference = 18;
998
+ CompletionItemKind.Folder = 19;
999
+ CompletionItemKind.EnumMember = 20;
1000
+ CompletionItemKind.Constant = 21;
1001
+ CompletionItemKind.Struct = 22;
1002
+ CompletionItemKind.Event = 23;
1003
+ CompletionItemKind.Operator = 24;
1004
+ CompletionItemKind.TypeParameter = 25;
1005
+ })(CompletionItemKind || (CompletionItemKind = {}));
1006
+ /**
1007
+ * Defines whether the insert text in a completion item should be interpreted as
1008
+ * plain text or a snippet.
1009
+ */
1010
+ var InsertTextFormat;
1011
+ (function(InsertTextFormat) {
1012
+ /**
1013
+ * The primary text to be inserted is treated as a plain string.
1014
+ */
1015
+ InsertTextFormat.PlainText = 1;
1016
+ /**
1017
+ * The primary text to be inserted is treated as a snippet.
1018
+ *
1019
+ * A snippet can define tab stops and placeholders with `$1`, `$2`
1020
+ * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
1021
+ * the end of the snippet. Placeholders with equal identifiers are linked,
1022
+ * that is typing in one will update others too.
1023
+ *
1024
+ * See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax
1025
+ */
1026
+ InsertTextFormat.Snippet = 2;
1027
+ })(InsertTextFormat || (InsertTextFormat = {}));
1028
+ /**
1029
+ * Completion item tags are extra annotations that tweak the rendering of a completion
1030
+ * item.
1031
+ *
1032
+ * @since 3.15.0
1033
+ */
1034
+ var CompletionItemTag;
1035
+ (function(CompletionItemTag) {
1036
+ /**
1037
+ * Render a completion as obsolete, usually using a strike-out.
1038
+ */
1039
+ CompletionItemTag.Deprecated = 1;
1040
+ })(CompletionItemTag || (CompletionItemTag = {}));
1041
+ /**
1042
+ * The InsertReplaceEdit namespace provides functions to deal with insert / replace edits.
1043
+ *
1044
+ * @since 3.16.0
1045
+ */
1046
+ var InsertReplaceEdit;
1047
+ (function(InsertReplaceEdit) {
1048
+ /**
1049
+ * Creates a new insert / replace edit
1050
+ */
1051
+ function create(newText, insert, replace) {
1052
+ return {
1053
+ newText,
1054
+ insert,
1055
+ replace
1056
+ };
1057
+ }
1058
+ InsertReplaceEdit.create = create;
1059
+ /**
1060
+ * Checks whether the given literal conforms to the {@link InsertReplaceEdit} interface.
1061
+ */
1062
+ function is(value) {
1063
+ const candidate = value;
1064
+ return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
1065
+ }
1066
+ InsertReplaceEdit.is = is;
1067
+ })(InsertReplaceEdit || (InsertReplaceEdit = {}));
1068
+ /**
1069
+ * How whitespace and indentation is handled during completion
1070
+ * item insertion.
1071
+ *
1072
+ * @since 3.16.0
1073
+ */
1074
+ var InsertTextMode;
1075
+ (function(InsertTextMode) {
1076
+ /**
1077
+ * The insertion or replace strings is taken as it is. If the
1078
+ * value is multi line the lines below the cursor will be
1079
+ * inserted using the indentation defined in the string value.
1080
+ * The client will not apply any kind of adjustments to the
1081
+ * string.
1082
+ */
1083
+ InsertTextMode.asIs = 1;
1084
+ /**
1085
+ * The editor adjusts leading whitespace of new lines so that
1086
+ * they match the indentation up to the cursor of the line for
1087
+ * which the item is accepted.
1088
+ *
1089
+ * Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
1090
+ * multi line completion item is indented using 2 tabs and all
1091
+ * following lines inserted will be indented using 2 tabs as well.
1092
+ */
1093
+ InsertTextMode.adjustIndentation = 2;
1094
+ })(InsertTextMode || (InsertTextMode = {}));
1095
+ var CompletionItemLabelDetails;
1096
+ (function(CompletionItemLabelDetails) {
1097
+ function is(value) {
1098
+ const candidate = value;
1099
+ return candidate && (Is.string(candidate.detail) || candidate.detail === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
1100
+ }
1101
+ CompletionItemLabelDetails.is = is;
1102
+ })(CompletionItemLabelDetails || (CompletionItemLabelDetails = {}));
1103
+ /**
1104
+ * The CompletionItem namespace provides functions to deal with
1105
+ * completion items.
1106
+ */
1107
+ var CompletionItem;
1108
+ (function(CompletionItem) {
1109
+ /**
1110
+ * Create a completion item and seed it with a label.
1111
+ * @param label The completion item's label
1112
+ */
1113
+ function create(label) {
1114
+ return { label };
1115
+ }
1116
+ CompletionItem.create = create;
1117
+ })(CompletionItem || (CompletionItem = {}));
1118
+ /**
1119
+ * The CompletionList namespace provides functions to deal with
1120
+ * completion lists.
1121
+ */
1122
+ var CompletionList;
1123
+ (function(CompletionList) {
1124
+ /**
1125
+ * Creates a new completion list.
1126
+ *
1127
+ * @param items The completion items.
1128
+ * @param isIncomplete The list is not complete.
1129
+ */
1130
+ function create(items, isIncomplete) {
1131
+ return {
1132
+ items: items ? items : [],
1133
+ isIncomplete: !!isIncomplete
1134
+ };
1135
+ }
1136
+ CompletionList.create = create;
1137
+ })(CompletionList || (CompletionList = {}));
1138
+ var MarkedString;
1139
+ (function(MarkedString) {
1140
+ /**
1141
+ * Creates a marked string from plain text.
1142
+ *
1143
+ * @param plainText The plain text.
1144
+ */
1145
+ function fromPlainText(plainText) {
1146
+ return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
1147
+ }
1148
+ MarkedString.fromPlainText = fromPlainText;
1149
+ /**
1150
+ * Checks whether the given value conforms to the {@link MarkedString} type.
1151
+ */
1152
+ function is(value) {
1153
+ const candidate = value;
1154
+ return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
1155
+ }
1156
+ MarkedString.is = is;
1157
+ })(MarkedString || (MarkedString = {}));
1158
+ var Hover;
1159
+ (function(Hover) {
1160
+ /**
1161
+ * Checks whether the given value conforms to the {@link Hover} interface.
1162
+ */
1163
+ function is(value) {
1164
+ let candidate = value;
1165
+ return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
1166
+ }
1167
+ Hover.is = is;
1168
+ })(Hover || (Hover = {}));
1169
+ /**
1170
+ * The ParameterInformation namespace provides helper functions to work with
1171
+ * {@link ParameterInformation} literals.
1172
+ */
1173
+ var ParameterInformation;
1174
+ (function(ParameterInformation) {
1175
+ /**
1176
+ * Creates a new parameter information literal.
1177
+ *
1178
+ * @param label A label string.
1179
+ * @param documentation A doc string.
1180
+ */
1181
+ function create(label, documentation) {
1182
+ return documentation ? {
1183
+ label,
1184
+ documentation
1185
+ } : { label };
1186
+ }
1187
+ ParameterInformation.create = create;
1188
+ })(ParameterInformation || (ParameterInformation = {}));
1189
+ /**
1190
+ * The SignatureInformation namespace provides helper functions to work with
1191
+ * {@link SignatureInformation} literals.
1192
+ */
1193
+ var SignatureInformation;
1194
+ (function(SignatureInformation) {
1195
+ function create(label, documentation, ...parameters) {
1196
+ let result = { label };
1197
+ if (Is.defined(documentation)) result.documentation = documentation;
1198
+ if (Is.defined(parameters)) result.parameters = parameters;
1199
+ else result.parameters = [];
1200
+ return result;
1201
+ }
1202
+ SignatureInformation.create = create;
1203
+ })(SignatureInformation || (SignatureInformation = {}));
1204
+ /**
1205
+ * A document highlight kind.
1206
+ */
1207
+ var DocumentHighlightKind;
1208
+ (function(DocumentHighlightKind) {
1209
+ /**
1210
+ * A textual occurrence.
1211
+ */
1212
+ DocumentHighlightKind.Text = 1;
1213
+ /**
1214
+ * Read-access of a symbol, like reading a variable.
1215
+ */
1216
+ DocumentHighlightKind.Read = 2;
1217
+ /**
1218
+ * Write-access of a symbol, like writing to a variable.
1219
+ */
1220
+ DocumentHighlightKind.Write = 3;
1221
+ })(DocumentHighlightKind || (DocumentHighlightKind = {}));
1222
+ /**
1223
+ * DocumentHighlight namespace to provide helper functions to work with
1224
+ * {@link DocumentHighlight} literals.
1225
+ */
1226
+ var DocumentHighlight;
1227
+ (function(DocumentHighlight) {
1228
+ /**
1229
+ * Create a DocumentHighlight object.
1230
+ * @param range The range the highlight applies to.
1231
+ * @param kind The highlight kind
1232
+ */
1233
+ function create(range, kind) {
1234
+ let result = { range };
1235
+ if (Is.number(kind)) result.kind = kind;
1236
+ return result;
1237
+ }
1238
+ DocumentHighlight.create = create;
1239
+ })(DocumentHighlight || (DocumentHighlight = {}));
1240
+ /**
1241
+ * A symbol kind.
1242
+ */
1243
+ var SymbolKind;
1244
+ (function(SymbolKind) {
1245
+ SymbolKind.File = 1;
1246
+ SymbolKind.Module = 2;
1247
+ SymbolKind.Namespace = 3;
1248
+ SymbolKind.Package = 4;
1249
+ SymbolKind.Class = 5;
1250
+ SymbolKind.Method = 6;
1251
+ SymbolKind.Property = 7;
1252
+ SymbolKind.Field = 8;
1253
+ SymbolKind.Constructor = 9;
1254
+ SymbolKind.Enum = 10;
1255
+ SymbolKind.Interface = 11;
1256
+ SymbolKind.Function = 12;
1257
+ SymbolKind.Variable = 13;
1258
+ SymbolKind.Constant = 14;
1259
+ SymbolKind.String = 15;
1260
+ SymbolKind.Number = 16;
1261
+ SymbolKind.Boolean = 17;
1262
+ SymbolKind.Array = 18;
1263
+ SymbolKind.Object = 19;
1264
+ SymbolKind.Key = 20;
1265
+ SymbolKind.Null = 21;
1266
+ SymbolKind.EnumMember = 22;
1267
+ SymbolKind.Struct = 23;
1268
+ SymbolKind.Event = 24;
1269
+ SymbolKind.Operator = 25;
1270
+ SymbolKind.TypeParameter = 26;
1271
+ })(SymbolKind || (SymbolKind = {}));
1272
+ /**
1273
+ * Symbol tags are extra annotations that tweak the rendering of a symbol.
1274
+ *
1275
+ * @since 3.16
1276
+ */
1277
+ var SymbolTag;
1278
+ (function(SymbolTag) {
1279
+ /**
1280
+ * Render a symbol as obsolete, usually using a strike-out.
1281
+ */
1282
+ SymbolTag.Deprecated = 1;
1283
+ })(SymbolTag || (SymbolTag = {}));
1284
+ var SymbolInformation;
1285
+ (function(SymbolInformation) {
1286
+ /**
1287
+ * Creates a new symbol information literal.
1288
+ *
1289
+ * @param name The name of the symbol.
1290
+ * @param kind The kind of the symbol.
1291
+ * @param range The range of the location of the symbol.
1292
+ * @param uri The resource of the location of symbol.
1293
+ * @param containerName The name of the symbol containing the symbol.
1294
+ */
1295
+ function create(name, kind, range, uri, containerName) {
1296
+ let result = {
1297
+ name,
1298
+ kind,
1299
+ location: {
1300
+ uri,
1301
+ range
1302
+ }
1303
+ };
1304
+ if (containerName) result.containerName = containerName;
1305
+ return result;
1306
+ }
1307
+ SymbolInformation.create = create;
1308
+ })(SymbolInformation || (SymbolInformation = {}));
1309
+ var WorkspaceSymbol;
1310
+ (function(WorkspaceSymbol) {
1311
+ /**
1312
+ * Create a new workspace symbol.
1313
+ *
1314
+ * @param name The name of the symbol.
1315
+ * @param kind The kind of the symbol.
1316
+ * @param uri The resource of the location of the symbol.
1317
+ * @param range An options range of the location.
1318
+ * @returns A WorkspaceSymbol.
1319
+ */
1320
+ function create(name, kind, uri, range) {
1321
+ return range !== void 0 ? {
1322
+ name,
1323
+ kind,
1324
+ location: {
1325
+ uri,
1326
+ range
1327
+ }
1328
+ } : {
1329
+ name,
1330
+ kind,
1331
+ location: { uri }
1332
+ };
1333
+ }
1334
+ WorkspaceSymbol.create = create;
1335
+ })(WorkspaceSymbol || (WorkspaceSymbol = {}));
1336
+ var DocumentSymbol;
1337
+ (function(DocumentSymbol) {
1338
+ /**
1339
+ * Creates a new symbol information literal.
1340
+ *
1341
+ * @param name The name of the symbol.
1342
+ * @param detail The detail of the symbol.
1343
+ * @param kind The kind of the symbol.
1344
+ * @param range The range of the symbol.
1345
+ * @param selectionRange The selectionRange of the symbol.
1346
+ * @param children Children of the symbol.
1347
+ */
1348
+ function create(name, detail, kind, range, selectionRange, children) {
1349
+ let result = {
1350
+ name,
1351
+ detail,
1352
+ kind,
1353
+ range,
1354
+ selectionRange
1355
+ };
1356
+ if (children !== void 0) result.children = children;
1357
+ return result;
1358
+ }
1359
+ DocumentSymbol.create = create;
1360
+ /**
1361
+ * Checks whether the given literal conforms to the {@link DocumentSymbol} interface.
1362
+ */
1363
+ function is(value) {
1364
+ let candidate = value;
1365
+ return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
1366
+ }
1367
+ DocumentSymbol.is = is;
1368
+ })(DocumentSymbol || (DocumentSymbol = {}));
1369
+ /**
1370
+ * A set of predefined code action kinds
1371
+ */
1372
+ var CodeActionKind;
1373
+ (function(CodeActionKind) {
1374
+ /**
1375
+ * Empty kind.
1376
+ */
1377
+ CodeActionKind.Empty = "";
1378
+ /**
1379
+ * Base kind for quickfix actions: 'quickfix'
1380
+ */
1381
+ CodeActionKind.QuickFix = "quickfix";
1382
+ /**
1383
+ * Base kind for refactoring actions: 'refactor'
1384
+ */
1385
+ CodeActionKind.Refactor = "refactor";
1386
+ /**
1387
+ * Base kind for refactoring extraction actions: 'refactor.extract'
1388
+ *
1389
+ * Example extract actions:
1390
+ *
1391
+ * - Extract method
1392
+ * - Extract function
1393
+ * - Extract variable
1394
+ * - Extract interface from class
1395
+ * - ...
1396
+ */
1397
+ CodeActionKind.RefactorExtract = "refactor.extract";
1398
+ /**
1399
+ * Base kind for refactoring inline actions: 'refactor.inline'
1400
+ *
1401
+ * Example inline actions:
1402
+ *
1403
+ * - Inline function
1404
+ * - Inline variable
1405
+ * - Inline constant
1406
+ * - ...
1407
+ */
1408
+ CodeActionKind.RefactorInline = "refactor.inline";
1409
+ /**
1410
+ * Base kind for refactoring rewrite actions: 'refactor.rewrite'
1411
+ *
1412
+ * Example rewrite actions:
1413
+ *
1414
+ * - Convert JavaScript function to class
1415
+ * - Add or remove parameter
1416
+ * - Encapsulate field
1417
+ * - Make method static
1418
+ * - Move method to base class
1419
+ * - ...
1420
+ */
1421
+ CodeActionKind.RefactorRewrite = "refactor.rewrite";
1422
+ /**
1423
+ * Base kind for source actions: `source`
1424
+ *
1425
+ * Source code actions apply to the entire file.
1426
+ */
1427
+ CodeActionKind.Source = "source";
1428
+ /**
1429
+ * Base kind for an organize imports source action: `source.organizeImports`
1430
+ */
1431
+ CodeActionKind.SourceOrganizeImports = "source.organizeImports";
1432
+ /**
1433
+ * Base kind for auto-fix source actions: `source.fixAll`.
1434
+ *
1435
+ * Fix all actions automatically fix errors that have a clear fix that do not require user input.
1436
+ * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
1437
+ *
1438
+ * @since 3.15.0
1439
+ */
1440
+ CodeActionKind.SourceFixAll = "source.fixAll";
1441
+ })(CodeActionKind || (CodeActionKind = {}));
1442
+ /**
1443
+ * The reason why code actions were requested.
1444
+ *
1445
+ * @since 3.17.0
1446
+ */
1447
+ var CodeActionTriggerKind;
1448
+ (function(CodeActionTriggerKind) {
1449
+ /**
1450
+ * Code actions were explicitly requested by the user or by an extension.
1451
+ */
1452
+ CodeActionTriggerKind.Invoked = 1;
1453
+ /**
1454
+ * Code actions were requested automatically.
1455
+ *
1456
+ * This typically happens when current selection in a file changes, but can
1457
+ * also be triggered when file content changes.
1458
+ */
1459
+ CodeActionTriggerKind.Automatic = 2;
1460
+ })(CodeActionTriggerKind || (CodeActionTriggerKind = {}));
1461
+ /**
1462
+ * The CodeActionContext namespace provides helper functions to work with
1463
+ * {@link CodeActionContext} literals.
1464
+ */
1465
+ var CodeActionContext;
1466
+ (function(CodeActionContext) {
1467
+ /**
1468
+ * Creates a new CodeActionContext literal.
1469
+ */
1470
+ function create(diagnostics, only, triggerKind) {
1471
+ let result = { diagnostics };
1472
+ if (only !== void 0 && only !== null) result.only = only;
1473
+ if (triggerKind !== void 0 && triggerKind !== null) result.triggerKind = triggerKind;
1474
+ return result;
1475
+ }
1476
+ CodeActionContext.create = create;
1477
+ /**
1478
+ * Checks whether the given literal conforms to the {@link CodeActionContext} interface.
1479
+ */
1480
+ function is(value) {
1481
+ let candidate = value;
1482
+ return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string)) && (candidate.triggerKind === void 0 || candidate.triggerKind === CodeActionTriggerKind.Invoked || candidate.triggerKind === CodeActionTriggerKind.Automatic);
1483
+ }
1484
+ CodeActionContext.is = is;
1485
+ })(CodeActionContext || (CodeActionContext = {}));
1486
+ var CodeAction;
1487
+ (function(CodeAction) {
1488
+ function create(title, kindOrCommandOrEdit, kind) {
1489
+ let result = { title };
1490
+ let checkKind = true;
1491
+ if (typeof kindOrCommandOrEdit === "string") {
1492
+ checkKind = false;
1493
+ result.kind = kindOrCommandOrEdit;
1494
+ } else if (Command.is(kindOrCommandOrEdit)) result.command = kindOrCommandOrEdit;
1495
+ else result.edit = kindOrCommandOrEdit;
1496
+ if (checkKind && kind !== void 0) result.kind = kind;
1497
+ return result;
1498
+ }
1499
+ CodeAction.create = create;
1500
+ function is(value) {
1501
+ let candidate = value;
1502
+ return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
1503
+ }
1504
+ CodeAction.is = is;
1505
+ })(CodeAction || (CodeAction = {}));
1506
+ /**
1507
+ * The CodeLens namespace provides helper functions to work with
1508
+ * {@link CodeLens} literals.
1509
+ */
1510
+ var CodeLens;
1511
+ (function(CodeLens) {
1512
+ /**
1513
+ * Creates a new CodeLens literal.
1514
+ */
1515
+ function create(range, data) {
1516
+ let result = { range };
1517
+ if (Is.defined(data)) result.data = data;
1518
+ return result;
1519
+ }
1520
+ CodeLens.create = create;
1521
+ /**
1522
+ * Checks whether the given literal conforms to the {@link CodeLens} interface.
1523
+ */
1524
+ function is(value) {
1525
+ let candidate = value;
1526
+ return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
1527
+ }
1528
+ CodeLens.is = is;
1529
+ })(CodeLens || (CodeLens = {}));
1530
+ /**
1531
+ * The FormattingOptions namespace provides helper functions to work with
1532
+ * {@link FormattingOptions} literals.
1533
+ */
1534
+ var FormattingOptions;
1535
+ (function(FormattingOptions) {
1536
+ /**
1537
+ * Creates a new FormattingOptions literal.
1538
+ */
1539
+ function create(tabSize, insertSpaces) {
1540
+ return {
1541
+ tabSize,
1542
+ insertSpaces
1543
+ };
1544
+ }
1545
+ FormattingOptions.create = create;
1546
+ /**
1547
+ * Checks whether the given literal conforms to the {@link FormattingOptions} interface.
1548
+ */
1549
+ function is(value) {
1550
+ let candidate = value;
1551
+ return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
1552
+ }
1553
+ FormattingOptions.is = is;
1554
+ })(FormattingOptions || (FormattingOptions = {}));
1555
+ /**
1556
+ * The DocumentLink namespace provides helper functions to work with
1557
+ * {@link DocumentLink} literals.
1558
+ */
1559
+ var DocumentLink;
1560
+ (function(DocumentLink) {
1561
+ /**
1562
+ * Creates a new DocumentLink literal.
1563
+ */
1564
+ function create(range, target, data) {
1565
+ return {
1566
+ range,
1567
+ target,
1568
+ data
1569
+ };
1570
+ }
1571
+ DocumentLink.create = create;
1572
+ /**
1573
+ * Checks whether the given literal conforms to the {@link DocumentLink} interface.
1574
+ */
1575
+ function is(value) {
1576
+ let candidate = value;
1577
+ return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
1578
+ }
1579
+ DocumentLink.is = is;
1580
+ })(DocumentLink || (DocumentLink = {}));
1581
+ /**
1582
+ * The SelectionRange namespace provides helper function to work with
1583
+ * SelectionRange literals.
1584
+ */
1585
+ var SelectionRange;
1586
+ (function(SelectionRange) {
1587
+ /**
1588
+ * Creates a new SelectionRange
1589
+ * @param range the range.
1590
+ * @param parent an optional parent.
1591
+ */
1592
+ function create(range, parent) {
1593
+ return {
1594
+ range,
1595
+ parent
1596
+ };
1597
+ }
1598
+ SelectionRange.create = create;
1599
+ function is(value) {
1600
+ let candidate = value;
1601
+ return Is.objectLiteral(candidate) && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange.is(candidate.parent));
1602
+ }
1603
+ SelectionRange.is = is;
1604
+ })(SelectionRange || (SelectionRange = {}));
1605
+ /**
1606
+ * A set of predefined token types. This set is not fixed
1607
+ * an clients can specify additional token types via the
1608
+ * corresponding client capabilities.
1609
+ *
1610
+ * @since 3.16.0
1611
+ */
1612
+ var SemanticTokenTypes;
1613
+ (function(SemanticTokenTypes) {
1614
+ SemanticTokenTypes["namespace"] = "namespace";
1615
+ /**
1616
+ * Represents a generic type. Acts as a fallback for types which can't be mapped to
1617
+ * a specific type like class or enum.
1618
+ */
1619
+ SemanticTokenTypes["type"] = "type";
1620
+ SemanticTokenTypes["class"] = "class";
1621
+ SemanticTokenTypes["enum"] = "enum";
1622
+ SemanticTokenTypes["interface"] = "interface";
1623
+ SemanticTokenTypes["struct"] = "struct";
1624
+ SemanticTokenTypes["typeParameter"] = "typeParameter";
1625
+ SemanticTokenTypes["parameter"] = "parameter";
1626
+ SemanticTokenTypes["variable"] = "variable";
1627
+ SemanticTokenTypes["property"] = "property";
1628
+ SemanticTokenTypes["enumMember"] = "enumMember";
1629
+ SemanticTokenTypes["event"] = "event";
1630
+ SemanticTokenTypes["function"] = "function";
1631
+ SemanticTokenTypes["method"] = "method";
1632
+ SemanticTokenTypes["macro"] = "macro";
1633
+ SemanticTokenTypes["keyword"] = "keyword";
1634
+ SemanticTokenTypes["modifier"] = "modifier";
1635
+ SemanticTokenTypes["comment"] = "comment";
1636
+ SemanticTokenTypes["string"] = "string";
1637
+ SemanticTokenTypes["number"] = "number";
1638
+ SemanticTokenTypes["regexp"] = "regexp";
1639
+ SemanticTokenTypes["operator"] = "operator";
1640
+ /**
1641
+ * @since 3.17.0
1642
+ */
1643
+ SemanticTokenTypes["decorator"] = "decorator";
1644
+ })(SemanticTokenTypes || (SemanticTokenTypes = {}));
1645
+ /**
1646
+ * A set of predefined token modifiers. This set is not fixed
1647
+ * an clients can specify additional token types via the
1648
+ * corresponding client capabilities.
1649
+ *
1650
+ * @since 3.16.0
1651
+ */
1652
+ var SemanticTokenModifiers;
1653
+ (function(SemanticTokenModifiers) {
1654
+ SemanticTokenModifiers["declaration"] = "declaration";
1655
+ SemanticTokenModifiers["definition"] = "definition";
1656
+ SemanticTokenModifiers["readonly"] = "readonly";
1657
+ SemanticTokenModifiers["static"] = "static";
1658
+ SemanticTokenModifiers["deprecated"] = "deprecated";
1659
+ SemanticTokenModifiers["abstract"] = "abstract";
1660
+ SemanticTokenModifiers["async"] = "async";
1661
+ SemanticTokenModifiers["modification"] = "modification";
1662
+ SemanticTokenModifiers["documentation"] = "documentation";
1663
+ SemanticTokenModifiers["defaultLibrary"] = "defaultLibrary";
1664
+ })(SemanticTokenModifiers || (SemanticTokenModifiers = {}));
1665
+ /**
1666
+ * @since 3.16.0
1667
+ */
1668
+ var SemanticTokens;
1669
+ (function(SemanticTokens) {
1670
+ function is(value) {
1671
+ const candidate = value;
1672
+ return Is.objectLiteral(candidate) && (candidate.resultId === void 0 || typeof candidate.resultId === "string") && Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === "number");
1673
+ }
1674
+ SemanticTokens.is = is;
1675
+ })(SemanticTokens || (SemanticTokens = {}));
1676
+ /**
1677
+ * The InlineValueText namespace provides functions to deal with InlineValueTexts.
1678
+ *
1679
+ * @since 3.17.0
1680
+ */
1681
+ var InlineValueText;
1682
+ (function(InlineValueText) {
1683
+ /**
1684
+ * Creates a new InlineValueText literal.
1685
+ */
1686
+ function create(range, text) {
1687
+ return {
1688
+ range,
1689
+ text
1690
+ };
1691
+ }
1692
+ InlineValueText.create = create;
1693
+ function is(value) {
1694
+ const candidate = value;
1695
+ return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && Is.string(candidate.text);
1696
+ }
1697
+ InlineValueText.is = is;
1698
+ })(InlineValueText || (InlineValueText = {}));
1699
+ /**
1700
+ * The InlineValueVariableLookup namespace provides functions to deal with InlineValueVariableLookups.
1701
+ *
1702
+ * @since 3.17.0
1703
+ */
1704
+ var InlineValueVariableLookup;
1705
+ (function(InlineValueVariableLookup) {
1706
+ /**
1707
+ * Creates a new InlineValueText literal.
1708
+ */
1709
+ function create(range, variableName, caseSensitiveLookup) {
1710
+ return {
1711
+ range,
1712
+ variableName,
1713
+ caseSensitiveLookup
1714
+ };
1715
+ }
1716
+ InlineValueVariableLookup.create = create;
1717
+ function is(value) {
1718
+ const candidate = value;
1719
+ return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
1720
+ }
1721
+ InlineValueVariableLookup.is = is;
1722
+ })(InlineValueVariableLookup || (InlineValueVariableLookup = {}));
1723
+ /**
1724
+ * The InlineValueEvaluatableExpression namespace provides functions to deal with InlineValueEvaluatableExpression.
1725
+ *
1726
+ * @since 3.17.0
1727
+ */
1728
+ var InlineValueEvaluatableExpression;
1729
+ (function(InlineValueEvaluatableExpression) {
1730
+ /**
1731
+ * Creates a new InlineValueEvaluatableExpression literal.
1732
+ */
1733
+ function create(range, expression) {
1734
+ return {
1735
+ range,
1736
+ expression
1737
+ };
1738
+ }
1739
+ InlineValueEvaluatableExpression.create = create;
1740
+ function is(value) {
1741
+ const candidate = value;
1742
+ return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
1743
+ }
1744
+ InlineValueEvaluatableExpression.is = is;
1745
+ })(InlineValueEvaluatableExpression || (InlineValueEvaluatableExpression = {}));
1746
+ /**
1747
+ * The InlineValueContext namespace provides helper functions to work with
1748
+ * {@link InlineValueContext} literals.
1749
+ *
1750
+ * @since 3.17.0
1751
+ */
1752
+ var InlineValueContext;
1753
+ (function(InlineValueContext) {
1754
+ /**
1755
+ * Creates a new InlineValueContext literal.
1756
+ */
1757
+ function create(frameId, stoppedLocation) {
1758
+ return {
1759
+ frameId,
1760
+ stoppedLocation
1761
+ };
1762
+ }
1763
+ InlineValueContext.create = create;
1764
+ /**
1765
+ * Checks whether the given literal conforms to the {@link InlineValueContext} interface.
1766
+ */
1767
+ function is(value) {
1768
+ const candidate = value;
1769
+ return Is.defined(candidate) && Range.is(value.stoppedLocation);
1770
+ }
1771
+ InlineValueContext.is = is;
1772
+ })(InlineValueContext || (InlineValueContext = {}));
1773
+ /**
1774
+ * Inlay hint kinds.
1775
+ *
1776
+ * @since 3.17.0
1777
+ */
1778
+ var InlayHintKind;
1779
+ (function(InlayHintKind) {
1780
+ /**
1781
+ * An inlay hint that for a type annotation.
1782
+ */
1783
+ InlayHintKind.Type = 1;
1784
+ /**
1785
+ * An inlay hint that is for a parameter.
1786
+ */
1787
+ InlayHintKind.Parameter = 2;
1788
+ function is(value) {
1789
+ return value === 1 || value === 2;
1790
+ }
1791
+ InlayHintKind.is = is;
1792
+ })(InlayHintKind || (InlayHintKind = {}));
1793
+ var InlayHintLabelPart;
1794
+ (function(InlayHintLabelPart) {
1795
+ function create(value) {
1796
+ return { value };
1797
+ }
1798
+ InlayHintLabelPart.create = create;
1799
+ function is(value) {
1800
+ const candidate = value;
1801
+ return Is.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.location === void 0 || Location.is(candidate.location)) && (candidate.command === void 0 || Command.is(candidate.command));
1802
+ }
1803
+ InlayHintLabelPart.is = is;
1804
+ })(InlayHintLabelPart || (InlayHintLabelPart = {}));
1805
+ var InlayHint;
1806
+ (function(InlayHint) {
1807
+ function create(position, label, kind) {
1808
+ const result = {
1809
+ position,
1810
+ label
1811
+ };
1812
+ if (kind !== void 0) result.kind = kind;
1813
+ return result;
1814
+ }
1815
+ InlayHint.create = create;
1816
+ function is(value) {
1817
+ const candidate = value;
1818
+ return Is.objectLiteral(candidate) && Position.is(candidate.position) && (Is.string(candidate.label) || Is.typedArray(candidate.label, InlayHintLabelPart.is)) && (candidate.kind === void 0 || InlayHintKind.is(candidate.kind)) && candidate.textEdits === void 0 || Is.typedArray(candidate.textEdits, TextEdit.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
1819
+ }
1820
+ InlayHint.is = is;
1821
+ })(InlayHint || (InlayHint = {}));
1822
+ var StringValue;
1823
+ (function(StringValue) {
1824
+ function createSnippet(value) {
1825
+ return {
1826
+ kind: "snippet",
1827
+ value
1828
+ };
1829
+ }
1830
+ StringValue.createSnippet = createSnippet;
1831
+ })(StringValue || (StringValue = {}));
1832
+ var InlineCompletionItem;
1833
+ (function(InlineCompletionItem) {
1834
+ function create(insertText, filterText, range, command) {
1835
+ return {
1836
+ insertText,
1837
+ filterText,
1838
+ range,
1839
+ command
1840
+ };
1841
+ }
1842
+ InlineCompletionItem.create = create;
1843
+ })(InlineCompletionItem || (InlineCompletionItem = {}));
1844
+ var InlineCompletionList;
1845
+ (function(InlineCompletionList) {
1846
+ function create(items) {
1847
+ return { items };
1848
+ }
1849
+ InlineCompletionList.create = create;
1850
+ })(InlineCompletionList || (InlineCompletionList = {}));
1851
+ /**
1852
+ * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.
1853
+ *
1854
+ * @since 3.18.0
1855
+ * @proposed
1856
+ */
1857
+ var InlineCompletionTriggerKind;
1858
+ (function(InlineCompletionTriggerKind) {
1859
+ /**
1860
+ * Completion was triggered explicitly by a user gesture.
1861
+ */
1862
+ InlineCompletionTriggerKind.Invoked = 0;
1863
+ /**
1864
+ * Completion was triggered automatically while editing.
1865
+ */
1866
+ InlineCompletionTriggerKind.Automatic = 1;
1867
+ })(InlineCompletionTriggerKind || (InlineCompletionTriggerKind = {}));
1868
+ var SelectedCompletionInfo;
1869
+ (function(SelectedCompletionInfo) {
1870
+ function create(range, text) {
1871
+ return {
1872
+ range,
1873
+ text
1874
+ };
1875
+ }
1876
+ SelectedCompletionInfo.create = create;
1877
+ })(SelectedCompletionInfo || (SelectedCompletionInfo = {}));
1878
+ var InlineCompletionContext;
1879
+ (function(InlineCompletionContext) {
1880
+ function create(triggerKind, selectedCompletionInfo) {
1881
+ return {
1882
+ triggerKind,
1883
+ selectedCompletionInfo
1884
+ };
1885
+ }
1886
+ InlineCompletionContext.create = create;
1887
+ })(InlineCompletionContext || (InlineCompletionContext = {}));
1888
+ var WorkspaceFolder;
1889
+ (function(WorkspaceFolder) {
1890
+ function is(value) {
1891
+ const candidate = value;
1892
+ return Is.objectLiteral(candidate) && URI.is(candidate.uri) && Is.string(candidate.name);
1893
+ }
1894
+ WorkspaceFolder.is = is;
1895
+ })(WorkspaceFolder || (WorkspaceFolder = {}));
1896
+ /**
1897
+ * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
1898
+ */
1899
+ var TextDocument;
1900
+ (function(TextDocument) {
1901
+ /**
1902
+ * Creates a new ITextDocument literal from the given uri and content.
1903
+ * @param uri The document's uri.
1904
+ * @param languageId The document's language Id.
1905
+ * @param version The document's version.
1906
+ * @param content The document's content.
1907
+ */
1908
+ function create(uri, languageId, version, content) {
1909
+ return new FullTextDocument(uri, languageId, version, content);
1910
+ }
1911
+ TextDocument.create = create;
1912
+ /**
1913
+ * Checks whether the given literal conforms to the {@link ITextDocument} interface.
1914
+ */
1915
+ function is(value) {
1916
+ let candidate = value;
1917
+ return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount) && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
1918
+ }
1919
+ TextDocument.is = is;
1920
+ function applyEdits(document, edits) {
1921
+ let text = document.getText();
1922
+ let sortedEdits = mergeSort(edits, (a, b) => {
1923
+ let diff = a.range.start.line - b.range.start.line;
1924
+ if (diff === 0) return a.range.start.character - b.range.start.character;
1925
+ return diff;
1926
+ });
1927
+ let lastModifiedOffset = text.length;
1928
+ for (let i = sortedEdits.length - 1; i >= 0; i--) {
1929
+ let e = sortedEdits[i];
1930
+ let startOffset = document.offsetAt(e.range.start);
1931
+ let endOffset = document.offsetAt(e.range.end);
1932
+ if (endOffset <= lastModifiedOffset) text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
1933
+ else throw new Error("Overlapping edit");
1934
+ lastModifiedOffset = startOffset;
1935
+ }
1936
+ return text;
1937
+ }
1938
+ TextDocument.applyEdits = applyEdits;
1939
+ function mergeSort(data, compare) {
1940
+ if (data.length <= 1) return data;
1941
+ const p = data.length / 2 | 0;
1942
+ const left = data.slice(0, p);
1943
+ const right = data.slice(p);
1944
+ mergeSort(left, compare);
1945
+ mergeSort(right, compare);
1946
+ let leftIdx = 0;
1947
+ let rightIdx = 0;
1948
+ let i = 0;
1949
+ while (leftIdx < left.length && rightIdx < right.length) if (compare(left[leftIdx], right[rightIdx]) <= 0) data[i++] = left[leftIdx++];
1950
+ else data[i++] = right[rightIdx++];
1951
+ while (leftIdx < left.length) data[i++] = left[leftIdx++];
1952
+ while (rightIdx < right.length) data[i++] = right[rightIdx++];
1953
+ return data;
1954
+ }
1955
+ })(TextDocument || (TextDocument = {}));
1956
+ /**
1957
+ * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
1958
+ */
1959
+ var FullTextDocument = class {
1960
+ constructor(uri, languageId, version, content) {
1961
+ this._uri = uri;
1962
+ this._languageId = languageId;
1963
+ this._version = version;
1964
+ this._content = content;
1965
+ this._lineOffsets = void 0;
1966
+ }
1967
+ get uri() {
1968
+ return this._uri;
1969
+ }
1970
+ get languageId() {
1971
+ return this._languageId;
1972
+ }
1973
+ get version() {
1974
+ return this._version;
1975
+ }
1976
+ getText(range) {
1977
+ if (range) {
1978
+ let start = this.offsetAt(range.start);
1979
+ let end = this.offsetAt(range.end);
1980
+ return this._content.substring(start, end);
1981
+ }
1982
+ return this._content;
1983
+ }
1984
+ update(event, version) {
1985
+ this._content = event.text;
1986
+ this._version = version;
1987
+ this._lineOffsets = void 0;
1988
+ }
1989
+ getLineOffsets() {
1990
+ if (this._lineOffsets === void 0) {
1991
+ let lineOffsets = [];
1992
+ let text = this._content;
1993
+ let isLineStart = true;
1994
+ for (let i = 0; i < text.length; i++) {
1995
+ if (isLineStart) {
1996
+ lineOffsets.push(i);
1997
+ isLineStart = false;
1998
+ }
1999
+ let ch = text.charAt(i);
2000
+ isLineStart = ch === "\r" || ch === "\n";
2001
+ if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") i++;
2002
+ }
2003
+ if (isLineStart && text.length > 0) lineOffsets.push(text.length);
2004
+ this._lineOffsets = lineOffsets;
2005
+ }
2006
+ return this._lineOffsets;
2007
+ }
2008
+ positionAt(offset) {
2009
+ offset = Math.max(Math.min(offset, this._content.length), 0);
2010
+ let lineOffsets = this.getLineOffsets();
2011
+ let low = 0, high = lineOffsets.length;
2012
+ if (high === 0) return Position.create(0, offset);
2013
+ while (low < high) {
2014
+ let mid = Math.floor((low + high) / 2);
2015
+ if (lineOffsets[mid] > offset) high = mid;
2016
+ else low = mid + 1;
2017
+ }
2018
+ let line = low - 1;
2019
+ return Position.create(line, offset - lineOffsets[line]);
2020
+ }
2021
+ offsetAt(position) {
2022
+ let lineOffsets = this.getLineOffsets();
2023
+ if (position.line >= lineOffsets.length) return this._content.length;
2024
+ else if (position.line < 0) return 0;
2025
+ let lineOffset = lineOffsets[position.line];
2026
+ let nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
2027
+ return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
2028
+ }
2029
+ get lineCount() {
2030
+ return this.getLineOffsets().length;
2031
+ }
2032
+ };
2033
+ var Is;
2034
+ (function(Is) {
2035
+ const toString = Object.prototype.toString;
2036
+ function defined(value) {
2037
+ return typeof value !== "undefined";
2038
+ }
2039
+ Is.defined = defined;
2040
+ function undefined$1(value) {
2041
+ return typeof value === "undefined";
2042
+ }
2043
+ Is.undefined = undefined$1;
2044
+ function boolean(value) {
2045
+ return value === true || value === false;
2046
+ }
2047
+ Is.boolean = boolean;
2048
+ function string(value) {
2049
+ return toString.call(value) === "[object String]";
2050
+ }
2051
+ Is.string = string;
2052
+ function number(value) {
2053
+ return toString.call(value) === "[object Number]";
2054
+ }
2055
+ Is.number = number;
2056
+ function numberRange(value, min, max) {
2057
+ return toString.call(value) === "[object Number]" && min <= value && value <= max;
2058
+ }
2059
+ Is.numberRange = numberRange;
2060
+ function integer(value) {
2061
+ return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
2062
+ }
2063
+ Is.integer = integer;
2064
+ function uinteger(value) {
2065
+ return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
2066
+ }
2067
+ Is.uinteger = uinteger;
2068
+ function func(value) {
2069
+ return toString.call(value) === "[object Function]";
2070
+ }
2071
+ Is.func = func;
2072
+ function objectLiteral(value) {
2073
+ return value !== null && typeof value === "object";
2074
+ }
2075
+ Is.objectLiteral = objectLiteral;
2076
+ function typedArray(value, check) {
2077
+ return Array.isArray(value) && value.every(check);
2078
+ }
2079
+ Is.typedArray = typedArray;
2080
+ })(Is || (Is = {}));
2081
+ //#endregion
2082
+ //#region node_modules/monaco-editor/esm/vs/languages/features/common/lspLanguageFeatures.js
2083
+ var DiagnosticsAdapter = class {
2084
+ constructor(_languageId, _worker, configChangeEvent) {
2085
+ this._languageId = _languageId;
2086
+ this._worker = _worker;
2087
+ this._disposables = [];
2088
+ this._listener = /* @__PURE__ */ Object.create(null);
2089
+ const onModelAdd = (model) => {
2090
+ let modeId = model.getLanguageId();
2091
+ if (modeId !== this._languageId) return;
2092
+ let handle;
2093
+ this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
2094
+ window.clearTimeout(handle);
2095
+ handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
2096
+ });
2097
+ this._doValidate(model.uri, modeId);
2098
+ };
2099
+ const onModelRemoved = (model) => {
2100
+ editor.setModelMarkers(model, this._languageId, []);
2101
+ let uriStr = model.uri.toString();
2102
+ let listener = this._listener[uriStr];
2103
+ if (listener) {
2104
+ listener.dispose();
2105
+ delete this._listener[uriStr];
2106
+ }
2107
+ };
2108
+ this._disposables.push(editor.onDidCreateModel(onModelAdd));
2109
+ this._disposables.push(editor.onWillDisposeModel(onModelRemoved));
2110
+ this._disposables.push(editor.onDidChangeModelLanguage((event) => {
2111
+ onModelRemoved(event.model);
2112
+ onModelAdd(event.model);
2113
+ }));
2114
+ this._disposables.push(configChangeEvent((_) => {
2115
+ editor.getModels().forEach((model) => {
2116
+ if (model.getLanguageId() === this._languageId) {
2117
+ onModelRemoved(model);
2118
+ onModelAdd(model);
2119
+ }
2120
+ });
2121
+ }));
2122
+ this._disposables.push({ dispose: () => {
2123
+ editor.getModels().forEach(onModelRemoved);
2124
+ for (let key in this._listener) this._listener[key].dispose();
2125
+ } });
2126
+ editor.getModels().forEach(onModelAdd);
2127
+ }
2128
+ dispose() {
2129
+ this._disposables.forEach((d) => d && d.dispose());
2130
+ this._disposables.length = 0;
2131
+ }
2132
+ _doValidate(resource, languageId) {
2133
+ this._worker(resource).then((worker) => {
2134
+ return worker.doValidation(resource.toString());
2135
+ }).then((diagnostics) => {
2136
+ const markers = diagnostics.map((d) => toDiagnostics(resource, d));
2137
+ let model = editor.getModel(resource);
2138
+ if (model && model.getLanguageId() === languageId) editor.setModelMarkers(model, languageId, markers);
2139
+ }).then(void 0, (err) => {
2140
+ console.error(err);
2141
+ });
2142
+ }
2143
+ };
2144
+ function toSeverity(lsSeverity) {
2145
+ switch (lsSeverity) {
2146
+ case DiagnosticSeverity.Error: return MarkerSeverity.Error;
2147
+ case DiagnosticSeverity.Warning: return MarkerSeverity.Warning;
2148
+ case DiagnosticSeverity.Information: return MarkerSeverity.Info;
2149
+ case DiagnosticSeverity.Hint: return MarkerSeverity.Hint;
2150
+ default: return MarkerSeverity.Info;
2151
+ }
2152
+ }
2153
+ function toDiagnostics(resource, diag) {
2154
+ let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
2155
+ return {
2156
+ severity: toSeverity(diag.severity),
2157
+ startLineNumber: diag.range.start.line + 1,
2158
+ startColumn: diag.range.start.character + 1,
2159
+ endLineNumber: diag.range.end.line + 1,
2160
+ endColumn: diag.range.end.character + 1,
2161
+ message: diag.message,
2162
+ code,
2163
+ source: diag.source
2164
+ };
2165
+ }
2166
+ var CompletionAdapter = class {
2167
+ constructor(_worker, _triggerCharacters) {
2168
+ this._worker = _worker;
2169
+ this._triggerCharacters = _triggerCharacters;
2170
+ }
2171
+ get triggerCharacters() {
2172
+ return this._triggerCharacters;
2173
+ }
2174
+ provideCompletionItems(model, position, context, token) {
2175
+ const resource = model.uri;
2176
+ return this._worker(resource).then((worker) => {
2177
+ return worker.doComplete(resource.toString(), fromPosition(position));
2178
+ }).then((info) => {
2179
+ if (!info) return;
2180
+ const wordInfo = model.getWordUntilPosition(position);
2181
+ const wordRange = new Range$1(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
2182
+ const items = info.items.map((entry) => {
2183
+ const item = {
2184
+ label: entry.label,
2185
+ insertText: entry.insertText || entry.label,
2186
+ sortText: entry.sortText,
2187
+ filterText: entry.filterText,
2188
+ documentation: entry.documentation,
2189
+ detail: entry.detail,
2190
+ command: toCommand(entry.command),
2191
+ range: wordRange,
2192
+ kind: toCompletionItemKind(entry.kind)
2193
+ };
2194
+ if (entry.textEdit) {
2195
+ if (isInsertReplaceEdit(entry.textEdit)) item.range = {
2196
+ insert: toRange(entry.textEdit.insert),
2197
+ replace: toRange(entry.textEdit.replace)
2198
+ };
2199
+ else item.range = toRange(entry.textEdit.range);
2200
+ item.insertText = entry.textEdit.newText;
2201
+ }
2202
+ if (entry.additionalTextEdits) item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
2203
+ if (entry.insertTextFormat === InsertTextFormat.Snippet) item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
2204
+ return item;
2205
+ });
2206
+ return {
2207
+ isIncomplete: info.isIncomplete,
2208
+ suggestions: items
2209
+ };
2210
+ });
2211
+ }
2212
+ };
2213
+ function fromPosition(position) {
2214
+ if (!position) return;
2215
+ return {
2216
+ character: position.column - 1,
2217
+ line: position.lineNumber - 1
2218
+ };
2219
+ }
2220
+ function fromRange(range) {
2221
+ if (!range) return;
2222
+ return {
2223
+ start: {
2224
+ line: range.startLineNumber - 1,
2225
+ character: range.startColumn - 1
2226
+ },
2227
+ end: {
2228
+ line: range.endLineNumber - 1,
2229
+ character: range.endColumn - 1
2230
+ }
2231
+ };
2232
+ }
2233
+ function toRange(range) {
2234
+ if (!range) return;
2235
+ return new Range$1(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
2236
+ }
2237
+ function isInsertReplaceEdit(edit) {
2238
+ return typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined";
2239
+ }
2240
+ function toCompletionItemKind(kind) {
2241
+ const mItemKind = languages.CompletionItemKind;
2242
+ switch (kind) {
2243
+ case CompletionItemKind.Text: return mItemKind.Text;
2244
+ case CompletionItemKind.Method: return mItemKind.Method;
2245
+ case CompletionItemKind.Function: return mItemKind.Function;
2246
+ case CompletionItemKind.Constructor: return mItemKind.Constructor;
2247
+ case CompletionItemKind.Field: return mItemKind.Field;
2248
+ case CompletionItemKind.Variable: return mItemKind.Variable;
2249
+ case CompletionItemKind.Class: return mItemKind.Class;
2250
+ case CompletionItemKind.Interface: return mItemKind.Interface;
2251
+ case CompletionItemKind.Module: return mItemKind.Module;
2252
+ case CompletionItemKind.Property: return mItemKind.Property;
2253
+ case CompletionItemKind.Unit: return mItemKind.Unit;
2254
+ case CompletionItemKind.Value: return mItemKind.Value;
2255
+ case CompletionItemKind.Enum: return mItemKind.Enum;
2256
+ case CompletionItemKind.Keyword: return mItemKind.Keyword;
2257
+ case CompletionItemKind.Snippet: return mItemKind.Snippet;
2258
+ case CompletionItemKind.Color: return mItemKind.Color;
2259
+ case CompletionItemKind.File: return mItemKind.File;
2260
+ case CompletionItemKind.Reference: return mItemKind.Reference;
2261
+ }
2262
+ return mItemKind.Property;
2263
+ }
2264
+ function toTextEdit(textEdit) {
2265
+ if (!textEdit) return;
2266
+ return {
2267
+ range: toRange(textEdit.range),
2268
+ text: textEdit.newText
2269
+ };
2270
+ }
2271
+ function toCommand(c) {
2272
+ return c && c.command === "editor.action.triggerSuggest" ? {
2273
+ id: c.command,
2274
+ title: c.title,
2275
+ arguments: c.arguments
2276
+ } : void 0;
2277
+ }
2278
+ var HoverAdapter = class {
2279
+ constructor(_worker) {
2280
+ this._worker = _worker;
2281
+ }
2282
+ provideHover(model, position, token) {
2283
+ let resource = model.uri;
2284
+ return this._worker(resource).then((worker) => {
2285
+ return worker.doHover(resource.toString(), fromPosition(position));
2286
+ }).then((info) => {
2287
+ if (!info) return;
2288
+ return {
2289
+ range: toRange(info.range),
2290
+ contents: toMarkedStringArray(info.contents)
2291
+ };
2292
+ });
2293
+ }
2294
+ };
2295
+ function isMarkupContent(thing) {
2296
+ return thing && typeof thing === "object" && typeof thing.kind === "string";
2297
+ }
2298
+ function toMarkdownString(entry) {
2299
+ if (typeof entry === "string") return { value: entry };
2300
+ if (isMarkupContent(entry)) {
2301
+ if (entry.kind === "plaintext") return { value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&") };
2302
+ return { value: entry.value };
2303
+ }
2304
+ return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
2305
+ }
2306
+ function toMarkedStringArray(contents) {
2307
+ if (!contents) return;
2308
+ if (Array.isArray(contents)) return contents.map(toMarkdownString);
2309
+ return [toMarkdownString(contents)];
2310
+ }
2311
+ var DocumentHighlightAdapter = class {
2312
+ constructor(_worker) {
2313
+ this._worker = _worker;
2314
+ }
2315
+ provideDocumentHighlights(model, position, token) {
2316
+ const resource = model.uri;
2317
+ return this._worker(resource).then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position))).then((entries) => {
2318
+ if (!entries) return;
2319
+ return entries.map((entry) => {
2320
+ return {
2321
+ range: toRange(entry.range),
2322
+ kind: toDocumentHighlightKind(entry.kind)
2323
+ };
2324
+ });
2325
+ });
2326
+ }
2327
+ };
2328
+ function toDocumentHighlightKind(kind) {
2329
+ switch (kind) {
2330
+ case DocumentHighlightKind.Read: return languages.DocumentHighlightKind.Read;
2331
+ case DocumentHighlightKind.Write: return languages.DocumentHighlightKind.Write;
2332
+ case DocumentHighlightKind.Text: return languages.DocumentHighlightKind.Text;
2333
+ }
2334
+ return languages.DocumentHighlightKind.Text;
2335
+ }
2336
+ var DefinitionAdapter = class {
2337
+ constructor(_worker) {
2338
+ this._worker = _worker;
2339
+ }
2340
+ provideDefinition(model, position, token) {
2341
+ const resource = model.uri;
2342
+ return this._worker(resource).then((worker) => {
2343
+ return worker.findDefinition(resource.toString(), fromPosition(position));
2344
+ }).then((definition) => {
2345
+ if (!definition) return;
2346
+ return [toLocation(definition)];
2347
+ });
2348
+ }
2349
+ };
2350
+ function toLocation(location) {
2351
+ return {
2352
+ uri: Uri.parse(location.uri),
2353
+ range: toRange(location.range)
2354
+ };
2355
+ }
2356
+ var ReferenceAdapter = class {
2357
+ constructor(_worker) {
2358
+ this._worker = _worker;
2359
+ }
2360
+ provideReferences(model, position, context, token) {
2361
+ const resource = model.uri;
2362
+ return this._worker(resource).then((worker) => {
2363
+ return worker.findReferences(resource.toString(), fromPosition(position));
2364
+ }).then((entries) => {
2365
+ if (!entries) return;
2366
+ return entries.map(toLocation);
2367
+ });
2368
+ }
2369
+ };
2370
+ var RenameAdapter = class {
2371
+ constructor(_worker) {
2372
+ this._worker = _worker;
2373
+ }
2374
+ provideRenameEdits(model, position, newName, token) {
2375
+ const resource = model.uri;
2376
+ return this._worker(resource).then((worker) => {
2377
+ return worker.doRename(resource.toString(), fromPosition(position), newName);
2378
+ }).then((edit) => {
2379
+ return toWorkspaceEdit(edit);
2380
+ });
2381
+ }
2382
+ };
2383
+ function toWorkspaceEdit(edit) {
2384
+ if (!edit || !edit.changes) return;
2385
+ let resourceEdits = [];
2386
+ for (let uri in edit.changes) {
2387
+ const _uri = Uri.parse(uri);
2388
+ for (let e of edit.changes[uri]) resourceEdits.push({
2389
+ resource: _uri,
2390
+ versionId: void 0,
2391
+ textEdit: {
2392
+ range: toRange(e.range),
2393
+ text: e.newText
2394
+ }
2395
+ });
2396
+ }
2397
+ return { edits: resourceEdits };
2398
+ }
2399
+ var DocumentSymbolAdapter = class {
2400
+ constructor(_worker) {
2401
+ this._worker = _worker;
2402
+ }
2403
+ provideDocumentSymbols(model, token) {
2404
+ const resource = model.uri;
2405
+ return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
2406
+ if (!items) return;
2407
+ return items.map((item) => {
2408
+ if (isDocumentSymbol(item)) return toDocumentSymbol(item);
2409
+ return {
2410
+ name: item.name,
2411
+ detail: "",
2412
+ containerName: item.containerName,
2413
+ kind: toSymbolKind(item.kind),
2414
+ range: toRange(item.location.range),
2415
+ selectionRange: toRange(item.location.range),
2416
+ tags: []
2417
+ };
2418
+ });
2419
+ });
2420
+ }
2421
+ };
2422
+ function isDocumentSymbol(symbol) {
2423
+ return "children" in symbol;
2424
+ }
2425
+ function toDocumentSymbol(symbol) {
2426
+ return {
2427
+ name: symbol.name,
2428
+ detail: symbol.detail ?? "",
2429
+ kind: toSymbolKind(symbol.kind),
2430
+ range: toRange(symbol.range),
2431
+ selectionRange: toRange(symbol.selectionRange),
2432
+ tags: symbol.tags ?? [],
2433
+ children: (symbol.children ?? []).map((item) => toDocumentSymbol(item))
2434
+ };
2435
+ }
2436
+ function toSymbolKind(kind) {
2437
+ let mKind = languages.SymbolKind;
2438
+ switch (kind) {
2439
+ case SymbolKind.File: return mKind.File;
2440
+ case SymbolKind.Module: return mKind.Module;
2441
+ case SymbolKind.Namespace: return mKind.Namespace;
2442
+ case SymbolKind.Package: return mKind.Package;
2443
+ case SymbolKind.Class: return mKind.Class;
2444
+ case SymbolKind.Method: return mKind.Method;
2445
+ case SymbolKind.Property: return mKind.Property;
2446
+ case SymbolKind.Field: return mKind.Field;
2447
+ case SymbolKind.Constructor: return mKind.Constructor;
2448
+ case SymbolKind.Enum: return mKind.Enum;
2449
+ case SymbolKind.Interface: return mKind.Interface;
2450
+ case SymbolKind.Function: return mKind.Function;
2451
+ case SymbolKind.Variable: return mKind.Variable;
2452
+ case SymbolKind.Constant: return mKind.Constant;
2453
+ case SymbolKind.String: return mKind.String;
2454
+ case SymbolKind.Number: return mKind.Number;
2455
+ case SymbolKind.Boolean: return mKind.Boolean;
2456
+ case SymbolKind.Array: return mKind.Array;
2457
+ }
2458
+ return mKind.Function;
2459
+ }
2460
+ var DocumentLinkAdapter = class {
2461
+ constructor(_worker) {
2462
+ this._worker = _worker;
2463
+ }
2464
+ provideLinks(model, token) {
2465
+ const resource = model.uri;
2466
+ return this._worker(resource).then((worker) => worker.findDocumentLinks(resource.toString())).then((items) => {
2467
+ if (!items) return;
2468
+ return { links: items.map((item) => ({
2469
+ range: toRange(item.range),
2470
+ url: item.target
2471
+ })) };
2472
+ });
2473
+ }
2474
+ };
2475
+ var DocumentFormattingEditProvider = class {
2476
+ constructor(_worker) {
2477
+ this._worker = _worker;
2478
+ }
2479
+ provideDocumentFormattingEdits(model, options, token) {
2480
+ const resource = model.uri;
2481
+ return this._worker(resource).then((worker) => {
2482
+ return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
2483
+ if (!edits || edits.length === 0) return;
2484
+ return edits.map(toTextEdit);
2485
+ });
2486
+ });
2487
+ }
2488
+ };
2489
+ var DocumentRangeFormattingEditProvider = class {
2490
+ constructor(_worker) {
2491
+ this._worker = _worker;
2492
+ this.canFormatMultipleRanges = false;
2493
+ }
2494
+ provideDocumentRangeFormattingEdits(model, range, options, token) {
2495
+ const resource = model.uri;
2496
+ return this._worker(resource).then((worker) => {
2497
+ return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
2498
+ if (!edits || edits.length === 0) return;
2499
+ return edits.map(toTextEdit);
2500
+ });
2501
+ });
2502
+ }
2503
+ };
2504
+ function fromFormattingOptions(options) {
2505
+ return {
2506
+ tabSize: options.tabSize,
2507
+ insertSpaces: options.insertSpaces
2508
+ };
2509
+ }
2510
+ var DocumentColorAdapter = class {
2511
+ constructor(_worker) {
2512
+ this._worker = _worker;
2513
+ }
2514
+ provideDocumentColors(model, token) {
2515
+ const resource = model.uri;
2516
+ return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
2517
+ if (!infos) return;
2518
+ return infos.map((item) => ({
2519
+ color: item.color,
2520
+ range: toRange(item.range)
2521
+ }));
2522
+ });
2523
+ }
2524
+ provideColorPresentations(model, info, token) {
2525
+ const resource = model.uri;
2526
+ return this._worker(resource).then((worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then((presentations) => {
2527
+ if (!presentations) return;
2528
+ return presentations.map((presentation) => {
2529
+ let item = { label: presentation.label };
2530
+ if (presentation.textEdit) item.textEdit = toTextEdit(presentation.textEdit);
2531
+ if (presentation.additionalTextEdits) item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
2532
+ return item;
2533
+ });
2534
+ });
2535
+ }
2536
+ };
2537
+ var FoldingRangeAdapter = class {
2538
+ constructor(_worker) {
2539
+ this._worker = _worker;
2540
+ }
2541
+ provideFoldingRanges(model, context, token) {
2542
+ const resource = model.uri;
2543
+ return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
2544
+ if (!ranges) return;
2545
+ return ranges.map((range) => {
2546
+ const result = {
2547
+ start: range.startLine + 1,
2548
+ end: range.endLine + 1
2549
+ };
2550
+ if (typeof range.kind !== "undefined") result.kind = toFoldingRangeKind(range.kind);
2551
+ return result;
2552
+ });
2553
+ });
2554
+ }
2555
+ };
2556
+ function toFoldingRangeKind(kind) {
2557
+ switch (kind) {
2558
+ case FoldingRangeKind.Comment: return languages.FoldingRangeKind.Comment;
2559
+ case FoldingRangeKind.Imports: return languages.FoldingRangeKind.Imports;
2560
+ case FoldingRangeKind.Region: return languages.FoldingRangeKind.Region;
2561
+ }
2562
+ }
2563
+ var SelectionRangeAdapter = class {
2564
+ constructor(_worker) {
2565
+ this._worker = _worker;
2566
+ }
2567
+ provideSelectionRanges(model, positions, token) {
2568
+ const resource = model.uri;
2569
+ return this._worker(resource).then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition))).then((selectionRanges) => {
2570
+ if (!selectionRanges) return;
2571
+ return selectionRanges.map((selectionRange) => {
2572
+ const result = [];
2573
+ while (selectionRange) {
2574
+ result.push({ range: toRange(selectionRange.range) });
2575
+ selectionRange = selectionRange.parent;
2576
+ }
2577
+ return result;
2578
+ });
2579
+ });
2580
+ }
2581
+ };
2582
+ //#endregion
2583
+ export { toRange as _, DocumentFormattingEditProvider as a, DocumentRangeFormattingEditProvider as c, HoverAdapter as d, ReferenceAdapter as f, fromRange as g, fromPosition as h, DocumentColorAdapter as i, DocumentSymbolAdapter as l, SelectionRangeAdapter as m, DefinitionAdapter as n, DocumentHighlightAdapter as o, RenameAdapter as p, DiagnosticsAdapter as r, DocumentLinkAdapter as s, CompletionAdapter as t, FoldingRangeAdapter as u, toTextEdit as v, createWebWorker as y };