cssMode.js 74 KB

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