@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/src/diagnostics-model.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorMarker, EditorMarkerSeverity, EditorPosition } from '@adecore/editor';
|
|
2
2
|
import type { Diagnostic } from '@adecore/lsp';
|
|
3
|
-
import
|
|
3
|
+
import { comparePositions, rangeHolds } from './positions.ts';
|
|
4
|
+
|
|
5
|
+
export interface ProblemCounts {
|
|
6
|
+
readonly error: number;
|
|
7
|
+
readonly warning: number;
|
|
8
|
+
readonly info: number;
|
|
9
|
+
}
|
|
4
10
|
|
|
5
11
|
/* A diagnostic and the language server process that reported it. */
|
|
6
12
|
export interface Problem {
|
|
@@ -37,59 +43,6 @@ export function problemCountsOf(diagnostics: readonly Diagnostic[]): ProblemCoun
|
|
|
37
43
|
return { error: count(1), warning: count(2), info: count(3) };
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
export function comparePositions(left: EditorPosition, right: EditorPosition): number {
|
|
41
|
-
return left.line === right.line ? left.character - right.character : left.line - right.line;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function sameRange(left: EditorRange, right: EditorRange): boolean {
|
|
45
|
-
return comparePositions(left.start, right.start) === 0 && comparePositions(left.end, right.end) === 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* Where an insertion of `text` at `start` ends, counting a line break of any kind once. */
|
|
49
|
-
export function endOfInsertion(start: EditorPosition, text: string): EditorPosition {
|
|
50
|
-
const lines = text.split(/\r\n|\r|\n/);
|
|
51
|
-
|
|
52
|
-
return lines.length === 1
|
|
53
|
-
? { line: start.line, character: start.character + text.length }
|
|
54
|
-
: { line: start.line + lines.length - 1, character: lines[lines.length - 1]!.length };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* 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. */
|
|
58
|
-
export function shiftPosition(position: EditorPosition, change: EditorContentChange): EditorPosition {
|
|
59
|
-
const { start, end } = change.range;
|
|
60
|
-
|
|
61
|
-
if (comparePositions(position, start) < 0) {
|
|
62
|
-
return position;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const inserted = endOfInsertion(start, change.text);
|
|
66
|
-
|
|
67
|
-
if (comparePositions(position, end) < 0) {
|
|
68
|
-
return inserted;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return position.line === end.line
|
|
72
|
-
? { line: inserted.line, character: inserted.character + (position.character - end.character) }
|
|
73
|
-
: { line: position.line + (inserted.line - end.line), character: position.character };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function shiftRange(range: EditorRange, changes: readonly EditorContentChange[]): EditorRange {
|
|
77
|
-
let start = range.start;
|
|
78
|
-
let end = range.end;
|
|
79
|
-
|
|
80
|
-
for (const change of changes) {
|
|
81
|
-
start = shiftPosition(start, change);
|
|
82
|
-
end = shiftPosition(end, change);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return { start, end };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/* 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. */
|
|
89
|
-
export function rangeHolds(range: EditorRange, position: EditorPosition): boolean {
|
|
90
|
-
return comparePositions(range.start, position) <= 0 && comparePositions(position, range.end) <= 0;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
46
|
/* The problems under a position, worst first. A hint is not a problem, so it is left to the colors and the faded text. */
|
|
94
47
|
export function problemsAt(problems: readonly Problem[], position: EditorPosition): Problem[] {
|
|
95
48
|
const rank = (problem: Problem): number => problem.diagnostic.severity ?? 1;
|
package/src/diagnostics.ts
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import type { EditorContentChange, EditorPosition, EditorReveal } from '@adecore/editor';
|
|
2
2
|
import type { Diagnostic } from '@adecore/lsp';
|
|
3
|
-
import {
|
|
4
|
-
comparePositions,
|
|
5
|
-
markerOf,
|
|
6
|
-
neighborProblem,
|
|
7
|
-
problemCountsOf,
|
|
8
|
-
problemsAt,
|
|
9
|
-
sameRange,
|
|
10
|
-
severityOf,
|
|
11
|
-
shiftRange,
|
|
12
|
-
type Problem
|
|
13
|
-
} from './diagnostics-model.ts';
|
|
14
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
3
|
+
import { markerOf, neighborProblem, problemCountsOf, problemsAt, severityOf, type Problem, type ProblemCounts } from './diagnostics-model.ts';
|
|
15
4
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
5
|
+
import type { LanguageContext } from './language-context.ts';
|
|
6
|
+
import { comparePositions, sameRange, shiftRange } from './positions.ts';
|
|
16
7
|
import { isShortcut } from './shortcut-keys.ts';
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
readonly info: number;
|
|
9
|
+
/* The sibling features DiagnosticsFeature drives, which the editor language hands over. */
|
|
10
|
+
interface DiagnosticsPeers {
|
|
11
|
+
readonly hover: { showProblemsAt(position: EditorPosition): boolean };
|
|
22
12
|
}
|
|
23
13
|
|
|
24
14
|
/*
|
|
@@ -27,13 +17,15 @@ export interface ProblemCounts {
|
|
|
27
17
|
* before the server reports again, so what is under a squiggle is still what it was about.
|
|
28
18
|
*/
|
|
29
19
|
export class DiagnosticsFeature {
|
|
30
|
-
private readonly language:
|
|
20
|
+
private readonly language: LanguageContext;
|
|
21
|
+
private readonly peers: DiagnosticsPeers;
|
|
31
22
|
private readonly reports = new Map<string, readonly Diagnostic[]>();
|
|
32
23
|
private readonly listeners = new Set<() => void>();
|
|
33
24
|
private list: readonly Problem[] = [];
|
|
34
25
|
|
|
35
|
-
constructor(language:
|
|
26
|
+
constructor(language: LanguageContext, peers: DiagnosticsPeers) {
|
|
36
27
|
this.language = language;
|
|
28
|
+
this.peers = peers;
|
|
37
29
|
const { editor, project, uri } = language;
|
|
38
30
|
|
|
39
31
|
const reports = project.service.onDiagnostics((report) => {
|
|
@@ -94,7 +86,6 @@ export class DiagnosticsFeature {
|
|
|
94
86
|
return true;
|
|
95
87
|
}
|
|
96
88
|
|
|
97
|
-
/* Puts the caret on the first problem of the file. */
|
|
98
89
|
goToFirst(): boolean {
|
|
99
90
|
const target = neighborProblem(this.list, { line: -1, character: 0 }, 1);
|
|
100
91
|
|
|
@@ -119,7 +110,7 @@ export class DiagnosticsFeature {
|
|
|
119
110
|
const { editor, project } = this.language;
|
|
120
111
|
editor.setCaret(problem.diagnostic.range.start, reveal);
|
|
121
112
|
editor.focus();
|
|
122
|
-
this.
|
|
113
|
+
this.peers.hover.showProblemsAt(editor.getCaret());
|
|
123
114
|
const severity = project.i18n.t(`editor:language.announce.severity.${severityOf(problem.diagnostic)}`);
|
|
124
115
|
editor.announce(project.i18n.t('editor:language.announce.problem', { severity, message: problem.diagnostic.message }));
|
|
125
116
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Editor, EditorEngine, EditorTheme } from '@adecore/editor';
|
|
2
|
+
import type { DiffDocument, DiffSourceLine } from '@adecore/merge';
|
|
3
|
+
import type { Ref } from 'react';
|
|
4
|
+
import type { DiffLimits } from './diff-expansion.ts';
|
|
5
|
+
import type { DiffSourceTokens } from './diff-syntax.ts';
|
|
6
|
+
|
|
7
|
+
export interface DiffViewProps {
|
|
8
|
+
engine: EditorEngine;
|
|
9
|
+
document: DiffDocument;
|
|
10
|
+
theme: EditorTheme;
|
|
11
|
+
tokens?: DiffSourceTokens;
|
|
12
|
+
wrap?: boolean;
|
|
13
|
+
layout?: 'unified' | 'split';
|
|
14
|
+
/* Above this many displayed unified rows, split uses fixed line heights. Defaults to 2000. */
|
|
15
|
+
splitWrapLimit?: number;
|
|
16
|
+
/* A fixed-height host supplies the height; otherwise the view grows with its rows. */
|
|
17
|
+
fill?: boolean;
|
|
18
|
+
/* Positive pixels; taller content scrolls inside the editor. Ignored with fill. */
|
|
19
|
+
maxHeight?: number;
|
|
20
|
+
/* Total visible source-text budgets after unfolding; changed rows are always retained. */
|
|
21
|
+
unfoldLimits?: DiffLimits;
|
|
22
|
+
label: string;
|
|
23
|
+
/* False draws no line numbers, for a fragment whose place in its file is not known. Defaults to true. */
|
|
24
|
+
numbered?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
ref?: Ref<HTMLDivElement>;
|
|
27
|
+
onMount?(editor: Editor, side?: 'old' | 'new'): void | (() => void);
|
|
28
|
+
/* Runs per editor like `onMount`, with a way to ask where its caret stands in the new file, for a host that opens the file there. */
|
|
29
|
+
onSource?(source: DiffSource): void | (() => void);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface DiffSource {
|
|
33
|
+
readonly editor: Editor;
|
|
34
|
+
/* `old` or `new` in split, absent in unified. */
|
|
35
|
+
readonly side?: 'old' | 'new';
|
|
36
|
+
/* The line and column of the new file under the caret, or null where the new file has none. */
|
|
37
|
+
at(): DiffSourceLine | null;
|
|
38
|
+
}
|
package/src/doc-comment-model.ts
CHANGED
|
@@ -33,10 +33,8 @@ const ALIASES: Readonly<Record<string, string>> = {
|
|
|
33
33
|
link: 'see'
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
/* Tags that carry a type before their subject. */
|
|
37
36
|
const TYPED = new Set(['param', 'property', 'return', 'throws', 'var', 'type', 'yield', 'template', 'this']);
|
|
38
37
|
|
|
39
|
-
/* Tags whose first word is the thing they are about. */
|
|
40
38
|
const SUBJECT_FIRST = new Set(['param', 'property', 'var', 'template']);
|
|
41
39
|
|
|
42
40
|
const TAG_START = /^@([A-Za-z][\w-]*)(?::[\w-]+)?[ \t]*(.*)$/;
|
package/src/document-colors.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { EditorContentChange, EditorInlayClick, EditorInlayHint } from '@adecore/editor';
|
|
2
2
|
import type { Color, ColorInformation, ColorPresentation, TextEdit } from '@adecore/lsp';
|
|
3
3
|
import { DocumentQuery } from './document-query.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
|
+
import type { PickFeature } from './pick.ts';
|
|
5
6
|
import { realTimers, type Timers } from './timers.ts';
|
|
6
7
|
|
|
7
8
|
const METHOD = 'textDocument/documentColor';
|
|
@@ -33,24 +34,30 @@ function hexOf(color: Color): string {
|
|
|
33
34
|
return `#${part(color.red)}${part(color.green)}${part(color.blue)}`;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
export function presentationEdits(presentation: ColorPresentation, information: ColorInformation): TextEdit[] {
|
|
37
|
+
function presentationEdits(presentation: ColorPresentation, information: ColorInformation): TextEdit[] {
|
|
38
38
|
return [presentation.textEdit ?? { range: information.range, newText: presentation.label }, ...(presentation.additionalTextEdits ?? [])];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/* The sibling features DocumentColorsFeature drives, which the editor language hands over. */
|
|
42
|
+
interface DocumentColorsPeers {
|
|
43
|
+
readonly pick: Pick<PickFeature, 'open'>;
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
/*
|
|
42
47
|
* The colors a server finds in the text, such as `#ff0000` in a stylesheet, each with a swatch before it. A press on
|
|
43
48
|
* a swatch lists the ways the server writes that color, so `rgb()` can become `#hex`, and offers a color of the
|
|
44
49
|
* platform's picker, which keeps the way the color was written when the server offers it.
|
|
45
50
|
*/
|
|
46
51
|
export class DocumentColorsFeature {
|
|
47
|
-
private readonly language:
|
|
52
|
+
private readonly language: LanguageContext;
|
|
53
|
+
private readonly peers: DocumentColorsPeers;
|
|
48
54
|
private colors: readonly ColorInformation[] = [];
|
|
49
55
|
private readonly query: DocumentQuery<ColorInformation[]>;
|
|
50
56
|
private enabled = true;
|
|
51
57
|
|
|
52
|
-
constructor(language:
|
|
58
|
+
constructor(language: LanguageContext, peers: DocumentColorsPeers, timers: Timers = realTimers) {
|
|
53
59
|
this.language = language;
|
|
60
|
+
this.peers = peers;
|
|
54
61
|
this.query = new DocumentQuery(
|
|
55
62
|
language,
|
|
56
63
|
timers,
|
|
@@ -136,7 +143,8 @@ export class DocumentColorsFeature {
|
|
|
136
143
|
if (!this.colors.includes(information)) {
|
|
137
144
|
return;
|
|
138
145
|
}
|
|
139
|
-
const {
|
|
146
|
+
const { project } = this.language;
|
|
147
|
+
const { pick } = this.peers;
|
|
140
148
|
const rows = presentations.map((presentation, index) => ({ id: String(index), label: presentation.label, detail: '' }));
|
|
141
149
|
pick.open({
|
|
142
150
|
anchor: information.range.start,
|
package/src/document-links.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
2
|
import type { DocumentLink } from '@adecore/lsp';
|
|
3
|
-
import { comparePositions } from './diagnostics-model.ts';
|
|
4
3
|
import { DocumentQuery } from './document-query.ts';
|
|
5
|
-
import type {
|
|
4
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
|
+
import { comparePositions } from './positions.ts';
|
|
6
6
|
import { realTimers, type Timers } from './timers.ts';
|
|
7
7
|
|
|
8
8
|
const METHOD = 'textDocument/documentLink';
|
|
9
9
|
const RESOLVE = 'documentLink/resolve';
|
|
10
|
-
/* How long after the last edit the links are asked again. */
|
|
11
10
|
const DELAY_MS = 500;
|
|
12
11
|
/* `#L12`, `#12` or `#L12,4`: a line, from one, and a column, from one, the form editors write into a link. */
|
|
13
12
|
const LINE_FRAGMENT = /^#L?(\d+)(?:[,:C](\d+))?$/i;
|
|
@@ -36,11 +35,11 @@ function opensInEditor(target: string): boolean {
|
|
|
36
35
|
* A link without a target asks the server for it first.
|
|
37
36
|
*/
|
|
38
37
|
export class DocumentLinksFeature {
|
|
39
|
-
private readonly language:
|
|
38
|
+
private readonly language: LanguageContext;
|
|
40
39
|
private links: readonly DocumentLink[] = [];
|
|
41
40
|
private readonly query: DocumentQuery<DocumentLink[]>;
|
|
42
41
|
|
|
43
|
-
constructor(language:
|
|
42
|
+
constructor(language: LanguageContext, timers: Timers = realTimers) {
|
|
44
43
|
this.language = language;
|
|
45
44
|
this.query = new DocumentQuery(
|
|
46
45
|
language,
|
|
@@ -113,7 +112,7 @@ export class DocumentLinksFeature {
|
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
/* Opens a file or a document of a server in the editor, and a web address through the host. */
|
|
116
|
-
|
|
115
|
+
function openTarget(language: LanguageContext, target: string, selection?: EditorRange): void {
|
|
117
116
|
if (!opensInEditor(target)) {
|
|
118
117
|
const { host } = language.project;
|
|
119
118
|
if (host.openExternal !== undefined) {
|
package/src/document-query.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageContext } from './language-context.ts';
|
|
2
2
|
import type { Timers } from './timers.ts';
|
|
3
3
|
|
|
4
4
|
/*
|
|
@@ -7,7 +7,7 @@ import type { Timers } from './timers.ts';
|
|
|
7
7
|
* text that is gone; an answer for an older text is dropped.
|
|
8
8
|
*/
|
|
9
9
|
export class DocumentQuery<Value> {
|
|
10
|
-
private readonly language:
|
|
10
|
+
private readonly language: LanguageContext;
|
|
11
11
|
private readonly timers: Timers;
|
|
12
12
|
private readonly delay: number;
|
|
13
13
|
private readonly ask: (signal: AbortSignal) => Promise<Value | null>;
|
|
@@ -17,7 +17,7 @@ export class DocumentQuery<Value> {
|
|
|
17
17
|
private generation = 0;
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
|
-
language:
|
|
20
|
+
language: LanguageContext,
|
|
21
21
|
timers: Timers,
|
|
22
22
|
delay: number,
|
|
23
23
|
ask: (signal: AbortSignal) => Promise<Value | null>,
|
package/src/edit-locations.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EditorContentChange, EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
|
+
import { comparePositions, endOfInsertion } from './positions.ts';
|
|
2
3
|
|
|
3
4
|
/* Where an edit left the carets of one file, the primary last. */
|
|
4
5
|
export interface EditPlace {
|
|
@@ -18,33 +19,19 @@ function isSame(left: EditPlace, right: EditPlace | null): boolean {
|
|
|
18
19
|
);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
function before(left: EditorPosition, right: EditorPosition): boolean {
|
|
22
|
-
return left.line < right.line || (left.line === right.line && left.character < right.character);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/* Where the text of a change ends, in the text after the change. */
|
|
26
|
-
function endOf(change: EditorContentChange): EditorPosition {
|
|
27
|
-
const lines = change.text.split('\n');
|
|
28
|
-
const { start } = change.range;
|
|
29
|
-
|
|
30
|
-
return lines.length === 1
|
|
31
|
-
? { line: start.line, character: start.character + change.text.length }
|
|
32
|
-
: { line: start.line + lines.length - 1, character: lines[lines.length - 1]!.length };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
22
|
/* A position after a change: untouched in front of it, at the start when the change replaced the text around it, moved along behind it. */
|
|
36
23
|
function follow(position: EditorPosition, change: EditorContentChange): EditorPosition {
|
|
37
24
|
const { start, end } = change.range;
|
|
38
25
|
|
|
39
|
-
if (
|
|
26
|
+
if (comparePositions(start, position) >= 0) {
|
|
40
27
|
return position;
|
|
41
28
|
}
|
|
42
29
|
|
|
43
|
-
if (
|
|
30
|
+
if (comparePositions(position, end) < 0) {
|
|
44
31
|
return start;
|
|
45
32
|
}
|
|
46
33
|
|
|
47
|
-
const landed =
|
|
34
|
+
const landed = endOfInsertion(start, change.text);
|
|
48
35
|
|
|
49
36
|
return position.line === end.line
|
|
50
37
|
? { line: landed.line, character: landed.character + position.character - end.character }
|
|
@@ -70,7 +57,6 @@ export class EditLocations {
|
|
|
70
57
|
return this.entries;
|
|
71
58
|
}
|
|
72
59
|
|
|
73
|
-
/* An edit left the carets here. */
|
|
74
60
|
record(place: EditPlace): void {
|
|
75
61
|
const last = this.entries.at(-1);
|
|
76
62
|
|
|
@@ -144,7 +130,6 @@ export class EditLocations {
|
|
|
144
130
|
});
|
|
145
131
|
}
|
|
146
132
|
|
|
147
|
-
/* Drops the places of files that are gone. */
|
|
148
133
|
forget(matches: (uri: string) => boolean): void {
|
|
149
134
|
this.entries = this.entries.filter((entry) => !matches(entry.uri));
|
|
150
135
|
this.index = this.entries.length;
|
package/src/editor-language.ts
CHANGED
|
@@ -18,15 +18,16 @@ import { HoverFeature } from './hover.ts';
|
|
|
18
18
|
import { InlayHintsFeature } from './inlay-hints.ts';
|
|
19
19
|
import { InlineCompletionFeature } from './inline-completion.ts';
|
|
20
20
|
import { KeyDispatcher } from './key-priority.ts';
|
|
21
|
+
import type { LanguageContext } from './language-context.ts';
|
|
21
22
|
import { LinkedEditingFeature } from './linked-editing.ts';
|
|
22
23
|
import { TemplatesFeature } from './live-templates.ts';
|
|
23
24
|
import { MarkupFeature } from './markup.ts';
|
|
24
25
|
import type { Place } from './navigation-history.ts';
|
|
25
|
-
import { NavigationFeature
|
|
26
|
+
import { NavigationFeature } from './navigation.ts';
|
|
26
27
|
import { PasteHistoryFeature } from './paste-history.ts';
|
|
27
28
|
import { PeekFeature } from './peek.ts';
|
|
28
29
|
import { PickFeature } from './pick.ts';
|
|
29
|
-
import {
|
|
30
|
+
import { Popups } from './popups.ts';
|
|
30
31
|
import type { LanguageDocumentHandle, ProjectLanguage } from './project-language.ts';
|
|
31
32
|
import { RenameFeature } from './rename.ts';
|
|
32
33
|
import { RenderedDocsFeature } from './rendered-docs.ts';
|
|
@@ -40,26 +41,29 @@ import { SymbolPickerFeature } from './symbol-picker.ts';
|
|
|
40
41
|
import { SymbolsFeature } from './symbols.ts';
|
|
41
42
|
import { realTimers, type Timers } from './timers.ts';
|
|
42
43
|
|
|
43
|
-
/* How long the edits servers want before a save are waited for. */
|
|
44
44
|
const SAVE_PARTICIPANT_MS = 1_000;
|
|
45
45
|
|
|
46
46
|
/* What an app tunes about the features of one editor. */
|
|
47
|
-
export interface EditorLanguageOptions {
|
|
47
|
+
export interface EditorLanguageOptions<App extends object = {}> {
|
|
48
48
|
/* Where a document counts as large for semantic tokens. */
|
|
49
49
|
semanticTokens?: SemanticTokensOptions;
|
|
50
50
|
/* False for a document no server serves: it counts as open in the project and the features stay inert. True by default. */
|
|
51
51
|
serve?: boolean;
|
|
52
|
+
/*
|
|
53
|
+
* The app's own features for this editor, built once the shared ones are, so it may use every one of them. They
|
|
54
|
+
* come back as `language.app`, which is not set yet while this runs. An app that drives the editor's keys does so
|
|
55
|
+
* through `onKey` and `onServedKey`, and one that suggests code adds a source to `inlineCompletion`.
|
|
56
|
+
*/
|
|
57
|
+
features?(language: EditorLanguage): App;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
/*
|
|
55
61
|
* The one place that connects an editor to the language servers: it opens the file's document for
|
|
56
62
|
* the editor and lets go of it again. Every language feature of the editor hangs off this object.
|
|
57
63
|
*/
|
|
58
|
-
export class EditorLanguage {
|
|
64
|
+
export class EditorLanguage<App extends object = {}> implements LanguageContext {
|
|
59
65
|
readonly editor: Editor;
|
|
60
66
|
readonly apple: boolean;
|
|
61
|
-
readonly keymap: Keymap;
|
|
62
|
-
readonly shortcuts: ReturnType<typeof shortcutsOf>;
|
|
63
67
|
readonly project: ProjectLanguage;
|
|
64
68
|
readonly document: LanguageDocumentHandle;
|
|
65
69
|
readonly languageId: string;
|
|
@@ -68,7 +72,7 @@ export class EditorLanguage {
|
|
|
68
72
|
readonly served: boolean;
|
|
69
73
|
|
|
70
74
|
/* What the features of this editor have open over it: the hover card, the suggestions, the signature. */
|
|
71
|
-
readonly popups =
|
|
75
|
+
readonly popups = new Popups();
|
|
72
76
|
|
|
73
77
|
readonly diagnostics: DiagnosticsFeature;
|
|
74
78
|
readonly hover: HoverFeature;
|
|
@@ -99,55 +103,72 @@ export class EditorLanguage {
|
|
|
99
103
|
readonly colors: DocumentColorsFeature;
|
|
100
104
|
readonly linkedEditing: LinkedEditingFeature;
|
|
101
105
|
readonly inlineCompletion: InlineCompletionFeature;
|
|
106
|
+
|
|
107
|
+
/* What the `features` option of the app built. */
|
|
108
|
+
readonly app: App;
|
|
102
109
|
private readonly disposers: Array<() => void> = [];
|
|
103
110
|
private readonly keys = new KeyDispatcher();
|
|
104
111
|
private readonly timers: Timers;
|
|
105
112
|
private disposed = false;
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
private resolvedShortcuts: { readonly keymap: Keymap; readonly shortcuts: ReturnType<typeof shortcutsOf> } | null = null;
|
|
114
|
+
|
|
115
|
+
constructor(
|
|
116
|
+
project: ProjectLanguage,
|
|
117
|
+
editor: Editor,
|
|
118
|
+
uri: string,
|
|
119
|
+
languageId: string,
|
|
120
|
+
timers: Timers = realTimers,
|
|
121
|
+
options: EditorLanguageOptions<App> = {}
|
|
122
|
+
) {
|
|
108
123
|
this.editor = editor;
|
|
109
124
|
this.apple = project.host.apple ?? false;
|
|
110
|
-
this.keymap = project.host.keymap ?? KEYMAP;
|
|
111
|
-
this.shortcuts = shortcutsOf(this.keymap, this.apple);
|
|
112
125
|
this.project = project;
|
|
113
126
|
this.languageId = languageId;
|
|
114
127
|
this.served = options.serve ?? true;
|
|
115
128
|
this.document = project.acquire(uri, languageId, editor, { serve: this.served });
|
|
116
129
|
this.timers = timers;
|
|
117
130
|
this.onDispose(editor.onKeyDown((event) => this.keys.dispatch(event)));
|
|
131
|
+
// A feature declares the siblings it drives as its `peers` and reads them when it acts; only a constructor that
|
|
132
|
+
// subscribes to one (code actions to diagnostics, templates to completion) needs that sibling built above it.
|
|
118
133
|
this.pick = new PickFeature(this, timers);
|
|
119
|
-
this.diagnostics = new DiagnosticsFeature(this);
|
|
120
|
-
this.hover = new HoverFeature(this, timers);
|
|
121
|
-
this.completion = new CompletionFeature(this, timers);
|
|
122
|
-
this.snippets = new SnippetFeature(this, timers);
|
|
123
|
-
this.markup = new MarkupFeature(this);
|
|
124
|
-
this.templates = new TemplatesFeature(this);
|
|
125
|
-
this.surround = new SurroundFeature(this);
|
|
134
|
+
this.diagnostics = new DiagnosticsFeature(this, this);
|
|
135
|
+
this.hover = new HoverFeature(this, this, timers);
|
|
136
|
+
this.completion = new CompletionFeature(this, this, timers);
|
|
137
|
+
this.snippets = new SnippetFeature(this, this, timers);
|
|
138
|
+
this.markup = new MarkupFeature(this, this);
|
|
139
|
+
this.templates = new TemplatesFeature(this, this);
|
|
140
|
+
this.surround = new SurroundFeature(this, this);
|
|
126
141
|
this.signature = new SignatureFeature(this, timers);
|
|
127
142
|
this.highlights = new HighlightsFeature(this, timers);
|
|
128
143
|
this.symbols = new SymbolsFeature(this, timers);
|
|
129
144
|
new SelectionRangesFeature(this);
|
|
130
145
|
new SemanticTokensFeature(this, timers, options.semanticTokens);
|
|
131
|
-
this.inlayHints = new InlayHintsFeature(this, timers);
|
|
132
|
-
this.codeActions = new CodeActionsFeature(this, timers);
|
|
146
|
+
this.inlayHints = new InlayHintsFeature(this, this, timers);
|
|
147
|
+
this.codeActions = new CodeActionsFeature(this, this, timers);
|
|
133
148
|
this.rename = new RenameFeature(this);
|
|
134
149
|
// Before navigation, whose Mod+click goes to a definition: a link under the pointer goes first.
|
|
135
150
|
this.links = new DocumentLinksFeature(this, timers);
|
|
136
|
-
this.colors = new DocumentColorsFeature(this, timers);
|
|
151
|
+
this.colors = new DocumentColorsFeature(this, this, timers);
|
|
137
152
|
this.linkedEditing = new LinkedEditingFeature(this, timers);
|
|
138
153
|
this.inlineCompletion = new InlineCompletionFeature(this, timers);
|
|
139
|
-
this.navigation = new NavigationFeature(this);
|
|
140
|
-
this.peek = new PeekFeature(this, timers);
|
|
141
|
-
this.callHierarchy = new CallHierarchyFeature(this, timers);
|
|
154
|
+
this.navigation = new NavigationFeature(this, this);
|
|
155
|
+
this.peek = new PeekFeature(this, this, timers);
|
|
156
|
+
this.callHierarchy = new CallHierarchyFeature(this, this, timers);
|
|
142
157
|
this.symbolPicker = new SymbolPickerFeature(this);
|
|
143
|
-
this.contextMenu = new ContextMenuFeature(this);
|
|
144
|
-
this.history = new HistoryFeature(this);
|
|
145
|
-
this.definitionLink = new DefinitionLinkFeature(this);
|
|
146
|
-
this.codeVision = new CodeVisionFeature(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
this.contextMenu = new ContextMenuFeature(this, this);
|
|
159
|
+
this.history = new HistoryFeature(this, this);
|
|
160
|
+
this.definitionLink = new DefinitionLinkFeature(this, this);
|
|
161
|
+
this.codeVision = new CodeVisionFeature(
|
|
162
|
+
this,
|
|
163
|
+
{ onSymbols: (listener) => this.symbols.onResult(listener), peek: { open: (position) => this.peek.open(position) } },
|
|
164
|
+
timers
|
|
165
|
+
);
|
|
166
|
+
this.formatOnType = new FormatOnTypeFeature(this, this);
|
|
167
|
+
this.renderedDocs = new RenderedDocsFeature(this, this, timers);
|
|
168
|
+
this.pasteHistory = new PasteHistoryFeature(this, this);
|
|
150
169
|
new FoldingFeature(this, (listener) => this.symbols.onResult(listener), timers);
|
|
170
|
+
// Without `features` the app has nothing to hold, and `App` is the empty object it defaults to.
|
|
171
|
+
this.app = options.features?.(this) ?? ({} as App);
|
|
151
172
|
|
|
152
173
|
const copies = editor.onCopy?.((copy) => project.clipboard.add(copy.text, { wholeLines: copy.wholeLines }));
|
|
153
174
|
|
|
@@ -161,6 +182,22 @@ export class EditorLanguage {
|
|
|
161
182
|
this.onDispose(editor.onCaret((position) => this.placeOpenedCaret(position)));
|
|
162
183
|
}
|
|
163
184
|
|
|
185
|
+
/* Read from the host on every use, so a rebound key reaches an editor that is already open. */
|
|
186
|
+
get keymap(): Keymap {
|
|
187
|
+
return this.project.host.keymap ?? KEYMAP;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* The keymap's shortcuts, resolved again only when the host hands a new keymap. */
|
|
191
|
+
get shortcuts(): ReturnType<typeof shortcutsOf> {
|
|
192
|
+
const keymap = this.keymap;
|
|
193
|
+
|
|
194
|
+
if (this.resolvedShortcuts?.keymap !== keymap) {
|
|
195
|
+
this.resolvedShortcuts = { keymap, shortcuts: shortcutsOf(keymap, this.apple) };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return this.resolvedShortcuts.shortcuts;
|
|
199
|
+
}
|
|
200
|
+
|
|
164
201
|
get uri(): string {
|
|
165
202
|
return this.document.uri;
|
|
166
203
|
}
|
|
@@ -200,12 +237,6 @@ export class EditorLanguage {
|
|
|
200
237
|
}
|
|
201
238
|
}
|
|
202
239
|
|
|
203
|
-
/* Lists places under a position to choose from; choosing one goes there. */
|
|
204
|
-
locations(places: readonly Location[], anchor: EditorPosition, title: string): void {
|
|
205
|
-
const rows = places.map((place, index) => ({ id: String(index), ...locationRow(place, this.project.pathOfLocation(place.uri)) }));
|
|
206
|
-
this.pick.open({ anchor, title, groups: [{ title: null, rows }], accept: (id) => this.goTo(places[Number(id)]!) });
|
|
207
|
-
}
|
|
208
|
-
|
|
209
240
|
/*
|
|
210
241
|
* Runs `listener` once the document is open and again whenever the service says what it can ask for
|
|
211
242
|
* this document changed. A service that is ready before the document opens never says so, so the
|
|
@@ -243,6 +274,11 @@ export class EditorLanguage {
|
|
|
243
274
|
return this.keys.add(handler, priority);
|
|
244
275
|
}
|
|
245
276
|
|
|
277
|
+
/* Like `onKey`, for a feature that needs a server behind the document: the editor of a document no server serves never gives it a key. */
|
|
278
|
+
onServedKey(handler: EditorKeyHandler, priority = 0): () => void {
|
|
279
|
+
return this.onKey((event) => this.served && handler(event), priority);
|
|
280
|
+
}
|
|
281
|
+
|
|
246
282
|
/*
|
|
247
283
|
* Lets the servers in before the host writes the file: tells them a save is coming and applies the edits they
|
|
248
284
|
* want made first, such as organized imports. A server that has not answered within a second is passed over,
|
|
@@ -268,7 +304,6 @@ export class EditorLanguage {
|
|
|
268
304
|
}
|
|
269
305
|
}
|
|
270
306
|
|
|
271
|
-
/* Runs `dispose` when the editor lets go of its document. */
|
|
272
307
|
onDispose(dispose: () => void): void {
|
|
273
308
|
this.disposers.push(dispose);
|
|
274
309
|
}
|
package/src/emmet.ts
CHANGED
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
import { extract, markup, markupAbbreviation, resolveConfig, type MarkupAbbreviationNode } from 'emmet';
|
|
5
5
|
import type { MarkupSyntax } from './markup-context.ts';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface AbbreviationOptions {
|
|
8
8
|
readonly syntax: MarkupSyntax;
|
|
9
|
-
/* One level of indentation inside the expansion. */
|
|
10
9
|
readonly indent: string;
|
|
11
10
|
/* Lines the abbreviation wraps; a repeated element without a count takes one line each. */
|
|
12
11
|
readonly wrap?: readonly string[];
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
interface FoundAbbreviation {
|
|
16
15
|
readonly abbreviation: string;
|
|
17
16
|
/* UTF-16 columns of the line, `end` past the caret when brackets the editor closed follow it. */
|
|
18
17
|
readonly start: number;
|
package/src/folding.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EditorFoldRangeHint, EditorFoldSymbol } from '@adecore/editor';
|
|
2
2
|
import type { DocumentSymbolResult, FoldingRange } from '@adecore/lsp';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
4
4
|
import { Refresher } from './refresher.ts';
|
|
5
5
|
import { symbolSpansOf } from './symbols.ts';
|
|
6
6
|
import { realTimers, type Timers } from './timers.ts';
|
|
@@ -23,8 +23,7 @@ const BODIES: Readonly<Record<number, EditorFoldSymbol['body']>> = {
|
|
|
23
23
|
23: 'class'
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
export function foldSymbolsOf(result: DocumentSymbolResult): EditorFoldSymbol[] {
|
|
26
|
+
function foldSymbolsOf(result: DocumentSymbolResult): EditorFoldSymbol[] {
|
|
28
27
|
return symbolSpansOf(result).flatMap(({ kind, range }) => {
|
|
29
28
|
const body = BODIES[kind];
|
|
30
29
|
|
|
@@ -54,9 +53,9 @@ export class FoldingFeature {
|
|
|
54
53
|
private symbols: EditorFoldSymbol[] = [];
|
|
55
54
|
private ranges: EditorFoldRangeHint[] = [];
|
|
56
55
|
private readonly refresher: Refresher;
|
|
57
|
-
private readonly language:
|
|
56
|
+
private readonly language: LanguageContext;
|
|
58
57
|
|
|
59
|
-
constructor(language:
|
|
58
|
+
constructor(language: LanguageContext, onSymbols: (listener: (result: DocumentSymbolResult) => void) => () => void, timers: Timers = realTimers) {
|
|
60
59
|
this.language = language;
|
|
61
60
|
const { editor, uri } = language;
|
|
62
61
|
|