jsonMode.js 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532
  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/json/jsonMode",[],()=>{
  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/json/jsonMode.ts
  42. var jsonMode_exports = {};
  43. __export(jsonMode_exports, {
  44. setupMode: () => setupMode
  45. });
  46. // src/fillers/monaco-editor-core.ts
  47. var monaco_editor_core_exports = {};
  48. __markAsModule(monaco_editor_core_exports);
  49. __reExport(monaco_editor_core_exports, __toModule(require_monaco_editor_core_amd()));
  50. // src/json/workerManager.ts
  51. var STOP_WHEN_IDLE_FOR = 2 * 60 * 1e3;
  52. var WorkerManager = class {
  53. constructor(defaults) {
  54. this._defaults = defaults;
  55. this._worker = null;
  56. this._client = null;
  57. this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1e3);
  58. this._lastUsedTime = 0;
  59. this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
  60. }
  61. _stopWorker() {
  62. if (this._worker) {
  63. this._worker.dispose();
  64. this._worker = null;
  65. }
  66. this._client = null;
  67. }
  68. dispose() {
  69. clearInterval(this._idleCheckInterval);
  70. this._configChangeListener.dispose();
  71. this._stopWorker();
  72. }
  73. _checkIfIdle() {
  74. if (!this._worker) {
  75. return;
  76. }
  77. let timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
  78. if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
  79. this._stopWorker();
  80. }
  81. }
  82. _getClient() {
  83. this._lastUsedTime = Date.now();
  84. if (!this._client) {
  85. this._worker = monaco_editor_core_exports.editor.createWebWorker({
  86. moduleId: "vs/language/json/jsonWorker",
  87. label: this._defaults.languageId,
  88. createData: {
  89. languageSettings: this._defaults.diagnosticsOptions,
  90. languageId: this._defaults.languageId,
  91. enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest
  92. }
  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 edit2;
  508. var id;
  509. if (annotation === void 0) {
  510. edit2 = TextEdit.insert(position, newText);
  511. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  512. id = annotation;
  513. edit2 = AnnotatedTextEdit.insert(position, newText, annotation);
  514. } else {
  515. this.assertChangeAnnotations(this.changeAnnotations);
  516. id = this.changeAnnotations.manage(annotation);
  517. edit2 = AnnotatedTextEdit.insert(position, newText, id);
  518. }
  519. this.edits.push(edit2);
  520. if (id !== void 0) {
  521. return id;
  522. }
  523. };
  524. TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
  525. var edit2;
  526. var id;
  527. if (annotation === void 0) {
  528. edit2 = TextEdit.replace(range, newText);
  529. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  530. id = annotation;
  531. edit2 = AnnotatedTextEdit.replace(range, newText, annotation);
  532. } else {
  533. this.assertChangeAnnotations(this.changeAnnotations);
  534. id = this.changeAnnotations.manage(annotation);
  535. edit2 = AnnotatedTextEdit.replace(range, newText, id);
  536. }
  537. this.edits.push(edit2);
  538. if (id !== void 0) {
  539. return id;
  540. }
  541. };
  542. TextEditChangeImpl2.prototype.delete = function(range, annotation) {
  543. var edit2;
  544. var id;
  545. if (annotation === void 0) {
  546. edit2 = TextEdit.del(range);
  547. } else if (ChangeAnnotationIdentifier.is(annotation)) {
  548. id = annotation;
  549. edit2 = AnnotatedTextEdit.del(range, annotation);
  550. } else {
  551. this.assertChangeAnnotations(this.changeAnnotations);
  552. id = this.changeAnnotations.manage(annotation);
  553. edit2 = AnnotatedTextEdit.del(range, id);
  554. }
  555. this.edits.push(edit2);
  556. if (id !== void 0) {
  557. return id;
  558. }
  559. };
  560. TextEditChangeImpl2.prototype.add = function(edit2) {
  561. this.edits.push(edit2);
  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 DiagnosticsAdapter = class {
  1368. constructor(_languageId, _worker, configChangeEvent) {
  1369. this._languageId = _languageId;
  1370. this._worker = _worker;
  1371. this._disposables = [];
  1372. this._listener = Object.create(null);
  1373. const onModelAdd = (model) => {
  1374. let modeId = model.getLanguageId();
  1375. if (modeId !== this._languageId) {
  1376. return;
  1377. }
  1378. let handle;
  1379. this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
  1380. window.clearTimeout(handle);
  1381. handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
  1382. });
  1383. this._doValidate(model.uri, modeId);
  1384. };
  1385. const onModelRemoved = (model) => {
  1386. monaco_editor_core_exports.editor.setModelMarkers(model, this._languageId, []);
  1387. let uriStr = model.uri.toString();
  1388. let listener = this._listener[uriStr];
  1389. if (listener) {
  1390. listener.dispose();
  1391. delete this._listener[uriStr];
  1392. }
  1393. };
  1394. this._disposables.push(monaco_editor_core_exports.editor.onDidCreateModel(onModelAdd));
  1395. this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel(onModelRemoved));
  1396. this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
  1397. onModelRemoved(event.model);
  1398. onModelAdd(event.model);
  1399. }));
  1400. this._disposables.push(configChangeEvent((_) => {
  1401. monaco_editor_core_exports.editor.getModels().forEach((model) => {
  1402. if (model.getLanguageId() === this._languageId) {
  1403. onModelRemoved(model);
  1404. onModelAdd(model);
  1405. }
  1406. });
  1407. }));
  1408. this._disposables.push({
  1409. dispose: () => {
  1410. monaco_editor_core_exports.editor.getModels().forEach(onModelRemoved);
  1411. for (let key in this._listener) {
  1412. this._listener[key].dispose();
  1413. }
  1414. }
  1415. });
  1416. monaco_editor_core_exports.editor.getModels().forEach(onModelAdd);
  1417. }
  1418. dispose() {
  1419. this._disposables.forEach((d) => d && d.dispose());
  1420. this._disposables.length = 0;
  1421. }
  1422. _doValidate(resource, languageId) {
  1423. this._worker(resource).then((worker) => {
  1424. return worker.doValidation(resource.toString());
  1425. }).then((diagnostics) => {
  1426. const markers = diagnostics.map((d) => toDiagnostics(resource, d));
  1427. let model = monaco_editor_core_exports.editor.getModel(resource);
  1428. if (model && model.getLanguageId() === languageId) {
  1429. monaco_editor_core_exports.editor.setModelMarkers(model, languageId, markers);
  1430. }
  1431. }).then(void 0, (err) => {
  1432. console.error(err);
  1433. });
  1434. }
  1435. };
  1436. function toSeverity(lsSeverity) {
  1437. switch (lsSeverity) {
  1438. case DiagnosticSeverity.Error:
  1439. return monaco_editor_core_exports.MarkerSeverity.Error;
  1440. case DiagnosticSeverity.Warning:
  1441. return monaco_editor_core_exports.MarkerSeverity.Warning;
  1442. case DiagnosticSeverity.Information:
  1443. return monaco_editor_core_exports.MarkerSeverity.Info;
  1444. case DiagnosticSeverity.Hint:
  1445. return monaco_editor_core_exports.MarkerSeverity.Hint;
  1446. default:
  1447. return monaco_editor_core_exports.MarkerSeverity.Info;
  1448. }
  1449. }
  1450. function toDiagnostics(resource, diag) {
  1451. let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
  1452. return {
  1453. severity: toSeverity(diag.severity),
  1454. startLineNumber: diag.range.start.line + 1,
  1455. startColumn: diag.range.start.character + 1,
  1456. endLineNumber: diag.range.end.line + 1,
  1457. endColumn: diag.range.end.character + 1,
  1458. message: diag.message,
  1459. code,
  1460. source: diag.source
  1461. };
  1462. }
  1463. var CompletionAdapter = class {
  1464. constructor(_worker, _triggerCharacters) {
  1465. this._worker = _worker;
  1466. this._triggerCharacters = _triggerCharacters;
  1467. }
  1468. get triggerCharacters() {
  1469. return this._triggerCharacters;
  1470. }
  1471. provideCompletionItems(model, position, context, token) {
  1472. const resource = model.uri;
  1473. return this._worker(resource).then((worker) => {
  1474. return worker.doComplete(resource.toString(), fromPosition(position));
  1475. }).then((info) => {
  1476. if (!info) {
  1477. return;
  1478. }
  1479. const wordInfo = model.getWordUntilPosition(position);
  1480. const wordRange = new monaco_editor_core_exports.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
  1481. const items = info.items.map((entry) => {
  1482. const item = {
  1483. label: entry.label,
  1484. insertText: entry.insertText || entry.label,
  1485. sortText: entry.sortText,
  1486. filterText: entry.filterText,
  1487. documentation: entry.documentation,
  1488. detail: entry.detail,
  1489. command: toCommand(entry.command),
  1490. range: wordRange,
  1491. kind: toCompletionItemKind(entry.kind)
  1492. };
  1493. if (entry.textEdit) {
  1494. if (isInsertReplaceEdit(entry.textEdit)) {
  1495. item.range = {
  1496. insert: toRange(entry.textEdit.insert),
  1497. replace: toRange(entry.textEdit.replace)
  1498. };
  1499. } else {
  1500. item.range = toRange(entry.textEdit.range);
  1501. }
  1502. item.insertText = entry.textEdit.newText;
  1503. }
  1504. if (entry.additionalTextEdits) {
  1505. item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
  1506. }
  1507. if (entry.insertTextFormat === InsertTextFormat.Snippet) {
  1508. item.insertTextRules = monaco_editor_core_exports.languages.CompletionItemInsertTextRule.InsertAsSnippet;
  1509. }
  1510. return item;
  1511. });
  1512. return {
  1513. isIncomplete: info.isIncomplete,
  1514. suggestions: items
  1515. };
  1516. });
  1517. }
  1518. };
  1519. function fromPosition(position) {
  1520. if (!position) {
  1521. return void 0;
  1522. }
  1523. return { character: position.column - 1, line: position.lineNumber - 1 };
  1524. }
  1525. function fromRange(range) {
  1526. if (!range) {
  1527. return void 0;
  1528. }
  1529. return {
  1530. start: {
  1531. line: range.startLineNumber - 1,
  1532. character: range.startColumn - 1
  1533. },
  1534. end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
  1535. };
  1536. }
  1537. function toRange(range) {
  1538. if (!range) {
  1539. return void 0;
  1540. }
  1541. return new monaco_editor_core_exports.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
  1542. }
  1543. function isInsertReplaceEdit(edit2) {
  1544. return typeof edit2.insert !== "undefined" && typeof edit2.replace !== "undefined";
  1545. }
  1546. function toCompletionItemKind(kind) {
  1547. const mItemKind = monaco_editor_core_exports.languages.CompletionItemKind;
  1548. switch (kind) {
  1549. case CompletionItemKind.Text:
  1550. return mItemKind.Text;
  1551. case CompletionItemKind.Method:
  1552. return mItemKind.Method;
  1553. case CompletionItemKind.Function:
  1554. return mItemKind.Function;
  1555. case CompletionItemKind.Constructor:
  1556. return mItemKind.Constructor;
  1557. case CompletionItemKind.Field:
  1558. return mItemKind.Field;
  1559. case CompletionItemKind.Variable:
  1560. return mItemKind.Variable;
  1561. case CompletionItemKind.Class:
  1562. return mItemKind.Class;
  1563. case CompletionItemKind.Interface:
  1564. return mItemKind.Interface;
  1565. case CompletionItemKind.Module:
  1566. return mItemKind.Module;
  1567. case CompletionItemKind.Property:
  1568. return mItemKind.Property;
  1569. case CompletionItemKind.Unit:
  1570. return mItemKind.Unit;
  1571. case CompletionItemKind.Value:
  1572. return mItemKind.Value;
  1573. case CompletionItemKind.Enum:
  1574. return mItemKind.Enum;
  1575. case CompletionItemKind.Keyword:
  1576. return mItemKind.Keyword;
  1577. case CompletionItemKind.Snippet:
  1578. return mItemKind.Snippet;
  1579. case CompletionItemKind.Color:
  1580. return mItemKind.Color;
  1581. case CompletionItemKind.File:
  1582. return mItemKind.File;
  1583. case CompletionItemKind.Reference:
  1584. return mItemKind.Reference;
  1585. }
  1586. return mItemKind.Property;
  1587. }
  1588. function toTextEdit(textEdit) {
  1589. if (!textEdit) {
  1590. return void 0;
  1591. }
  1592. return {
  1593. range: toRange(textEdit.range),
  1594. text: textEdit.newText
  1595. };
  1596. }
  1597. function toCommand(c) {
  1598. return c && c.command === "editor.action.triggerSuggest" ? { id: c.command, title: c.title, arguments: c.arguments } : void 0;
  1599. }
  1600. var HoverAdapter = class {
  1601. constructor(_worker) {
  1602. this._worker = _worker;
  1603. }
  1604. provideHover(model, position, token) {
  1605. let resource = model.uri;
  1606. return this._worker(resource).then((worker) => {
  1607. return worker.doHover(resource.toString(), fromPosition(position));
  1608. }).then((info) => {
  1609. if (!info) {
  1610. return;
  1611. }
  1612. return {
  1613. range: toRange(info.range),
  1614. contents: toMarkedStringArray(info.contents)
  1615. };
  1616. });
  1617. }
  1618. };
  1619. function isMarkupContent(thing) {
  1620. return thing && typeof thing === "object" && typeof thing.kind === "string";
  1621. }
  1622. function toMarkdownString(entry) {
  1623. if (typeof entry === "string") {
  1624. return {
  1625. value: entry
  1626. };
  1627. }
  1628. if (isMarkupContent(entry)) {
  1629. if (entry.kind === "plaintext") {
  1630. return {
  1631. value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
  1632. };
  1633. }
  1634. return {
  1635. value: entry.value
  1636. };
  1637. }
  1638. return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
  1639. }
  1640. function toMarkedStringArray(contents) {
  1641. if (!contents) {
  1642. return void 0;
  1643. }
  1644. if (Array.isArray(contents)) {
  1645. return contents.map(toMarkdownString);
  1646. }
  1647. return [toMarkdownString(contents)];
  1648. }
  1649. var DocumentSymbolAdapter = class {
  1650. constructor(_worker) {
  1651. this._worker = _worker;
  1652. }
  1653. provideDocumentSymbols(model, token) {
  1654. const resource = model.uri;
  1655. return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
  1656. if (!items) {
  1657. return;
  1658. }
  1659. return items.map((item) => ({
  1660. name: item.name,
  1661. detail: "",
  1662. containerName: item.containerName,
  1663. kind: toSymbolKind(item.kind),
  1664. range: toRange(item.location.range),
  1665. selectionRange: toRange(item.location.range),
  1666. tags: []
  1667. }));
  1668. });
  1669. }
  1670. };
  1671. function toSymbolKind(kind) {
  1672. let mKind = monaco_editor_core_exports.languages.SymbolKind;
  1673. switch (kind) {
  1674. case SymbolKind.File:
  1675. return mKind.Array;
  1676. case SymbolKind.Module:
  1677. return mKind.Module;
  1678. case SymbolKind.Namespace:
  1679. return mKind.Namespace;
  1680. case SymbolKind.Package:
  1681. return mKind.Package;
  1682. case SymbolKind.Class:
  1683. return mKind.Class;
  1684. case SymbolKind.Method:
  1685. return mKind.Method;
  1686. case SymbolKind.Property:
  1687. return mKind.Property;
  1688. case SymbolKind.Field:
  1689. return mKind.Field;
  1690. case SymbolKind.Constructor:
  1691. return mKind.Constructor;
  1692. case SymbolKind.Enum:
  1693. return mKind.Enum;
  1694. case SymbolKind.Interface:
  1695. return mKind.Interface;
  1696. case SymbolKind.Function:
  1697. return mKind.Function;
  1698. case SymbolKind.Variable:
  1699. return mKind.Variable;
  1700. case SymbolKind.Constant:
  1701. return mKind.Constant;
  1702. case SymbolKind.String:
  1703. return mKind.String;
  1704. case SymbolKind.Number:
  1705. return mKind.Number;
  1706. case SymbolKind.Boolean:
  1707. return mKind.Boolean;
  1708. case SymbolKind.Array:
  1709. return mKind.Array;
  1710. }
  1711. return mKind.Function;
  1712. }
  1713. var DocumentFormattingEditProvider = class {
  1714. constructor(_worker) {
  1715. this._worker = _worker;
  1716. }
  1717. provideDocumentFormattingEdits(model, options, token) {
  1718. const resource = model.uri;
  1719. return this._worker(resource).then((worker) => {
  1720. return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
  1721. if (!edits || edits.length === 0) {
  1722. return;
  1723. }
  1724. return edits.map(toTextEdit);
  1725. });
  1726. });
  1727. }
  1728. };
  1729. var DocumentRangeFormattingEditProvider = class {
  1730. constructor(_worker) {
  1731. this._worker = _worker;
  1732. }
  1733. provideDocumentRangeFormattingEdits(model, range, options, token) {
  1734. const resource = model.uri;
  1735. return this._worker(resource).then((worker) => {
  1736. return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
  1737. if (!edits || edits.length === 0) {
  1738. return;
  1739. }
  1740. return edits.map(toTextEdit);
  1741. });
  1742. });
  1743. }
  1744. };
  1745. function fromFormattingOptions(options) {
  1746. return {
  1747. tabSize: options.tabSize,
  1748. insertSpaces: options.insertSpaces
  1749. };
  1750. }
  1751. var DocumentColorAdapter = class {
  1752. constructor(_worker) {
  1753. this._worker = _worker;
  1754. }
  1755. provideDocumentColors(model, token) {
  1756. const resource = model.uri;
  1757. return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
  1758. if (!infos) {
  1759. return;
  1760. }
  1761. return infos.map((item) => ({
  1762. color: item.color,
  1763. range: toRange(item.range)
  1764. }));
  1765. });
  1766. }
  1767. provideColorPresentations(model, info, token) {
  1768. const resource = model.uri;
  1769. return this._worker(resource).then((worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then((presentations) => {
  1770. if (!presentations) {
  1771. return;
  1772. }
  1773. return presentations.map((presentation) => {
  1774. let item = {
  1775. label: presentation.label
  1776. };
  1777. if (presentation.textEdit) {
  1778. item.textEdit = toTextEdit(presentation.textEdit);
  1779. }
  1780. if (presentation.additionalTextEdits) {
  1781. item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
  1782. }
  1783. return item;
  1784. });
  1785. });
  1786. }
  1787. };
  1788. var FoldingRangeAdapter = class {
  1789. constructor(_worker) {
  1790. this._worker = _worker;
  1791. }
  1792. provideFoldingRanges(model, context, token) {
  1793. const resource = model.uri;
  1794. return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
  1795. if (!ranges) {
  1796. return;
  1797. }
  1798. return ranges.map((range) => {
  1799. const result = {
  1800. start: range.startLine + 1,
  1801. end: range.endLine + 1
  1802. };
  1803. if (typeof range.kind !== "undefined") {
  1804. result.kind = toFoldingRangeKind(range.kind);
  1805. }
  1806. return result;
  1807. });
  1808. });
  1809. }
  1810. };
  1811. function toFoldingRangeKind(kind) {
  1812. switch (kind) {
  1813. case FoldingRangeKind.Comment:
  1814. return monaco_editor_core_exports.languages.FoldingRangeKind.Comment;
  1815. case FoldingRangeKind.Imports:
  1816. return monaco_editor_core_exports.languages.FoldingRangeKind.Imports;
  1817. case FoldingRangeKind.Region:
  1818. return monaco_editor_core_exports.languages.FoldingRangeKind.Region;
  1819. }
  1820. return void 0;
  1821. }
  1822. var SelectionRangeAdapter = class {
  1823. constructor(_worker) {
  1824. this._worker = _worker;
  1825. }
  1826. provideSelectionRanges(model, positions, token) {
  1827. const resource = model.uri;
  1828. return this._worker(resource).then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition))).then((selectionRanges) => {
  1829. if (!selectionRanges) {
  1830. return;
  1831. }
  1832. return selectionRanges.map((selectionRange) => {
  1833. const result = [];
  1834. while (selectionRange) {
  1835. result.push({ range: toRange(selectionRange.range) });
  1836. selectionRange = selectionRange.parent;
  1837. }
  1838. return result;
  1839. });
  1840. });
  1841. }
  1842. };
  1843. // node_modules/jsonc-parser/lib/esm/impl/scanner.js
  1844. "use strict";
  1845. function createScanner(text, ignoreTrivia) {
  1846. if (ignoreTrivia === void 0) {
  1847. ignoreTrivia = false;
  1848. }
  1849. var len = text.length;
  1850. var pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
  1851. function scanHexDigits(count, exact) {
  1852. var digits = 0;
  1853. var value2 = 0;
  1854. while (digits < count || !exact) {
  1855. var ch = text.charCodeAt(pos);
  1856. if (ch >= 48 && ch <= 57) {
  1857. value2 = value2 * 16 + ch - 48;
  1858. } else if (ch >= 65 && ch <= 70) {
  1859. value2 = value2 * 16 + ch - 65 + 10;
  1860. } else if (ch >= 97 && ch <= 102) {
  1861. value2 = value2 * 16 + ch - 97 + 10;
  1862. } else {
  1863. break;
  1864. }
  1865. pos++;
  1866. digits++;
  1867. }
  1868. if (digits < count) {
  1869. value2 = -1;
  1870. }
  1871. return value2;
  1872. }
  1873. function setPosition(newPosition) {
  1874. pos = newPosition;
  1875. value = "";
  1876. tokenOffset = 0;
  1877. token = 16;
  1878. scanError = 0;
  1879. }
  1880. function scanNumber() {
  1881. var start = pos;
  1882. if (text.charCodeAt(pos) === 48) {
  1883. pos++;
  1884. } else {
  1885. pos++;
  1886. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  1887. pos++;
  1888. }
  1889. }
  1890. if (pos < text.length && text.charCodeAt(pos) === 46) {
  1891. pos++;
  1892. if (pos < text.length && isDigit(text.charCodeAt(pos))) {
  1893. pos++;
  1894. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  1895. pos++;
  1896. }
  1897. } else {
  1898. scanError = 3;
  1899. return text.substring(start, pos);
  1900. }
  1901. }
  1902. var end = pos;
  1903. if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
  1904. pos++;
  1905. if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
  1906. pos++;
  1907. }
  1908. if (pos < text.length && isDigit(text.charCodeAt(pos))) {
  1909. pos++;
  1910. while (pos < text.length && isDigit(text.charCodeAt(pos))) {
  1911. pos++;
  1912. }
  1913. end = pos;
  1914. } else {
  1915. scanError = 3;
  1916. }
  1917. }
  1918. return text.substring(start, end);
  1919. }
  1920. function scanString() {
  1921. var result = "", start = pos;
  1922. while (true) {
  1923. if (pos >= len) {
  1924. result += text.substring(start, pos);
  1925. scanError = 2;
  1926. break;
  1927. }
  1928. var ch = text.charCodeAt(pos);
  1929. if (ch === 34) {
  1930. result += text.substring(start, pos);
  1931. pos++;
  1932. break;
  1933. }
  1934. if (ch === 92) {
  1935. result += text.substring(start, pos);
  1936. pos++;
  1937. if (pos >= len) {
  1938. scanError = 2;
  1939. break;
  1940. }
  1941. var ch2 = text.charCodeAt(pos++);
  1942. switch (ch2) {
  1943. case 34:
  1944. result += '"';
  1945. break;
  1946. case 92:
  1947. result += "\\";
  1948. break;
  1949. case 47:
  1950. result += "/";
  1951. break;
  1952. case 98:
  1953. result += "\b";
  1954. break;
  1955. case 102:
  1956. result += "\f";
  1957. break;
  1958. case 110:
  1959. result += "\n";
  1960. break;
  1961. case 114:
  1962. result += "\r";
  1963. break;
  1964. case 116:
  1965. result += " ";
  1966. break;
  1967. case 117:
  1968. var ch3 = scanHexDigits(4, true);
  1969. if (ch3 >= 0) {
  1970. result += String.fromCharCode(ch3);
  1971. } else {
  1972. scanError = 4;
  1973. }
  1974. break;
  1975. default:
  1976. scanError = 5;
  1977. }
  1978. start = pos;
  1979. continue;
  1980. }
  1981. if (ch >= 0 && ch <= 31) {
  1982. if (isLineBreak(ch)) {
  1983. result += text.substring(start, pos);
  1984. scanError = 2;
  1985. break;
  1986. } else {
  1987. scanError = 6;
  1988. }
  1989. }
  1990. pos++;
  1991. }
  1992. return result;
  1993. }
  1994. function scanNext() {
  1995. value = "";
  1996. scanError = 0;
  1997. tokenOffset = pos;
  1998. lineStartOffset = lineNumber;
  1999. prevTokenLineStartOffset = tokenLineStartOffset;
  2000. if (pos >= len) {
  2001. tokenOffset = len;
  2002. return token = 17;
  2003. }
  2004. var code = text.charCodeAt(pos);
  2005. if (isWhiteSpace(code)) {
  2006. do {
  2007. pos++;
  2008. value += String.fromCharCode(code);
  2009. code = text.charCodeAt(pos);
  2010. } while (isWhiteSpace(code));
  2011. return token = 15;
  2012. }
  2013. if (isLineBreak(code)) {
  2014. pos++;
  2015. value += String.fromCharCode(code);
  2016. if (code === 13 && text.charCodeAt(pos) === 10) {
  2017. pos++;
  2018. value += "\n";
  2019. }
  2020. lineNumber++;
  2021. tokenLineStartOffset = pos;
  2022. return token = 14;
  2023. }
  2024. switch (code) {
  2025. case 123:
  2026. pos++;
  2027. return token = 1;
  2028. case 125:
  2029. pos++;
  2030. return token = 2;
  2031. case 91:
  2032. pos++;
  2033. return token = 3;
  2034. case 93:
  2035. pos++;
  2036. return token = 4;
  2037. case 58:
  2038. pos++;
  2039. return token = 6;
  2040. case 44:
  2041. pos++;
  2042. return token = 5;
  2043. case 34:
  2044. pos++;
  2045. value = scanString();
  2046. return token = 10;
  2047. case 47:
  2048. var start = pos - 1;
  2049. if (text.charCodeAt(pos + 1) === 47) {
  2050. pos += 2;
  2051. while (pos < len) {
  2052. if (isLineBreak(text.charCodeAt(pos))) {
  2053. break;
  2054. }
  2055. pos++;
  2056. }
  2057. value = text.substring(start, pos);
  2058. return token = 12;
  2059. }
  2060. if (text.charCodeAt(pos + 1) === 42) {
  2061. pos += 2;
  2062. var safeLength = len - 1;
  2063. var commentClosed = false;
  2064. while (pos < safeLength) {
  2065. var ch = text.charCodeAt(pos);
  2066. if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
  2067. pos += 2;
  2068. commentClosed = true;
  2069. break;
  2070. }
  2071. pos++;
  2072. if (isLineBreak(ch)) {
  2073. if (ch === 13 && text.charCodeAt(pos) === 10) {
  2074. pos++;
  2075. }
  2076. lineNumber++;
  2077. tokenLineStartOffset = pos;
  2078. }
  2079. }
  2080. if (!commentClosed) {
  2081. pos++;
  2082. scanError = 1;
  2083. }
  2084. value = text.substring(start, pos);
  2085. return token = 13;
  2086. }
  2087. value += String.fromCharCode(code);
  2088. pos++;
  2089. return token = 16;
  2090. case 45:
  2091. value += String.fromCharCode(code);
  2092. pos++;
  2093. if (pos === len || !isDigit(text.charCodeAt(pos))) {
  2094. return token = 16;
  2095. }
  2096. case 48:
  2097. case 49:
  2098. case 50:
  2099. case 51:
  2100. case 52:
  2101. case 53:
  2102. case 54:
  2103. case 55:
  2104. case 56:
  2105. case 57:
  2106. value += scanNumber();
  2107. return token = 11;
  2108. default:
  2109. while (pos < len && isUnknownContentCharacter(code)) {
  2110. pos++;
  2111. code = text.charCodeAt(pos);
  2112. }
  2113. if (tokenOffset !== pos) {
  2114. value = text.substring(tokenOffset, pos);
  2115. switch (value) {
  2116. case "true":
  2117. return token = 8;
  2118. case "false":
  2119. return token = 9;
  2120. case "null":
  2121. return token = 7;
  2122. }
  2123. return token = 16;
  2124. }
  2125. value += String.fromCharCode(code);
  2126. pos++;
  2127. return token = 16;
  2128. }
  2129. }
  2130. function isUnknownContentCharacter(code) {
  2131. if (isWhiteSpace(code) || isLineBreak(code)) {
  2132. return false;
  2133. }
  2134. switch (code) {
  2135. case 125:
  2136. case 93:
  2137. case 123:
  2138. case 91:
  2139. case 34:
  2140. case 58:
  2141. case 44:
  2142. case 47:
  2143. return false;
  2144. }
  2145. return true;
  2146. }
  2147. function scanNextNonTrivia() {
  2148. var result;
  2149. do {
  2150. result = scanNext();
  2151. } while (result >= 12 && result <= 15);
  2152. return result;
  2153. }
  2154. return {
  2155. setPosition,
  2156. getPosition: function() {
  2157. return pos;
  2158. },
  2159. scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
  2160. getToken: function() {
  2161. return token;
  2162. },
  2163. getTokenValue: function() {
  2164. return value;
  2165. },
  2166. getTokenOffset: function() {
  2167. return tokenOffset;
  2168. },
  2169. getTokenLength: function() {
  2170. return pos - tokenOffset;
  2171. },
  2172. getTokenStartLine: function() {
  2173. return lineStartOffset;
  2174. },
  2175. getTokenStartCharacter: function() {
  2176. return tokenOffset - prevTokenLineStartOffset;
  2177. },
  2178. getTokenError: function() {
  2179. return scanError;
  2180. }
  2181. };
  2182. }
  2183. function isWhiteSpace(ch) {
  2184. return ch === 32 || ch === 9 || ch === 11 || ch === 12 || ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 || ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279;
  2185. }
  2186. function isLineBreak(ch) {
  2187. return ch === 10 || ch === 13 || ch === 8232 || ch === 8233;
  2188. }
  2189. function isDigit(ch) {
  2190. return ch >= 48 && ch <= 57;
  2191. }
  2192. // node_modules/jsonc-parser/lib/esm/impl/format.js
  2193. "use strict";
  2194. // node_modules/jsonc-parser/lib/esm/impl/parser.js
  2195. "use strict";
  2196. var ParseOptions;
  2197. (function(ParseOptions2) {
  2198. ParseOptions2.DEFAULT = {
  2199. allowTrailingComma: false
  2200. };
  2201. })(ParseOptions || (ParseOptions = {}));
  2202. // node_modules/jsonc-parser/lib/esm/impl/edit.js
  2203. "use strict";
  2204. // node_modules/jsonc-parser/lib/esm/main.js
  2205. "use strict";
  2206. var createScanner2 = createScanner;
  2207. // src/json/tokenization.ts
  2208. function createTokenizationSupport(supportComments) {
  2209. return {
  2210. getInitialState: () => new JSONState(null, null, false, null),
  2211. tokenize: (line, state) => tokenize(supportComments, line, state)
  2212. };
  2213. }
  2214. var TOKEN_DELIM_OBJECT = "delimiter.bracket.json";
  2215. var TOKEN_DELIM_ARRAY = "delimiter.array.json";
  2216. var TOKEN_DELIM_COLON = "delimiter.colon.json";
  2217. var TOKEN_DELIM_COMMA = "delimiter.comma.json";
  2218. var TOKEN_VALUE_BOOLEAN = "keyword.json";
  2219. var TOKEN_VALUE_NULL = "keyword.json";
  2220. var TOKEN_VALUE_STRING = "string.value.json";
  2221. var TOKEN_VALUE_NUMBER = "number.json";
  2222. var TOKEN_PROPERTY_NAME = "string.key.json";
  2223. var TOKEN_COMMENT_BLOCK = "comment.block.json";
  2224. var TOKEN_COMMENT_LINE = "comment.line.json";
  2225. var JSONParent;
  2226. (function(JSONParent2) {
  2227. JSONParent2[JSONParent2["Object"] = 0] = "Object";
  2228. JSONParent2[JSONParent2["Array"] = 1] = "Array";
  2229. })(JSONParent || (JSONParent = {}));
  2230. var ParentsStack = class {
  2231. constructor(parent, type) {
  2232. this.parent = parent;
  2233. this.type = type;
  2234. }
  2235. static pop(parents) {
  2236. if (parents) {
  2237. return parents.parent;
  2238. }
  2239. return null;
  2240. }
  2241. static push(parents, type) {
  2242. return new ParentsStack(parents, type);
  2243. }
  2244. static equals(a, b) {
  2245. if (!a && !b) {
  2246. return true;
  2247. }
  2248. if (!a || !b) {
  2249. return false;
  2250. }
  2251. while (a && b) {
  2252. if (a === b) {
  2253. return true;
  2254. }
  2255. if (a.type !== b.type) {
  2256. return false;
  2257. }
  2258. a = a.parent;
  2259. b = b.parent;
  2260. }
  2261. return true;
  2262. }
  2263. };
  2264. var JSONState = class {
  2265. constructor(state, scanError, lastWasColon, parents) {
  2266. this._state = state;
  2267. this.scanError = scanError;
  2268. this.lastWasColon = lastWasColon;
  2269. this.parents = parents;
  2270. }
  2271. clone() {
  2272. return new JSONState(this._state, this.scanError, this.lastWasColon, this.parents);
  2273. }
  2274. equals(other) {
  2275. if (other === this) {
  2276. return true;
  2277. }
  2278. if (!other || !(other instanceof JSONState)) {
  2279. return false;
  2280. }
  2281. return this.scanError === other.scanError && this.lastWasColon === other.lastWasColon && ParentsStack.equals(this.parents, other.parents);
  2282. }
  2283. getStateData() {
  2284. return this._state;
  2285. }
  2286. setStateData(state) {
  2287. this._state = state;
  2288. }
  2289. };
  2290. var ScanError;
  2291. (function(ScanError2) {
  2292. ScanError2[ScanError2["None"] = 0] = "None";
  2293. ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
  2294. ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
  2295. ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
  2296. ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
  2297. ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
  2298. ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
  2299. })(ScanError || (ScanError = {}));
  2300. var SyntaxKind;
  2301. (function(SyntaxKind2) {
  2302. SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
  2303. SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
  2304. SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
  2305. SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
  2306. SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
  2307. SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
  2308. SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
  2309. SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
  2310. SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
  2311. SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
  2312. SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
  2313. SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
  2314. SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
  2315. SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
  2316. SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
  2317. SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
  2318. SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
  2319. })(SyntaxKind || (SyntaxKind = {}));
  2320. function tokenize(comments, line, state, offsetDelta = 0) {
  2321. let numberOfInsertedCharacters = 0;
  2322. let adjustOffset = false;
  2323. switch (state.scanError) {
  2324. case 2:
  2325. line = '"' + line;
  2326. numberOfInsertedCharacters = 1;
  2327. break;
  2328. case 1:
  2329. line = "/*" + line;
  2330. numberOfInsertedCharacters = 2;
  2331. break;
  2332. }
  2333. const scanner2 = createScanner2(line);
  2334. let lastWasColon = state.lastWasColon;
  2335. let parents = state.parents;
  2336. const ret = {
  2337. tokens: [],
  2338. endState: state.clone()
  2339. };
  2340. while (true) {
  2341. let offset = offsetDelta + scanner2.getPosition();
  2342. let type = "";
  2343. const kind = scanner2.scan();
  2344. if (kind === 17) {
  2345. break;
  2346. }
  2347. if (offset === offsetDelta + scanner2.getPosition()) {
  2348. throw new Error("Scanner did not advance, next 3 characters are: " + line.substr(scanner2.getPosition(), 3));
  2349. }
  2350. if (adjustOffset) {
  2351. offset -= numberOfInsertedCharacters;
  2352. }
  2353. adjustOffset = numberOfInsertedCharacters > 0;
  2354. switch (kind) {
  2355. case 1:
  2356. parents = ParentsStack.push(parents, 0);
  2357. type = TOKEN_DELIM_OBJECT;
  2358. lastWasColon = false;
  2359. break;
  2360. case 2:
  2361. parents = ParentsStack.pop(parents);
  2362. type = TOKEN_DELIM_OBJECT;
  2363. lastWasColon = false;
  2364. break;
  2365. case 3:
  2366. parents = ParentsStack.push(parents, 1);
  2367. type = TOKEN_DELIM_ARRAY;
  2368. lastWasColon = false;
  2369. break;
  2370. case 4:
  2371. parents = ParentsStack.pop(parents);
  2372. type = TOKEN_DELIM_ARRAY;
  2373. lastWasColon = false;
  2374. break;
  2375. case 6:
  2376. type = TOKEN_DELIM_COLON;
  2377. lastWasColon = true;
  2378. break;
  2379. case 5:
  2380. type = TOKEN_DELIM_COMMA;
  2381. lastWasColon = false;
  2382. break;
  2383. case 8:
  2384. case 9:
  2385. type = TOKEN_VALUE_BOOLEAN;
  2386. lastWasColon = false;
  2387. break;
  2388. case 7:
  2389. type = TOKEN_VALUE_NULL;
  2390. lastWasColon = false;
  2391. break;
  2392. case 10:
  2393. const currentParent = parents ? parents.type : 0;
  2394. const inArray = currentParent === 1;
  2395. type = lastWasColon || inArray ? TOKEN_VALUE_STRING : TOKEN_PROPERTY_NAME;
  2396. lastWasColon = false;
  2397. break;
  2398. case 11:
  2399. type = TOKEN_VALUE_NUMBER;
  2400. lastWasColon = false;
  2401. break;
  2402. }
  2403. if (comments) {
  2404. switch (kind) {
  2405. case 12:
  2406. type = TOKEN_COMMENT_LINE;
  2407. break;
  2408. case 13:
  2409. type = TOKEN_COMMENT_BLOCK;
  2410. break;
  2411. }
  2412. }
  2413. ret.endState = new JSONState(state.getStateData(), scanner2.getTokenError(), lastWasColon, parents);
  2414. ret.tokens.push({
  2415. startIndex: offset,
  2416. scopes: type
  2417. });
  2418. }
  2419. return ret;
  2420. }
  2421. // src/json/jsonMode.ts
  2422. var JSONDiagnosticsAdapter = class extends DiagnosticsAdapter {
  2423. constructor(languageId, worker, defaults) {
  2424. super(languageId, worker, defaults.onDidChange);
  2425. this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel((model) => {
  2426. this._resetSchema(model.uri);
  2427. }));
  2428. this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
  2429. this._resetSchema(event.model.uri);
  2430. }));
  2431. }
  2432. _resetSchema(resource) {
  2433. this._worker().then((worker) => {
  2434. worker.resetSchema(resource.toString());
  2435. });
  2436. }
  2437. };
  2438. function setupMode(defaults) {
  2439. const disposables = [];
  2440. const providers = [];
  2441. const client = new WorkerManager(defaults);
  2442. disposables.push(client);
  2443. const worker = (...uris) => {
  2444. return client.getLanguageServiceWorker(...uris);
  2445. };
  2446. function registerProviders() {
  2447. const { languageId, modeConfiguration: modeConfiguration2 } = defaults;
  2448. disposeAll(providers);
  2449. if (modeConfiguration2.documentFormattingEdits) {
  2450. providers.push(monaco_editor_core_exports.languages.registerDocumentFormattingEditProvider(languageId, new DocumentFormattingEditProvider(worker)));
  2451. }
  2452. if (modeConfiguration2.documentRangeFormattingEdits) {
  2453. providers.push(monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(languageId, new DocumentRangeFormattingEditProvider(worker)));
  2454. }
  2455. if (modeConfiguration2.completionItems) {
  2456. providers.push(monaco_editor_core_exports.languages.registerCompletionItemProvider(languageId, new CompletionAdapter(worker, [" ", ":", '"'])));
  2457. }
  2458. if (modeConfiguration2.hovers) {
  2459. providers.push(monaco_editor_core_exports.languages.registerHoverProvider(languageId, new HoverAdapter(worker)));
  2460. }
  2461. if (modeConfiguration2.documentSymbols) {
  2462. providers.push(monaco_editor_core_exports.languages.registerDocumentSymbolProvider(languageId, new DocumentSymbolAdapter(worker)));
  2463. }
  2464. if (modeConfiguration2.tokens) {
  2465. providers.push(monaco_editor_core_exports.languages.setTokensProvider(languageId, createTokenizationSupport(true)));
  2466. }
  2467. if (modeConfiguration2.colors) {
  2468. providers.push(monaco_editor_core_exports.languages.registerColorProvider(languageId, new DocumentColorAdapter(worker)));
  2469. }
  2470. if (modeConfiguration2.foldingRanges) {
  2471. providers.push(monaco_editor_core_exports.languages.registerFoldingRangeProvider(languageId, new FoldingRangeAdapter(worker)));
  2472. }
  2473. if (modeConfiguration2.diagnostics) {
  2474. providers.push(new JSONDiagnosticsAdapter(languageId, worker, defaults));
  2475. }
  2476. if (modeConfiguration2.selectionRanges) {
  2477. providers.push(monaco_editor_core_exports.languages.registerSelectionRangeProvider(languageId, new SelectionRangeAdapter(worker)));
  2478. }
  2479. }
  2480. registerProviders();
  2481. disposables.push(monaco_editor_core_exports.languages.setLanguageConfiguration(defaults.languageId, richEditConfiguration));
  2482. let modeConfiguration = defaults.modeConfiguration;
  2483. defaults.onDidChange((newDefaults) => {
  2484. if (newDefaults.modeConfiguration !== modeConfiguration) {
  2485. modeConfiguration = newDefaults.modeConfiguration;
  2486. registerProviders();
  2487. }
  2488. });
  2489. disposables.push(asDisposable(providers));
  2490. return asDisposable(disposables);
  2491. }
  2492. function asDisposable(disposables) {
  2493. return { dispose: () => disposeAll(disposables) };
  2494. }
  2495. function disposeAll(disposables) {
  2496. while (disposables.length) {
  2497. disposables.pop().dispose();
  2498. }
  2499. }
  2500. var richEditConfiguration = {
  2501. wordPattern: /(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,
  2502. comments: {
  2503. lineComment: "//",
  2504. blockComment: ["/*", "*/"]
  2505. },
  2506. brackets: [
  2507. ["{", "}"],
  2508. ["[", "]"]
  2509. ],
  2510. autoClosingPairs: [
  2511. { open: "{", close: "}", notIn: ["string"] },
  2512. { open: "[", close: "]", notIn: ["string"] },
  2513. { open: '"', close: '"', notIn: ["string"] }
  2514. ]
  2515. };
  2516. return jsonMode_exports;
  2517. })();
  2518. return moduleExports;
  2519. });