lsp.hpp 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556
  1. /*************************************************************************/
  2. /* lsp.hpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef GODOT_LSP_H
  31. #define GODOT_LSP_H
  32. #include "core/variant.h"
  33. namespace lsp {
  34. typedef String DocumentUri;
  35. /**
  36. * Text documents are identified using a URI. On the protocol level, URIs are passed as strings.
  37. */
  38. struct TextDocumentIdentifier {
  39. /**
  40. * The text document's URI.
  41. */
  42. DocumentUri uri;
  43. _FORCE_INLINE_ void load(const Dictionary &p_params) {
  44. uri = p_params["uri"];
  45. }
  46. _FORCE_INLINE_ Dictionary to_json() const {
  47. Dictionary dict;
  48. dict["uri"] = uri;
  49. return dict;
  50. }
  51. };
  52. /**
  53. * Position in a text document expressed as zero-based line and zero-based character offset.
  54. * A position is between two characters like an ‘insert’ cursor in a editor.
  55. * Special values like for example -1 to denote the end of a line are not supported.
  56. */
  57. struct Position {
  58. /**
  59. * Line position in a document (zero-based).
  60. */
  61. int line = 0;
  62. /**
  63. * Character offset on a line in a document (zero-based). Assuming that the line is
  64. * represented as a string, the `character` value represents the gap between the
  65. * `character` and `character + 1`.
  66. *
  67. * If the character value is greater than the line length it defaults back to the
  68. * line length.
  69. */
  70. int character = 0;
  71. _FORCE_INLINE_ void load(const Dictionary &p_params) {
  72. line = p_params["line"];
  73. character = p_params["character"];
  74. }
  75. _FORCE_INLINE_ Dictionary to_json() const {
  76. Dictionary dict;
  77. dict["line"] = line;
  78. dict["character"] = character;
  79. return dict;
  80. }
  81. };
  82. /**
  83. * A range in a text document expressed as (zero-based) start and end positions.
  84. * A range is comparable to a selection in an editor. Therefore the end position is exclusive.
  85. * If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line.
  86. */
  87. struct Range {
  88. /**
  89. * The range's start position.
  90. */
  91. Position start;
  92. /**
  93. * The range's end position.
  94. */
  95. Position end;
  96. _FORCE_INLINE_ void load(const Dictionary &p_params) {
  97. start.load(p_params["start"]);
  98. end.load(p_params["end"]);
  99. }
  100. _FORCE_INLINE_ Dictionary to_json() const {
  101. Dictionary dict;
  102. dict["start"] = start.to_json();
  103. dict["end"] = end.to_json();
  104. return dict;
  105. }
  106. };
  107. /**
  108. * Represents a location inside a resource, such as a line inside a text file.
  109. */
  110. struct Location {
  111. DocumentUri uri;
  112. Range range;
  113. _FORCE_INLINE_ void load(const Dictionary &p_params) {
  114. uri = p_params["uri"];
  115. range.load(p_params["range"]);
  116. }
  117. _FORCE_INLINE_ Dictionary to_json() const {
  118. Dictionary dict;
  119. dict["uri"] = uri;
  120. dict["range"] = range.to_json();
  121. return dict;
  122. }
  123. };
  124. /**
  125. * Represents a link between a source and a target location.
  126. */
  127. struct LocationLink {
  128. /**
  129. * Span of the origin of this link.
  130. *
  131. * Used as the underlined span for mouse interaction. Defaults to the word range at
  132. * the mouse position.
  133. */
  134. Range *originSelectionRange = NULL;
  135. /**
  136. * The target resource identifier of this link.
  137. */
  138. String targetUri;
  139. /**
  140. * The full target range of this link. If the target for example is a symbol then target range is the
  141. * range enclosing this symbol not including leading/trailing whitespace but everything else
  142. * like comments. This information is typically used to highlight the range in the editor.
  143. */
  144. Range targetRange;
  145. /**
  146. * The range that should be selected and revealed when this link is being followed, e.g the name of a function.
  147. * Must be contained by the the `targetRange`. See also `DocumentSymbol#range`
  148. */
  149. Range targetSelectionRange;
  150. };
  151. /**
  152. * A parameter literal used in requests to pass a text document and a position inside that document.
  153. */
  154. struct TextDocumentPositionParams {
  155. /**
  156. * The text document.
  157. */
  158. TextDocumentIdentifier textDocument;
  159. /**
  160. * The position inside the text document.
  161. */
  162. Position position;
  163. _FORCE_INLINE_ void load(const Dictionary &p_params) {
  164. textDocument.load(p_params["textDocument"]);
  165. position.load(p_params["position"]);
  166. }
  167. _FORCE_INLINE_ Dictionary to_json() const {
  168. Dictionary dict;
  169. dict["textDocument"] = textDocument.to_json();
  170. dict["position"] = position.to_json();
  171. return dict;
  172. }
  173. };
  174. struct DocumentLinkParams {
  175. /**
  176. * The document to provide document links for.
  177. */
  178. TextDocumentIdentifier textDocument;
  179. _FORCE_INLINE_ void load(const Dictionary &p_params) {
  180. textDocument.load(p_params["textDocument"]);
  181. }
  182. };
  183. /**
  184. * A document link is a range in a text document that links to an internal or external resource, like another
  185. * text document or a web site.
  186. */
  187. struct DocumentLink {
  188. /**
  189. * The range this link applies to.
  190. */
  191. Range range;
  192. /**
  193. * The uri this link points to. If missing a resolve request is sent later.
  194. */
  195. DocumentUri target;
  196. Dictionary to_json() const {
  197. Dictionary dict;
  198. dict["range"] = range.to_json();
  199. dict["target"] = target;
  200. return dict;
  201. }
  202. };
  203. /**
  204. * A textual edit applicable to a text document.
  205. */
  206. struct TextEdit {
  207. /**
  208. * The range of the text document to be manipulated. To insert
  209. * text into a document create a range where start === end.
  210. */
  211. Range range;
  212. /**
  213. * The string to be inserted. For delete operations use an
  214. * empty string.
  215. */
  216. String newText;
  217. };
  218. /**
  219. * Represents a reference to a command.
  220. * Provides a title which will be used to represent a command in the UI.
  221. * Commands are identified by a string identifier.
  222. * The recommended way to handle commands is to implement their execution on the server side if the client and server provides the corresponding capabilities.
  223. * Alternatively the tool extension code could handle the command. The protocol currently doesn’t specify a set of well-known commands.
  224. */
  225. struct Command {
  226. /**
  227. * Title of the command, like `save`.
  228. */
  229. String title;
  230. /**
  231. * The identifier of the actual command handler.
  232. */
  233. String command;
  234. /**
  235. * Arguments that the command handler should be
  236. * invoked with.
  237. */
  238. Array arguments;
  239. Dictionary to_json() const {
  240. Dictionary dict;
  241. dict["title"] = title;
  242. dict["command"] = command;
  243. if (arguments.size()) dict["arguments"] = arguments;
  244. return dict;
  245. }
  246. };
  247. namespace TextDocumentSyncKind {
  248. /**
  249. * Documents should not be synced at all.
  250. */
  251. static const int None = 0;
  252. /**
  253. * Documents are synced by always sending the full content
  254. * of the document.
  255. */
  256. static const int Full = 1;
  257. /**
  258. * Documents are synced by sending the full content on open.
  259. * After that only incremental updates to the document are
  260. * send.
  261. */
  262. static const int Incremental = 2;
  263. }; // namespace TextDocumentSyncKind
  264. /**
  265. * Completion options.
  266. */
  267. struct CompletionOptions {
  268. /**
  269. * The server provides support to resolve additional
  270. * information for a completion item.
  271. */
  272. bool resolveProvider = true;
  273. /**
  274. * The characters that trigger completion automatically.
  275. */
  276. Vector<String> triggerCharacters;
  277. CompletionOptions() {
  278. triggerCharacters.push_back(".");
  279. triggerCharacters.push_back("$");
  280. triggerCharacters.push_back("'");
  281. triggerCharacters.push_back("\"");
  282. triggerCharacters.push_back("(");
  283. triggerCharacters.push_back(",");
  284. }
  285. Dictionary to_json() const {
  286. Dictionary dict;
  287. dict["resolveProvider"] = resolveProvider;
  288. dict["triggerCharacters"] = triggerCharacters;
  289. return dict;
  290. }
  291. };
  292. /**
  293. * Signature help options.
  294. */
  295. struct SignatureHelpOptions {
  296. /**
  297. * The characters that trigger signature help
  298. * automatically.
  299. */
  300. Vector<String> triggerCharacters;
  301. Dictionary to_json() {
  302. Dictionary dict;
  303. dict["triggerCharacters"] = triggerCharacters;
  304. return dict;
  305. }
  306. };
  307. /**
  308. * Code Lens options.
  309. */
  310. struct CodeLensOptions {
  311. /**
  312. * Code lens has a resolve provider as well.
  313. */
  314. bool resolveProvider = false;
  315. Dictionary to_json() {
  316. Dictionary dict;
  317. dict["resolveProvider"] = resolveProvider;
  318. return dict;
  319. }
  320. };
  321. /**
  322. * Rename options
  323. */
  324. struct RenameOptions {
  325. /**
  326. * Renames should be checked and tested before being executed.
  327. */
  328. bool prepareProvider = false;
  329. Dictionary to_json() {
  330. Dictionary dict;
  331. dict["prepareProvider"] = prepareProvider;
  332. return dict;
  333. }
  334. };
  335. /**
  336. * Document link options.
  337. */
  338. struct DocumentLinkOptions {
  339. /**
  340. * Document links have a resolve provider as well.
  341. */
  342. bool resolveProvider = false;
  343. Dictionary to_json() {
  344. Dictionary dict;
  345. dict["resolveProvider"] = resolveProvider;
  346. return dict;
  347. }
  348. };
  349. /**
  350. * Execute command options.
  351. */
  352. struct ExecuteCommandOptions {
  353. /**
  354. * The commands to be executed on the server
  355. */
  356. Vector<String> commands;
  357. Dictionary to_json() {
  358. Dictionary dict;
  359. dict["commands"] = commands;
  360. return dict;
  361. }
  362. };
  363. /**
  364. * Save options.
  365. */
  366. struct SaveOptions {
  367. /**
  368. * The client is supposed to include the content on save.
  369. */
  370. bool includeText = true;
  371. Dictionary to_json() {
  372. Dictionary dict;
  373. dict["includeText"] = includeText;
  374. return dict;
  375. }
  376. };
  377. /**
  378. * Color provider options.
  379. */
  380. struct ColorProviderOptions {
  381. Dictionary to_json() {
  382. Dictionary dict;
  383. return dict;
  384. }
  385. };
  386. /**
  387. * Folding range provider options.
  388. */
  389. struct FoldingRangeProviderOptions {
  390. Dictionary to_json() {
  391. Dictionary dict;
  392. return dict;
  393. }
  394. };
  395. struct TextDocumentSyncOptions {
  396. /**
  397. * Open and close notifications are sent to the server. If omitted open close notification should not
  398. * be sent.
  399. */
  400. bool openClose = true;
  401. /**
  402. * Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full
  403. * and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None.
  404. */
  405. int change = TextDocumentSyncKind::Full;
  406. /**
  407. * If present will save notifications are sent to the server. If omitted the notification should not be
  408. * sent.
  409. */
  410. bool willSave = false;
  411. /**
  412. * If present will save wait until requests are sent to the server. If omitted the request should not be
  413. * sent.
  414. */
  415. bool willSaveWaitUntil = false;
  416. /**
  417. * If present save notifications are sent to the server. If omitted the notification should not be
  418. * sent.
  419. */
  420. SaveOptions save;
  421. Dictionary to_json() {
  422. Dictionary dict;
  423. dict["willSaveWaitUntil"] = willSaveWaitUntil;
  424. dict["willSave"] = willSave;
  425. dict["openClose"] = openClose;
  426. dict["change"] = change;
  427. dict["change"] = save.to_json();
  428. return dict;
  429. }
  430. };
  431. /**
  432. * Static registration options to be returned in the initialize request.
  433. */
  434. struct StaticRegistrationOptions {
  435. /**
  436. * The id used to register the request. The id can be used to deregister
  437. * the request again. See also Registration#id.
  438. */
  439. String id;
  440. };
  441. /**
  442. * Format document on type options.
  443. */
  444. struct DocumentOnTypeFormattingOptions {
  445. /**
  446. * A character on which formatting should be triggered, like `}`.
  447. */
  448. String firstTriggerCharacter;
  449. /**
  450. * More trigger characters.
  451. */
  452. Vector<String> moreTriggerCharacter;
  453. Dictionary to_json() {
  454. Dictionary dict;
  455. dict["firstTriggerCharacter"] = firstTriggerCharacter;
  456. dict["moreTriggerCharacter"] = moreTriggerCharacter;
  457. return dict;
  458. }
  459. };
  460. struct TextDocumentItem {
  461. /**
  462. * The text document's URI.
  463. */
  464. DocumentUri uri;
  465. /**
  466. * The text document's language identifier.
  467. */
  468. String languageId;
  469. /**
  470. * The version number of this document (it will increase after each
  471. * change, including undo/redo).
  472. */
  473. int version;
  474. /**
  475. * The content of the opened text document.
  476. */
  477. String text;
  478. void load(const Dictionary &p_dict) {
  479. uri = p_dict["uri"];
  480. languageId = p_dict["languageId"];
  481. version = p_dict["version"];
  482. text = p_dict["text"];
  483. }
  484. Dictionary to_json() const {
  485. Dictionary dict;
  486. dict["uri"] = uri;
  487. dict["languageId"] = languageId;
  488. dict["version"] = version;
  489. dict["text"] = text;
  490. return dict;
  491. }
  492. };
  493. /**
  494. * An event describing a change to a text document. If range and rangeLength are omitted
  495. * the new text is considered to be the full content of the document.
  496. */
  497. struct TextDocumentContentChangeEvent {
  498. /**
  499. * The range of the document that changed.
  500. */
  501. Range range;
  502. /**
  503. * The length of the range that got replaced.
  504. */
  505. int rangeLength;
  506. /**
  507. * The new text of the range/document.
  508. */
  509. String text;
  510. void load(const Dictionary &p_params) {
  511. text = p_params["text"];
  512. rangeLength = p_params["rangeLength"];
  513. range.load(p_params["range"]);
  514. }
  515. };
  516. namespace DiagnosticSeverity {
  517. /**
  518. * Reports an error.
  519. */
  520. static const int Error = 1;
  521. /**
  522. * Reports a warning.
  523. */
  524. static const int Warning = 2;
  525. /**
  526. * Reports an information.
  527. */
  528. static const int Information = 3;
  529. /**
  530. * Reports a hint.
  531. */
  532. static const int Hint = 4;
  533. }; // namespace DiagnosticSeverity
  534. /**
  535. * Represents a related message and source code location for a diagnostic. This should be
  536. * used to point to code locations that cause or related to a diagnostics, e.g when duplicating
  537. * a symbol in a scope.
  538. */
  539. struct DiagnosticRelatedInformation {
  540. /**
  541. * The location of this related diagnostic information.
  542. */
  543. Location location;
  544. /**
  545. * The message of this related diagnostic information.
  546. */
  547. String message;
  548. Dictionary to_json() const {
  549. Dictionary dict;
  550. dict["location"] = location.to_json(),
  551. dict["message"] = message;
  552. return dict;
  553. }
  554. };
  555. /**
  556. * Represents a diagnostic, such as a compiler error or warning.
  557. * Diagnostic objects are only valid in the scope of a resource.
  558. */
  559. struct Diagnostic {
  560. /**
  561. * The range at which the message applies.
  562. */
  563. Range range;
  564. /**
  565. * The diagnostic's severity. Can be omitted. If omitted it is up to the
  566. * client to interpret diagnostics as error, warning, info or hint.
  567. */
  568. int severity;
  569. /**
  570. * The diagnostic's code, which might appear in the user interface.
  571. */
  572. int code;
  573. /**
  574. * A human-readable string describing the source of this
  575. * diagnostic, e.g. 'typescript' or 'super lint'.
  576. */
  577. String source;
  578. /**
  579. * The diagnostic's message.
  580. */
  581. String message;
  582. /**
  583. * An array of related diagnostic information, e.g. when symbol-names within
  584. * a scope collide all definitions can be marked via this property.
  585. */
  586. Vector<DiagnosticRelatedInformation> relatedInformation;
  587. Dictionary to_json() const {
  588. Dictionary dict;
  589. dict["range"] = range.to_json();
  590. dict["code"] = code;
  591. dict["severity"] = severity;
  592. dict["message"] = message;
  593. dict["source"] = source;
  594. if (!relatedInformation.empty()) {
  595. Array arr;
  596. arr.resize(relatedInformation.size());
  597. for (int i = 0; i < relatedInformation.size(); i++) {
  598. arr[i] = relatedInformation[i].to_json();
  599. }
  600. dict["relatedInformation"] = arr;
  601. }
  602. return dict;
  603. }
  604. };
  605. /**
  606. * Describes the content type that a client supports in various
  607. * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
  608. *
  609. * Please note that `MarkupKinds` must not start with a `$`. This kinds
  610. * are reserved for internal usage.
  611. */
  612. namespace MarkupKind {
  613. static const String PlainText = "plaintext";
  614. static const String Markdown = "markdown";
  615. }; // namespace MarkupKind
  616. /**
  617. * A `MarkupContent` literal represents a string value which content is interpreted base on its
  618. * kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.
  619. *
  620. * If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues.
  621. * See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
  622. *
  623. * Here is an example how such a string can be constructed using JavaScript / TypeScript:
  624. * ```typescript
  625. * let markdown: MarkdownContent = {
  626. * kind: MarkupKind.Markdown,
  627. * value: [
  628. * '# Header',
  629. * 'Some text',
  630. * '```typescript',
  631. * 'someCode();',
  632. * '```'
  633. * ].join('\n')
  634. * };
  635. * ```
  636. *
  637. * *Please Note* that clients might sanitize the return markdown. A client could decide to
  638. * remove HTML from the markdown to avoid script execution.
  639. */
  640. struct MarkupContent {
  641. /**
  642. * The type of the Markup
  643. */
  644. String kind;
  645. /**
  646. * The content itself
  647. */
  648. String value;
  649. MarkupContent() {
  650. kind = MarkupKind::Markdown;
  651. }
  652. MarkupContent(const String &p_value) {
  653. value = p_value;
  654. kind = MarkupKind::Markdown;
  655. }
  656. Dictionary to_json() const {
  657. Dictionary dict;
  658. dict["kind"] = kind;
  659. dict["value"] = value;
  660. return dict;
  661. }
  662. };
  663. /**
  664. * The kind of a completion entry.
  665. */
  666. namespace CompletionItemKind {
  667. static const int Text = 1;
  668. static const int Method = 2;
  669. static const int Function = 3;
  670. static const int Constructor = 4;
  671. static const int Field = 5;
  672. static const int Variable = 6;
  673. static const int Class = 7;
  674. static const int Interface = 8;
  675. static const int Module = 9;
  676. static const int Property = 10;
  677. static const int Unit = 11;
  678. static const int Value = 12;
  679. static const int Enum = 13;
  680. static const int Keyword = 14;
  681. static const int Snippet = 15;
  682. static const int Color = 16;
  683. static const int File = 17;
  684. static const int Reference = 18;
  685. static const int Folder = 19;
  686. static const int EnumMember = 20;
  687. static const int Constant = 21;
  688. static const int Struct = 22;
  689. static const int Event = 23;
  690. static const int Operator = 24;
  691. static const int TypeParameter = 25;
  692. }; // namespace CompletionItemKind
  693. /**
  694. * Defines whether the insert text in a completion item should be interpreted as
  695. * plain text or a snippet.
  696. */
  697. namespace InsertTextFormat {
  698. /**
  699. * The primary text to be inserted is treated as a plain string.
  700. */
  701. static const int PlainText = 1;
  702. /**
  703. * The primary text to be inserted is treated as a snippet.
  704. *
  705. * A snippet can define tab stops and placeholders with `$1`, `$2`
  706. * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
  707. * the end of the snippet. Placeholders with equal identifiers are linked,
  708. * that is typing in one will update others too.
  709. */
  710. static const int Snippet = 2;
  711. }; // namespace InsertTextFormat
  712. struct CompletionItem {
  713. /**
  714. * The label of this completion item. By default
  715. * also the text that is inserted when selecting
  716. * this completion.
  717. */
  718. String label;
  719. /**
  720. * The kind of this completion item. Based of the kind
  721. * an icon is chosen by the editor. The standardized set
  722. * of available values is defined in `CompletionItemKind`.
  723. */
  724. int kind;
  725. /**
  726. * A human-readable string with additional information
  727. * about this item, like type or symbol information.
  728. */
  729. String detail;
  730. /**
  731. * A human-readable string that represents a doc-comment.
  732. */
  733. MarkupContent documentation;
  734. /**
  735. * Indicates if this item is deprecated.
  736. */
  737. bool deprecated = false;
  738. /**
  739. * Select this item when showing.
  740. *
  741. * *Note* that only one completion item can be selected and that the
  742. * tool / client decides which item that is. The rule is that the *first*
  743. * item of those that match best is selected.
  744. */
  745. bool preselect = false;
  746. /**
  747. * A string that should be used when comparing this item
  748. * with other items. When `falsy` the label is used.
  749. */
  750. String sortText;
  751. /**
  752. * A string that should be used when filtering a set of
  753. * completion items. When `falsy` the label is used.
  754. */
  755. String filterText;
  756. /**
  757. * A string that should be inserted into a document when selecting
  758. * this completion. When `falsy` the label is used.
  759. *
  760. * The `insertText` is subject to interpretation by the client side.
  761. * Some tools might not take the string literally. For example
  762. * VS Code when code complete is requested in this example `con<cursor position>`
  763. * and a completion item with an `insertText` of `console` is provided it
  764. * will only insert `sole`. Therefore it is recommended to use `textEdit` instead
  765. * since it avoids additional client side interpretation.
  766. *
  767. * @deprecated Use textEdit instead.
  768. */
  769. String insertText;
  770. /**
  771. * The format of the insert text. The format applies to both the `insertText` property
  772. * and the `newText` property of a provided `textEdit`.
  773. */
  774. int insertTextFormat;
  775. /**
  776. * An edit which is applied to a document when selecting this completion. When an edit is provided the value of
  777. * `insertText` is ignored.
  778. *
  779. * *Note:* The range of the edit must be a single line range and it must contain the position at which completion
  780. * has been requested.
  781. */
  782. TextEdit textEdit;
  783. /**
  784. * An optional array of additional text edits that are applied when
  785. * selecting this completion. Edits must not overlap (including the same insert position)
  786. * with the main edit nor with themselves.
  787. *
  788. * Additional text edits should be used to change text unrelated to the current cursor position
  789. * (for example adding an import statement at the top of the file if the completion item will
  790. * insert an unqualified type).
  791. */
  792. Vector<TextEdit> additionalTextEdits;
  793. /**
  794. * An optional set of characters that when pressed while this completion is active will accept it first and
  795. * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
  796. * characters will be ignored.
  797. */
  798. Vector<String> commitCharacters;
  799. /**
  800. * An optional command that is executed *after* inserting this completion. *Note* that
  801. * additional modifications to the current document should be described with the
  802. * additionalTextEdits-property.
  803. */
  804. Command command;
  805. /**
  806. * A data entry field that is preserved on a completion item between
  807. * a completion and a completion resolve request.
  808. */
  809. Variant data;
  810. _FORCE_INLINE_ Dictionary to_json(bool resolved = false) const {
  811. Dictionary dict;
  812. dict["label"] = label;
  813. dict["kind"] = kind;
  814. dict["data"] = data;
  815. if (resolved) {
  816. dict["insertText"] = insertText;
  817. dict["detail"] = detail;
  818. dict["documentation"] = documentation.to_json();
  819. dict["deprecated"] = deprecated;
  820. dict["preselect"] = preselect;
  821. dict["sortText"] = sortText;
  822. dict["filterText"] = filterText;
  823. if (commitCharacters.size()) dict["commitCharacters"] = commitCharacters;
  824. dict["command"] = command.to_json();
  825. }
  826. return dict;
  827. }
  828. void load(const Dictionary &p_dict) {
  829. if (p_dict.has("label")) label = p_dict["label"];
  830. if (p_dict.has("kind")) kind = p_dict["kind"];
  831. if (p_dict.has("detail")) detail = p_dict["detail"];
  832. if (p_dict.has("documentation")) {
  833. Variant doc = p_dict["documentation"];
  834. if (doc.get_type() == Variant::STRING) {
  835. documentation.value = doc;
  836. } else if (doc.get_type() == Variant::DICTIONARY) {
  837. Dictionary v = doc;
  838. documentation.value = v["value"];
  839. }
  840. }
  841. if (p_dict.has("deprecated")) deprecated = p_dict["deprecated"];
  842. if (p_dict.has("preselect")) preselect = p_dict["preselect"];
  843. if (p_dict.has("sortText")) sortText = p_dict["sortText"];
  844. if (p_dict.has("filterText")) filterText = p_dict["filterText"];
  845. if (p_dict.has("insertText")) insertText = p_dict["insertText"];
  846. if (p_dict.has("data")) data = p_dict["data"];
  847. }
  848. };
  849. /**
  850. * Represents a collection of [completion items](#CompletionItem) to be presented
  851. * in the editor.
  852. */
  853. struct CompletionList {
  854. /**
  855. * This list it not complete. Further typing should result in recomputing
  856. * this list.
  857. */
  858. bool isIncomplete;
  859. /**
  860. * The completion items.
  861. */
  862. Vector<CompletionItem> items;
  863. };
  864. /**
  865. * A symbol kind.
  866. */
  867. namespace SymbolKind {
  868. static const int File = 0;
  869. static const int Module = 1;
  870. static const int Namespace = 2;
  871. static const int Package = 3;
  872. static const int Class = 4;
  873. static const int Method = 5;
  874. static const int Property = 6;
  875. static const int Field = 7;
  876. static const int Constructor = 8;
  877. static const int Enum = 9;
  878. static const int Interface = 10;
  879. static const int Function = 11;
  880. static const int Variable = 12;
  881. static const int Constant = 13;
  882. static const int String = 14;
  883. static const int Number = 15;
  884. static const int Boolean = 16;
  885. static const int Array = 17;
  886. static const int Object = 18;
  887. static const int Key = 19;
  888. static const int Null = 20;
  889. static const int EnumMember = 21;
  890. static const int Struct = 22;
  891. static const int Event = 23;
  892. static const int Operator = 24;
  893. static const int TypeParameter = 25;
  894. }; // namespace SymbolKind
  895. /**
  896. * Represents information about programming constructs like variables, classes,
  897. * interfaces etc.
  898. */
  899. struct SymbolInformation {
  900. /**
  901. * The name of this symbol.
  902. */
  903. String name;
  904. /**
  905. * The kind of this symbol.
  906. */
  907. int kind = SymbolKind::File;
  908. /**
  909. * Indicates if this symbol is deprecated.
  910. */
  911. bool deprecated = false;
  912. /**
  913. * The location of this symbol. The location's range is used by a tool
  914. * to reveal the location in the editor. If the symbol is selected in the
  915. * tool the range's start information is used to position the cursor. So
  916. * the range usually spans more then the actual symbol's name and does
  917. * normally include things like visibility modifiers.
  918. *
  919. * The range doesn't have to denote a node range in the sense of a abstract
  920. * syntax tree. It can therefore not be used to re-construct a hierarchy of
  921. * the symbols.
  922. */
  923. Location location;
  924. /**
  925. * The name of the symbol containing this symbol. This information is for
  926. * user interface purposes (e.g. to render a qualifier in the user interface
  927. * if necessary). It can't be used to re-infer a hierarchy for the document
  928. * symbols.
  929. */
  930. String containerName;
  931. _FORCE_INLINE_ Dictionary to_json() const {
  932. Dictionary dict;
  933. dict["name"] = name;
  934. dict["kind"] = kind;
  935. dict["deprecated"] = deprecated;
  936. dict["location"] = location.to_json();
  937. dict["containerName"] = containerName;
  938. return dict;
  939. }
  940. };
  941. struct DocumentedSymbolInformation : public SymbolInformation {
  942. /**
  943. * A human-readable string with additional information
  944. */
  945. String detail;
  946. /**
  947. * A human-readable string that represents a doc-comment.
  948. */
  949. String documentation;
  950. };
  951. /**
  952. * Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be
  953. * hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range,
  954. * e.g. the range of an identifier.
  955. */
  956. struct DocumentSymbol {
  957. /**
  958. * The name of this symbol. Will be displayed in the user interface and therefore must not be
  959. * an empty string or a string only consisting of white spaces.
  960. */
  961. String name;
  962. /**
  963. * More detail for this symbol, e.g the signature of a function.
  964. */
  965. String detail;
  966. /**
  967. * Documentation for this symbol
  968. */
  969. String documentation;
  970. /**
  971. * Class name for the native symbols
  972. */
  973. String native_class;
  974. /**
  975. * The kind of this symbol.
  976. */
  977. int kind = SymbolKind::File;
  978. /**
  979. * Indicates if this symbol is deprecated.
  980. */
  981. bool deprecated = false;
  982. /**
  983. * The range enclosing this symbol not including leading/trailing whitespace but everything else
  984. * like comments. This information is typically used to determine if the clients cursor is
  985. * inside the symbol to reveal in the symbol in the UI.
  986. */
  987. Range range;
  988. /**
  989. * The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
  990. * Must be contained by the `range`.
  991. */
  992. Range selectionRange;
  993. DocumentUri uri;
  994. String script_path;
  995. /**
  996. * Children of this symbol, e.g. properties of a class.
  997. */
  998. Vector<DocumentSymbol> children;
  999. Dictionary to_json(bool with_doc = false) const {
  1000. Dictionary dict;
  1001. dict["name"] = name;
  1002. dict["detail"] = detail;
  1003. dict["kind"] = kind;
  1004. dict["deprecated"] = deprecated;
  1005. dict["range"] = range.to_json();
  1006. dict["selectionRange"] = selectionRange.to_json();
  1007. if (with_doc) {
  1008. dict["documentation"] = documentation;
  1009. dict["native_class"] = native_class;
  1010. }
  1011. Array arr;
  1012. arr.resize(children.size());
  1013. for (int i = 0; i < children.size(); i++) {
  1014. arr[i] = children[i].to_json(with_doc);
  1015. }
  1016. dict["children"] = arr;
  1017. return dict;
  1018. }
  1019. void symbol_tree_as_list(const String &p_uri, Vector<DocumentedSymbolInformation> &r_list, const String &p_container = "", bool p_join_name = false) const {
  1020. DocumentedSymbolInformation si;
  1021. if (p_join_name && !p_container.empty()) {
  1022. si.name = p_container + ">" + name;
  1023. } else {
  1024. si.name = name;
  1025. }
  1026. si.kind = kind;
  1027. si.containerName = p_container;
  1028. si.deprecated = deprecated;
  1029. si.location.uri = p_uri;
  1030. si.location.range = range;
  1031. si.detail = detail;
  1032. si.documentation = documentation;
  1033. r_list.push_back(si);
  1034. for (int i = 0; i < children.size(); i++) {
  1035. children[i].symbol_tree_as_list(p_uri, r_list, si.name, p_join_name);
  1036. }
  1037. }
  1038. _FORCE_INLINE_ MarkupContent render() const {
  1039. MarkupContent markdown;
  1040. if (detail.length()) {
  1041. markdown.value = "\t" + detail + "\n\n";
  1042. }
  1043. if (documentation.length()) {
  1044. markdown.value += documentation + "\n\n";
  1045. }
  1046. if (script_path.length()) {
  1047. markdown.value += "Defined in [" + script_path + "](" + uri + ")";
  1048. }
  1049. return markdown;
  1050. }
  1051. _FORCE_INLINE_ CompletionItem make_completion_item(bool resolved = false) const {
  1052. lsp::CompletionItem item;
  1053. item.label = name;
  1054. if (resolved) {
  1055. item.documentation = render();
  1056. }
  1057. switch (kind) {
  1058. case lsp::SymbolKind::Enum:
  1059. item.kind = lsp::CompletionItemKind::Enum;
  1060. break;
  1061. case lsp::SymbolKind::Class:
  1062. item.kind = lsp::CompletionItemKind::Class;
  1063. break;
  1064. case lsp::SymbolKind::Property:
  1065. item.kind = lsp::CompletionItemKind::Property;
  1066. break;
  1067. case lsp::SymbolKind::Method:
  1068. case lsp::SymbolKind::Function:
  1069. item.kind = lsp::CompletionItemKind::Method;
  1070. break;
  1071. case lsp::SymbolKind::Event:
  1072. item.kind = lsp::CompletionItemKind::Event;
  1073. break;
  1074. case lsp::SymbolKind::Constant:
  1075. item.kind = lsp::CompletionItemKind::Constant;
  1076. break;
  1077. case lsp::SymbolKind::Variable:
  1078. item.kind = lsp::CompletionItemKind::Variable;
  1079. break;
  1080. case lsp::SymbolKind::File:
  1081. item.kind = lsp::CompletionItemKind::File;
  1082. break;
  1083. default:
  1084. item.kind = lsp::CompletionItemKind::Text;
  1085. break;
  1086. }
  1087. return item;
  1088. }
  1089. };
  1090. struct NativeSymbolInspectParams {
  1091. String native_class;
  1092. String symbol_name;
  1093. void load(const Dictionary &p_params) {
  1094. native_class = p_params["native_class"];
  1095. symbol_name = p_params["symbol_name"];
  1096. }
  1097. };
  1098. /**
  1099. * Enum of known range kinds
  1100. */
  1101. namespace FoldingRangeKind {
  1102. /**
  1103. * Folding range for a comment
  1104. */
  1105. static const String Comment = "comment";
  1106. /**
  1107. * Folding range for a imports or includes
  1108. */
  1109. static const String Imports = "imports";
  1110. /**
  1111. * Folding range for a region (e.g. `#region`)
  1112. */
  1113. static const String Region = "region";
  1114. } // namespace FoldingRangeKind
  1115. /**
  1116. * Represents a folding range.
  1117. */
  1118. struct FoldingRange {
  1119. /**
  1120. * The zero-based line number from where the folded range starts.
  1121. */
  1122. int startLine = 0;
  1123. /**
  1124. * The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line.
  1125. */
  1126. int startCharacter = 0;
  1127. /**
  1128. * The zero-based line number where the folded range ends.
  1129. */
  1130. int endLine = 0;
  1131. /**
  1132. * The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line.
  1133. */
  1134. int endCharacter = 0;
  1135. /**
  1136. * Describes the kind of the folding range such as `comment' or 'region'. The kind
  1137. * is used to categorize folding ranges and used by commands like 'Fold all comments'. See
  1138. * [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds.
  1139. */
  1140. String kind = FoldingRangeKind::Region;
  1141. _FORCE_INLINE_ Dictionary to_json() const {
  1142. Dictionary dict;
  1143. dict["startLine"] = startLine;
  1144. dict["startCharacter"] = startCharacter;
  1145. dict["endLine"] = endLine;
  1146. dict["endCharacter"] = endCharacter;
  1147. return dict;
  1148. }
  1149. };
  1150. /**
  1151. * How a completion was triggered
  1152. */
  1153. namespace CompletionTriggerKind {
  1154. /**
  1155. * Completion was triggered by typing an identifier (24x7 code
  1156. * complete), manual invocation (e.g Ctrl+Space) or via API.
  1157. */
  1158. static const int Invoked = 1;
  1159. /**
  1160. * Completion was triggered by a trigger character specified by
  1161. * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
  1162. */
  1163. static const int TriggerCharacter = 2;
  1164. /**
  1165. * Completion was re-triggered as the current completion list is incomplete.
  1166. */
  1167. static const int TriggerForIncompleteCompletions = 3;
  1168. } // namespace CompletionTriggerKind
  1169. /**
  1170. * Contains additional information about the context in which a completion request is triggered.
  1171. */
  1172. struct CompletionContext {
  1173. /**
  1174. * How the completion was triggered.
  1175. */
  1176. int triggerKind = CompletionTriggerKind::TriggerCharacter;
  1177. /**
  1178. * The trigger character (a single character) that has trigger code complete.
  1179. * Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
  1180. */
  1181. String triggerCharacter;
  1182. void load(const Dictionary &p_params) {
  1183. triggerKind = int(p_params["triggerKind"]);
  1184. triggerCharacter = p_params["triggerCharacter"];
  1185. }
  1186. };
  1187. struct CompletionParams : public TextDocumentPositionParams {
  1188. /**
  1189. * The completion context. This is only available if the client specifies
  1190. * to send this using `ClientCapabilities.textDocument.completion.contextSupport === true`
  1191. */
  1192. CompletionContext context;
  1193. void load(const Dictionary &p_params) {
  1194. TextDocumentPositionParams::load(p_params);
  1195. context.load(p_params["context"]);
  1196. }
  1197. };
  1198. /**
  1199. * The result of a hover request.
  1200. */
  1201. struct Hover {
  1202. /**
  1203. * The hover's content
  1204. */
  1205. MarkupContent contents;
  1206. /**
  1207. * An optional range is a range inside a text document
  1208. * that is used to visualize a hover, e.g. by changing the background color.
  1209. */
  1210. Range range;
  1211. _FORCE_INLINE_ Dictionary to_json() const {
  1212. Dictionary dict;
  1213. dict["range"] = range.to_json();
  1214. dict["contents"] = contents.to_json();
  1215. return dict;
  1216. }
  1217. };
  1218. struct ServerCapabilities {
  1219. /**
  1220. * Defines how text documents are synced. Is either a detailed structure defining each notification or
  1221. * for backwards compatibility the TextDocumentSyncKind number. If omitted it defaults to `TextDocumentSyncKind.None`.
  1222. */
  1223. TextDocumentSyncOptions textDocumentSync;
  1224. /**
  1225. * The server provides hover support.
  1226. */
  1227. bool hoverProvider = true;
  1228. /**
  1229. * The server provides completion support.
  1230. */
  1231. CompletionOptions completionProvider;
  1232. /**
  1233. * The server provides signature help support.
  1234. */
  1235. SignatureHelpOptions signatureHelpProvider;
  1236. /**
  1237. * The server provides goto definition support.
  1238. */
  1239. bool definitionProvider = true;
  1240. /**
  1241. * The server provides Goto Type Definition support.
  1242. *
  1243. * Since 3.6.0
  1244. */
  1245. bool typeDefinitionProvider = false;
  1246. /**
  1247. * The server provides Goto Implementation support.
  1248. *
  1249. * Since 3.6.0
  1250. */
  1251. bool implementationProvider = false;
  1252. /**
  1253. * The server provides find references support.
  1254. */
  1255. bool referencesProvider = false;
  1256. /**
  1257. * The server provides document highlight support.
  1258. */
  1259. bool documentHighlightProvider = false;
  1260. /**
  1261. * The server provides document symbol support.
  1262. */
  1263. bool documentSymbolProvider = true;
  1264. /**
  1265. * The server provides workspace symbol support.
  1266. */
  1267. bool workspaceSymbolProvider = true;
  1268. /**
  1269. * The server provides code actions. The `CodeActionOptions` return type is only
  1270. * valid if the client signals code action literal support via the property
  1271. * `textDocument.codeAction.codeActionLiteralSupport`.
  1272. */
  1273. bool codeActionProvider = false;
  1274. /**
  1275. * The server provides code lens.
  1276. */
  1277. CodeLensOptions codeLensProvider;
  1278. /**
  1279. * The server provides document formatting.
  1280. */
  1281. bool documentFormattingProvider = false;
  1282. /**
  1283. * The server provides document range formatting.
  1284. */
  1285. bool documentRangeFormattingProvider = false;
  1286. /**
  1287. * The server provides document formatting on typing.
  1288. */
  1289. DocumentOnTypeFormattingOptions documentOnTypeFormattingProvider;
  1290. /**
  1291. * The server provides rename support. RenameOptions may only be
  1292. * specified if the client states that it supports
  1293. * `prepareSupport` in its initial `initialize` request.
  1294. */
  1295. RenameOptions renameProvider;
  1296. /**
  1297. * The server provides document link support.
  1298. */
  1299. DocumentLinkOptions documentLinkProvider;
  1300. /**
  1301. * The server provides color provider support.
  1302. *
  1303. * Since 3.6.0
  1304. */
  1305. ColorProviderOptions colorProvider;
  1306. /**
  1307. * The server provides folding provider support.
  1308. *
  1309. * Since 3.10.0
  1310. */
  1311. FoldingRangeProviderOptions foldingRangeProvider;
  1312. /**
  1313. * The server provides go to declaration support.
  1314. *
  1315. * Since 3.14.0
  1316. */
  1317. bool declarationProvider = true;
  1318. /**
  1319. * The server provides execute command support.
  1320. */
  1321. ExecuteCommandOptions executeCommandProvider;
  1322. _FORCE_INLINE_ Dictionary to_json() {
  1323. Dictionary dict;
  1324. dict["textDocumentSync"] = (int)textDocumentSync.change;
  1325. dict["completionProvider"] = completionProvider.to_json();
  1326. dict["signatureHelpProvider"] = signatureHelpProvider.to_json();
  1327. dict["codeLensProvider"] = false; // codeLensProvider.to_json();
  1328. dict["documentOnTypeFormattingProvider"] = documentOnTypeFormattingProvider.to_json();
  1329. dict["renameProvider"] = renameProvider.to_json();
  1330. dict["documentLinkProvider"] = documentLinkProvider.to_json();
  1331. dict["colorProvider"] = false; // colorProvider.to_json();
  1332. dict["foldingRangeProvider"] = false; //foldingRangeProvider.to_json();
  1333. dict["executeCommandProvider"] = executeCommandProvider.to_json();
  1334. dict["hoverProvider"] = hoverProvider;
  1335. dict["definitionProvider"] = definitionProvider;
  1336. dict["typeDefinitionProvider"] = typeDefinitionProvider;
  1337. dict["implementationProvider"] = implementationProvider;
  1338. dict["referencesProvider"] = referencesProvider;
  1339. dict["documentHighlightProvider"] = documentHighlightProvider;
  1340. dict["documentSymbolProvider"] = documentSymbolProvider;
  1341. dict["workspaceSymbolProvider"] = workspaceSymbolProvider;
  1342. dict["codeActionProvider"] = codeActionProvider;
  1343. dict["documentFormattingProvider"] = documentFormattingProvider;
  1344. dict["documentRangeFormattingProvider"] = documentRangeFormattingProvider;
  1345. dict["declarationProvider"] = declarationProvider;
  1346. return dict;
  1347. }
  1348. };
  1349. struct InitializeResult {
  1350. /**
  1351. * The capabilities the language server provides.
  1352. */
  1353. ServerCapabilities capabilities;
  1354. _FORCE_INLINE_ Dictionary to_json() {
  1355. Dictionary dict;
  1356. dict["capabilities"] = capabilities.to_json();
  1357. return dict;
  1358. }
  1359. };
  1360. } // namespace lsp
  1361. #endif