Skip to content
Snippets Groups Projects
Commit ad4b146e authored by Michele Alberti's avatar Michele Alberti
Browse files

[ivette] Some refactoring to Locations components.

parent a70275dc
No related branches found
No related tags found
No related merge requests found
...@@ -65,16 +65,15 @@ async function loadAST( ...@@ -65,16 +65,15 @@ async function loadAST(
} }
} }
async function functionCallers( /** Compute the [[functionName]] caller locations. */
updateSelection: (a: States.SelectionActions) => void, async function functionCallers(functionName: string) {
kf: string,
) {
try { try {
const data = await Server.send(getCallers, kf); const data = await Server.send(getCallers, functionName);
const locations = data.map(([fct, marker]) => ({ function: fct, marker })); const locations = data.map(([fct, marker]) => ({ function: fct, marker }));
updateSelection({ locations }); return locations;
} catch (err) { } catch (err) {
PP.error(`Fail to retrieve callers of function ${kf}`, err); PP.error(`Fail to retrieve callers of function ${functionName}.`, err);
return [];
} }
} }
...@@ -145,7 +144,10 @@ const ASTview = () => { ...@@ -145,7 +144,10 @@ const ASTview = () => {
if (marker?.kind === 'declaration' && marker?.name) { if (marker?.kind === 'declaration' && marker?.name) {
items.push({ items.push({
label: 'Go to callers', label: 'Go to callers',
onClick: () => functionCallers(updateSelection, marker.name), onClick: async () => {
const locations = await functionCallers(marker.name);
updateSelection({ locations });
},
}); });
} }
if (items.length > 0) if (items.length > 0)
......
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