htmlMode.js 67 KB

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