jsonMode.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644
  1. "use strict";
  2. /*!-----------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Version: 0.34.1(547870b6881302c5b4ff32173c16d06009e3588f)
  5. * Released under the MIT license
  6. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  7. *-----------------------------------------------------------------------------*/
  8. define("vs/language/json/jsonMode", ["require"],(require)=>{
  9. var moduleExports = (() => {
  10. var __create = Object.create;
  11. var __defProp = Object.defineProperty;
  12. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  13. var __getOwnPropNames = Object.getOwnPropertyNames;
  14. var __getProtoOf = Object.getPrototypeOf;
  15. var __hasOwnProp = Object.prototype.hasOwnProperty;
  16. var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
  17. get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
  18. }) : x)(function(x) {
  19. if (typeof require !== "undefined")
  20. return require.apply(this, arguments);
  21. throw new Error('Dynamic require of "' + x + '" is not supported');
  22. });
  23. var __commonJS = (cb, mod) => function __require2() {
  24. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  25. };
  26. var __export = (target, all) => {
  27. for (var name in all)
  28. __defProp(target, name, { get: all[name], enumerable: true });
  29. };
  30. var __copyProps = (to, from, except, desc) => {
  31. if (from && typeof from === "object" || typeof from === "function") {
  32. for (let key of __getOwnPropNames(from))
  33. if (!__hasOwnProp.call(to, key) && key !== except)
  34. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  35. }
  36. return to;
  37. };
  38. var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
  39. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
  40. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  41. // src/fillers/monaco-editor-core-amd.ts
  42. var require_monaco_editor_core_amd = __commonJS({
  43. "src/fillers/monaco-editor-core-amd.ts"(exports, module) {
  44. var api = __toESM(__require("vs/editor/editor.api"));
  45. module.exports = api;
  46. }
  47. });
  48. // src/language/json/jsonMode.ts
  49. var jsonMode_exports = {};
  50. __export(jsonMode_exports, {
  51. CompletionAdapter: () => CompletionAdapter,
  52. DefinitionAdapter: () => DefinitionAdapter,
  53. DiagnosticsAdapter: () => DiagnosticsAdapter,
  54. DocumentColorAdapter: () => DocumentColorAdapter,
  55. DocumentFormattingEditProvider: () => DocumentFormattingEditProvider,
  56. DocumentHighlightAdapter: () => DocumentHighlightAdapter,
  57. DocumentLinkAdapter: () => DocumentLinkAdapter,
  58. DocumentRangeFormattingEditProvider: () => DocumentRangeFormattingEditProvider,
  59. DocumentSymbolAdapter: () => DocumentSymbolAdapter,
  60. FoldingRangeAdapter: () => FoldingRangeAdapter,
  61. HoverAdapter: () => HoverAdapter,
  62. ReferenceAdapter: () => ReferenceAdapter,
  63. RenameAdapter: () => RenameAdapter,
  64. SelectionRangeAdapter: () => SelectionRangeAdapter,
  65. WorkerManager: () => WorkerManager,
  66. fromPosition: () => fromPosition,
  67. fromRange: () => fromRange,
  68. setupMode: () => setupMode,
  69. toRange: () => toRange,
  70. toTextEdit: () => toTextEdit
  71. });
  72. // src/fillers/monaco-editor-core.ts
  73. var monaco_editor_core_exports = {};
  74. __reExport(monaco_editor_core_exports, __toESM(require_monaco_editor_core_amd()));
  75. // src/language/json/workerManager.ts
  76. var STOP_WHEN_IDLE_FOR = 2 * 60 * 1e3;
  77. var WorkerManager = class {
  78. _defaults;
  79. _idleCheckInterval;
  80. _lastUsedTime;
  81. _configChangeListener;
  82. _worker;
  83. _client;
  84. constructor(defaults) {
  85. this._defaults = defaults;
  86. this._worker = null;
  87. this._client = null;
  88. this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1e3);
  89. this._lastUsedTime = 0;
  90. this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
  91. }
  92. _stopWorker() {
  93. if (this._worker) {
  94. this._worker.dispose();
  95. this._worker = null;
  96. }
  97. this._client = null;
  98. }
  99. dispose() {
  100. clearInterval(this._idleCheckInterval);
  101. this._configChangeListener.dispose();
  102. this._stopWorker();
  103. }
  104. _checkIfIdle() {
  105. if (!this._worker) {
  106. return;
  107. }
  108. let timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
  109. if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
  110. this._stopWorker();
  111. }
  112. }
  113. _getClient() {
  114. this._lastUsedTime = Date.now();
  115. if (!this._client) {
  116. this._worker = monaco_editor_core_exports.editor.createWebWorker({
  117. moduleId: "vs/language/json/jsonWorker",
  118. label: this._defaults.languageId,
  119. createData: {
  120. languageSettings: this._defaults.diagnosticsOptions,
  121. languageId: this._defaults.languageId,
  122. enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest
  123. }
  124. });
  125. this._client = this._worker.getProxy();
  126. }
  127. return this._client;
  128. }
  129. getLanguageServiceWorker(...resources) {
  130. let _client;
  131. return this._getClient().then((client) => {
  132. _client = client;
  133. }).then((_) => {
  134. if (this._worker) {
  135. return this._worker.withSyncedResources(resources);
  136. }
  137. }).then((_) => _client);
  138. }
  139. };
  140. // node_modules/vscode-languageserver-types/lib/esm/main.js
  141. var integer;
  142. (function(integer2) {
  143. integer2.MIN_VALUE = -2147483648;
  144. integer2.MAX_VALUE = 2147483647;
  145. })(integer || (integer = {}));
  146. var uinteger;
  147. (function(uinteger2) {
  148. uinteger2.MIN_VALUE = 0;
  149. uinteger2.MAX_VALUE = 2147483647;
  150. })(uinteger || (uinteger = {}));
  151. var Position;
  152. (function(Position3) {
  153. function create(line, character) {
  154. if (line === Number.MAX_VALUE) {
  155. line = uinteger.MAX_VALUE;
  156. }
  157. if (character === Number.MAX_VALUE) {
  158. character = uinteger.MAX_VALUE;
  159. }
  160. return { line, character };
  161. }
  162. Position3.create = create;
  163. function is(value) {
  164. var candidate = value;
  165. return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
  166. }
  167. Position3.is = is;
  168. })(Position || (Position = {}));
  169. var Range;
  170. (function(Range3) {
  171. function create(one, two, three, four) {
  172. if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
  173. return { start: Position.create(one, two), end: Position.create(three, four) };
  174. } else if (Position.is(one) && Position.is(two)) {
  175. return { start: one, end: two };
  176. } else {
  177. throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
  178. }
  179. }
  180. Range3.create = create;
  181. function is(value) {
  182. var candidate = value;
  183. return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
  184. }
  185. Range3.is = is;
  186. })(Range || (Range = {}));
  187. var Location;
  188. (function(Location2) {
  189. function create(uri, range) {
  190. return { uri, range };
  191. }
  192. Location2.create = create;
  193. function is(value) {
  194. var candidate = value;
  195. return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
  196. }
  197. Location2.is = is;
  198. })(Location || (Location = {}));
  199. var LocationLink;
  200. (function(LocationLink2) {
  201. function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
  202. return { targetUri, targetRange, targetSelectionRange, originSelectionRange };
  203. }
  204. LocationLink2.create = create;
  205. function is(value) {
  206. var candidate = value;
  207. return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
  208. }
  209. LocationLink2.is = is;
  210. })(LocationLink || (LocationLink = {}));
  211. var Color;
  212. (function(Color2) {
  213. function create(red, green, blue, alpha) {
  214. return {
  215. red,
  216. green,
  217. blue,
  218. alpha
  219. };
  220. }
  221. Color2.create = create;
  222. function is(value) {
  223. var candidate = value;
  224. return Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
  225. }
  226. Color2.is = is;
  227. })(Color || (Color = {}));
  228. var ColorInformation;
  229. (function(ColorInformation2) {
  230. function create(range, color) {
  231. return {
  232. range,
  233. color
  234. };
  235. }
  236. ColorInformation2.create = create;
  237. function is(value) {
  238. var candidate = value;
  239. return Range.is(candidate.range) && Color.is(candidate.color);
  240. }
  241. ColorInformation2.is = is;
  242. })(ColorInformation || (ColorInformation = {}));
  243. var ColorPresentation;
  244. (function(ColorPresentation2) {
  245. function create(label, textEdit, additionalTextEdits) {
  246. return {
  247. label,
  248. textEdit,
  249. additionalTextEdits
  250. };
  251. }
  252. ColorPresentation2.create = create;
  253. function is(value) {
  254. var candidate = value;
  255. return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
  256. }
  257. ColorPresentation2.is = is;
  258. })(ColorPresentation || (ColorPresentation = {}));
  259. var FoldingRangeKind;
  260. (function(FoldingRangeKind2) {
  261. FoldingRangeKind2["Comment"] = "comment";
  262. FoldingRangeKind2["Imports"] = "imports";
  263. FoldingRangeKind2["Region"] = "region";
  264. })(FoldingRangeKind || (FoldingRangeKind = {}));
  265. var FoldingRange;
  266. (function(FoldingRange2) {
  267. function create(startLine, endLine, startCharacter, endCharacter, kind) {
  268. var result = {
  269. startLine,
  270. endLine
  271. };
  272. if (Is.defined(startCharacter)) {
  273. result.startCharacter = startCharacter;
  274. }
  275. if (Is.defined(endCharacter)) {
  276. result.endCharacter = endCharacter;
  277. }
  278. if (Is.defined(kind)) {
  279. result.kind = kind;
  280. }
  281. return result;
  282. }
  283. FoldingRange2.create = create;
  284. function is(value) {
  285. var candidate = value;
  286. return 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));
  287. }
  288. FoldingRange2.is = is;
  289. })(FoldingRange || (FoldingRange = {}));
  290. var DiagnosticRelatedInformation;
  291. (function(DiagnosticRelatedInformation2) {
  292. function create(location, message) {
  293. return {
  294. location,
  295. message
  296. };
  297. }
  298. DiagnosticRelatedInformation2.create = create;
  299. function is(value) {
  300. var candidate = value;
  301. return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
  302. }
  303. DiagnosticRelatedInformation2.is = is;
  304. })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
  305. var DiagnosticSeverity;
  306. (function(DiagnosticSeverity2) {
  307. DiagnosticSeverity2.Error = 1;
  308. DiagnosticSeverity2.Warning = 2;
  309. DiagnosticSeverity2.Information = 3;
  310. DiagnosticSeverity2.Hint = 4;
  311. })(DiagnosticSeverity || (DiagnosticSeverity = {}));
  312. var DiagnosticTag;
  313. (function(DiagnosticTag2) {
  314. DiagnosticTag2.Unnecessary = 1;
  315. DiagnosticTag2.Deprecated = 2;
  316. })(DiagnosticTag || (DiagnosticTag = {}));
  317. var CodeDescription;
  318. (function(CodeDescription2) {
  319. function is(value) {
  320. var candidate = value;
  321. return candidate !== void 0 && candidate !== null && Is.string(candidate.href);
  322. }
  323. CodeDescription2.is = is;
  324. })(CodeDescription || (CodeDescription = {}));
  325. var Diagnostic;
  326. (function(Diagnostic2) {
  327. function create(range, message, severity, code, source, relatedInformation) {
  328. var result = { range, message };
  329. if (Is.defined(severity)) {
  330. result.severity = severity;
  331. }
  332. if (Is.defined(code)) {
  333. result.code = code;
  334. }
  335. if (Is.defined(source)) {
  336. result.source = source;
  337. }
  338. if (Is.defined(relatedInformation)) {
  339. result.relatedInformation = relatedInformation;
  340. }
  341. return result;
  342. }
  343. Diagnostic2.create = create;
  344. function is(value) {
  345. var _a;
  346. var candidate = value;
  347. 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));
  348. }
  349. Diagnostic2.is = is;
  350. })(Diagnostic || (Diagnostic = {}));
  351. var Command;
  352. (function(Command2) {
  353. function create(title, command) {
  354. var args = [];
  355. for (var _i = 2; _i < arguments.length; _i++) {
  356. args[_i - 2] = arguments[_i];
  357. }
  358. var result = { title, command };
  359. if (Is.defined(args) && args.length > 0) {
  360. result.arguments = args;
  361. }
  362. return result;
  363. }
  364. Command2.create = create;
  365. function is(value) {
  366. var candidate = value;
  367. return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
  368. }
  369. Command2.is = is;
  370. })(Command || (Command = {}));
  371. var TextEdit;
  372. (function(TextEdit2) {
  373. function replace(range, newText) {
  374. return { range, newText };
  375. }
  376. TextEdit2.replace = replace;
  377. function insert(position, newText) {
  378. return { range: { start: position, end: position }, newText };
  379. }
  380. TextEdit2.insert = insert;
  381. function del(range) {
  382. return { range, newText: "" };
  383. }
  384. TextEdit2.del = del;
  385. function is(value) {
  386. var candidate = value;
  387. return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
  388. }
  389. TextEdit2.is = is;
  390. })(TextEdit || (TextEdit = {}));
  391. var ChangeAnnotation;
  392. (function(ChangeAnnotation2) {
  393. function create(label, needsConfirmation, description) {
  394. var result = { label };
  395. if (needsConfirmation !== void 0) {
  396. result.needsConfirmation = needsConfirmation;
  397. }
  398. if (description !== void 0) {
  399. result.description = description;
  400. }
  401. return result;
  402. }
  403. ChangeAnnotation2.create = create;
  404. function is(value) {
  405. var candidate = value;
  406. return candidate !== void 0 && Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
  407. }
  408. ChangeAnnotation2.is = is;
  409. })(ChangeAnnotation || (ChangeAnnotation = {}));
  410. var ChangeAnnotationIdentifier;
  411. (function(ChangeAnnotationIdentifier2) {
  412. function is(value) {
  413. var candidate = value;
  414. return typeof candidate === "string";
  415. }
  416. ChangeAnnotationIdentifier2.is = is;
  417. })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
  418. var AnnotatedTextEdit;
  419. (function(AnnotatedTextEdit2) {
  420. function replace(range, newText, annotation) {
  421. return { range, newText, annotationId: annotation };
  422. }
  423. AnnotatedTextEdit2.replace = replace;
  424. function insert(position, newText, annotation) {
  425. return { range: { start: position, end: position }, newText, annotationId: annotation };
  426. }
  427. AnnotatedTextEdit2.insert = insert;
  428. function del(range, annotation) {
  429. return { range, newText: "", annotationId: annotation };
  430. }
  431. AnnotatedTextEdit2.del = del;
  432. function is(value) {
  433. var candidate = value;
  434. return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
  435. }
  436. AnnotatedTextEdit2.is = is;
  437. })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
  438. var TextDocumentEdit;
  439. (function(TextDocumentEdit2) {
  440. function create(textDocument, edits) {
  441. return { textDocument, edits };
  442. }
  443. TextDocumentEdit2.create = create;
  444. function is(value) {
  445. var candidate = value;
  446. return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
  447. }
  448. TextDocumentEdit2.is = is;
  449. })(TextDocumentEdit || (TextDocumentEdit = {}));
  450. var CreateFile;
  451. (function(CreateFile2) {
  452. function create(uri, options, annotation) {
  453. var result = {
  454. kind: "create",
  455. uri
  456. };
  457. if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
  458. result.options = options;
  459. }
  460. if (annotation !== void 0) {
  461. result.annotationId = annotation;
  462. }
  463. return result;
  464. }
  465. CreateFile2.create = create;
  466. function is(value) {
  467. var candidate = value;
  468. 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));
  469. }
  470. CreateFile2.is = is;
  471. })(CreateFile || (CreateFile = {}));
  472. var RenameFile;
  473. (function(RenameFile2) {
  474. function create(oldUri, newUri, options, annotation) {
  475. var result = {
  476. kind: "rename",
  477. oldUri,
  478. newUri
  479. };
  480. if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
  481. result.options = options;
  482. }
  483. if (annotation !== void 0) {
  484. result.annotationId = annotation;
  485. }
  486. return result;
  487. }
  488. RenameFile2.create = create;
  489. function is(value) {
  490. var candidate = value;
  491. 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));
  492. }
  493. RenameFile2.is = is;
  494. })(RenameFile || (RenameFile = {}));
  495. var DeleteFile;
  496. (function(DeleteFile2) {
  497. function create(uri, options, annotation) {
  498. var result = {
  499. kind: "delete",
  500. uri
  501. };
  502. if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
  503. result.options = options;
  504. }
  505. if (annotation !== void 0) {
  506. result.annotationId = annotation;
  507. }
  508. return result;
  509. }
  510. DeleteFile2.create = create;
  511. function is(value) {
  512. var candidate = value;
  513. 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));
  514. }
  515. DeleteFile2.is = is;
  516. })(DeleteFile || (DeleteFile = {}));
  517. var WorkspaceEdit;
  518. (function(WorkspaceEdit2) {
  519. function is(value) {
  520. var candidate = value;
  521. return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
  522. if (Is.string(change.kind)) {
  523. return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
  524. } else {
  525. return TextDocumentEdit.is(change);
  526. }
  527. }));
  528. }
  529. WorkspaceEdit2.is = is;
  530. })(WorkspaceEdit || (WorkspaceEdit = {}));
  531. var TextEditChangeImpl = function() {
  532. function TextEditChangeImpl2(edits, changeAnnotations) {
  533. this.edits = edits;
  534. this.changeAnnotations = changeAnnotations;
  535. }
  536. TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
  537. var edit;
  538. var id;
  539. if (annotation === void 0) {
  540. edit = TextEdit.insert(position, newText);
  541. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  542. id = annotation;
  543. edit = AnnotatedTextEdit.insert(position, newText, annotation);
  544. } else {
  545. this.assertChangeAnnotations(this.changeAnnotations);
  546. id = this.changeAnnotations.manage(annotation);
  547. edit = AnnotatedTextEdit.insert(position, newText, id);
  548. }
  549. this.edits.push(edit);
  550. if (id !== void 0) {
  551. return id;
  552. }
  553. };
  554. TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
  555. var edit;
  556. var id;
  557. if (annotation === void 0) {
  558. edit = TextEdit.replace(range, newText);
  559. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  560. id = annotation;
  561. edit = AnnotatedTextEdit.replace(range, newText, annotation);
  562. } else {
  563. this.assertChangeAnnotations(this.changeAnnotations);
  564. id = this.changeAnnotations.manage(annotation);
  565. edit = AnnotatedTextEdit.replace(range, newText, id);
  566. }
  567. this.edits.push(edit);
  568. if (id !== void 0) {
  569. return id;
  570. }
  571. };
  572. TextEditChangeImpl2.prototype.delete = function(range, annotation) {
  573. var edit;
  574. var id;
  575. if (annotation === void 0) {
  576. edit = TextEdit.del(range);
  577. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  578. id = annotation;
  579. edit = AnnotatedTextEdit.del(range, annotation);
  580. } else {
  581. this.assertChangeAnnotations(this.changeAnnotations);
  582. id = this.changeAnnotations.manage(annotation);
  583. edit = AnnotatedTextEdit.del(range, id);
  584. }
  585. this.edits.push(edit);
  586. if (id !== void 0) {
  587. return id;
  588. }
  589. };
  590. TextEditChangeImpl2.prototype.add = function(edit) {
  591. this.edits.push(edit);
  592. };
  593. TextEditChangeImpl2.prototype.all = function() {
  594. return this.edits;
  595. };
  596. TextEditChangeImpl2.prototype.clear = function() {
  597. this.edits.splice(0, this.edits.length);
  598. };
  599. TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
  600. if (value === void 0) {
  601. throw new Error("Text edit change is not configured to manage change annotations.");
  602. }
  603. };
  604. return TextEditChangeImpl2;
  605. }();
  606. var ChangeAnnotations = function() {
  607. function ChangeAnnotations2(annotations) {
  608. this._annotations = annotations === void 0 ? /* @__PURE__ */ Object.create(null) : annotations;
  609. this._counter = 0;
  610. this._size = 0;
  611. }
  612. ChangeAnnotations2.prototype.all = function() {
  613. return this._annotations;
  614. };
  615. Object.defineProperty(ChangeAnnotations2.prototype, "size", {
  616. get: function() {
  617. return this._size;
  618. },
  619. enumerable: false,
  620. configurable: true
  621. });
  622. ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
  623. var id;
  624. if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
  625. id = idOrAnnotation;
  626. } else {
  627. id = this.nextId();
  628. annotation = idOrAnnotation;
  629. }
  630. if (this._annotations[id] !== void 0) {
  631. throw new Error("Id " + id + " is already in use.");
  632. }
  633. if (annotation === void 0) {
  634. throw new Error("No annotation provided for id " + id);
  635. }
  636. this._annotations[id] = annotation;
  637. this._size++;
  638. return id;
  639. };
  640. ChangeAnnotations2.prototype.nextId = function() {
  641. this._counter++;
  642. return this._counter.toString();
  643. };
  644. return ChangeAnnotations2;
  645. }();
  646. var WorkspaceChange = function() {
  647. function WorkspaceChange2(workspaceEdit) {
  648. var _this = this;
  649. this._textEditChanges = /* @__PURE__ */ Object.create(null);
  650. if (workspaceEdit !== void 0) {
  651. this._workspaceEdit = workspaceEdit;
  652. if (workspaceEdit.documentChanges) {
  653. this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
  654. workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  655. workspaceEdit.documentChanges.forEach(function(change) {
  656. if (TextDocumentEdit.is(change)) {
  657. var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
  658. _this._textEditChanges[change.textDocument.uri] = textEditChange;
  659. }
  660. });
  661. } else if (workspaceEdit.changes) {
  662. Object.keys(workspaceEdit.changes).forEach(function(key) {
  663. var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
  664. _this._textEditChanges[key] = textEditChange;
  665. });
  666. }
  667. } else {
  668. this._workspaceEdit = {};
  669. }
  670. }
  671. Object.defineProperty(WorkspaceChange2.prototype, "edit", {
  672. get: function() {
  673. this.initDocumentChanges();
  674. if (this._changeAnnotations !== void 0) {
  675. if (this._changeAnnotations.size === 0) {
  676. this._workspaceEdit.changeAnnotations = void 0;
  677. } else {
  678. this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  679. }
  680. }
  681. return this._workspaceEdit;
  682. },
  683. enumerable: false,
  684. configurable: true
  685. });
  686. WorkspaceChange2.prototype.getTextEditChange = function(key) {
  687. if (OptionalVersionedTextDocumentIdentifier.is(key)) {
  688. this.initDocumentChanges();
  689. if (this._workspaceEdit.documentChanges === void 0) {
  690. throw new Error("Workspace edit is not configured for document changes.");
  691. }
  692. var textDocument = { uri: key.uri, version: key.version };
  693. var result = this._textEditChanges[textDocument.uri];
  694. if (!result) {
  695. var edits = [];
  696. var textDocumentEdit = {
  697. textDocument,
  698. edits
  699. };
  700. this._workspaceEdit.documentChanges.push(textDocumentEdit);
  701. result = new TextEditChangeImpl(edits, this._changeAnnotations);
  702. this._textEditChanges[textDocument.uri] = result;
  703. }
  704. return result;
  705. } else {
  706. this.initChanges();
  707. if (this._workspaceEdit.changes === void 0) {
  708. throw new Error("Workspace edit is not configured for normal text edit changes.");
  709. }
  710. var result = this._textEditChanges[key];
  711. if (!result) {
  712. var edits = [];
  713. this._workspaceEdit.changes[key] = edits;
  714. result = new TextEditChangeImpl(edits);
  715. this._textEditChanges[key] = result;
  716. }
  717. return result;
  718. }
  719. };
  720. WorkspaceChange2.prototype.initDocumentChanges = function() {
  721. if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
  722. this._changeAnnotations = new ChangeAnnotations();
  723. this._workspaceEdit.documentChanges = [];
  724. this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  725. }
  726. };
  727. WorkspaceChange2.prototype.initChanges = function() {
  728. if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
  729. this._workspaceEdit.changes = /* @__PURE__ */ Object.create(null);
  730. }
  731. };
  732. WorkspaceChange2.prototype.createFile = function(uri, optionsOrAnnotation, options) {
  733. this.initDocumentChanges();
  734. if (this._workspaceEdit.documentChanges === void 0) {
  735. throw new Error("Workspace edit is not configured for document changes.");
  736. }
  737. var annotation;
  738. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  739. annotation = optionsOrAnnotation;
  740. } else {
  741. options = optionsOrAnnotation;
  742. }
  743. var operation;
  744. var id;
  745. if (annotation === void 0) {
  746. operation = CreateFile.create(uri, options);
  747. } else {
  748. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  749. operation = CreateFile.create(uri, options, id);
  750. }
  751. this._workspaceEdit.documentChanges.push(operation);
  752. if (id !== void 0) {
  753. return id;
  754. }
  755. };
  756. WorkspaceChange2.prototype.renameFile = function(oldUri, newUri, optionsOrAnnotation, options) {
  757. this.initDocumentChanges();
  758. if (this._workspaceEdit.documentChanges === void 0) {
  759. throw new Error("Workspace edit is not configured for document changes.");
  760. }
  761. var annotation;
  762. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  763. annotation = optionsOrAnnotation;
  764. } else {
  765. options = optionsOrAnnotation;
  766. }
  767. var operation;
  768. var id;
  769. if (annotation === void 0) {
  770. operation = RenameFile.create(oldUri, newUri, options);
  771. } else {
  772. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  773. operation = RenameFile.create(oldUri, newUri, options, id);
  774. }
  775. this._workspaceEdit.documentChanges.push(operation);
  776. if (id !== void 0) {
  777. return id;
  778. }
  779. };
  780. WorkspaceChange2.prototype.deleteFile = function(uri, optionsOrAnnotation, options) {
  781. this.initDocumentChanges();
  782. if (this._workspaceEdit.documentChanges === void 0) {
  783. throw new Error("Workspace edit is not configured for document changes.");
  784. }
  785. var annotation;
  786. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  787. annotation = optionsOrAnnotation;
  788. } else {
  789. options = optionsOrAnnotation;
  790. }
  791. var operation;
  792. var id;
  793. if (annotation === void 0) {
  794. operation = DeleteFile.create(uri, options);
  795. } else {
  796. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  797. operation = DeleteFile.create(uri, options, id);
  798. }
  799. this._workspaceEdit.documentChanges.push(operation);
  800. if (id !== void 0) {
  801. return id;
  802. }
  803. };
  804. return WorkspaceChange2;
  805. }();
  806. var TextDocumentIdentifier;
  807. (function(TextDocumentIdentifier2) {
  808. function create(uri) {
  809. return { uri };
  810. }
  811. TextDocumentIdentifier2.create = create;
  812. function is(value) {
  813. var candidate = value;
  814. return Is.defined(candidate) && Is.string(candidate.uri);
  815. }
  816. TextDocumentIdentifier2.is = is;
  817. })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
  818. var VersionedTextDocumentIdentifier;
  819. (function(VersionedTextDocumentIdentifier2) {
  820. function create(uri, version) {
  821. return { uri, version };
  822. }
  823. VersionedTextDocumentIdentifier2.create = create;
  824. function is(value) {
  825. var candidate = value;
  826. return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
  827. }
  828. VersionedTextDocumentIdentifier2.is = is;
  829. })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
  830. var OptionalVersionedTextDocumentIdentifier;
  831. (function(OptionalVersionedTextDocumentIdentifier2) {
  832. function create(uri, version) {
  833. return { uri, version };
  834. }
  835. OptionalVersionedTextDocumentIdentifier2.create = create;
  836. function is(value) {
  837. var candidate = value;
  838. return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
  839. }
  840. OptionalVersionedTextDocumentIdentifier2.is = is;
  841. })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
  842. var TextDocumentItem;
  843. (function(TextDocumentItem2) {
  844. function create(uri, languageId, version, text) {
  845. return { uri, languageId, version, text };
  846. }
  847. TextDocumentItem2.create = create;
  848. function is(value) {
  849. var candidate = value;
  850. return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
  851. }
  852. TextDocumentItem2.is = is;
  853. })(TextDocumentItem || (TextDocumentItem = {}));
  854. var MarkupKind;
  855. (function(MarkupKind2) {
  856. MarkupKind2.PlainText = "plaintext";
  857. MarkupKind2.Markdown = "markdown";
  858. })(MarkupKind || (MarkupKind = {}));
  859. (function(MarkupKind2) {
  860. function is(value) {
  861. var candidate = value;
  862. return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
  863. }
  864. MarkupKind2.is = is;
  865. })(MarkupKind || (MarkupKind = {}));
  866. var MarkupContent;
  867. (function(MarkupContent2) {
  868. function is(value) {
  869. var candidate = value;
  870. return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
  871. }
  872. MarkupContent2.is = is;
  873. })(MarkupContent || (MarkupContent = {}));
  874. var CompletionItemKind;
  875. (function(CompletionItemKind2) {
  876. CompletionItemKind2.Text = 1;
  877. CompletionItemKind2.Method = 2;
  878. CompletionItemKind2.Function = 3;
  879. CompletionItemKind2.Constructor = 4;
  880. CompletionItemKind2.Field = 5;
  881. CompletionItemKind2.Variable = 6;
  882. CompletionItemKind2.Class = 7;
  883. CompletionItemKind2.Interface = 8;
  884. CompletionItemKind2.Module = 9;
  885. CompletionItemKind2.Property = 10;
  886. CompletionItemKind2.Unit = 11;
  887. CompletionItemKind2.Value = 12;
  888. CompletionItemKind2.Enum = 13;
  889. CompletionItemKind2.Keyword = 14;
  890. CompletionItemKind2.Snippet = 15;
  891. CompletionItemKind2.Color = 16;
  892. CompletionItemKind2.File = 17;
  893. CompletionItemKind2.Reference = 18;
  894. CompletionItemKind2.Folder = 19;
  895. CompletionItemKind2.EnumMember = 20;
  896. CompletionItemKind2.Constant = 21;
  897. CompletionItemKind2.Struct = 22;
  898. CompletionItemKind2.Event = 23;
  899. CompletionItemKind2.Operator = 24;
  900. CompletionItemKind2.TypeParameter = 25;
  901. })(CompletionItemKind || (CompletionItemKind = {}));
  902. var InsertTextFormat;
  903. (function(InsertTextFormat2) {
  904. InsertTextFormat2.PlainText = 1;
  905. InsertTextFormat2.Snippet = 2;
  906. })(InsertTextFormat || (InsertTextFormat = {}));
  907. var CompletionItemTag;
  908. (function(CompletionItemTag2) {
  909. CompletionItemTag2.Deprecated = 1;
  910. })(CompletionItemTag || (CompletionItemTag = {}));
  911. var InsertReplaceEdit;
  912. (function(InsertReplaceEdit2) {
  913. function create(newText, insert, replace) {
  914. return { newText, insert, replace };
  915. }
  916. InsertReplaceEdit2.create = create;
  917. function is(value) {
  918. var candidate = value;
  919. return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
  920. }
  921. InsertReplaceEdit2.is = is;
  922. })(InsertReplaceEdit || (InsertReplaceEdit = {}));
  923. var InsertTextMode;
  924. (function(InsertTextMode2) {
  925. InsertTextMode2.asIs = 1;
  926. InsertTextMode2.adjustIndentation = 2;
  927. })(InsertTextMode || (InsertTextMode = {}));
  928. var CompletionItem;
  929. (function(CompletionItem2) {
  930. function create(label) {
  931. return { label };
  932. }
  933. CompletionItem2.create = create;
  934. })(CompletionItem || (CompletionItem = {}));
  935. var CompletionList;
  936. (function(CompletionList2) {
  937. function create(items, isIncomplete) {
  938. return { items: items ? items : [], isIncomplete: !!isIncomplete };
  939. }
  940. CompletionList2.create = create;
  941. })(CompletionList || (CompletionList = {}));
  942. var MarkedString;
  943. (function(MarkedString2) {
  944. function fromPlainText(plainText) {
  945. return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
  946. }
  947. MarkedString2.fromPlainText = fromPlainText;
  948. function is(value) {
  949. var candidate = value;
  950. return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
  951. }
  952. MarkedString2.is = is;
  953. })(MarkedString || (MarkedString = {}));
  954. var Hover;
  955. (function(Hover2) {
  956. function is(value) {
  957. var candidate = value;
  958. 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));
  959. }
  960. Hover2.is = is;
  961. })(Hover || (Hover = {}));
  962. var ParameterInformation;
  963. (function(ParameterInformation2) {
  964. function create(label, documentation) {
  965. return documentation ? { label, documentation } : { label };
  966. }
  967. ParameterInformation2.create = create;
  968. })(ParameterInformation || (ParameterInformation = {}));
  969. var SignatureInformation;
  970. (function(SignatureInformation2) {
  971. function create(label, documentation) {
  972. var parameters = [];
  973. for (var _i = 2; _i < arguments.length; _i++) {
  974. parameters[_i - 2] = arguments[_i];
  975. }
  976. var result = { label };
  977. if (Is.defined(documentation)) {
  978. result.documentation = documentation;
  979. }
  980. if (Is.defined(parameters)) {
  981. result.parameters = parameters;
  982. } else {
  983. result.parameters = [];
  984. }
  985. return result;
  986. }
  987. SignatureInformation2.create = create;
  988. })(SignatureInformation || (SignatureInformation = {}));
  989. var DocumentHighlightKind;
  990. (function(DocumentHighlightKind2) {
  991. DocumentHighlightKind2.Text = 1;
  992. DocumentHighlightKind2.Read = 2;
  993. DocumentHighlightKind2.Write = 3;
  994. })(DocumentHighlightKind || (DocumentHighlightKind = {}));
  995. var DocumentHighlight;
  996. (function(DocumentHighlight2) {
  997. function create(range, kind) {
  998. var result = { range };
  999. if (Is.number(kind)) {
  1000. result.kind = kind;
  1001. }
  1002. return result;
  1003. }
  1004. DocumentHighlight2.create = create;
  1005. })(DocumentHighlight || (DocumentHighlight = {}));
  1006. var SymbolKind;
  1007. (function(SymbolKind2) {
  1008. SymbolKind2.File = 1;
  1009. SymbolKind2.Module = 2;
  1010. SymbolKind2.Namespace = 3;
  1011. SymbolKind2.Package = 4;
  1012. SymbolKind2.Class = 5;
  1013. SymbolKind2.Method = 6;
  1014. SymbolKind2.Property = 7;
  1015. SymbolKind2.Field = 8;
  1016. SymbolKind2.Constructor = 9;
  1017. SymbolKind2.Enum = 10;
  1018. SymbolKind2.Interface = 11;
  1019. SymbolKind2.Function = 12;
  1020. SymbolKind2.Variable = 13;
  1021. SymbolKind2.Constant = 14;
  1022. SymbolKind2.String = 15;
  1023. SymbolKind2.Number = 16;
  1024. SymbolKind2.Boolean = 17;
  1025. SymbolKind2.Array = 18;
  1026. SymbolKind2.Object = 19;
  1027. SymbolKind2.Key = 20;
  1028. SymbolKind2.Null = 21;
  1029. SymbolKind2.EnumMember = 22;
  1030. SymbolKind2.Struct = 23;
  1031. SymbolKind2.Event = 24;
  1032. SymbolKind2.Operator = 25;
  1033. SymbolKind2.TypeParameter = 26;
  1034. })(SymbolKind || (SymbolKind = {}));
  1035. var SymbolTag;
  1036. (function(SymbolTag2) {
  1037. SymbolTag2.Deprecated = 1;
  1038. })(SymbolTag || (SymbolTag = {}));
  1039. var SymbolInformation;
  1040. (function(SymbolInformation2) {
  1041. function create(name, kind, range, uri, containerName) {
  1042. var result = {
  1043. name,
  1044. kind,
  1045. location: { uri, range }
  1046. };
  1047. if (containerName) {
  1048. result.containerName = containerName;
  1049. }
  1050. return result;
  1051. }
  1052. SymbolInformation2.create = create;
  1053. })(SymbolInformation || (SymbolInformation = {}));
  1054. var DocumentSymbol;
  1055. (function(DocumentSymbol2) {
  1056. function create(name, detail, kind, range, selectionRange, children) {
  1057. var result = {
  1058. name,
  1059. detail,
  1060. kind,
  1061. range,
  1062. selectionRange
  1063. };
  1064. if (children !== void 0) {
  1065. result.children = children;
  1066. }
  1067. return result;
  1068. }
  1069. DocumentSymbol2.create = create;
  1070. function is(value) {
  1071. var candidate = value;
  1072. 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));
  1073. }
  1074. DocumentSymbol2.is = is;
  1075. })(DocumentSymbol || (DocumentSymbol = {}));
  1076. var CodeActionKind;
  1077. (function(CodeActionKind2) {
  1078. CodeActionKind2.Empty = "";
  1079. CodeActionKind2.QuickFix = "quickfix";
  1080. CodeActionKind2.Refactor = "refactor";
  1081. CodeActionKind2.RefactorExtract = "refactor.extract";
  1082. CodeActionKind2.RefactorInline = "refactor.inline";
  1083. CodeActionKind2.RefactorRewrite = "refactor.rewrite";
  1084. CodeActionKind2.Source = "source";
  1085. CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
  1086. CodeActionKind2.SourceFixAll = "source.fixAll";
  1087. })(CodeActionKind || (CodeActionKind = {}));
  1088. var CodeActionContext;
  1089. (function(CodeActionContext2) {
  1090. function create(diagnostics, only) {
  1091. var result = { diagnostics };
  1092. if (only !== void 0 && only !== null) {
  1093. result.only = only;
  1094. }
  1095. return result;
  1096. }
  1097. CodeActionContext2.create = create;
  1098. function is(value) {
  1099. var candidate = value;
  1100. return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
  1101. }
  1102. CodeActionContext2.is = is;
  1103. })(CodeActionContext || (CodeActionContext = {}));
  1104. var CodeAction;
  1105. (function(CodeAction2) {
  1106. function create(title, kindOrCommandOrEdit, kind) {
  1107. var result = { title };
  1108. var checkKind = true;
  1109. if (typeof kindOrCommandOrEdit === "string") {
  1110. checkKind = false;
  1111. result.kind = kindOrCommandOrEdit;
  1112. } else if (Command.is(kindOrCommandOrEdit)) {
  1113. result.command = kindOrCommandOrEdit;
  1114. } else {
  1115. result.edit = kindOrCommandOrEdit;
  1116. }
  1117. if (checkKind && kind !== void 0) {
  1118. result.kind = kind;
  1119. }
  1120. return result;
  1121. }
  1122. CodeAction2.create = create;
  1123. function is(value) {
  1124. var candidate = value;
  1125. 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));
  1126. }
  1127. CodeAction2.is = is;
  1128. })(CodeAction || (CodeAction = {}));
  1129. var CodeLens;
  1130. (function(CodeLens2) {
  1131. function create(range, data) {
  1132. var result = { range };
  1133. if (Is.defined(data)) {
  1134. result.data = data;
  1135. }
  1136. return result;
  1137. }
  1138. CodeLens2.create = create;
  1139. function is(value) {
  1140. var candidate = value;
  1141. return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
  1142. }
  1143. CodeLens2.is = is;
  1144. })(CodeLens || (CodeLens = {}));
  1145. var FormattingOptions;
  1146. (function(FormattingOptions2) {
  1147. function create(tabSize, insertSpaces) {
  1148. return { tabSize, insertSpaces };
  1149. }
  1150. FormattingOptions2.create = create;
  1151. function is(value) {
  1152. var candidate = value;
  1153. return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
  1154. }
  1155. FormattingOptions2.is = is;
  1156. })(FormattingOptions || (FormattingOptions = {}));
  1157. var DocumentLink;
  1158. (function(DocumentLink2) {
  1159. function create(range, target, data) {
  1160. return { range, target, data };
  1161. }
  1162. DocumentLink2.create = create;
  1163. function is(value) {
  1164. var candidate = value;
  1165. return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
  1166. }
  1167. DocumentLink2.is = is;
  1168. })(DocumentLink || (DocumentLink = {}));
  1169. var SelectionRange;
  1170. (function(SelectionRange2) {
  1171. function create(range, parent) {
  1172. return { range, parent };
  1173. }
  1174. SelectionRange2.create = create;
  1175. function is(value) {
  1176. var candidate = value;
  1177. return candidate !== void 0 && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
  1178. }
  1179. SelectionRange2.is = is;
  1180. })(SelectionRange || (SelectionRange = {}));
  1181. var TextDocument;
  1182. (function(TextDocument2) {
  1183. function create(uri, languageId, version, content) {
  1184. return new FullTextDocument(uri, languageId, version, content);
  1185. }
  1186. TextDocument2.create = create;
  1187. function is(value) {
  1188. var candidate = value;
  1189. 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;
  1190. }
  1191. TextDocument2.is = is;
  1192. function applyEdits(document, edits) {
  1193. var text = document.getText();
  1194. var sortedEdits = mergeSort(edits, function(a, b) {
  1195. var diff = a.range.start.line - b.range.start.line;
  1196. if (diff === 0) {
  1197. return a.range.start.character - b.range.start.character;
  1198. }
  1199. return diff;
  1200. });
  1201. var lastModifiedOffset = text.length;
  1202. for (var i = sortedEdits.length - 1; i >= 0; i--) {
  1203. var e = sortedEdits[i];
  1204. var startOffset = document.offsetAt(e.range.start);
  1205. var endOffset = document.offsetAt(e.range.end);
  1206. if (endOffset <= lastModifiedOffset) {
  1207. text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
  1208. } else {
  1209. throw new Error("Overlapping edit");
  1210. }
  1211. lastModifiedOffset = startOffset;
  1212. }
  1213. return text;
  1214. }
  1215. TextDocument2.applyEdits = applyEdits;
  1216. function mergeSort(data, compare) {
  1217. if (data.length <= 1) {
  1218. return data;
  1219. }
  1220. var p = data.length / 2 | 0;
  1221. var left = data.slice(0, p);
  1222. var right = data.slice(p);
  1223. mergeSort(left, compare);
  1224. mergeSort(right, compare);
  1225. var leftIdx = 0;
  1226. var rightIdx = 0;
  1227. var i = 0;
  1228. while (leftIdx < left.length && rightIdx < right.length) {
  1229. var ret = compare(left[leftIdx], right[rightIdx]);
  1230. if (ret <= 0) {
  1231. data[i++] = left[leftIdx++];
  1232. } else {
  1233. data[i++] = right[rightIdx++];
  1234. }
  1235. }
  1236. while (leftIdx < left.length) {
  1237. data[i++] = left[leftIdx++];
  1238. }
  1239. while (rightIdx < right.length) {
  1240. data[i++] = right[rightIdx++];
  1241. }
  1242. return data;
  1243. }
  1244. })(TextDocument || (TextDocument = {}));
  1245. var FullTextDocument = function() {
  1246. function FullTextDocument2(uri, languageId, version, content) {
  1247. this._uri = uri;
  1248. this._languageId = languageId;
  1249. this._version = version;
  1250. this._content = content;
  1251. this._lineOffsets = void 0;
  1252. }
  1253. Object.defineProperty(FullTextDocument2.prototype, "uri", {
  1254. get: function() {
  1255. return this._uri;
  1256. },
  1257. enumerable: false,
  1258. configurable: true
  1259. });
  1260. Object.defineProperty(FullTextDocument2.prototype, "languageId", {
  1261. get: function() {
  1262. return this._languageId;
  1263. },
  1264. enumerable: false,
  1265. configurable: true
  1266. });
  1267. Object.defineProperty(FullTextDocument2.prototype, "version", {
  1268. get: function() {
  1269. return this._version;
  1270. },
  1271. enumerable: false,
  1272. configurable: true
  1273. });
  1274. FullTextDocument2.prototype.getText = function(range) {
  1275. if (range) {
  1276. var start = this.offsetAt(range.start);
  1277. var end = this.offsetAt(range.end);
  1278. return this._content.substring(start, end);
  1279. }
  1280. return this._content;
  1281. };
  1282. FullTextDocument2.prototype.update = function(event, version) {
  1283. this._content = event.text;
  1284. this._version = version;
  1285. this._lineOffsets = void 0;
  1286. };
  1287. FullTextDocument2.prototype.getLineOffsets = function() {
  1288. if (this._lineOffsets === void 0) {
  1289. var lineOffsets = [];
  1290. var text = this._content;
  1291. var isLineStart = true;
  1292. for (var i = 0; i < text.length; i++) {
  1293. if (isLineStart) {
  1294. lineOffsets.push(i);
  1295. isLineStart = false;
  1296. }
  1297. var ch = text.charAt(i);
  1298. isLineStart = ch === "\r" || ch === "\n";
  1299. if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
  1300. i++;
  1301. }
  1302. }
  1303. if (isLineStart && text.length > 0) {
  1304. lineOffsets.push(text.length);
  1305. }
  1306. this._lineOffsets = lineOffsets;
  1307. }
  1308. return this._lineOffsets;
  1309. };
  1310. FullTextDocument2.prototype.positionAt = function(offset) {
  1311. offset = Math.max(Math.min(offset, this._content.length), 0);
  1312. var lineOffsets = this.getLineOffsets();
  1313. var low = 0, high = lineOffsets.length;
  1314. if (high === 0) {
  1315. return Position.create(0, offset);
  1316. }
  1317. while (low < high) {
  1318. var mid = Math.floor((low + high) / 2);
  1319. if (lineOffsets[mid] > offset) {
  1320. high = mid;
  1321. } else {
  1322. low = mid + 1;
  1323. }
  1324. }
  1325. var line = low - 1;
  1326. return Position.create(line, offset - lineOffsets[line]);
  1327. };
  1328. FullTextDocument2.prototype.offsetAt = function(position) {
  1329. var lineOffsets = this.getLineOffsets();
  1330. if (position.line >= lineOffsets.length) {
  1331. return this._content.length;
  1332. } else if (position.line < 0) {
  1333. return 0;
  1334. }
  1335. var lineOffset = lineOffsets[position.line];
  1336. var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
  1337. return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
  1338. };
  1339. Object.defineProperty(FullTextDocument2.prototype, "lineCount", {
  1340. get: function() {
  1341. return this.getLineOffsets().length;
  1342. },
  1343. enumerable: false,
  1344. configurable: true
  1345. });
  1346. return FullTextDocument2;
  1347. }();
  1348. var Is;
  1349. (function(Is2) {
  1350. var toString = Object.prototype.toString;
  1351. function defined(value) {
  1352. return typeof value !== "undefined";
  1353. }
  1354. Is2.defined = defined;
  1355. function undefined2(value) {
  1356. return typeof value === "undefined";
  1357. }
  1358. Is2.undefined = undefined2;
  1359. function boolean(value) {
  1360. return value === true || value === false;
  1361. }
  1362. Is2.boolean = boolean;
  1363. function string(value) {
  1364. return toString.call(value) === "[object String]";
  1365. }
  1366. Is2.string = string;
  1367. function number(value) {
  1368. return toString.call(value) === "[object Number]";
  1369. }
  1370. Is2.number = number;
  1371. function numberRange(value, min, max) {
  1372. return toString.call(value) === "[object Number]" && min <= value && value <= max;
  1373. }
  1374. Is2.numberRange = numberRange;
  1375. function integer2(value) {
  1376. return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
  1377. }
  1378. Is2.integer = integer2;
  1379. function uinteger2(value) {
  1380. return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
  1381. }
  1382. Is2.uinteger = uinteger2;
  1383. function func(value) {
  1384. return toString.call(value) === "[object Function]";
  1385. }
  1386. Is2.func = func;
  1387. function objectLiteral(value) {
  1388. return value !== null && typeof value === "object";
  1389. }
  1390. Is2.objectLiteral = objectLiteral;
  1391. function typedArray(value, check) {
  1392. return Array.isArray(value) && value.every(check);
  1393. }
  1394. Is2.typedArray = typedArray;
  1395. })(Is || (Is = {}));
  1396. // src/language/common/lspLanguageFeatures.ts
  1397. var DiagnosticsAdapter = class {
  1398. constructor(_languageId, _worker, configChangeEvent) {
  1399. this._languageId = _languageId;
  1400. this._worker = _worker;
  1401. const onModelAdd = (model) => {
  1402. let modeId = model.getLanguageId();
  1403. if (modeId !== this._languageId) {
  1404. return;
  1405. }
  1406. let handle;
  1407. this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
  1408. window.clearTimeout(handle);
  1409. handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
  1410. });
  1411. this._doValidate(model.uri, modeId);
  1412. };
  1413. const onModelRemoved = (model) => {
  1414. monaco_editor_core_exports.editor.setModelMarkers(model, this._languageId, []);
  1415. let uriStr = model.uri.toString();
  1416. let listener = this._listener[uriStr];
  1417. if (listener) {
  1418. listener.dispose();
  1419. delete this._listener[uriStr];
  1420. }
  1421. };
  1422. this._disposables.push(monaco_editor_core_exports.editor.onDidCreateModel(onModelAdd));
  1423. this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel(onModelRemoved));
  1424. this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
  1425. onModelRemoved(event.model);
  1426. onModelAdd(event.model);
  1427. }));
  1428. this._disposables.push(configChangeEvent((_) => {
  1429. monaco_editor_core_exports.editor.getModels().forEach((model) => {
  1430. if (model.getLanguageId() === this._languageId) {
  1431. onModelRemoved(model);
  1432. onModelAdd(model);
  1433. }
  1434. });
  1435. }));
  1436. this._disposables.push({
  1437. dispose: () => {
  1438. monaco_editor_core_exports.editor.getModels().forEach(onModelRemoved);
  1439. for (let key in this._listener) {
  1440. this._listener[key].dispose();
  1441. }
  1442. }
  1443. });
  1444. monaco_editor_core_exports.editor.getModels().forEach(onModelAdd);
  1445. }
  1446. _disposables = [];
  1447. _listener = /* @__PURE__ */ Object.create(null);
  1448. dispose() {
  1449. this._disposables.forEach((d) => d && d.dispose());
  1450. this._disposables.length = 0;
  1451. }
  1452. _doValidate(resource, languageId) {
  1453. this._worker(resource).then((worker) => {
  1454. return worker.doValidation(resource.toString());
  1455. }).then((diagnostics) => {
  1456. const markers = diagnostics.map((d) => toDiagnostics(resource, d));
  1457. let model = monaco_editor_core_exports.editor.getModel(resource);
  1458. if (model && model.getLanguageId() === languageId) {
  1459. monaco_editor_core_exports.editor.setModelMarkers(model, languageId, markers);
  1460. }
  1461. }).then(void 0, (err) => {
  1462. console.error(err);
  1463. });
  1464. }
  1465. };
  1466. function toSeverity(lsSeverity) {
  1467. switch (lsSeverity) {
  1468. case DiagnosticSeverity.Error:
  1469. return monaco_editor_core_exports.MarkerSeverity.Error;
  1470. case DiagnosticSeverity.Warning:
  1471. return monaco_editor_core_exports.MarkerSeverity.Warning;
  1472. case DiagnosticSeverity.Information:
  1473. return monaco_editor_core_exports.MarkerSeverity.Info;
  1474. case DiagnosticSeverity.Hint:
  1475. return monaco_editor_core_exports.MarkerSeverity.Hint;
  1476. default:
  1477. return monaco_editor_core_exports.MarkerSeverity.Info;
  1478. }
  1479. }
  1480. function toDiagnostics(resource, diag) {
  1481. let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
  1482. return {
  1483. severity: toSeverity(diag.severity),
  1484. startLineNumber: diag.range.start.line + 1,
  1485. startColumn: diag.range.start.character + 1,
  1486. endLineNumber: diag.range.end.line + 1,
  1487. endColumn: diag.range.end.character + 1,
  1488. message: diag.message,
  1489. code,
  1490. source: diag.source
  1491. };
  1492. }
  1493. var CompletionAdapter = class {
  1494. constructor(_worker, _triggerCharacters) {
  1495. this._worker = _worker;
  1496. this._triggerCharacters = _triggerCharacters;
  1497. }
  1498. get triggerCharacters() {
  1499. return this._triggerCharacters;
  1500. }
  1501. provideCompletionItems(model, position, context, token) {
  1502. const resource = model.uri;
  1503. return this._worker(resource).then((worker) => {
  1504. return worker.doComplete(resource.toString(), fromPosition(position));
  1505. }).then((info) => {
  1506. if (!info) {
  1507. return;
  1508. }
  1509. const wordInfo = model.getWordUntilPosition(position);
  1510. const wordRange = new monaco_editor_core_exports.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
  1511. const items = info.items.map((entry) => {
  1512. const item = {
  1513. label: entry.label,
  1514. insertText: entry.insertText || entry.label,
  1515. sortText: entry.sortText,
  1516. filterText: entry.filterText,
  1517. documentation: entry.documentation,
  1518. detail: entry.detail,
  1519. command: toCommand(entry.command),
  1520. range: wordRange,
  1521. kind: toCompletionItemKind(entry.kind)
  1522. };
  1523. if (entry.textEdit) {
  1524. if (isInsertReplaceEdit(entry.textEdit)) {
  1525. item.range = {
  1526. insert: toRange(entry.textEdit.insert),
  1527. replace: toRange(entry.textEdit.replace)
  1528. };
  1529. } else {
  1530. item.range = toRange(entry.textEdit.range);
  1531. }
  1532. item.insertText = entry.textEdit.newText;
  1533. }
  1534. if (entry.additionalTextEdits) {
  1535. item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
  1536. }
  1537. if (entry.insertTextFormat === InsertTextFormat.Snippet) {
  1538. item.insertTextRules = monaco_editor_core_exports.languages.CompletionItemInsertTextRule.InsertAsSnippet;
  1539. }
  1540. return item;
  1541. });
  1542. return {
  1543. isIncomplete: info.isIncomplete,
  1544. suggestions: items
  1545. };
  1546. });
  1547. }
  1548. };
  1549. function fromPosition(position) {
  1550. if (!position) {
  1551. return void 0;
  1552. }
  1553. return { character: position.column - 1, line: position.lineNumber - 1 };
  1554. }
  1555. function fromRange(range) {
  1556. if (!range) {
  1557. return void 0;
  1558. }
  1559. return {
  1560. start: {
  1561. line: range.startLineNumber - 1,
  1562. character: range.startColumn - 1
  1563. },
  1564. end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
  1565. };
  1566. }
  1567. function toRange(range) {
  1568. if (!range) {
  1569. return void 0;
  1570. }
  1571. return new monaco_editor_core_exports.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
  1572. }
  1573. function isInsertReplaceEdit(edit) {
  1574. return typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined";
  1575. }
  1576. function toCompletionItemKind(kind) {
  1577. const mItemKind = monaco_editor_core_exports.languages.CompletionItemKind;
  1578. switch (kind) {
  1579. case CompletionItemKind.Text:
  1580. return mItemKind.Text;
  1581. case CompletionItemKind.Method:
  1582. return mItemKind.Method;
  1583. case CompletionItemKind.Function:
  1584. return mItemKind.Function;
  1585. case CompletionItemKind.Constructor:
  1586. return mItemKind.Constructor;
  1587. case CompletionItemKind.Field:
  1588. return mItemKind.Field;
  1589. case CompletionItemKind.Variable:
  1590. return mItemKind.Variable;
  1591. case CompletionItemKind.Class:
  1592. return mItemKind.Class;
  1593. case CompletionItemKind.Interface:
  1594. return mItemKind.Interface;
  1595. case CompletionItemKind.Module:
  1596. return mItemKind.Module;
  1597. case CompletionItemKind.Property:
  1598. return mItemKind.Property;
  1599. case CompletionItemKind.Unit:
  1600. return mItemKind.Unit;
  1601. case CompletionItemKind.Value:
  1602. return mItemKind.Value;
  1603. case CompletionItemKind.Enum:
  1604. return mItemKind.Enum;
  1605. case CompletionItemKind.Keyword:
  1606. return mItemKind.Keyword;
  1607. case CompletionItemKind.Snippet:
  1608. return mItemKind.Snippet;
  1609. case CompletionItemKind.Color:
  1610. return mItemKind.Color;
  1611. case CompletionItemKind.File:
  1612. return mItemKind.File;
  1613. case CompletionItemKind.Reference:
  1614. return mItemKind.Reference;
  1615. }
  1616. return mItemKind.Property;
  1617. }
  1618. function toTextEdit(textEdit) {
  1619. if (!textEdit) {
  1620. return void 0;
  1621. }
  1622. return {
  1623. range: toRange(textEdit.range),
  1624. text: textEdit.newText
  1625. };
  1626. }
  1627. function toCommand(c) {
  1628. return c && c.command === "editor.action.triggerSuggest" ? { id: c.command, title: c.title, arguments: c.arguments } : void 0;
  1629. }
  1630. var HoverAdapter = class {
  1631. constructor(_worker) {
  1632. this._worker = _worker;
  1633. }
  1634. provideHover(model, position, token) {
  1635. let resource = model.uri;
  1636. return this._worker(resource).then((worker) => {
  1637. return worker.doHover(resource.toString(), fromPosition(position));
  1638. }).then((info) => {
  1639. if (!info) {
  1640. return;
  1641. }
  1642. return {
  1643. range: toRange(info.range),
  1644. contents: toMarkedStringArray(info.contents)
  1645. };
  1646. });
  1647. }
  1648. };
  1649. function isMarkupContent(thing) {
  1650. return thing && typeof thing === "object" && typeof thing.kind === "string";
  1651. }
  1652. function toMarkdownString(entry) {
  1653. if (typeof entry === "string") {
  1654. return {
  1655. value: entry
  1656. };
  1657. }
  1658. if (isMarkupContent(entry)) {
  1659. if (entry.kind === "plaintext") {
  1660. return {
  1661. value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
  1662. };
  1663. }
  1664. return {
  1665. value: entry.value
  1666. };
  1667. }
  1668. return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
  1669. }
  1670. function toMarkedStringArray(contents) {
  1671. if (!contents) {
  1672. return void 0;
  1673. }
  1674. if (Array.isArray(contents)) {
  1675. return contents.map(toMarkdownString);
  1676. }
  1677. return [toMarkdownString(contents)];
  1678. }
  1679. var DocumentHighlightAdapter = class {
  1680. constructor(_worker) {
  1681. this._worker = _worker;
  1682. }
  1683. provideDocumentHighlights(model, position, token) {
  1684. const resource = model.uri;
  1685. return this._worker(resource).then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position))).then((entries) => {
  1686. if (!entries) {
  1687. return;
  1688. }
  1689. return entries.map((entry) => {
  1690. return {
  1691. range: toRange(entry.range),
  1692. kind: toDocumentHighlightKind(entry.kind)
  1693. };
  1694. });
  1695. });
  1696. }
  1697. };
  1698. function toDocumentHighlightKind(kind) {
  1699. switch (kind) {
  1700. case DocumentHighlightKind.Read:
  1701. return monaco_editor_core_exports.languages.DocumentHighlightKind.Read;
  1702. case DocumentHighlightKind.Write:
  1703. return monaco_editor_core_exports.languages.DocumentHighlightKind.Write;
  1704. case DocumentHighlightKind.Text:
  1705. return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
  1706. }
  1707. return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
  1708. }
  1709. var DefinitionAdapter = class {
  1710. constructor(_worker) {
  1711. this._worker = _worker;
  1712. }
  1713. provideDefinition(model, position, token) {
  1714. const resource = model.uri;
  1715. return this._worker(resource).then((worker) => {
  1716. return worker.findDefinition(resource.toString(), fromPosition(position));
  1717. }).then((definition) => {
  1718. if (!definition) {
  1719. return;
  1720. }
  1721. return [toLocation(definition)];
  1722. });
  1723. }
  1724. };
  1725. function toLocation(location) {
  1726. return {
  1727. uri: monaco_editor_core_exports.Uri.parse(location.uri),
  1728. range: toRange(location.range)
  1729. };
  1730. }
  1731. var ReferenceAdapter = class {
  1732. constructor(_worker) {
  1733. this._worker = _worker;
  1734. }
  1735. provideReferences(model, position, context, token) {
  1736. const resource = model.uri;
  1737. return this._worker(resource).then((worker) => {
  1738. return worker.findReferences(resource.toString(), fromPosition(position));
  1739. }).then((entries) => {
  1740. if (!entries) {
  1741. return;
  1742. }
  1743. return entries.map(toLocation);
  1744. });
  1745. }
  1746. };
  1747. var RenameAdapter = class {
  1748. constructor(_worker) {
  1749. this._worker = _worker;
  1750. }
  1751. provideRenameEdits(model, position, newName, token) {
  1752. const resource = model.uri;
  1753. return this._worker(resource).then((worker) => {
  1754. return worker.doRename(resource.toString(), fromPosition(position), newName);
  1755. }).then((edit) => {
  1756. return toWorkspaceEdit(edit);
  1757. });
  1758. }
  1759. };
  1760. function toWorkspaceEdit(edit) {
  1761. if (!edit || !edit.changes) {
  1762. return void 0;
  1763. }
  1764. let resourceEdits = [];
  1765. for (let uri in edit.changes) {
  1766. const _uri = monaco_editor_core_exports.Uri.parse(uri);
  1767. for (let e of edit.changes[uri]) {
  1768. resourceEdits.push({
  1769. resource: _uri,
  1770. versionId: void 0,
  1771. textEdit: {
  1772. range: toRange(e.range),
  1773. text: e.newText
  1774. }
  1775. });
  1776. }
  1777. }
  1778. return {
  1779. edits: resourceEdits
  1780. };
  1781. }
  1782. var DocumentSymbolAdapter = class {
  1783. constructor(_worker) {
  1784. this._worker = _worker;
  1785. }
  1786. provideDocumentSymbols(model, token) {
  1787. const resource = model.uri;
  1788. return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
  1789. if (!items) {
  1790. return;
  1791. }
  1792. return items.map((item) => ({
  1793. name: item.name,
  1794. detail: "",
  1795. containerName: item.containerName,
  1796. kind: toSymbolKind(item.kind),
  1797. range: toRange(item.location.range),
  1798. selectionRange: toRange(item.location.range),
  1799. tags: []
  1800. }));
  1801. });
  1802. }
  1803. };
  1804. function toSymbolKind(kind) {
  1805. let mKind = monaco_editor_core_exports.languages.SymbolKind;
  1806. switch (kind) {
  1807. case SymbolKind.File:
  1808. return mKind.Array;
  1809. case SymbolKind.Module:
  1810. return mKind.Module;
  1811. case SymbolKind.Namespace:
  1812. return mKind.Namespace;
  1813. case SymbolKind.Package:
  1814. return mKind.Package;
  1815. case SymbolKind.Class:
  1816. return mKind.Class;
  1817. case SymbolKind.Method:
  1818. return mKind.Method;
  1819. case SymbolKind.Property:
  1820. return mKind.Property;
  1821. case SymbolKind.Field:
  1822. return mKind.Field;
  1823. case SymbolKind.Constructor:
  1824. return mKind.Constructor;
  1825. case SymbolKind.Enum:
  1826. return mKind.Enum;
  1827. case SymbolKind.Interface:
  1828. return mKind.Interface;
  1829. case SymbolKind.Function:
  1830. return mKind.Function;
  1831. case SymbolKind.Variable:
  1832. return mKind.Variable;
  1833. case SymbolKind.Constant:
  1834. return mKind.Constant;
  1835. case SymbolKind.String:
  1836. return mKind.String;
  1837. case SymbolKind.Number:
  1838. return mKind.Number;
  1839. case SymbolKind.Boolean:
  1840. return mKind.Boolean;
  1841. case SymbolKind.Array:
  1842. return mKind.Array;
  1843. }
  1844. return mKind.Function;
  1845. }
  1846. var DocumentLinkAdapter = class {
  1847. constructor(_worker) {
  1848. this._worker = _worker;
  1849. }
  1850. provideLinks(model, token) {
  1851. const resource = model.uri;
  1852. return this._worker(resource).then((worker) => worker.findDocumentLinks(resource.toString())).then((items) => {
  1853. if (!items) {
  1854. return;
  1855. }
  1856. return {
  1857. links: items.map((item) => ({
  1858. range: toRange(item.range),
  1859. url: item.target
  1860. }))
  1861. };
  1862. });
  1863. }
  1864. };
  1865. var DocumentFormattingEditProvider = class {
  1866. constructor(_worker) {
  1867. this._worker = _worker;
  1868. }
  1869. provideDocumentFormattingEdits(model, options, token) {
  1870. const resource = model.uri;
  1871. return this._worker(resource).then((worker) => {
  1872. return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
  1873. if (!edits || edits.length === 0) {
  1874. return;
  1875. }
  1876. return edits.map(toTextEdit);
  1877. });
  1878. });
  1879. }
  1880. };
  1881. var DocumentRangeFormattingEditProvider = class {
  1882. constructor(_worker) {
  1883. this._worker = _worker;
  1884. }
  1885. provideDocumentRangeFormattingEdits(model, range, options, token) {
  1886. const resource = model.uri;
  1887. return this._worker(resource).then((worker) => {
  1888. return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
  1889. if (!edits || edits.length === 0) {
  1890. return;
  1891. }
  1892. return edits.map(toTextEdit);
  1893. });
  1894. });
  1895. }
  1896. };
  1897. function fromFormattingOptions(options) {
  1898. return {
  1899. tabSize: options.tabSize,
  1900. insertSpaces: options.insertSpaces
  1901. };
  1902. }
  1903. var DocumentColorAdapter = class {
  1904. constructor(_worker) {
  1905. this._worker = _worker;
  1906. }
  1907. provideDocumentColors(model, token) {
  1908. const resource = model.uri;
  1909. return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
  1910. if (!infos) {
  1911. return;
  1912. }
  1913. return infos.map((item) => ({
  1914. color: item.color,
  1915. range: toRange(item.range)
  1916. }));
  1917. });
  1918. }
  1919. provideColorPresentations(model, info, token) {
  1920. const resource = model.uri;
  1921. return this._worker(resource).then((worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then((presentations) => {
  1922. if (!presentations) {
  1923. return;
  1924. }
  1925. return presentations.map((presentation) => {
  1926. let item = {
  1927. label: presentation.label
  1928. };
  1929. if (presentation.textEdit) {
  1930. item.textEdit = toTextEdit(presentation.textEdit);
  1931. }
  1932. if (presentation.additionalTextEdits) {
  1933. item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
  1934. }
  1935. return item;
  1936. });
  1937. });
  1938. }
  1939. };
  1940. var FoldingRangeAdapter = class {
  1941. constructor(_worker) {
  1942. this._worker = _worker;
  1943. }
  1944. provideFoldingRanges(model, context, token) {
  1945. const resource = model.uri;
  1946. return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
  1947. if (!ranges) {
  1948. return;
  1949. }
  1950. return ranges.map((range) => {
  1951. const result = {
  1952. start: range.startLine + 1,
  1953. end: range.endLine + 1
  1954. };
  1955. if (typeof range.kind !== "undefined") {
  1956. result.kind = toFoldingRangeKind(range.kind);
  1957. }
  1958. return result;
  1959. });
  1960. });
  1961. }
  1962. };
  1963. function toFoldingRangeKind(kind) {
  1964. switch (kind) {
  1965. case FoldingRangeKind.Comment:
  1966. return monaco_editor_core_exports.languages.FoldingRangeKind.Comment;
  1967. case FoldingRangeKind.Imports:
  1968. return monaco_editor_core_exports.languages.FoldingRangeKind.Imports;
  1969. case FoldingRangeKind.Region:
  1970. return monaco_editor_core_exports.languages.FoldingRangeKind.Region;
  1971. }
  1972. return void 0;
  1973. }
  1974. var SelectionRangeAdapter = class {
  1975. constructor(_worker) {
  1976. this._worker = _worker;
  1977. }
  1978. provideSelectionRanges(model, positions, token) {
  1979. const resource = model.uri;
  1980. return this._worker(resource).then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition))).then((selectionRanges) => {
  1981. if (!selectionRanges) {
  1982. return;
  1983. }
  1984. return selectionRanges.map((selectionRange) => {
  1985. const result = [];
  1986. while (selectionRange) {
  1987. result.push({ range: toRange(selectionRange.range) });
  1988. selectionRange = selectionRange.parent;
  1989. }
  1990. return result;
  1991. });
  1992. });
  1993. }
  1994. };
  1995. // node_modules/jsonc-parser/lib/esm/impl/scanner.js
  1996. function createScanner(text, ignoreTrivia) {
  1997. if (ignoreTrivia === void 0) {
  1998. ignoreTrivia = false;
  1999. }
  2000. var len = text.length;
  2001. var pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
  2002. function scanHexDigits(count, exact) {
  2003. var digits = 0;
  2004. var value2 = 0;
  2005. while (digits < count || !exact) {
  2006. var ch = text.charCodeAt(pos);
  2007. if (ch >= 48 && ch <= 57) {
  2008. value2 = value2 * 16 + ch - 48;
  2009. } else if (ch >= 65 && ch <= 70) {
  2010. value2 = value2 * 16 + ch - 65 + 10;
  2011. } else if (ch >= 97 && ch <= 102) {
  2012. value2 = value2 * 16 + ch - 97 + 10;
  2013. } else {
  2014. break;
  2015. }
  2016. pos++;
  2017. digits++;
  2018. }
  2019. if (digits < count) {
  2020. value2 = -1;
  2021. }
  2022. return value2;
  2023. }
  2024. function setPosition(newPosition) {
  2025. pos = newPosition;
  2026. value = "";
  2027. tokenOffset = 0;
  2028. token = 16;
  2029. scanError = 0;
  2030. }
  2031. function scanNumber() {
  2032. var start = pos;
  2033. if (text.charCodeAt(pos) === 48) {
  2034. pos++;
  2035. } else {
  2036. pos++;
  2037. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  2038. pos++;
  2039. }
  2040. }
  2041. if (pos < text.length && text.charCodeAt(pos) === 46) {
  2042. pos++;
  2043. if (pos < text.length && isDigit(text.charCodeAt(pos))) {
  2044. pos++;
  2045. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  2046. pos++;
  2047. }
  2048. } else {
  2049. scanError = 3;
  2050. return text.substring(start, pos);
  2051. }
  2052. }
  2053. var end = pos;
  2054. if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
  2055. pos++;
  2056. if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
  2057. pos++;
  2058. }
  2059. if (pos < text.length && isDigit(text.charCodeAt(pos))) {
  2060. pos++;
  2061. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  2062. pos++;
  2063. }
  2064. end = pos;
  2065. } else {
  2066. scanError = 3;
  2067. }
  2068. }
  2069. return text.substring(start, end);
  2070. }
  2071. function scanString() {
  2072. var result = "", start = pos;
  2073. while (true) {
  2074. if (pos >= len) {
  2075. result += text.substring(start, pos);
  2076. scanError = 2;
  2077. break;
  2078. }
  2079. var ch = text.charCodeAt(pos);
  2080. if (ch === 34) {
  2081. result += text.substring(start, pos);
  2082. pos++;
  2083. break;
  2084. }
  2085. if (ch === 92) {
  2086. result += text.substring(start, pos);
  2087. pos++;
  2088. if (pos >= len) {
  2089. scanError = 2;
  2090. break;
  2091. }
  2092. var ch2 = text.charCodeAt(pos++);
  2093. switch (ch2) {
  2094. case 34:
  2095. result += '"';
  2096. break;
  2097. case 92:
  2098. result += "\\";
  2099. break;
  2100. case 47:
  2101. result += "/";
  2102. break;
  2103. case 98:
  2104. result += "\b";
  2105. break;
  2106. case 102:
  2107. result += "\f";
  2108. break;
  2109. case 110:
  2110. result += "\n";
  2111. break;
  2112. case 114:
  2113. result += "\r";
  2114. break;
  2115. case 116:
  2116. result += " ";
  2117. break;
  2118. case 117:
  2119. var ch3 = scanHexDigits(4, true);
  2120. if (ch3 >= 0) {
  2121. result += String.fromCharCode(ch3);
  2122. } else {
  2123. scanError = 4;
  2124. }
  2125. break;
  2126. default:
  2127. scanError = 5;
  2128. }
  2129. start = pos;
  2130. continue;
  2131. }
  2132. if (ch >= 0 && ch <= 31) {
  2133. if (isLineBreak(ch)) {
  2134. result += text.substring(start, pos);
  2135. scanError = 2;
  2136. break;
  2137. } else {
  2138. scanError = 6;
  2139. }
  2140. }
  2141. pos++;
  2142. }
  2143. return result;
  2144. }
  2145. function scanNext() {
  2146. value = "";
  2147. scanError = 0;
  2148. tokenOffset = pos;
  2149. lineStartOffset = lineNumber;
  2150. prevTokenLineStartOffset = tokenLineStartOffset;
  2151. if (pos >= len) {
  2152. tokenOffset = len;
  2153. return token = 17;
  2154. }
  2155. var code = text.charCodeAt(pos);
  2156. if (isWhiteSpace(code)) {
  2157. do {
  2158. pos++;
  2159. value += String.fromCharCode(code);
  2160. code = text.charCodeAt(pos);
  2161. } while (isWhiteSpace(code));
  2162. return token = 15;
  2163. }
  2164. if (isLineBreak(code)) {
  2165. pos++;
  2166. value += String.fromCharCode(code);
  2167. if (code === 13 && text.charCodeAt(pos) === 10) {
  2168. pos++;
  2169. value += "\n";
  2170. }
  2171. lineNumber++;
  2172. tokenLineStartOffset = pos;
  2173. return token = 14;
  2174. }
  2175. switch (code) {
  2176. case 123:
  2177. pos++;
  2178. return token = 1;
  2179. case 125:
  2180. pos++;
  2181. return token = 2;
  2182. case 91:
  2183. pos++;
  2184. return token = 3;
  2185. case 93:
  2186. pos++;
  2187. return token = 4;
  2188. case 58:
  2189. pos++;
  2190. return token = 6;
  2191. case 44:
  2192. pos++;
  2193. return token = 5;
  2194. case 34:
  2195. pos++;
  2196. value = scanString();
  2197. return token = 10;
  2198. case 47:
  2199. var start = pos - 1;
  2200. if (text.charCodeAt(pos + 1) === 47) {
  2201. pos += 2;
  2202. while (pos < len) {
  2203. if (isLineBreak(text.charCodeAt(pos))) {
  2204. break;
  2205. }
  2206. pos++;
  2207. }
  2208. value = text.substring(start, pos);
  2209. return token = 12;
  2210. }
  2211. if (text.charCodeAt(pos + 1) === 42) {
  2212. pos += 2;
  2213. var safeLength = len - 1;
  2214. var commentClosed = false;
  2215. while (pos < safeLength) {
  2216. var ch = text.charCodeAt(pos);
  2217. if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
  2218. pos += 2;
  2219. commentClosed = true;
  2220. break;
  2221. }
  2222. pos++;
  2223. if (isLineBreak(ch)) {
  2224. if (ch === 13 && text.charCodeAt(pos) === 10) {
  2225. pos++;
  2226. }
  2227. lineNumber++;
  2228. tokenLineStartOffset = pos;
  2229. }
  2230. }
  2231. if (!commentClosed) {
  2232. pos++;
  2233. scanError = 1;
  2234. }
  2235. value = text.substring(start, pos);
  2236. return token = 13;
  2237. }
  2238. value += String.fromCharCode(code);
  2239. pos++;
  2240. return token = 16;
  2241. case 45:
  2242. value += String.fromCharCode(code);
  2243. pos++;
  2244. if (pos === len || !isDigit(text.charCodeAt(pos))) {
  2245. return token = 16;
  2246. }
  2247. case 48:
  2248. case 49:
  2249. case 50:
  2250. case 51:
  2251. case 52:
  2252. case 53:
  2253. case 54:
  2254. case 55:
  2255. case 56:
  2256. case 57:
  2257. value += scanNumber();
  2258. return token = 11;
  2259. default:
  2260. while (pos < len && isUnknownContentCharacter(code)) {
  2261. pos++;
  2262. code = text.charCodeAt(pos);
  2263. }
  2264. if (tokenOffset !== pos) {
  2265. value = text.substring(tokenOffset, pos);
  2266. switch (value) {
  2267. case "true":
  2268. return token = 8;
  2269. case "false":
  2270. return token = 9;
  2271. case "null":
  2272. return token = 7;
  2273. }
  2274. return token = 16;
  2275. }
  2276. value += String.fromCharCode(code);
  2277. pos++;
  2278. return token = 16;
  2279. }
  2280. }
  2281. function isUnknownContentCharacter(code) {
  2282. if (isWhiteSpace(code) || isLineBreak(code)) {
  2283. return false;
  2284. }
  2285. switch (code) {
  2286. case 125:
  2287. case 93:
  2288. case 123:
  2289. case 91:
  2290. case 34:
  2291. case 58:
  2292. case 44:
  2293. case 47:
  2294. return false;
  2295. }
  2296. return true;
  2297. }
  2298. function scanNextNonTrivia() {
  2299. var result;
  2300. do {
  2301. result = scanNext();
  2302. } while (result >= 12 && result <= 15);
  2303. return result;
  2304. }
  2305. return {
  2306. setPosition,
  2307. getPosition: function() {
  2308. return pos;
  2309. },
  2310. scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
  2311. getToken: function() {
  2312. return token;
  2313. },
  2314. getTokenValue: function() {
  2315. return value;
  2316. },
  2317. getTokenOffset: function() {
  2318. return tokenOffset;
  2319. },
  2320. getTokenLength: function() {
  2321. return pos - tokenOffset;
  2322. },
  2323. getTokenStartLine: function() {
  2324. return lineStartOffset;
  2325. },
  2326. getTokenStartCharacter: function() {
  2327. return tokenOffset - prevTokenLineStartOffset;
  2328. },
  2329. getTokenError: function() {
  2330. return scanError;
  2331. }
  2332. };
  2333. }
  2334. function isWhiteSpace(ch) {
  2335. return ch === 32 || ch === 9 || ch === 11 || ch === 12 || ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279;
  2336. }
  2337. function isLineBreak(ch) {
  2338. return ch === 10 || ch === 13 || ch === 8232 || ch === 8233;
  2339. }
  2340. function isDigit(ch) {
  2341. return ch >= 48 && ch <= 57;
  2342. }
  2343. // node_modules/jsonc-parser/lib/esm/impl/parser.js
  2344. var ParseOptions;
  2345. (function(ParseOptions2) {
  2346. ParseOptions2.DEFAULT = {
  2347. allowTrailingComma: false
  2348. };
  2349. })(ParseOptions || (ParseOptions = {}));
  2350. // node_modules/jsonc-parser/lib/esm/main.js
  2351. var createScanner2 = createScanner;
  2352. // src/language/json/tokenization.ts
  2353. function createTokenizationSupport(supportComments) {
  2354. return {
  2355. getInitialState: () => new JSONState(null, null, false, null),
  2356. tokenize: (line, state) => tokenize(supportComments, line, state)
  2357. };
  2358. }
  2359. var TOKEN_DELIM_OBJECT = "delimiter.bracket.json";
  2360. var TOKEN_DELIM_ARRAY = "delimiter.array.json";
  2361. var TOKEN_DELIM_COLON = "delimiter.colon.json";
  2362. var TOKEN_DELIM_COMMA = "delimiter.comma.json";
  2363. var TOKEN_VALUE_BOOLEAN = "keyword.json";
  2364. var TOKEN_VALUE_NULL = "keyword.json";
  2365. var TOKEN_VALUE_STRING = "string.value.json";
  2366. var TOKEN_VALUE_NUMBER = "number.json";
  2367. var TOKEN_PROPERTY_NAME = "string.key.json";
  2368. var TOKEN_COMMENT_BLOCK = "comment.block.json";
  2369. var TOKEN_COMMENT_LINE = "comment.line.json";
  2370. var ParentsStack = class {
  2371. constructor(parent, type) {
  2372. this.parent = parent;
  2373. this.type = type;
  2374. }
  2375. static pop(parents) {
  2376. if (parents) {
  2377. return parents.parent;
  2378. }
  2379. return null;
  2380. }
  2381. static push(parents, type) {
  2382. return new ParentsStack(parents, type);
  2383. }
  2384. static equals(a, b) {
  2385. if (!a && !b) {
  2386. return true;
  2387. }
  2388. if (!a || !b) {
  2389. return false;
  2390. }
  2391. while (a && b) {
  2392. if (a === b) {
  2393. return true;
  2394. }
  2395. if (a.type !== b.type) {
  2396. return false;
  2397. }
  2398. a = a.parent;
  2399. b = b.parent;
  2400. }
  2401. return true;
  2402. }
  2403. };
  2404. var JSONState = class {
  2405. _state;
  2406. scanError;
  2407. lastWasColon;
  2408. parents;
  2409. constructor(state, scanError, lastWasColon, parents) {
  2410. this._state = state;
  2411. this.scanError = scanError;
  2412. this.lastWasColon = lastWasColon;
  2413. this.parents = parents;
  2414. }
  2415. clone() {
  2416. return new JSONState(this._state, this.scanError, this.lastWasColon, this.parents);
  2417. }
  2418. equals(other) {
  2419. if (other === this) {
  2420. return true;
  2421. }
  2422. if (!other || !(other instanceof JSONState)) {
  2423. return false;
  2424. }
  2425. return this.scanError === other.scanError && this.lastWasColon === other.lastWasColon && ParentsStack.equals(this.parents, other.parents);
  2426. }
  2427. getStateData() {
  2428. return this._state;
  2429. }
  2430. setStateData(state) {
  2431. this._state = state;
  2432. }
  2433. };
  2434. function tokenize(comments, line, state, offsetDelta = 0) {
  2435. let numberOfInsertedCharacters = 0;
  2436. let adjustOffset = false;
  2437. switch (state.scanError) {
  2438. case 2 /* UnexpectedEndOfString */:
  2439. line = '"' + line;
  2440. numberOfInsertedCharacters = 1;
  2441. break;
  2442. case 1 /* UnexpectedEndOfComment */:
  2443. line = "/*" + line;
  2444. numberOfInsertedCharacters = 2;
  2445. break;
  2446. }
  2447. const scanner = createScanner2(line);
  2448. let lastWasColon = state.lastWasColon;
  2449. let parents = state.parents;
  2450. const ret = {
  2451. tokens: [],
  2452. endState: state.clone()
  2453. };
  2454. while (true) {
  2455. let offset = offsetDelta + scanner.getPosition();
  2456. let type = "";
  2457. const kind = scanner.scan();
  2458. if (kind === 17 /* EOF */) {
  2459. break;
  2460. }
  2461. if (offset === offsetDelta + scanner.getPosition()) {
  2462. throw new Error("Scanner did not advance, next 3 characters are: " + line.substr(scanner.getPosition(), 3));
  2463. }
  2464. if (adjustOffset) {
  2465. offset -= numberOfInsertedCharacters;
  2466. }
  2467. adjustOffset = numberOfInsertedCharacters > 0;
  2468. switch (kind) {
  2469. case 1 /* OpenBraceToken */:
  2470. parents = ParentsStack.push(parents, 0 /* Object */);
  2471. type = TOKEN_DELIM_OBJECT;
  2472. lastWasColon = false;
  2473. break;
  2474. case 2 /* CloseBraceToken */:
  2475. parents = ParentsStack.pop(parents);
  2476. type = TOKEN_DELIM_OBJECT;
  2477. lastWasColon = false;
  2478. break;
  2479. case 3 /* OpenBracketToken */:
  2480. parents = ParentsStack.push(parents, 1 /* Array */);
  2481. type = TOKEN_DELIM_ARRAY;
  2482. lastWasColon = false;
  2483. break;
  2484. case 4 /* CloseBracketToken */:
  2485. parents = ParentsStack.pop(parents);
  2486. type = TOKEN_DELIM_ARRAY;
  2487. lastWasColon = false;
  2488. break;
  2489. case 6 /* ColonToken */:
  2490. type = TOKEN_DELIM_COLON;
  2491. lastWasColon = true;
  2492. break;
  2493. case 5 /* CommaToken */:
  2494. type = TOKEN_DELIM_COMMA;
  2495. lastWasColon = false;
  2496. break;
  2497. case 8 /* TrueKeyword */:
  2498. case 9 /* FalseKeyword */:
  2499. type = TOKEN_VALUE_BOOLEAN;
  2500. lastWasColon = false;
  2501. break;
  2502. case 7 /* NullKeyword */:
  2503. type = TOKEN_VALUE_NULL;
  2504. lastWasColon = false;
  2505. break;
  2506. case 10 /* StringLiteral */:
  2507. const currentParent = parents ? parents.type : 0 /* Object */;
  2508. const inArray = currentParent === 1 /* Array */;
  2509. type = lastWasColon || inArray ? TOKEN_VALUE_STRING : TOKEN_PROPERTY_NAME;
  2510. lastWasColon = false;
  2511. break;
  2512. case 11 /* NumericLiteral */:
  2513. type = TOKEN_VALUE_NUMBER;
  2514. lastWasColon = false;
  2515. break;
  2516. }
  2517. if (comments) {
  2518. switch (kind) {
  2519. case 12 /* LineCommentTrivia */:
  2520. type = TOKEN_COMMENT_LINE;
  2521. break;
  2522. case 13 /* BlockCommentTrivia */:
  2523. type = TOKEN_COMMENT_BLOCK;
  2524. break;
  2525. }
  2526. }
  2527. ret.endState = new JSONState(state.getStateData(), scanner.getTokenError(), lastWasColon, parents);
  2528. ret.tokens.push({
  2529. startIndex: offset,
  2530. scopes: type
  2531. });
  2532. }
  2533. return ret;
  2534. }
  2535. // src/language/json/jsonMode.ts
  2536. var JSONDiagnosticsAdapter = class extends DiagnosticsAdapter {
  2537. constructor(languageId, worker, defaults) {
  2538. super(languageId, worker, defaults.onDidChange);
  2539. this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel((model) => {
  2540. this._resetSchema(model.uri);
  2541. }));
  2542. this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
  2543. this._resetSchema(event.model.uri);
  2544. }));
  2545. }
  2546. _resetSchema(resource) {
  2547. this._worker().then((worker) => {
  2548. worker.resetSchema(resource.toString());
  2549. });
  2550. }
  2551. };
  2552. function setupMode(defaults) {
  2553. const disposables = [];
  2554. const providers = [];
  2555. const client = new WorkerManager(defaults);
  2556. disposables.push(client);
  2557. const worker = (...uris) => {
  2558. return client.getLanguageServiceWorker(...uris);
  2559. };
  2560. function registerProviders() {
  2561. const { languageId, modeConfiguration: modeConfiguration2 } = defaults;
  2562. disposeAll(providers);
  2563. if (modeConfiguration2.documentFormattingEdits) {
  2564. providers.push(monaco_editor_core_exports.languages.registerDocumentFormattingEditProvider(languageId, new DocumentFormattingEditProvider(worker)));
  2565. }
  2566. if (modeConfiguration2.documentRangeFormattingEdits) {
  2567. providers.push(monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(languageId, new DocumentRangeFormattingEditProvider(worker)));
  2568. }
  2569. if (modeConfiguration2.completionItems) {
  2570. providers.push(monaco_editor_core_exports.languages.registerCompletionItemProvider(languageId, new CompletionAdapter(worker, [" ", ":", '"'])));
  2571. }
  2572. if (modeConfiguration2.hovers) {
  2573. providers.push(monaco_editor_core_exports.languages.registerHoverProvider(languageId, new HoverAdapter(worker)));
  2574. }
  2575. if (modeConfiguration2.documentSymbols) {
  2576. providers.push(monaco_editor_core_exports.languages.registerDocumentSymbolProvider(languageId, new DocumentSymbolAdapter(worker)));
  2577. }
  2578. if (modeConfiguration2.tokens) {
  2579. providers.push(monaco_editor_core_exports.languages.setTokensProvider(languageId, createTokenizationSupport(true)));
  2580. }
  2581. if (modeConfiguration2.colors) {
  2582. providers.push(monaco_editor_core_exports.languages.registerColorProvider(languageId, new DocumentColorAdapter(worker)));
  2583. }
  2584. if (modeConfiguration2.foldingRanges) {
  2585. providers.push(monaco_editor_core_exports.languages.registerFoldingRangeProvider(languageId, new FoldingRangeAdapter(worker)));
  2586. }
  2587. if (modeConfiguration2.diagnostics) {
  2588. providers.push(new JSONDiagnosticsAdapter(languageId, worker, defaults));
  2589. }
  2590. if (modeConfiguration2.selectionRanges) {
  2591. providers.push(monaco_editor_core_exports.languages.registerSelectionRangeProvider(languageId, new SelectionRangeAdapter(worker)));
  2592. }
  2593. }
  2594. registerProviders();
  2595. disposables.push(monaco_editor_core_exports.languages.setLanguageConfiguration(defaults.languageId, richEditConfiguration));
  2596. let modeConfiguration = defaults.modeConfiguration;
  2597. defaults.onDidChange((newDefaults) => {
  2598. if (newDefaults.modeConfiguration !== modeConfiguration) {
  2599. modeConfiguration = newDefaults.modeConfiguration;
  2600. registerProviders();
  2601. }
  2602. });
  2603. disposables.push(asDisposable(providers));
  2604. return asDisposable(disposables);
  2605. }
  2606. function asDisposable(disposables) {
  2607. return { dispose: () => disposeAll(disposables) };
  2608. }
  2609. function disposeAll(disposables) {
  2610. while (disposables.length) {
  2611. disposables.pop().dispose();
  2612. }
  2613. }
  2614. var richEditConfiguration = {
  2615. wordPattern: /(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,
  2616. comments: {
  2617. lineComment: "//",
  2618. blockComment: ["/*", "*/"]
  2619. },
  2620. brackets: [
  2621. ["{", "}"],
  2622. ["[", "]"]
  2623. ],
  2624. autoClosingPairs: [
  2625. { open: "{", close: "}", notIn: ["string"] },
  2626. { open: "[", close: "]", notIn: ["string"] },
  2627. { open: '"', close: '"', notIn: ["string"] }
  2628. ]
  2629. };
  2630. return __toCommonJS(jsonMode_exports);
  2631. })();
  2632. return moduleExports;
  2633. });