diff --git a/ivette/src/frama-c/states.js b/ivette/src/frama-c/states.js index 334a49f065f26c67df7b43054030cf2bf61dad55..7f1d3f78d05327762123b5b9f88540a75204f4de 100644 --- a/ivette/src/frama-c/states.js +++ b/ivette/src/frama-c/states.js @@ -434,7 +434,7 @@ const SELECTION = 'kernel.selection' ; setStateDefault( SELECTION , {} ); /** - @sumamry Current selection state. + @summary Current selection state. @return {array} `[selection,update]` for the current selection @description The selection is an object with many independant fields. diff --git a/ivette/src/renderer/ASTview.js b/ivette/src/renderer/ASTview.js index 0085ebf7cbf634c84eddaa76cc0d3fcde1c8df4d..e220194a0f318a5f17b92398ceaac526f18aa88c 100644 --- a/ivette/src/renderer/ASTview.js +++ b/ivette/src/renderer/ASTview.js @@ -43,26 +43,35 @@ const ASTview = () => { const buffer = React.useMemo( () => new Buffer(), []); const [ select, setSelect ] = States.useSelection(); const theFunction = select && select.function ; + const theMarker = select && select.marker ; + + // Hook: async loading React.useEffect( () => { buffer.clear(); if (theFunction) { - buffer.log('Loading',theFunction,'…'); + buffer.log('// Loading',theFunction,'…'); Server .sendGET("kernel.ast.printFunction", theFunction) .then(data => { buffer.clear(); + if (!data) + buffer.log('// No code for function ', theFunction); return print(buffer,data); }); } }, [ theFunction ] ); + // Callbacks + const onSelection = marker => setSelect({ marker }); + + // Component return ( <Vfill> - <div>Function: {select && select.function}</div> - <div>Marker: {select && select.marker}</div> <Text buffer={buffer} mode='text/x-csrc' theme='ambiance' + selection={theMarker} + onSelection={onSelection} readOnly /> </Vfill> );