@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.
- package/README.md +2 -2
- package/dist/AnchoredPopup.d.ts +2 -1
- package/dist/CompletionPopup.js +0 -2
- package/dist/DiffView.d.ts +1 -28
- package/dist/EditorView.js +0 -1
- package/dist/HoverSections.d.ts +1 -8
- package/dist/HoverSections.js +2 -2
- package/dist/LanguagePopups.js +30 -14
- package/dist/PanelResizeHandle.js +0 -1
- package/dist/PeekPanel.js +0 -1
- package/dist/PickPopup.js +0 -1
- package/dist/RenderedDocs.js +0 -2
- package/dist/SplitDiffView.d.ts +1 -1
- package/dist/SymbolPicker.js +0 -1
- package/dist/call-hierarchy-model.js +0 -4
- package/dist/call-hierarchy.d.ts +9 -2
- package/dist/call-hierarchy.js +51 -67
- package/dist/clipboard-history.d.ts +3 -0
- package/dist/clipboard-history.js +0 -1
- package/dist/code-actions-model.js +1 -1
- package/dist/code-actions.d.ts +14 -2
- package/dist/code-actions.js +14 -9
- package/dist/code-authors.js +4 -12
- package/dist/code-vision-model.d.ts +0 -1
- package/dist/code-vision-model.js +1 -2
- package/dist/code-vision.d.ts +11 -3
- package/dist/code-vision.js +13 -18
- package/dist/completion-call.d.ts +1 -1
- package/dist/completion-call.js +2 -1
- package/dist/completion-model.d.ts +5 -4
- package/dist/completion-model.js +4 -4
- package/dist/completion.d.ts +13 -4
- package/dist/completion.js +19 -18
- package/dist/context-menu-rows.d.ts +2 -1
- package/dist/context-menu.d.ts +9 -3
- package/dist/context-menu.js +17 -19
- package/dist/definition-link.d.ts +8 -2
- package/dist/definition-link.js +4 -2
- package/dist/diagnostics-model.d.ts +6 -8
- package/dist/diagnostics-model.js +1 -54
- package/dist/diagnostics.d.ts +9 -7
- package/dist/diagnostics.js +6 -4
- package/dist/diff-view-props.d.ts +28 -0
- package/dist/diff-view-props.js +1 -0
- package/dist/doc-comment-model.js +0 -2
- package/dist/document-colors.d.ts +9 -4
- package/dist/document-colors.js +7 -4
- package/dist/document-links.d.ts +2 -3
- package/dist/document-links.js +2 -3
- package/dist/document-query.d.ts +2 -2
- package/dist/edit-locations.js +4 -22
- package/dist/editor-language.d.ts +12 -7
- package/dist/editor-language.js +54 -45
- package/dist/emmet.d.ts +3 -2
- package/dist/folding.d.ts +2 -4
- package/dist/folding.js +1 -2
- package/dist/format-on-type.d.ts +8 -2
- package/dist/format-on-type.js +8 -6
- package/dist/highlights.d.ts +2 -6
- package/dist/highlights.js +3 -3
- package/dist/history.d.ts +8 -2
- package/dist/history.js +4 -2
- package/dist/host-types.d.ts +39 -22
- package/dist/hover-content.js +0 -1
- package/dist/hover.d.ts +13 -2
- package/dist/hover.js +25 -28
- package/dist/index.d.ts +19 -9
- package/dist/index.js +5 -2
- package/dist/inlay-hints.d.ts +12 -21
- package/dist/inlay-hints.js +16 -15
- package/dist/inline-completion.d.ts +30 -10
- package/dist/inline-completion.js +346 -102
- package/dist/key-priority.d.ts +1 -1
- package/dist/key-priority.js +2 -2
- package/dist/language-context.d.ts +30 -0
- package/dist/language-context.js +1 -0
- package/dist/language-ids.d.ts +0 -1
- package/dist/language-ids.js +0 -32
- package/dist/line-text.js +0 -1
- package/dist/linked-editing.d.ts +2 -4
- package/dist/linked-editing.js +1 -3
- package/dist/live-templates.d.ts +14 -2
- package/dist/live-templates.js +15 -10
- package/dist/locales/en.d.ts +357 -0
- package/dist/locales/en.js +356 -0
- package/dist/locales/nl.d.ts +357 -0
- package/dist/locales/nl.js +356 -0
- package/dist/markup-context.d.ts +7 -6
- package/dist/markup-context.js +0 -1
- package/dist/markup.d.ts +8 -2
- package/dist/markup.js +19 -20
- package/dist/models.d.ts +2 -1
- package/dist/models.js +2 -1
- package/dist/navigation-history.d.ts +7 -0
- package/dist/navigation.d.ts +11 -8
- package/dist/navigation.js +9 -20
- package/dist/panel-size.d.ts +4 -0
- package/dist/paste-history.d.ts +8 -2
- package/dist/paste-history.js +4 -2
- package/dist/patch-layout.d.ts +0 -4
- package/dist/patch-layout.js +1 -1
- package/dist/peek-model.js +0 -1
- package/dist/peek.d.ts +8 -2
- package/dist/peek.js +31 -42
- package/dist/pick.d.ts +4 -2
- package/dist/pick.js +38 -15
- package/dist/popups.d.ts +25 -20
- package/dist/popups.js +31 -15
- package/dist/positions.d.ts +7 -0
- package/dist/positions.js +54 -0
- package/dist/postfix.d.ts +11 -2
- package/dist/postfix.js +10 -6
- package/dist/project-language.d.ts +11 -3
- package/dist/project-language.js +40 -9
- package/dist/project-problems.d.ts +7 -1
- package/dist/project-problems.js +2 -1
- package/dist/rename-model.js +1 -1
- package/dist/rename.d.ts +2 -2
- package/dist/rename.js +17 -22
- package/dist/rendered-docs.d.ts +8 -2
- package/dist/rendered-docs.js +5 -4
- package/dist/selection-ranges.d.ts +2 -2
- package/dist/semantic-tokens.d.ts +2 -4
- package/dist/semantic-tokens.js +2 -2
- package/dist/shortcut-keys.d.ts +2 -1
- package/dist/signature.d.ts +2 -2
- package/dist/signature.js +9 -15
- package/dist/snippet-field-transforms.js +1 -1
- package/dist/snippet-insert.d.ts +4 -2
- package/dist/snippet-insert.js +9 -15
- package/dist/snippet-session.d.ts +9 -4
- package/dist/snippet-session.js +14 -14
- package/dist/snippet-transform-format.d.ts +2 -1
- package/dist/snippet-transform-queue.d.ts +2 -4
- package/dist/snippet-transform-queue.js +5 -37
- package/dist/snippet.d.ts +2 -1
- package/dist/surround-constructs.d.ts +1 -1
- package/dist/surround.d.ts +13 -2
- package/dist/surround.js +15 -8
- package/dist/symbol-links.d.ts +0 -1
- package/dist/symbol-links.js +1 -1
- package/dist/symbol-picker-model.d.ts +0 -1
- package/dist/symbol-picker-model.js +1 -2
- package/dist/symbol-picker.d.ts +2 -2
- package/dist/symbol-picker.js +5 -10
- package/dist/symbols.d.ts +4 -3
- package/dist/template-builtins.d.ts +1 -1
- package/dist/template-builtins.js +0 -1
- package/dist/template-context.d.ts +3 -3
- package/dist/template-context.js +2 -11
- package/dist/template-types.d.ts +20 -0
- package/dist/template-types.js +1 -0
- package/dist/templates.d.ts +5 -20
- package/dist/templates.js +0 -1
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +42 -0
- package/dist/use-problem-counts.d.ts +1 -1
- package/dist/word-diff.d.ts +1 -1
- package/dist/word-diff.js +16 -25
- package/dist/workspace-edit.d.ts +1 -24
- package/dist/workspace-edit.js +0 -1
- package/package.json +10 -9
- package/src/AnchoredPopup.tsx +1 -1
- package/src/CompletionPopup.tsx +0 -2
- package/src/DiffView.tsx +6 -38
- package/src/EditorView.tsx +0 -1
- package/src/HoverSections.tsx +2 -2
- package/src/LanguagePopups.tsx +20 -14
- package/src/PanelResizeHandle.tsx +0 -1
- package/src/PeekPanel.tsx +0 -1
- package/src/PickPopup.tsx +0 -1
- package/src/RenderedDocs.tsx +0 -2
- package/src/SplitDiffView.tsx +1 -1
- package/src/SymbolPicker.tsx +0 -1
- package/src/call-hierarchy-model.ts +0 -7
- package/src/call-hierarchy.ts +32 -31
- package/src/clipboard-history.ts +5 -2
- package/src/code-actions-model.ts +1 -4
- package/src/code-actions.ts +26 -10
- package/src/code-authors.ts +4 -15
- package/src/code-vision-model.ts +1 -2
- package/src/code-vision.ts +23 -19
- package/src/completion-call.ts +2 -2
- package/src/completion-model.ts +12 -7
- package/src/completion.ts +31 -16
- package/src/context-menu-rows.ts +1 -1
- package/src/context-menu.ts +19 -10
- package/src/definition-link.ts +12 -4
- package/src/diagnostics-model.ts +8 -55
- package/src/diagnostics.ts +11 -20
- package/src/diff-view-props.ts +38 -0
- package/src/doc-comment-model.ts +0 -2
- package/src/document-colors.ts +14 -6
- package/src/document-links.ts +5 -6
- package/src/document-query.ts +3 -3
- package/src/edit-locations.ts +4 -19
- package/src/editor-language.ts +74 -39
- package/src/emmet.ts +2 -3
- package/src/folding.ts +4 -5
- package/src/format-on-type.ts +14 -7
- package/src/highlights.ts +6 -6
- package/src/history.ts +12 -4
- package/src/host-types.ts +52 -33
- package/src/hover-content.ts +0 -1
- package/src/hover.ts +29 -22
- package/src/index.ts +25 -14
- package/src/inlay-hints.ts +23 -17
- package/src/inline-completion.ts +340 -90
- package/src/key-priority.ts +2 -2
- package/src/language-context.ts +60 -0
- package/src/language-ids.ts +0 -34
- package/src/line-text.ts +0 -1
- package/src/linked-editing.ts +4 -6
- package/src/live-templates.ts +27 -13
- package/src/locales/en.ts +356 -0
- package/src/locales/nl.ts +356 -0
- package/src/markup-context.ts +6 -9
- package/src/markup.ts +19 -10
- package/src/models.ts +2 -1
- package/src/navigation-history.ts +11 -0
- package/src/navigation.ts +18 -20
- package/src/panel-size.ts +8 -0
- package/src/paste-history.ts +12 -4
- package/src/patch-layout.ts +1 -1
- package/src/peek-model.ts +0 -1
- package/src/peek.ts +22 -18
- package/src/pick.ts +30 -16
- package/src/popups.ts +61 -40
- package/src/positions.ts +54 -0
- package/src/postfix.ts +21 -8
- package/src/project-language.ts +63 -14
- package/src/project-problems.ts +10 -2
- package/src/proposal-model.ts +0 -1
- package/src/rename-model.ts +1 -1
- package/src/rename.ts +21 -24
- package/src/rendered-docs.ts +13 -6
- package/src/selection-ranges.ts +2 -2
- package/src/semantic-tokens.ts +5 -5
- package/src/shortcut-keys.ts +1 -1
- package/src/signature.ts +8 -8
- package/src/snippet-field-transforms.ts +1 -1
- package/src/snippet-insert.ts +21 -14
- package/src/snippet-session.ts +25 -24
- package/src/snippet-transform-format.ts +1 -1
- package/src/snippet-transform-queue.ts +5 -51
- package/src/snippet.ts +1 -1
- package/src/surround-constructs.ts +1 -1
- package/src/surround.ts +24 -12
- package/src/symbol-links.ts +1 -1
- package/src/symbol-picker-model.ts +1 -4
- package/src/symbol-picker.ts +6 -7
- package/src/symbols.ts +3 -4
- package/src/template-builtins.ts +1 -2
- package/src/template-context.ts +5 -14
- package/src/template-types.ts +43 -0
- package/src/templates.ts +9 -45
- package/src/testing.ts +52 -0
- package/src/use-problem-counts.ts +1 -1
- package/src/word-diff.ts +17 -28
- package/src/workspace-edit.ts +1 -34
- package/dist/locales/en.json +0 -356
- package/dist/locales/nl.json +0 -356
- package/src/locales/en.json +0 -356
- package/src/locales/nl.json +0 -356
package/dist/code-actions.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ErrorCodes, LspError, StaleResultError } from '@adecore/lsp';
|
|
2
2
|
import { ACTION_GROUPS, REFACTOR_GROUPS, actionsOf, diagnosticsAt, fixableOnLine, isHint, mergeEntries, previewOf } from './code-actions-model.js';
|
|
3
|
-
import
|
|
3
|
+
import './diagnostics-model.js';
|
|
4
4
|
import { messageOf } from './error-message.js';
|
|
5
5
|
import { KEY_PRIORITY } from './key-priority.js';
|
|
6
|
+
import { comparePositions } from './positions.js';
|
|
6
7
|
import { Refresher } from './refresher.js';
|
|
7
8
|
import { isShortcut } from './shortcut-keys.js';
|
|
8
9
|
import { realTimers } from './timers.js';
|
|
@@ -27,12 +28,14 @@ function isRefusal(error) {
|
|
|
27
28
|
*/
|
|
28
29
|
export class CodeActionsFeature {
|
|
29
30
|
language;
|
|
31
|
+
peers;
|
|
30
32
|
refresher;
|
|
31
33
|
/* While a list is being asked for, the lightbulb waits: both are the same request and the newer one would cancel the older. */
|
|
32
34
|
asking = false;
|
|
33
35
|
resolved = new Map();
|
|
34
|
-
constructor(language, timers = realTimers) {
|
|
36
|
+
constructor(language, peers, timers = realTimers) {
|
|
35
37
|
this.language = language;
|
|
38
|
+
this.peers = peers;
|
|
36
39
|
const {
|
|
37
40
|
editor
|
|
38
41
|
} = language;
|
|
@@ -55,7 +58,7 @@ export class CodeActionsFeature {
|
|
|
55
58
|
return true;
|
|
56
59
|
}
|
|
57
60
|
return false;
|
|
58
|
-
}, KEY_PRIORITY.codeActions),
|
|
61
|
+
}, KEY_PRIORITY.codeActions), peers.diagnostics.onChange(() => this.refresher.later()), providers];
|
|
59
62
|
language.onDispose(() => {
|
|
60
63
|
for (const off of offs) {
|
|
61
64
|
off();
|
|
@@ -231,8 +234,8 @@ export class CodeActionsFeature {
|
|
|
231
234
|
rows
|
|
232
235
|
}];
|
|
233
236
|
});
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
237
|
+
this.peers.completion.close();
|
|
238
|
+
this.peers.pick.open({
|
|
236
239
|
anchor: options.anchor,
|
|
237
240
|
groups,
|
|
238
241
|
accept: id => {
|
|
@@ -248,9 +251,11 @@ export class CodeActionsFeature {
|
|
|
248
251
|
/* Asks the servers; null when they could not answer, with the reason said aloud for a request a person made. */
|
|
249
252
|
async request(range, triggerKind, options = {}) {
|
|
250
253
|
const {
|
|
251
|
-
uri
|
|
252
|
-
diagnostics
|
|
254
|
+
uri
|
|
253
255
|
} = this.language;
|
|
256
|
+
const {
|
|
257
|
+
diagnostics
|
|
258
|
+
} = this.peers;
|
|
254
259
|
const {
|
|
255
260
|
only,
|
|
256
261
|
signal,
|
|
@@ -288,7 +293,7 @@ export class CodeActionsFeature {
|
|
|
288
293
|
if (entries === null || range.start.line !== range.end.line) {
|
|
289
294
|
return entries;
|
|
290
295
|
}
|
|
291
|
-
const all = this.
|
|
296
|
+
const all = this.peers.diagnostics.problems.map(problem => problem.diagnostic);
|
|
292
297
|
if (diagnosticsAt(all, range).length > 0) {
|
|
293
298
|
return entries;
|
|
294
299
|
}
|
|
@@ -437,7 +442,7 @@ export class CodeActionsFeature {
|
|
|
437
442
|
const target = command.arguments?.[0] ?? null;
|
|
438
443
|
if (target?.position !== undefined && target.textDocument?.uri === this.language.uri) {
|
|
439
444
|
this.language.editor.setCaret(target.position);
|
|
440
|
-
await this.
|
|
445
|
+
await this.peers.rename.start();
|
|
441
446
|
}
|
|
442
447
|
}
|
|
443
448
|
tell(kind, title) {
|
package/dist/code-authors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lineMap, splitLines } from '@adecore/merge';
|
|
2
2
|
import { formatNumber } from '@adecore/ui/format';
|
|
3
3
|
/* A line no commit holds yet; every other line maps to the index of the commit that wrote it. */
|
|
4
4
|
export const UNCOMMITTED = -1;
|
|
@@ -13,19 +13,11 @@ export function mapBlame(blame, base, current) {
|
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
const mapped = new Int32Array(current.length).fill(UNCOMMITTED);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (; position < until; position++, basePosition++) {
|
|
20
|
-
mapped[position] = blame.lines[basePosition];
|
|
16
|
+
for (const [index, place] of lineMap(baseLines, current).entries()) {
|
|
17
|
+
if (place >= 0) {
|
|
18
|
+
mapped[place] = blame.lines[index];
|
|
21
19
|
}
|
|
22
|
-
};
|
|
23
|
-
for (const change of diffLines(baseLines, current)) {
|
|
24
|
-
carry(change.otherStart);
|
|
25
|
-
position = change.otherEnd;
|
|
26
|
-
basePosition = change.baseEnd;
|
|
27
20
|
}
|
|
28
|
-
carry(current.length);
|
|
29
21
|
return mapped;
|
|
30
22
|
}
|
|
31
23
|
/* A person's name as git has it, with runs of space made one. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatNumber } from '@adecore/ui/format';
|
|
2
2
|
/* Past this many declarations in one file the rows are left out, since that many rows would be noise. */
|
|
3
|
-
|
|
3
|
+
const MAX_DECLARATIONS = 3000;
|
|
4
4
|
/* LSP's SymbolKind: the kinds a row is drawn for and the ones whose children can be declarations too. */
|
|
5
5
|
const CLASS = 5;
|
|
6
6
|
const METHOD = 6;
|
|
@@ -181,7 +181,6 @@ export function declarationsOf(result, source) {
|
|
|
181
181
|
}
|
|
182
182
|
return declarations;
|
|
183
183
|
}
|
|
184
|
-
/* "No usages", "1 usage" and "N usages". */
|
|
185
184
|
export function usagesText(count, i18n) {
|
|
186
185
|
return count === 0 ? i18n.t('editor:language.codeVision.usagesNone') : i18n.t('editor:language.codeVision.usages', {
|
|
187
186
|
count,
|
package/dist/code-vision.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { EditorPosition } from '@adecore/editor';
|
|
1
2
|
import type { DocumentSymbolResult } from '@adecore/lsp';
|
|
2
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
3
3
|
import type { GitBlameResult } from './host-types.ts';
|
|
4
|
+
import type { LanguageContext } from './language-context.ts';
|
|
4
5
|
import { type Timers } from './timers.ts';
|
|
5
|
-
export declare const MAX_LINES = 20000;
|
|
6
6
|
export interface CodeVisionSettings {
|
|
7
7
|
readonly usages: boolean;
|
|
8
8
|
readonly authors: boolean;
|
|
@@ -15,8 +15,15 @@ export type BlameSource = {
|
|
|
15
15
|
readonly base: string;
|
|
16
16
|
openCommit?(hash: string): void;
|
|
17
17
|
};
|
|
18
|
+
interface CodeVisionPeers {
|
|
19
|
+
onSymbols(listener: (result: DocumentSymbolResult) => void): () => void;
|
|
20
|
+
readonly peek: {
|
|
21
|
+
open(position: EditorPosition): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
18
24
|
export declare class CodeVisionFeature {
|
|
19
25
|
private readonly language;
|
|
26
|
+
private readonly peers;
|
|
20
27
|
private readonly timers;
|
|
21
28
|
private settings;
|
|
22
29
|
private declarations;
|
|
@@ -33,7 +40,7 @@ export declare class CodeVisionFeature {
|
|
|
33
40
|
private scrollTimer;
|
|
34
41
|
private publishing;
|
|
35
42
|
private disposed;
|
|
36
|
-
constructor(language:
|
|
43
|
+
constructor(language: LanguageContext, peers: CodeVisionPeers, timers?: Timers);
|
|
37
44
|
configure(settings: CodeVisionSettings): void;
|
|
38
45
|
setBlame(blame: BlameSource | null): void;
|
|
39
46
|
private read;
|
|
@@ -47,3 +54,4 @@ export declare class CodeVisionFeature {
|
|
|
47
54
|
private showAuthors;
|
|
48
55
|
closeAuthors(restoreFocus?: boolean): void;
|
|
49
56
|
}
|
|
57
|
+
export {};
|
package/dist/code-vision.js
CHANGED
|
@@ -10,7 +10,7 @@ const MARGIN_LINES = 40;
|
|
|
10
10
|
const MAX_PARALLEL = 3;
|
|
11
11
|
const SCROLL_PAUSE_MS = 150;
|
|
12
12
|
/* Past this many lines a file gets no rows at all, which is also what keeps blame and the walk of symbols cheap. */
|
|
13
|
-
|
|
13
|
+
const MAX_LINES = 20_000;
|
|
14
14
|
/*
|
|
15
15
|
* The rows above declarations: how often each is used and who wrote it. A row holds its height from the
|
|
16
16
|
* first answer on, empty until its entries are in, so the text never moves when they arrive. Counts are
|
|
@@ -19,6 +19,7 @@ export const MAX_LINES = 20_000;
|
|
|
19
19
|
*/
|
|
20
20
|
export class CodeVisionFeature {
|
|
21
21
|
language;
|
|
22
|
+
peers;
|
|
22
23
|
timers;
|
|
23
24
|
settings = {
|
|
24
25
|
usages: false,
|
|
@@ -42,13 +43,14 @@ export class CodeVisionFeature {
|
|
|
42
43
|
scrollTimer;
|
|
43
44
|
publishing = false;
|
|
44
45
|
disposed = false;
|
|
45
|
-
constructor(language,
|
|
46
|
+
constructor(language, peers, timers = realTimers) {
|
|
46
47
|
this.language = language;
|
|
48
|
+
this.peers = peers;
|
|
47
49
|
this.timers = timers;
|
|
48
50
|
const {
|
|
49
51
|
editor
|
|
50
52
|
} = language;
|
|
51
|
-
const offs = [onSymbols(result => this.read(result)), editor.onTextChange(() => {
|
|
53
|
+
const offs = [peers.onSymbols(result => this.read(result)), editor.onTextChange(() => {
|
|
52
54
|
this.edited = true;
|
|
53
55
|
this.closeAuthors();
|
|
54
56
|
}), editor.onViewChange(() => {
|
|
@@ -74,7 +76,6 @@ export class CodeVisionFeature {
|
|
|
74
76
|
editor.setCodeVision([]);
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
|
-
/* Which rows to draw, from the settings of the client. */
|
|
78
79
|
configure(settings) {
|
|
79
80
|
if (settings.usages === this.settings.usages && settings.authors === this.settings.authors) {
|
|
80
81
|
return;
|
|
@@ -83,7 +84,6 @@ export class CodeVisionFeature {
|
|
|
83
84
|
this.publish();
|
|
84
85
|
this.plan();
|
|
85
86
|
}
|
|
86
|
-
/* What git says about the file, from the client that asked it. */
|
|
87
87
|
setBlame(blame) {
|
|
88
88
|
this.blame = blame;
|
|
89
89
|
this.mapped = null;
|
|
@@ -113,7 +113,6 @@ export class CodeVisionFeature {
|
|
|
113
113
|
get canCount() {
|
|
114
114
|
return this.settings.usages && this.language.service.supports(REFERENCES, this.language.uri);
|
|
115
115
|
}
|
|
116
|
-
/* Queues the declarations in view whose count is not from the current text, nearest the top of the view first. */
|
|
117
116
|
plan() {
|
|
118
117
|
if (this.disposed || this.edited || !this.canCount) {
|
|
119
118
|
return;
|
|
@@ -187,7 +186,7 @@ export class CodeVisionFeature {
|
|
|
187
186
|
entries.push({
|
|
188
187
|
id: 'usages',
|
|
189
188
|
text: usagesText(known.count, this.language.project.i18n),
|
|
190
|
-
activate: () => void this.
|
|
189
|
+
activate: () => void this.peers.peek.open(declaration.position)
|
|
191
190
|
});
|
|
192
191
|
}
|
|
193
192
|
if (mapped !== null && declaration.authors) {
|
|
@@ -230,21 +229,17 @@ export class CodeVisionFeature {
|
|
|
230
229
|
showAuthors(declaration, authorship, anchor) {
|
|
231
230
|
const source = this.blame;
|
|
232
231
|
const openCommit = source?.kind === 'ready' ? source.openCommit : undefined;
|
|
233
|
-
this.language.popups.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
openCommit: openCommit === undefined || authorship.latest === null ? null : () => openCommit(authorship.latest.hash)
|
|
239
|
-
}
|
|
232
|
+
this.language.popups.slot('authors').set({
|
|
233
|
+
anchor,
|
|
234
|
+
name: declaration.name,
|
|
235
|
+
authorship,
|
|
236
|
+
openCommit: openCommit === undefined || authorship.latest === null ? null : () => openCommit(authorship.latest.hash)
|
|
240
237
|
});
|
|
241
238
|
}
|
|
242
239
|
/* Closes the card of the authors; `restoreFocus` is for a close that came from the keyboard, which gives the editor its keys back. */
|
|
243
240
|
closeAuthors(restoreFocus = false) {
|
|
244
|
-
if (this.language.popups.
|
|
245
|
-
this.language.popups.
|
|
246
|
-
authors: null
|
|
247
|
-
});
|
|
241
|
+
if (this.language.popups.slot('authors').get() !== null) {
|
|
242
|
+
this.language.popups.slot('authors').set(null);
|
|
248
243
|
if (restoreFocus) {
|
|
249
244
|
this.language.editor.focus();
|
|
250
245
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CompletionItem } from '@adecore/lsp';
|
|
2
2
|
import { type Insertion } from './completion-model.ts';
|
|
3
3
|
export declare const PARAMETER_HINTS_COMMAND = "editor.action.triggerParameterHints";
|
|
4
4
|
export type CallPlan = {
|
package/dist/completion-call.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SCRIPT_LANGUAGE_IDS } from '@adecore/lsp';
|
|
1
2
|
import { CLASS_KIND, SNIPPET_FORMAT, SOURCE_LINE, isCallableKind } from './completion-model.js';
|
|
2
3
|
/* What the platform's editors send to ask for parameter info once an item is in; the card is ours to open. */
|
|
3
4
|
export const PARAMETER_HINTS_COMMAND = 'editor.action.triggerParameterHints';
|
|
4
|
-
const CALL_LANGUAGES = new Set([
|
|
5
|
+
const CALL_LANGUAGES = new Set([...SCRIPT_LANGUAGE_IDS, 'vue', 'php', 'python']);
|
|
5
6
|
const MARKUP_LANGUAGES = new Set(['typescriptreact', 'javascriptreact', 'vue']);
|
|
6
7
|
const IMPORT_BRACE = /\b(?:import|export)(?:\s+type)?(?:\s+[\w$]+\s*,)?\s*$/;
|
|
7
8
|
const PHP_USE_BRACE = /\buse(?:\s+(?:function|const))?\s+[\w\\]*\\\s*$/;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { EditorContentChange, EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
2
|
import { type CompletionItem, type CompletionResult, type MarkupContent } from '@adecore/lsp';
|
|
3
|
-
import type
|
|
3
|
+
import { type HoverText } from './hover-content.ts';
|
|
4
4
|
import type { SnippetTransformJob } from './snippet-transform-protocol.ts';
|
|
5
5
|
import { type SnippetField, type SnippetStop, type SnippetTemplate, type SnippetVariableResolver } from './snippet.ts';
|
|
6
|
+
export interface CompletionDocs {
|
|
7
|
+
readonly source: string;
|
|
8
|
+
readonly text: HoverText;
|
|
9
|
+
}
|
|
6
10
|
export declare function isIdentifierCharacter(character: string): boolean;
|
|
7
11
|
export declare function identifierPrefix(before: string): string;
|
|
8
12
|
export declare function opensCompletion(before: string, text: string): boolean;
|
|
@@ -28,9 +32,6 @@ export declare function matchedCharacters(label: string, prefix: string): readon
|
|
|
28
32
|
export declare function qualifierOf(item: CompletionItem): string;
|
|
29
33
|
export declare function qualifiersOf(items: readonly CompletionItem[]): string[];
|
|
30
34
|
export declare function snippetToText(snippet: string): string;
|
|
31
|
-
export declare const METHOD_KIND = 2;
|
|
32
|
-
export declare const FUNCTION_KIND = 3;
|
|
33
|
-
export declare const CONSTRUCTOR_KIND = 4;
|
|
34
35
|
export declare const CLASS_KIND = 7;
|
|
35
36
|
export declare const SNIPPET_FORMAT = 2;
|
|
36
37
|
export declare function isCallableKind(kind: number | undefined): boolean;
|
package/dist/completion-model.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { applyCompletionDefaults } from '@adecore/lsp';
|
|
2
2
|
import { labelCollator } from '@adecore/ui/format';
|
|
3
|
-
import { comparePositions, sameRange } from './diagnostics-model.js';
|
|
4
3
|
import { escapeMarkdown, isEmptyHover, splitSignatures } from './hover-content.js';
|
|
4
|
+
import { comparePositions, sameRange } from './positions.js';
|
|
5
5
|
import { indentSnippet } from './snippet-indent.js';
|
|
6
6
|
import { compileSnippet, parseSnippet, tabOrder } from './snippet.js';
|
|
7
7
|
const IDENTIFIER_CHARACTER = /[\p{L}\p{N}\p{M}_$]/u;
|
|
@@ -243,9 +243,9 @@ export function qualifiersOf(items) {
|
|
|
243
243
|
export function snippetToText(snippet) {
|
|
244
244
|
return parseSnippet(snippet).text;
|
|
245
245
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
const METHOD_KIND = 2;
|
|
247
|
+
const FUNCTION_KIND = 3;
|
|
248
|
+
const CONSTRUCTOR_KIND = 4;
|
|
249
249
|
export const CLASS_KIND = 7;
|
|
250
250
|
export const SNIPPET_FORMAT = 2;
|
|
251
251
|
export function isCallableKind(kind) {
|
package/dist/completion.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { EditorPosition } from '@adecore/editor';
|
|
2
2
|
import { type CompletionItem } from '@adecore/lsp';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
4
|
+
import type { PickFeature } from './pick.ts';
|
|
5
|
+
import type { SignatureFeature } from './signature.ts';
|
|
6
|
+
import type { SnippetFeature } from './snippet-session.ts';
|
|
4
7
|
import { type Timers } from './timers.ts';
|
|
5
8
|
/** A row a source of the editor offers beside the language server's. */
|
|
6
9
|
export interface LocalCompletionItem {
|
|
@@ -9,8 +12,7 @@ export interface LocalCompletionItem {
|
|
|
9
12
|
/** Runs instead of the insertion: the source inserts the row itself. */
|
|
10
13
|
accept(): void;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
export interface CompletionRequest {
|
|
15
|
+
interface CompletionRequest {
|
|
14
16
|
readonly position: EditorPosition;
|
|
15
17
|
/** Whether the person asked for the list with the keyboard. */
|
|
16
18
|
readonly explicit: boolean;
|
|
@@ -21,8 +23,14 @@ export interface CompletionSource {
|
|
|
21
23
|
/** Synchronous and cheap; asked on every request of the list. */
|
|
22
24
|
items(request: CompletionRequest): readonly LocalCompletionItem[];
|
|
23
25
|
}
|
|
26
|
+
interface CompletionPeers {
|
|
27
|
+
readonly pick: Pick<PickFeature, 'close'>;
|
|
28
|
+
readonly snippets: Pick<SnippetFeature, 'applyEdits' | 'beginInstances' | 'end' | 'hasPendingTransforms' | 'isActive' | 'settleTransforms' | 'token' | 'transformVariables'>;
|
|
29
|
+
readonly signature: Pick<SignatureFeature, 'trigger'>;
|
|
30
|
+
}
|
|
24
31
|
export declare class CompletionFeature {
|
|
25
32
|
private readonly language;
|
|
33
|
+
private readonly peers;
|
|
26
34
|
private readonly timers;
|
|
27
35
|
private pool;
|
|
28
36
|
private incomplete;
|
|
@@ -48,7 +56,7 @@ export declare class CompletionFeature {
|
|
|
48
56
|
private readonly sources;
|
|
49
57
|
private locals;
|
|
50
58
|
private shown;
|
|
51
|
-
constructor(language:
|
|
59
|
+
constructor(language: LanguageContext, peers: CompletionPeers, timers?: Timers);
|
|
52
60
|
get isOpen(): boolean;
|
|
53
61
|
invoke(): void;
|
|
54
62
|
/** Adds rows to every list, also in a document without a language server. Returns the function that takes the source away again. */
|
|
@@ -76,3 +84,4 @@ export declare class CompletionFeature {
|
|
|
76
84
|
private scheduleResolve;
|
|
77
85
|
private publish;
|
|
78
86
|
}
|
|
87
|
+
export {};
|
package/dist/completion.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { fileUriToPath, StaleResultError } from '@adecore/lsp';
|
|
2
2
|
import { PARAMETER_HINTS_COMMAND, isCallItem, planCall, withParentheses } from './completion-call.js';
|
|
3
3
|
import { completionDocsOf, editRangeOf, identifierPrefix, insertionOf, isIdentifierCharacter, itemsOf, matchedCharacters, mirroredInsertions, opensCompletion, prefixFor, qualifiersOf, rankCompletions } from './completion-model.js';
|
|
4
|
-
import { comparePositions, sameRange, shiftPosition } from './diagnostics-model.js';
|
|
5
4
|
import { messageOf } from './error-message.js';
|
|
6
5
|
import { KEY_PRIORITY } from './key-priority.js';
|
|
7
6
|
import { shikiLanguageOf } from './language-ids.js';
|
|
8
7
|
import { lineTextOf, textBeforeOf } from './line-text.js';
|
|
8
|
+
import { comparePositions, sameRange, shiftPosition } from './positions.js';
|
|
9
9
|
import { isEmptyRange } from './proposal-model.js';
|
|
10
10
|
import { RecentChoices, recentChoicesOf } from './recent-choices.js';
|
|
11
11
|
import { wordRangeAt } from './rename-model.js';
|
|
@@ -76,6 +76,7 @@ function mapCompletionEdits(item, changes, mapRange) {
|
|
|
76
76
|
*/
|
|
77
77
|
export class CompletionFeature {
|
|
78
78
|
language;
|
|
79
|
+
peers;
|
|
79
80
|
timers;
|
|
80
81
|
pool = [];
|
|
81
82
|
incomplete = false;
|
|
@@ -106,8 +107,9 @@ export class CompletionFeature {
|
|
|
106
107
|
locals = new Map();
|
|
107
108
|
/* Whether the list holds the rows `showItems` gave it and no request refreshes it. */
|
|
108
109
|
shown = false;
|
|
109
|
-
constructor(language, timers = realTimers) {
|
|
110
|
+
constructor(language, peers, timers = realTimers) {
|
|
110
111
|
this.language = language;
|
|
112
|
+
this.peers = peers;
|
|
111
113
|
this.timers = timers;
|
|
112
114
|
const {
|
|
113
115
|
editor
|
|
@@ -127,11 +129,11 @@ export class CompletionFeature {
|
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
get isOpen() {
|
|
130
|
-
return this.language.popups.
|
|
132
|
+
return this.language.popups.slot('completion').get() !== null;
|
|
131
133
|
}
|
|
132
134
|
/* Asks for suggestions at the caret now, as Ctrl+Space does. */
|
|
133
135
|
invoke() {
|
|
134
|
-
this.
|
|
136
|
+
this.peers.pick.close();
|
|
135
137
|
this.explicit = true;
|
|
136
138
|
this.beginRequest({
|
|
137
139
|
triggerKind: 1
|
|
@@ -146,7 +148,7 @@ export class CompletionFeature {
|
|
|
146
148
|
}
|
|
147
149
|
/** Opens the list with only these rows, the typed prefix starting at `start`, as Insert Live Template does. */
|
|
148
150
|
showItems(items, start) {
|
|
149
|
-
this.
|
|
151
|
+
this.peers.pick.close();
|
|
150
152
|
this.close();
|
|
151
153
|
this.shown = true;
|
|
152
154
|
this.locals = new Map(items.map(local => [local.item, local]));
|
|
@@ -201,9 +203,11 @@ export class CompletionFeature {
|
|
|
201
203
|
const {
|
|
202
204
|
editor,
|
|
203
205
|
project,
|
|
204
|
-
uri
|
|
205
|
-
snippets
|
|
206
|
+
uri
|
|
206
207
|
} = this.language;
|
|
208
|
+
const {
|
|
209
|
+
snippets
|
|
210
|
+
} = this.peers;
|
|
207
211
|
const acceptSequence = ++this.acceptSequence;
|
|
208
212
|
this.accepting?.abort();
|
|
209
213
|
const accepting = new AbortController();
|
|
@@ -404,7 +408,7 @@ export class CompletionFeature {
|
|
|
404
408
|
}
|
|
405
409
|
const landed = editor.getSelections();
|
|
406
410
|
if (commit === undefined) {
|
|
407
|
-
this.
|
|
411
|
+
this.peers.snippets.beginInstances([...mirrored, primary].map((insertion, index) => {
|
|
408
412
|
const rendered = insertion === primary ? main : instances.get(insertion);
|
|
409
413
|
return {
|
|
410
414
|
start: starts[index],
|
|
@@ -489,7 +493,6 @@ export class CompletionFeature {
|
|
|
489
493
|
selections[primary] = editor.getSelection();
|
|
490
494
|
editor.setSelections(selections);
|
|
491
495
|
}
|
|
492
|
-
/* The lines above the insertion down to where it starts, and the rest of the line past what it replaces. */
|
|
493
496
|
surroundings(insertion, caret, lineAfter) {
|
|
494
497
|
const {
|
|
495
498
|
editor
|
|
@@ -515,9 +518,11 @@ export class CompletionFeature {
|
|
|
515
518
|
afterInsert(item, commit, lineBefore) {
|
|
516
519
|
const {
|
|
517
520
|
editor,
|
|
518
|
-
uri
|
|
519
|
-
signature
|
|
521
|
+
uri
|
|
520
522
|
} = this.language;
|
|
523
|
+
const {
|
|
524
|
+
signature
|
|
525
|
+
} = this.peers;
|
|
521
526
|
const {
|
|
522
527
|
start
|
|
523
528
|
} = editor.getSelection();
|
|
@@ -597,10 +602,8 @@ export class CompletionFeature {
|
|
|
597
602
|
this.resolved.clear();
|
|
598
603
|
this.locals = new Map();
|
|
599
604
|
this.shown = false;
|
|
600
|
-
if (this.language.popups.
|
|
601
|
-
this.language.popups.
|
|
602
|
-
completion: null
|
|
603
|
-
});
|
|
605
|
+
if (this.language.popups.slot('completion').get() !== null) {
|
|
606
|
+
this.language.popups.slot('completion').set(null);
|
|
604
607
|
}
|
|
605
608
|
}
|
|
606
609
|
key(event) {
|
|
@@ -930,8 +933,6 @@ export class CompletionFeature {
|
|
|
930
933
|
server: this.server,
|
|
931
934
|
highlightLanguage
|
|
932
935
|
};
|
|
933
|
-
this.language.popups.
|
|
934
|
-
completion: view
|
|
935
|
-
});
|
|
936
|
+
this.language.popups.slot('completion').set(view);
|
|
936
937
|
}
|
|
937
938
|
}
|
|
@@ -6,9 +6,10 @@ export interface MenuRowSpec {
|
|
|
6
6
|
readonly method: string;
|
|
7
7
|
readonly shortcut: KeymapId | null;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
interface MenuGroups {
|
|
10
10
|
readonly goTo: readonly MenuRowSpec[];
|
|
11
11
|
readonly references: readonly MenuRowSpec[];
|
|
12
12
|
readonly changes: readonly MenuRowSpec[];
|
|
13
13
|
}
|
|
14
14
|
export declare function menuGroupsOf(supports: (method: string) => boolean): MenuGroups;
|
|
15
|
+
export {};
|
package/dist/context-menu.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { CodeActionsFeature } from './code-actions.ts';
|
|
2
|
+
import type { LanguageContext } from './language-context.ts';
|
|
3
|
+
type ClipboardAction = 'cut' | 'copy' | 'paste';
|
|
4
|
+
interface ContextMenuPeers {
|
|
5
|
+
readonly codeActions: Pick<CodeActionsFeature, 'list'>;
|
|
6
|
+
}
|
|
3
7
|
export declare class ContextMenuFeature {
|
|
4
8
|
private readonly language;
|
|
9
|
+
private readonly peers;
|
|
5
10
|
private request;
|
|
6
|
-
constructor(language:
|
|
11
|
+
constructor(language: LanguageContext, peers: ContextMenuPeers);
|
|
7
12
|
close(): void;
|
|
8
13
|
clipboard(action: ClipboardAction): void;
|
|
9
14
|
private open;
|
|
10
15
|
}
|
|
16
|
+
export {};
|
package/dist/context-menu.js
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export class ContextMenuFeature {
|
|
6
6
|
language;
|
|
7
|
+
peers;
|
|
7
8
|
request = 0;
|
|
8
|
-
constructor(language) {
|
|
9
|
+
constructor(language, peers) {
|
|
9
10
|
this.language = language;
|
|
11
|
+
this.peers = peers;
|
|
10
12
|
const off = language.editor.onContextMenu(menu => {
|
|
11
13
|
// A right click outside the selection moves the caret first, so the menu is about what was clicked.
|
|
12
14
|
if (!menu.inSelection) {
|
|
@@ -21,10 +23,8 @@ export class ContextMenuFeature {
|
|
|
21
23
|
}
|
|
22
24
|
close() {
|
|
23
25
|
this.request++;
|
|
24
|
-
if (this.language.popups.
|
|
25
|
-
this.language.popups.
|
|
26
|
-
menu: null
|
|
27
|
-
});
|
|
26
|
+
if (this.language.popups.slot('menu').get() !== null) {
|
|
27
|
+
this.language.popups.slot('menu').set(null);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
/* The browser's own commands on the editor's input, which keep the clipboard and the undo history one thing. */
|
|
@@ -47,24 +47,22 @@ export class ContextMenuFeature {
|
|
|
47
47
|
open(x, y) {
|
|
48
48
|
const request = ++this.request;
|
|
49
49
|
const {
|
|
50
|
-
popups
|
|
51
|
-
codeActions
|
|
50
|
+
popups
|
|
52
51
|
} = this.language;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
const {
|
|
53
|
+
codeActions
|
|
54
|
+
} = this.peers;
|
|
55
|
+
popups.slot('menu').set({
|
|
56
|
+
x,
|
|
57
|
+
y,
|
|
58
|
+
refactors: []
|
|
59
59
|
});
|
|
60
60
|
void codeActions.list(['refactor']).then(entries => {
|
|
61
|
-
const shown = popups.
|
|
61
|
+
const shown = popups.slot('menu').get();
|
|
62
62
|
if (request === this.request && shown !== null && entries !== null) {
|
|
63
|
-
popups.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
refactors: entries
|
|
67
|
-
}
|
|
63
|
+
popups.slot('menu').set({
|
|
64
|
+
...shown,
|
|
65
|
+
refactors: entries
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
68
|
});
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DocumentLinksFeature } from './document-links.ts';
|
|
2
|
+
import type { LanguageContext } from './language-context.ts';
|
|
2
3
|
export declare function followModKey(apple: boolean, onHeld: (held: boolean) => void): () => void;
|
|
4
|
+
interface DefinitionLinkPeers {
|
|
5
|
+
readonly links: Pick<DocumentLinksFeature, 'rangeAt'>;
|
|
6
|
+
}
|
|
3
7
|
export declare class DefinitionLinkFeature {
|
|
4
8
|
private readonly language;
|
|
9
|
+
private readonly peers;
|
|
5
10
|
private held;
|
|
6
11
|
private pointer;
|
|
7
12
|
private shownKey;
|
|
8
13
|
private drawn;
|
|
9
14
|
private request;
|
|
10
15
|
private lookup;
|
|
11
|
-
constructor(language:
|
|
16
|
+
constructor(language: LanguageContext, peers: DefinitionLinkPeers);
|
|
12
17
|
setModHeld(held: boolean): void;
|
|
13
18
|
private clear;
|
|
14
19
|
private update;
|
|
15
20
|
}
|
|
21
|
+
export {};
|
package/dist/definition-link.js
CHANGED
|
@@ -30,14 +30,16 @@ export function followModKey(apple, onHeld) {
|
|
|
30
30
|
*/
|
|
31
31
|
export class DefinitionLinkFeature {
|
|
32
32
|
language;
|
|
33
|
+
peers;
|
|
33
34
|
held = false;
|
|
34
35
|
pointer = null;
|
|
35
36
|
shownKey = '';
|
|
36
37
|
drawn = false;
|
|
37
38
|
request = 0;
|
|
38
39
|
lookup = null;
|
|
39
|
-
constructor(language) {
|
|
40
|
+
constructor(language, peers) {
|
|
40
41
|
this.language = language;
|
|
42
|
+
this.peers = peers;
|
|
41
43
|
const {
|
|
42
44
|
editor
|
|
43
45
|
} = language;
|
|
@@ -71,7 +73,7 @@ export class DefinitionLinkFeature {
|
|
|
71
73
|
const {
|
|
72
74
|
pointer
|
|
73
75
|
} = this;
|
|
74
|
-
const link = pointer === null ? null : this.
|
|
76
|
+
const link = pointer === null ? null : this.peers.links.rangeAt(pointer);
|
|
75
77
|
if (this.held && link !== null) {
|
|
76
78
|
const key = `link:${link.start.line}:${link.start.character}`;
|
|
77
79
|
if (key !== this.shownKey) {
|