From 3cea788b597cf9f5de5322182dd923593b6cd869 Mon Sep 17 00:00:00 2001
From: Daniel Campora <dcampora@cern.ch>
Date: Thu, 24 Aug 2023 21:04:08 +0200
Subject: [PATCH] Parse all properties.

---
 configuration/parser/AlgorithmTraversalLibClang.py | 13 +++++++------
 configuration/parser/ParseAlgorithms.py            |  3 ---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/configuration/parser/AlgorithmTraversalLibClang.py b/configuration/parser/AlgorithmTraversalLibClang.py
index c8bc2a5ac6d..e2abd61705e 100644
--- a/configuration/parser/AlgorithmTraversalLibClang.py
+++ b/configuration/parser/AlgorithmTraversalLibClang.py
@@ -44,14 +44,14 @@ class Property():
                  description,
                  default_value,
                  scope="algorithm"):
-        self.typename = name[1:-1]
+        self.typename = name.strip('"')
         self.typedef = typedef
         self.name = name
         self.description = description
         self.default_value = default_value
         self.scope = scope
 
-        # print(name, typedef, description, default_value)
+        print(name, typedef, description, default_value)
 
 
 class Parameter():
@@ -237,10 +237,6 @@ class AlgorithmTraversal():
             elif "Parameters" in c.type.spelling:
                 return AlgorithmTraversal.traverse_children(
                     c.get_definition(), AlgorithmTraversal.parameters)
-        elif c.kind == cindex.CursorKind.FIELD_DECL:
-            if c.spelling in AlgorithmTraversal.__properties:
-                prop = AlgorithmTraversal.__properties[c.spelling]
-                return ("Property", prop["name"], c.type.get_template_argument_type(0).spelling, prop["description"], prop["default_value"])
         else:
             return None
 
@@ -258,6 +254,9 @@ class AlgorithmTraversal():
             algorithm_parameters = []
             algorithm_class_parameters = AlgorithmTraversal.traverse_children(
                 c, AlgorithmTraversal.algorithm_definition)
+            # Add properties
+            for _, prop in AlgorithmTraversal.__properties.items():
+                algorithm_class_parameters.append(("Property", prop["name"], prop["variable_type"], prop["description"], prop["default_value"]))
             algorithm_properties = []
             for d in algorithm_class_parameters:
                 if d[0] == "AlgorithmClass":
@@ -301,6 +300,7 @@ class AlgorithmTraversal():
                     pass
                     this_position = ts.index("this", last_found)
                     semicolon_position = ts.index(";", last_found)
+                    variable_type = "".join(ts[last_found + 2:this_position - 4])
                     variable_name = ts[this_position - 2]
                     name = ts[this_position + 2]
                     description = ts[semicolon_position - 2]
@@ -308,6 +308,7 @@ class AlgorithmTraversal():
                     properties[variable_name] = {
                         "name": name,
                         "description": description,
+                        "variable_type": variable_type,
                         "default_value": default_value
                     }
 
diff --git a/configuration/parser/ParseAlgorithms.py b/configuration/parser/ParseAlgorithms.py
index cdd5c0ede60..5aaf2fb0fd7 100755
--- a/configuration/parser/ParseAlgorithms.py
+++ b/configuration/parser/ParseAlgorithms.py
@@ -605,9 +605,6 @@ class AllenCore():
     def write_algorithms_view(algorithms, filename, default_properties):
         from subprocess import (PIPE, run)
 
-        a = ';'.join(["{}::{}".format(a.namespace, a.name) for a in parsed_algorithms])
-        print(a)
-
         # Run the default_properties executable to get a JSON
         # representation of the default values of all properties of
         # all algorithms
-- 
GitLab