@adecore/editor-react 0.31.12 → 0.32.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/AnchoredPopup.js +73 -19
- package/dist/AttributionCard.js +162 -4
- package/dist/BaselineStatus.js +62 -8
- package/dist/CallHierarchyPanel.js +977 -60
- package/dist/ChangeReview.js +76 -25
- package/dist/CodeAuthorsCard.js +314 -14
- package/dist/CompletionPopup.js +490 -83
- package/dist/DiffView.js +548 -181
- package/dist/EditorContextMenu.js +352 -34
- package/dist/EditorView.js +276 -99
- package/dist/FindReplace.js +525 -67
- package/dist/HoverCard.js +378 -38
- package/dist/HoverSections.js +367 -56
- package/dist/LanguagePopups.js +95 -34
- package/dist/Markdown.js +41 -6
- package/dist/PanelResizeHandle.js +199 -66
- package/dist/PathText.js +49 -7
- package/dist/PeekPanel.js +675 -72
- package/dist/PickPopup.js +304 -34
- package/dist/RenameCard.js +679 -85
- package/dist/RenderedDocs.js +329 -58
- package/dist/SignatureCard.js +91 -7
- package/dist/SplitDiffView.js +344 -254
- package/dist/SymbolPicker.js +440 -85
- package/dist/call-hierarchy-model.js +102 -68
- package/dist/call-hierarchy.js +458 -359
- package/dist/code-actions-model.js +88 -76
- package/dist/code-actions.js +372 -283
- package/dist/code-authors.js +64 -55
- package/dist/code-vision-model.js +134 -127
- package/dist/code-vision.js +224 -206
- package/dist/completion-call.js +94 -67
- package/dist/completion-model.js +334 -244
- package/dist/completion.js +840 -649
- package/dist/conflict-model.js +35 -29
- package/dist/context-menu-rows.js +42 -17
- package/dist/context-menu.js +64 -46
- package/dist/definition-link.js +88 -85
- package/dist/diagnostics-model.js +74 -55
- package/dist/diagnostics.js +121 -100
- package/dist/diff-expansion.js +38 -35
- package/dist/diff-overlays.js +144 -22
- package/dist/diff-syntax.js +65 -42
- package/dist/diff-wordmarks.js +26 -23
- package/dist/doc-comment-model.js +265 -216
- package/dist/editor-language.js +177 -152
- package/dist/error-message.js +2 -2
- package/dist/find-query.js +49 -36
- package/dist/folding.js +81 -62
- package/dist/format-on-type.js +86 -67
- package/dist/highlight-layers.js +19 -20
- package/dist/highlights.js +105 -83
- package/dist/history.js +44 -38
- package/dist/holder.js +18 -18
- package/dist/host-types.js +1 -1
- package/dist/hover-content.js +167 -129
- package/dist/hover.js +285 -245
- package/dist/index.js +10 -10
- package/dist/inlay-hints.js +369 -324
- package/dist/key-priority.js +34 -31
- package/dist/language-ids.js +45 -42
- package/dist/line-edits.js +74 -28
- package/dist/line-text.js +18 -3
- package/dist/locales/en.json +38 -38
- package/dist/locales/nl.json +41 -41
- package/dist/models.js +1 -1
- package/dist/navigation-history.js +40 -41
- package/dist/navigation.js +141 -123
- package/dist/panel-size.js +8 -8
- package/dist/patch-decorations.js +236 -160
- package/dist/patch-layout.js +331 -262
- package/dist/paths.js +3 -3
- package/dist/peek-model.js +86 -69
- package/dist/peek.js +254 -192
- package/dist/pick.js +164 -157
- package/dist/popup-focus.js +5 -5
- package/dist/popup-placement.js +36 -21
- package/dist/popups.js +13 -13
- package/dist/project-language.js +228 -211
- package/dist/project-problems.js +81 -69
- package/dist/proposal-model.js +163 -126
- package/dist/recent-choices.js +25 -25
- package/dist/refresher.js +44 -49
- package/dist/rename-model.js +113 -113
- package/dist/rename.js +321 -233
- package/dist/rendered-docs.d.ts +4 -2
- package/dist/rendered-docs.js +384 -318
- package/dist/rendering-context.js +5 -3
- package/dist/rendering.js +22 -4
- package/dist/review-group.js +42 -39
- package/dist/row-host.d.ts +4 -2
- package/dist/row-host.js +90 -78
- package/dist/selection-ranges.js +21 -17
- package/dist/semantic-delta.js +22 -19
- package/dist/semantic-model.js +86 -73
- package/dist/semantic-tokens.js +201 -162
- package/dist/shortcut-keys.js +16 -10
- package/dist/signature-model.js +34 -28
- package/dist/signature.js +177 -129
- package/dist/snippet-field-transforms.js +118 -106
- package/dist/snippet-indent.js +48 -43
- package/dist/snippet-range-order.js +11 -11
- package/dist/snippet-session.js +703 -667
- package/dist/snippet-transform-client.js +59 -59
- package/dist/snippet-transform-format.js +285 -263
- package/dist/snippet-transform-protocol.js +1 -1
- package/dist/snippet-transform-queue.js +163 -153
- package/dist/snippet-transform-worker.js +42 -35
- package/dist/snippet-variable-names.js +1 -36
- package/dist/snippet-variables.js +53 -63
- package/dist/snippet.js +477 -405
- package/dist/split-alignment.js +47 -35
- package/dist/split-scroll.js +42 -40
- package/dist/symbol-links.js +33 -25
- package/dist/symbol-picker-model.js +126 -116
- package/dist/symbol-picker.js +98 -59
- package/dist/symbols.js +117 -88
- package/dist/testing.js +248 -165
- package/dist/timers.js +35 -30
- package/dist/use-panel-body.js +49 -8
- package/dist/use-problem-counts.js +29 -15
- package/dist/view-state.js +54 -33
- package/dist/word-diff.js +18 -18
- package/dist/workspace-edit.js +300 -249
- package/package.json +6 -6
- package/src/CallHierarchyPanel.tsx +2 -2
- package/src/DiffView.tsx +3 -3
- package/src/FindReplace.tsx +2 -2
- package/src/LanguagePopups.tsx +2 -0
- package/src/PeekPanel.tsx +3 -3
- package/src/RenderedDocs.tsx +9 -10
- package/src/SymbolPicker.tsx +2 -2
- package/src/diff-overlays.tsx +6 -4
- package/src/locales/en.json +38 -38
- package/src/locales/nl.json +41 -41
- package/src/rendered-docs.ts +14 -3
- package/src/row-host.ts +14 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
-
export const RenderingContext = createContext({
|
|
2
|
+
export const RenderingContext = createContext({
|
|
3
|
+
theme: 'light'
|
|
4
|
+
});
|
|
3
5
|
export function useEditorRendering() {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
+
return useContext(RenderingContext);
|
|
7
|
+
}
|
package/dist/rendering.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { RenderingContext } from './rendering-context.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export function EditorRenderingProvider(t0) {
|
|
5
|
+
const $ = _c(3);
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
children
|
|
9
|
+
} = t0;
|
|
10
|
+
let t1;
|
|
11
|
+
if ($[0] !== children || $[1] !== value) {
|
|
12
|
+
t1 = /*#__PURE__*/_jsx(RenderingContext, {
|
|
13
|
+
value: value,
|
|
14
|
+
children: children
|
|
15
|
+
});
|
|
16
|
+
$[0] = children;
|
|
17
|
+
$[1] = value;
|
|
18
|
+
$[2] = t1;
|
|
19
|
+
} else {
|
|
20
|
+
t1 = $[2];
|
|
21
|
+
}
|
|
22
|
+
return t1;
|
|
23
|
+
}
|
package/dist/review-group.js
CHANGED
|
@@ -4,47 +4,50 @@
|
|
|
4
4
|
* change in front of a person that the other already took.
|
|
5
5
|
*/
|
|
6
6
|
export class ReviewGroup {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
7
|
+
members = new Set();
|
|
8
|
+
join(member) {
|
|
9
|
+
this.members.add(member);
|
|
10
|
+
return () => {
|
|
11
|
+
this.members.delete(member);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
hide(runIds) {
|
|
15
|
+
this.each(member => member.hide(runIds));
|
|
16
|
+
}
|
|
17
|
+
show(runIds) {
|
|
18
|
+
this.each(member => member.show(runIds));
|
|
19
|
+
}
|
|
20
|
+
refresh() {
|
|
21
|
+
this.each(member => member.refresh());
|
|
22
|
+
}
|
|
23
|
+
/* Over a copy, since a member may leave while it hears. */
|
|
24
|
+
each(action) {
|
|
25
|
+
for (const member of [...this.members]) {
|
|
26
|
+
action(member);
|
|
28
27
|
}
|
|
28
|
+
}
|
|
29
29
|
}
|
|
30
30
|
const groups = new Map();
|
|
31
31
|
/* The host supplies a shared file key; the group is released with its last editor. */
|
|
32
32
|
export function joinReviewGroup(key) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
33
|
+
const held = groups.get(key) ?? {
|
|
34
|
+
group: new ReviewGroup(),
|
|
35
|
+
holders: 0
|
|
36
|
+
};
|
|
37
|
+
groups.set(key, held);
|
|
38
|
+
held.holders++;
|
|
39
|
+
let left = false;
|
|
40
|
+
return {
|
|
41
|
+
group: held.group,
|
|
42
|
+
leave: () => {
|
|
43
|
+
if (left) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
left = true;
|
|
47
|
+
held.holders--;
|
|
48
|
+
if (held.holders === 0 && groups.get(key) === held) {
|
|
49
|
+
groups.delete(key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
package/dist/row-host.d.ts
CHANGED
|
@@ -18,9 +18,11 @@ declare abstract class ContainerHost {
|
|
|
18
18
|
private readonly listeners;
|
|
19
19
|
private version;
|
|
20
20
|
private signature;
|
|
21
|
+
private shown;
|
|
21
22
|
constructor(editor: Editor, owner: string);
|
|
22
|
-
getVersion
|
|
23
|
-
|
|
23
|
+
getVersion(): number;
|
|
24
|
+
getContainers(): ReadonlyMap<string, HTMLElement>;
|
|
25
|
+
subscribe(listener: () => void): () => void;
|
|
24
26
|
container(id: string): HTMLElement | undefined;
|
|
25
27
|
protected replace(signature: string, ids: readonly string[]): boolean;
|
|
26
28
|
protected mounted(id: string, container: HTMLElement): void;
|
package/dist/row-host.js
CHANGED
|
@@ -1,49 +1,62 @@
|
|
|
1
1
|
/* The elements an editor made for one owner's entries, and a version React reads them by. */
|
|
2
2
|
class ContainerHost {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
editor;
|
|
4
|
+
owner;
|
|
5
|
+
containers = new Map();
|
|
6
|
+
listeners = new Set();
|
|
7
|
+
version = 0;
|
|
8
|
+
signature = '';
|
|
9
|
+
shown = null;
|
|
10
|
+
constructor(editor, owner) {
|
|
11
|
+
this.editor = editor;
|
|
12
|
+
this.owner = owner;
|
|
13
|
+
}
|
|
14
|
+
getVersion() {
|
|
15
|
+
return this.version;
|
|
16
|
+
}
|
|
17
|
+
/* The elements by id as they stand now, one map until they change, so React can read them as a snapshot. */
|
|
18
|
+
getContainers() {
|
|
19
|
+
if (this.shown?.version !== this.version) {
|
|
20
|
+
this.shown = {
|
|
21
|
+
version: this.version,
|
|
22
|
+
containers: new Map(this.containers)
|
|
23
|
+
};
|
|
12
24
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
return this.shown.containers;
|
|
26
|
+
}
|
|
27
|
+
subscribe(listener) {
|
|
28
|
+
this.listeners.add(listener);
|
|
29
|
+
return () => {
|
|
30
|
+
this.listeners.delete(listener);
|
|
19
31
|
};
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
}
|
|
33
|
+
container(id) {
|
|
34
|
+
return this.containers.get(id);
|
|
35
|
+
}
|
|
36
|
+
/* False for the same entries again, so an editor does not measure them twice; otherwise drops the elements of entries that left. */
|
|
37
|
+
replace(signature, ids) {
|
|
38
|
+
if (signature === this.signature) {
|
|
39
|
+
return false;
|
|
22
40
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const kept = new Set(ids);
|
|
30
|
-
for (const id of [...this.containers.keys()]) {
|
|
31
|
-
if (!kept.has(id)) {
|
|
32
|
-
this.containers.delete(id);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
41
|
+
this.signature = signature;
|
|
42
|
+
const kept = new Set(ids);
|
|
43
|
+
for (const id of [...this.containers.keys()]) {
|
|
44
|
+
if (!kept.has(id)) {
|
|
45
|
+
this.containers.delete(id);
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
bump()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
mounted(id, container) {
|
|
51
|
+
this.containers.set(id, container);
|
|
52
|
+
this.bump();
|
|
53
|
+
}
|
|
54
|
+
bump() {
|
|
55
|
+
this.version++;
|
|
56
|
+
for (const listener of [...this.listeners]) {
|
|
57
|
+
listener();
|
|
46
58
|
}
|
|
59
|
+
}
|
|
47
60
|
}
|
|
48
61
|
/*
|
|
49
62
|
* The rows of one owner in an editor, and the elements the editor draws them in, so React can portal
|
|
@@ -51,31 +64,30 @@ class ContainerHost {
|
|
|
51
64
|
* row's content never keeps state of its own.
|
|
52
65
|
*/
|
|
53
66
|
export class RowHost extends ContainerHost {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
this.editor.setWidgets(rows.map((row) => ({
|
|
60
|
-
id: row.filler ? `${row.id}-filler` : row.id,
|
|
61
|
-
line: row.line,
|
|
62
|
-
placement: row.placement,
|
|
63
|
-
height: row.height,
|
|
64
|
-
fixed: row.fixed,
|
|
65
|
-
render: (container) => {
|
|
66
|
-
if (row.filler) {
|
|
67
|
-
container.classList.add('adecore-editor-diff-filler');
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.mounted(row.id, container);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
})), this.owner);
|
|
74
|
-
this.bump();
|
|
75
|
-
}
|
|
76
|
-
clear() {
|
|
77
|
-
this.set([]);
|
|
67
|
+
set(rows) {
|
|
68
|
+
const signature = rows.map(row => `${row.id}@${row.line}${row.placement}:${row.height}:${row.fixed}:${row.filler}`).join('|');
|
|
69
|
+
if (!this.replace(signature, rows.map(row => row.id))) {
|
|
70
|
+
return;
|
|
78
71
|
}
|
|
72
|
+
this.editor.setWidgets(rows.map(row => ({
|
|
73
|
+
id: row.filler ? `${row.id}-filler` : row.id,
|
|
74
|
+
line: row.line,
|
|
75
|
+
placement: row.placement,
|
|
76
|
+
height: row.height,
|
|
77
|
+
fixed: row.fixed,
|
|
78
|
+
render: container => {
|
|
79
|
+
if (row.filler) {
|
|
80
|
+
container.classList.add('adecore-editor-diff-filler');
|
|
81
|
+
} else {
|
|
82
|
+
this.mounted(row.id, container);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
})), this.owner);
|
|
86
|
+
this.bump();
|
|
87
|
+
}
|
|
88
|
+
clear() {
|
|
89
|
+
this.set([]);
|
|
90
|
+
}
|
|
79
91
|
}
|
|
80
92
|
/*
|
|
81
93
|
* The actions of one owner after the end of lines in an editor, and the elements the editor makes for
|
|
@@ -83,19 +95,19 @@ export class RowHost extends ContainerHost {
|
|
|
83
95
|
* its state.
|
|
84
96
|
*/
|
|
85
97
|
export class LineActionHost extends ContainerHost {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
this.editor.setLineActions(actions.map((action) => ({
|
|
92
|
-
id: action.id,
|
|
93
|
-
line: action.line,
|
|
94
|
-
render: (container) => this.mounted(action.id, container)
|
|
95
|
-
})), this.owner);
|
|
96
|
-
this.bump();
|
|
98
|
+
set(actions) {
|
|
99
|
+
const signature = actions.map(action => `${action.id}@${action.line}`).join('|');
|
|
100
|
+
if (!this.replace(signature, actions.map(action => action.id))) {
|
|
101
|
+
return;
|
|
97
102
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
this.editor.setLineActions(actions.map(action => ({
|
|
104
|
+
id: action.id,
|
|
105
|
+
line: action.line,
|
|
106
|
+
render: container => this.mounted(action.id, container)
|
|
107
|
+
})), this.owner);
|
|
108
|
+
this.bump();
|
|
109
|
+
}
|
|
110
|
+
clear() {
|
|
111
|
+
this.set([]);
|
|
112
|
+
}
|
|
113
|
+
}
|
package/dist/selection-ranges.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
const METHOD = 'textDocument/selectionRange';
|
|
2
2
|
/* The links of one answer, the smallest range first. */
|
|
3
3
|
export function selectionChainOf(selection) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const chain = [];
|
|
5
|
+
for (let link = selection; link; link = link.parent) {
|
|
6
|
+
chain.push(link.range);
|
|
7
|
+
}
|
|
8
|
+
return chain;
|
|
9
9
|
}
|
|
10
10
|
/*
|
|
11
11
|
* Extend and Shrink Selection grow through the ranges the language server knows around the caret, which
|
|
12
12
|
* follow the syntax of the file. Where no server offers them the editor grows by its own rule.
|
|
13
13
|
*/
|
|
14
14
|
export class SelectionRangesFeature {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
constructor(language) {
|
|
16
|
+
const {
|
|
17
|
+
editor,
|
|
18
|
+
project,
|
|
19
|
+
uri
|
|
20
|
+
} = language;
|
|
21
|
+
editor.setSelectionRanges(async positions => {
|
|
22
|
+
if (!project.service.supports(METHOD, uri)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const chains = await project.service.selectionRanges(uri, positions);
|
|
26
|
+
return chains === null || chains.length !== positions.length ? null : chains.map(selectionChainOf);
|
|
27
|
+
});
|
|
28
|
+
language.onDispose(() => editor.setSelectionRanges(null));
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/semantic-delta.js
CHANGED
|
@@ -4,24 +4,27 @@
|
|
|
4
4
|
* whole number of tokens. The caller then asks for the full tokens instead. One pass over data and edits.
|
|
5
5
|
*/
|
|
6
6
|
export function applySemanticEdits(data, edits) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
for (const value of inserted) {
|
|
19
|
-
result.push(value);
|
|
20
|
-
}
|
|
21
|
-
cursor = start + deleteCount;
|
|
7
|
+
const result = [];
|
|
8
|
+
let cursor = 0;
|
|
9
|
+
for (const edit of edits) {
|
|
10
|
+
const {
|
|
11
|
+
start,
|
|
12
|
+
deleteCount
|
|
13
|
+
} = edit;
|
|
14
|
+
const inserted = edit.data ?? [];
|
|
15
|
+
if (!Number.isInteger(start) || !Number.isInteger(deleteCount) || start < cursor || deleteCount < 0 || start + deleteCount > data.length) {
|
|
16
|
+
return null;
|
|
22
17
|
}
|
|
23
|
-
for (let at = cursor; at <
|
|
24
|
-
|
|
18
|
+
for (let at = cursor; at < start; at++) {
|
|
19
|
+
result.push(data[at]);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
for (const value of inserted) {
|
|
22
|
+
result.push(value);
|
|
23
|
+
}
|
|
24
|
+
cursor = start + deleteCount;
|
|
25
|
+
}
|
|
26
|
+
for (let at = cursor; at < data.length; at++) {
|
|
27
|
+
result.push(data[at]);
|
|
28
|
+
}
|
|
29
|
+
return result.length % 5 === 0 ? result : null;
|
|
30
|
+
}
|
package/dist/semantic-model.js
CHANGED
|
@@ -5,86 +5,99 @@
|
|
|
5
5
|
* marks what is local to a function, so a variable it leaves unmarked is drawn as a global.
|
|
6
6
|
*/
|
|
7
7
|
export function scopesOf(type, modifiers, scoped = false) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'namespace':
|
|
10
|
+
return ['entity.name.namespace'];
|
|
11
|
+
case 'class':
|
|
12
|
+
return ['entity.name.type.class'];
|
|
13
|
+
case 'enum':
|
|
14
|
+
return ['entity.name.type.enum'];
|
|
15
|
+
case 'interface':
|
|
16
|
+
return ['entity.name.type.interface'];
|
|
17
|
+
case 'struct':
|
|
18
|
+
return ['entity.name.type.struct'];
|
|
19
|
+
case 'type':
|
|
20
|
+
return ['entity.name.type'];
|
|
21
|
+
case 'typeParameter':
|
|
22
|
+
return ['entity.name.type.parameter'];
|
|
23
|
+
case 'parameter':
|
|
24
|
+
return ['variable.parameter'];
|
|
25
|
+
case 'property':
|
|
26
|
+
return [modifiers.has('static') ? 'variable.other.property.static' : 'variable.other.property'];
|
|
27
|
+
case 'enumMember':
|
|
28
|
+
return ['variable.other.enummember'];
|
|
29
|
+
case 'function':
|
|
30
|
+
case 'method':
|
|
31
|
+
if (modifiers.has('static')) {
|
|
32
|
+
return ['entity.name.function.static'];
|
|
33
|
+
}
|
|
34
|
+
if (modifiers.has('declaration')) {
|
|
35
|
+
return ['entity.name.function'];
|
|
36
|
+
}
|
|
37
|
+
return [type === 'method' ? 'entity.name.function.method' : 'entity.name.function.call'];
|
|
38
|
+
case 'decorator':
|
|
39
|
+
return ['meta.decorator'];
|
|
40
|
+
case 'macro':
|
|
41
|
+
return ['entity.name.function.macro'];
|
|
42
|
+
case 'variable':
|
|
43
|
+
if (scoped) {
|
|
44
|
+
return modifiers.has('local') ? null : ['variable.other.constant'];
|
|
45
|
+
}
|
|
46
|
+
return modifiers.has('readonly') ? ['variable.other.constant'] : null;
|
|
47
|
+
default:
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
50
|
}
|
|
51
51
|
/*
|
|
52
52
|
* What a server sends for the language it reads inside a string (SQL in a PHP string). Outside a string the grammar
|
|
53
53
|
* colors these better, so they only apply where the grammar says it is a string.
|
|
54
54
|
*/
|
|
55
55
|
const EMBEDDED_SCOPES = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
keyword: ['keyword'],
|
|
57
|
+
string: ['string'],
|
|
58
|
+
number: ['constant.numeric'],
|
|
59
|
+
comment: ['comment'],
|
|
60
|
+
operator: ['keyword.operator']
|
|
61
61
|
};
|
|
62
62
|
/* The encoded data of `textDocument/semanticTokens` as one token per classified range, the ones the theme has nothing to say about left out. */
|
|
63
63
|
export function decodeSemanticTokens(tokens, legend) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const modifiers = new Set(legend.tokenModifiers.filter((_, index) => (bits & (1 << index)) !== 0));
|
|
79
|
-
const scopes = scopesOf(type, modifiers, scoped);
|
|
80
|
-
if (scopes !== null) {
|
|
81
|
-
result.push({ line, character, length: data[at + 2], scopes });
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const embedded = EMBEDDED_SCOPES[type];
|
|
85
|
-
if (embedded !== undefined) {
|
|
86
|
-
result.push({ line, character, length: data[at + 2], scopes: embedded, within: 'string' });
|
|
87
|
-
}
|
|
64
|
+
const result = [];
|
|
65
|
+
const {
|
|
66
|
+
data
|
|
67
|
+
} = tokens;
|
|
68
|
+
const scoped = legend.tokenModifiers.includes('local');
|
|
69
|
+
let line = 0;
|
|
70
|
+
let character = 0;
|
|
71
|
+
for (let at = 0; at + 4 < data.length; at += 5) {
|
|
72
|
+
const deltaLine = data[at];
|
|
73
|
+
line += deltaLine;
|
|
74
|
+
character = deltaLine === 0 ? character + data[at + 1] : data[at + 1];
|
|
75
|
+
const type = legend.tokenTypes[data[at + 3]];
|
|
76
|
+
if (type === undefined) {
|
|
77
|
+
continue;
|
|
88
78
|
}
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
const bits = data[at + 4];
|
|
80
|
+
const modifiers = new Set(legend.tokenModifiers.filter((_, index) => (bits & 1 << index) !== 0));
|
|
81
|
+
const scopes = scopesOf(type, modifiers, scoped);
|
|
82
|
+
if (scopes !== null) {
|
|
83
|
+
result.push({
|
|
84
|
+
line,
|
|
85
|
+
character,
|
|
86
|
+
length: data[at + 2],
|
|
87
|
+
scopes
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const embedded = EMBEDDED_SCOPES[type];
|
|
92
|
+
if (embedded !== undefined) {
|
|
93
|
+
result.push({
|
|
94
|
+
line,
|
|
95
|
+
character,
|
|
96
|
+
length: data[at + 2],
|
|
97
|
+
scopes: embedded,
|
|
98
|
+
within: 'string'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|