300 if m.start("Method") >= 0: |
300 if m.start("Method") >= 0: |
301 # found a method definition or function |
301 # found a method definition or function |
302 thisindent = indent |
302 thisindent = indent |
303 indent += 1 |
303 indent += 1 |
304 meth_name = m.group("MethodName") or \ |
304 meth_name = m.group("MethodName") or \ |
305 m.group("MethodName2") or \ |
305 m.group("MethodName2") or \ |
306 m.group("MethodName3") |
306 m.group("MethodName3") |
307 meth_sig = m.group("MethodSignature") |
307 meth_sig = m.group("MethodSignature") |
308 meth_sig = meth_sig and meth_sig.replace('\\\n', '') or '' |
308 meth_sig = meth_sig and meth_sig.replace('\\\n', '') or '' |
309 meth_sig = _commentsub('', meth_sig) |
309 meth_sig = _commentsub('', meth_sig) |
310 lineno = lineno + src.count('\n', last_lineno_pos, start) |
310 lineno = lineno + src.count('\n', last_lineno_pos, start) |
311 last_lineno_pos = start |
311 last_lineno_pos = start |
313 meth_name = meth_name[5:] |
313 meth_name = meth_name[5:] |
314 elif meth_name.startswith('self::'): |
314 elif meth_name.startswith('self::'): |
315 meth_name = meth_name[6:] |
315 meth_name = meth_name[6:] |
316 # close all classes/modules indented at least as much |
316 # close all classes/modules indented at least as much |
317 while classstack and \ |
317 while classstack and \ |
318 classstack[-1][1] >= thisindent: |
318 classstack[-1][1] >= thisindent: |
319 if classstack[-1][0] is not None: |
319 if classstack[-1][0] is not None: |
320 # record the end line |
320 # record the end line |
321 classstack[-1][0].setEndLine(lineno - 1) |
321 classstack[-1][0].setEndLine(lineno - 1) |
322 del classstack[-1] |
322 del classstack[-1] |
323 while acstack and \ |
323 while acstack and \ |
324 acstack[-1][1] >= thisindent: |
324 acstack[-1][1] >= thisindent: |
325 del acstack[-1] |
325 del acstack[-1] |
326 if classstack: |
326 if classstack: |
327 # it's a class/module method |
327 # it's a class/module method |
328 cur_class = classstack[-1][0] |
328 cur_class = classstack[-1][0] |
329 if isinstance(cur_class, Class) or \ |
329 if isinstance(cur_class, Class) or \ |
379 indent += 1 |
379 indent += 1 |
380 lineno = lineno + src.count('\n', last_lineno_pos, start) |
380 lineno = lineno + src.count('\n', last_lineno_pos, start) |
381 last_lineno_pos = start |
381 last_lineno_pos = start |
382 # close all classes/modules indented at least as much |
382 # close all classes/modules indented at least as much |
383 while classstack and \ |
383 while classstack and \ |
384 classstack[-1][1] >= thisindent: |
384 classstack[-1][1] >= thisindent: |
385 if classstack[-1][0] is not None: |
385 if classstack[-1][0] is not None: |
386 # record the end line |
386 # record the end line |
387 classstack[-1][0].setEndLine(lineno - 1) |
387 classstack[-1][0].setEndLine(lineno - 1) |
388 del classstack[-1] |
388 del classstack[-1] |
389 class_name = m.group("ClassName") or m.group("ClassName2") |
389 class_name = m.group("ClassName") or m.group("ClassName2") |
413 lastGlobalEntry.setEndLine(lineno - 1) |
413 lastGlobalEntry.setEndLine(lineno - 1) |
414 lastGlobalEntry = cur_class |
414 lastGlobalEntry = cur_class |
415 cur_obj = cur_class |
415 cur_obj = cur_class |
416 classstack.append((cur_class, thisindent)) |
416 classstack.append((cur_class, thisindent)) |
417 while acstack and \ |
417 while acstack and \ |
418 acstack[-1][1] >= thisindent: |
418 acstack[-1][1] >= thisindent: |
419 del acstack[-1] |
419 del acstack[-1] |
420 acstack.append(["public", thisindent]) # default access control |
420 acstack.append(["public", thisindent]) # default access control |
421 # is 'public' |
421 # is 'public' |
422 |
422 |
423 elif m.start("Module") >= 0: |
423 elif m.start("Module") >= 0: |
426 indent += 1 |
426 indent += 1 |
427 lineno = lineno + src.count('\n', last_lineno_pos, start) |
427 lineno = lineno + src.count('\n', last_lineno_pos, start) |
428 last_lineno_pos = start |
428 last_lineno_pos = start |
429 # close all classes/modules indented at least as much |
429 # close all classes/modules indented at least as much |
430 while classstack and \ |
430 while classstack and \ |
431 classstack[-1][1] >= thisindent: |
431 classstack[-1][1] >= thisindent: |
432 if classstack[-1][0] is not None: |
432 if classstack[-1][0] is not None: |
433 # record the end line |
433 # record the end line |
434 classstack[-1][0].setEndLine(lineno - 1) |
434 classstack[-1][0].setEndLine(lineno - 1) |
435 del classstack[-1] |
435 del classstack[-1] |
436 module_name = m.group("ModuleName") |
436 module_name = m.group("ModuleName") |
454 lastGlobalEntry.setEndLine(lineno - 1) |
454 lastGlobalEntry.setEndLine(lineno - 1) |
455 lastGlobalEntry = cur_class |
455 lastGlobalEntry = cur_class |
456 cur_obj = cur_class |
456 cur_obj = cur_class |
457 classstack.append((cur_class, thisindent)) |
457 classstack.append((cur_class, thisindent)) |
458 while acstack and \ |
458 while acstack and \ |
459 acstack[-1][1] >= thisindent: |
459 acstack[-1][1] >= thisindent: |
460 del acstack[-1] |
460 del acstack[-1] |
461 acstack.append(["public", thisindent]) # default access control |
461 acstack.append(["public", thisindent]) # default access control |
462 # is 'public' |
462 # is 'public' |
463 |
463 |
464 elif m.start("AccessControl") >= 0: |
464 elif m.start("AccessControl") >= 0: |
466 if aclist is None: |
466 if aclist is None: |
467 index = -1 |
467 index = -1 |
468 while index >= -len(acstack): |
468 while index >= -len(acstack): |
469 if acstack[index][1] < indent: |
469 if acstack[index][1] < indent: |
470 actype = m.group("AccessControlType") or \ |
470 actype = m.group("AccessControlType") or \ |
471 m.group("AccessControlType2").split('_')[0] |
471 m.group("AccessControlType2").split('_')[0] |
472 acstack[index][0] = actype.lower() |
472 acstack[index][0] = actype.lower() |
473 break |
473 break |
474 else: |
474 else: |
475 index -= 1 |
475 index -= 1 |
476 else: |
476 else: |
479 if classstack[index][0] is not None and \ |
479 if classstack[index][0] is not None and \ |
480 not isinstance(classstack[index][0], Function) and \ |
480 not isinstance(classstack[index][0], Function) and \ |
481 not classstack[index][1] >= indent: |
481 not classstack[index][1] >= indent: |
482 parent = classstack[index][0] |
482 parent = classstack[index][0] |
483 actype = m.group("AccessControlType") or \ |
483 actype = m.group("AccessControlType") or \ |
484 m.group("AccessControlType2").split('_')[0] |
484 m.group("AccessControlType2").split('_')[0] |
485 actype = actype.lower() |
485 actype = actype.lower() |
486 for name in aclist.split(","): |
486 for name in aclist.split(","): |
487 name = name.strip()[1:] # get rid of leading ':' |
487 name = name.strip()[1:] # get rid of leading ':' |
488 acmeth = parent._getmethod(name) |
488 acmeth = parent._getmethod(name) |
489 if acmeth is None: |
489 if acmeth is None: |
529 nv = m.group("AttrList").split(",") |
529 nv = m.group("AttrList").split(",") |
530 if not nv: |
530 if not nv: |
531 break |
531 break |
532 name = nv[0].strip()[1:] # get rid of leading ':' |
532 name = nv[0].strip()[1:] # get rid of leading ':' |
533 attr = parent._getattribute("@" + name) or \ |
533 attr = parent._getattribute("@" + name) or \ |
534 parent._getattribute("@@" + name) or \ |
534 parent._getattribute("@@" + name) or \ |
535 Attribute(module, "@" + name, file, lineno) |
535 Attribute(module, "@" + name, file, lineno) |
536 if len(nv) == 1 or nv[1].strip() == "false": |
536 if len(nv) == 1 or nv[1].strip() == "false": |
537 attr.setProtected() |
537 attr.setProtected() |
538 elif nv[1].strip() == "true": |
538 elif nv[1].strip() == "true": |
539 attr.setPublic() |
539 attr.setPublic() |
540 parent._addattribute(attr) |
540 parent._addattribute(attr) |
541 else: |
541 else: |
542 access = m.group("AttrType") |
542 access = m.group("AttrType") |
543 for name in m.group("AttrList").split(","): |
543 for name in m.group("AttrList").split(","): |
544 name = name.strip()[1:] # get rid of leading ':' |
544 name = name.strip()[1:] # get rid of leading ':' |
545 attr = parent._getattribute("@" + name) or \ |
545 attr = parent._getattribute("@" + name) or \ |
546 parent._getattribute("@@" + name) or \ |
546 parent._getattribute("@@" + name) or \ |
547 Attribute(module, "@" + name, file, lineno) |
547 Attribute(module, "@" + name, file, lineno) |
548 if access == "_accessor": |
548 if access == "_accessor": |
549 attr.setPublic() |
549 attr.setPublic() |
550 elif access == "_reader" or access == "_writer": |
550 elif access == "_reader" or access == "_writer": |
551 if attr.isPrivate(): |
551 if attr.isPrivate(): |
552 attr.setProtected() |
552 attr.setProtected() |