From 9171adbd38c9ba26e596ec6e7d3e6359272af108 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20B=C3=BChler?= <david.buhler@cea.fr>
Date: Thu, 6 Jul 2023 15:44:18 +0200
Subject: [PATCH] [ivette] AST view: adds contextual menu entries for studia
 search mode.

---
 ivette/src/frama-c/plugins/studia/studia.ts | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/ivette/src/frama-c/plugins/studia/studia.ts b/ivette/src/frama-c/plugins/studia/studia.ts
index a45a2b06e6e..6045af5178a 100644
--- a/ivette/src/frama-c/plugins/studia/studia.ts
+++ b/ivette/src/frama-c/plugins/studia/studia.ts
@@ -68,15 +68,21 @@ interface MenuProps {
 /** Builds the Studia entries in the contextual menu about a given marker.  */
 export function buildMenu(props: MenuProps) : void {
   const { update, marker, attrs, menu } = props;
-  const enabled = attrs?.isLval;
-  function onClick(kind: access) : void {
+  function onClick(kind: access): void {
     if (marker && attrs)
       compute(marker, attrs.name, kind).then(update);
   }
-  const reads = 'Studia: select reads';
-  const writes = 'Studia: select writes';
-  menu.push({ label: reads, enabled, onClick: () => onClick('Reads') });
-  menu.push({ label: writes, enabled, onClick: () => onClick('Writes') });
+  if (attrs?.isLval) {
+    const reads = 'Studia: select reads';
+    const writes = 'Studia: select writes';
+    menu.push({ label: reads, onClick: () => onClick('Reads') });
+    menu.push({ label: writes, onClick: () => onClick('Writes') });
+  } else {
+    const reads = 'Studia: select reads…';
+    const writes = 'Studia: select writes…';
+    menu.push({ label: reads, onClick: studiaReadsEvent.emit });
+    menu.push({ label: writes, onClick: studiaWritesEvent.emit });
+  }
 }
 
 export function useStudiaMode(): void {
-- 
GitLab