From ad4b146e551b9da21a3a0cb73f576b96ffc35529 Mon Sep 17 00:00:00 2001 From: Michele Alberti <michele.alberti@cea.fr> Date: Wed, 15 Jul 2020 10:20:03 +0200 Subject: [PATCH] [ivette] Some refactoring to Locations components. --- ivette/src/renderer/ASTview.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ivette/src/renderer/ASTview.tsx b/ivette/src/renderer/ASTview.tsx index 6622778b4dd..4c946bb3960 100644 --- a/ivette/src/renderer/ASTview.tsx +++ b/ivette/src/renderer/ASTview.tsx @@ -65,16 +65,15 @@ async function loadAST( } } -async function functionCallers( - updateSelection: (a: States.SelectionActions) => void, - kf: string, -) { +/** Compute the [[functionName]] caller locations. */ +async function functionCallers(functionName: string) { try { - const data = await Server.send(getCallers, kf); + const data = await Server.send(getCallers, functionName); const locations = data.map(([fct, marker]) => ({ function: fct, marker })); - updateSelection({ locations }); + return locations; } 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 = () => { if (marker?.kind === 'declaration' && marker?.name) { items.push({ label: 'Go to callers', - onClick: () => functionCallers(updateSelection, marker.name), + onClick: async () => { + const locations = await functionCallers(marker.name); + updateSelection({ locations }); + }, }); } if (items.length > 0) -- GitLab