eric6/Utilities/ClassBrowsers/pyclbr.py

changeset 8087
db518728761c
parent 7973
e836d196e888
child 8131
f2129bb79269
diff -r eff504bb6dec -r db518728761c eric6/Utilities/ClassBrowsers/pyclbr.py
--- a/eric6/Utilities/ClassBrowsers/pyclbr.py	Mon Feb 08 19:31:39 2021 +0100
+++ b/eric6/Utilities/ClassBrowsers/pyclbr.py	Tue Feb 09 08:33:41 2021 +0100
@@ -436,7 +436,7 @@
     conditionalsstack = []  # stack of indents of conditional defines
     deltastack = []
     deltaindent = 0
-    deltaindentcalculated = 0
+    deltaindentcalculated = False
     
     lineno, last_lineno_pos = 1, 0
     i = 0
@@ -479,7 +479,7 @@
                     if not deltaindentcalculated:
                         deltastack.append(thisindent - conditionalsstack[-1])
                         deltaindent = reduce(lambda x, y: x + y, deltastack)
-                        deltaindentcalculated = 1
+                        deltaindentcalculated = True
                     thisindent -= deltaindent
                 else:
                     while (
@@ -489,7 +489,7 @@
                         del conditionalsstack[-1]
                         if deltastack:
                             del deltastack[-1]
-                    deltaindentcalculated = 0
+                    deltaindentcalculated = False
             # close all classes indented at least as much
             while classstack and classstack[-1][1] >= thisindent:
                 del classstack[-1]
@@ -564,6 +564,23 @@
                                     n = d[c]
                     names.append(n)
                 inherit = names
+            # modify indentation level for conditional defines
+            if conditionalsstack:
+                if thisindent > conditionalsstack[-1]:
+                    if not deltaindentcalculated:
+                        deltastack.append(thisindent - conditionalsstack[-1])
+                        deltaindent = reduce(lambda x, y: x + y, deltastack)
+                        deltaindentcalculated = True
+                    thisindent -= deltaindent
+                else:
+                    while (
+                        conditionalsstack and
+                        conditionalsstack[-1] >= thisindent
+                    ):
+                        del conditionalsstack[-1]
+                        if deltastack:
+                            del deltastack[-1]
+                    deltaindentcalculated = False
             # remember this class
             cur_class = Class(module, class_name, inherit,
                               file, lineno)
@@ -673,7 +690,7 @@
                 if deltastack:
                     del deltastack[-1]
             conditionalsstack.append(thisindent)
-            deltaindentcalculated = 0
+            deltaindentcalculated = False
         
         elif m.start("CodingLine") >= 0:
             # a coding statement

eric ide

mercurial