From 359ecbfb8342008bb1546854a7328615c098ddf1 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Tue, 22 Apr 2025 15:18:46 +0200
Subject: [PATCH] Added filter to flag when a condition is not extracted
 correctly

---
 src/code_.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/code_.py b/src/code_.py
index 513b791..b7d256d 100644
--- a/src/code_.py
+++ b/src/code_.py
@@ -1,4 +1,4 @@
-from .outils import remove_comments, get_parenthese_count, get_curly_count, get_code_until_parenthese_count, extract_curly
+from .outils import remove_comments, get_parenthese_count, get_curly_count, get_code_until_parenthese_count, extract_curly, get_next_element_caracter
 from .bioflowinsighterror import BioFlowInsightError
 import re
 from . import constant
@@ -100,6 +100,7 @@ class Code:
                     temp_code = code[start:]
                     for match in re.finditer(pattern, temp_code):
                         if(match.span(0)[0]==0):
+                            _, end_line = match.span(0)
                             found_if_bloc = True
                             all = match.group(0)
                             extarcted = match.group(2).strip()
@@ -113,6 +114,12 @@ class Code:
                                 if(body!="" and body[0]!="{"):
                                     new = f"if ({condition}) {{\n{body}\n}}\n"
                                     to_replace.append((all, new))
+                                elif(body==""):
+                                    char, pos = get_next_element_caracter(temp_code, end_line)
+                                    if(char!="{"):
+                                        raise BioFlowInsightError(f"The condition '({extracted_condition}' was not extracted correctly. Make sure the condition follows the correct syntaxe.", type="Unable to extract condition")
+                                    
+                                
                                     
                             
                 start+=1
-- 
GitLab