From 96db03678a6f6aca33e4f3ab208c88f05535aa1a Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Tue, 18 Mar 2025 12:32:17 +0100
Subject: [PATCH] updated condition extraction

---
 src/call.py   | 1 -
 src/code_.py  | 5 +++--
 src/outils.py | 2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/call.py b/src/call.py
index 41bba12..6361913 100644
--- a/src/call.py
+++ b/src/call.py
@@ -164,7 +164,6 @@ class Call(Executor):
         #Step 2 -> analyse paramters
         for param in tab_params:
             analysed_param = False
-    
             if param!='':
                 #Case it's a channel
                 if(re.fullmatch(constant.WORD, param) and not analysed_param):
diff --git a/src/code_.py b/src/code_.py
index cb7b985..d4d4b4b 100644
--- a/src/code_.py
+++ b/src/code_.py
@@ -46,8 +46,9 @@ class Code:
                 extracted_condition = get_code_until_parenthese_count(code=code[end:], val=-1)
                 condition = extracted_condition[:-1]
                 body = extarcted.replace(extracted_condition.strip(), "")
-                new = f"if ({condition}) {{\n{body}\n}}\n"
-                to_replace.append((all, new))
+                if(body!="" and body[0]!="{"):
+                    new = f"if ({condition}) {{\n{body}\n}}\n"
+                    to_replace.append((all, new))
         for r in to_replace:
             old, new = r
             code = code.replace(old, new)
diff --git a/src/outils.py b/src/outils.py
index 9491059..bcaa57e 100644
--- a/src/outils.py
+++ b/src/outils.py
@@ -1057,6 +1057,8 @@ def extract_conditions(code, only_get_inside = True):
                     start = end-1
     
             start+=1
+    for c in conditions_dico:
+        start, end = conditions_dico[c]
     return conditions_dico
     
 def process_2_DSL2(code):
-- 
GitLab