@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
@@ -6,8 +6,9 @@ import { NavigationHistory } from './navigation-history.js';
6
6
  import { PANEL_BODY_HEIGHT } from './panel-size.js';
7
7
  import { relativeTo } from './paths.js';
8
8
  import { ProjectProblems, serviceProblems } from './project-problems.js';
9
- import { disposeSnippetTransforms } from './snippet-transform-queue.js';
9
+ import { SnippetTransforms } from './snippet-transform-queue.js';
10
10
  import { TemplateRegistry } from './templates.js';
11
+ import { realTimers } from './timers.js';
11
12
  import { applyWorkspaceEdit } from './workspace-edit.js';
12
13
  const UNSERVED = unservedLanguageService();
13
14
  /* Sends one editor's edits to the document, holding them until the document is open. */
@@ -95,6 +96,7 @@ export class ProjectLanguage {
95
96
  templates;
96
97
  holders = new Map();
97
98
  files;
99
+ snippetQueue = null;
98
100
  /* The body height of the peek and call hierarchy panels, shared by the editors of the project. */
99
101
  panelBodyHeight;
100
102
  panelListeners = new Set();
@@ -102,23 +104,32 @@ export class ProjectLanguage {
102
104
  lastPlace = null;
103
105
  disposed = false;
104
106
  subscriptions;
107
+ disposers = [];
105
108
  /* The result id the server gave each document in its last workspace report, which the next asks with. */
106
109
  workspaceResults = new Map();
107
110
  constructor(service, host = {}) {
108
- this.service = service;
109
111
  this.host = host;
110
112
  this.i18n = host.i18n ?? i18next;
111
113
  this.folder = host.folder ?? '';
112
114
  this.files = host.files ?? null;
115
+ this.service = typeof service === 'function' ? service(this) : service;
113
116
  this.edits = new EditLocations(host.editHistoryLimit);
114
117
  this.clipboard = host.clipboard ?? new ClipboardHistory();
115
118
  this.templates = host.templates ?? new TemplateRegistry();
116
119
  this.panelBodyHeight = host.panelBodyHeight ?? PANEL_BODY_HEIGHT;
117
- this.problems = new ProjectProblems(host.problemSource ?? serviceProblems(service, uri => this.pathOfLocation(uri) ?? uri));
118
- const shows = service.onShowDocument?.(params => this.showDocument(params));
119
- const messages = host.onServerMessage === undefined ? undefined : service.onServerMessage?.(message => host.onServerMessage(message));
120
+ this.problems = new ProjectProblems(host.problemSource ?? serviceProblems(this.service, uri => this.pathOfLocation(uri) ?? uri));
121
+ const shows = this.service.onShowDocument?.(params => this.showDocument(params));
122
+ const messages = host.onServerMessage === undefined ? undefined : this.service.onServerMessage?.(message => host.onServerMessage(message));
120
123
  this.subscriptions = [shows, messages].flatMap(subscription => subscription === undefined ? [] : [subscription]);
121
124
  }
125
+ /* Runs `dispose` when the project is disposed, after the editors' documents are closed. */
126
+ onDispose(dispose) {
127
+ this.disposers.push(dispose);
128
+ }
129
+ /* The text of the editor that holds a document first, or undefined when no editor holds it. */
130
+ openTextOf(uri) {
131
+ return this.holders.get(uri)?.editors[0]?.getText();
132
+ }
122
133
  /* Open panels of other editors of the project follow a resize. */
123
134
  onPanelBodyChange(listener) {
124
135
  this.panelListeners.add(listener);
@@ -159,7 +170,6 @@ export class ProjectLanguage {
159
170
  willCreateFiles(targets) {
160
171
  return this.service.willCreateFiles?.(filesOf(targets)) ?? Promise.resolve(null);
161
172
  }
162
- /* Tells the servers that files were made, once they are. */
163
173
  didCreateFiles(targets) {
164
174
  return this.service.didCreateFiles?.(filesOf(targets)) ?? Promise.resolve();
165
175
  }
@@ -167,7 +177,6 @@ export class ProjectLanguage {
167
177
  willDeleteFiles(targets) {
168
178
  return this.service.willDeleteFiles?.(filesOf(targets)) ?? Promise.resolve(null);
169
179
  }
170
- /* Tells the servers that files were deleted, once they are. */
171
180
  didDeleteFiles(targets) {
172
181
  const files = filesOf(targets);
173
182
  this.edits.forget(uri => files.some(file => file.directory ? uri.startsWith(`${file.uri}/`) : uri === file.uri));
@@ -178,7 +187,7 @@ export class ProjectLanguage {
178
187
  * text file. A document of a scheme a server owns, such as a decompiled class, is read from that server.
179
188
  */
180
189
  async readText(uri) {
181
- const open = this.holders.get(uri)?.editors[0]?.getText();
190
+ const open = this.openTextOf(uri);
182
191
  if (open !== undefined) {
183
192
  return open;
184
193
  }
@@ -193,6 +202,9 @@ export class ProjectLanguage {
193
202
  * offers workspace diagnostics. A file the server reports as unchanged keeps what it had. False when no server offers them.
194
203
  */
195
204
  async pullWorkspaceProblems(uri, options = {}) {
205
+ if (this.host.pullWorkspaceProblems !== undefined) {
206
+ return this.host.pullWorkspaceProblems(uri, options);
207
+ }
196
208
  const {
197
209
  service
198
210
  } = this;
@@ -278,6 +290,22 @@ export class ProjectLanguage {
278
290
  this.pendingCaret = null;
279
291
  return pending.position;
280
292
  }
293
+ /* A lease on the project's one snippet transform queue, which runs one job at a time for every editor; null when the host brought no worker. The queue keeps the clock of the first editor that asked. */
294
+ acquireSnippetTransforms(timers = realTimers) {
295
+ const factory = this.host.snippetTransformWorker;
296
+ if (factory === undefined) {
297
+ return null;
298
+ }
299
+ if (this.snippetQueue === null) {
300
+ const queue = new SnippetTransforms(factory, timers, () => {
301
+ if (this.snippetQueue === queue) {
302
+ this.snippetQueue = null;
303
+ }
304
+ });
305
+ this.snippetQueue = queue;
306
+ }
307
+ return this.snippetQueue.acquire();
308
+ }
281
309
  /* Whether the editor is the first to hold the document, the one whose changes stand for the document's. */
282
310
  holdsFirst(uri, editor) {
283
311
  return this.holders.get(uri)?.editors[0] === editor;
@@ -364,7 +392,7 @@ export class ProjectLanguage {
364
392
  for (const subscription of this.subscriptions) {
365
393
  subscription.dispose();
366
394
  }
367
- disposeSnippetTransforms(this);
395
+ this.snippetQueue?.dispose();
368
396
  for (const [uri, holder] of this.holders) {
369
397
  if (holder.sync === null) {
370
398
  continue;
@@ -374,5 +402,8 @@ export class ProjectLanguage {
374
402
  }
375
403
  this.holders.clear();
376
404
  this.problems.dispose();
405
+ for (const dispose of this.disposers.splice(0).reverse()) {
406
+ dispose();
407
+ }
377
408
  }
378
409
  }
@@ -1,5 +1,5 @@
1
1
  import type { Diagnostic, LanguageService } from '@adecore/lsp';
2
- import type { ProblemCounts } from './diagnostics.ts';
2
+ import type { ProblemCounts } from './diagnostics-model.ts';
3
3
  export interface ProblemRow {
4
4
  readonly diagnostic: Diagnostic;
5
5
  readonly server: string;
@@ -14,6 +14,12 @@ export interface ProblemReport {
14
14
  readonly server: string;
15
15
  readonly diagnostics: readonly Diagnostic[];
16
16
  }
17
+ export interface ProblemsHost {
18
+ readonly problemSource?: ProblemSource;
19
+ pullWorkspaceProblems?(uri: string, options: {
20
+ readonly signal?: AbortSignal;
21
+ }): Promise<boolean>;
22
+ }
17
23
  export type ProblemSource = (listener: (report: ProblemReport) => void) => () => void;
18
24
  export declare function serviceProblems(service: LanguageService, pathOf?: (uri: string) => string): ProblemSource;
19
25
  export declare class ProjectProblems {
@@ -1,4 +1,5 @@
1
- import { comparePositions, problemCountsOf, severityOf } from './diagnostics-model.js';
1
+ import { problemCountsOf, severityOf } from './diagnostics-model.js';
2
+ import { comparePositions } from './positions.js';
2
3
  const SEVERITY_ORDER = {
3
4
  error: 0,
4
5
  warning: 1,
@@ -1,5 +1,5 @@
1
1
  import { isIdentifierCharacter } from './completion-model.js';
2
- import { rangeHolds } from './diagnostics-model.js';
2
+ import { rangeHolds } from './positions.js';
3
3
  import { textEntriesOf } from './workspace-edit.js';
4
4
  /* The identifier the caret is in or touches; null where there is none. */
5
5
  export function wordRangeAt(lineText, position) {
package/dist/rename.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { LanguageContext } from './language-context.ts';
2
2
  export declare class RenameFeature {
3
3
  private readonly language;
4
4
  private session;
5
- constructor(language: EditorLanguage);
5
+ constructor(language: LanguageContext);
6
6
  get isOpen(): boolean;
7
7
  start(): Promise<void>;
8
8
  submit(name: string, preview: boolean): Promise<void>;
package/dist/rename.js CHANGED
@@ -139,7 +139,6 @@ export class RenameFeature {
139
139
  }
140
140
  }
141
141
  }
142
- /* Applies the edit the preview showed. */
143
142
  async confirm() {
144
143
  const session = this.session;
145
144
  if (session?.edit) {
@@ -154,7 +153,7 @@ export class RenameFeature {
154
153
  }
155
154
  /* The name was changed, which answers the failure under it. */
156
155
  edited() {
157
- if (this.language.popups.getState().rename?.error != null) {
156
+ if (this.language.popups.slot('rename').get()?.error != null) {
158
157
  this.publish({
159
158
  error: null
160
159
  });
@@ -193,9 +192,7 @@ export class RenameFeature {
193
192
  editor,
194
193
  popups
195
194
  } = this.language;
196
- popups.setState({
197
- rename: null
198
- });
195
+ popups.slot('rename').set(null);
199
196
  editor.setHighlights([]);
200
197
  editor.focus();
201
198
  }
@@ -325,23 +322,21 @@ export class RenameFeature {
325
322
  const {
326
323
  popups
327
324
  } = this.language;
328
- const current = popups.getState().rename;
329
- popups.setState({
330
- rename: {
331
- phase: 'input',
332
- range: session.target.range,
333
- original: session.original,
334
- placeholder: session.target.placeholder,
335
- occurrences: null,
336
- busy: false,
337
- error: null,
338
- name: session.target.placeholder,
339
- files: [],
340
- operations: [],
341
- suggestions: [],
342
- ...current,
343
- ...patch
344
- }
325
+ const current = popups.slot('rename').get();
326
+ popups.slot('rename').set({
327
+ phase: 'input',
328
+ range: session.target.range,
329
+ original: session.original,
330
+ placeholder: session.target.placeholder,
331
+ occurrences: null,
332
+ busy: false,
333
+ error: null,
334
+ name: session.target.placeholder,
335
+ files: [],
336
+ operations: [],
337
+ suggestions: [],
338
+ ...current,
339
+ ...patch
345
340
  });
346
341
  }
347
342
  tell(kind, title) {
@@ -1,6 +1,7 @@
1
1
  import { type DocComment } from '@adecore/editor';
2
2
  import { type ParsedDocComment } from './doc-comment-model.ts';
3
- import type { EditorLanguage } from './editor-language.ts';
3
+ import type { LanguageContext } from './language-context.ts';
4
+ import type { NavigationFeature } from './navigation.ts';
4
5
  import { type Timers } from './timers.ts';
5
6
  export interface RenderedDocsSettings {
6
7
  readonly renderDocComments: boolean;
@@ -12,8 +13,12 @@ export interface RenderedDocEntry {
12
13
  readonly parsed: ParsedDocComment;
13
14
  readonly container: HTMLElement;
14
15
  }
16
+ interface RenderedDocsPeers {
17
+ readonly navigation: Pick<NavigationFeature, 'goToName'>;
18
+ }
15
19
  export declare class RenderedDocsFeature {
16
20
  private readonly language;
21
+ private readonly peers;
17
22
  private readonly timers;
18
23
  private settings;
19
24
  private enabled;
@@ -33,7 +38,7 @@ export declare class RenderedDocsFeature {
33
38
  private marked;
34
39
  private stale;
35
40
  private disposed;
36
- constructor(language: EditorLanguage, timers?: Timers);
41
+ constructor(language: LanguageContext, peers: RenderedDocsPeers, timers?: Timers);
37
42
  configure(settings: RenderedDocsSettings): void;
38
43
  get all(): readonly DocComment[];
39
44
  isRendered(comment: DocComment): boolean;
@@ -65,3 +70,4 @@ export declare class RenderedDocsFeature {
65
70
  private sweep;
66
71
  private bump;
67
72
  }
73
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { findDocComments } from '@adecore/editor';
2
- import { comparePositions } from './diagnostics-model.js';
3
2
  import { parseDocComment } from './doc-comment-model.js';
4
3
  import { KEY_PRIORITY } from './key-priority.js';
5
4
  import { lineTextOf } from './line-text.js';
5
+ import { comparePositions } from './positions.js';
6
6
  import { isShortcut } from './shortcut-keys.js';
7
7
  import { realTimers } from './timers.js';
8
8
  const OWNER = 'rendered-docs';
@@ -48,6 +48,7 @@ function samePlace(range, position) {
48
48
  */
49
49
  export class RenderedDocsFeature {
50
50
  language;
51
+ peers;
51
52
  timers;
52
53
  settings = {
53
54
  renderDocComments: false
@@ -71,8 +72,9 @@ export class RenderedDocsFeature {
71
72
  /* The comments are from before the last edit, so nothing is decided from them until they are read again. */
72
73
  stale = false;
73
74
  disposed = false;
74
- constructor(language, timers = realTimers) {
75
+ constructor(language, peers, timers = realTimers) {
75
76
  this.language = language;
77
+ this.peers = peers;
76
78
  this.timers = timers;
77
79
  const {
78
80
  editor
@@ -196,11 +198,10 @@ export class RenderedDocsFeature {
196
198
  } = this.language;
197
199
  return this.language.service.supports('workspace/symbol', uri);
198
200
  }
199
- /* Goes to what a link in a comment names. */
200
201
  follow(name, comment) {
201
202
  const member = name.split(/::|[#.\\]/).filter(part => part !== '');
202
203
  const target = (member.at(-1) ?? name).replace(/\(\)$/, '');
203
- void this.language.navigation.goToName(target, startOf(comment), null);
204
+ void this.peers.navigation.goToName(target, startOf(comment), null);
204
205
  }
205
206
  /* By place in the document, so a row keeps its element when an edit above it moves its lines. */
206
207
  idOf(comment) {
@@ -1,7 +1,7 @@
1
1
  import type { EditorRange } from '@adecore/editor';
2
2
  import type { SelectionRange } from '@adecore/lsp';
3
- import type { EditorLanguage } from './editor-language.ts';
3
+ import type { LanguageContext } from './language-context.ts';
4
4
  export declare function selectionChainOf(selection: SelectionRange): EditorRange[];
5
5
  export declare class SelectionRangesFeature {
6
- constructor(language: EditorLanguage);
6
+ constructor(language: LanguageContext);
7
7
  }
@@ -1,7 +1,5 @@
1
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { LanguageContext } from './language-context.ts';
2
2
  import { type Timers } from './timers.ts';
3
- export declare const DEFAULT_RANGE_LINES = 5000;
4
- export declare const DEFAULT_RANGE_CHARACTERS = 500000;
5
3
  export interface SemanticTokensOptions {
6
4
  rangeLines?: number;
7
5
  rangeCharacters?: number;
@@ -17,7 +15,7 @@ export declare class SemanticTokensFeature {
17
15
  private covered;
18
16
  private drawn;
19
17
  private epoch;
20
- constructor(language: EditorLanguage, timers?: Timers, options?: SemanticTokensOptions);
18
+ constructor(language: LanguageContext, timers?: Timers, options?: SemanticTokensOptions);
21
19
  private forget;
22
20
  private legend;
23
21
  private isLarge;
@@ -11,8 +11,8 @@ const RANGE = 'textDocument/semanticTokens/range';
11
11
  const PAUSE_MS = 200;
12
12
  const SCROLL_PAUSE_MS = 100;
13
13
  /* A document with more lines or characters than this is first asked for what is in view, when the server answers ranges. */
14
- export const DEFAULT_RANGE_LINES = 5000;
15
- export const DEFAULT_RANGE_CHARACTERS = 500_000;
14
+ const DEFAULT_RANGE_LINES = 5000;
15
+ const DEFAULT_RANGE_CHARACTERS = 500_000;
16
16
  /*
17
17
  * Colors from what the language servers know, over the grammar's guess. It asks after a pause in typing
18
18
  * and when a server's offer changed, and keeps drawing the last answer meanwhile so the colors never blink out.
@@ -1,6 +1,6 @@
1
1
  import type { KeyChord } from '@adecore/editor';
2
2
  import { type Keymap } from '@adecore/editor/keymap';
3
- export interface LanguageShortcut extends KeyChord {
3
+ interface LanguageShortcut extends KeyChord {
4
4
  readonly apple: boolean;
5
5
  }
6
6
  export declare function shortcutsOf(keymap: Keymap, apple: boolean): {
@@ -124,3 +124,4 @@ export declare function shortcutsOf(keymap: Keymap, apple: boolean): {
124
124
  wrapWithAbbreviation: LanguageShortcut | null;
125
125
  };
126
126
  export declare function isShortcut(target: LanguageShortcut | null, event: KeyboardEvent): boolean;
127
+ export {};
@@ -1,4 +1,4 @@
1
- import type { EditorLanguage } from './editor-language.ts';
1
+ import type { LanguageContext } from './language-context.ts';
2
2
  import { type Timers } from './timers.ts';
3
3
  export declare class SignatureFeature {
4
4
  private readonly language;
@@ -8,7 +8,7 @@ export declare class SignatureFeature {
8
8
  private controller;
9
9
  private help;
10
10
  private anchor;
11
- constructor(language: EditorLanguage, timers?: Timers);
11
+ constructor(language: LanguageContext, timers?: Timers);
12
12
  get isOpen(): boolean;
13
13
  invoke(): void;
14
14
  trigger(): void;
package/dist/signature.js CHANGED
@@ -24,7 +24,7 @@ export class SignatureFeature {
24
24
  editor
25
25
  } = language;
26
26
  const offs = [editor.onTextChange(change => this.edited(change)), editor.onCaret(() => this.retrigger()), editor.onBlur(() => this.close()), language.onKey(event => {
27
- if (event.key === 'Escape' && this.isOpen && this.language.popups.getState().callHierarchy === null) {
27
+ if (event.key === 'Escape' && this.isOpen && this.language.popups.slot('callHierarchy').get() === null) {
28
28
  this.close();
29
29
  return true;
30
30
  }
@@ -45,7 +45,7 @@ export class SignatureFeature {
45
45
  });
46
46
  }
47
47
  get isOpen() {
48
- return this.language.popups.getState().signature !== null;
48
+ return this.language.popups.slot('signature').get() !== null;
49
49
  }
50
50
  /* Asks for the parameters of the call at the caret, as its key does. */
51
51
  invoke() {
@@ -80,11 +80,9 @@ export class SignatureFeature {
80
80
  return false;
81
81
  }
82
82
  this.help = next;
83
- this.language.popups.setState({
84
- signature: {
85
- anchor: this.anchor,
86
- model
87
- }
83
+ this.language.popups.slot('signature').set({
84
+ anchor: this.anchor,
85
+ model
88
86
  });
89
87
  return true;
90
88
  }
@@ -95,9 +93,7 @@ export class SignatureFeature {
95
93
  this.help = null;
96
94
  this.anchor = null;
97
95
  if (this.isOpen) {
98
- this.language.popups.setState({
99
- signature: null
100
- });
96
+ this.language.popups.slot('signature').set(null);
101
97
  }
102
98
  }
103
99
  options() {
@@ -186,11 +182,9 @@ export class SignatureFeature {
186
182
  }
187
183
  this.help = help;
188
184
  this.anchor ??= caret;
189
- this.language.popups.setState({
190
- signature: {
191
- anchor: this.anchor,
192
- model
193
- }
185
+ this.language.popups.slot('signature').set({
186
+ anchor: this.anchor,
187
+ model
194
188
  });
195
189
  }
196
190
  }
@@ -1,4 +1,4 @@
1
- import { comparePositions, shiftPosition } from './diagnostics-model.js';
1
+ import { comparePositions, shiftPosition } from './positions.js';
2
2
  /* Each distinct job once, so a transform that several ranges share is computed once; `slotOf` is its index in `jobs`. */
3
3
  export function jobTable() {
4
4
  const jobs = [];
@@ -1,5 +1,7 @@
1
1
  import type { Editor, EditorRange } from '@adecore/editor';
2
- import type { EditorLanguage } from './editor-language.ts';
2
+ import type { LanguageContext } from './language-context.ts';
3
+ import { type SnippetFeature } from './snippet-session.ts';
4
+ export type InsertingSnippets = Pick<SnippetFeature, 'applyEdits' | 'beginInstances' | 'isActive' | 'token' | 'transformVariables'>;
3
5
  export interface SnippetPlacement {
4
6
  readonly range: EditorRange;
5
7
  readonly selectedText?: string;
@@ -7,4 +9,4 @@ export interface SnippetPlacement {
7
9
  export declare function bodyWithIndentUnit(body: string, unit: string): string;
8
10
  export declare function indentUnitOf(editor: Editor): string;
9
11
  export declare function dedentLines(text: string, base?: string): string;
10
- export declare function insertSnippet(language: EditorLanguage, source: string, placements: readonly SnippetPlacement[], extra?: (name: string) => string | undefined): Promise<boolean>;
12
+ export declare function insertSnippet(language: LanguageContext, snippets: InsertingSnippets, source: string, placements: readonly SnippetPlacement[], extra?: (name: string) => string | undefined): Promise<boolean>;
@@ -1,6 +1,6 @@
1
1
  import { fileUriToPath } from '@adecore/lsp';
2
- import { comparePositions, shiftPosition } from './diagnostics-model.js';
3
2
  import { lineTextOf, textBeforeOf } from './line-text.js';
3
+ import { comparePositions, shiftPosition } from './positions.js';
4
4
  import { wordRangeAt } from './rename-model.js';
5
5
  import { jobTable } from './snippet-field-transforms.js';
6
6
  import { indentSnippet } from './snippet-indent.js';
@@ -15,11 +15,9 @@ const MAX_CHARACTERS = 2_000_000;
15
15
  const MAX_RANGES = 1_000;
16
16
  const TOAST_ID = 'language-completion';
17
17
  class LimitError extends Error {}
18
- /* Each line's leading tabs become the editor's own indentation unit. */
19
18
  export function bodyWithIndentUnit(body, unit) {
20
19
  return unit === '\t' ? body : body.replace(/^\t+/gm, tabs => unit.repeat(tabs.length));
21
20
  }
22
- /* One level of the editor's indentation: spaces for a tab size, or a tab. */
23
21
  export function indentUnitOf(editor) {
24
22
  const {
25
23
  tabSize,
@@ -42,12 +40,11 @@ function sizeOf(parsed) {
42
40
  * variables are resolved for each placement (`extra` first, then the host's and the built-in ones), the lines are indented
43
41
  * to the text before the placement, and a running session takes the insertion as a nested one. False when nothing was inserted.
44
42
  */
45
- export async function insertSnippet(language, source, placements, extra) {
43
+ export async function insertSnippet(language, snippets, source, placements, extra) {
46
44
  const {
47
45
  editor,
48
46
  project,
49
- uri,
50
- snippets
47
+ uri
51
48
  } = language;
52
49
  if (placements.length === 0 || editor.isReadOnly?.() === true) {
53
50
  return false;
@@ -102,7 +99,7 @@ export async function insertSnippet(language, source, placements, extra) {
102
99
  throw new LimitError();
103
100
  }
104
101
  }
105
- await transformVariables(language, template, drafts, current);
102
+ await transformVariables(language, snippets, template, drafts, current);
106
103
  if (!current()) {
107
104
  return false;
108
105
  }
@@ -119,7 +116,7 @@ export async function insertSnippet(language, source, placements, extra) {
119
116
  return false;
120
117
  }
121
118
  off();
122
- place(language, drafts, starts, continuing && snippets.isActive && snippets.token === token);
119
+ place(language, snippets, drafts, starts, continuing && snippets.isActive && snippets.token === token);
123
120
  editor.focus();
124
121
  return true;
125
122
  } catch (error) {
@@ -153,11 +150,10 @@ export async function insertSnippet(language, source, placements, extra) {
153
150
  }
154
151
  }
155
152
  /* Runs the transforms of variables through the worker, once for all placements, and renders them again with the answers. */
156
- async function transformVariables(language, template, drafts, current) {
153
+ async function transformVariables(language, snippets, template, drafts, current) {
157
154
  const {
158
155
  editor,
159
- project,
160
- snippets
156
+ project
161
157
  } = language;
162
158
  const {
163
159
  jobs,
@@ -189,11 +185,9 @@ async function transformVariables(language, template, drafts, current) {
189
185
  draft.parsed = parsed;
190
186
  });
191
187
  }
192
- /* Starts the session on the tab stops, or puts the caret after the primary insertion when there are none. */
193
- function place(language, drafts, starts, nested) {
188
+ function place(language, snippets, drafts, starts, nested) {
194
189
  const {
195
- editor,
196
- snippets
190
+ editor
197
191
  } = language;
198
192
  const primary = drafts.at(-1).parsed;
199
193
  if (primary.stops.length > 0) {
@@ -1,18 +1,23 @@
1
1
  import type { EditorApplyEditsOptions, EditorContentChange, EditorPosition, EditorRange } from '@adecore/editor';
2
- import type { EditorLanguage } from './editor-language.ts';
2
+ import type { LanguageContext } from './language-context.ts';
3
+ import type { PickFeature } from './pick.ts';
3
4
  import { type SnippetTransformJob } from './snippet-transform-protocol.ts';
4
5
  import type { SnippetField, SnippetStop } from './snippet.ts';
5
6
  import { type Timers } from './timers.ts';
6
7
  export declare function positionInInsertion(start: EditorPosition, text: string, offset: number): EditorPosition;
7
- export interface SnippetInsertion {
8
+ interface SnippetInsertion {
8
9
  readonly start: EditorPosition;
9
10
  readonly text: string;
10
11
  readonly stops: readonly SnippetStop[];
11
12
  readonly fields?: readonly SnippetField[];
12
13
  }
13
- type SnippetHost = Pick<EditorLanguage, 'editor' | 'onDispose'> & Partial<Pick<EditorLanguage, 'popups' | 'pick' | 'project' | 'onKey'>>;
14
+ type SnippetHost = Pick<LanguageContext, 'editor' | 'onDispose' | 'popups' | 'onKey'> & Partial<Pick<LanguageContext, 'project'>>;
15
+ interface SnippetPeers {
16
+ readonly pick: Pick<PickFeature, 'close' | 'open'>;
17
+ }
14
18
  export declare class SnippetFeature {
15
19
  private readonly language;
20
+ private readonly peers;
16
21
  private frames;
17
22
  private placed;
18
23
  private visiting;
@@ -24,7 +29,7 @@ export declare class SnippetFeature {
24
29
  private readonly fieldTransforms;
25
30
  private exitGeneration;
26
31
  private detached;
27
- constructor(language: SnippetHost, timers?: Timers);
32
+ constructor(language: SnippetHost, peers: SnippetPeers, timers?: Timers);
28
33
  transformVariables(jobs: readonly SnippetTransformJob[], current?: () => boolean): Promise<readonly string[] | null>;
29
34
  get hasPendingTransforms(): boolean;
30
35
  settleTransforms(current: () => boolean, edited?: (changes: readonly EditorContentChange[], map: (range: EditorRange) => EditorRange) => void): Promise<boolean>;