Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
99fc3dd3
Commit
99fc3dd3
authored
1 year ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[ivette/wp] goal & list view
parent
6f96e181
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ivette/src/frama-c/plugins/wp/goals.tsx
+23
-14
23 additions, 14 deletions
ivette/src/frama-c/plugins/wp/goals.tsx
ivette/src/frama-c/plugins/wp/index.tsx
+37
-23
37 additions, 23 deletions
ivette/src/frama-c/plugins/wp/index.tsx
ivette/src/frama-c/states.ts
+2
-0
2 additions, 0 deletions
ivette/src/frama-c/states.ts
with
62 additions
and
37 deletions
ivette/src/frama-c/plugins/wp/goals.tsx
+
23
−
14
View file @
99fc3dd3
...
...
@@ -96,19 +96,27 @@ function filterGoal(
export
interface
GoalTableProps
{
scope
:
Ast
.
decl
|
undefined
;
failed
:
boolean
;
onFilter
:
(
goals
:
number
,
total
:
number
)
=>
void
;
display
:
boolean
;
current
:
WP
.
goal
;
setCurrent
:
(
goal
:
WP
.
goal
)
=>
void
;
setGoals
:
(
goals
:
number
)
=>
void
;
setTotal
:
(
total
:
number
)
=>
void
;
}
export
function
GoalTable
(
props
:
GoalTableProps
):
JSX
.
Element
{
const
{
scope
,
failed
,
onFilter
}
=
props
;
const
model
=
States
.
useSyncArrayModel
(
WP
.
goals
);
const
[
wpoSelection
,
setWpoSelection
]
=
React
.
useState
(
WP
.
goalDefault
);
const
onWpoSelection
=
React
.
useCallback
(
const
{
display
,
scope
,
failed
,
current
,
setCurrent
,
setGoals
,
setTotal
,
}
=
props
;
const
{
model
}
=
States
.
useSyncArrayProxy
(
WP
.
goals
);
const
goals
=
model
.
getRowCount
();
const
total
=
model
.
getTotalRowCount
();
const
onSelection
=
React
.
useCallback
(
({
wpo
,
property
}:
WP
.
goalsData
)
=>
{
States
.
setSelected
(
property
);
set
WpoSelection
(
wpo
);
},
[]);
set
Current
(
wpo
);
},
[
setCurrent
]);
React
.
useEffect
(()
=>
{
if
(
failed
||
!!
scope
)
{
...
...
@@ -116,17 +124,18 @@ export function GoalTable(props: GoalTableProps): JSX.Element {
}
else
{
model
.
setFilter
();
}
const
goals
=
model
.
getRowCount
(
);
const
total
=
model
.
getTotalRowCount
();
onFilter
(
goals
,
total
);
},
[
model
,
scope
,
failed
,
onFilter
]);
},
[
model
,
scope
,
failed
]
);
React
.
useEffect
(()
=>
setGoals
(
goals
)
,
[
goals
,
setGoals
]
);
React
.
useEffect
(()
=>
setTotal
(
total
),
[
total
,
setTotal
]);
return
(
<
Table
model
=
{
model
}
display
=
{
display
}
settings
=
'wp.goals'
onS
election
=
{
onWpoSelection
}
s
election
=
{
wp
oSelection
}
s
election
=
{
current
}
onS
election
=
{
o
n
Selection
}
>
<
Column
id
=
'scope'
label
=
'Scope'
width
=
{
150
}
...
...
This diff is collapsed.
Click to expand it.
ivette/src/frama-c/plugins/wp/index.tsx
+
37
−
23
View file @
99fc3dd3
...
...
@@ -41,32 +41,46 @@ import './style.css';
/* -------------------------------------------------------------------------- */
function
WPGoals
():
JSX
.
Element
{
const
[
scoped
,
flipScoped
]
=
Dome
.
useFlipSettings
(
'
frama-c.wp.goals.scoped
'
);
const
[
failed
,
flipFailed
]
=
Dome
.
useFlipSettings
(
'
frama-c.wp.goals.failed
'
);
const
[
scoped
,
flipScoped
]
=
Dome
.
useFlipSettings
(
'
frama-c.wp.goals.scoped
'
,
false
);
const
[
failed
,
flipFailed
]
=
Dome
.
useFlipSettings
(
'
frama-c.wp.goals.failed
'
,
true
);
const
[
list
,
flipListView
]
=
Dome
.
useFlipSettings
(
'
frama-c.wp.goals.list
'
,
true
);
const
[
current
,
setCurrent
]
=
React
.
useState
(
WP
.
goalDefault
);
const
scope
=
States
.
useCurrentScope
();
const
[
goals
,
setGoals
]
=
React
.
useState
(
0
);
const
[
total
,
setTotal
]
=
React
.
useState
(
0
);
const
onFilter
=
React
.
useCallback
((
goals
,
total
)
=>
{
setGoals
(
goals
);
setTotal
(
total
);
},
[
setGoals
,
setTotal
]);
const
current
=
scoped
?
scope
:
undefined
;
return
(
<>
<
Ivette
.
TitleBar
>
<
Label
display
=
{
goals
<
total
}
>
{
goals
}
/
{
total
}
</
Label
>
<
Inset
/>
<
IconButton
icon
=
'COMPONENT'
title
=
'Current Scope Only'
enabled
=
{
!!
current
}
selected
=
{
scoped
}
onClick
=
{
flipScoped
}
/>
<
IconButton
icon
=
'CIRC.QUESTION'
title
=
'Unresolved Goals Only'
selected
=
{
failed
}
onClick
=
{
flipFailed
}
/>
</
Ivette
.
TitleBar
>
<
GoalTable
scope
=
{
scope
}
failed
=
{
failed
}
onFilter
=
{
onFilter
}
/>
</>
);
const
hasGoals
=
total
>
0
;
return
(
<>
<
Ivette
.
TitleBar
>
<
Label
display
=
{
goals
<
total
}
>
{
goals
}
/
{
total
}
</
Label
>
<
Inset
/>
<
IconButton
icon
=
'CURSOR'
title
=
'Current Scope Only'
enabled
=
{
hasGoals
}
selected
=
{
scoped
}
onClick
=
{
flipScoped
}
/>
<
IconButton
icon
=
'CIRC.QUESTION'
title
=
'Unresolved Goals Only'
enabled
=
{
hasGoals
}
selected
=
{
failed
}
onClick
=
{
flipFailed
}
/>
<
IconButton
icon
=
'ITEMS.LIST'
title
=
'Goals List / Current Goal Details'
enabled
=
{
hasGoals
}
selected
=
{
list
}
onClick
=
{
flipListView
}
/>
</
Ivette
.
TitleBar
>
<
GoalTable
display
=
{
list
}
scope
=
{
scope
}
failed
=
{
failed
}
current
=
{
current
}
setCurrent
=
{
setCurrent
}
setGoals
=
{
setGoals
}
setTotal
=
{
setTotal
}
/>
</>
);
}
Ivette
.
registerComponent
({
...
...
This diff is collapsed.
Click to expand it.
ivette/src/frama-c/states.ts
+
2
−
0
View file @
99fc3dd3
...
...
@@ -409,6 +409,7 @@ export function reloadArray<K, A>(arr: Array<K, A>): void {
/** Access to Synchronized Array elements. */
export
interface
ArrayProxy
<
K
,
A
>
{
model
:
CompactModel
<
K
,
A
>
;
length
:
number
;
getData
(
elt
:
K
|
undefined
):
(
A
|
undefined
);
forEach
(
fn
:
(
row
:
A
,
elt
:
K
)
=>
void
):
void
;
...
...
@@ -429,6 +430,7 @@ function arrayProxy<K, A>(
_stamp
:
number
,
):
ArrayProxy
<
K
,
A
>
{
return
{
model
,
length
:
model
.
length
(),
getData
:
(
elt
)
=>
elt
?
model
.
getData
(
elt
)
:
undefined
,
forEach
:
(
fn
)
=>
model
.
forEach
((
r
)
=>
fn
(
r
,
model
.
getkey
(
r
))),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment