@adecore/editor-react 0.62.1 → 0.63.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 (264) hide show
  1. package/README.md +2 -2
  2. package/dist/AnchoredPopup.d.ts +2 -1
  3. package/dist/CompletionPopup.js +0 -2
  4. package/dist/DiffView.d.ts +1 -28
  5. package/dist/EditorView.js +0 -1
  6. package/dist/HoverSections.d.ts +1 -8
  7. package/dist/HoverSections.js +2 -2
  8. package/dist/LanguagePopups.js +30 -14
  9. package/dist/PanelResizeHandle.js +0 -1
  10. package/dist/PeekPanel.js +0 -1
  11. package/dist/PickPopup.js +0 -1
  12. package/dist/RenderedDocs.js +0 -2
  13. package/dist/SplitDiffView.d.ts +1 -1
  14. package/dist/SymbolPicker.js +0 -1
  15. package/dist/call-hierarchy-model.js +0 -4
  16. package/dist/call-hierarchy.d.ts +9 -2
  17. package/dist/call-hierarchy.js +51 -67
  18. package/dist/clipboard-history.d.ts +3 -0
  19. package/dist/clipboard-history.js +0 -1
  20. package/dist/code-actions-model.js +1 -1
  21. package/dist/code-actions.d.ts +14 -2
  22. package/dist/code-actions.js +14 -9
  23. package/dist/code-authors.js +4 -12
  24. package/dist/code-vision-model.d.ts +0 -1
  25. package/dist/code-vision-model.js +1 -2
  26. package/dist/code-vision.d.ts +11 -3
  27. package/dist/code-vision.js +13 -18
  28. package/dist/completion-call.d.ts +1 -1
  29. package/dist/completion-call.js +2 -1
  30. package/dist/completion-model.d.ts +5 -4
  31. package/dist/completion-model.js +4 -4
  32. package/dist/completion.d.ts +13 -4
  33. package/dist/completion.js +19 -18
  34. package/dist/context-menu-rows.d.ts +2 -1
  35. package/dist/context-menu.d.ts +9 -3
  36. package/dist/context-menu.js +17 -19
  37. package/dist/definition-link.d.ts +8 -2
  38. package/dist/definition-link.js +4 -2
  39. package/dist/diagnostics-model.d.ts +6 -8
  40. package/dist/diagnostics-model.js +1 -54
  41. package/dist/diagnostics.d.ts +9 -7
  42. package/dist/diagnostics.js +6 -4
  43. package/dist/diff-view-props.d.ts +28 -0
  44. package/dist/diff-view-props.js +1 -0
  45. package/dist/doc-comment-model.js +0 -2
  46. package/dist/document-colors.d.ts +9 -4
  47. package/dist/document-colors.js +7 -4
  48. package/dist/document-links.d.ts +2 -3
  49. package/dist/document-links.js +2 -3
  50. package/dist/document-query.d.ts +2 -2
  51. package/dist/edit-locations.js +4 -22
  52. package/dist/editor-language.d.ts +12 -7
  53. package/dist/editor-language.js +54 -45
  54. package/dist/emmet.d.ts +3 -2
  55. package/dist/folding.d.ts +2 -4
  56. package/dist/folding.js +1 -2
  57. package/dist/format-on-type.d.ts +8 -2
  58. package/dist/format-on-type.js +8 -6
  59. package/dist/highlights.d.ts +2 -6
  60. package/dist/highlights.js +3 -3
  61. package/dist/history.d.ts +8 -2
  62. package/dist/history.js +4 -2
  63. package/dist/host-types.d.ts +39 -22
  64. package/dist/hover-content.js +0 -1
  65. package/dist/hover.d.ts +13 -2
  66. package/dist/hover.js +25 -28
  67. package/dist/index.d.ts +19 -9
  68. package/dist/index.js +5 -2
  69. package/dist/inlay-hints.d.ts +12 -21
  70. package/dist/inlay-hints.js +16 -15
  71. package/dist/inline-completion.d.ts +30 -10
  72. package/dist/inline-completion.js +346 -102
  73. package/dist/key-priority.d.ts +1 -1
  74. package/dist/key-priority.js +2 -2
  75. package/dist/language-context.d.ts +30 -0
  76. package/dist/language-context.js +1 -0
  77. package/dist/language-ids.d.ts +0 -1
  78. package/dist/language-ids.js +0 -32
  79. package/dist/line-text.js +0 -1
  80. package/dist/linked-editing.d.ts +2 -4
  81. package/dist/linked-editing.js +1 -3
  82. package/dist/live-templates.d.ts +14 -2
  83. package/dist/live-templates.js +15 -10
  84. package/dist/locales/en.d.ts +357 -0
  85. package/dist/locales/en.js +356 -0
  86. package/dist/locales/nl.d.ts +357 -0
  87. package/dist/locales/nl.js +356 -0
  88. package/dist/markup-context.d.ts +7 -6
  89. package/dist/markup-context.js +0 -1
  90. package/dist/markup.d.ts +8 -2
  91. package/dist/markup.js +19 -20
  92. package/dist/models.d.ts +2 -1
  93. package/dist/models.js +2 -1
  94. package/dist/navigation-history.d.ts +7 -0
  95. package/dist/navigation.d.ts +11 -8
  96. package/dist/navigation.js +9 -20
  97. package/dist/panel-size.d.ts +4 -0
  98. package/dist/paste-history.d.ts +8 -2
  99. package/dist/paste-history.js +4 -2
  100. package/dist/patch-layout.d.ts +0 -4
  101. package/dist/patch-layout.js +1 -1
  102. package/dist/peek-model.js +0 -1
  103. package/dist/peek.d.ts +8 -2
  104. package/dist/peek.js +31 -42
  105. package/dist/pick.d.ts +4 -2
  106. package/dist/pick.js +38 -15
  107. package/dist/popups.d.ts +25 -20
  108. package/dist/popups.js +31 -15
  109. package/dist/positions.d.ts +7 -0
  110. package/dist/positions.js +54 -0
  111. package/dist/postfix.d.ts +11 -2
  112. package/dist/postfix.js +10 -6
  113. package/dist/project-language.d.ts +11 -3
  114. package/dist/project-language.js +40 -9
  115. package/dist/project-problems.d.ts +7 -1
  116. package/dist/project-problems.js +2 -1
  117. package/dist/rename-model.js +1 -1
  118. package/dist/rename.d.ts +2 -2
  119. package/dist/rename.js +17 -22
  120. package/dist/rendered-docs.d.ts +8 -2
  121. package/dist/rendered-docs.js +5 -4
  122. package/dist/selection-ranges.d.ts +2 -2
  123. package/dist/semantic-tokens.d.ts +2 -4
  124. package/dist/semantic-tokens.js +2 -2
  125. package/dist/shortcut-keys.d.ts +2 -1
  126. package/dist/signature.d.ts +2 -2
  127. package/dist/signature.js +9 -15
  128. package/dist/snippet-field-transforms.js +1 -1
  129. package/dist/snippet-insert.d.ts +4 -2
  130. package/dist/snippet-insert.js +9 -15
  131. package/dist/snippet-session.d.ts +9 -4
  132. package/dist/snippet-session.js +14 -14
  133. package/dist/snippet-transform-format.d.ts +2 -1
  134. package/dist/snippet-transform-queue.d.ts +2 -4
  135. package/dist/snippet-transform-queue.js +5 -37
  136. package/dist/snippet.d.ts +2 -1
  137. package/dist/surround-constructs.d.ts +1 -1
  138. package/dist/surround.d.ts +13 -2
  139. package/dist/surround.js +15 -8
  140. package/dist/symbol-links.d.ts +0 -1
  141. package/dist/symbol-links.js +1 -1
  142. package/dist/symbol-picker-model.d.ts +0 -1
  143. package/dist/symbol-picker-model.js +1 -2
  144. package/dist/symbol-picker.d.ts +2 -2
  145. package/dist/symbol-picker.js +5 -10
  146. package/dist/symbols.d.ts +4 -3
  147. package/dist/template-builtins.d.ts +1 -1
  148. package/dist/template-builtins.js +0 -1
  149. package/dist/template-context.d.ts +3 -3
  150. package/dist/template-context.js +2 -11
  151. package/dist/template-types.d.ts +20 -0
  152. package/dist/template-types.js +1 -0
  153. package/dist/templates.d.ts +5 -20
  154. package/dist/templates.js +0 -1
  155. package/dist/testing.d.ts +6 -0
  156. package/dist/testing.js +42 -0
  157. package/dist/use-problem-counts.d.ts +1 -1
  158. package/dist/word-diff.d.ts +1 -1
  159. package/dist/word-diff.js +16 -25
  160. package/dist/workspace-edit.d.ts +1 -24
  161. package/dist/workspace-edit.js +0 -1
  162. package/package.json +10 -9
  163. package/src/AnchoredPopup.tsx +1 -1
  164. package/src/CompletionPopup.tsx +0 -2
  165. package/src/DiffView.tsx +6 -38
  166. package/src/EditorView.tsx +0 -1
  167. package/src/HoverSections.tsx +2 -2
  168. package/src/LanguagePopups.tsx +20 -14
  169. package/src/PanelResizeHandle.tsx +0 -1
  170. package/src/PeekPanel.tsx +0 -1
  171. package/src/PickPopup.tsx +0 -1
  172. package/src/RenderedDocs.tsx +0 -2
  173. package/src/SplitDiffView.tsx +1 -1
  174. package/src/SymbolPicker.tsx +0 -1
  175. package/src/call-hierarchy-model.ts +0 -7
  176. package/src/call-hierarchy.ts +32 -31
  177. package/src/clipboard-history.ts +5 -2
  178. package/src/code-actions-model.ts +1 -4
  179. package/src/code-actions.ts +26 -10
  180. package/src/code-authors.ts +4 -15
  181. package/src/code-vision-model.ts +1 -2
  182. package/src/code-vision.ts +23 -19
  183. package/src/completion-call.ts +2 -2
  184. package/src/completion-model.ts +12 -7
  185. package/src/completion.ts +31 -16
  186. package/src/context-menu-rows.ts +1 -1
  187. package/src/context-menu.ts +19 -10
  188. package/src/definition-link.ts +12 -4
  189. package/src/diagnostics-model.ts +8 -55
  190. package/src/diagnostics.ts +11 -20
  191. package/src/diff-view-props.ts +38 -0
  192. package/src/doc-comment-model.ts +0 -2
  193. package/src/document-colors.ts +14 -6
  194. package/src/document-links.ts +5 -6
  195. package/src/document-query.ts +3 -3
  196. package/src/edit-locations.ts +4 -19
  197. package/src/editor-language.ts +74 -39
  198. package/src/emmet.ts +2 -3
  199. package/src/folding.ts +4 -5
  200. package/src/format-on-type.ts +14 -7
  201. package/src/highlights.ts +6 -6
  202. package/src/history.ts +12 -4
  203. package/src/host-types.ts +52 -33
  204. package/src/hover-content.ts +0 -1
  205. package/src/hover.ts +29 -22
  206. package/src/index.ts +25 -14
  207. package/src/inlay-hints.ts +23 -17
  208. package/src/inline-completion.ts +340 -90
  209. package/src/key-priority.ts +2 -2
  210. package/src/language-context.ts +60 -0
  211. package/src/language-ids.ts +0 -34
  212. package/src/line-text.ts +0 -1
  213. package/src/linked-editing.ts +4 -6
  214. package/src/live-templates.ts +27 -13
  215. package/src/locales/en.ts +356 -0
  216. package/src/locales/nl.ts +356 -0
  217. package/src/markup-context.ts +6 -9
  218. package/src/markup.ts +19 -10
  219. package/src/models.ts +2 -1
  220. package/src/navigation-history.ts +11 -0
  221. package/src/navigation.ts +18 -20
  222. package/src/panel-size.ts +8 -0
  223. package/src/paste-history.ts +12 -4
  224. package/src/patch-layout.ts +1 -1
  225. package/src/peek-model.ts +0 -1
  226. package/src/peek.ts +22 -18
  227. package/src/pick.ts +30 -16
  228. package/src/popups.ts +61 -40
  229. package/src/positions.ts +54 -0
  230. package/src/postfix.ts +21 -8
  231. package/src/project-language.ts +63 -14
  232. package/src/project-problems.ts +10 -2
  233. package/src/proposal-model.ts +0 -1
  234. package/src/rename-model.ts +1 -1
  235. package/src/rename.ts +21 -24
  236. package/src/rendered-docs.ts +13 -6
  237. package/src/selection-ranges.ts +2 -2
  238. package/src/semantic-tokens.ts +5 -5
  239. package/src/shortcut-keys.ts +1 -1
  240. package/src/signature.ts +8 -8
  241. package/src/snippet-field-transforms.ts +1 -1
  242. package/src/snippet-insert.ts +21 -14
  243. package/src/snippet-session.ts +25 -24
  244. package/src/snippet-transform-format.ts +1 -1
  245. package/src/snippet-transform-queue.ts +5 -51
  246. package/src/snippet.ts +1 -1
  247. package/src/surround-constructs.ts +1 -1
  248. package/src/surround.ts +24 -12
  249. package/src/symbol-links.ts +1 -1
  250. package/src/symbol-picker-model.ts +1 -4
  251. package/src/symbol-picker.ts +6 -7
  252. package/src/symbols.ts +3 -4
  253. package/src/template-builtins.ts +1 -2
  254. package/src/template-context.ts +5 -14
  255. package/src/template-types.ts +43 -0
  256. package/src/templates.ts +9 -45
  257. package/src/testing.ts +52 -0
  258. package/src/use-problem-counts.ts +1 -1
  259. package/src/word-diff.ts +17 -28
  260. package/src/workspace-edit.ts +1 -34
  261. package/dist/locales/en.json +0 -356
  262. package/dist/locales/nl.json +0 -356
  263. package/src/locales/en.json +0 -356
  264. package/src/locales/nl.json +0 -356
package/dist/folding.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- import type { EditorFoldSymbol } from '@adecore/editor';
2
1
  import type { DocumentSymbolResult } from '@adecore/lsp';
3
- import type { EditorLanguage } from './editor-language.ts';
2
+ import type { LanguageContext } from './language-context.ts';
4
3
  import { type Timers } from './timers.ts';
5
- export declare function foldSymbolsOf(result: DocumentSymbolResult): EditorFoldSymbol[];
6
4
  export declare class FoldingFeature {
7
5
  private symbols;
8
6
  private ranges;
9
7
  private readonly refresher;
10
8
  private readonly language;
11
- constructor(language: EditorLanguage, onSymbols: (listener: (result: DocumentSymbolResult) => void) => () => void, timers?: Timers);
9
+ constructor(language: LanguageContext, onSymbols: (listener: (result: DocumentSymbolResult) => void) => () => void, timers?: Timers);
12
10
  private publish;
13
11
  }
package/dist/folding.js CHANGED
@@ -17,8 +17,7 @@ const BODIES = {
17
17
  14: 'value',
18
18
  23: 'class'
19
19
  };
20
- /* The symbols that have a body of more than one line, as what the editor folds them by. */
21
- export function foldSymbolsOf(result) {
20
+ function foldSymbolsOf(result) {
22
21
  return symbolSpansOf(result).flatMap(({
23
22
  kind,
24
23
  range
@@ -1,10 +1,15 @@
1
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { LanguageContext } from './language-context.ts';
2
+ import type { SnippetFeature } from './snippet-session.ts';
3
+ interface FormatOnTypePeers {
4
+ readonly snippets: Pick<SnippetFeature, 'applyEdits' | 'isActive' | 'token'>;
5
+ }
2
6
  export declare class FormatOnTypeFeature {
3
7
  private readonly language;
8
+ private readonly peers;
4
9
  private enabled;
5
10
  private revision;
6
11
  private controller;
7
- constructor(language: EditorLanguage);
12
+ constructor(language: LanguageContext, peers: FormatOnTypePeers);
8
13
  get isEnabled(): boolean;
9
14
  get supported(): boolean;
10
15
  configure(enabled: boolean): void;
@@ -12,3 +17,4 @@ export declare class FormatOnTypeFeature {
12
17
  private typed;
13
18
  private ask;
14
19
  }
20
+ export {};
@@ -1,4 +1,4 @@
1
- import { comparePositions } from './diagnostics-model.js';
1
+ import { comparePositions } from './positions.js';
2
2
  const METHOD = 'textDocument/onTypeFormatting';
3
3
  /* A line break with the indentation the editor put after it, which is how Enter reaches the server. */
4
4
  const LINE_BREAK = /^\r?\n[ \t]*(\r?\n[ \t]*)?$/;
@@ -20,12 +20,14 @@ function overlaps(edits) {
20
20
  */
21
21
  export class FormatOnTypeFeature {
22
22
  language;
23
+ peers;
23
24
  enabled = false;
24
25
  /* Raised by every change of the text, so an answer for an older text is told from the one for the text that is. */
25
26
  revision = 0;
26
27
  controller = new AbortController();
27
- constructor(language) {
28
+ constructor(language, peers) {
28
29
  this.language = language;
30
+ this.peers = peers;
29
31
  const off = language.editor.onTextChange(change => this.typed(change));
30
32
  language.onDispose(() => {
31
33
  off();
@@ -35,7 +37,6 @@ export class FormatOnTypeFeature {
35
37
  get isEnabled() {
36
38
  return this.enabled;
37
39
  }
38
- /* Whether the server of this document formats on type and the service can ask it. */
39
40
  get supported() {
40
41
  const {
41
42
  uri
@@ -48,7 +49,6 @@ export class FormatOnTypeFeature {
48
49
  this.controller.abort();
49
50
  }
50
51
  }
51
- /* The characters that ask the server, the first one and the more. */
52
52
  triggerCharacters() {
53
53
  const options = this.language.service.providerOptions(METHOD, this.language.uri);
54
54
  return options === undefined ? [] : [...(options.firstTriggerCharacter === undefined ? [] : [options.firstTriggerCharacter]), ...(options.moreTriggerCharacter ?? [])];
@@ -60,9 +60,11 @@ export class FormatOnTypeFeature {
60
60
  return;
61
61
  }
62
62
  const {
63
- editor,
64
- snippets
63
+ editor
65
64
  } = this.language;
65
+ const {
66
+ snippets
67
+ } = this.peers;
66
68
  const {
67
69
  text
68
70
  } = change.changes[0];
@@ -1,14 +1,10 @@
1
- import type { EditorHighlight, EditorPosition, EditorRange } from '@adecore/editor';
2
- import type { DocumentHighlight } from '@adecore/lsp';
3
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { LanguageContext } from './language-context.ts';
4
2
  import { type Timers } from './timers.ts';
5
- export declare function editorHighlightsOf(highlights: readonly DocumentHighlight[]): EditorHighlight[];
6
- export declare function neighborRange(ranges: readonly EditorRange[], from: EditorPosition, direction: 1 | -1): EditorRange | null;
7
3
  export declare class HighlightsFeature {
8
4
  private readonly language;
9
5
  private readonly refresher;
10
6
  private current;
11
- constructor(language: EditorLanguage, timers?: Timers);
7
+ constructor(language: LanguageContext, timers?: Timers);
12
8
  step(direction: 1 | -1): boolean;
13
9
  private onName;
14
10
  private set;
@@ -1,6 +1,6 @@
1
1
  import { isIdentifierCharacter } from './completion-model.js';
2
- import { comparePositions, rangeHolds } from './diagnostics-model.js';
3
2
  import { KEY_PRIORITY } from './key-priority.js';
3
+ import { comparePositions, rangeHolds } from './positions.js';
4
4
  import { Refresher } from './refresher.js';
5
5
  import { isShortcut } from './shortcut-keys.js';
6
6
  import { realTimers } from './timers.js';
@@ -11,14 +11,14 @@ const KINDS = {
11
11
  2: 'read',
12
12
  3: 'write'
13
13
  };
14
- export function editorHighlightsOf(highlights) {
14
+ function editorHighlightsOf(highlights) {
15
15
  return highlights.filter(highlight => comparePositions(highlight.range.start, highlight.range.end) < 0).map(highlight => ({
16
16
  range: highlight.range,
17
17
  kind: KINDS[highlight.kind ?? 1] ?? 'text'
18
18
  })).sort((left, right) => comparePositions(left.range.start, right.range.start));
19
19
  }
20
20
  /* The range before the caret when stepping back, or after it when stepping forward, wrapping round the document; null for no ranges. */
21
- export function neighborRange(ranges, from, direction) {
21
+ function neighborRange(ranges, from, direction) {
22
22
  if (ranges.length === 0) {
23
23
  return null;
24
24
  }
package/dist/history.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { LanguageContext } from './language-context.ts';
2
+ import type { PickFeature } from './pick.ts';
3
+ interface HistoryPeers {
4
+ readonly pick: Pick<PickFeature, 'locations'>;
5
+ }
2
6
  export declare class HistoryFeature {
3
7
  private readonly language;
8
+ private readonly peers;
4
9
  private editing;
5
- constructor(language: EditorLanguage);
10
+ constructor(language: LanguageContext, peers: HistoryPeers);
6
11
  lastEdit(): boolean;
7
12
  nextEdit(): boolean;
8
13
  back(): boolean;
@@ -14,3 +19,4 @@ export declare class HistoryFeature {
14
19
  private visitEdit;
15
20
  private visit;
16
21
  }
22
+ export {};
package/dist/history.js CHANGED
@@ -3,9 +3,11 @@ import { isShortcut } from './shortcut-keys.js';
3
3
  /* Back, Forward and the list of recent locations over the history the whole project shares. */
4
4
  export class HistoryFeature {
5
5
  language;
6
+ peers;
6
7
  editing = false;
7
- constructor(language) {
8
+ constructor(language, peers) {
8
9
  this.language = language;
10
+ this.peers = peers;
9
11
  const off = language.onKey(event => {
10
12
  if (isShortcut(this.language.shortcuts.historyBack, event)) {
11
13
  this.back();
@@ -61,7 +63,7 @@ export class HistoryFeature {
61
63
  /* Lists the places of the history under the caret; choosing one jumps there like any other jump. */
62
64
  recent() {
63
65
  const places = this.language.project.history.recent(this.language.place);
64
- this.language.locations(places.map(place => ({
66
+ this.peers.pick.locations(places.map(place => ({
65
67
  uri: place.uri,
66
68
  range: {
67
69
  start: place.position,
@@ -3,15 +3,38 @@ import type { Keymap } from '@adecore/editor/keymap';
3
3
  import type { WorkerRequestPort } from '@adecore/editor/worker-client';
4
4
  import type { ServerMessage } from '@adecore/lsp';
5
5
  import type { i18n } from 'i18next';
6
- import type { ClipboardHistory } from './clipboard-history.ts';
7
- import type { Place } from './navigation-history.ts';
8
- import type { ProblemSource } from './project-problems.ts';
9
- import type { LiveTemplateDraft, TemplateRegistry } from './templates.ts';
10
- import type { ProjectFiles } from './workspace-edit.ts';
6
+ import type { ClipboardHost } from './clipboard-history.ts';
7
+ import type { NavigationHost } from './navigation-history.ts';
8
+ import type { PanelsHost } from './panel-size.ts';
9
+ import type { ProblemsHost } from './project-problems.ts';
10
+ import type { TemplatesHost } from './templates.ts';
11
11
  export interface DiskText {
12
12
  text: string;
13
13
  mtime: number;
14
14
  }
15
+ export interface StagedFile {
16
+ readonly path: string;
17
+ readonly disk: DiskText;
18
+ readonly text: string;
19
+ }
20
+ export interface ProjectFiles {
21
+ read(path: string): Promise<DiskText | null>;
22
+ stage(files: readonly StagedFile[]): void;
23
+ save(files: readonly StagedFile[]): Promise<string | null>;
24
+ rename(from: string, to: string, options?: {
25
+ readonly overwrite: boolean;
26
+ }): Promise<string | null>;
27
+ create?(path: string, text: string, options?: {
28
+ readonly overwrite: boolean;
29
+ }): Promise<string | null>;
30
+ delete?(path: string, options: {
31
+ readonly recursive: boolean;
32
+ }): Promise<string | null>;
33
+ readonly supportsOverwrite?: boolean;
34
+ isUnsaved?(path: string): boolean;
35
+ exists?(path: string): Promise<boolean>;
36
+ isFolder?(path: string): Promise<boolean>;
37
+ }
15
38
  export interface GitBlameCommit {
16
39
  hash: string;
17
40
  shortHash: string;
@@ -51,27 +74,21 @@ export interface SnippetVariableContext {
51
74
  readonly folder?: string;
52
75
  readonly path?: string;
53
76
  }
54
- export interface LanguageHost {
77
+ export interface SnippetsHost {
55
78
  readonly snippetTransformWorker?: () => WorkerRequestPort;
79
+ resolveSnippetVariable?(name: string, context: SnippetVariableContext): string | undefined;
80
+ }
81
+ export interface MessagesHost {
82
+ notify?(notification: EditorNotification): void;
83
+ onServerMessage?(message: ServerMessage): void;
84
+ }
85
+ export interface RenameHost {
86
+ suggestNames?(request: RenameSuggestionsRequest, signal: AbortSignal): Promise<readonly string[]>;
87
+ }
88
+ export interface LanguageHost extends SnippetsHost, MessagesHost, RenameHost, NavigationHost, PanelsHost, ProblemsHost, TemplatesHost, ClipboardHost {
56
89
  readonly i18n?: i18n;
57
90
  readonly folder?: string;
58
91
  readonly files?: ProjectFiles;
59
92
  readonly apple?: boolean;
60
93
  readonly keymap?: Keymap;
61
- readonly clipboard?: ClipboardHistory;
62
- readonly templates?: TemplateRegistry;
63
- saveAsLiveTemplate?(draft: LiveTemplateDraft): void;
64
- openTemplateSettings?(): void;
65
- readonly editHistoryLimit?: number;
66
- readonly panelBodyHeight?: number;
67
- onPanelResize?(height: number): void;
68
- readonly problemSource?: ProblemSource;
69
- openPlace?(place: Place): void;
70
- openExternal?(url: string): void;
71
- pathOfUri?(uri: string): string | null;
72
- serverNames?(uri: string): readonly string[];
73
- notify?(notification: EditorNotification): void;
74
- onServerMessage?(message: ServerMessage): void;
75
- resolveSnippetVariable?(name: string, context: SnippetVariableContext): string | undefined;
76
- suggestNames?(request: RenameSuggestionsRequest, signal: AbortSignal): Promise<readonly string[]>;
77
94
  }
@@ -52,7 +52,6 @@ export function hoverTextOf(hover) {
52
52
  markdown: escapeMarkdown(contents.value).trim()
53
53
  } : splitSignatures(contents.value);
54
54
  }
55
- /* Plain text as markdown that reads the same, its markdown characters escaped. */
56
55
  export function escapeMarkdown(text) {
57
56
  return text.replace(/([\\`*_{}[\]()#+\-.!|<>~])/g, '\\$1');
58
57
  }
package/dist/hover.d.ts CHANGED
@@ -1,13 +1,23 @@
1
1
  import type { EditorPosition, EditorRange } from '@adecore/editor';
2
- import type { EditorLanguage } from './editor-language.ts';
2
+ import { type Problem } from './diagnostics-model.ts';
3
3
  import { type HoverText } from './hover-content.ts';
4
+ import type { LanguageContext } from './language-context.ts';
4
5
  import { type Timers } from './timers.ts';
5
6
  export declare const SHOW_DELAY_MS = 300;
6
7
  export interface HoverSettings {
7
8
  readonly referenceCount?: boolean;
8
9
  }
10
+ interface HoverPeers {
11
+ readonly diagnostics: {
12
+ at(position: EditorPosition): Problem[];
13
+ };
14
+ readonly inlayHints: {
15
+ showTooltipAt(position: EditorPosition): Promise<boolean>;
16
+ };
17
+ }
9
18
  export declare class HoverFeature {
10
19
  private readonly language;
20
+ private readonly peers;
11
21
  private readonly timers;
12
22
  private readonly counts;
13
23
  private showTimer;
@@ -19,7 +29,7 @@ export declare class HoverFeature {
19
29
  private lookup;
20
30
  private pinned;
21
31
  private held;
22
- constructor(language: EditorLanguage, timers?: Timers);
32
+ constructor(language: LanguageContext, peers: HoverPeers, timers?: Timers);
23
33
  configure(settings: HoverSettings): void;
24
34
  holdCard(inside: boolean): void;
25
35
  quickInfo(): void;
@@ -39,3 +49,4 @@ export declare class HoverFeature {
39
49
  private showCount;
40
50
  wordStart(position: EditorPosition): number;
41
51
  }
52
+ export {};
package/dist/hover.js CHANGED
@@ -1,7 +1,8 @@
1
- import { rangeHolds } from './diagnostics-model.js';
1
+ import './diagnostics-model.js';
2
2
  import { hoverTextOf, isEmptyHover, locationsOf } from './hover-content.js';
3
3
  import { KEY_PRIORITY } from './key-priority.js';
4
4
  import { lineTextOf } from './line-text.js';
5
+ import { rangeHolds } from './positions.js';
5
6
  import { wordRangeAt } from './rename-model.js';
6
7
  import { isShortcut } from './shortcut-keys.js';
7
8
  import { realTimers } from './timers.js';
@@ -17,6 +18,7 @@ const TOAST_ID = 'language-hover';
17
18
  */
18
19
  export class HoverFeature {
19
20
  language;
21
+ peers;
20
22
  timers;
21
23
  /* The counts asked for since the text last changed, by the symbol's position, so moving back to a name does not ask again. */
22
24
  counts = new Map();
@@ -32,8 +34,9 @@ export class HoverFeature {
32
34
  pinned = false;
33
35
  /* The card is being read: an explanation runs in it or is shown, so the pointer going elsewhere neither closes nor replaces it. */
34
36
  held = false;
35
- constructor(language, timers = realTimers) {
37
+ constructor(language, peers, timers = realTimers) {
36
38
  this.language = language;
39
+ this.peers = peers;
37
40
  this.timers = timers;
38
41
  const {
39
42
  editor
@@ -59,7 +62,7 @@ export class HoverFeature {
59
62
  this.quickInfo();
60
63
  return true;
61
64
  }
62
- if (event.key === 'Escape' && this.language.popups.getState().hover !== null && this.language.popups.getState().callHierarchy === null) {
65
+ if (event.key === 'Escape' && this.language.popups.slot('hover').get() !== null && this.language.popups.slot('callHierarchy').get() === null) {
63
66
  this.hide();
64
67
  return true;
65
68
  }
@@ -95,7 +98,7 @@ export class HoverFeature {
95
98
  }
96
99
  /* The problems at a position as a card, at once; what the servers say about the symbol is left for the pointer and Quick Info. */
97
100
  showProblemsAt(position) {
98
- const problems = this.language.diagnostics.at(position);
101
+ const problems = this.peers.diagnostics.at(position);
99
102
  if (problems.length === 0) {
100
103
  return false;
101
104
  }
@@ -140,10 +143,8 @@ export class HoverFeature {
140
143
  this.timers.clear(this.hideTimer);
141
144
  this.timers.clear(this.countTimer);
142
145
  this.inCard = false;
143
- if (this.language.popups.getState().hover !== null) {
144
- this.language.popups.setState({
145
- hover: null
146
- });
146
+ if (this.language.popups.slot('hover').get() !== null) {
147
+ this.language.popups.slot('hover').set(null);
147
148
  }
148
149
  }
149
150
  moved(hover) {
@@ -156,7 +157,7 @@ export class HoverFeature {
156
157
  this.scheduleHide();
157
158
  return;
158
159
  }
159
- const shown = this.language.popups.getState().hover;
160
+ const shown = this.language.popups.slot('hover').get();
160
161
  if (shown !== null && rangeHolds(shown.subject, hover.position)) {
161
162
  this.timers.clear(this.hideTimer);
162
163
  return;
@@ -167,7 +168,7 @@ export class HoverFeature {
167
168
  }
168
169
  scheduleHide() {
169
170
  this.timers.clear(this.hideTimer);
170
- if (this.language.popups.getState().hover === null || this.inCard || this.held) {
171
+ if (this.language.popups.slot('hover').get() === null || this.inCard || this.held) {
171
172
  return;
172
173
  }
173
174
  this.hideTimer = this.timers.set(() => {
@@ -224,7 +225,7 @@ export class HoverFeature {
224
225
  };
225
226
  }
226
227
  async show(position, request, pinned) {
227
- const problems = this.language.diagnostics.at(position);
228
+ const problems = this.peers.diagnostics.at(position);
228
229
  this.lookup?.abort();
229
230
  const controller = new AbortController();
230
231
  this.lookup = controller;
@@ -237,7 +238,7 @@ export class HoverFeature {
237
238
  }
238
239
  if (problems.length === 0 && info === null) {
239
240
  this.hide();
240
- if (pinned && (await this.language.inlayHints.showTooltipAt(position))) {
241
+ if (pinned && (await this.peers.inlayHints.showTooltipAt(position))) {
241
242
  this.pinned = true;
242
243
  return;
243
244
  }
@@ -262,14 +263,12 @@ export class HoverFeature {
262
263
  end: position
263
264
  };
264
265
  this.timers.clear(this.hideTimer);
265
- this.language.popups.setState({
266
- hover: {
267
- anchor: subject.start.line === position.line ? subject.start : position,
268
- position,
269
- subject,
270
- problems,
271
- info
272
- }
266
+ this.language.popups.slot('hover').set({
267
+ anchor: subject.start.line === position.line ? subject.start : position,
268
+ position,
269
+ subject,
270
+ problems,
271
+ info
273
272
  });
274
273
  }
275
274
  /* The references of the symbol are counted once the card has stayed up a while, or at once when the text has not changed since they were. */
@@ -301,15 +300,13 @@ export class HoverFeature {
301
300
  this.showCount(found.length, request);
302
301
  }
303
302
  showCount(count, request) {
304
- const shown = this.language.popups.getState().hover;
303
+ const shown = this.language.popups.slot('hover').get();
305
304
  if (request === this.request && shown?.info != null) {
306
- this.language.popups.setState({
307
- hover: {
308
- ...shown,
309
- info: {
310
- ...shown.info,
311
- references: count
312
- }
305
+ this.language.popups.slot('hover').set({
306
+ ...shown,
307
+ info: {
308
+ ...shown.info,
309
+ references: count
313
310
  }
314
311
  });
315
312
  }
package/dist/index.d.ts CHANGED
@@ -3,8 +3,13 @@ export { KEY_PRIORITY } from './key-priority.ts';
3
3
  export { realTimers, type Timers } from './timers.ts';
4
4
  export { type SemanticTokensOptions } from './semantic-tokens.ts';
5
5
  export { ProjectLanguage, type FileOperationTarget } from './project-language.ts';
6
- export type { AcquireOptions, LanguageDocumentHandle } from './project-language.ts';
7
- export type { SnippetVariableContext, LanguageHost, DiskText, GitBlameCommit, GitBlameResult, EditorNotification, RenameSuggestionsRequest } from './host-types.ts';
6
+ export type { NavigationHost } from './navigation-history.ts';
7
+ export type { PanelsHost } from './panel-size.ts';
8
+ export type { ProblemsHost } from './project-problems.ts';
9
+ export type { TemplatesHost } from './templates.ts';
10
+ export type { ClipboardHost } from './clipboard-history.ts';
11
+ export type { AcquireOptions, LanguageDocumentHandle, LanguageServiceFactory } from './project-language.ts';
12
+ export type { SnippetVariableContext, LanguageHost, SnippetsHost, MessagesHost, RenameHost, DiskText, GitBlameCommit, GitBlameResult, EditorNotification, RenameSuggestionsRequest } from './host-types.ts';
8
13
  export { EditorView } from './EditorView.tsx';
9
14
  export { createHolder } from './holder.ts';
10
15
  export type { EditorViewProps } from './EditorView.tsx';
@@ -16,7 +21,7 @@ export { type RenderedDocsFeature } from './rendered-docs.ts';
16
21
  export { type DocumentLinksFeature } from './document-links.ts';
17
22
  export { type DocumentColorsFeature } from './document-colors.ts';
18
23
  export { type LinkedEditingFeature } from './linked-editing.ts';
19
- export { type InlineCompletionFeature, type InlineSuggestion } from './inline-completion.ts';
24
+ export { firstWord, type InlineCompletionFeature, type InlineSuggestion, type InlineSuggestionRequest, type InlineSuggestionSource } from './inline-completion.ts';
20
25
  export type { RenderedDocEntry, RenderedDocsSettings } from './rendered-docs.ts';
21
26
  export type { DocTagEntry, DocTagSection, ParsedDocComment } from './doc-comment-model.ts';
22
27
  export { EditorRenderingProvider } from './rendering.tsx';
@@ -27,12 +32,15 @@ export type { ChangeReviewProps } from './ChangeReview.tsx';
27
32
  export { ProjectProblems, serviceProblems, countsOf } from './project-problems.ts';
28
33
  export type { ProblemFile, ProblemRow, ProblemReport, ProblemSource } from './project-problems.ts';
29
34
  export { applyWorkspaceEdit, supportedResourceOperations } from './workspace-edit.ts';
30
- export type { ProjectFiles, StagedFile, WorkspaceEditHost } from './workspace-edit.ts';
35
+ export type { WorkspaceEditHost } from './workspace-edit.ts';
36
+ export type { ProjectFiles, StagedFile } from './host-types.ts';
31
37
  export { useProblemCounts } from './use-problem-counts.ts';
32
- export type { ProblemCounts } from './diagnostics.ts';
38
+ export type { ProblemCounts } from './diagnostics-model.ts';
33
39
  export type { BlameSource, CodeVisionSettings } from './code-vision.ts';
34
40
  export type { HoverSettings } from './hover.ts';
35
- export type { PopupState, PopupStore, HoverInfo, HoverView, CompletionView, CompletionDocs, CompletionRow, SignatureView, RenameView, RenameFileView, PeekView, CallHierarchyView, PickView, PickGroup, PickRow, PickPreview, SymbolsView, MenuView, AuthorsView, WrapView } from './popups.ts';
41
+ export { Popups, PopupSlot, type PopupViews } from './popups.ts';
42
+ export type { HoverInfo, HoverView, CompletionView, CompletionRow, SignatureView, RenameView, RenameFileView, PeekView, CallHierarchyView, PickView, PickGroup, PickRow, PickPreview, SymbolsView, MenuView, AuthorsView, WrapView } from './popups.ts';
43
+ export type { CompletionDocs } from './completion-model.ts';
36
44
  export { type MarkupFeature } from './markup.ts';
37
45
  export { type SurroundFeature } from './surround.ts';
38
46
  export type { MarkupSettings } from './markup.ts';
@@ -44,16 +52,18 @@ export type { Place } from './navigation-history.ts';
44
52
  export { EditLocations, type EditPlace } from './edit-locations.ts';
45
53
  export { ClipboardHistory, type ClipboardEntry, type ClipboardHistoryOptions } from './clipboard-history.ts';
46
54
  export { type PasteHistoryFeature } from './paste-history.ts';
47
- export { TemplateRegistry, checkTemplate, BUILT_IN_LIVE_TEMPLATES, BUILT_IN_POSTFIX_TEMPLATES, type TemplatesFeature, type LiveTemplate, type PostfixTemplate, type LiveTemplateDraft, type TemplateLanguage, type TemplatePlace, type TemplateSettings, type TemplateRegistryOptions, type TemplateUpdate } from './templates.ts';
55
+ export { type TemplatesFeature } from './live-templates.ts';
56
+ export { TemplateRegistry, checkTemplate, BUILT_IN_LIVE_TEMPLATES, BUILT_IN_POSTFIX_TEMPLATES, type LiveTemplateDraft, type TemplateSettings, type TemplateRegistryOptions, type TemplateUpdate } from './templates.ts';
57
+ export { type LiveTemplate, type PostfixTemplate, type TemplateLanguage, type TemplatePlace } from './template-types.ts';
48
58
  export { openingPlace, viewStates, followViewStates, viewStateKey, forgetMovesFrom } from './view-state.ts';
49
59
  export type { ViewState, RevealLineRequest } from './view-state.ts';
50
- export { lspLanguageIdOf, shikiLanguageOf, shikiLanguageOfPath } from './language-ids.ts';
60
+ export { shikiLanguageOf, shikiLanguageOfPath } from './language-ids.ts';
51
61
  export { AttributionCard } from './AttributionCard.tsx';
52
62
  export type { AttributionCardProps } from './AttributionCard.tsx';
53
63
  export { ReviewGroup, joinReviewGroup } from './review-group.ts';
54
64
  export type { ReviewMember } from './review-group.ts';
55
65
  export { DiffView } from './DiffView.tsx';
56
- export type { DiffSource, DiffViewProps } from './DiffView.tsx';
66
+ export type { DiffSource, DiffViewProps } from './diff-view-props.ts';
57
67
  export type { DiffLimits } from './diff-expansion.ts';
58
68
  export { diffSyntaxDocument } from './diff-syntax.ts';
59
69
  export type { DiffSourceSide, DiffSourceTokens, DiffSyntaxSources } from './diff-syntax.ts';
package/dist/index.js CHANGED
@@ -12,13 +12,14 @@ export {} from './rendered-docs.js';
12
12
  export {} from './document-links.js';
13
13
  export {} from './document-colors.js';
14
14
  export {} from './linked-editing.js';
15
- export {} from './inline-completion.js';
15
+ export { firstWord } from './inline-completion.js';
16
16
  export { EditorRenderingProvider } from "./rendering.js";
17
17
  export { FindReplace } from "./FindReplace.js";
18
18
  export { ChangeReview } from "./ChangeReview.js";
19
19
  export { ProjectProblems, serviceProblems, countsOf } from './project-problems.js';
20
20
  export { applyWorkspaceEdit, supportedResourceOperations } from './workspace-edit.js';
21
21
  export { useProblemCounts } from './use-problem-counts.js';
22
+ export { Popups, PopupSlot } from './popups.js';
22
23
  export {} from './markup.js';
23
24
  export {} from './surround.js';
24
25
  export { RowHost, LineActionHost } from './row-host.js';
@@ -27,9 +28,11 @@ export {} from './navigation-history.js';
27
28
  export { EditLocations } from './edit-locations.js';
28
29
  export { ClipboardHistory } from './clipboard-history.js';
29
30
  export {} from './paste-history.js';
31
+ export {} from './live-templates.js';
30
32
  export { TemplateRegistry, checkTemplate, BUILT_IN_LIVE_TEMPLATES, BUILT_IN_POSTFIX_TEMPLATES } from './templates.js';
33
+ export {} from './template-types.js';
31
34
  export { openingPlace, viewStates, followViewStates, viewStateKey, forgetMovesFrom } from './view-state.js';
32
- export { lspLanguageIdOf, shikiLanguageOf, shikiLanguageOfPath } from './language-ids.js';
35
+ export { shikiLanguageOf, shikiLanguageOfPath } from './language-ids.js';
33
36
  export { AttributionCard } from "./AttributionCard.js";
34
37
  export { ReviewGroup, joinReviewGroup } from './review-group.js';
35
38
  export { DiffView } from "./DiffView.js";
@@ -1,31 +1,22 @@
1
- import type { Editor, EditorInlayClick, EditorInlayHint, EditorPosition, EditorRange } from '@adecore/editor';
2
- import type { Command, InlayHint, InlayHintLabelPart, Location, MarkupContent, TextEdit } from '@adecore/lsp';
3
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { EditorPosition, EditorRange } from '@adecore/editor';
2
+ import type { InlayHint, InlayHintLabelPart } from '@adecore/lsp';
4
3
  import { type HoverText } from './hover-content.ts';
4
+ import type { LanguageContext } from './language-context.ts';
5
5
  import { type Timers } from './timers.ts';
6
- export declare function hintLabelOf(hint: InlayHint): string;
7
- export declare function drawableHints(hints: readonly InlayHint[]): InlayHint[];
8
- export declare function editorHintOf(hint: InlayHint, id: string): EditorInlayHint;
9
6
  export declare function withMargin(visible: EditorRange, endOfDocument: EditorPosition, endOfLine: (line: number) => EditorPosition): EditorRange;
10
7
  export declare function covers(asked: EditorRange, visible: EditorRange): boolean;
11
- export declare function tooltipTextOf(tooltip: string | MarkupContent | undefined): HoverText | null;
12
8
  export declare function partOf(hint: InlayHint, index: number | null): InlayHintLabelPart | null;
13
9
  export declare function tooltipOf(hint: InlayHint, index: number | null): HoverText | null;
14
- export declare function lacksInfo(hint: InlayHint, index: number | null): boolean;
15
- export declare function editsFit(editor: Editor, edits: readonly TextEdit[]): boolean;
16
- type Action = {
17
- readonly kind: 'go';
18
- readonly location: Location;
19
- } | {
20
- readonly kind: 'run';
21
- readonly command: Command;
22
- } | {
23
- readonly kind: 'insert';
24
- readonly edits: TextEdit[];
25
- };
26
- export declare function actionOf(hint: InlayHint, click: Pick<EditorInlayClick, 'part' | 'mod' | 'clicks'>): Action | null;
10
+ interface InlayHintsPeers {
11
+ readonly hover: {
12
+ hide(): void;
13
+ release(): void;
14
+ showText(position: EditorPosition, text: HoverText): void;
15
+ };
16
+ }
27
17
  export declare class InlayHintsFeature {
28
18
  private readonly language;
19
+ private readonly peers;
29
20
  private readonly timers;
30
21
  private readonly refresher;
31
22
  private asked;
@@ -39,7 +30,7 @@ export declare class InlayHintsFeature {
39
30
  private commandTimer;
40
31
  private pressCount;
41
32
  private request;
42
- constructor(language: EditorLanguage, timers?: Timers);
33
+ constructor(language: LanguageContext, peers: InlayHintsPeers, timers?: Timers);
43
34
  setModHeld(held: boolean): void;
44
35
  showTooltipAt(position: EditorPosition): Promise<boolean>;
45
36
  private install;