@adecore/editor-react 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/CallHierarchyPanel.js +177 -181
  2. package/dist/EditorContextMenu.js +118 -105
  3. package/dist/LanguagePopups.js +7 -0
  4. package/dist/PickPopup.js +190 -70
  5. package/dist/WrapCard.d.ts +8 -0
  6. package/dist/WrapCard.js +172 -0
  7. package/dist/call-hierarchy-model.d.ts +4 -2
  8. package/dist/call-hierarchy-model.js +20 -0
  9. package/dist/call-hierarchy.d.ts +3 -0
  10. package/dist/call-hierarchy.js +54 -22
  11. package/dist/clipboard-history.d.ts +31 -0
  12. package/dist/clipboard-history.js +70 -0
  13. package/dist/code-actions.d.ts +3 -1
  14. package/dist/code-actions.js +50 -10
  15. package/dist/code-vision.js +2 -3
  16. package/dist/completion.js +10 -15
  17. package/dist/context-menu-rows.d.ts +1 -1
  18. package/dist/context-menu-rows.js +4 -0
  19. package/dist/definition-link.js +15 -5
  20. package/dist/document-colors.d.ts +24 -0
  21. package/dist/document-colors.js +194 -0
  22. package/dist/document-links.d.ts +22 -0
  23. package/dist/document-links.js +133 -0
  24. package/dist/document-query.d.ts +15 -0
  25. package/dist/document-query.js +54 -0
  26. package/dist/edit-locations.d.ts +20 -0
  27. package/dist/edit-locations.js +136 -0
  28. package/dist/editor-language.d.ts +19 -1
  29. package/dist/editor-language.js +77 -2
  30. package/dist/emmet.d.ts +13 -0
  31. package/dist/emmet.js +62 -0
  32. package/dist/folding.js +2 -3
  33. package/dist/format-on-type.js +3 -5
  34. package/dist/highlights.js +2 -3
  35. package/dist/history.d.ts +7 -0
  36. package/dist/history.js +79 -1
  37. package/dist/host-types.d.ts +6 -0
  38. package/dist/index.d.ts +11 -2
  39. package/dist/index.js +8 -0
  40. package/dist/inlay-hints.js +2 -2
  41. package/dist/inline-completion.d.ts +39 -0
  42. package/dist/inline-completion.js +221 -0
  43. package/dist/key-priority.d.ts +8 -5
  44. package/dist/key-priority.js +9 -6
  45. package/dist/linked-editing.d.ts +26 -0
  46. package/dist/linked-editing.js +215 -0
  47. package/dist/locales/en.json +31 -2
  48. package/dist/locales/nl.json +31 -2
  49. package/dist/markup-context.d.ts +37 -0
  50. package/dist/markup-context.js +291 -0
  51. package/dist/markup.d.ts +36 -0
  52. package/dist/markup.js +453 -0
  53. package/dist/navigation.js +4 -6
  54. package/dist/paste-history.d.ts +7 -0
  55. package/dist/paste-history.js +104 -0
  56. package/dist/peek.js +3 -4
  57. package/dist/pick.d.ts +20 -2
  58. package/dist/pick.js +141 -18
  59. package/dist/popups.d.ts +9 -0
  60. package/dist/popups.js +2 -1
  61. package/dist/project-language.d.ts +18 -1
  62. package/dist/project-language.js +129 -18
  63. package/dist/rename.js +8 -11
  64. package/dist/rendered-docs.js +1 -2
  65. package/dist/selection-ranges.js +2 -3
  66. package/dist/shortcut-keys.d.ts +19 -0
  67. package/dist/signature.js +3 -6
  68. package/dist/snippet-session.d.ts +2 -2
  69. package/dist/snippet-session.js +3 -3
  70. package/dist/symbol-picker.js +4 -6
  71. package/dist/symbols.js +22 -3
  72. package/dist/testing.d.ts +23 -1
  73. package/dist/testing.js +114 -0
  74. package/package.json +7 -6
  75. package/src/CallHierarchyPanel.tsx +26 -11
  76. package/src/EditorContextMenu.tsx +7 -0
  77. package/src/LanguagePopups.tsx +4 -0
  78. package/src/PickPopup.tsx +40 -5
  79. package/src/WrapCard.tsx +64 -0
  80. package/src/call-hierarchy-model.ts +25 -3
  81. package/src/call-hierarchy.ts +62 -20
  82. package/src/clipboard-history.ts +102 -0
  83. package/src/code-actions.ts +48 -11
  84. package/src/code-vision.ts +3 -3
  85. package/src/completion.ts +15 -15
  86. package/src/context-menu-rows.ts +3 -2
  87. package/src/definition-link.ts +17 -5
  88. package/src/document-colors.ts +189 -0
  89. package/src/document-links.ts +129 -0
  90. package/src/document-query.ts +71 -0
  91. package/src/edit-locations.ts +162 -0
  92. package/src/editor-language.ts +80 -3
  93. package/src/emmet-module.d.ts +44 -0
  94. package/src/emmet.ts +73 -0
  95. package/src/folding.ts +3 -3
  96. package/src/format-on-type.ts +5 -5
  97. package/src/highlights.ts +3 -3
  98. package/src/history.ts +81 -1
  99. package/src/host-types.ts +10 -0
  100. package/src/index.ts +12 -3
  101. package/src/inlay-hints.ts +2 -2
  102. package/src/inline-completion.ts +221 -0
  103. package/src/key-priority.ts +9 -6
  104. package/src/linked-editing.ts +199 -0
  105. package/src/locales/en.json +31 -2
  106. package/src/locales/nl.json +31 -2
  107. package/src/markup-context.ts +262 -0
  108. package/src/markup.ts +367 -0
  109. package/src/navigation.ts +6 -6
  110. package/src/paste-history.ts +111 -0
  111. package/src/peek.ts +4 -4
  112. package/src/pick.ts +201 -19
  113. package/src/popups.ts +19 -1
  114. package/src/project-language.ts +136 -19
  115. package/src/rename.ts +11 -11
  116. package/src/rendered-docs.ts +2 -2
  117. package/src/selection-ranges.ts +3 -3
  118. package/src/signature.ts +6 -6
  119. package/src/snippet-session.ts +9 -4
  120. package/src/symbol-picker.ts +6 -6
  121. package/src/symbols.ts +30 -4
  122. package/src/testing.ts +126 -1
package/src/testing.ts CHANGED
@@ -38,7 +38,24 @@ import {
38
38
  type SignatureHelpContext,
39
39
  type TextEdit,
40
40
  type WorkspaceEdit,
41
- type WorkspaceSymbolResult
41
+ type WorkspaceSymbolResult,
42
+ type Color,
43
+ type ColorInformation,
44
+ type ColorPresentation,
45
+ type DocumentLink,
46
+ type InlineCompletionContext,
47
+ type InlineCompletionResult,
48
+ type InlineValue,
49
+ type InlineValueContext,
50
+ type LinkedEditingRanges,
51
+ type Moniker,
52
+ type PreviousResultId,
53
+ type ServerMessage,
54
+ type ShowDocumentParams,
55
+ type ShowDocumentResult,
56
+ type TextDocumentSaveReason,
57
+ type TypeHierarchyItem,
58
+ type WorkspaceDiagnosticReport
42
59
  } from '@adecore/lsp';
43
60
 
44
61
  export { ManualTimers } from './timers.ts';
@@ -57,6 +74,8 @@ export class FakeLanguageService implements LanguageService {
57
74
  private readonly answers = new Map<string, (call: LanguageCall) => unknown>();
58
75
  private readonly diagnostics = new Set<(report: DiagnosticsReport) => void>();
59
76
  private readonly changes = new Set<(uri: string) => void>();
77
+ private readonly messages = new Set<(message: ServerMessage) => void>();
78
+ private showDocument: ((params: ShowDocumentParams) => Promise<ShowDocumentResult>) | null = null;
60
79
 
61
80
  respond(method: string, answer: (call: LanguageCall) => unknown, provider: ProviderOptions = {}): void {
62
81
  this.answers.set(method, answer);
@@ -271,4 +290,110 @@ export class FakeLanguageService implements LanguageService {
271
290
  resolveCodeLens(uri: string, lens: CodeLens, options: LanguageRequestOptions = {}): Promise<CodeLens> {
272
291
  return this.request<CodeLens>('codeLens/resolve', uri, lens, options);
273
292
  }
293
+
294
+ documentLinks(uri: string, options: LanguageRequestOptions = {}): Promise<DocumentLink[] | null> {
295
+ return this.request<DocumentLink[] | null>('textDocument/documentLink', uri, {}, options);
296
+ }
297
+
298
+ resolveDocumentLink(uri: string, link: DocumentLink, options: LanguageRequestOptions = {}): Promise<DocumentLink> {
299
+ return this.request<DocumentLink>('documentLink/resolve', uri, link, options);
300
+ }
301
+
302
+ documentColors(uri: string, options: LanguageRequestOptions = {}): Promise<ColorInformation[] | null> {
303
+ return this.request<ColorInformation[] | null>('textDocument/documentColor', uri, {}, options);
304
+ }
305
+
306
+ colorPresentations(uri: string, color: Color, range: Range, options: LanguageRequestOptions = {}): Promise<ColorPresentation[] | null> {
307
+ return this.request<ColorPresentation[] | null>('textDocument/colorPresentation', uri, { color, range }, options);
308
+ }
309
+
310
+ linkedEditingRanges(uri: string, position: Position, options: LanguageRequestOptions = {}): Promise<LinkedEditingRanges | null> {
311
+ return this.request<LinkedEditingRanges | null>('textDocument/linkedEditingRange', uri, { position }, options);
312
+ }
313
+
314
+ monikers(uri: string, position: Position, options: LanguageRequestOptions = {}): Promise<Moniker[] | null> {
315
+ return this.request<Moniker[] | null>('textDocument/moniker', uri, { position }, options);
316
+ }
317
+
318
+ prepareTypeHierarchy(uri: string, position: Position, options: LanguageRequestOptions = {}): Promise<TypeHierarchyItem[] | null> {
319
+ return this.request<TypeHierarchyItem[] | null>('textDocument/prepareTypeHierarchy', uri, { position }, options);
320
+ }
321
+
322
+ supertypes(uri: string, item: TypeHierarchyItem, options: LanguageRequestOptions = {}): Promise<TypeHierarchyItem[] | null> {
323
+ return this.request<TypeHierarchyItem[] | null>('typeHierarchy/supertypes', uri, { item }, options);
324
+ }
325
+
326
+ subtypes(uri: string, item: TypeHierarchyItem, options: LanguageRequestOptions = {}): Promise<TypeHierarchyItem[] | null> {
327
+ return this.request<TypeHierarchyItem[] | null>('typeHierarchy/subtypes', uri, { item }, options);
328
+ }
329
+
330
+ inlineValues(uri: string, range: Range, context: InlineValueContext, options: LanguageRequestOptions = {}): Promise<InlineValue[] | null> {
331
+ return this.request<InlineValue[] | null>('textDocument/inlineValue', uri, { range, context }, options);
332
+ }
333
+
334
+ inlineCompletions(
335
+ uri: string,
336
+ position: Position,
337
+ context: InlineCompletionContext,
338
+ options: LanguageRequestOptions = {}
339
+ ): Promise<InlineCompletionResult> {
340
+ return this.request<InlineCompletionResult>('textDocument/inlineCompletion', uri, { position, context }, options);
341
+ }
342
+
343
+ rangesFormatting(uri: string, ranges: readonly Range[], formatting: FormattingOptions, options: LanguageRequestOptions = {}): Promise<TextEdit[] | null> {
344
+ return this.request<TextEdit[] | null>('textDocument/rangesFormatting', uri, { ranges, options: formatting }, options);
345
+ }
346
+
347
+ async willSave(uri: string, reason: TextDocumentSaveReason = 1): Promise<void> {
348
+ this.calls.push({ method: 'textDocument/willSave', uri, params: { reason }, options: {} });
349
+ }
350
+
351
+ async willSaveWaitUntil(uri: string, reason: TextDocumentSaveReason = 1, options: LanguageRequestOptions = {}): Promise<TextEdit[] | null> {
352
+ return this.supports('textDocument/willSaveWaitUntil', uri)
353
+ ? this.request<TextEdit[] | null>('textDocument/willSaveWaitUntil', uri, { reason }, options)
354
+ : null;
355
+ }
356
+
357
+ workspaceDiagnostics(
358
+ uri: string,
359
+ previousResultIds: readonly PreviousResultId[] = [],
360
+ options: LanguageRequestOptions = {}
361
+ ): Promise<WorkspaceDiagnosticReport> {
362
+ return this.request<WorkspaceDiagnosticReport>('workspace/diagnostic', uri, { previousResultIds }, options);
363
+ }
364
+
365
+ async textDocumentContent(uri: string, options: LanguageRequestOptions = {}): Promise<string | null> {
366
+ if (!this.supports('workspace/textDocumentContent', uri)) {
367
+ return null;
368
+ }
369
+ return (await this.request<{ text: string } | null>('workspace/textDocumentContent', uri, { uri }, options))?.text ?? null;
370
+ }
371
+
372
+ onServerMessage(listener: (message: ServerMessage) => void): Disposable {
373
+ this.messages.add(listener);
374
+ return { dispose: () => this.messages.delete(listener) };
375
+ }
376
+
377
+ onShowDocument(handler: (params: ShowDocumentParams) => Promise<ShowDocumentResult>): Disposable {
378
+ this.showDocument = handler;
379
+ return {
380
+ dispose: () => {
381
+ if (this.showDocument === handler) {
382
+ this.showDocument = null;
383
+ }
384
+ }
385
+ };
386
+ }
387
+
388
+ /* Sends a message as a server would. */
389
+ message(message: ServerMessage): void {
390
+ for (const listener of this.messages) {
391
+ listener(message);
392
+ }
393
+ }
394
+
395
+ /* Asks the host to show a document as a server would; false when nothing handles it. */
396
+ async show(params: ShowDocumentParams): Promise<boolean> {
397
+ return (await this.showDocument?.(params))?.success ?? false;
398
+ }
274
399
  }