@adecore/editor-react 0.22.1 → 0.23.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/dist/CallHierarchyPanel.d.ts +6 -0
- package/dist/CallHierarchyPanel.js +88 -0
- package/dist/CompletionPopup.js +11 -3
- package/dist/DiffView.d.ts +22 -0
- package/dist/DiffView.js +203 -0
- package/dist/EditorContextMenu.js +1 -0
- package/dist/EditorView.js +18 -1
- package/dist/FindReplace.d.ts +1 -1
- package/dist/FindReplace.js +41 -11
- package/dist/HoverCard.js +2 -2
- package/dist/LanguagePopups.js +4 -1
- package/dist/Markdown.d.ts +2 -1
- package/dist/Markdown.js +8 -4
- package/dist/PeekPanel.d.ts +3 -0
- package/dist/PeekPanel.js +2 -3
- package/dist/PickPopup.js +15 -2
- package/dist/RenameCard.js +10 -5
- package/dist/RenderedDocs.d.ts +9 -0
- package/dist/RenderedDocs.js +84 -0
- package/dist/SplitDiffView.d.ts +9 -0
- package/dist/SplitDiffView.js +276 -0
- package/dist/SymbolPicker.d.ts +3 -0
- package/dist/SymbolPicker.js +4 -3
- package/dist/call-hierarchy-model.d.ts +52 -0
- package/dist/call-hierarchy-model.js +99 -0
- package/dist/call-hierarchy.d.ts +42 -0
- package/dist/call-hierarchy.js +399 -0
- package/dist/code-actions-model.d.ts +2 -0
- package/dist/code-actions-model.js +12 -10
- package/dist/code-actions.js +3 -1
- package/dist/completion-model.d.ts +14 -4
- package/dist/completion-model.js +40 -33
- package/dist/completion.d.ts +4 -0
- package/dist/completion.js +257 -42
- package/dist/diagnostics.js +8 -6
- package/dist/diff-expansion.d.ts +9 -0
- package/dist/diff-expansion.js +41 -0
- package/dist/diff-overlays.d.ts +15 -0
- package/dist/diff-overlays.js +28 -0
- package/dist/diff-syntax.d.ts +16 -0
- package/dist/diff-syntax.js +49 -0
- package/dist/diff-wordmarks.d.ts +5 -0
- package/dist/diff-wordmarks.js +26 -0
- package/dist/doc-comment-model.d.ts +23 -0
- package/dist/doc-comment-model.js +291 -0
- package/dist/editor-language.d.ts +13 -1
- package/dist/editor-language.js +14 -4
- package/dist/editor-react.css +79 -0
- package/dist/format-on-type.d.ts +14 -0
- package/dist/format-on-type.js +96 -0
- package/dist/host-types.d.ts +17 -0
- package/dist/hover.d.ts +4 -0
- package/dist/hover.js +15 -2
- package/dist/index.d.ts +19 -5
- package/dist/index.js +9 -1
- package/dist/inlay-hints.d.ts +47 -2
- package/dist/inlay-hints.js +353 -16
- package/dist/language-ids.js +4 -2
- package/dist/locales/en.json +114 -3
- package/dist/locales/nl.json +114 -3
- package/dist/models.d.ts +6 -2
- package/dist/models.js +5 -1
- package/dist/patch-decorations.d.ts +27 -0
- package/dist/patch-decorations.js +182 -0
- package/dist/patch-layout.d.ts +40 -0
- package/dist/patch-layout.js +304 -0
- package/dist/peek.js +1 -0
- package/dist/pick.d.ts +1 -0
- package/dist/pick.js +11 -1
- package/dist/popups.d.ts +17 -0
- package/dist/popups.js +1 -0
- package/dist/project-language.d.ts +8 -0
- package/dist/project-language.js +34 -2
- package/dist/refresher.d.ts +1 -0
- package/dist/refresher.js +5 -0
- package/dist/rename-model.d.ts +1 -1
- package/dist/rename-model.js +3 -7
- package/dist/rename.js +5 -8
- package/dist/rendered-docs.d.ts +62 -0
- package/dist/rendered-docs.js +368 -0
- package/dist/row-host.d.ts +2 -0
- package/dist/row-host.js +11 -3
- package/dist/semantic-delta.d.ts +2 -0
- package/dist/semantic-delta.js +27 -0
- package/dist/semantic-model.js +16 -0
- package/dist/semantic-tokens.d.ts +26 -1
- package/dist/semantic-tokens.js +174 -14
- package/dist/shortcut-keys.d.ts +2 -0
- package/dist/shortcut-keys.js +6 -2
- package/dist/signature.js +1 -1
- package/dist/snippet-field-transforms.d.ts +30 -0
- package/dist/snippet-field-transforms.js +116 -0
- package/dist/snippet-indent.d.ts +2 -0
- package/dist/snippet-indent.js +49 -0
- package/dist/snippet-range-order.d.ts +3 -0
- package/dist/snippet-range-order.js +19 -0
- package/dist/snippet-session.d.ts +42 -6
- package/dist/snippet-session.js +650 -53
- package/dist/snippet-transform-client.d.ts +19 -0
- package/dist/snippet-transform-client.js +66 -0
- package/dist/snippet-transform-format.d.ts +15 -0
- package/dist/snippet-transform-format.js +302 -0
- package/dist/snippet-transform-protocol.d.ts +45 -0
- package/dist/snippet-transform-protocol.js +8 -0
- package/dist/snippet-transform-queue.d.ts +32 -0
- package/dist/snippet-transform-queue.js +173 -0
- package/dist/snippet-transform-worker.d.ts +10 -0
- package/dist/snippet-transform-worker.js +41 -0
- package/dist/snippet-variable-names.d.ts +1 -0
- package/dist/snippet-variable-names.js +36 -0
- package/dist/snippet-variables.d.ts +7 -0
- package/dist/snippet-variables.js +66 -0
- package/dist/snippet.d.ts +30 -3
- package/dist/snippet.js +402 -87
- package/dist/split-alignment.d.ts +6 -0
- package/dist/split-alignment.js +38 -0
- package/dist/split-scroll.d.ts +14 -0
- package/dist/split-scroll.js +45 -0
- package/dist/symbols.d.ts +2 -1
- package/dist/symbols.js +39 -7
- package/dist/testing.d.ts +5 -1
- package/dist/testing.js +12 -0
- package/dist/workspace-edit.d.ts +25 -3
- package/dist/workspace-edit.js +282 -143
- package/package.json +10 -5
- package/src/CallHierarchyPanel.tsx +238 -0
- package/src/CompletionPopup.tsx +12 -1
- package/src/DiffView.tsx +262 -0
- package/src/EditorContextMenu.tsx +1 -0
- package/src/EditorView.tsx +21 -2
- package/src/FindReplace.tsx +51 -13
- package/src/HoverCard.tsx +23 -21
- package/src/LanguagePopups.tsx +5 -0
- package/src/Markdown.tsx +10 -3
- package/src/PeekPanel.tsx +2 -3
- package/src/PickPopup.tsx +18 -2
- package/src/RenameCard.tsx +18 -0
- package/src/RenderedDocs.tsx +155 -0
- package/src/SplitDiffView.tsx +337 -0
- package/src/SymbolPicker.tsx +4 -3
- package/src/call-hierarchy-model.ts +158 -0
- package/src/call-hierarchy.ts +441 -0
- package/src/code-actions-model.ts +17 -11
- package/src/code-actions.ts +3 -1
- package/src/completion-model.ts +61 -35
- package/src/completion.ts +302 -42
- package/src/diagnostics.ts +8 -6
- package/src/diff-expansion.ts +49 -0
- package/src/diff-overlays.tsx +69 -0
- package/src/diff-syntax.ts +67 -0
- package/src/diff-wordmarks.ts +31 -0
- package/src/doc-comment-model.ts +336 -0
- package/src/editor-language.ts +21 -5
- package/src/editor-react.css +79 -0
- package/src/format-on-type.ts +111 -0
- package/src/host-types.ts +19 -0
- package/src/hover.ts +18 -3
- package/src/index.ts +27 -4
- package/src/inlay-hints.ts +394 -18
- package/src/language-ids.ts +4 -2
- package/src/locales/en.json +114 -3
- package/src/locales/nl.json +114 -3
- package/src/models.ts +40 -1
- package/src/patch-decorations.ts +224 -0
- package/src/patch-layout.ts +388 -0
- package/src/peek.ts +1 -0
- package/src/pick.ts +12 -1
- package/src/popups.ts +24 -0
- package/src/project-language.ts +43 -2
- package/src/refresher.ts +6 -0
- package/src/rename-model.ts +4 -8
- package/src/rename.ts +5 -8
- package/src/rendered-docs.ts +422 -0
- package/src/row-host.ts +12 -3
- package/src/semantic-delta.ts +29 -0
- package/src/semantic-model.ts +17 -0
- package/src/semantic-tokens.ts +202 -19
- package/src/shortcut-keys.ts +6 -2
- package/src/signature.ts +1 -1
- package/src/snippet-field-transforms.ts +144 -0
- package/src/snippet-indent.ts +53 -0
- package/src/snippet-range-order.ts +19 -0
- package/src/snippet-session.ts +797 -56
- package/src/snippet-transform-client.ts +84 -0
- package/src/snippet-transform-format.ts +325 -0
- package/src/snippet-transform-protocol.ts +24 -0
- package/src/snippet-transform-queue.ts +199 -0
- package/src/snippet-transform-worker.ts +58 -0
- package/src/snippet-variable-names.ts +36 -0
- package/src/snippet-variables.ts +74 -0
- package/src/snippet.ts +452 -89
- package/src/split-alignment.ts +45 -0
- package/src/split-scroll.ts +54 -0
- package/src/symbols.ts +43 -7
- package/src/testing.ts +25 -0
- package/src/workspace-edit.ts +347 -169
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Editor } from '@adecore/editor';
|
|
2
|
+
import type { DiffSourceSide } from './diff-syntax.ts';
|
|
3
|
+
|
|
4
|
+
type ScrollEditor = Pick<Editor, 'getScrollTop' | 'setScrollTop'>;
|
|
5
|
+
|
|
6
|
+
export class SplitScroll {
|
|
7
|
+
private leader: DiffSourceSide = 'new';
|
|
8
|
+
private syncing = false;
|
|
9
|
+
private readonly expected: Record<DiffSourceSide, number>;
|
|
10
|
+
|
|
11
|
+
private readonly editors: Record<DiffSourceSide, ScrollEditor>;
|
|
12
|
+
|
|
13
|
+
constructor(editors: Record<DiffSourceSide, ScrollEditor>) {
|
|
14
|
+
this.editors = editors;
|
|
15
|
+
this.expected = { old: editors.old.getScrollTop(), new: editors.new.getScrollTop() };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
drive(side: DiffSourceSide): void {
|
|
19
|
+
this.leader = side;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
changed(side: DiffSourceSide): void {
|
|
23
|
+
if (this.syncing) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const top = this.editors[side].getScrollTop();
|
|
27
|
+
if (side !== this.leader) {
|
|
28
|
+
// Native scroll echoes arrive after setScrollTop returns, including a clamped follower position.
|
|
29
|
+
if (Math.abs(top - this.expected[side]) < 1) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.leader = side;
|
|
33
|
+
}
|
|
34
|
+
this.sync();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
sync(): void {
|
|
38
|
+
const side = this.leader;
|
|
39
|
+
const other = side === 'old' ? 'new' : 'old';
|
|
40
|
+
const top = this.editors[side].getScrollTop();
|
|
41
|
+
this.expected[side] = top;
|
|
42
|
+
if (Math.abs(this.editors[other].getScrollTop() - top) < 1) {
|
|
43
|
+
this.expected[other] = this.editors[other].getScrollTop();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.syncing = true;
|
|
47
|
+
try {
|
|
48
|
+
this.editors[other].setScrollTop(top);
|
|
49
|
+
} finally {
|
|
50
|
+
this.expected[other] = this.editors[other].getScrollTop();
|
|
51
|
+
this.syncing = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/symbols.ts
CHANGED
|
@@ -27,11 +27,13 @@ export interface SymbolSpan {
|
|
|
27
27
|
readonly name: string;
|
|
28
28
|
readonly kind: number;
|
|
29
29
|
readonly range: Range;
|
|
30
|
+
/* The line of the name, when the server says where the name is. */
|
|
31
|
+
readonly nameLine?: number;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
function walk(symbols: readonly DocumentSymbol[], spans: SymbolSpan[]): void {
|
|
33
35
|
for (const symbol of symbols) {
|
|
34
|
-
spans.push({ name: symbol.name, kind: symbol.kind, range: symbol.range });
|
|
36
|
+
spans.push({ name: symbol.name, kind: symbol.kind, range: symbol.range, nameLine: symbol.selectionRange?.start.line });
|
|
35
37
|
walk(symbol.children ?? [], spans);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -49,17 +51,51 @@ export function symbolSpansOf(result: DocumentSymbolResult): SymbolSpan[] {
|
|
|
49
51
|
return (result as SymbolInformation[]).map((symbol) => ({ name: symbol.name, kind: symbol.kind, range: symbol.location.range }));
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
/* A line a declaration can have above it: blank, a comment, or an attribute. A bare `#` is no comment, since it heads a Markdown section. */
|
|
55
|
+
const PRELUDE = /^\s*(?:$|\/\/|\/\*|\*|#\[)/;
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
* The line a block is pinned by. A range may begin at the doc comment or the attributes of a declaration, so the
|
|
59
|
+
* line of the name wins, and without it the first line below the comment that holds the name.
|
|
60
|
+
*/
|
|
61
|
+
function headerLineOf({ name, range, nameLine }: SymbolSpan, lines: readonly string[] | undefined): number {
|
|
62
|
+
const { start, end } = range;
|
|
63
|
+
if (nameLine !== undefined && nameLine >= start.line && nameLine <= end.line) {
|
|
64
|
+
return nameLine;
|
|
65
|
+
}
|
|
66
|
+
if (lines === undefined) {
|
|
67
|
+
return start.line;
|
|
68
|
+
}
|
|
69
|
+
const last = Math.min(end.line, lines.length - 1);
|
|
70
|
+
let first = start.line;
|
|
71
|
+
while (first < last && PRELUDE.test(lines[first] ?? '')) {
|
|
72
|
+
first++;
|
|
73
|
+
}
|
|
74
|
+
const short = name.slice(name.lastIndexOf('\\') + 1);
|
|
75
|
+
for (let line = first; line <= last; line++) {
|
|
76
|
+
if (!PRELUDE.test(lines[line] ?? '') && (lines[line] ?? '').includes(short)) {
|
|
77
|
+
return line;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return first;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function blockOf(span: SymbolSpan, lines: readonly string[] | undefined): EditorBlock | null {
|
|
84
|
+
const { name, kind, range } = span;
|
|
53
85
|
const label = KINDS[kind];
|
|
54
86
|
// A one-line symbol has no body to pin, and a property or an enum member is part of the block around it.
|
|
55
87
|
return label === undefined || range.end.line <= range.start.line
|
|
56
88
|
? null
|
|
57
|
-
: { startLine:
|
|
89
|
+
: { startLine: headerLineOf(span, lines) + 1, endLine: range.end.line + 1, name, kind: label };
|
|
58
90
|
}
|
|
59
91
|
|
|
60
|
-
/*
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
/*
|
|
93
|
+
* The multi-line symbols of a file as blocks, outermost first, in one-based lines. The text of the document
|
|
94
|
+
* lets a block start at its declaration rather than at the comment a server counts into the symbol.
|
|
95
|
+
*/
|
|
96
|
+
export function blocksOf(result: DocumentSymbolResult, text?: string): EditorBlock[] {
|
|
97
|
+
const lines = text?.split('\n');
|
|
98
|
+
const blocks = symbolSpansOf(result).flatMap((span) => blockOf(span, lines) ?? []);
|
|
63
99
|
return blocks.sort((left, right) => left.startLine - right.startLine || right.endLine - left.endLine);
|
|
64
100
|
}
|
|
65
101
|
|
|
@@ -80,7 +116,7 @@ export class SymbolsFeature {
|
|
|
80
116
|
}
|
|
81
117
|
const result = await project.service.documentSymbols(uri, { signal });
|
|
82
118
|
if (!signal.aborted) {
|
|
83
|
-
editor.setBlocks(result === null ? null : blocksOf(result));
|
|
119
|
+
editor.setBlocks(result === null ? null : blocksOf(result, editor.getText()));
|
|
84
120
|
for (const listener of [...this.listeners]) {
|
|
85
121
|
listener(result);
|
|
86
122
|
}
|
package/src/testing.ts
CHANGED
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
type ContentChange,
|
|
11
11
|
type Disposable,
|
|
12
12
|
type ProviderOptions,
|
|
13
|
+
type CallHierarchyIncomingCall,
|
|
14
|
+
type CallHierarchyItem,
|
|
15
|
+
type CallHierarchyOutgoingCall,
|
|
13
16
|
type CodeAction,
|
|
14
17
|
type CodeActionContext,
|
|
15
18
|
type CodeLens,
|
|
@@ -200,6 +203,16 @@ export class FakeLanguageService implements LanguageService {
|
|
|
200
203
|
return this.request<TextEdit[] | null>('textDocument/rangeFormatting', uri, { range, options: formatting }, options);
|
|
201
204
|
}
|
|
202
205
|
|
|
206
|
+
onTypeFormatting(
|
|
207
|
+
uri: string,
|
|
208
|
+
position: Position,
|
|
209
|
+
ch: string,
|
|
210
|
+
formatting: FormattingOptions,
|
|
211
|
+
options: LanguageRequestOptions = {}
|
|
212
|
+
): Promise<TextEdit[] | null> {
|
|
213
|
+
return this.request<TextEdit[] | null>('textDocument/onTypeFormatting', uri, { position, ch, options: formatting }, options);
|
|
214
|
+
}
|
|
215
|
+
|
|
203
216
|
semanticTokens(uri: string, options: LanguageRequestOptions = {}): Promise<SemanticTokens | null> {
|
|
204
217
|
return this.request<SemanticTokens | null>('textDocument/semanticTokens/full', uri, {}, options);
|
|
205
218
|
}
|
|
@@ -232,6 +245,18 @@ export class FakeLanguageService implements LanguageService {
|
|
|
232
245
|
return this.request<SelectionRange[] | null>('textDocument/selectionRange', uri, { positions }, options);
|
|
233
246
|
}
|
|
234
247
|
|
|
248
|
+
prepareCallHierarchy(uri: string, position: Position, options: LanguageRequestOptions = {}): Promise<CallHierarchyItem[] | null> {
|
|
249
|
+
return this.request<CallHierarchyItem[] | null>('textDocument/prepareCallHierarchy', uri, { position }, options);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
incomingCalls(uri: string, item: CallHierarchyItem, options: LanguageRequestOptions = {}): Promise<CallHierarchyIncomingCall[] | null> {
|
|
253
|
+
return this.request<CallHierarchyIncomingCall[] | null>('callHierarchy/incomingCalls', uri, { item }, options);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
outgoingCalls(uri: string, item: CallHierarchyItem, options: LanguageRequestOptions = {}): Promise<CallHierarchyOutgoingCall[] | null> {
|
|
257
|
+
return this.request<CallHierarchyOutgoingCall[] | null>('callHierarchy/outgoingCalls', uri, { item }, options);
|
|
258
|
+
}
|
|
259
|
+
|
|
235
260
|
codeLenses(uri: string, options: LanguageRequestOptions = {}): Promise<CodeLens[] | null> {
|
|
236
261
|
return this.request<CodeLens[] | null>('textDocument/codeLens', uri, {}, options);
|
|
237
262
|
}
|