jsonMode-JB3Z7BUW.js 82 KB

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