@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.
Files changed (137) hide show
  1. package/dist/AnchoredPopup.js +73 -19
  2. package/dist/AttributionCard.js +162 -4
  3. package/dist/BaselineStatus.js +62 -8
  4. package/dist/CallHierarchyPanel.js +977 -60
  5. package/dist/ChangeReview.js +76 -25
  6. package/dist/CodeAuthorsCard.js +314 -14
  7. package/dist/CompletionPopup.js +490 -83
  8. package/dist/DiffView.js +548 -181
  9. package/dist/EditorContextMenu.js +352 -34
  10. package/dist/EditorView.js +276 -99
  11. package/dist/FindReplace.js +525 -67
  12. package/dist/HoverCard.js +378 -38
  13. package/dist/HoverSections.js +367 -56
  14. package/dist/LanguagePopups.js +95 -34
  15. package/dist/Markdown.js +41 -6
  16. package/dist/PanelResizeHandle.js +199 -66
  17. package/dist/PathText.js +49 -7
  18. package/dist/PeekPanel.js +675 -72
  19. package/dist/PickPopup.js +304 -34
  20. package/dist/RenameCard.js +679 -85
  21. package/dist/RenderedDocs.js +329 -58
  22. package/dist/SignatureCard.js +91 -7
  23. package/dist/SplitDiffView.js +344 -254
  24. package/dist/SymbolPicker.js +440 -85
  25. package/dist/call-hierarchy-model.js +102 -68
  26. package/dist/call-hierarchy.js +458 -359
  27. package/dist/code-actions-model.js +88 -76
  28. package/dist/code-actions.js +372 -283
  29. package/dist/code-authors.js +64 -55
  30. package/dist/code-vision-model.js +134 -127
  31. package/dist/code-vision.js +224 -206
  32. package/dist/completion-call.js +94 -67
  33. package/dist/completion-model.js +334 -244
  34. package/dist/completion.js +840 -649
  35. package/dist/conflict-model.js +35 -29
  36. package/dist/context-menu-rows.js +42 -17
  37. package/dist/context-menu.js +64 -46
  38. package/dist/definition-link.js +88 -85
  39. package/dist/diagnostics-model.js +74 -55
  40. package/dist/diagnostics.js +121 -100
  41. package/dist/diff-expansion.js +38 -35
  42. package/dist/diff-overlays.js +144 -22
  43. package/dist/diff-syntax.js +65 -42
  44. package/dist/diff-wordmarks.js +26 -23
  45. package/dist/doc-comment-model.js +265 -216
  46. package/dist/editor-language.js +177 -152
  47. package/dist/error-message.js +2 -2
  48. package/dist/find-query.js +49 -36
  49. package/dist/folding.js +81 -62
  50. package/dist/format-on-type.js +86 -67
  51. package/dist/highlight-layers.js +19 -20
  52. package/dist/highlights.js +105 -83
  53. package/dist/history.js +44 -38
  54. package/dist/holder.js +18 -18
  55. package/dist/host-types.js +1 -1
  56. package/dist/hover-content.js +167 -129
  57. package/dist/hover.js +285 -245
  58. package/dist/index.js +10 -10
  59. package/dist/inlay-hints.js +369 -324
  60. package/dist/key-priority.js +34 -31
  61. package/dist/language-ids.js +45 -42
  62. package/dist/line-edits.js +74 -28
  63. package/dist/line-text.js +18 -3
  64. package/dist/locales/en.json +38 -38
  65. package/dist/locales/nl.json +41 -41
  66. package/dist/models.js +1 -1
  67. package/dist/navigation-history.js +40 -41
  68. package/dist/navigation.js +141 -123
  69. package/dist/panel-size.js +8 -8
  70. package/dist/patch-decorations.js +236 -160
  71. package/dist/patch-layout.js +331 -262
  72. package/dist/paths.js +3 -3
  73. package/dist/peek-model.js +86 -69
  74. package/dist/peek.js +254 -192
  75. package/dist/pick.js +164 -157
  76. package/dist/popup-focus.js +5 -5
  77. package/dist/popup-placement.js +36 -21
  78. package/dist/popups.js +13 -13
  79. package/dist/project-language.js +228 -211
  80. package/dist/project-problems.js +81 -69
  81. package/dist/proposal-model.js +163 -126
  82. package/dist/recent-choices.js +25 -25
  83. package/dist/refresher.js +44 -49
  84. package/dist/rename-model.js +113 -113
  85. package/dist/rename.js +321 -233
  86. package/dist/rendered-docs.d.ts +4 -2
  87. package/dist/rendered-docs.js +384 -318
  88. package/dist/rendering-context.js +5 -3
  89. package/dist/rendering.js +22 -4
  90. package/dist/review-group.js +42 -39
  91. package/dist/row-host.d.ts +4 -2
  92. package/dist/row-host.js +90 -78
  93. package/dist/selection-ranges.js +21 -17
  94. package/dist/semantic-delta.js +22 -19
  95. package/dist/semantic-model.js +86 -73
  96. package/dist/semantic-tokens.js +201 -162
  97. package/dist/shortcut-keys.js +16 -10
  98. package/dist/signature-model.js +34 -28
  99. package/dist/signature.js +177 -129
  100. package/dist/snippet-field-transforms.js +118 -106
  101. package/dist/snippet-indent.js +48 -43
  102. package/dist/snippet-range-order.js +11 -11
  103. package/dist/snippet-session.js +703 -667
  104. package/dist/snippet-transform-client.js +59 -59
  105. package/dist/snippet-transform-format.js +285 -263
  106. package/dist/snippet-transform-protocol.js +1 -1
  107. package/dist/snippet-transform-queue.js +163 -153
  108. package/dist/snippet-transform-worker.js +42 -35
  109. package/dist/snippet-variable-names.js +1 -36
  110. package/dist/snippet-variables.js +53 -63
  111. package/dist/snippet.js +477 -405
  112. package/dist/split-alignment.js +47 -35
  113. package/dist/split-scroll.js +42 -40
  114. package/dist/symbol-links.js +33 -25
  115. package/dist/symbol-picker-model.js +126 -116
  116. package/dist/symbol-picker.js +98 -59
  117. package/dist/symbols.js +117 -88
  118. package/dist/testing.js +248 -165
  119. package/dist/timers.js +35 -30
  120. package/dist/use-panel-body.js +49 -8
  121. package/dist/use-problem-counts.js +29 -15
  122. package/dist/view-state.js +54 -33
  123. package/dist/word-diff.js +18 -18
  124. package/dist/workspace-edit.js +300 -249
  125. package/package.json +6 -6
  126. package/src/CallHierarchyPanel.tsx +2 -2
  127. package/src/DiffView.tsx +3 -3
  128. package/src/FindReplace.tsx +2 -2
  129. package/src/LanguagePopups.tsx +2 -0
  130. package/src/PeekPanel.tsx +3 -3
  131. package/src/RenderedDocs.tsx +9 -10
  132. package/src/SymbolPicker.tsx +2 -2
  133. package/src/diff-overlays.tsx +6 -4
  134. package/src/locales/en.json +38 -38
  135. package/src/locales/nl.json +41 -41
  136. package/src/rendered-docs.ts +14 -3
  137. package/src/row-host.ts +14 -3
@@ -3,144 +3,144 @@ import { rangeHolds } from './diagnostics-model.js';
3
3
  import { textEntriesOf } from './workspace-edit.js';
4
4
  /* The identifier the caret is in or touches; null where there is none. */
5
5
  export function wordRangeAt(lineText, position) {
6
- let start = Math.min(position.character, lineText.length);
7
- let end = start;
8
- while (start > 0 && isIdentifierCharacter(lineText[start - 1])) {
9
- start--;
6
+ let start = Math.min(position.character, lineText.length);
7
+ let end = start;
8
+ while (start > 0 && isIdentifierCharacter(lineText[start - 1])) {
9
+ start--;
10
+ }
11
+ while (end < lineText.length && isIdentifierCharacter(lineText[end])) {
12
+ end++;
13
+ }
14
+ return start === end ? null : {
15
+ start: {
16
+ line: position.line,
17
+ character: start
18
+ },
19
+ end: {
20
+ line: position.line,
21
+ character: end
10
22
  }
11
- while (end < lineText.length && isIdentifierCharacter(lineText[end])) {
12
- end++;
13
- }
14
- return start === end ? null : { start: { line: position.line, character: start }, end: { line: position.line, character: end } };
23
+ };
15
24
  }
16
25
  /*
17
26
  * The target of a prepare answer. A server that answers with a bare range or the default behavior leaves
18
27
  * the name to the text, and one that answers null says nothing here can be renamed.
19
28
  */
20
29
  export function renameTargetOf(result, textOf, wordAtCaret) {
21
- if (result === null) {
22
- return null;
23
- }
24
- if ('placeholder' in result) {
25
- return { range: result.range, placeholder: result.placeholder };
26
- }
27
- if ('start' in result) {
28
- return { range: result, placeholder: textOf(result) };
29
- }
30
- const word = wordAtCaret();
31
- return word === null ? null : { range: word, placeholder: textOf(word) };
32
- }
33
- export function occurrencesOf(locations, uri) {
30
+ if (result === null) {
31
+ return null;
32
+ }
33
+ if ('placeholder' in result) {
34
34
  return {
35
- inFile: locations.filter((location) => location.uri === uri).map((location) => location.range),
36
- count: locations.length,
37
- files: new Set(locations.map((location) => location.uri)).size
35
+ range: result.range,
36
+ placeholder: result.placeholder
38
37
  };
38
+ }
39
+ if ('start' in result) {
40
+ return {
41
+ range: result,
42
+ placeholder: textOf(result)
43
+ };
44
+ }
45
+ const word = wordAtCaret();
46
+ return word === null ? null : {
47
+ range: word,
48
+ placeholder: textOf(word)
49
+ };
50
+ }
51
+ export function occurrencesOf(locations, uri) {
52
+ return {
53
+ inFile: locations.filter(location => location.uri === uri).map(location => location.range),
54
+ count: locations.length,
55
+ files: new Set(locations.map(location => location.uri)).size
56
+ };
39
57
  }
40
58
  /* LSP's SymbolKind in words, indexed by its number. */
41
- const SYMBOL_KINDS = [
42
- '',
43
- 'file',
44
- 'module',
45
- 'namespace',
46
- 'package',
47
- 'class',
48
- 'method',
49
- 'property',
50
- 'field',
51
- 'constructor',
52
- 'enum',
53
- 'interface',
54
- 'function',
55
- 'variable',
56
- 'constant',
57
- 'string',
58
- 'number',
59
- 'boolean',
60
- 'array',
61
- 'object',
62
- 'key',
63
- 'null',
64
- 'enum member',
65
- 'struct',
66
- 'event',
67
- 'operator',
68
- 'type parameter'
69
- ];
59
+ const SYMBOL_KINDS = ['', 'file', 'module', 'namespace', 'package', 'class', 'method', 'property', 'field', 'constructor', 'enum', 'interface', 'function', 'variable', 'constant', 'string', 'number', 'boolean', 'array', 'object', 'key', 'null', 'enum member', 'struct', 'event', 'operator', 'type parameter'];
70
60
  /*
71
61
  * The kind of the symbol a rename names, in words, from the outline of the open file: the symbol whose name
72
62
  * holds one of the places of the name there. Undefined when the outline does not list it, as with most locals.
73
63
  */
74
64
  export function renameKindOf(result, name, places) {
75
- if (result === null || result.length === 0) {
76
- return undefined;
77
- }
78
- const named = (range) => places.some((place) => rangeHolds(range, place.start));
79
- if ('range' in result[0]) {
80
- let found;
81
- const walk = (symbols) => {
82
- for (const symbol of symbols) {
83
- if (named(symbol.selectionRange)) {
84
- found = symbol;
85
- }
86
- walk(symbol.children ?? []);
87
- }
88
- };
89
- walk(result);
90
- return found === undefined ? undefined : SYMBOL_KINDS[found.kind];
91
- }
92
- // A flat list only gives the whole span of a symbol, so the name has to match as well.
93
- const found = result.find((symbol) => 'location' in symbol && symbol.name === name && named(symbol.location.range));
65
+ if (result === null || result.length === 0) {
66
+ return undefined;
67
+ }
68
+ const named = range => places.some(place => rangeHolds(range, place.start));
69
+ if ('range' in result[0]) {
70
+ let found;
71
+ const walk = symbols => {
72
+ for (const symbol of symbols) {
73
+ if (named(symbol.selectionRange)) {
74
+ found = symbol;
75
+ }
76
+ walk(symbol.children ?? []);
77
+ }
78
+ };
79
+ walk(result);
94
80
  return found === undefined ? undefined : SYMBOL_KINDS[found.kind];
81
+ }
82
+ // A flat list only gives the whole span of a symbol, so the name has to match as well.
83
+ const found = result.find(symbol => 'location' in symbol && symbol.name === name && named(symbol.location.range));
84
+ return found === undefined ? undefined : SYMBOL_KINDS[found.kind];
95
85
  }
96
86
  function lineStarts(text) {
97
- const starts = [0];
98
- for (let index = 0; index < text.length; index++) {
99
- const code = text.charCodeAt(index);
100
- if (code === 13 && text.charCodeAt(index + 1) === 10) {
101
- index++;
102
- starts.push(index + 1);
103
- }
104
- else if (code === 10 || code === 13) {
105
- starts.push(index + 1);
106
- }
87
+ const starts = [0];
88
+ for (let index = 0; index < text.length; index++) {
89
+ const code = text.charCodeAt(index);
90
+ if (code === 13 && text.charCodeAt(index + 1) === 10) {
91
+ index++;
92
+ starts.push(index + 1);
93
+ } else if (code === 10 || code === 13) {
94
+ starts.push(index + 1);
107
95
  }
108
- return starts;
96
+ }
97
+ return starts;
109
98
  }
110
99
  /* The lines of a file an edit touches, each once, as they read before and after. An edit across lines is shown from its first line. */
111
100
  export function renameRowsOf(text, edits) {
112
- const starts = lineStarts(text);
113
- const lineAt = (line) => {
114
- const from = starts[line] ?? text.length;
115
- let to = (starts[line + 1] ?? text.length + 1) - 1;
116
- while (to > from && (text[to - 1] === '\n' || text[to - 1] === '\r')) {
117
- to--;
118
- }
119
- return { from, to: Math.min(to, text.length) };
101
+ const starts = lineStarts(text);
102
+ const lineAt = line => {
103
+ const from = starts[line] ?? text.length;
104
+ let to = (starts[line + 1] ?? text.length + 1) - 1;
105
+ while (to > from && (text[to - 1] === '\n' || text[to - 1] === '\r')) {
106
+ to--;
107
+ }
108
+ return {
109
+ from,
110
+ to: Math.min(to, text.length)
120
111
  };
121
- const byLine = new Map();
122
- for (const edit of edits) {
123
- byLine.set(edit.range.start.line, [...(byLine.get(edit.range.start.line) ?? []), edit]);
112
+ };
113
+ const byLine = new Map();
114
+ for (const edit of edits) {
115
+ byLine.set(edit.range.start.line, [...(byLine.get(edit.range.start.line) ?? []), edit]);
116
+ }
117
+ return [...byLine].sort((left, right) => left[0] - right[0]).map(([line, own]) => {
118
+ const {
119
+ from,
120
+ to
121
+ } = lineAt(line);
122
+ const before = text.slice(from, to);
123
+ let after = before;
124
+ for (const edit of [...own].sort((left, right) => right.range.start.character - left.range.start.character)) {
125
+ const end = edit.range.end.line === line ? edit.range.end.character : before.length;
126
+ after = after.slice(0, edit.range.start.character) + edit.newText + after.slice(end);
124
127
  }
125
- return [...byLine]
126
- .sort((left, right) => left[0] - right[0])
127
- .map(([line, own]) => {
128
- const { from, to } = lineAt(line);
129
- const before = text.slice(from, to);
130
- let after = before;
131
- for (const edit of [...own].sort((left, right) => right.range.start.character - left.range.start.character)) {
132
- const end = edit.range.end.line === line ? edit.range.end.character : before.length;
133
- after = after.slice(0, edit.range.start.character) + edit.newText + after.slice(end);
134
- }
135
- return { line: line + 1, before, after };
136
- });
128
+ return {
129
+ line: line + 1,
130
+ before,
131
+ after
132
+ };
133
+ });
137
134
  }
138
135
  /* The lines of the files an edit edits; the files it makes, moves or deletes are listed by `resourceOperationsOf`. */
139
136
  export async function renamePreviewOf(edit, textOf) {
140
- const files = [];
141
- for (const [uri, list] of textEntriesOf(edit)) {
142
- const text = await textOf(uri);
143
- files.push({ uri, rows: text === null ? [] : renameRowsOf(text, list.flat()) });
144
- }
145
- return files;
146
- }
137
+ const files = [];
138
+ for (const [uri, list] of textEntriesOf(edit)) {
139
+ const text = await textOf(uri);
140
+ files.push({
141
+ uri,
142
+ rows: text === null ? [] : renameRowsOf(text, list.flat())
143
+ });
144
+ }
145
+ return files;
146
+ }