cssMode-WPBTKTDP.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037
  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/css/cssMode.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/css/cssWorker",
  66. label: this._defaults.languageId,
  67. createData: {
  68. options: this._defaults.options,
  69. languageId: this._defaults.languageId
  70. }
  71. });
  72. this._client = this._worker.getProxy();
  73. }
  74. return this._client;
  75. }
  76. getLanguageServiceWorker(...resources) {
  77. let _client;
  78. return this._getClient().then((client) => {
  79. _client = client;
  80. }).then((_) => {
  81. if (this._worker) {
  82. return this._worker.withSyncedResources(resources);
  83. }
  84. }).then((_) => _client);
  85. }
  86. };
  87. var integer;
  88. (function(integer2) {
  89. integer2.MIN_VALUE = -2147483648;
  90. integer2.MAX_VALUE = 2147483647;
  91. })(integer || (integer = {}));
  92. var uinteger;
  93. (function(uinteger2) {
  94. uinteger2.MIN_VALUE = 0;
  95. uinteger2.MAX_VALUE = 2147483647;
  96. })(uinteger || (uinteger = {}));
  97. var Position;
  98. (function(Position3) {
  99. function create(line, character) {
  100. if (line === Number.MAX_VALUE) {
  101. line = uinteger.MAX_VALUE;
  102. }
  103. if (character === Number.MAX_VALUE) {
  104. character = uinteger.MAX_VALUE;
  105. }
  106. return { line, character };
  107. }
  108. Position3.create = create;
  109. function is(value) {
  110. var candidate = value;
  111. return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
  112. }
  113. Position3.is = is;
  114. })(Position || (Position = {}));
  115. var Range;
  116. (function(Range3) {
  117. function create(one, two, three, four) {
  118. if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
  119. return { start: Position.create(one, two), end: Position.create(three, four) };
  120. } else if (Position.is(one) && Position.is(two)) {
  121. return { start: one, end: two };
  122. } else {
  123. throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
  124. }
  125. }
  126. Range3.create = create;
  127. function is(value) {
  128. var candidate = value;
  129. return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
  130. }
  131. Range3.is = is;
  132. })(Range || (Range = {}));
  133. var Location;
  134. (function(Location2) {
  135. function create(uri, range) {
  136. return { uri, range };
  137. }
  138. Location2.create = create;
  139. function is(value) {
  140. var candidate = value;
  141. return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
  142. }
  143. Location2.is = is;
  144. })(Location || (Location = {}));
  145. var LocationLink;
  146. (function(LocationLink2) {
  147. function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
  148. return { targetUri, targetRange, targetSelectionRange, originSelectionRange };
  149. }
  150. LocationLink2.create = create;
  151. function is(value) {
  152. var candidate = value;
  153. 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));
  154. }
  155. LocationLink2.is = is;
  156. })(LocationLink || (LocationLink = {}));
  157. var Color;
  158. (function(Color2) {
  159. function create(red, green, blue, alpha) {
  160. return {
  161. red,
  162. green,
  163. blue,
  164. alpha
  165. };
  166. }
  167. Color2.create = create;
  168. function is(value) {
  169. var candidate = value;
  170. 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);
  171. }
  172. Color2.is = is;
  173. })(Color || (Color = {}));
  174. var ColorInformation;
  175. (function(ColorInformation2) {
  176. function create(range, color) {
  177. return {
  178. range,
  179. color
  180. };
  181. }
  182. ColorInformation2.create = create;
  183. function is(value) {
  184. var candidate = value;
  185. return Range.is(candidate.range) && Color.is(candidate.color);
  186. }
  187. ColorInformation2.is = is;
  188. })(ColorInformation || (ColorInformation = {}));
  189. var ColorPresentation;
  190. (function(ColorPresentation2) {
  191. function create(label, textEdit, additionalTextEdits) {
  192. return {
  193. label,
  194. textEdit,
  195. additionalTextEdits
  196. };
  197. }
  198. ColorPresentation2.create = create;
  199. function is(value) {
  200. var candidate = value;
  201. return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
  202. }
  203. ColorPresentation2.is = is;
  204. })(ColorPresentation || (ColorPresentation = {}));
  205. var FoldingRangeKind;
  206. (function(FoldingRangeKind2) {
  207. FoldingRangeKind2["Comment"] = "comment";
  208. FoldingRangeKind2["Imports"] = "imports";
  209. FoldingRangeKind2["Region"] = "region";
  210. })(FoldingRangeKind || (FoldingRangeKind = {}));
  211. var FoldingRange;
  212. (function(FoldingRange2) {
  213. function create(startLine, endLine, startCharacter, endCharacter, kind) {
  214. var result = {
  215. startLine,
  216. endLine
  217. };
  218. if (Is.defined(startCharacter)) {
  219. result.startCharacter = startCharacter;
  220. }
  221. if (Is.defined(endCharacter)) {
  222. result.endCharacter = endCharacter;
  223. }
  224. if (Is.defined(kind)) {
  225. result.kind = kind;
  226. }
  227. return result;
  228. }
  229. FoldingRange2.create = create;
  230. function is(value) {
  231. var candidate = value;
  232. 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));
  233. }
  234. FoldingRange2.is = is;
  235. })(FoldingRange || (FoldingRange = {}));
  236. var DiagnosticRelatedInformation;
  237. (function(DiagnosticRelatedInformation2) {
  238. function create(location, message) {
  239. return {
  240. location,
  241. message
  242. };
  243. }
  244. DiagnosticRelatedInformation2.create = create;
  245. function is(value) {
  246. var candidate = value;
  247. return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
  248. }
  249. DiagnosticRelatedInformation2.is = is;
  250. })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
  251. var DiagnosticSeverity;
  252. (function(DiagnosticSeverity2) {
  253. DiagnosticSeverity2.Error = 1;
  254. DiagnosticSeverity2.Warning = 2;
  255. DiagnosticSeverity2.Information = 3;
  256. DiagnosticSeverity2.Hint = 4;
  257. })(DiagnosticSeverity || (DiagnosticSeverity = {}));
  258. var DiagnosticTag;
  259. (function(DiagnosticTag2) {
  260. DiagnosticTag2.Unnecessary = 1;
  261. DiagnosticTag2.Deprecated = 2;
  262. })(DiagnosticTag || (DiagnosticTag = {}));
  263. var CodeDescription;
  264. (function(CodeDescription2) {
  265. function is(value) {
  266. var candidate = value;
  267. return candidate !== void 0 && candidate !== null && Is.string(candidate.href);
  268. }
  269. CodeDescription2.is = is;
  270. })(CodeDescription || (CodeDescription = {}));
  271. var Diagnostic;
  272. (function(Diagnostic2) {
  273. function create(range, message, severity, code, source, relatedInformation) {
  274. var result = { range, message };
  275. if (Is.defined(severity)) {
  276. result.severity = severity;
  277. }
  278. if (Is.defined(code)) {
  279. result.code = code;
  280. }
  281. if (Is.defined(source)) {
  282. result.source = source;
  283. }
  284. if (Is.defined(relatedInformation)) {
  285. result.relatedInformation = relatedInformation;
  286. }
  287. return result;
  288. }
  289. Diagnostic2.create = create;
  290. function is(value) {
  291. var _a;
  292. var candidate = value;
  293. 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));
  294. }
  295. Diagnostic2.is = is;
  296. })(Diagnostic || (Diagnostic = {}));
  297. var Command;
  298. (function(Command2) {
  299. function create(title, command) {
  300. var args = [];
  301. for (var _i = 2; _i < arguments.length; _i++) {
  302. args[_i - 2] = arguments[_i];
  303. }
  304. var result = { title, command };
  305. if (Is.defined(args) && args.length > 0) {
  306. result.arguments = args;
  307. }
  308. return result;
  309. }
  310. Command2.create = create;
  311. function is(value) {
  312. var candidate = value;
  313. return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
  314. }
  315. Command2.is = is;
  316. })(Command || (Command = {}));
  317. var TextEdit;
  318. (function(TextEdit2) {
  319. function replace(range, newText) {
  320. return { range, newText };
  321. }
  322. TextEdit2.replace = replace;
  323. function insert(position, newText) {
  324. return { range: { start: position, end: position }, newText };
  325. }
  326. TextEdit2.insert = insert;
  327. function del(range) {
  328. return { range, newText: "" };
  329. }
  330. TextEdit2.del = del;
  331. function is(value) {
  332. var candidate = value;
  333. return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
  334. }
  335. TextEdit2.is = is;
  336. })(TextEdit || (TextEdit = {}));
  337. var ChangeAnnotation;
  338. (function(ChangeAnnotation2) {
  339. function create(label, needsConfirmation, description) {
  340. var result = { label };
  341. if (needsConfirmation !== void 0) {
  342. result.needsConfirmation = needsConfirmation;
  343. }
  344. if (description !== void 0) {
  345. result.description = description;
  346. }
  347. return result;
  348. }
  349. ChangeAnnotation2.create = create;
  350. function is(value) {
  351. var candidate = value;
  352. 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);
  353. }
  354. ChangeAnnotation2.is = is;
  355. })(ChangeAnnotation || (ChangeAnnotation = {}));
  356. var ChangeAnnotationIdentifier;
  357. (function(ChangeAnnotationIdentifier2) {
  358. function is(value) {
  359. var candidate = value;
  360. return typeof candidate === "string";
  361. }
  362. ChangeAnnotationIdentifier2.is = is;
  363. })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
  364. var AnnotatedTextEdit;
  365. (function(AnnotatedTextEdit2) {
  366. function replace(range, newText, annotation) {
  367. return { range, newText, annotationId: annotation };
  368. }
  369. AnnotatedTextEdit2.replace = replace;
  370. function insert(position, newText, annotation) {
  371. return { range: { start: position, end: position }, newText, annotationId: annotation };
  372. }
  373. AnnotatedTextEdit2.insert = insert;
  374. function del(range, annotation) {
  375. return { range, newText: "", annotationId: annotation };
  376. }
  377. AnnotatedTextEdit2.del = del;
  378. function is(value) {
  379. var candidate = value;
  380. return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
  381. }
  382. AnnotatedTextEdit2.is = is;
  383. })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
  384. var TextDocumentEdit;
  385. (function(TextDocumentEdit2) {
  386. function create(textDocument, edits) {
  387. return { textDocument, edits };
  388. }
  389. TextDocumentEdit2.create = create;
  390. function is(value) {
  391. var candidate = value;
  392. return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
  393. }
  394. TextDocumentEdit2.is = is;
  395. })(TextDocumentEdit || (TextDocumentEdit = {}));
  396. var CreateFile;
  397. (function(CreateFile2) {
  398. function create(uri, options, annotation) {
  399. var result = {
  400. kind: "create",
  401. uri
  402. };
  403. if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
  404. result.options = options;
  405. }
  406. if (annotation !== void 0) {
  407. result.annotationId = annotation;
  408. }
  409. return result;
  410. }
  411. CreateFile2.create = create;
  412. function is(value) {
  413. var candidate = value;
  414. 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));
  415. }
  416. CreateFile2.is = is;
  417. })(CreateFile || (CreateFile = {}));
  418. var RenameFile;
  419. (function(RenameFile2) {
  420. function create(oldUri, newUri, options, annotation) {
  421. var result = {
  422. kind: "rename",
  423. oldUri,
  424. newUri
  425. };
  426. if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
  427. result.options = options;
  428. }
  429. if (annotation !== void 0) {
  430. result.annotationId = annotation;
  431. }
  432. return result;
  433. }
  434. RenameFile2.create = create;
  435. function is(value) {
  436. var candidate = value;
  437. 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));
  438. }
  439. RenameFile2.is = is;
  440. })(RenameFile || (RenameFile = {}));
  441. var DeleteFile;
  442. (function(DeleteFile2) {
  443. function create(uri, options, annotation) {
  444. var result = {
  445. kind: "delete",
  446. uri
  447. };
  448. if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
  449. result.options = options;
  450. }
  451. if (annotation !== void 0) {
  452. result.annotationId = annotation;
  453. }
  454. return result;
  455. }
  456. DeleteFile2.create = create;
  457. function is(value) {
  458. var candidate = value;
  459. 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));
  460. }
  461. DeleteFile2.is = is;
  462. })(DeleteFile || (DeleteFile = {}));
  463. var WorkspaceEdit;
  464. (function(WorkspaceEdit2) {
  465. function is(value) {
  466. var candidate = value;
  467. return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
  468. if (Is.string(change.kind)) {
  469. return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
  470. } else {
  471. return TextDocumentEdit.is(change);
  472. }
  473. }));
  474. }
  475. WorkspaceEdit2.is = is;
  476. })(WorkspaceEdit || (WorkspaceEdit = {}));
  477. var TextEditChangeImpl = function() {
  478. function TextEditChangeImpl2(edits, changeAnnotations) {
  479. this.edits = edits;
  480. this.changeAnnotations = changeAnnotations;
  481. }
  482. TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
  483. var edit;
  484. var id;
  485. if (annotation === void 0) {
  486. edit = TextEdit.insert(position, newText);
  487. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  488. id = annotation;
  489. edit = AnnotatedTextEdit.insert(position, newText, annotation);
  490. } else {
  491. this.assertChangeAnnotations(this.changeAnnotations);
  492. id = this.changeAnnotations.manage(annotation);
  493. edit = AnnotatedTextEdit.insert(position, newText, id);
  494. }
  495. this.edits.push(edit);
  496. if (id !== void 0) {
  497. return id;
  498. }
  499. };
  500. TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
  501. var edit;
  502. var id;
  503. if (annotation === void 0) {
  504. edit = TextEdit.replace(range, newText);
  505. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  506. id = annotation;
  507. edit = AnnotatedTextEdit.replace(range, newText, annotation);
  508. } else {
  509. this.assertChangeAnnotations(this.changeAnnotations);
  510. id = this.changeAnnotations.manage(annotation);
  511. edit = AnnotatedTextEdit.replace(range, newText, id);
  512. }
  513. this.edits.push(edit);
  514. if (id !== void 0) {
  515. return id;
  516. }
  517. };
  518. TextEditChangeImpl2.prototype.delete = function(range, annotation) {
  519. var edit;
  520. var id;
  521. if (annotation === void 0) {
  522. edit = TextEdit.del(range);
  523. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  524. id = annotation;
  525. edit = AnnotatedTextEdit.del(range, annotation);
  526. } else {
  527. this.assertChangeAnnotations(this.changeAnnotations);
  528. id = this.changeAnnotations.manage(annotation);
  529. edit = AnnotatedTextEdit.del(range, id);
  530. }
  531. this.edits.push(edit);
  532. if (id !== void 0) {
  533. return id;
  534. }
  535. };
  536. TextEditChangeImpl2.prototype.add = function(edit) {
  537. this.edits.push(edit);
  538. };
  539. TextEditChangeImpl2.prototype.all = function() {
  540. return this.edits;
  541. };
  542. TextEditChangeImpl2.prototype.clear = function() {
  543. this.edits.splice(0, this.edits.length);
  544. };
  545. TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
  546. if (value === void 0) {
  547. throw new Error("Text edit change is not configured to manage change annotations.");
  548. }
  549. };
  550. return TextEditChangeImpl2;
  551. }();
  552. var ChangeAnnotations = function() {
  553. function ChangeAnnotations2(annotations) {
  554. this._annotations = annotations === void 0 ? /* @__PURE__ */ Object.create(null) : annotations;
  555. this._counter = 0;
  556. this._size = 0;
  557. }
  558. ChangeAnnotations2.prototype.all = function() {
  559. return this._annotations;
  560. };
  561. Object.defineProperty(ChangeAnnotations2.prototype, "size", {
  562. get: function() {
  563. return this._size;
  564. },
  565. enumerable: false,
  566. configurable: true
  567. });
  568. ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
  569. var id;
  570. if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
  571. id = idOrAnnotation;
  572. } else {
  573. id = this.nextId();
  574. annotation = idOrAnnotation;
  575. }
  576. if (this._annotations[id] !== void 0) {
  577. throw new Error("Id " + id + " is already in use.");
  578. }
  579. if (annotation === void 0) {
  580. throw new Error("No annotation provided for id " + id);
  581. }
  582. this._annotations[id] = annotation;
  583. this._size++;
  584. return id;
  585. };
  586. ChangeAnnotations2.prototype.nextId = function() {
  587. this._counter++;
  588. return this._counter.toString();
  589. };
  590. return ChangeAnnotations2;
  591. }();
  592. var WorkspaceChange = function() {
  593. function WorkspaceChange2(workspaceEdit) {
  594. var _this = this;
  595. this._textEditChanges = /* @__PURE__ */ Object.create(null);
  596. if (workspaceEdit !== void 0) {
  597. this._workspaceEdit = workspaceEdit;
  598. if (workspaceEdit.documentChanges) {
  599. this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
  600. workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  601. workspaceEdit.documentChanges.forEach(function(change) {
  602. if (TextDocumentEdit.is(change)) {
  603. var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
  604. _this._textEditChanges[change.textDocument.uri] = textEditChange;
  605. }
  606. });
  607. } else if (workspaceEdit.changes) {
  608. Object.keys(workspaceEdit.changes).forEach(function(key) {
  609. var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
  610. _this._textEditChanges[key] = textEditChange;
  611. });
  612. }
  613. } else {
  614. this._workspaceEdit = {};
  615. }
  616. }
  617. Object.defineProperty(WorkspaceChange2.prototype, "edit", {
  618. get: function() {
  619. this.initDocumentChanges();
  620. if (this._changeAnnotations !== void 0) {
  621. if (this._changeAnnotations.size === 0) {
  622. this._workspaceEdit.changeAnnotations = void 0;
  623. } else {
  624. this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  625. }
  626. }
  627. return this._workspaceEdit;
  628. },
  629. enumerable: false,
  630. configurable: true
  631. });
  632. WorkspaceChange2.prototype.getTextEditChange = function(key) {
  633. if (OptionalVersionedTextDocumentIdentifier.is(key)) {
  634. this.initDocumentChanges();
  635. if (this._workspaceEdit.documentChanges === void 0) {
  636. throw new Error("Workspace edit is not configured for document changes.");
  637. }
  638. var textDocument = { uri: key.uri, version: key.version };
  639. var result = this._textEditChanges[textDocument.uri];
  640. if (!result) {
  641. var edits = [];
  642. var textDocumentEdit = {
  643. textDocument,
  644. edits
  645. };
  646. this._workspaceEdit.documentChanges.push(textDocumentEdit);
  647. result = new TextEditChangeImpl(edits, this._changeAnnotations);
  648. this._textEditChanges[textDocument.uri] = result;
  649. }
  650. return result;
  651. } else {
  652. this.initChanges();
  653. if (this._workspaceEdit.changes === void 0) {
  654. throw new Error("Workspace edit is not configured for normal text edit changes.");
  655. }
  656. var result = this._textEditChanges[key];
  657. if (!result) {
  658. var edits = [];
  659. this._workspaceEdit.changes[key] = edits;
  660. result = new TextEditChangeImpl(edits);
  661. this._textEditChanges[key] = result;
  662. }
  663. return result;
  664. }
  665. };
  666. WorkspaceChange2.prototype.initDocumentChanges = function() {
  667. if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
  668. this._changeAnnotations = new ChangeAnnotations();
  669. this._workspaceEdit.documentChanges = [];
  670. this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
  671. }
  672. };
  673. WorkspaceChange2.prototype.initChanges = function() {
  674. if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
  675. this._workspaceEdit.changes = /* @__PURE__ */ Object.create(null);
  676. }
  677. };
  678. WorkspaceChange2.prototype.createFile = function(uri, optionsOrAnnotation, options) {
  679. this.initDocumentChanges();
  680. if (this._workspaceEdit.documentChanges === void 0) {
  681. throw new Error("Workspace edit is not configured for document changes.");
  682. }
  683. var annotation;
  684. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  685. annotation = optionsOrAnnotation;
  686. } else {
  687. options = optionsOrAnnotation;
  688. }
  689. var operation;
  690. var id;
  691. if (annotation === void 0) {
  692. operation = CreateFile.create(uri, options);
  693. } else {
  694. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  695. operation = CreateFile.create(uri, options, id);
  696. }
  697. this._workspaceEdit.documentChanges.push(operation);
  698. if (id !== void 0) {
  699. return id;
  700. }
  701. };
  702. WorkspaceChange2.prototype.renameFile = function(oldUri, newUri, optionsOrAnnotation, options) {
  703. this.initDocumentChanges();
  704. if (this._workspaceEdit.documentChanges === void 0) {
  705. throw new Error("Workspace edit is not configured for document changes.");
  706. }
  707. var annotation;
  708. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  709. annotation = optionsOrAnnotation;
  710. } else {
  711. options = optionsOrAnnotation;
  712. }
  713. var operation;
  714. var id;
  715. if (annotation === void 0) {
  716. operation = RenameFile.create(oldUri, newUri, options);
  717. } else {
  718. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  719. operation = RenameFile.create(oldUri, newUri, options, id);
  720. }
  721. this._workspaceEdit.documentChanges.push(operation);
  722. if (id !== void 0) {
  723. return id;
  724. }
  725. };
  726. WorkspaceChange2.prototype.deleteFile = function(uri, optionsOrAnnotation, options) {
  727. this.initDocumentChanges();
  728. if (this._workspaceEdit.documentChanges === void 0) {
  729. throw new Error("Workspace edit is not configured for document changes.");
  730. }
  731. var annotation;
  732. if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
  733. annotation = optionsOrAnnotation;
  734. } else {
  735. options = optionsOrAnnotation;
  736. }
  737. var operation;
  738. var id;
  739. if (annotation === void 0) {
  740. operation = DeleteFile.create(uri, options);
  741. } else {
  742. id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
  743. operation = DeleteFile.create(uri, options, id);
  744. }
  745. this._workspaceEdit.documentChanges.push(operation);
  746. if (id !== void 0) {
  747. return id;
  748. }
  749. };
  750. return WorkspaceChange2;
  751. }();
  752. var TextDocumentIdentifier;
  753. (function(TextDocumentIdentifier2) {
  754. function create(uri) {
  755. return { uri };
  756. }
  757. TextDocumentIdentifier2.create = create;
  758. function is(value) {
  759. var candidate = value;
  760. return Is.defined(candidate) && Is.string(candidate.uri);
  761. }
  762. TextDocumentIdentifier2.is = is;
  763. })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
  764. var VersionedTextDocumentIdentifier;
  765. (function(VersionedTextDocumentIdentifier2) {
  766. function create(uri, version) {
  767. return { uri, version };
  768. }
  769. VersionedTextDocumentIdentifier2.create = create;
  770. function is(value) {
  771. var candidate = value;
  772. return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
  773. }
  774. VersionedTextDocumentIdentifier2.is = is;
  775. })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
  776. var OptionalVersionedTextDocumentIdentifier;
  777. (function(OptionalVersionedTextDocumentIdentifier2) {
  778. function create(uri, version) {
  779. return { uri, version };
  780. }
  781. OptionalVersionedTextDocumentIdentifier2.create = create;
  782. function is(value) {
  783. var candidate = value;
  784. return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
  785. }
  786. OptionalVersionedTextDocumentIdentifier2.is = is;
  787. })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
  788. var TextDocumentItem;
  789. (function(TextDocumentItem2) {
  790. function create(uri, languageId, version, text) {
  791. return { uri, languageId, version, text };
  792. }
  793. TextDocumentItem2.create = create;
  794. function is(value) {
  795. var candidate = value;
  796. return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
  797. }
  798. TextDocumentItem2.is = is;
  799. })(TextDocumentItem || (TextDocumentItem = {}));
  800. var MarkupKind;
  801. (function(MarkupKind2) {
  802. MarkupKind2.PlainText = "plaintext";
  803. MarkupKind2.Markdown = "markdown";
  804. })(MarkupKind || (MarkupKind = {}));
  805. (function(MarkupKind2) {
  806. function is(value) {
  807. var candidate = value;
  808. return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
  809. }
  810. MarkupKind2.is = is;
  811. })(MarkupKind || (MarkupKind = {}));
  812. var MarkupContent;
  813. (function(MarkupContent2) {
  814. function is(value) {
  815. var candidate = value;
  816. return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
  817. }
  818. MarkupContent2.is = is;
  819. })(MarkupContent || (MarkupContent = {}));
  820. var CompletionItemKind;
  821. (function(CompletionItemKind2) {
  822. CompletionItemKind2.Text = 1;
  823. CompletionItemKind2.Method = 2;
  824. CompletionItemKind2.Function = 3;
  825. CompletionItemKind2.Constructor = 4;
  826. CompletionItemKind2.Field = 5;
  827. CompletionItemKind2.Variable = 6;
  828. CompletionItemKind2.Class = 7;
  829. CompletionItemKind2.Interface = 8;
  830. CompletionItemKind2.Module = 9;
  831. CompletionItemKind2.Property = 10;
  832. CompletionItemKind2.Unit = 11;
  833. CompletionItemKind2.Value = 12;
  834. CompletionItemKind2.Enum = 13;
  835. CompletionItemKind2.Keyword = 14;
  836. CompletionItemKind2.Snippet = 15;
  837. CompletionItemKind2.Color = 16;
  838. CompletionItemKind2.File = 17;
  839. CompletionItemKind2.Reference = 18;
  840. CompletionItemKind2.Folder = 19;
  841. CompletionItemKind2.EnumMember = 20;
  842. CompletionItemKind2.Constant = 21;
  843. CompletionItemKind2.Struct = 22;
  844. CompletionItemKind2.Event = 23;
  845. CompletionItemKind2.Operator = 24;
  846. CompletionItemKind2.TypeParameter = 25;
  847. })(CompletionItemKind || (CompletionItemKind = {}));
  848. var InsertTextFormat;
  849. (function(InsertTextFormat2) {
  850. InsertTextFormat2.PlainText = 1;
  851. InsertTextFormat2.Snippet = 2;
  852. })(InsertTextFormat || (InsertTextFormat = {}));
  853. var CompletionItemTag;
  854. (function(CompletionItemTag2) {
  855. CompletionItemTag2.Deprecated = 1;
  856. })(CompletionItemTag || (CompletionItemTag = {}));
  857. var InsertReplaceEdit;
  858. (function(InsertReplaceEdit2) {
  859. function create(newText, insert, replace) {
  860. return { newText, insert, replace };
  861. }
  862. InsertReplaceEdit2.create = create;
  863. function is(value) {
  864. var candidate = value;
  865. return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
  866. }
  867. InsertReplaceEdit2.is = is;
  868. })(InsertReplaceEdit || (InsertReplaceEdit = {}));
  869. var InsertTextMode;
  870. (function(InsertTextMode2) {
  871. InsertTextMode2.asIs = 1;
  872. InsertTextMode2.adjustIndentation = 2;
  873. })(InsertTextMode || (InsertTextMode = {}));
  874. var CompletionItem;
  875. (function(CompletionItem2) {
  876. function create(label) {
  877. return { label };
  878. }
  879. CompletionItem2.create = create;
  880. })(CompletionItem || (CompletionItem = {}));
  881. var CompletionList;
  882. (function(CompletionList2) {
  883. function create(items, isIncomplete) {
  884. return { items: items ? items : [], isIncomplete: !!isIncomplete };
  885. }
  886. CompletionList2.create = create;
  887. })(CompletionList || (CompletionList = {}));
  888. var MarkedString;
  889. (function(MarkedString2) {
  890. function fromPlainText(plainText) {
  891. return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
  892. }
  893. MarkedString2.fromPlainText = fromPlainText;
  894. function is(value) {
  895. var candidate = value;
  896. return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
  897. }
  898. MarkedString2.is = is;
  899. })(MarkedString || (MarkedString = {}));
  900. var Hover;
  901. (function(Hover2) {
  902. function is(value) {
  903. var candidate = value;
  904. 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));
  905. }
  906. Hover2.is = is;
  907. })(Hover || (Hover = {}));
  908. var ParameterInformation;
  909. (function(ParameterInformation2) {
  910. function create(label, documentation) {
  911. return documentation ? { label, documentation } : { label };
  912. }
  913. ParameterInformation2.create = create;
  914. })(ParameterInformation || (ParameterInformation = {}));
  915. var SignatureInformation;
  916. (function(SignatureInformation2) {
  917. function create(label, documentation) {
  918. var parameters = [];
  919. for (var _i = 2; _i < arguments.length; _i++) {
  920. parameters[_i - 2] = arguments[_i];
  921. }
  922. var result = { label };
  923. if (Is.defined(documentation)) {
  924. result.documentation = documentation;
  925. }
  926. if (Is.defined(parameters)) {
  927. result.parameters = parameters;
  928. } else {
  929. result.parameters = [];
  930. }
  931. return result;
  932. }
  933. SignatureInformation2.create = create;
  934. })(SignatureInformation || (SignatureInformation = {}));
  935. var DocumentHighlightKind;
  936. (function(DocumentHighlightKind2) {
  937. DocumentHighlightKind2.Text = 1;
  938. DocumentHighlightKind2.Read = 2;
  939. DocumentHighlightKind2.Write = 3;
  940. })(DocumentHighlightKind || (DocumentHighlightKind = {}));
  941. var DocumentHighlight;
  942. (function(DocumentHighlight2) {
  943. function create(range, kind) {
  944. var result = { range };
  945. if (Is.number(kind)) {
  946. result.kind = kind;
  947. }
  948. return result;
  949. }
  950. DocumentHighlight2.create = create;
  951. })(DocumentHighlight || (DocumentHighlight = {}));
  952. var SymbolKind;
  953. (function(SymbolKind2) {
  954. SymbolKind2.File = 1;
  955. SymbolKind2.Module = 2;
  956. SymbolKind2.Namespace = 3;
  957. SymbolKind2.Package = 4;
  958. SymbolKind2.Class = 5;
  959. SymbolKind2.Method = 6;
  960. SymbolKind2.Property = 7;
  961. SymbolKind2.Field = 8;
  962. SymbolKind2.Constructor = 9;
  963. SymbolKind2.Enum = 10;
  964. SymbolKind2.Interface = 11;
  965. SymbolKind2.Function = 12;
  966. SymbolKind2.Variable = 13;
  967. SymbolKind2.Constant = 14;
  968. SymbolKind2.String = 15;
  969. SymbolKind2.Number = 16;
  970. SymbolKind2.Boolean = 17;
  971. SymbolKind2.Array = 18;
  972. SymbolKind2.Object = 19;
  973. SymbolKind2.Key = 20;
  974. SymbolKind2.Null = 21;
  975. SymbolKind2.EnumMember = 22;
  976. SymbolKind2.Struct = 23;
  977. SymbolKind2.Event = 24;
  978. SymbolKind2.Operator = 25;
  979. SymbolKind2.TypeParameter = 26;
  980. })(SymbolKind || (SymbolKind = {}));
  981. var SymbolTag;
  982. (function(SymbolTag2) {
  983. SymbolTag2.Deprecated = 1;
  984. })(SymbolTag || (SymbolTag = {}));
  985. var SymbolInformation;
  986. (function(SymbolInformation2) {
  987. function create(name, kind, range, uri, containerName) {
  988. var result = {
  989. name,
  990. kind,
  991. location: { uri, range }
  992. };
  993. if (containerName) {
  994. result.containerName = containerName;
  995. }
  996. return result;
  997. }
  998. SymbolInformation2.create = create;
  999. })(SymbolInformation || (SymbolInformation = {}));
  1000. var DocumentSymbol;
  1001. (function(DocumentSymbol2) {
  1002. function create(name, detail, kind, range, selectionRange, children) {
  1003. var result = {
  1004. name,
  1005. detail,
  1006. kind,
  1007. range,
  1008. selectionRange
  1009. };
  1010. if (children !== void 0) {
  1011. result.children = children;
  1012. }
  1013. return result;
  1014. }
  1015. DocumentSymbol2.create = create;
  1016. function is(value) {
  1017. var candidate = value;
  1018. 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));
  1019. }
  1020. DocumentSymbol2.is = is;
  1021. })(DocumentSymbol || (DocumentSymbol = {}));
  1022. var CodeActionKind;
  1023. (function(CodeActionKind2) {
  1024. CodeActionKind2.Empty = "";
  1025. CodeActionKind2.QuickFix = "quickfix";
  1026. CodeActionKind2.Refactor = "refactor";
  1027. CodeActionKind2.RefactorExtract = "refactor.extract";
  1028. CodeActionKind2.RefactorInline = "refactor.inline";
  1029. CodeActionKind2.RefactorRewrite = "refactor.rewrite";
  1030. CodeActionKind2.Source = "source";
  1031. CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
  1032. CodeActionKind2.SourceFixAll = "source.fixAll";
  1033. })(CodeActionKind || (CodeActionKind = {}));
  1034. var CodeActionContext;
  1035. (function(CodeActionContext2) {
  1036. function create(diagnostics, only) {
  1037. var result = { diagnostics };
  1038. if (only !== void 0 && only !== null) {
  1039. result.only = only;
  1040. }
  1041. return result;
  1042. }
  1043. CodeActionContext2.create = create;
  1044. function is(value) {
  1045. var candidate = value;
  1046. return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
  1047. }
  1048. CodeActionContext2.is = is;
  1049. })(CodeActionContext || (CodeActionContext = {}));
  1050. var CodeAction;
  1051. (function(CodeAction2) {
  1052. function create(title, kindOrCommandOrEdit, kind) {
  1053. var result = { title };
  1054. var checkKind = true;
  1055. if (typeof kindOrCommandOrEdit === "string") {
  1056. checkKind = false;
  1057. result.kind = kindOrCommandOrEdit;
  1058. } else if (Command.is(kindOrCommandOrEdit)) {
  1059. result.command = kindOrCommandOrEdit;
  1060. } else {
  1061. result.edit = kindOrCommandOrEdit;
  1062. }
  1063. if (checkKind && kind !== void 0) {
  1064. result.kind = kind;
  1065. }
  1066. return result;
  1067. }
  1068. CodeAction2.create = create;
  1069. function is(value) {
  1070. var candidate = value;
  1071. 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));
  1072. }
  1073. CodeAction2.is = is;
  1074. })(CodeAction || (CodeAction = {}));
  1075. var CodeLens;
  1076. (function(CodeLens2) {
  1077. function create(range, data) {
  1078. var result = { range };
  1079. if (Is.defined(data)) {
  1080. result.data = data;
  1081. }
  1082. return result;
  1083. }
  1084. CodeLens2.create = create;
  1085. function is(value) {
  1086. var candidate = value;
  1087. return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
  1088. }
  1089. CodeLens2.is = is;
  1090. })(CodeLens || (CodeLens = {}));
  1091. var FormattingOptions;
  1092. (function(FormattingOptions2) {
  1093. function create(tabSize, insertSpaces) {
  1094. return { tabSize, insertSpaces };
  1095. }
  1096. FormattingOptions2.create = create;
  1097. function is(value) {
  1098. var candidate = value;
  1099. return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
  1100. }
  1101. FormattingOptions2.is = is;
  1102. })(FormattingOptions || (FormattingOptions = {}));
  1103. var DocumentLink;
  1104. (function(DocumentLink2) {
  1105. function create(range, target, data) {
  1106. return { range, target, data };
  1107. }
  1108. DocumentLink2.create = create;
  1109. function is(value) {
  1110. var candidate = value;
  1111. return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
  1112. }
  1113. DocumentLink2.is = is;
  1114. })(DocumentLink || (DocumentLink = {}));
  1115. var SelectionRange;
  1116. (function(SelectionRange2) {
  1117. function create(range, parent) {
  1118. return { range, parent };
  1119. }
  1120. SelectionRange2.create = create;
  1121. function is(value) {
  1122. var candidate = value;
  1123. return candidate !== void 0 && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
  1124. }
  1125. SelectionRange2.is = is;
  1126. })(SelectionRange || (SelectionRange = {}));
  1127. var TextDocument;
  1128. (function(TextDocument2) {
  1129. function create(uri, languageId, version, content) {
  1130. return new FullTextDocument(uri, languageId, version, content);
  1131. }
  1132. TextDocument2.create = create;
  1133. function is(value) {
  1134. var candidate = value;
  1135. 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;
  1136. }
  1137. TextDocument2.is = is;
  1138. function applyEdits(document, edits) {
  1139. var text = document.getText();
  1140. var sortedEdits = mergeSort(edits, function(a, b) {
  1141. var diff = a.range.start.line - b.range.start.line;
  1142. if (diff === 0) {
  1143. return a.range.start.character - b.range.start.character;
  1144. }
  1145. return diff;
  1146. });
  1147. var lastModifiedOffset = text.length;
  1148. for (var i = sortedEdits.length - 1; i >= 0; i--) {
  1149. var e = sortedEdits[i];
  1150. var startOffset = document.offsetAt(e.range.start);
  1151. var endOffset = document.offsetAt(e.range.end);
  1152. if (endOffset <= lastModifiedOffset) {
  1153. text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
  1154. } else {
  1155. throw new Error("Overlapping edit");
  1156. }
  1157. lastModifiedOffset = startOffset;
  1158. }
  1159. return text;
  1160. }
  1161. TextDocument2.applyEdits = applyEdits;
  1162. function mergeSort(data, compare) {
  1163. if (data.length <= 1) {
  1164. return data;
  1165. }
  1166. var p = data.length / 2 | 0;
  1167. var left = data.slice(0, p);
  1168. var right = data.slice(p);
  1169. mergeSort(left, compare);
  1170. mergeSort(right, compare);
  1171. var leftIdx = 0;
  1172. var rightIdx = 0;
  1173. var i = 0;
  1174. while (leftIdx < left.length && rightIdx < right.length) {
  1175. var ret = compare(left[leftIdx], right[rightIdx]);
  1176. if (ret <= 0) {
  1177. data[i++] = left[leftIdx++];
  1178. } else {
  1179. data[i++] = right[rightIdx++];
  1180. }
  1181. }
  1182. while (leftIdx < left.length) {
  1183. data[i++] = left[leftIdx++];
  1184. }
  1185. while (rightIdx < right.length) {
  1186. data[i++] = right[rightIdx++];
  1187. }
  1188. return data;
  1189. }
  1190. })(TextDocument || (TextDocument = {}));
  1191. var FullTextDocument = function() {
  1192. function FullTextDocument2(uri, languageId, version, content) {
  1193. this._uri = uri;
  1194. this._languageId = languageId;
  1195. this._version = version;
  1196. this._content = content;
  1197. this._lineOffsets = void 0;
  1198. }
  1199. Object.defineProperty(FullTextDocument2.prototype, "uri", {
  1200. get: function() {
  1201. return this._uri;
  1202. },
  1203. enumerable: false,
  1204. configurable: true
  1205. });
  1206. Object.defineProperty(FullTextDocument2.prototype, "languageId", {
  1207. get: function() {
  1208. return this._languageId;
  1209. },
  1210. enumerable: false,
  1211. configurable: true
  1212. });
  1213. Object.defineProperty(FullTextDocument2.prototype, "version", {
  1214. get: function() {
  1215. return this._version;
  1216. },
  1217. enumerable: false,
  1218. configurable: true
  1219. });
  1220. FullTextDocument2.prototype.getText = function(range) {
  1221. if (range) {
  1222. var start = this.offsetAt(range.start);
  1223. var end = this.offsetAt(range.end);
  1224. return this._content.substring(start, end);
  1225. }
  1226. return this._content;
  1227. };
  1228. FullTextDocument2.prototype.update = function(event, version) {
  1229. this._content = event.text;
  1230. this._version = version;
  1231. this._lineOffsets = void 0;
  1232. };
  1233. FullTextDocument2.prototype.getLineOffsets = function() {
  1234. if (this._lineOffsets === void 0) {
  1235. var lineOffsets = [];
  1236. var text = this._content;
  1237. var isLineStart = true;
  1238. for (var i = 0; i < text.length; i++) {
  1239. if (isLineStart) {
  1240. lineOffsets.push(i);
  1241. isLineStart = false;
  1242. }
  1243. var ch = text.charAt(i);
  1244. isLineStart = ch === "\r" || ch === "\n";
  1245. if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
  1246. i++;
  1247. }
  1248. }
  1249. if (isLineStart && text.length > 0) {
  1250. lineOffsets.push(text.length);
  1251. }
  1252. this._lineOffsets = lineOffsets;
  1253. }
  1254. return this._lineOffsets;
  1255. };
  1256. FullTextDocument2.prototype.positionAt = function(offset) {
  1257. offset = Math.max(Math.min(offset, this._content.length), 0);
  1258. var lineOffsets = this.getLineOffsets();
  1259. var low = 0, high = lineOffsets.length;
  1260. if (high === 0) {
  1261. return Position.create(0, offset);
  1262. }
  1263. while (low < high) {
  1264. var mid = Math.floor((low + high) / 2);
  1265. if (lineOffsets[mid] > offset) {
  1266. high = mid;
  1267. } else {
  1268. low = mid + 1;
  1269. }
  1270. }
  1271. var line = low - 1;
  1272. return Position.create(line, offset - lineOffsets[line]);
  1273. };
  1274. FullTextDocument2.prototype.offsetAt = function(position) {
  1275. var lineOffsets = this.getLineOffsets();
  1276. if (position.line >= lineOffsets.length) {
  1277. return this._content.length;
  1278. } else if (position.line < 0) {
  1279. return 0;
  1280. }
  1281. var lineOffset = lineOffsets[position.line];
  1282. var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
  1283. return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
  1284. };
  1285. Object.defineProperty(FullTextDocument2.prototype, "lineCount", {
  1286. get: function() {
  1287. return this.getLineOffsets().length;
  1288. },
  1289. enumerable: false,
  1290. configurable: true
  1291. });
  1292. return FullTextDocument2;
  1293. }();
  1294. var Is;
  1295. (function(Is2) {
  1296. var toString = Object.prototype.toString;
  1297. function defined(value) {
  1298. return typeof value !== "undefined";
  1299. }
  1300. Is2.defined = defined;
  1301. function undefined2(value) {
  1302. return typeof value === "undefined";
  1303. }
  1304. Is2.undefined = undefined2;
  1305. function boolean(value) {
  1306. return value === true || value === false;
  1307. }
  1308. Is2.boolean = boolean;
  1309. function string(value) {
  1310. return toString.call(value) === "[object String]";
  1311. }
  1312. Is2.string = string;
  1313. function number(value) {
  1314. return toString.call(value) === "[object Number]";
  1315. }
  1316. Is2.number = number;
  1317. function numberRange(value, min, max) {
  1318. return toString.call(value) === "[object Number]" && min <= value && value <= max;
  1319. }
  1320. Is2.numberRange = numberRange;
  1321. function integer2(value) {
  1322. return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
  1323. }
  1324. Is2.integer = integer2;
  1325. function uinteger2(value) {
  1326. return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
  1327. }
  1328. Is2.uinteger = uinteger2;
  1329. function func(value) {
  1330. return toString.call(value) === "[object Function]";
  1331. }
  1332. Is2.func = func;
  1333. function objectLiteral(value) {
  1334. return value !== null && typeof value === "object";
  1335. }
  1336. Is2.objectLiteral = objectLiteral;
  1337. function typedArray(value, check) {
  1338. return Array.isArray(value) && value.every(check);
  1339. }
  1340. Is2.typedArray = typedArray;
  1341. })(Is || (Is = {}));
  1342. var DiagnosticsAdapter = class {
  1343. constructor(_languageId, _worker, configChangeEvent) {
  1344. __publicField(this, "_disposables", []);
  1345. __publicField(this, "_listener", /* @__PURE__ */ Object.create(null));
  1346. this._languageId = _languageId;
  1347. this._worker = _worker;
  1348. const onModelAdd = (model) => {
  1349. let modeId = model.getLanguageId();
  1350. if (modeId !== this._languageId) {
  1351. return;
  1352. }
  1353. let handle;
  1354. this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
  1355. window.clearTimeout(handle);
  1356. handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
  1357. });
  1358. this._doValidate(model.uri, modeId);
  1359. };
  1360. const onModelRemoved = (model) => {
  1361. monaco_editor_core_exports.editor.setModelMarkers(model, this._languageId, []);
  1362. let uriStr = model.uri.toString();
  1363. let listener = this._listener[uriStr];
  1364. if (listener) {
  1365. listener.dispose();
  1366. delete this._listener[uriStr];
  1367. }
  1368. };
  1369. this._disposables.push(monaco_editor_core_exports.editor.onDidCreateModel(onModelAdd));
  1370. this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel(onModelRemoved));
  1371. this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
  1372. onModelRemoved(event.model);
  1373. onModelAdd(event.model);
  1374. }));
  1375. this._disposables.push(configChangeEvent((_) => {
  1376. monaco_editor_core_exports.editor.getModels().forEach((model) => {
  1377. if (model.getLanguageId() === this._languageId) {
  1378. onModelRemoved(model);
  1379. onModelAdd(model);
  1380. }
  1381. });
  1382. }));
  1383. this._disposables.push({
  1384. dispose: () => {
  1385. monaco_editor_core_exports.editor.getModels().forEach(onModelRemoved);
  1386. for (let key in this._listener) {
  1387. this._listener[key].dispose();
  1388. }
  1389. }
  1390. });
  1391. monaco_editor_core_exports.editor.getModels().forEach(onModelAdd);
  1392. }
  1393. dispose() {
  1394. this._disposables.forEach((d) => d && d.dispose());
  1395. this._disposables.length = 0;
  1396. }
  1397. _doValidate(resource, languageId) {
  1398. this._worker(resource).then((worker) => {
  1399. return worker.doValidation(resource.toString());
  1400. }).then((diagnostics) => {
  1401. const markers = diagnostics.map((d) => toDiagnostics(resource, d));
  1402. let model = monaco_editor_core_exports.editor.getModel(resource);
  1403. if (model && model.getLanguageId() === languageId) {
  1404. monaco_editor_core_exports.editor.setModelMarkers(model, languageId, markers);
  1405. }
  1406. }).then(void 0, (err) => {
  1407. console.error(err);
  1408. });
  1409. }
  1410. };
  1411. function toSeverity(lsSeverity) {
  1412. switch (lsSeverity) {
  1413. case DiagnosticSeverity.Error:
  1414. return monaco_editor_core_exports.MarkerSeverity.Error;
  1415. case DiagnosticSeverity.Warning:
  1416. return monaco_editor_core_exports.MarkerSeverity.Warning;
  1417. case DiagnosticSeverity.Information:
  1418. return monaco_editor_core_exports.MarkerSeverity.Info;
  1419. case DiagnosticSeverity.Hint:
  1420. return monaco_editor_core_exports.MarkerSeverity.Hint;
  1421. default:
  1422. return monaco_editor_core_exports.MarkerSeverity.Info;
  1423. }
  1424. }
  1425. function toDiagnostics(resource, diag) {
  1426. let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
  1427. return {
  1428. severity: toSeverity(diag.severity),
  1429. startLineNumber: diag.range.start.line + 1,
  1430. startColumn: diag.range.start.character + 1,
  1431. endLineNumber: diag.range.end.line + 1,
  1432. endColumn: diag.range.end.character + 1,
  1433. message: diag.message,
  1434. code,
  1435. source: diag.source
  1436. };
  1437. }
  1438. var CompletionAdapter = class {
  1439. constructor(_worker, _triggerCharacters) {
  1440. this._worker = _worker;
  1441. this._triggerCharacters = _triggerCharacters;
  1442. }
  1443. get triggerCharacters() {
  1444. return this._triggerCharacters;
  1445. }
  1446. provideCompletionItems(model, position, context, token) {
  1447. const resource = model.uri;
  1448. return this._worker(resource).then((worker) => {
  1449. return worker.doComplete(resource.toString(), fromPosition(position));
  1450. }).then((info) => {
  1451. if (!info) {
  1452. return;
  1453. }
  1454. const wordInfo = model.getWordUntilPosition(position);
  1455. const wordRange = new monaco_editor_core_exports.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
  1456. const items = info.items.map((entry) => {
  1457. const item = {
  1458. label: entry.label,
  1459. insertText: entry.insertText || entry.label,
  1460. sortText: entry.sortText,
  1461. filterText: entry.filterText,
  1462. documentation: entry.documentation,
  1463. detail: entry.detail,
  1464. command: toCommand(entry.command),
  1465. range: wordRange,
  1466. kind: toCompletionItemKind(entry.kind)
  1467. };
  1468. if (entry.textEdit) {
  1469. if (isInsertReplaceEdit(entry.textEdit)) {
  1470. item.range = {
  1471. insert: toRange(entry.textEdit.insert),
  1472. replace: toRange(entry.textEdit.replace)
  1473. };
  1474. } else {
  1475. item.range = toRange(entry.textEdit.range);
  1476. }
  1477. item.insertText = entry.textEdit.newText;
  1478. }
  1479. if (entry.additionalTextEdits) {
  1480. item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
  1481. }
  1482. if (entry.insertTextFormat === InsertTextFormat.Snippet) {
  1483. item.insertTextRules = monaco_editor_core_exports.languages.CompletionItemInsertTextRule.InsertAsSnippet;
  1484. }
  1485. return item;
  1486. });
  1487. return {
  1488. isIncomplete: info.isIncomplete,
  1489. suggestions: items
  1490. };
  1491. });
  1492. }
  1493. };
  1494. function fromPosition(position) {
  1495. if (!position) {
  1496. return void 0;
  1497. }
  1498. return { character: position.column - 1, line: position.lineNumber - 1 };
  1499. }
  1500. function fromRange(range) {
  1501. if (!range) {
  1502. return void 0;
  1503. }
  1504. return {
  1505. start: {
  1506. line: range.startLineNumber - 1,
  1507. character: range.startColumn - 1
  1508. },
  1509. end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
  1510. };
  1511. }
  1512. function toRange(range) {
  1513. if (!range) {
  1514. return void 0;
  1515. }
  1516. return new monaco_editor_core_exports.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
  1517. }
  1518. function isInsertReplaceEdit(edit) {
  1519. return typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined";
  1520. }
  1521. function toCompletionItemKind(kind) {
  1522. const mItemKind = monaco_editor_core_exports.languages.CompletionItemKind;
  1523. switch (kind) {
  1524. case CompletionItemKind.Text:
  1525. return mItemKind.Text;
  1526. case CompletionItemKind.Method:
  1527. return mItemKind.Method;
  1528. case CompletionItemKind.Function:
  1529. return mItemKind.Function;
  1530. case CompletionItemKind.Constructor:
  1531. return mItemKind.Constructor;
  1532. case CompletionItemKind.Field:
  1533. return mItemKind.Field;
  1534. case CompletionItemKind.Variable:
  1535. return mItemKind.Variable;
  1536. case CompletionItemKind.Class:
  1537. return mItemKind.Class;
  1538. case CompletionItemKind.Interface:
  1539. return mItemKind.Interface;
  1540. case CompletionItemKind.Module:
  1541. return mItemKind.Module;
  1542. case CompletionItemKind.Property:
  1543. return mItemKind.Property;
  1544. case CompletionItemKind.Unit:
  1545. return mItemKind.Unit;
  1546. case CompletionItemKind.Value:
  1547. return mItemKind.Value;
  1548. case CompletionItemKind.Enum:
  1549. return mItemKind.Enum;
  1550. case CompletionItemKind.Keyword:
  1551. return mItemKind.Keyword;
  1552. case CompletionItemKind.Snippet:
  1553. return mItemKind.Snippet;
  1554. case CompletionItemKind.Color:
  1555. return mItemKind.Color;
  1556. case CompletionItemKind.File:
  1557. return mItemKind.File;
  1558. case CompletionItemKind.Reference:
  1559. return mItemKind.Reference;
  1560. }
  1561. return mItemKind.Property;
  1562. }
  1563. function toTextEdit(textEdit) {
  1564. if (!textEdit) {
  1565. return void 0;
  1566. }
  1567. return {
  1568. range: toRange(textEdit.range),
  1569. text: textEdit.newText
  1570. };
  1571. }
  1572. function toCommand(c) {
  1573. return c && c.command === "editor.action.triggerSuggest" ? { id: c.command, title: c.title, arguments: c.arguments } : void 0;
  1574. }
  1575. var HoverAdapter = class {
  1576. constructor(_worker) {
  1577. this._worker = _worker;
  1578. }
  1579. provideHover(model, position, token) {
  1580. let resource = model.uri;
  1581. return this._worker(resource).then((worker) => {
  1582. return worker.doHover(resource.toString(), fromPosition(position));
  1583. }).then((info) => {
  1584. if (!info) {
  1585. return;
  1586. }
  1587. return {
  1588. range: toRange(info.range),
  1589. contents: toMarkedStringArray(info.contents)
  1590. };
  1591. });
  1592. }
  1593. };
  1594. function isMarkupContent(thing) {
  1595. return thing && typeof thing === "object" && typeof thing.kind === "string";
  1596. }
  1597. function toMarkdownString(entry) {
  1598. if (typeof entry === "string") {
  1599. return {
  1600. value: entry
  1601. };
  1602. }
  1603. if (isMarkupContent(entry)) {
  1604. if (entry.kind === "plaintext") {
  1605. return {
  1606. value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
  1607. };
  1608. }
  1609. return {
  1610. value: entry.value
  1611. };
  1612. }
  1613. return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
  1614. }
  1615. function toMarkedStringArray(contents) {
  1616. if (!contents) {
  1617. return void 0;
  1618. }
  1619. if (Array.isArray(contents)) {
  1620. return contents.map(toMarkdownString);
  1621. }
  1622. return [toMarkdownString(contents)];
  1623. }
  1624. var DocumentHighlightAdapter = class {
  1625. constructor(_worker) {
  1626. this._worker = _worker;
  1627. }
  1628. provideDocumentHighlights(model, position, token) {
  1629. const resource = model.uri;
  1630. return this._worker(resource).then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position))).then((entries) => {
  1631. if (!entries) {
  1632. return;
  1633. }
  1634. return entries.map((entry) => {
  1635. return {
  1636. range: toRange(entry.range),
  1637. kind: toDocumentHighlightKind(entry.kind)
  1638. };
  1639. });
  1640. });
  1641. }
  1642. };
  1643. function toDocumentHighlightKind(kind) {
  1644. switch (kind) {
  1645. case DocumentHighlightKind.Read:
  1646. return monaco_editor_core_exports.languages.DocumentHighlightKind.Read;
  1647. case DocumentHighlightKind.Write:
  1648. return monaco_editor_core_exports.languages.DocumentHighlightKind.Write;
  1649. case DocumentHighlightKind.Text:
  1650. return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
  1651. }
  1652. return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
  1653. }
  1654. var DefinitionAdapter = class {
  1655. constructor(_worker) {
  1656. this._worker = _worker;
  1657. }
  1658. provideDefinition(model, position, token) {
  1659. const resource = model.uri;
  1660. return this._worker(resource).then((worker) => {
  1661. return worker.findDefinition(resource.toString(), fromPosition(position));
  1662. }).then((definition) => {
  1663. if (!definition) {
  1664. return;
  1665. }
  1666. return [toLocation(definition)];
  1667. });
  1668. }
  1669. };
  1670. function toLocation(location) {
  1671. return {
  1672. uri: monaco_editor_core_exports.Uri.parse(location.uri),
  1673. range: toRange(location.range)
  1674. };
  1675. }
  1676. var ReferenceAdapter = class {
  1677. constructor(_worker) {
  1678. this._worker = _worker;
  1679. }
  1680. provideReferences(model, position, context, token) {
  1681. const resource = model.uri;
  1682. return this._worker(resource).then((worker) => {
  1683. return worker.findReferences(resource.toString(), fromPosition(position));
  1684. }).then((entries) => {
  1685. if (!entries) {
  1686. return;
  1687. }
  1688. return entries.map(toLocation);
  1689. });
  1690. }
  1691. };
  1692. var RenameAdapter = class {
  1693. constructor(_worker) {
  1694. this._worker = _worker;
  1695. }
  1696. provideRenameEdits(model, position, newName, token) {
  1697. const resource = model.uri;
  1698. return this._worker(resource).then((worker) => {
  1699. return worker.doRename(resource.toString(), fromPosition(position), newName);
  1700. }).then((edit) => {
  1701. return toWorkspaceEdit(edit);
  1702. });
  1703. }
  1704. };
  1705. function toWorkspaceEdit(edit) {
  1706. if (!edit || !edit.changes) {
  1707. return void 0;
  1708. }
  1709. let resourceEdits = [];
  1710. for (let uri in edit.changes) {
  1711. const _uri = monaco_editor_core_exports.Uri.parse(uri);
  1712. for (let e of edit.changes[uri]) {
  1713. resourceEdits.push({
  1714. resource: _uri,
  1715. versionId: void 0,
  1716. textEdit: {
  1717. range: toRange(e.range),
  1718. text: e.newText
  1719. }
  1720. });
  1721. }
  1722. }
  1723. return {
  1724. edits: resourceEdits
  1725. };
  1726. }
  1727. var DocumentSymbolAdapter = class {
  1728. constructor(_worker) {
  1729. this._worker = _worker;
  1730. }
  1731. provideDocumentSymbols(model, token) {
  1732. const resource = model.uri;
  1733. return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
  1734. if (!items) {
  1735. return;
  1736. }
  1737. return items.map((item) => ({
  1738. name: item.name,
  1739. detail: "",
  1740. containerName: item.containerName,
  1741. kind: toSymbolKind(item.kind),
  1742. range: toRange(item.location.range),
  1743. selectionRange: toRange(item.location.range),
  1744. tags: []
  1745. }));
  1746. });
  1747. }
  1748. };
  1749. function toSymbolKind(kind) {
  1750. let mKind = monaco_editor_core_exports.languages.SymbolKind;
  1751. switch (kind) {
  1752. case SymbolKind.File:
  1753. return mKind.Array;
  1754. case SymbolKind.Module:
  1755. return mKind.Module;
  1756. case SymbolKind.Namespace:
  1757. return mKind.Namespace;
  1758. case SymbolKind.Package:
  1759. return mKind.Package;
  1760. case SymbolKind.Class:
  1761. return mKind.Class;
  1762. case SymbolKind.Method:
  1763. return mKind.Method;
  1764. case SymbolKind.Property:
  1765. return mKind.Property;
  1766. case SymbolKind.Field:
  1767. return mKind.Field;
  1768. case SymbolKind.Constructor:
  1769. return mKind.Constructor;
  1770. case SymbolKind.Enum:
  1771. return mKind.Enum;
  1772. case SymbolKind.Interface:
  1773. return mKind.Interface;
  1774. case SymbolKind.Function:
  1775. return mKind.Function;
  1776. case SymbolKind.Variable:
  1777. return mKind.Variable;
  1778. case SymbolKind.Constant:
  1779. return mKind.Constant;
  1780. case SymbolKind.String:
  1781. return mKind.String;
  1782. case SymbolKind.Number:
  1783. return mKind.Number;
  1784. case SymbolKind.Boolean:
  1785. return mKind.Boolean;
  1786. case SymbolKind.Array:
  1787. return mKind.Array;
  1788. }
  1789. return mKind.Function;
  1790. }
  1791. var DocumentLinkAdapter = class {
  1792. constructor(_worker) {
  1793. this._worker = _worker;
  1794. }
  1795. provideLinks(model, token) {
  1796. const resource = model.uri;
  1797. return this._worker(resource).then((worker) => worker.findDocumentLinks(resource.toString())).then((items) => {
  1798. if (!items) {
  1799. return;
  1800. }
  1801. return {
  1802. links: items.map((item) => ({
  1803. range: toRange(item.range),
  1804. url: item.target
  1805. }))
  1806. };
  1807. });
  1808. }
  1809. };
  1810. var DocumentFormattingEditProvider = class {
  1811. constructor(_worker) {
  1812. this._worker = _worker;
  1813. }
  1814. provideDocumentFormattingEdits(model, options, token) {
  1815. const resource = model.uri;
  1816. return this._worker(resource).then((worker) => {
  1817. return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
  1818. if (!edits || edits.length === 0) {
  1819. return;
  1820. }
  1821. return edits.map(toTextEdit);
  1822. });
  1823. });
  1824. }
  1825. };
  1826. var DocumentRangeFormattingEditProvider = class {
  1827. constructor(_worker) {
  1828. __publicField(this, "canFormatMultipleRanges", false);
  1829. this._worker = _worker;
  1830. }
  1831. provideDocumentRangeFormattingEdits(model, range, options, token) {
  1832. const resource = model.uri;
  1833. return this._worker(resource).then((worker) => {
  1834. return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
  1835. if (!edits || edits.length === 0) {
  1836. return;
  1837. }
  1838. return edits.map(toTextEdit);
  1839. });
  1840. });
  1841. }
  1842. };
  1843. function fromFormattingOptions(options) {
  1844. return {
  1845. tabSize: options.tabSize,
  1846. insertSpaces: options.insertSpaces
  1847. };
  1848. }
  1849. var DocumentColorAdapter = class {
  1850. constructor(_worker) {
  1851. this._worker = _worker;
  1852. }
  1853. provideDocumentColors(model, token) {
  1854. const resource = model.uri;
  1855. return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
  1856. if (!infos) {
  1857. return;
  1858. }
  1859. return infos.map((item) => ({
  1860. color: item.color,
  1861. range: toRange(item.range)
  1862. }));
  1863. });
  1864. }
  1865. provideColorPresentations(model, info, token) {
  1866. const resource = model.uri;
  1867. return this._worker(resource).then((worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then((presentations) => {
  1868. if (!presentations) {
  1869. return;
  1870. }
  1871. return presentations.map((presentation) => {
  1872. let item = {
  1873. label: presentation.label
  1874. };
  1875. if (presentation.textEdit) {
  1876. item.textEdit = toTextEdit(presentation.textEdit);
  1877. }
  1878. if (presentation.additionalTextEdits) {
  1879. item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
  1880. }
  1881. return item;
  1882. });
  1883. });
  1884. }
  1885. };
  1886. var FoldingRangeAdapter = class {
  1887. constructor(_worker) {
  1888. this._worker = _worker;
  1889. }
  1890. provideFoldingRanges(model, context, token) {
  1891. const resource = model.uri;
  1892. return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
  1893. if (!ranges) {
  1894. return;
  1895. }
  1896. return ranges.map((range) => {
  1897. const result = {
  1898. start: range.startLine + 1,
  1899. end: range.endLine + 1
  1900. };
  1901. if (typeof range.kind !== "undefined") {
  1902. result.kind = toFoldingRangeKind(range.kind);
  1903. }
  1904. return result;
  1905. });
  1906. });
  1907. }
  1908. };
  1909. function toFoldingRangeKind(kind) {
  1910. switch (kind) {
  1911. case FoldingRangeKind.Comment:
  1912. return monaco_editor_core_exports.languages.FoldingRangeKind.Comment;
  1913. case FoldingRangeKind.Imports:
  1914. return monaco_editor_core_exports.languages.FoldingRangeKind.Imports;
  1915. case FoldingRangeKind.Region:
  1916. return monaco_editor_core_exports.languages.FoldingRangeKind.Region;
  1917. }
  1918. return void 0;
  1919. }
  1920. var SelectionRangeAdapter = class {
  1921. constructor(_worker) {
  1922. this._worker = _worker;
  1923. }
  1924. provideSelectionRanges(model, positions, token) {
  1925. const resource = model.uri;
  1926. return this._worker(resource).then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition))).then((selectionRanges) => {
  1927. if (!selectionRanges) {
  1928. return;
  1929. }
  1930. return selectionRanges.map((selectionRange) => {
  1931. const result = [];
  1932. while (selectionRange) {
  1933. result.push({ range: toRange(selectionRange.range) });
  1934. selectionRange = selectionRange.parent;
  1935. }
  1936. return result;
  1937. });
  1938. });
  1939. }
  1940. };
  1941. function setupMode(defaults) {
  1942. const disposables = [];
  1943. const providers = [];
  1944. const client = new WorkerManager(defaults);
  1945. disposables.push(client);
  1946. const worker = (...uris) => {
  1947. return client.getLanguageServiceWorker(...uris);
  1948. };
  1949. function registerProviders() {
  1950. const { languageId, modeConfiguration } = defaults;
  1951. disposeAll(providers);
  1952. if (modeConfiguration.completionItems) {
  1953. providers.push(monaco_editor_core_exports.languages.registerCompletionItemProvider(languageId, new CompletionAdapter(worker, ["/", "-", ":"])));
  1954. }
  1955. if (modeConfiguration.hovers) {
  1956. providers.push(monaco_editor_core_exports.languages.registerHoverProvider(languageId, new HoverAdapter(worker)));
  1957. }
  1958. if (modeConfiguration.documentHighlights) {
  1959. providers.push(monaco_editor_core_exports.languages.registerDocumentHighlightProvider(languageId, new DocumentHighlightAdapter(worker)));
  1960. }
  1961. if (modeConfiguration.definitions) {
  1962. providers.push(monaco_editor_core_exports.languages.registerDefinitionProvider(languageId, new DefinitionAdapter(worker)));
  1963. }
  1964. if (modeConfiguration.references) {
  1965. providers.push(monaco_editor_core_exports.languages.registerReferenceProvider(languageId, new ReferenceAdapter(worker)));
  1966. }
  1967. if (modeConfiguration.documentSymbols) {
  1968. providers.push(monaco_editor_core_exports.languages.registerDocumentSymbolProvider(languageId, new DocumentSymbolAdapter(worker)));
  1969. }
  1970. if (modeConfiguration.rename) {
  1971. providers.push(monaco_editor_core_exports.languages.registerRenameProvider(languageId, new RenameAdapter(worker)));
  1972. }
  1973. if (modeConfiguration.colors) {
  1974. providers.push(monaco_editor_core_exports.languages.registerColorProvider(languageId, new DocumentColorAdapter(worker)));
  1975. }
  1976. if (modeConfiguration.foldingRanges) {
  1977. providers.push(monaco_editor_core_exports.languages.registerFoldingRangeProvider(languageId, new FoldingRangeAdapter(worker)));
  1978. }
  1979. if (modeConfiguration.diagnostics) {
  1980. providers.push(new DiagnosticsAdapter(languageId, worker, defaults.onDidChange));
  1981. }
  1982. if (modeConfiguration.selectionRanges) {
  1983. providers.push(monaco_editor_core_exports.languages.registerSelectionRangeProvider(languageId, new SelectionRangeAdapter(worker)));
  1984. }
  1985. if (modeConfiguration.documentFormattingEdits) {
  1986. providers.push(monaco_editor_core_exports.languages.registerDocumentFormattingEditProvider(languageId, new DocumentFormattingEditProvider(worker)));
  1987. }
  1988. if (modeConfiguration.documentRangeFormattingEdits) {
  1989. providers.push(monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(languageId, new DocumentRangeFormattingEditProvider(worker)));
  1990. }
  1991. }
  1992. registerProviders();
  1993. disposables.push(asDisposable(providers));
  1994. return asDisposable(disposables);
  1995. }
  1996. function asDisposable(disposables) {
  1997. return { dispose: () => disposeAll(disposables) };
  1998. }
  1999. function disposeAll(disposables) {
  2000. while (disposables.length) {
  2001. disposables.pop().dispose();
  2002. }
  2003. }
  2004. export {
  2005. CompletionAdapter,
  2006. DefinitionAdapter,
  2007. DiagnosticsAdapter,
  2008. DocumentColorAdapter,
  2009. DocumentFormattingEditProvider,
  2010. DocumentHighlightAdapter,
  2011. DocumentLinkAdapter,
  2012. DocumentRangeFormattingEditProvider,
  2013. DocumentSymbolAdapter,
  2014. FoldingRangeAdapter,
  2015. HoverAdapter,
  2016. ReferenceAdapter,
  2017. RenameAdapter,
  2018. SelectionRangeAdapter,
  2019. WorkerManager,
  2020. fromPosition,
  2021. fromRange,
  2022. setupMode,
  2023. toRange,
  2024. toTextEdit
  2025. };
  2026. /*! Bundled license information:
  2027. monaco-editor/esm/vs/language/css/cssMode.js:
  2028. (*!-----------------------------------------------------------------------------
  2029. * Copyright (c) Microsoft Corporation. All rights reserved.
  2030. * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
  2031. * Released under the MIT license
  2032. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  2033. *-----------------------------------------------------------------------------*)
  2034. */
  2035. //# sourceMappingURL=cssMode-WPBTKTDP.js.map