271 # can't do anything with this module |
271 # can't do anything with this module |
272 _modules[module] = dict |
272 _modules[module] = dict |
273 return dict |
273 return dict |
274 |
274 |
275 lineno, last_lineno_pos = 1, 0 |
275 lineno, last_lineno_pos = 1, 0 |
|
276 lastGlobalEntry = None |
|
277 cur_obj = None |
276 i = 0 |
278 i = 0 |
277 modifierType = ClbrBaseClasses.Function.General |
279 modifierType = ClbrBaseClasses.Function.General |
278 modifierIndent = -1 |
280 modifierIndent = -1 |
279 while True: |
281 while True: |
280 m = _getnext(src, i) |
282 m = _getnext(src, i) |
320 del deltastack[-1] |
322 del deltastack[-1] |
321 deltaindentcalculated = 0 |
323 deltaindentcalculated = 0 |
322 # close all classes indented at least as much |
324 # close all classes indented at least as much |
323 while classstack and \ |
325 while classstack and \ |
324 classstack[-1][1] >= thisindent: |
326 classstack[-1][1] >= thisindent: |
|
327 if classstack[-1][0] is not None: |
|
328 # record the end line |
|
329 classstack[-1][0].setEndLine(lineno - 1) |
325 del classstack[-1] |
330 del classstack[-1] |
326 if classstack: |
331 if classstack: |
327 # it's a class method |
332 # it's a class method |
328 cur_class = classstack[-1][0] |
333 cur_class = classstack[-1][0] |
329 if cur_class: |
334 if cur_class: |
339 dict_counts[meth_name] += 1 |
344 dict_counts[meth_name] += 1 |
340 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
345 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
341 else: |
346 else: |
342 dict_counts[meth_name] = 0 |
347 dict_counts[meth_name] = 0 |
343 dict[meth_name] = f |
348 dict[meth_name] = f |
|
349 if not classstack: |
|
350 if lastGlobalEntry: |
|
351 lastGlobalEntry.setEndLine(lineno - 1) |
|
352 lastGlobalEntry = f |
|
353 if cur_obj and isinstance(cur_obj, Function): |
|
354 cur_obj.setEndLine(lineno - 1) |
|
355 cur_obj = f |
344 classstack.append((f, thisindent)) # Marker for nested fns |
356 classstack.append((f, thisindent)) # Marker for nested fns |
345 |
357 |
346 # reset the modifier settings |
358 # reset the modifier settings |
347 modifierType = ClbrBaseClasses.Function.General |
359 modifierType = ClbrBaseClasses.Function.General |
348 modifierIndent = -1 |
360 modifierIndent = -1 |
354 # we found a class definition |
366 # we found a class definition |
355 thisindent = _indent(m.group("ClassIndent")) |
367 thisindent = _indent(m.group("ClassIndent")) |
356 # close all classes indented at least as much |
368 # close all classes indented at least as much |
357 while classstack and \ |
369 while classstack and \ |
358 classstack[-1][1] >= thisindent: |
370 classstack[-1][1] >= thisindent: |
|
371 if classstack[-1][0] is not None: |
|
372 # record the end line |
|
373 classstack[-1][0].setEndLine(lineno - 1) |
359 del classstack[-1] |
374 del classstack[-1] |
360 lineno = lineno + src.count('\n', last_lineno_pos, start) |
375 lineno = lineno + src.count('\n', last_lineno_pos, start) |
361 last_lineno_pos = start |
376 last_lineno_pos = start |
362 class_name = m.group("ClassName") |
377 class_name = m.group("ClassName") |
363 inherit = m.group("ClassSupers") |
378 inherit = m.group("ClassSupers") |
397 else: |
412 else: |
398 dict_counts[class_name] = 0 |
413 dict_counts[class_name] = 0 |
399 dict[class_name] = cur_class |
414 dict[class_name] = cur_class |
400 else: |
415 else: |
401 classstack[-1][0]._addclass(class_name, cur_class) |
416 classstack[-1][0]._addclass(class_name, cur_class) |
|
417 if not classstack: |
|
418 if lastGlobalEntry: |
|
419 lastGlobalEntry.setEndLine(lineno - 1) |
|
420 lastGlobalEntry = cur_class |
402 classstack.append((cur_class, thisindent)) |
421 classstack.append((cur_class, thisindent)) |
403 |
422 |
404 elif m.start("Attribute") >= 0: |
423 elif m.start("Attribute") >= 0: |
405 lineno = lineno + src.count('\n', last_lineno_pos, start) |
424 lineno = lineno + src.count('\n', last_lineno_pos, start) |
406 last_lineno_pos = start |
425 last_lineno_pos = start |
424 if "@@Globals@@" not in dict: |
443 if "@@Globals@@" not in dict: |
425 dict["@@Globals@@"] = \ |
444 dict["@@Globals@@"] = \ |
426 ClbrBaseClasses.ClbrBase(module, "Globals", file, lineno) |
445 ClbrBaseClasses.ClbrBase(module, "Globals", file, lineno) |
427 dict["@@Globals@@"]._addglobal( |
446 dict["@@Globals@@"]._addglobal( |
428 Attribute(module, variable_name, file, lineno)) |
447 Attribute(module, variable_name, file, lineno)) |
|
448 if lastGlobalEntry: |
|
449 lastGlobalEntry.setEndLine(lineno - 1) |
|
450 lastGlobalEntry = None |
429 else: |
451 else: |
430 index = -1 |
452 index = -1 |
431 while index >= -len(classstack): |
453 while index >= -len(classstack): |
432 if classstack[index][1] >= thisindent: |
454 if classstack[index][1] >= thisindent: |
433 index -= 1 |
455 index -= 1 |