19
19
__author__ = "Cody Precord <cprecord@editra.org>"
20
__svnid__ = "$Id: tcltags.py 56505 2008-10-25 03:04:13Z CJP $"
21
__revision__ = "$Revision: 56505 $"
20
__svnid__ = "$Id: tcltags.py 64494 2010-06-05 22:03:14Z CJP $"
21
__revision__ = "$Revision: 64494 $"
23
23
#--------------------------------------------------------------------------#
35
35
rtags = taglib.DocStruct()
36
36
rtags.SetElementDescription('procedure', "Procedure Definitions")
37
rtags.SetElementDescription('class', "SNIT")
39
# Scope tracking for SNIT blocks
38
44
for lnum, line in enumerate(buff):
39
45
line = line.strip()
42
48
if line.startswith(u"#") or not line:
51
if insnit and cursnit is not None:
52
if parselib.IsToken(line, 0, u'method') or \
53
parselib.IsToken(line, 0, u'typemethod'):
57
cursnit.AddMethod(taglib.Method(name, lnum))
58
elif parselib.IsToken(line, 0, u'typevariable') or \
59
parselib.IsToken(line, 0, u'variable'):
63
cursnit.AddVariable(taglib.Variable(name, lnum))
64
elif parselib.IsToken(u'constructor', 0, line) or \
65
parselib.IsToken(u'destructor', 0, line):
66
name = parselib.GetFirstIdentifier(line)
67
cursnit.AddMethod(taglib.Method(name, lnum))
68
elif parselib.IsToken(line, 0, u"package"):
69
pkg = GetPackage(line, lnum)
71
cursnit.AddElement('package', pkg)
74
openparens += GetParenCount(line)
45
80
# Check for Procedure defs
46
81
if parselib.IsToken(line, 0, u'proc'):
47
82
parts = line.split()
56
91
space_l.AddElement('procedure', taglib.Procedure(spaces[-1], lnum))
58
93
rtags.AddElement('procedure', taglib.Procedure(parts[1], lnum))
94
elif line.startswith(u'snit::'):
98
openparens = GetParenCount(line)
100
cursnit = taglib.Class(name, lnum)
101
rtags.AddClass(cursnit)
102
elif parselib.IsToken(line, 0, u"package"):
103
pkg = GetPackage(line, lnum)
105
rtags.AddElement('package', pkg)
112
def GetParenCount(line):
113
"""Get the delta of parens on the given line"""
114
openparens = line.count(u"{")
115
openparens -= line.count(u"}")
118
def GetPackage(line, lnum):
119
"""Get a package object from the current line
120
@precondition: line has a package def on it
125
# package require name version
127
name = u" ".join(parts[2:])
128
package = taglib.Package(name, lnum)
62
131
#-----------------------------------------------------------------------------#
64
133
if __name__ == '__main__':