Skip to content
Snippets Groups Projects
Commit 52af885d authored by David Bühler's avatar David Bühler
Browse files

[ivette] ASTview: adds contextual menu "go to callers" on functions declaration.

Uses the Eva request "eva.callers".
parent a470b4dc
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,21 @@ async function loadAST( ...@@ -64,6 +64,21 @@ async function loadAST(
} }
} }
async function callers(updateSelection: any, kf: string) {
try {
const data = await Server.GET({
endpoint: 'eva.callers',
params: kf,
});
const locations = data.map((d: string[2]) => (
{ function: d[0], marker: d[1] }
));
updateSelection({ locations });
} catch (err) {
PP.error('Fail to retrieve callers of function', kf, err);
}
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- AST Printer // --- AST Printer
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -107,17 +122,27 @@ const ASTview = () => { ...@@ -107,17 +122,27 @@ const ASTview = () => {
} }
function onContextMenu(id: string) { function onContextMenu(id: string) {
const items = [];
const marker = markers[id]; const marker = markers[id];
if (marker && marker.kind === 'function') { if (marker?.kind === 'lvalue' && marker?.var === 'function') {
const item = { items.push({
label: `Go to definition of ${marker.name}`, label: `Go to definition of ${marker.name}`,
onClick: () => { onClick: () => {
const location = { function: marker.name }; const location = { function: marker.name };
updateSelection({ location }); updateSelection({ location });
}, },
}; });
Dome.popupMenu([item]); }
if (marker?.kind === 'declaration'
&& marker?.var === 'function'
&& marker?.name) {
items.push({
label: 'Go to callers',
onClick: () => callers(updateSelection, marker.name),
});
} }
if (items.length > 0)
Dome.popupMenu(items);
} }
// Theme Popup // Theme Popup
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment