@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/panel-size.d.ts
CHANGED
package/dist/paste-history.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageContext } from './language-context.ts';
|
|
2
|
+
import type { PickFeature } from './pick.ts';
|
|
3
|
+
interface PasteHistoryPeers {
|
|
4
|
+
readonly pick: Pick<PickFeature, 'open'>;
|
|
5
|
+
}
|
|
2
6
|
export declare class PasteHistoryFeature {
|
|
3
7
|
private readonly language;
|
|
4
|
-
|
|
8
|
+
private readonly peers;
|
|
9
|
+
constructor(language: LanguageContext, peers: PasteHistoryPeers);
|
|
5
10
|
open(): void;
|
|
6
11
|
private paste;
|
|
7
12
|
}
|
|
13
|
+
export {};
|
package/dist/paste-history.js
CHANGED
|
@@ -13,8 +13,10 @@ function labelOf(text) {
|
|
|
13
13
|
*/
|
|
14
14
|
export class PasteHistoryFeature {
|
|
15
15
|
language;
|
|
16
|
-
|
|
16
|
+
peers;
|
|
17
|
+
constructor(language, peers) {
|
|
17
18
|
this.language = language;
|
|
19
|
+
this.peers = peers;
|
|
18
20
|
const off = language.onKey(event => {
|
|
19
21
|
if (!isShortcut(this.language.shortcuts.pasteFromHistory, event)) {
|
|
20
22
|
return false;
|
|
@@ -53,7 +55,7 @@ export class PasteHistoryFeature {
|
|
|
53
55
|
})
|
|
54
56
|
}];
|
|
55
57
|
const rows = groups();
|
|
56
|
-
this.
|
|
58
|
+
this.peers.pick.open({
|
|
57
59
|
anchor: editor.getCaret(),
|
|
58
60
|
title: project.i18n.t('editor:language.pasteHistory.title'),
|
|
59
61
|
groups: rows,
|
package/dist/patch-layout.d.ts
CHANGED
|
@@ -33,8 +33,4 @@ export interface PatchLimits {
|
|
|
33
33
|
readonly maxLines?: number;
|
|
34
34
|
readonly maxCharacters?: number;
|
|
35
35
|
}
|
|
36
|
-
export declare const DEFAULT_PATCH_LIMITS: {
|
|
37
|
-
readonly maxLines: 50000;
|
|
38
|
-
readonly maxCharacters: 4000000;
|
|
39
|
-
};
|
|
40
36
|
export declare function patchLayoutOf(text: string, limits?: PatchLimits): PatchLayout;
|
package/dist/patch-layout.js
CHANGED
package/dist/peek-model.js
CHANGED
|
@@ -11,7 +11,6 @@ function columnsOf(range, line, length) {
|
|
|
11
11
|
end
|
|
12
12
|
} : null;
|
|
13
13
|
}
|
|
14
|
-
/* The name of a place within its line once the indentation is cut off. */
|
|
15
14
|
function trimmedNameOf(raw, range, line) {
|
|
16
15
|
const leading = raw.length - raw.trimStart().length;
|
|
17
16
|
const columns = columnsOf(range, line, raw.length);
|
package/dist/peek.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { EditorPosition } from '@adecore/editor';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageContext } from './language-context.ts';
|
|
3
3
|
import type { PeekView } from './popups.ts';
|
|
4
4
|
import { type Timers } from './timers.ts';
|
|
5
5
|
export declare const PEEK_HEIGHT = 241;
|
|
6
6
|
type PeekKind = PeekView['kind'];
|
|
7
|
+
interface PeekPeers {
|
|
8
|
+
readonly callHierarchy: {
|
|
9
|
+
close(): void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
7
12
|
export declare class PeekFeature {
|
|
8
13
|
private readonly language;
|
|
14
|
+
private readonly peers;
|
|
9
15
|
private readonly timers;
|
|
10
16
|
private kind;
|
|
11
17
|
private targets;
|
|
@@ -14,7 +20,7 @@ export declare class PeekFeature {
|
|
|
14
20
|
private order;
|
|
15
21
|
private line;
|
|
16
22
|
private token;
|
|
17
|
-
constructor(language:
|
|
23
|
+
constructor(language: LanguageContext, peers: PeekPeers, timers?: Timers);
|
|
18
24
|
get isOpen(): boolean;
|
|
19
25
|
open(position?: EditorPosition, kind?: PeekKind): Promise<void>;
|
|
20
26
|
openDefinition(position?: EditorPosition): Promise<void>;
|
package/dist/peek.js
CHANGED
|
@@ -28,6 +28,7 @@ const KINDS = {
|
|
|
28
28
|
*/
|
|
29
29
|
export class PeekFeature {
|
|
30
30
|
language;
|
|
31
|
+
peers;
|
|
31
32
|
timers;
|
|
32
33
|
kind = 'references';
|
|
33
34
|
/* The whole declaration of each place of a definition peek, where the server gave it. */
|
|
@@ -37,8 +38,9 @@ export class PeekFeature {
|
|
|
37
38
|
order = [];
|
|
38
39
|
line = 0;
|
|
39
40
|
token = 0;
|
|
40
|
-
constructor(language, timers = realTimers) {
|
|
41
|
+
constructor(language, peers, timers = realTimers) {
|
|
41
42
|
this.language = language;
|
|
43
|
+
this.peers = peers;
|
|
42
44
|
this.timers = timers;
|
|
43
45
|
const {
|
|
44
46
|
editor
|
|
@@ -62,7 +64,7 @@ export class PeekFeature {
|
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
get isOpen() {
|
|
65
|
-
return this.language.popups.
|
|
67
|
+
return this.language.popups.slot('peek').get() !== null;
|
|
66
68
|
}
|
|
67
69
|
async open(position = this.language.editor.getCaret(), kind = 'references') {
|
|
68
70
|
const {
|
|
@@ -118,17 +120,15 @@ export class PeekFeature {
|
|
|
118
120
|
// The references open on the first place that is not the one the caret is on, which is what a person came to see.
|
|
119
121
|
const first = kind === 'definitions' ? files[0].places[0] : files.flatMap(file => file.places).find(place => !(place.location.uri === uri && place.line === position.line)) ?? files[0].places[0];
|
|
120
122
|
this.line = position.line;
|
|
121
|
-
this.
|
|
122
|
-
this.language.popups.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
preview: null
|
|
131
|
-
}
|
|
123
|
+
this.peers.callHierarchy.close();
|
|
124
|
+
this.language.popups.slot('peek').set({
|
|
125
|
+
kind,
|
|
126
|
+
container: null,
|
|
127
|
+
files,
|
|
128
|
+
active: first.id,
|
|
129
|
+
collapsed: [],
|
|
130
|
+
count: unique.length,
|
|
131
|
+
preview: null
|
|
132
132
|
});
|
|
133
133
|
this.select(first.id);
|
|
134
134
|
// The editor draws a row once per id, so a peek opened over another needs an id of its own to get a container.
|
|
@@ -141,7 +141,6 @@ export class PeekFeature {
|
|
|
141
141
|
// The keys come through the editor, which a click on the hover's link or a menu command has taken the focus from.
|
|
142
142
|
editor.focus();
|
|
143
143
|
}
|
|
144
|
-
/* The definition of the name at the caret, as its source between the lines of the file. */
|
|
145
144
|
openDefinition(position = this.language.editor.getCaret()) {
|
|
146
145
|
return this.open(position, 'definitions');
|
|
147
146
|
}
|
|
@@ -170,18 +169,15 @@ export class PeekFeature {
|
|
|
170
169
|
}
|
|
171
170
|
close() {
|
|
172
171
|
this.token++;
|
|
173
|
-
if (this.language.popups.
|
|
172
|
+
if (this.language.popups.slot('peek').get() === null) {
|
|
174
173
|
return;
|
|
175
174
|
}
|
|
176
|
-
this.language.popups.
|
|
177
|
-
peek: null
|
|
178
|
-
});
|
|
175
|
+
this.language.popups.slot('peek').set(null);
|
|
179
176
|
this.language.editor.setWidgets([]);
|
|
180
177
|
this.language.editor.focus();
|
|
181
178
|
}
|
|
182
|
-
/* Shows the code around a place. */
|
|
183
179
|
select(id) {
|
|
184
|
-
const view = this.language.popups.
|
|
180
|
+
const view = this.language.popups.slot('peek').get();
|
|
185
181
|
const location = this.places.get(id);
|
|
186
182
|
if (view === null || location === undefined) {
|
|
187
183
|
return;
|
|
@@ -189,27 +185,22 @@ export class PeekFeature {
|
|
|
189
185
|
const text = this.texts.get(location.uri);
|
|
190
186
|
const line = location.range.start.line;
|
|
191
187
|
const snippet = text === undefined ? null : this.kind === 'definitions' ? definitionSnippetOf(text, line, this.targets.get(placeKey(location)) ?? null, location.range) : snippetOf(text, line, location.range);
|
|
192
|
-
this.language.popups.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
uri: location.uri
|
|
199
|
-
}
|
|
188
|
+
this.language.popups.slot('peek').set({
|
|
189
|
+
...view,
|
|
190
|
+
active: id,
|
|
191
|
+
preview: snippet === null ? null : {
|
|
192
|
+
...snippet,
|
|
193
|
+
uri: location.uri
|
|
200
194
|
}
|
|
201
195
|
});
|
|
202
196
|
}
|
|
203
|
-
/* Folds the places of a file away from the list, or brings them back. */
|
|
204
197
|
toggleFile(uri) {
|
|
205
|
-
const view = this.language.popups.
|
|
198
|
+
const view = this.language.popups.slot('peek').get();
|
|
206
199
|
if (view !== null) {
|
|
207
200
|
const collapsed = view.collapsed.includes(uri) ? view.collapsed.filter(other => other !== uri) : [...view.collapsed, uri];
|
|
208
|
-
this.language.popups.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
collapsed
|
|
212
|
-
}
|
|
201
|
+
this.language.popups.slot('peek').set({
|
|
202
|
+
...view,
|
|
203
|
+
collapsed
|
|
213
204
|
});
|
|
214
205
|
}
|
|
215
206
|
}
|
|
@@ -222,19 +213,17 @@ export class PeekFeature {
|
|
|
222
213
|
}
|
|
223
214
|
}
|
|
224
215
|
mounted(container) {
|
|
225
|
-
const view = this.language.popups.
|
|
216
|
+
const view = this.language.popups.slot('peek').get();
|
|
226
217
|
if (view !== null && view.container !== container) {
|
|
227
|
-
this.language.popups.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
container
|
|
231
|
-
}
|
|
218
|
+
this.language.popups.slot('peek').set({
|
|
219
|
+
...view,
|
|
220
|
+
container
|
|
232
221
|
});
|
|
233
222
|
revealRow(this.timers, container);
|
|
234
223
|
}
|
|
235
224
|
}
|
|
236
225
|
key(event) {
|
|
237
|
-
const view = this.language.popups.
|
|
226
|
+
const view = this.language.popups.slot('peek').get();
|
|
238
227
|
if (view === null || event.metaKey || event.ctrlKey || event.altKey) {
|
|
239
228
|
return false;
|
|
240
229
|
}
|
package/dist/pick.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EditorPosition } from '@adecore/editor';
|
|
2
|
-
import type
|
|
2
|
+
import { type Location } from '@adecore/lsp';
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
3
4
|
import type { PickGroup, PickPreview } from './popups.ts';
|
|
4
5
|
import { type Timers } from './timers.ts';
|
|
5
6
|
export interface PickSpec {
|
|
@@ -30,9 +31,10 @@ export declare class PickFeature {
|
|
|
30
31
|
private controller;
|
|
31
32
|
private refusals;
|
|
32
33
|
private attempting;
|
|
33
|
-
constructor(language:
|
|
34
|
+
constructor(language: LanguageContext, timers?: Timers);
|
|
34
35
|
get isOpen(): boolean;
|
|
35
36
|
open(spec: PickSpec): void;
|
|
37
|
+
locations(places: readonly Location[], anchor: EditorPosition, title: string): void;
|
|
36
38
|
close(): void;
|
|
37
39
|
move(delta: number, extend?: boolean): void;
|
|
38
40
|
private settle;
|
package/dist/pick.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { fileUriToPath } from '@adecore/lsp';
|
|
1
2
|
import { KEY_PRIORITY } from './key-priority.js';
|
|
3
|
+
import { basenameOf } from './paths.js';
|
|
2
4
|
import { realTimers } from './timers.js';
|
|
3
5
|
const PREVIEW_DELAY_MS = 120;
|
|
4
6
|
/*
|
|
@@ -20,7 +22,6 @@ export class PickFeature {
|
|
|
20
22
|
rangeAnchor = null;
|
|
21
23
|
previewTimer;
|
|
22
24
|
controller = null;
|
|
23
|
-
/* The rows that said why they cannot be taken, by id. */
|
|
24
25
|
refusals = new Map();
|
|
25
26
|
attempting = false;
|
|
26
27
|
constructor(language, timers = realTimers) {
|
|
@@ -57,6 +58,22 @@ export class PickFeature {
|
|
|
57
58
|
this.publish(null);
|
|
58
59
|
this.schedulePreview();
|
|
59
60
|
}
|
|
61
|
+
/* Lists the places of a result under a position to choose from; choosing one goes there. */
|
|
62
|
+
locations(places, anchor, title) {
|
|
63
|
+
const rows = places.map((place, index) => ({
|
|
64
|
+
id: String(index),
|
|
65
|
+
...locationRow(place, this.language.project.pathOfLocation(place.uri))
|
|
66
|
+
}));
|
|
67
|
+
this.open({
|
|
68
|
+
anchor,
|
|
69
|
+
title,
|
|
70
|
+
groups: [{
|
|
71
|
+
title: null,
|
|
72
|
+
rows
|
|
73
|
+
}],
|
|
74
|
+
accept: id => this.language.goTo(places[Number(id)])
|
|
75
|
+
});
|
|
76
|
+
}
|
|
60
77
|
close() {
|
|
61
78
|
if (this.spec === null) {
|
|
62
79
|
return;
|
|
@@ -65,9 +82,7 @@ export class PickFeature {
|
|
|
65
82
|
this.timers.clear(this.previewTimer);
|
|
66
83
|
this.controller?.abort();
|
|
67
84
|
this.controller = null;
|
|
68
|
-
this.language.popups.
|
|
69
|
-
pick: null
|
|
70
|
-
});
|
|
85
|
+
this.language.popups.slot('pick').set(null);
|
|
71
86
|
}
|
|
72
87
|
/* Moves the active row; with `extend`, in a list of several choices, the rows between where the move began and the new row are chosen. */
|
|
73
88
|
move(delta, extend = false) {
|
|
@@ -82,7 +97,6 @@ export class PickFeature {
|
|
|
82
97
|
}
|
|
83
98
|
this.settle(id);
|
|
84
99
|
}
|
|
85
|
-
/* Makes `id` the only row the list is on. */
|
|
86
100
|
settle(id) {
|
|
87
101
|
const hadChosen = this.chosen.length > 0;
|
|
88
102
|
this.chosen = [];
|
|
@@ -302,16 +316,25 @@ export class PickFeature {
|
|
|
302
316
|
note: null,
|
|
303
317
|
refusal
|
|
304
318
|
};
|
|
305
|
-
this.language.popups.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
chosen: this.chosen
|
|
314
|
-
}
|
|
319
|
+
this.language.popups.slot('pick').set({
|
|
320
|
+
anchor: spec.anchor,
|
|
321
|
+
groups: this.visibleGroups(),
|
|
322
|
+
active: this.active,
|
|
323
|
+
preview: shown,
|
|
324
|
+
title: spec.title ?? null,
|
|
325
|
+
query: spec.filter === true ? this.query : null,
|
|
326
|
+
chosen: this.chosen
|
|
315
327
|
});
|
|
316
328
|
}
|
|
329
|
+
}
|
|
330
|
+
/* How a place reads in a list: the file and the line, with the folder it is in. */
|
|
331
|
+
function locationRow(location, stored) {
|
|
332
|
+
const path = stored ?? fileUriToPath(location.uri) ?? location.uri;
|
|
333
|
+
const name = basenameOf(path);
|
|
334
|
+
const folder = path.slice(0, Math.max(0, path.length - name.length)).replace(/\/$/, '');
|
|
335
|
+
return {
|
|
336
|
+
label: `${name}:${location.range.start.line + 1}`,
|
|
337
|
+
detail: folder,
|
|
338
|
+
path: true
|
|
339
|
+
};
|
|
317
340
|
}
|
package/dist/popups.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EditorPosition, EditorRange, EditorRect } from '@adecore/editor';
|
|
2
2
|
import type { Location } from '@adecore/lsp';
|
|
3
|
-
import { type StoreApi } from 'zustand';
|
|
4
3
|
import type { CallDirection, CallRow } from './call-hierarchy-model.ts';
|
|
5
4
|
import type { ActionEntry } from './code-actions-model.ts';
|
|
6
5
|
import type { CodeAuthorship } from './code-authors.ts';
|
|
6
|
+
import type { CompletionDocs } from './completion-model.ts';
|
|
7
7
|
import type { Problem } from './diagnostics-model.ts';
|
|
8
8
|
import type { HoverText } from './hover-content.ts';
|
|
9
9
|
import type { PeekFile, PeekSnippet } from './peek-model.ts';
|
|
@@ -32,10 +32,6 @@ export interface CompletionRow {
|
|
|
32
32
|
readonly matches: readonly number[];
|
|
33
33
|
readonly deprecated: boolean;
|
|
34
34
|
}
|
|
35
|
-
export interface CompletionDocs {
|
|
36
|
-
readonly source: string;
|
|
37
|
-
readonly text: HoverText;
|
|
38
|
-
}
|
|
39
35
|
export interface CompletionView {
|
|
40
36
|
readonly anchor: EditorPosition;
|
|
41
37
|
readonly rows: readonly CompletionRow[];
|
|
@@ -143,18 +139,27 @@ export interface WrapView {
|
|
|
143
139
|
readonly anchor: EditorPosition;
|
|
144
140
|
readonly error: string | null;
|
|
145
141
|
}
|
|
146
|
-
export interface
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
export
|
|
160
|
-
|
|
142
|
+
export interface PopupViews {
|
|
143
|
+
hover: HoverView;
|
|
144
|
+
completion: CompletionView;
|
|
145
|
+
signature: SignatureView;
|
|
146
|
+
pick: PickView;
|
|
147
|
+
rename: RenameView;
|
|
148
|
+
peek: PeekView;
|
|
149
|
+
callHierarchy: CallHierarchyView;
|
|
150
|
+
symbols: SymbolsView;
|
|
151
|
+
menu: MenuView;
|
|
152
|
+
authors: AuthorsView;
|
|
153
|
+
wrap: WrapView;
|
|
154
|
+
}
|
|
155
|
+
export declare class PopupSlot<View> {
|
|
156
|
+
private view;
|
|
157
|
+
private readonly listeners;
|
|
158
|
+
get(): View | null;
|
|
159
|
+
subscribe(listener: () => void): () => void;
|
|
160
|
+
set(view: View | null): void;
|
|
161
|
+
}
|
|
162
|
+
export declare class Popups {
|
|
163
|
+
private readonly slots;
|
|
164
|
+
slot<Name extends keyof PopupViews>(name: Name): PopupSlot<PopupViews[Name]>;
|
|
165
|
+
}
|
package/dist/popups.js
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/* One card's state with a snapshot of its own, so a card draws again only for a change of its own view. */
|
|
2
|
+
export class PopupSlot {
|
|
3
|
+
view = null;
|
|
4
|
+
listeners = new Set();
|
|
5
|
+
get() {
|
|
6
|
+
return this.view;
|
|
7
|
+
}
|
|
8
|
+
subscribe(listener) {
|
|
9
|
+
this.listeners.add(listener);
|
|
10
|
+
return () => this.listeners.delete(listener);
|
|
11
|
+
}
|
|
12
|
+
set(view) {
|
|
13
|
+
if (Object.is(view, this.view)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.view = view;
|
|
17
|
+
for (const listener of [...this.listeners]) {
|
|
18
|
+
listener();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class Popups {
|
|
23
|
+
slots = new Map();
|
|
24
|
+
slot(name) {
|
|
25
|
+
let slot = this.slots.get(name);
|
|
26
|
+
if (slot === undefined) {
|
|
27
|
+
slot = new PopupSlot();
|
|
28
|
+
this.slots.set(name, slot);
|
|
29
|
+
}
|
|
30
|
+
return slot;
|
|
31
|
+
}
|
|
16
32
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EditorContentChange, EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
|
+
export declare function comparePositions(left: EditorPosition, right: EditorPosition): number;
|
|
3
|
+
export declare function sameRange(left: EditorRange, right: EditorRange): boolean;
|
|
4
|
+
export declare function endOfInsertion(start: EditorPosition, text: string): EditorPosition;
|
|
5
|
+
export declare function shiftPosition(position: EditorPosition, change: EditorContentChange): EditorPosition;
|
|
6
|
+
export declare function shiftRange(range: EditorRange, changes: readonly EditorContentChange[]): EditorRange;
|
|
7
|
+
export declare function rangeHolds(range: EditorRange, position: EditorPosition): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function comparePositions(left, right) {
|
|
2
|
+
return left.line === right.line ? left.character - right.character : left.line - right.line;
|
|
3
|
+
}
|
|
4
|
+
export function sameRange(left, right) {
|
|
5
|
+
return comparePositions(left.start, right.start) === 0 && comparePositions(left.end, right.end) === 0;
|
|
6
|
+
}
|
|
7
|
+
/* Where an insertion of `text` at `start` ends, counting a line break of any kind once. */
|
|
8
|
+
export function endOfInsertion(start, text) {
|
|
9
|
+
const lines = text.split(/\r\n|\r|\n/);
|
|
10
|
+
return lines.length === 1 ? {
|
|
11
|
+
line: start.line,
|
|
12
|
+
character: start.character + text.length
|
|
13
|
+
} : {
|
|
14
|
+
line: start.line + lines.length - 1,
|
|
15
|
+
character: lines[lines.length - 1].length
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/* Where a position is once one change is applied to the text it was in. One inside the replaced range lands after the new text. */
|
|
19
|
+
export function shiftPosition(position, change) {
|
|
20
|
+
const {
|
|
21
|
+
start,
|
|
22
|
+
end
|
|
23
|
+
} = change.range;
|
|
24
|
+
if (comparePositions(position, start) < 0) {
|
|
25
|
+
return position;
|
|
26
|
+
}
|
|
27
|
+
const inserted = endOfInsertion(start, change.text);
|
|
28
|
+
if (comparePositions(position, end) < 0) {
|
|
29
|
+
return inserted;
|
|
30
|
+
}
|
|
31
|
+
return position.line === end.line ? {
|
|
32
|
+
line: inserted.line,
|
|
33
|
+
character: inserted.character + (position.character - end.character)
|
|
34
|
+
} : {
|
|
35
|
+
line: position.line + (inserted.line - end.line),
|
|
36
|
+
character: position.character
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function shiftRange(range, changes) {
|
|
40
|
+
let start = range.start;
|
|
41
|
+
let end = range.end;
|
|
42
|
+
for (const change of changes) {
|
|
43
|
+
start = shiftPosition(start, change);
|
|
44
|
+
end = shiftPosition(end, change);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
start,
|
|
48
|
+
end
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/* A range holds a position from its start up to and including its end, so a caret at either edge of a word is on it. An empty range holds only its own place. */
|
|
52
|
+
export function rangeHolds(range, position) {
|
|
53
|
+
return comparePositions(range.start, position) <= 0 && comparePositions(position, range.end) <= 0;
|
|
54
|
+
}
|
package/dist/postfix.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { EditorPosition } from '@adecore/editor';
|
|
2
2
|
import type { LocalCompletionItem } from './completion.ts';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CompletionFeature } from './completion.ts';
|
|
4
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
|
+
import type { PickFeature } from './pick.ts';
|
|
6
|
+
import { type InsertingSnippets } from './snippet-insert.ts';
|
|
4
7
|
interface PostfixKey {
|
|
5
8
|
readonly start: EditorPosition;
|
|
6
9
|
expand(): boolean;
|
|
7
10
|
}
|
|
11
|
+
interface PostfixPeers {
|
|
12
|
+
readonly completion: Pick<CompletionFeature, 'close' | 'showItems'>;
|
|
13
|
+
readonly pick: Pick<PickFeature, 'open'>;
|
|
14
|
+
readonly snippets: InsertingSnippets;
|
|
15
|
+
}
|
|
8
16
|
export declare class PostfixFeature {
|
|
9
17
|
private readonly language;
|
|
10
|
-
|
|
18
|
+
private readonly peers;
|
|
19
|
+
constructor(language: LanguageContext, peers: PostfixPeers);
|
|
11
20
|
key(): PostfixKey | null;
|
|
12
21
|
rows(position: EditorPosition): readonly LocalCompletionItem[];
|
|
13
22
|
private row;
|
package/dist/postfix.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isIdentifierCharacter } from './completion-model.js';
|
|
2
|
-
import { comparePositions } from './diagnostics-model.js';
|
|
3
2
|
import { lineTextOf, textBeforeOf } from './line-text.js';
|
|
3
|
+
import { comparePositions } from './positions.js';
|
|
4
4
|
import { bodyWithIndentUnit, dedentLines, indentUnitOf, insertSnippet } from './snippet-insert.js';
|
|
5
5
|
import { compileSnippet } from './snippet.js';
|
|
6
6
|
import { SNIPPET_KIND, sortAfterServer, templateContextAt } from './template-context.js';
|
|
@@ -27,8 +27,10 @@ function rowLabel(text) {
|
|
|
27
27
|
*/
|
|
28
28
|
export class PostfixFeature {
|
|
29
29
|
language;
|
|
30
|
-
|
|
30
|
+
peers;
|
|
31
|
+
constructor(language, peers) {
|
|
31
32
|
this.language = language;
|
|
33
|
+
this.peers = peers;
|
|
32
34
|
}
|
|
33
35
|
/* The key before the caret that a template of the registry applies to; null where Tab has no postfix template to expand. */
|
|
34
36
|
key() {
|
|
@@ -139,7 +141,7 @@ export class PostfixFeature {
|
|
|
139
141
|
line: candidates.dot.line,
|
|
140
142
|
character: candidates.dot.character + 1
|
|
141
143
|
};
|
|
142
|
-
this.
|
|
144
|
+
this.peers.completion.showItems(candidates.templates.map(template => this.row(template, candidates, {
|
|
143
145
|
start,
|
|
144
146
|
end: caret
|
|
145
147
|
}, template.id)), start);
|
|
@@ -156,10 +158,12 @@ export class PostfixFeature {
|
|
|
156
158
|
}
|
|
157
159
|
const {
|
|
158
160
|
editor,
|
|
159
|
-
completion,
|
|
160
|
-
pick,
|
|
161
161
|
project
|
|
162
162
|
} = this.language;
|
|
163
|
+
const {
|
|
164
|
+
completion,
|
|
165
|
+
pick
|
|
166
|
+
} = this.peers;
|
|
163
167
|
const rows = operands.map((operand, index) => ({
|
|
164
168
|
id: String(index),
|
|
165
169
|
label: rowLabel(editor.textInRange(operand.range)),
|
|
@@ -187,7 +191,7 @@ export class PostfixFeature {
|
|
|
187
191
|
editor
|
|
188
192
|
} = this.language;
|
|
189
193
|
const expression = this.expressionOf(operand);
|
|
190
|
-
return insertSnippet(this.language, bodyWithIndentUnit(template.body, indentUnitOf(editor)), [{
|
|
194
|
+
return insertSnippet(this.language, this.peers.snippets, bodyWithIndentUnit(template.body, indentUnitOf(editor)), [{
|
|
191
195
|
range: {
|
|
192
196
|
start: operand.range.start,
|
|
193
197
|
end: caret
|
|
@@ -6,7 +6,10 @@ import { EditLocations } from './edit-locations.ts';
|
|
|
6
6
|
import type { LanguageHost } from './host-types.ts';
|
|
7
7
|
import { NavigationHistory, type Place } from './navigation-history.ts';
|
|
8
8
|
import { ProjectProblems } from './project-problems.ts';
|
|
9
|
+
import { type SnippetTransformLease } from './snippet-transform-queue.ts';
|
|
9
10
|
import { TemplateRegistry } from './templates.ts';
|
|
11
|
+
import { type Timers } from './timers.ts';
|
|
12
|
+
export type LanguageServiceFactory<Service extends LanguageService = LanguageService> = (project: Pick<ProjectLanguage, 'openTextOf' | 'applyWorkspaceEdit'>) => Service;
|
|
10
13
|
export interface LanguageDocumentHandle {
|
|
11
14
|
readonly uri: string;
|
|
12
15
|
readonly service: LanguageService;
|
|
@@ -20,8 +23,8 @@ export type FileOperationTarget = string | {
|
|
|
20
23
|
readonly path: string;
|
|
21
24
|
readonly directory?: boolean;
|
|
22
25
|
};
|
|
23
|
-
export declare class ProjectLanguage {
|
|
24
|
-
readonly service:
|
|
26
|
+
export declare class ProjectLanguage<Service extends LanguageService = LanguageService> {
|
|
27
|
+
readonly service: Service;
|
|
25
28
|
readonly host: LanguageHost;
|
|
26
29
|
readonly i18n: i18n;
|
|
27
30
|
readonly folder: string;
|
|
@@ -32,14 +35,18 @@ export declare class ProjectLanguage {
|
|
|
32
35
|
readonly templates: TemplateRegistry;
|
|
33
36
|
private readonly holders;
|
|
34
37
|
private readonly files;
|
|
38
|
+
private snippetQueue;
|
|
35
39
|
panelBodyHeight: number;
|
|
36
40
|
private readonly panelListeners;
|
|
37
41
|
private pendingCaret;
|
|
38
42
|
private lastPlace;
|
|
39
43
|
private disposed;
|
|
40
44
|
private readonly subscriptions;
|
|
45
|
+
private readonly disposers;
|
|
41
46
|
private readonly workspaceResults;
|
|
42
|
-
constructor(service:
|
|
47
|
+
constructor(service: Service | LanguageServiceFactory<Service>, host?: LanguageHost);
|
|
48
|
+
onDispose(dispose: () => void): void;
|
|
49
|
+
openTextOf(uri: string): string | undefined;
|
|
43
50
|
onPanelBodyChange(listener: (height: number) => void): () => void;
|
|
44
51
|
resizePanelBody(height: number): void;
|
|
45
52
|
pathOfLocation(uri: string): string | null;
|
|
@@ -57,6 +64,7 @@ export declare class ProjectLanguage {
|
|
|
57
64
|
noteCaret(place: Place): void;
|
|
58
65
|
jumpTo(place: Place): void;
|
|
59
66
|
takeCaret(uri: string, line: number): EditorPosition | null;
|
|
67
|
+
acquireSnippetTransforms(timers?: Timers): SnippetTransformLease | null;
|
|
60
68
|
holdsFirst(uri: string, editor: Editor): boolean;
|
|
61
69
|
openEditors(): readonly {
|
|
62
70
|
uri: string;
|