--- a/eric6/Utilities/ClassBrowsers/pyclbr.py Wed Sep 09 18:07:21 2020 +0200 +++ b/eric6/Utilities/ClassBrowsers/pyclbr.py Fri Sep 11 17:28:59 2020 +0200 @@ -13,11 +13,11 @@ import sys import re +from functools import reduce import Utilities import Utilities.ClassBrowsers as ClassBrowsers from . import ClbrBaseClasses -from functools import reduce TABWIDTH = 4 @@ -404,13 +404,13 @@ """ Function to calculate the end line of a class or method/function. - @param lineno line number to start at + @param lineno line number to start at (one based) @type int @param lines list of source lines @type list of str @param indent indent length the class/method/function definition @type int - @return end line of the class/method/function + @return end line of the class/method/function (one based) @rtype int """ # start with zero based line after start line @@ -440,7 +440,6 @@ deltaindentcalculated = 0 lineno, last_lineno_pos = 1, 0 - cur_obj = None i = 0 modifierType = ClbrBaseClasses.Function.General modifierIndent = -1 @@ -494,9 +493,6 @@ deltaindentcalculated = 0 # close all classes 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 a class method @@ -507,6 +503,8 @@ file, lineno, meth_sig, annotation=meth_ret, modifierType=modifier) cur_class._addmethod(meth_name, f) + else: + f = None else: # it's a function f = Function(module, meth_name, @@ -519,12 +517,10 @@ else: dict_counts[meth_name] = 0 dictionary[meth_name] = f - endlineno = calculateEndline(lineno, srcLines, thisindent) - f.setEndLine(endlineno) - if cur_obj and isinstance(cur_obj, Function): - cur_obj.setEndLine(lineno - 1) - cur_obj = f - classstack.append((f, thisindent)) # Marker for nested fns + if f: + endlineno = calculateEndline(lineno, srcLines, thisindent) + f.setEndLine(endlineno) + classstack.append((f, thisindent)) # Marker for nested fns # reset the modifier settings modifierType = ClbrBaseClasses.Function.General @@ -538,9 +534,6 @@ thisindent = _indent(m.group("ClassIndent")) # close all classes 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