diff --git a/ivette/src/frama-c/index.tsx b/ivette/src/frama-c/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a63e1225775874f212c5494ee6591c58432c633e --- /dev/null +++ b/ivette/src/frama-c/index.tsx @@ -0,0 +1,69 @@ +/* --------------------------------------------------------------------------*/ +/* --- Frama-C Registry ---*/ +/* --------------------------------------------------------------------------*/ + +import React from 'react'; +import * as Ivette from 'ivette'; + +import History from 'frama-c/kernel/History'; +import Globals from 'frama-c/kernel/Globals'; +import ASTview from 'frama-c/kernel/ASTview'; +import ASTinfo from 'frama-c/kernel/ASTinfo'; +import SourceCode from 'frama-c/kernel/SourceCode'; +import Locations from 'frama-c/kernel/Locations'; +import Properties from 'frama-c/kernel/Properties'; + +import 'frama-c/kernel/style.css'; + +/* --------------------------------------------------------------------------*/ +/* --- Frama-C Kernel Groups ---*/ +/* --------------------------------------------------------------------------*/ + +Ivette.registerGroup({ + id: 'frama-c.kernel', + label: 'Frama-C Kernel', +}, () => { + Ivette.registerSidebar({ id: 'frama-c.globals', children: <Globals /> }); + Ivette.registerToolbar({ id: 'frama-c.history', children: <History /> }); + Ivette.registerComponent({ + id: 'frama-c.astview', + label: 'AST', + title: 'Normalized C/ACSL Source Code', + children: <ASTview />, + }); + Ivette.registerComponent({ + id: 'frama-c.astinfo', + label: 'Informations', + title: 'Informations on currently selected item', + children: <ASTinfo />, + }); + Ivette.registerComponent({ + id: 'frama-c.sourcecode', + label: 'Source Code', + title: 'C/ASCL Source Code', + children: <SourceCode />, + }); + Ivette.registerComponent({ + id: 'frama-c.locations', + label: 'Locations', + title: 'Selected list of locations', + children: <Locations />, + }); + Ivette.registerComponent({ + id: 'frama-c.properties', + label: 'Properties', + title: 'Status of ASCL Properties', + children: <Properties />, + }); +}); + +/* --------------------------------------------------------------------------*/ +/* --- Frama-C Plug-ins Group ---*/ +/* --------------------------------------------------------------------------*/ + +Ivette.registerGroup({ + id: 'frama-c.plugins', + label: 'Frama-C Plug-ins', +}); + +/* --------------------------------------------------------------------------*/ diff --git a/ivette/src/frama-c/kernel/ASTinfo.tsx b/ivette/src/frama-c/kernel/ASTinfo.tsx index dedaf8985eafd646b8d0820e8ef3a4b2c1838867..75e85684bdb488849a75da5df3274cf3d5606897 100644 --- a/ivette/src/frama-c/kernel/ASTinfo.tsx +++ b/ivette/src/frama-c/kernel/ASTinfo.tsx @@ -9,14 +9,13 @@ import * as Utils from 'frama-c/utils'; import { Vfill } from 'dome/layout/boxes'; import { RichTextBuffer } from 'dome/text/buffers'; import { Text } from 'dome/text/editors'; -import { Component } from 'ivette'; import { getInfo } from 'frama-c/api/kernel/ast'; // -------------------------------------------------------------------------- // --- Information Panel // -------------------------------------------------------------------------- -const ASTinfo = () => { +export default function ASTinfo() { const buffer = React.useMemo(() => new RichTextBuffer(), []); const [selection, updateSelection] = States.useSelection(); @@ -51,20 +50,6 @@ const ASTinfo = () => { </Vfill> </> ); -}; - -// -------------------------------------------------------------------------- -// --- Export Component -// -------------------------------------------------------------------------- - -export default () => ( - <Component - id="frama-c.astinfo" - label="Information" - title="AST Information" - > - <ASTinfo /> - </Component> -); +} // -------------------------------------------------------------------------- diff --git a/ivette/src/frama-c/kernel/ASTview.tsx b/ivette/src/frama-c/kernel/ASTview.tsx index 423a87859cb23c72b55e7c178ebbdfd4769affe4..7bf897426b521f111ee9abb307d1f80344c0d727 100644 --- a/ivette/src/frama-c/kernel/ASTview.tsx +++ b/ivette/src/frama-c/kernel/ASTview.tsx @@ -11,7 +11,7 @@ import * as Utils from 'frama-c/utils'; import * as Dome from 'dome'; import { RichTextBuffer } from 'dome/text/buffers'; import { Text } from 'dome/text/editors'; -import { Component, TitleBar } from 'ivette'; +import { TitleBar } from 'ivette'; import * as Preferences from 'ivette/prefs'; import * as Ast from 'frama-c/api/kernel/ast'; @@ -131,7 +131,7 @@ function makeBullet(status: States.Tag) { // --- AST Printer // -------------------------------------------------------------------------- -const ASTview = () => { +export default function ASTview() { // Hooks const buffer = React.useMemo(() => new RichTextBuffer(), []); @@ -291,20 +291,6 @@ const ASTview = () => { </> ); -}; - -// -------------------------------------------------------------------------- -// --- Export Component -// -------------------------------------------------------------------------- - -export default () => ( - <Component - id="frama-c.astview" - label="AST" - title="Normalized source code representation" - > - <ASTview /> - </Component> -); +} // -------------------------------------------------------------------------- diff --git a/ivette/src/frama-c/kernel/Locations.tsx b/ivette/src/frama-c/kernel/Locations.tsx index bafb5f61590b509393acf3ed04463249035cd027..3d5f9da244bddeb6ff5a2ed9fa36d2e99d09fcd1 100644 --- a/ivette/src/frama-c/kernel/Locations.tsx +++ b/ivette/src/frama-c/kernel/Locations.tsx @@ -11,7 +11,7 @@ import { Table, Column, Renderer } from 'dome/table/views'; import { Label } from 'dome/controls/labels'; import { IconButton } from 'dome/controls/buttons'; import { Space } from 'dome/frame/toolbars'; -import { Component, TitleBar } from 'ivette'; +import { TitleBar } from 'ivette'; import { markerInfo } from 'frama-c/api/kernel/ast'; // -------------------------------------------------------------------------- @@ -20,7 +20,7 @@ import { markerInfo } from 'frama-c/api/kernel/ast'; type LocationId = States.Location & { id: number }; -const LocationsTable = () => { +export default function LocationsTable() { // Hooks const [selection, updateSelection] = States.useSelection(); @@ -134,20 +134,6 @@ const LocationsTable = () => { </Table> </> ); -}; - -// -------------------------------------------------------------------------- -// --- Export Component -// -------------------------------------------------------------------------- - -export default () => ( - <Component - id="frama-c.locations" - label="Locations" - title="Browse multiple locations" - > - <LocationsTable /> - </Component> -); +} // -------------------------------------------------------------------------- diff --git a/ivette/src/frama-c/kernel/Properties.tsx b/ivette/src/frama-c/kernel/Properties.tsx index cc71c812c832219da065e23b989900b201ae1e32..5024f12f3e0ce47a2bbfb0d88d4a43edb8b4c2ec 100644 --- a/ivette/src/frama-c/kernel/Properties.tsx +++ b/ivette/src/frama-c/kernel/Properties.tsx @@ -14,7 +14,7 @@ import { IconButton, Checkbox } from 'dome/controls/buttons'; import * as Models from 'dome/table/models'; import * as Arrays from 'dome/table/arrays'; import { Table, Column, ColumnProps, Renderer } from 'dome/table/views'; -import { TitleBar, Component } from 'ivette'; +import { TitleBar } from 'ivette'; import { Scroll, Folder } from 'dome/layout/boxes'; import { RSplit } from 'dome/layout/splitters'; @@ -467,7 +467,8 @@ function FilterRatio({ model }: { model: PropertyModel }) { // --- Properties Table // ------------------------------------------------------------------------- -const RenderTable = () => { +export default function RenderProperties() { + // Hooks const model = React.useMemo(() => new PropertyModel(), []); const data = States.useSyncArray(Properties.status).getArray(); @@ -528,20 +529,6 @@ const RenderTable = () => { </RSplit> </> ); -}; - -// -------------------------------------------------------------------------- -// --- Export Component -// ------------------------------------------------------------------------- - -export default () => ( - <Component - id="frama-c.properties" - label="Properties" - title="Registered ACSL properties status" - > - <RenderTable /> - </Component> -); +} // -------------------------------------------------------------------------- diff --git a/ivette/src/frama-c/kernel/SourceCode.tsx b/ivette/src/frama-c/kernel/SourceCode.tsx index 8a9f35da7b135b00cd1e865189728dbb134673b7..9fb4f2082b3f11e93b9a94de6fa88b546ad0614a 100644 --- a/ivette/src/frama-c/kernel/SourceCode.tsx +++ b/ivette/src/frama-c/kernel/SourceCode.tsx @@ -9,7 +9,7 @@ import * as Dome from 'dome'; import { readFile } from 'dome/system'; import { RichTextBuffer } from 'dome/text/buffers'; import { Text } from 'dome/text/editors'; -import { Component, TitleBar } from 'ivette'; +import { TitleBar } from 'ivette'; import * as Preferences from 'ivette/prefs'; import { functions, markerInfo } from 'frama-c/api/kernel/ast'; import { source } from 'frama-c/api/kernel/services'; @@ -31,7 +31,7 @@ const D = new Dome.Debug('Source Code'); // --- Source Code Printer // -------------------------------------------------------------------------- -const SourceCode = () => { +export default function SourceCode() { // Hooks const buffer = React.useMemo(() => new RichTextBuffer(), []); @@ -104,20 +104,6 @@ const SourceCode = () => { </> ); -}; - -// -------------------------------------------------------------------------- -// --- Export Component -// -------------------------------------------------------------------------- - -export default () => ( - <Component - id="frama-c.sourcecode" - label="Source Code" - title="Original source code" - > - <SourceCode /> - </Component> -); +} // -------------------------------------------------------------------------- diff --git a/ivette/src/frama-c/plugins/dive/index.tsx b/ivette/src/frama-c/plugins/dive/index.tsx index 840fa2efe0eda7b25ea3931136374417e60b850e..607b5065878ebe9b83a71a982d0c0c6b32bfc9cf 100644 --- a/ivette/src/frama-c/plugins/dive/index.tsx +++ b/ivette/src/frama-c/plugins/dive/index.tsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import _ from 'lodash'; import { renderToString } from 'react-dom/server'; import * as Dome from 'dome'; +import * as Ivette from 'ivette'; import * as Server from 'frama-c/server'; import * as States from 'frama-c/states'; @@ -20,7 +21,6 @@ import './tippy.css'; import { IconButton } from 'dome/controls/buttons'; import { Space } from 'dome/frame/toolbars'; -import { Component, TitleBar } from 'ivette'; import '@fortawesome/fontawesome-free/js/all'; @@ -495,7 +495,7 @@ class Dive { } } -const GraphView = () => { +function GraphView() { // Hooks const [dive, setDive] = useState(() => new Dive()); @@ -565,7 +565,7 @@ const GraphView = () => { // Component return ( <> - <TitleBar> + <Ivette.TitleBar> <IconButton icon="LOCK" onClick={flipLock} @@ -590,7 +590,7 @@ const GraphView = () => { onClick={() => dive.clear()} title="Clear the graph" /> - </TitleBar> + </Ivette.TitleBar> <CytoscapeComponent stylesheet={style} cy={setCy} @@ -599,21 +599,21 @@ const GraphView = () => { </> ); -}; +} // -------------------------------------------------------------------------- // --- Export Component // -------------------------------------------------------------------------- -export default () => ( - <Component - id="dive.graph" - label="Data-flow graph" - title={'Data dependency graph according to an Eva analysis.\nNodes color ' + - 'represents the precision of the values inferred by Eva.'} - > - <GraphView /> - </Component> -); +Ivette.registerComponent({ + id: 'frama-c.plugins.dive', + label: 'Data-flow graph', + group: 'frama-c.plugins', + rank: 2, + title: + 'Data dependency graph according to an Eva analysis.\nNodes color ' + + 'represents the precision of the values inferred by Eva.', + children: <GraphView />, +}); // -------------------------------------------------------------------------- diff --git a/ivette/src/frama-c/plugins/eva/index.tsx b/ivette/src/frama-c/plugins/eva/index.tsx index cff472e3ca9ae07b3f43051f1136b5a0c9132f8c..91c24dfae8e4033152c3f41962251cf5aa8e81b8 100644 --- a/ivette/src/frama-c/plugins/eva/index.tsx +++ b/ivette/src/frama-c/plugins/eva/index.tsx @@ -5,15 +5,11 @@ // React & Dome import React from 'react'; import * as Dome from 'dome'; +import * as Ivette from 'ivette'; import { Vfill } from 'dome/layout/boxes'; import { IconButton } from 'dome/controls/buttons'; - -// External Libs import { AutoSizer } from 'react-virtualized'; -// Frama-C -import { Component, TitleBar } from 'ivette'; - // Locals import { ProbeInfos } from './probeinfos'; import { Dimension, ValuesPanel } from './valuetable'; @@ -28,7 +24,7 @@ function ValuesComponent() { const [zoom, setZoom] = Dome.useNumberSettings('eva-zoom-factor', 0); return ( <> - <TitleBar> + <Ivette.TitleBar> <IconButton enabled={zoom > 0} icon="ZOOM.OUT" @@ -39,7 +35,7 @@ function ValuesComponent() { icon="ZOOM.IN" onClick={() => setZoom(zoom + 1)} /> - </TitleBar> + </Ivette.TitleBar> <Vfill> <ProbeInfos /> <Vfill> @@ -63,14 +59,12 @@ function ValuesComponent() { // --- Export Component // -------------------------------------------------------------------------- -export default () => ( - <Component - id="frama-c.values" - label="Eva Values" - title="Values inferred by the Eva analysis" - > - <ValuesComponent /> - </Component> -); +Ivette.registerComponent({ + id: 'frama-c.plugins.values', + group: 'frama-c.plugins', + label: 'Eva Values', + title: 'Values inferred by the Eva analysis', + children: <ValuesComponent />, +}); // -------------------------------------------------------------------------- diff --git a/ivette/src/renderer/Application.tsx b/ivette/src/renderer/Application.tsx index c32c4000916cd588df2eba1c8adbd3fb924b3d77..7da66a8b13affd622e546ad5f65ef11d597bbca4 100644 --- a/ivette/src/renderer/Application.tsx +++ b/ivette/src/renderer/Application.tsx @@ -11,28 +11,11 @@ import { LSplit } from 'dome/layout/splitters'; import * as Toolbar from 'dome/frame/toolbars'; import * as Sidebar from 'dome/frame/sidebars'; import { GridHbox, GridItem } from 'dome/layout/grids'; - -// --- Ivette - -import { View, Group } from 'ivette'; - -// --- Frama-C - -import History from 'frama-c/kernel/History'; -import Globals from 'frama-c/kernel/Globals'; -import ASTview from 'frama-c/kernel/ASTview'; -import ASTinfo from 'frama-c/kernel/ASTinfo'; -import Properties from 'frama-c/kernel/Properties'; -import Locations from 'frama-c/kernel/Locations'; -import SourceCode from 'frama-c/kernel/SourceCode'; -import Values from 'frama-c/plugins/eva'; -import Dive from 'frama-c/plugins/dive'; - +import { View } from 'ivette'; import * as Controller from './Controller'; import * as Extensions from './Extensions'; -import { LabView } from './LabView'; - -import 'frama-c/kernel/style.css'; +import * as Laboratory from './LabView'; +import './PackageLoader'; // -------------------------------------------------------------------------- // --- Main View @@ -58,7 +41,7 @@ export default (() => { onClick={flipSidebar} /> <Controller.Control /> - <History /> + <Extensions.Toolbar /> <Toolbar.Filler /> <Toolbar.SearchField placeholder="Search…" @@ -77,9 +60,9 @@ export default (() => { <LSplit settings="frama-c.sidebar.split" unfold={sidebar}> <Sidebar.SideBar> <div className="sidebar-ruler" /> - <Globals /> + <Extensions.Sidebar /> </Sidebar.SideBar> - <LabView + <Laboratory.LabView customize={viewbar} settings="frama-c.labview" > @@ -89,14 +72,14 @@ export default (() => { <View id="values" label="Values"> <GridHbox> <GridItem id="frama-c.astview" /> - <GridItem id="frama-c.values" /> + <GridItem id="frama-c.plugins.values" /> </GridHbox> <GridItem id="frama-c.properties" /> </View> <View id="dive" label="Dive"> <GridHbox> <GridItem id="frama-c.astview" /> - <GridItem id="dive.graph" /> + <GridItem id="frama-c.plugins.dive" /> <GridItem id="frama-c.locations" /> </GridHbox> <GridHbox> @@ -104,20 +87,11 @@ export default (() => { <GridItem id="frama-c.console" /> </GridHbox> </View> - <Group id="frama-c" label="Frama-C" title="Frama-C Kernel Components"> - <Controller.Console /> - <Properties /> - <SourceCode /> - <ASTview /> - <ASTinfo /> - <Locations /> - <Dive /> - <Values /> - </Group> - </LabView> + </Laboratory.LabView> </LSplit> <Toolbar.ToolBar> <Controller.Status /> + <Extensions.Statusbar /> <Toolbar.Filler /> <Controller.Stats /> </Toolbar.ToolBar> diff --git a/ivette/src/renderer/Controller.tsx b/ivette/src/renderer/Controller.tsx index 8174bf44ae687ab35ebf8300bc64240db9749222..bfbc957317e2edf787c034938548d04fb007d8bc 100644 --- a/ivette/src/renderer/Controller.tsx +++ b/ivette/src/renderer/Controller.tsx @@ -14,7 +14,7 @@ import { RichTextBuffer } from 'dome/text/buffers'; import { Text } from 'dome/text/editors'; import * as Server from 'frama-c/server'; -import { Component, TitleBar } from 'ivette'; +import { registerComponent, TitleBar } from 'ivette'; import 'codemirror/theme/ambiance.css'; @@ -311,15 +311,14 @@ const RenderConsole = () => { ); }; -export const Console = () => ( - <Component - id="frama-c.console" - label="Console" - title="Frama-C Server Output & Command Line" - > - <RenderConsole /> - </Component> -); +registerComponent({ + id: 'frama-c.console', + group: 'frama-c.kernel', + label: 'Console', + title: 'Frama-C Server Output & Command Line', + rank: -1, + children: <RenderConsole />, +}); // -------------------------------------------------------------------------- // --- Status diff --git a/ivette/src/renderer/LabView.tsx b/ivette/src/renderer/LabView.tsx index eb220ac43b53ae28a563fc0e331a9d3aac7dd6b8..3218c3e4d7033c62b3f40c6f841a074023770929 100644 --- a/ivette/src/renderer/LabView.tsx +++ b/ivette/src/renderer/LabView.tsx @@ -145,7 +145,6 @@ export function addLibraryItem( { id, ...props }: any, ) { const itemId = `${fd}.${id}`; - console.log('ITEM', itemId, group, order, props); LIBRARY.addItem(itemId, group, order, props); } diff --git a/ivette/src/renderer/PackageLoader.tsx b/ivette/src/renderer/PackageLoader.tsx new file mode 100644 index 0000000000000000000000000000000000000000..df0c5edbe93256e63a089f0a01506f3b216c500a --- /dev/null +++ b/ivette/src/renderer/PackageLoader.tsx @@ -0,0 +1,9 @@ +/* --------------------------------------------------------------------------*/ +/* --- This file is intended to be generated ---*/ +/* --------------------------------------------------------------------------*/ + +import 'frama-c'; +import 'frama-c/plugins/eva'; +import 'frama-c/plugins/dive'; + +/* --------------------------------------------------------------------------*/