function map updates

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-05-08 03:54:24 +00:00
parent 7c70d570ac
commit 7c07ed1e3b
1 changed files with 18 additions and 5 deletions

View File

@ -712,12 +712,25 @@ class Perl(mode.Fundamental):
self.functions = None
def build_function_map(self):
b = self.window.buffer
self.functions = {}
for i in range(0, len(b.lines)):
m = regex.perl_function.match(b.lines[i])
if m:
self.functions[m.group(1)] = i
self.funclines = []
highlights = self.window.get_highlighter()
curr, stack = None, []
for group in highlights.tokens:
for t in group:
if not curr and t.name == 'sub':
curr = t.string
stack = []
self.functions[curr] = t.y
elif t.name == 'delimiter':
if t.string == '{':
stack.append(None)
elif t.string == '}':
stack.pop()
if not stack:
curr = None
self.funclines.append(curr)
def get_functions(self):
if self.functions is None:
self.build_function_map()