Utilities/ClassBrowsers/idlclbr.py

changeset 2769
8cbebde7a984
parent 2302
f29e9405c851
child 2791
a9577f248f04
child 2965
d133c7edd88a
--- a/Utilities/ClassBrowsers/idlclbr.py	Wed Jul 03 19:34:42 2013 +0200
+++ b/Utilities/ClassBrowsers/idlclbr.py	Fri Jul 05 19:17:29 2013 +0200
@@ -212,6 +212,8 @@
         return dict
 
     lineno, last_lineno_pos = 1, 0
+    lastGlobalEntry = None
+    cur_obj = None
     i = 0
     while True:
         m = _getnext(src, i)
@@ -232,6 +234,9 @@
             # close all interfaces/modules indented at least as much
             while classstack and \
                   classstack[-1][1] >= thisindent:
+                if classstack[-1][0] is not None:
+                    # record the end line
+                    classstack[-1][0].setEndLine(lineno - 1)
                 del classstack[-1]
             if classstack:
                 # it's an interface/module method
@@ -242,6 +247,8 @@
                                  file, lineno, meth_sig)
                     cur_class._addmethod(meth_name, f)
                 # else it's a nested def
+                else:
+                    f = None
             else:
                 # it's a function
                 f = Function(module, meth_name,
@@ -252,6 +259,13 @@
                 else:
                     dict_counts[meth_name] = 0
                 dict[meth_name] = f
+            if not classstack:
+                if lastGlobalEntry:
+                    lastGlobalEntry.setEndLine(lineno - 1)
+                lastGlobalEntry = f
+            if cur_obj and isinstance(cur_obj, Function):
+                cur_obj.setEndLine(lineno - 1)
+            cur_obj = f
             classstack.append((f, thisindent))  # Marker for nested fns
 
         elif m.start("String") >= 0:
@@ -267,6 +281,9 @@
             # close all interfaces/modules indented at least as much
             while classstack and \
                   classstack[-1][1] >= thisindent:
+                if classstack[-1][0] is not None:
+                    # record the end line
+                    classstack[-1][0].setEndLine(lineno - 1)
                 del classstack[-1]
             lineno = lineno + src.count('\n', last_lineno_pos, start)
             last_lineno_pos = start
@@ -284,6 +301,13 @@
             else:
                 cls = classstack[-1][0]
                 cls._addclass(class_name, cur_class)
+            if not classstack:
+                if lastGlobalEntry:
+                    lastGlobalEntry.setEndLine(lineno - 1)
+                lastGlobalEntry = cur_class
+            if cur_obj and isinstance(cur_obj, Function):
+                cur_obj.setEndLine(lineno - 1)
+            cur_obj = cur_class
             classstack.append((cur_class, thisindent))
 
         elif m.start("Module") >= 0:
@@ -293,6 +317,9 @@
             # close all interfaces/modules indented at least as much
             while classstack and \
                   classstack[-1][1] >= thisindent:
+                if classstack[-1][0] is not None:
+                    # record the end line
+                    classstack[-1][0].setEndLine(lineno - 1)
                 del classstack[-1]
             lineno = lineno + src.count('\n', last_lineno_pos, start)
             last_lineno_pos = start
@@ -301,6 +328,12 @@
             cur_class = Module(module, module_name, file, lineno)
             if not classstack:
                 dict[module_name] = cur_class
+                if lastGlobalEntry:
+                    lastGlobalEntry.setEndLine(lineno - 1)
+                lastGlobalEntry = cur_class
+            if cur_obj and isinstance(cur_obj, Function):
+                cur_obj.setEndLine(lineno - 1)
+            cur_obj = cur_class
             classstack.append((cur_class, thisindent))
 
         elif m.start("Attribute") >= 0:
@@ -321,6 +354,9 @@
                     break
                 else:
                     index -= 1
+                    if lastGlobalEntry:
+                        lastGlobalEntry.setEndLine(lineno - 1)
+                    lastGlobalEntry = None
 
         elif m.start("Begin") >= 0:
             # a begin of a block we are not interested in

eric ide

mercurial