@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/snippet-session.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { EditorApplyEditsOptions, EditorContentChange, EditorPosition, EditorRange, EditorTextChange } from '@adecore/editor';
|
|
2
|
-
import { comparePositions, endOfInsertion, rangeHolds, sameRange, shiftPosition } from './diagnostics-model.ts';
|
|
3
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
4
2
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
4
|
import { textBeforeOf } from './line-text.ts';
|
|
5
|
+
import type { PickFeature } from './pick.ts';
|
|
6
|
+
import { comparePositions, endOfInsertion, rangeHolds, sameRange, shiftPosition } from './positions.ts';
|
|
6
7
|
import { SnippetFieldTransforms, type FieldTransformTarget } from './snippet-field-transforms.ts';
|
|
7
8
|
import { compareSnippetOrder, snippetOrderOf } from './snippet-range-order.ts';
|
|
8
9
|
import { SnippetTransformError } from './snippet-transform-client.ts';
|
|
9
10
|
import { MAX_TRANSFORM_CHARACTERS, type SnippetTransformJob } from './snippet-transform-protocol.ts';
|
|
10
|
-
import {
|
|
11
|
+
import type { SnippetTransformLease } from './snippet-transform-queue.ts';
|
|
11
12
|
import type { SnippetField, SnippetStop, SnippetTransform } from './snippet.ts';
|
|
12
13
|
import { realTimers, type Timers } from './timers.ts';
|
|
13
14
|
|
|
@@ -76,14 +77,20 @@ interface Frame {
|
|
|
76
77
|
readonly exits: Map<number, number>;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
interface SnippetInsertion {
|
|
80
81
|
readonly start: EditorPosition;
|
|
81
82
|
readonly text: string;
|
|
82
83
|
readonly stops: readonly SnippetStop[];
|
|
83
84
|
readonly fields?: readonly SnippetField[];
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
// Without a project the snippets run no transforms and choose no words; keys and popups always come as an editor's language gives them.
|
|
88
|
+
type SnippetHost = Pick<LanguageContext, 'editor' | 'onDispose' | 'popups' | 'onKey'> & Partial<Pick<LanguageContext, 'project'>>;
|
|
89
|
+
|
|
90
|
+
/* The choice list. */
|
|
91
|
+
interface SnippetPeers {
|
|
92
|
+
readonly pick: Pick<PickFeature, 'close' | 'open'>;
|
|
93
|
+
}
|
|
87
94
|
|
|
88
95
|
const MAX_FRAMES = 8;
|
|
89
96
|
const MAX_RANGES = 1000;
|
|
@@ -185,6 +192,7 @@ function activeOwners(active: readonly SessionRange[], changes: readonly EditorC
|
|
|
185
192
|
|
|
186
193
|
export class SnippetFeature {
|
|
187
194
|
private readonly language: SnippetHost;
|
|
195
|
+
private readonly peers: SnippetPeers;
|
|
188
196
|
private frames: Frame[] = [];
|
|
189
197
|
private placed: SessionRange[] = [];
|
|
190
198
|
private visiting = false;
|
|
@@ -202,19 +210,16 @@ export class SnippetFeature {
|
|
|
202
210
|
map: <Range extends EditorRange>(range: Range, parent?: (target: FieldTransformTarget) => boolean) => Range;
|
|
203
211
|
} | null = null;
|
|
204
212
|
|
|
205
|
-
constructor(language: SnippetHost, timers: Timers = realTimers) {
|
|
213
|
+
constructor(language: SnippetHost, peers: SnippetPeers, timers: Timers = realTimers) {
|
|
206
214
|
this.language = language;
|
|
207
|
-
this.
|
|
215
|
+
this.peers = peers;
|
|
216
|
+
this.transforms = language.project === undefined ? null : language.project.acquireSnippetTransforms(timers);
|
|
208
217
|
const { editor } = language;
|
|
209
218
|
this.fieldTransforms = new SnippetFieldTransforms(editor, this.transforms, (targets, values) => this.applyFieldTransforms(targets, values));
|
|
210
219
|
|
|
211
220
|
const key = (event: KeyboardEvent): boolean => this.key(event);
|
|
212
221
|
|
|
213
|
-
const offs = [
|
|
214
|
-
language.onKey === undefined ? editor.onKeyDown(key) : language.onKey(key, KEY_PRIORITY.snippets),
|
|
215
|
-
editor.onTextChange((change) => this.edited(change)),
|
|
216
|
-
editor.onCaret(() => this.moved())
|
|
217
|
-
];
|
|
222
|
+
const offs = [language.onKey(key, KEY_PRIORITY.snippets), editor.onTextChange((change) => this.edited(change)), editor.onCaret(() => this.moved())];
|
|
218
223
|
|
|
219
224
|
language.onDispose(() => {
|
|
220
225
|
this.transforms?.dispose();
|
|
@@ -414,10 +419,10 @@ export class SnippetFeature {
|
|
|
414
419
|
}
|
|
415
420
|
|
|
416
421
|
private closeChoices(): void {
|
|
417
|
-
const view = this.language.popups
|
|
422
|
+
const view = this.language.popups.slot('pick').get();
|
|
418
423
|
|
|
419
424
|
if (this.choicePrefix !== null && view?.groups.some((group) => group.rows.some((row) => row.id.startsWith(this.choicePrefix!)))) {
|
|
420
|
-
this.
|
|
425
|
+
this.peers.pick.close();
|
|
421
426
|
}
|
|
422
427
|
|
|
423
428
|
this.choicePrefix = null;
|
|
@@ -477,7 +482,6 @@ export class SnippetFeature {
|
|
|
477
482
|
}
|
|
478
483
|
}
|
|
479
484
|
|
|
480
|
-
/* Says which field the caret moved to, with the number of choices when the field is a list. */
|
|
481
485
|
private announceField(frame: Frame, index: number): void {
|
|
482
486
|
const i18n = this.language.project?.i18n;
|
|
483
487
|
|
|
@@ -503,7 +507,7 @@ export class SnippetFeature {
|
|
|
503
507
|
private openChoices(frame: Frame, activeChoice?: number): void {
|
|
504
508
|
const field = this.fieldOf(frame);
|
|
505
509
|
|
|
506
|
-
if (field?.choices === undefined || field.choices.length === 0
|
|
510
|
+
if (field?.choices === undefined || field.choices.length === 0) {
|
|
507
511
|
return;
|
|
508
512
|
}
|
|
509
513
|
|
|
@@ -511,7 +515,7 @@ export class SnippetFeature {
|
|
|
511
515
|
const prefix = `snippet-${token}-`;
|
|
512
516
|
this.choicePrefix = prefix;
|
|
513
517
|
|
|
514
|
-
this.
|
|
518
|
+
this.peers.pick.open({
|
|
515
519
|
anchor: field.ranges[field.primary]!.start,
|
|
516
520
|
title: this.language.project?.i18n.t('editor:language.snippet.choices'),
|
|
517
521
|
active: prefix + (activeChoice ?? Math.max(0, field.choices.indexOf(this.language.editor.textInRange(field.ranges[field.primary]!)))),
|
|
@@ -571,12 +575,9 @@ export class SnippetFeature {
|
|
|
571
575
|
}
|
|
572
576
|
|
|
573
577
|
if (event.key === 'Escape') {
|
|
574
|
-
const popups = this.language.popups
|
|
578
|
+
const popups = this.language.popups;
|
|
575
579
|
|
|
576
|
-
if (
|
|
577
|
-
popups !== undefined &&
|
|
578
|
-
[popups.completion, popups.signature, popups.hover, popups.pick, popups.peek, popups.callHierarchy].some((popup) => popup !== null)
|
|
579
|
-
) {
|
|
580
|
+
if ((['completion', 'signature', 'hover', 'pick', 'peek', 'callHierarchy'] as const).some((name) => popups.slot(name).get() !== null)) {
|
|
580
581
|
return false;
|
|
581
582
|
}
|
|
582
583
|
|
|
@@ -746,7 +747,7 @@ export class SnippetFeature {
|
|
|
746
747
|
}
|
|
747
748
|
|
|
748
749
|
const frame = this.frames.at(-1);
|
|
749
|
-
const pick = this.language.popups
|
|
750
|
+
const pick = this.language.popups.slot('pick').get();
|
|
750
751
|
|
|
751
752
|
const activeChoice =
|
|
752
753
|
this.choicePrefix !== null && pick?.active.startsWith(this.choicePrefix) ? Number(pick.active.slice(this.choicePrefix.length)) : undefined;
|
|
@@ -843,7 +844,7 @@ export class SnippetFeature {
|
|
|
843
844
|
}
|
|
844
845
|
|
|
845
846
|
// The generic picker closes on any text edit, including an exit elsewhere in the snippet.
|
|
846
|
-
if (frame !== undefined && frame === this.frames.at(-1) && activeChoice !== undefined && this.language.popups
|
|
847
|
+
if (frame !== undefined && frame === this.frames.at(-1) && activeChoice !== undefined && this.language.popups.slot('pick').get() === null) {
|
|
847
848
|
this.openChoices(frame, activeChoice);
|
|
848
849
|
}
|
|
849
850
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { WorkerRequestPort } from '@adecore/editor/worker-client';
|
|
2
|
-
import type { ProjectLanguage } from './project-language.ts';
|
|
3
2
|
import { createSnippetTransformClient, SnippetTransformError, type SnippetTransformClient } from './snippet-transform-client.ts';
|
|
4
3
|
import { validateSnippetTransformJobs } from './snippet-transform-format.ts';
|
|
5
4
|
import { MAX_TRANSFORM_WORK, type SnippetTransformJob } from './snippet-transform-protocol.ts';
|
|
@@ -37,9 +36,12 @@ export class SnippetTransforms {
|
|
|
37
36
|
private active: Job | null = null;
|
|
38
37
|
private idle: unknown;
|
|
39
38
|
private disposed = false;
|
|
39
|
+
private readonly onDispose: (() => void) | undefined;
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
/* `onDispose` runs when the queue ends, whether its owner called for it or the last lease let go. */
|
|
42
|
+
constructor(factory: () => WorkerRequestPort, timers: Timers = realTimers, onDispose?: () => void) {
|
|
42
43
|
this.timers = timers;
|
|
44
|
+
this.onDispose = onDispose;
|
|
43
45
|
|
|
44
46
|
this.client = createSnippetTransformClient({
|
|
45
47
|
workerFactory: factory,
|
|
@@ -199,54 +201,6 @@ export class SnippetTransforms {
|
|
|
199
201
|
this.pending.forEach((job) => job.reject(error));
|
|
200
202
|
this.pending = [];
|
|
201
203
|
this.client.dispose();
|
|
204
|
+
this.onDispose?.();
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
|
-
|
|
205
|
-
interface Entry {
|
|
206
|
-
readonly queue: SnippetTransforms;
|
|
207
|
-
references: number;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const projects = new WeakMap<ProjectLanguage, Entry>();
|
|
211
|
-
|
|
212
|
-
export function acquireSnippetTransforms(project: ProjectLanguage, timers: Timers): SnippetTransformLease | null {
|
|
213
|
-
const factory = project.host.snippetTransformWorker;
|
|
214
|
-
|
|
215
|
-
if (factory === undefined) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
let entry = projects.get(project);
|
|
220
|
-
|
|
221
|
-
if (entry === undefined) {
|
|
222
|
-
entry = { queue: new SnippetTransforms(factory, timers), references: 0 };
|
|
223
|
-
projects.set(project, entry);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const held = entry,
|
|
227
|
-
lease = held.queue.acquire();
|
|
228
|
-
|
|
229
|
-
held.references++;
|
|
230
|
-
let disposed = false;
|
|
231
|
-
|
|
232
|
-
return {
|
|
233
|
-
request: (jobs, options) => lease.request(jobs, options),
|
|
234
|
-
dispose: () => {
|
|
235
|
-
if (disposed) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
disposed = true;
|
|
240
|
-
lease.dispose();
|
|
241
|
-
|
|
242
|
-
if (--held.references === 0 && projects.get(project) === held) {
|
|
243
|
-
projects.delete(project);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function disposeSnippetTransforms(project: ProjectLanguage): void {
|
|
250
|
-
projects.get(project)?.queue.dispose();
|
|
251
|
-
projects.delete(project);
|
|
252
|
-
}
|
package/src/snippet.ts
CHANGED
|
@@ -47,7 +47,7 @@ type Node =
|
|
|
47
47
|
|
|
48
48
|
export type SnippetVariableResolver = (name: string) => string | undefined;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
interface SnippetRenderOptions {
|
|
51
51
|
/* The way VS Code treats `TM_SELECTED_TEXT`: the lines of a value after its first take the leading whitespace of the output line the variable starts on. */
|
|
52
52
|
readonly indentVariables?: boolean;
|
|
53
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CommentSyntax } from '@adecore/editor';
|
|
2
2
|
import { escapeSnippetText } from './snippet.ts';
|
|
3
|
-
import type { TemplateLanguage } from './
|
|
3
|
+
import type { TemplateLanguage } from './template-types.ts';
|
|
4
4
|
|
|
5
5
|
/* A row of Surround With that wraps the selection in a snippet. */
|
|
6
6
|
export interface Construct {
|
package/src/surround.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { commentSyntax, type EditorContentChange, type EditorRange } from '@adecore/editor';
|
|
2
|
-
import { comparePositions, shiftRange } from './diagnostics-model.ts';
|
|
3
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
4
2
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
4
|
import { lineTextOf, textBeforeOf } from './line-text.ts';
|
|
6
5
|
import { enclosingElements, lineEndOf, lineStartOf, markupSyntaxOf, removeTagEdits, type TextReplacement } from './markup-context.ts';
|
|
6
|
+
import type { MarkupFeature } from './markup.ts';
|
|
7
|
+
import type { PickFeature } from './pick.ts';
|
|
7
8
|
import type { PickGroup, PickPreview, PickRow } from './popups.ts';
|
|
9
|
+
import { comparePositions, shiftRange } from './positions.ts';
|
|
8
10
|
import { isShortcut } from './shortcut-keys.ts';
|
|
9
11
|
import { indentSnippet } from './snippet-indent.ts';
|
|
10
|
-
import { bodyWithIndentUnit, dedentLines, insertSnippet, type SnippetPlacement } from './snippet-insert.ts';
|
|
12
|
+
import { bodyWithIndentUnit, dedentLines, insertSnippet, type InsertingSnippets, type SnippetPlacement } from './snippet-insert.ts';
|
|
13
|
+
import type { SnippetFeature } from './snippet-session.ts';
|
|
11
14
|
import { compileSnippet, snippetVariables } from './snippet.ts';
|
|
12
15
|
import { expressionConstructs, regionConstructs, statementConstructs } from './surround-constructs.ts';
|
|
13
16
|
import { templateApplies, templateContextAt, type TemplateContext } from './template-context.ts';
|
|
@@ -28,7 +31,6 @@ interface Subject {
|
|
|
28
31
|
readonly expression: boolean;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
/* A row of the list and what it does. */
|
|
32
34
|
interface Entry {
|
|
33
35
|
readonly row: PickRow;
|
|
34
36
|
|
|
@@ -86,6 +88,13 @@ function mergedRanges(ranges: readonly EditorRange[]): EditorRange[] | null {
|
|
|
86
88
|
return [...merged.filter((_range, other) => other !== index), merged[index]!];
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
/* The sibling features SurroundFeature drives, which the editor language hands over. */
|
|
92
|
+
interface SurroundPeers {
|
|
93
|
+
readonly pick: Pick<PickFeature, 'open'>;
|
|
94
|
+
readonly markup: Pick<MarkupFeature, 'startWrap' | 'supported'>;
|
|
95
|
+
readonly snippets: InsertingSnippets & Pick<SnippetFeature, 'end'>;
|
|
96
|
+
}
|
|
97
|
+
|
|
89
98
|
/*
|
|
90
99
|
* Surround With, Surround with Live Template and Unwrap/Remove, as IntelliJ's handlers offer them. Surround With
|
|
91
100
|
* wraps the selection, or the content of the caret's line, in a statement, an expression, a region comment or a live
|
|
@@ -93,10 +102,12 @@ function mergedRanges(ranges: readonly EditorRange[]): EditorRange[] | null {
|
|
|
93
102
|
* Each is one edit, so one undo step, and nothing happens in a read-only editor.
|
|
94
103
|
*/
|
|
95
104
|
export class SurroundFeature {
|
|
96
|
-
private readonly language:
|
|
105
|
+
private readonly language: LanguageContext;
|
|
106
|
+
private readonly peers: SurroundPeers;
|
|
97
107
|
|
|
98
|
-
constructor(language:
|
|
108
|
+
constructor(language: LanguageContext, peers: SurroundPeers) {
|
|
99
109
|
this.language = language;
|
|
110
|
+
this.peers = peers;
|
|
100
111
|
|
|
101
112
|
language.onDispose(
|
|
102
113
|
language.onKey((event) => {
|
|
@@ -125,7 +136,8 @@ export class SurroundFeature {
|
|
|
125
136
|
|
|
126
137
|
/* Opens the list of constructs around the caret that can be unwrapped or removed. */
|
|
127
138
|
unwrap(): boolean {
|
|
128
|
-
const { editor,
|
|
139
|
+
const { editor, project } = this.language;
|
|
140
|
+
const { pick } = this.peers;
|
|
129
141
|
|
|
130
142
|
if (editor.isReadOnly?.() === true) {
|
|
131
143
|
return true;
|
|
@@ -152,7 +164,8 @@ export class SurroundFeature {
|
|
|
152
164
|
}
|
|
153
165
|
|
|
154
166
|
private show(templatesOnly: boolean): boolean {
|
|
155
|
-
const { editor,
|
|
167
|
+
const { editor, project } = this.language;
|
|
168
|
+
const { pick } = this.peers;
|
|
156
169
|
|
|
157
170
|
if (editor.isReadOnly?.() === true) {
|
|
158
171
|
return true;
|
|
@@ -279,7 +292,7 @@ export class SurroundFeature {
|
|
|
279
292
|
}
|
|
280
293
|
|
|
281
294
|
const live: Entry[] = [];
|
|
282
|
-
const markup = this.
|
|
295
|
+
const { markup } = this.peers;
|
|
283
296
|
|
|
284
297
|
if (markup.supported && (families.includes('html') || families.includes('xml')) && this.language.editor.getSelections().length === 1) {
|
|
285
298
|
live.push({
|
|
@@ -320,8 +333,8 @@ export class SurroundFeature {
|
|
|
320
333
|
|
|
321
334
|
/* Inserts the snippet around every range; a snippet that still runs ends first, as the previous template does in IntelliJ. */
|
|
322
335
|
private insert(source: string, placements: readonly SnippetPlacement[]): void {
|
|
323
|
-
this.
|
|
324
|
-
void insertSnippet(this.language, bodyWithIndentUnit(source, this.indentUnit()), placements);
|
|
336
|
+
this.peers.snippets.end();
|
|
337
|
+
void insertSnippet(this.language, this.peers.snippets, bodyWithIndentUnit(source, this.indentUnit()), placements);
|
|
325
338
|
}
|
|
326
339
|
|
|
327
340
|
private indentUnit(): string {
|
|
@@ -408,7 +421,6 @@ export class SurroundFeature {
|
|
|
408
421
|
editor.focus();
|
|
409
422
|
}
|
|
410
423
|
|
|
411
|
-
/* The lines of the construct before and after its edits. */
|
|
412
424
|
private unwrapPreview(text: string, row: UnwrapRow): PickPreview {
|
|
413
425
|
const edits = row.edits;
|
|
414
426
|
const from = lineStartOf(text, Math.min(row.from, ...edits.map((edit) => edit.from)));
|
package/src/symbol-links.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Location, SymbolInformation, WorkspaceSymbol, WorkspaceSymbolResul
|
|
|
2
2
|
import { uniqueBy } from './unique.ts';
|
|
3
3
|
|
|
4
4
|
/* The classes a name in a signature has: a pointer, an underline and the accent, all only on hover, so the signature keeps its colors at rest. */
|
|
5
|
-
|
|
5
|
+
const SYMBOL_LINK_CLASS = 'cursor-pointer hover:text-accent hover:underline';
|
|
6
6
|
|
|
7
7
|
const TYPE_NAME = /^[A-Z][A-Za-z0-9_]*$/;
|
|
8
8
|
|
|
@@ -4,7 +4,7 @@ import type { DocumentSymbol, DocumentSymbolResult, SymbolInformation, Workspace
|
|
|
4
4
|
export type SymbolGroup = 'namespaces' | 'classes' | 'interfaces' | 'enums' | 'functions' | 'methods' | 'properties' | 'variables' | 'constants' | 'other';
|
|
5
5
|
|
|
6
6
|
/* The order the groups are listed in: what a file declares, then what those declare. */
|
|
7
|
-
|
|
7
|
+
const SYMBOL_GROUPS: readonly SymbolGroup[] = [
|
|
8
8
|
'namespaces',
|
|
9
9
|
'classes',
|
|
10
10
|
'interfaces',
|
|
@@ -55,7 +55,6 @@ const LETTERS: Record<SymbolGroup, string> = {
|
|
|
55
55
|
other: '·'
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
/* The letter in the badge in front of a symbol. */
|
|
59
58
|
export function letterOfKind(kind: number): string {
|
|
60
59
|
return kind === ENUM_MEMBER ? 'e' : LETTERS[groupOfKind(kind)];
|
|
61
60
|
}
|
|
@@ -87,7 +86,6 @@ export function toneOfKind(kind: number): SymbolTone {
|
|
|
87
86
|
return TONES[groupOfKind(kind)];
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
/* One symbol of a file as a row of the picker. */
|
|
91
89
|
export interface SymbolEntry {
|
|
92
90
|
readonly id: string;
|
|
93
91
|
readonly name: string;
|
|
@@ -209,7 +207,6 @@ export function modeOf(input: string): PickerMode {
|
|
|
209
207
|
return { mode: 'symbol', text: input };
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
/* A symbol of the project as a place to go to. */
|
|
213
210
|
export interface WorkspaceEntry {
|
|
214
211
|
readonly id: string;
|
|
215
212
|
readonly name: string;
|
package/src/symbol-picker.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StaleResultError, type Location } from '@adecore/lsp';
|
|
2
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
3
2
|
import { messageOf } from './error-message.ts';
|
|
4
3
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
4
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
5
|
import { basenameOf } from './paths.ts';
|
|
6
6
|
import { isShortcut } from './shortcut-keys.ts';
|
|
7
7
|
import { entriesOf, workspaceEntriesOf, type SymbolEntry, type WorkspaceEntry } from './symbol-picker-model.ts';
|
|
@@ -14,9 +14,9 @@ const TOAST_ID = 'language-symbols';
|
|
|
14
14
|
* its own input, so the editor only has to open it.
|
|
15
15
|
*/
|
|
16
16
|
export class SymbolPickerFeature {
|
|
17
|
-
private readonly language:
|
|
17
|
+
private readonly language: LanguageContext;
|
|
18
18
|
|
|
19
|
-
constructor(language:
|
|
19
|
+
constructor(language: LanguageContext) {
|
|
20
20
|
this.language = language;
|
|
21
21
|
|
|
22
22
|
const off = language.onKey((event) => {
|
|
@@ -46,7 +46,7 @@ export class SymbolPickerFeature {
|
|
|
46
46
|
|
|
47
47
|
try {
|
|
48
48
|
const entries = entriesOf(await this.language.service.documentSymbols(uri));
|
|
49
|
-
popups.
|
|
49
|
+
popups.slot('symbols').set({ file: basenameOf(this.language.uri), entries });
|
|
50
50
|
} catch (error) {
|
|
51
51
|
if (!(error instanceof StaleResultError)) {
|
|
52
52
|
this.language.project.host.notify?.({
|
|
@@ -59,13 +59,12 @@ export class SymbolPickerFeature {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
close(): void {
|
|
62
|
-
if (this.language.popups.
|
|
63
|
-
this.language.popups.
|
|
62
|
+
if (this.language.popups.slot('symbols').get() !== null) {
|
|
63
|
+
this.language.popups.slot('symbols').set(null);
|
|
64
64
|
this.language.editor.focus();
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
/* Puts the caret on a symbol of the file. */
|
|
69
68
|
goTo(entry: SymbolEntry): void {
|
|
70
69
|
this.close();
|
|
71
70
|
this.language.jump({ line: entry.line, character: entry.character });
|
package/src/symbols.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EditorBlock, EditorPosition } from '@adecore/editor';
|
|
2
2
|
import type { DocumentSymbol, DocumentSymbolResult, Range, SymbolInformation } from '@adecore/lsp';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
4
4
|
import { Refresher } from './refresher.ts';
|
|
5
5
|
import { realTimers, type Timers } from './timers.ts';
|
|
6
6
|
|
|
@@ -23,11 +23,10 @@ const KINDS: Record<number, string> = {
|
|
|
23
23
|
23: 'struct'
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
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
30
|
readonly nameLine?: number;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -143,7 +142,7 @@ export class SymbolsFeature {
|
|
|
143
142
|
private readonly refresher: Refresher;
|
|
144
143
|
private readonly listeners = new Set<(result: DocumentSymbolResult) => void>();
|
|
145
144
|
|
|
146
|
-
constructor(language:
|
|
145
|
+
constructor(language: LanguageContext, timers: Timers = realTimers) {
|
|
147
146
|
const { editor, uri } = language;
|
|
148
147
|
|
|
149
148
|
this.refresher = new Refresher(
|
package/src/template-builtins.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LiveTemplate, PostfixTemplate, TemplateLanguage } from './
|
|
1
|
+
import type { LiveTemplate, PostfixTemplate, TemplateLanguage } from './template-types.ts';
|
|
2
2
|
|
|
3
3
|
/* A body of lines; a leading tab is one indentation unit. */
|
|
4
4
|
function body(...lines: string[]): string {
|
|
@@ -49,7 +49,6 @@ export const BUILT_IN_LIVE_TEMPLATES: readonly LiveTemplate[] = [
|
|
|
49
49
|
live('xml', 'CD', ['xml'], body('<![CDATA[', '$TM_SELECTED_TEXT', ']]>'), 'Surround with CDATA section')
|
|
50
50
|
];
|
|
51
51
|
|
|
52
|
-
/* A block statement around the expression, with the caret inside it. */
|
|
53
52
|
function block(head: string): string {
|
|
54
53
|
return body(`${head} {`, '\t$0', '}');
|
|
55
54
|
}
|
package/src/template-context.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EditorPosition } from '@adecore/editor';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
2
|
+
import { lspLanguageId } from '@adecore/lsp';
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
4
|
+
import type { LiveTemplate, TemplateLanguage, TemplatePlace } from './template-types.ts';
|
|
4
5
|
|
|
5
|
-
/* The completion item kind of a snippet. */
|
|
6
6
|
export const SNIPPET_KIND = 15;
|
|
7
7
|
|
|
8
8
|
/* Sorts a template row after the rows of the same score that a service answers. */
|
|
@@ -12,19 +12,11 @@ export function sortAfterServer(key: string): string {
|
|
|
12
12
|
|
|
13
13
|
/* The families a language id counts as; TypeScript builds on JavaScript. */
|
|
14
14
|
export function familiesOf(languageId: string): readonly TemplateLanguage[] {
|
|
15
|
-
switch (languageId) {
|
|
15
|
+
switch (lspLanguageId(languageId)) {
|
|
16
16
|
case 'javascript':
|
|
17
|
-
case 'js':
|
|
18
|
-
case 'mjs':
|
|
19
|
-
case 'cjs':
|
|
20
|
-
case 'jsx':
|
|
21
17
|
case 'javascriptreact':
|
|
22
18
|
return ['javascript'];
|
|
23
19
|
case 'typescript':
|
|
24
|
-
case 'ts':
|
|
25
|
-
case 'mts':
|
|
26
|
-
case 'cts':
|
|
27
|
-
case 'tsx':
|
|
28
20
|
case 'typescriptreact':
|
|
29
21
|
return ['javascript', 'typescript'];
|
|
30
22
|
case 'php':
|
|
@@ -53,13 +45,12 @@ export interface TemplateContext {
|
|
|
53
45
|
}
|
|
54
46
|
|
|
55
47
|
/* The families and the place at a position; an editor that cannot tell has the language of the document, in code. */
|
|
56
|
-
export function templateContextAt(language:
|
|
48
|
+
export function templateContextAt(language: LanguageContext, position: EditorPosition): TemplateContext {
|
|
57
49
|
const place = language.editor.placeAt?.(position);
|
|
58
50
|
|
|
59
51
|
return place === undefined ? { families: familiesOf(language.languageId), place: 'code' } : { families: familiesOf(place.language), place: place.kind };
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
/* Whether a template shares a family with the context and applies to its place. */
|
|
63
54
|
export function templateApplies(template: LiveTemplate, context: TemplateContext): boolean {
|
|
64
55
|
return template.languages.some((family) => context.families.includes(family)) && (template.places ?? ['code']).includes(context.place);
|
|
65
56
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* The families of language a live template belongs to; a family also matches the languages that build on it. */
|
|
2
|
+
export type TemplateLanguage = 'javascript' | 'typescript' | 'php' | 'css' | 'html' | 'xml' | 'other';
|
|
3
|
+
|
|
4
|
+
export type TemplatePlace = 'code' | 'comment' | 'string';
|
|
5
|
+
|
|
6
|
+
/* A text that Tab expands after its key, in the syntax of a snippet. */
|
|
7
|
+
export interface LiveTemplate {
|
|
8
|
+
/* Stable; a built-in one is `builtin.<language>.<key>`. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
|
|
11
|
+
/* One to 40 characters, none of them whitespace. */
|
|
12
|
+
readonly key: string;
|
|
13
|
+
|
|
14
|
+
/* Snippet syntax; the leading tabs of a line are one indentation unit each. */
|
|
15
|
+
readonly body: string;
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
readonly languages: readonly TemplateLanguage[];
|
|
18
|
+
|
|
19
|
+
/* Where it applies; `['code']` without it. */
|
|
20
|
+
readonly places?: readonly TemplatePlace[];
|
|
21
|
+
|
|
22
|
+
/* What Insert Live Template sorts by; the first language without it. */
|
|
23
|
+
readonly group?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* A text that Tab expands after a dot and its key, around the expression before the dot. */
|
|
27
|
+
export interface PostfixTemplate {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
|
|
30
|
+
/* Without the dot; identifier characters only. */
|
|
31
|
+
readonly key: string;
|
|
32
|
+
|
|
33
|
+
/* Snippet syntax, in which `$EXPR` is the expression. */
|
|
34
|
+
readonly body: string;
|
|
35
|
+
readonly description?: string;
|
|
36
|
+
|
|
37
|
+
/* Shown at the end of its row, as in `if (expr) {}`. */
|
|
38
|
+
readonly example?: string;
|
|
39
|
+
readonly languages: readonly ('javascript' | 'typescript' | 'php')[];
|
|
40
|
+
|
|
41
|
+
/* `any` without it. */
|
|
42
|
+
readonly expression?: 'any' | 'statement';
|
|
43
|
+
}
|
package/src/templates.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { checkSnippet } from './snippet.ts';
|
|
2
2
|
import { BUILT_IN_LIVE_TEMPLATES, BUILT_IN_POSTFIX_TEMPLATES } from './template-builtins.ts';
|
|
3
|
+
import type { LiveTemplate, PostfixTemplate, TemplateLanguage, TemplatePlace } from './template-types.ts';
|
|
3
4
|
|
|
4
5
|
export { BUILT_IN_LIVE_TEMPLATES, BUILT_IN_POSTFIX_TEMPLATES };
|
|
5
|
-
export { type TemplatesFeature } from './live-templates.ts';
|
|
6
|
-
|
|
7
|
-
/* The families of language a live template belongs to; a family also matches the languages that build on it. */
|
|
8
|
-
export type TemplateLanguage = 'javascript' | 'typescript' | 'php' | 'css' | 'html' | 'xml' | 'other';
|
|
9
|
-
|
|
10
|
-
/* What the text at the caret is: code, a comment or a string. */
|
|
11
|
-
export type TemplatePlace = 'code' | 'comment' | 'string';
|
|
12
6
|
|
|
13
7
|
const MAX_KEY_LENGTH = 40;
|
|
14
8
|
const MAX_BODY_LENGTH = 20_000;
|
|
@@ -16,46 +10,16 @@ const POSTFIX_LANGUAGES: readonly string[] = ['javascript', 'typescript', 'php']
|
|
|
16
10
|
const LANGUAGES: readonly string[] = ['javascript', 'typescript', 'php', 'css', 'html', 'xml', 'other'];
|
|
17
11
|
const PLACES: readonly string[] = ['code', 'comment', 'string'];
|
|
18
12
|
|
|
19
|
-
/*
|
|
20
|
-
export interface
|
|
21
|
-
/*
|
|
22
|
-
readonly
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/* Snippet syntax; the leading tabs of a line are one indentation unit each. */
|
|
28
|
-
readonly body: string;
|
|
29
|
-
readonly description?: string;
|
|
30
|
-
readonly languages: readonly TemplateLanguage[];
|
|
31
|
-
|
|
32
|
-
/* Where it applies; `['code']` without it. */
|
|
33
|
-
readonly places?: readonly TemplatePlace[];
|
|
34
|
-
|
|
35
|
-
/* What Insert Live Template sorts by; the first language without it. */
|
|
36
|
-
readonly group?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* A text that Tab expands after a dot and its key, around the expression before the dot. */
|
|
40
|
-
export interface PostfixTemplate {
|
|
41
|
-
readonly id: string;
|
|
42
|
-
|
|
43
|
-
/* Without the dot; identifier characters only. */
|
|
44
|
-
readonly key: string;
|
|
45
|
-
|
|
46
|
-
/* Snippet syntax, in which `$EXPR` is the expression. */
|
|
47
|
-
readonly body: string;
|
|
48
|
-
readonly description?: string;
|
|
49
|
-
|
|
50
|
-
/* Shown at the end of its row, as in `if (expr) {}`. */
|
|
51
|
-
readonly example?: string;
|
|
52
|
-
readonly languages: readonly ('javascript' | 'typescript' | 'php')[];
|
|
53
|
-
|
|
54
|
-
/* `any` without it. */
|
|
55
|
-
readonly expression?: 'any' | 'statement';
|
|
13
|
+
/* Each is on unless false. */
|
|
14
|
+
export interface TemplatesHost {
|
|
15
|
+
/* What templates the editors of the project know. A registry of the built-in ones that lives as long as the project without one. */
|
|
16
|
+
readonly templates?: TemplateRegistry;
|
|
17
|
+
/* Save as Live Template: the host opens its own form with this draft. Without it the command does nothing. */
|
|
18
|
+
saveAsLiveTemplate?(draft: LiveTemplateDraft): void;
|
|
19
|
+
/* The last row of the template lists, "Configure live templates…"; the row is left out without it. */
|
|
20
|
+
openTemplateSettings?(): void;
|
|
56
21
|
}
|
|
57
22
|
|
|
58
|
-
/* Each is on unless false. */
|
|
59
23
|
export interface TemplateSettings {
|
|
60
24
|
/* Live templates are rows of the suggestion list. */
|
|
61
25
|
readonly liveInCompletion?: boolean;
|