@adecore/editor-react 0.31.11 → 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
package/dist/code-authors.js
CHANGED
|
@@ -8,72 +8,81 @@ export const UNCOMMITTED = -1;
|
|
|
8
8
|
* pasted has none, which reads as uncommitted. Null when the blame is not of that text.
|
|
9
9
|
*/
|
|
10
10
|
export function mapBlame(blame, base, current) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const baseLines = splitLines(base);
|
|
12
|
+
if (blame.lines.length !== baseLines.length) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const mapped = new Int32Array(current.length).fill(UNCOMMITTED);
|
|
16
|
+
let basePosition = 0;
|
|
17
|
+
let position = 0;
|
|
18
|
+
const carry = until => {
|
|
19
|
+
for (; position < until; position++, basePosition++) {
|
|
20
|
+
mapped[position] = blame.lines[basePosition];
|
|
14
21
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (const change of diffLines(baseLines, current)) {
|
|
24
|
-
carry(change.otherStart);
|
|
25
|
-
position = change.otherEnd;
|
|
26
|
-
basePosition = change.baseEnd;
|
|
27
|
-
}
|
|
28
|
-
carry(current.length);
|
|
29
|
-
return mapped;
|
|
22
|
+
};
|
|
23
|
+
for (const change of diffLines(baseLines, current)) {
|
|
24
|
+
carry(change.otherStart);
|
|
25
|
+
position = change.otherEnd;
|
|
26
|
+
basePosition = change.baseEnd;
|
|
27
|
+
}
|
|
28
|
+
carry(current.length);
|
|
29
|
+
return mapped;
|
|
30
30
|
}
|
|
31
31
|
/* A person's name as git has it, with runs of space made one. */
|
|
32
32
|
export function shortName(name) {
|
|
33
|
-
|
|
33
|
+
return name.replace(/\s+/g, ' ').trim();
|
|
34
34
|
}
|
|
35
35
|
/*
|
|
36
36
|
* Who wrote the lines `from` through `to`. Blank lines count for no one and a line that is not
|
|
37
37
|
* committed for no author, so a method that is only edited keeps its author and says it was edited.
|
|
38
38
|
*/
|
|
39
39
|
export function authorshipOf(commits, mapped, lines, from, to) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
const author = byName.get(name) ?? { name, email: commit.email, lines: 0 };
|
|
62
|
-
author.lines++;
|
|
63
|
-
byName.set(name, author);
|
|
64
|
-
if (latest === null || commit.at > latest.at) {
|
|
65
|
-
latest = commit;
|
|
66
|
-
}
|
|
40
|
+
const byName = new Map();
|
|
41
|
+
let uncommittedLines = 0;
|
|
42
|
+
let modified = false;
|
|
43
|
+
let latest = null;
|
|
44
|
+
for (let line = from; line <= to && line < mapped.length; line++) {
|
|
45
|
+
const index = mapped[line];
|
|
46
|
+
if (index === UNCOMMITTED) {
|
|
47
|
+
modified = true;
|
|
48
|
+
}
|
|
49
|
+
if (lines[line].trim() === '') {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (index === UNCOMMITTED) {
|
|
53
|
+
uncommittedLines++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const commit = commits[index];
|
|
57
|
+
const name = shortName(commit.author);
|
|
58
|
+
if (name === '') {
|
|
59
|
+
continue;
|
|
67
60
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
61
|
+
const author = byName.get(name) ?? {
|
|
62
|
+
name,
|
|
63
|
+
email: commit.email,
|
|
64
|
+
lines: 0
|
|
65
|
+
};
|
|
66
|
+
author.lines++;
|
|
67
|
+
byName.set(name, author);
|
|
68
|
+
if (latest === null || commit.at > latest.at) {
|
|
69
|
+
latest = commit;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const authors = [...byName.values()].sort((left, right) => right.lines - left.lines || (left.name < right.name ? -1 : left.name > right.name ? 1 : 0));
|
|
73
|
+
return {
|
|
74
|
+
authors,
|
|
75
|
+
uncommittedLines,
|
|
76
|
+
modified,
|
|
77
|
+
latest
|
|
78
|
+
};
|
|
70
79
|
}
|
|
71
80
|
/* The row's words: the author with most lines, how many others wrote some, and a star when the range is edited since the commit. */
|
|
72
81
|
export function authorsText(authorship, i18n) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
82
|
+
const main = authorship.authors[0];
|
|
83
|
+
if (main === undefined) {
|
|
84
|
+
return i18n.t('editor:language.codeVision.newCode');
|
|
85
|
+
}
|
|
86
|
+
const others = authorship.authors.length - 1;
|
|
87
|
+
return `${main.name}${others > 0 ? ` +${formatNumber(others)}` : ''}${authorship.modified ? ' *' : ''}`;
|
|
88
|
+
}
|
|
@@ -18,118 +18,124 @@ const CALLABLES = new Set([METHOD, FUNCTION]);
|
|
|
18
18
|
/* Languages whose `#` starts a comment, so a docblock written with it is passed like any other. */
|
|
19
19
|
const HASH_COMMENTS = new Set(['php', 'python', 'shellscript', 'ruby', 'yaml', 'dockerfile']);
|
|
20
20
|
function isLocalName(name) {
|
|
21
|
-
|
|
21
|
+
return name === '' || name.startsWith('<') || name === 'default';
|
|
22
22
|
}
|
|
23
23
|
function isUsageKind(kind, parentKind) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (TYPES.has(kind) || CALLABLES.has(kind)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return (kind === PROPERTY || kind === FIELD || kind === CONSTANT) && (parentKind === CLASS || parentKind === STRUCT);
|
|
28
28
|
}
|
|
29
29
|
function isAuthorKind(kind) {
|
|
30
|
-
|
|
30
|
+
return TYPES.has(kind) || CALLABLES.has(kind) || kind === CONSTRUCTOR;
|
|
31
31
|
}
|
|
32
32
|
function walk(symbols, path, parentKind, out) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
33
|
+
for (const symbol of symbols) {
|
|
34
|
+
out.push({
|
|
35
|
+
name: symbol.name,
|
|
36
|
+
kind: symbol.kind,
|
|
37
|
+
start: symbol.range.start,
|
|
38
|
+
end: symbol.range.end,
|
|
39
|
+
namePosition: symbol.selectionRange.start,
|
|
40
|
+
path,
|
|
41
|
+
parentKind
|
|
42
|
+
});
|
|
43
|
+
// What a function or a method holds is local to it, and a row for a callback is noise.
|
|
44
|
+
if (CONTAINERS.has(symbol.kind)) {
|
|
45
|
+
walk(symbol.children ?? [], [...path, symbol.name], symbol.kind, out);
|
|
47
46
|
}
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
function candidatesOf(result) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return out;
|
|
53
|
-
}
|
|
54
|
-
if ('range' in result[0]) {
|
|
55
|
-
walk(result, [], null, out);
|
|
56
|
-
return out;
|
|
57
|
-
}
|
|
58
|
-
const flat = result;
|
|
59
|
-
const containers = new Map(flat.filter((symbol) => CONTAINERS.has(symbol.kind)).map((symbol) => [symbol.name, symbol.kind]));
|
|
60
|
-
for (const symbol of flat) {
|
|
61
|
-
const container = symbol.containerName ?? '';
|
|
62
|
-
if (container !== '' && !containers.has(container)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
out.push({
|
|
66
|
-
name: symbol.name,
|
|
67
|
-
kind: symbol.kind,
|
|
68
|
-
start: symbol.location.range.start,
|
|
69
|
-
end: symbol.location.range.end,
|
|
70
|
-
namePosition: null,
|
|
71
|
-
path: container === '' ? [] : [container],
|
|
72
|
-
parentKind: container === '' ? null : (containers.get(container) ?? null)
|
|
73
|
-
});
|
|
74
|
-
}
|
|
50
|
+
const out = [];
|
|
51
|
+
if (result === null || result.length === 0) {
|
|
75
52
|
return out;
|
|
53
|
+
}
|
|
54
|
+
if ('range' in result[0]) {
|
|
55
|
+
walk(result, [], null, out);
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
const flat = result;
|
|
59
|
+
const containers = new Map(flat.filter(symbol => CONTAINERS.has(symbol.kind)).map(symbol => [symbol.name, symbol.kind]));
|
|
60
|
+
for (const symbol of flat) {
|
|
61
|
+
const container = symbol.containerName ?? '';
|
|
62
|
+
if (container !== '' && !containers.has(container)) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
out.push({
|
|
66
|
+
name: symbol.name,
|
|
67
|
+
kind: symbol.kind,
|
|
68
|
+
start: symbol.location.range.start,
|
|
69
|
+
end: symbol.location.range.end,
|
|
70
|
+
namePosition: null,
|
|
71
|
+
path: container === '' ? [] : [container],
|
|
72
|
+
parentKind: container === '' ? null : containers.get(container) ?? null
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
76
|
}
|
|
77
77
|
/*
|
|
78
78
|
* Where a declaration really starts: past the comments and the blank lines a server counts into its
|
|
79
79
|
* range. Null when its range is nothing but comments.
|
|
80
80
|
*/
|
|
81
81
|
export function startAfterComments(source, from, to) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
if (text.startsWith('/*', at)) {
|
|
97
|
-
let end = text.indexOf('*/', at + 2);
|
|
98
|
-
let scan = line;
|
|
99
|
-
while (end === -1 && scan + 1 <= to.line && scan + 1 < source.lineCount) {
|
|
100
|
-
scan++;
|
|
101
|
-
end = source.lineAt(scan).indexOf('*/');
|
|
102
|
-
}
|
|
103
|
-
if (end === -1) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
line = scan;
|
|
107
|
-
character = end + 2;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (text.startsWith('//', at) || (hash && text[at] === '#' && text[at + 1] !== '[')) {
|
|
111
|
-
line++;
|
|
112
|
-
character = 0;
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
return line > to.line ? null : { line, character: at };
|
|
82
|
+
const hash = HASH_COMMENTS.has(source.languageId);
|
|
83
|
+
let line = from.line;
|
|
84
|
+
let character = from.character;
|
|
85
|
+
while (line <= to.line && line < source.lineCount) {
|
|
86
|
+
const text = source.lineAt(line);
|
|
87
|
+
let at = character;
|
|
88
|
+
while (at < text.length && (text[at] === ' ' || text[at] === '\t')) {
|
|
89
|
+
at++;
|
|
90
|
+
}
|
|
91
|
+
if (at >= text.length) {
|
|
92
|
+
line++;
|
|
93
|
+
character = 0;
|
|
94
|
+
continue;
|
|
116
95
|
}
|
|
117
|
-
|
|
96
|
+
if (text.startsWith('/*', at)) {
|
|
97
|
+
let end = text.indexOf('*/', at + 2);
|
|
98
|
+
let scan = line;
|
|
99
|
+
while (end === -1 && scan + 1 <= to.line && scan + 1 < source.lineCount) {
|
|
100
|
+
scan++;
|
|
101
|
+
end = source.lineAt(scan).indexOf('*/');
|
|
102
|
+
}
|
|
103
|
+
if (end === -1) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
line = scan;
|
|
107
|
+
character = end + 2;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (text.startsWith('//', at) || hash && text[at] === '#' && text[at + 1] !== '[') {
|
|
111
|
+
line++;
|
|
112
|
+
character = 0;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
return line > to.line ? null : {
|
|
116
|
+
line,
|
|
117
|
+
character: at
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
118
121
|
}
|
|
119
122
|
const CLOSERS = /^\s*[})\]]*[;,]?\s*$/;
|
|
120
123
|
/* The last line of a declaration that holds more than the brackets that close it or nothing, which is what its authors are read from. */
|
|
121
124
|
function lastLineWithCode(source, from, to) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
125
|
+
for (let line = Math.min(to, source.lineCount - 1); line > from; line--) {
|
|
126
|
+
if (!CLOSERS.test(source.lineAt(line))) {
|
|
127
|
+
return line;
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
}
|
|
130
|
+
return from;
|
|
128
131
|
}
|
|
129
132
|
/* Where the name starts when a server gave only a range: its first occurrence on the line the declaration starts on. */
|
|
130
133
|
function nameIn(source, name, start) {
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
const at = source.lineAt(start.line).indexOf(name, start.character);
|
|
135
|
+
return at === -1 ? null : {
|
|
136
|
+
line: start.line,
|
|
137
|
+
character: at
|
|
138
|
+
};
|
|
133
139
|
}
|
|
134
140
|
/*
|
|
135
141
|
* The declarations of a file a row is drawn above: classes, interfaces, enums, structs, functions and
|
|
@@ -137,47 +143,48 @@ function nameIn(source, name, start) {
|
|
|
137
143
|
* function. Only one that starts its line gets a row, since a row sits above the line.
|
|
138
144
|
*/
|
|
139
145
|
export function declarationsOf(result, source) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
const position = candidate.namePosition ?? nameIn(source, candidate.name, start);
|
|
156
|
-
if (position === null) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
const key = `${candidate.path.join('>')}>${candidate.name}#${candidate.kind}`;
|
|
160
|
-
const index = seen.get(key) ?? 0;
|
|
161
|
-
seen.set(key, index + 1);
|
|
162
|
-
declarations.push({
|
|
163
|
-
id: `${key}#${index}`,
|
|
164
|
-
name: candidate.name,
|
|
165
|
-
position,
|
|
166
|
-
line: start.line,
|
|
167
|
-
usages,
|
|
168
|
-
authors,
|
|
169
|
-
authorFrom: position.line,
|
|
170
|
-
authorTo: lastLineWithCode(source, position.line, candidate.end.line)
|
|
171
|
-
});
|
|
172
|
-
if (declarations.length > MAX_DECLARATIONS) {
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
146
|
+
const declarations = [];
|
|
147
|
+
const seen = new Map();
|
|
148
|
+
for (const candidate of candidatesOf(result)) {
|
|
149
|
+
if (isLocalName(candidate.name)) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const usages = isUsageKind(candidate.kind, candidate.parentKind) && !candidate.name.startsWith('__');
|
|
153
|
+
const authors = isAuthorKind(candidate.kind);
|
|
154
|
+
if (!usages && !authors) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const start = startAfterComments(source, candidate.start, candidate.end);
|
|
158
|
+
if (start === null || source.lineAt(start.line).slice(0, start.character).trim() !== '') {
|
|
159
|
+
continue;
|
|
175
160
|
}
|
|
176
|
-
|
|
161
|
+
const position = candidate.namePosition ?? nameIn(source, candidate.name, start);
|
|
162
|
+
if (position === null) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const key = `${candidate.path.join('>')}>${candidate.name}#${candidate.kind}`;
|
|
166
|
+
const index = seen.get(key) ?? 0;
|
|
167
|
+
seen.set(key, index + 1);
|
|
168
|
+
declarations.push({
|
|
169
|
+
id: `${key}#${index}`,
|
|
170
|
+
name: candidate.name,
|
|
171
|
+
position,
|
|
172
|
+
line: start.line,
|
|
173
|
+
usages,
|
|
174
|
+
authors,
|
|
175
|
+
authorFrom: position.line,
|
|
176
|
+
authorTo: lastLineWithCode(source, position.line, candidate.end.line)
|
|
177
|
+
});
|
|
178
|
+
if (declarations.length > MAX_DECLARATIONS) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return declarations;
|
|
177
183
|
}
|
|
178
184
|
/* "No usages", "1 usage" and "N usages". */
|
|
179
185
|
export function usagesText(count, i18n) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
186
|
+
return count === 0 ? i18n.t('editor:language.codeVision.usagesNone') : i18n.t('editor:language.codeVision.usages', {
|
|
187
|
+
count,
|
|
188
|
+
formatted: formatNumber(count)
|
|
189
|
+
});
|
|
190
|
+
}
|