improve python's goto-name support
--HG-- branch : pmacs2
This commit is contained in:
parent
33c5cc3cf5
commit
4ea1f53a46
|
@ -486,6 +486,7 @@ class PythonContext(context.Context):
|
||||||
blen = len(self.mode.window.buffer.lines)
|
blen = len(self.mode.window.buffer.lines)
|
||||||
highlights = self.mode.window.get_highlighter()
|
highlights = self.mode.window.get_highlighter()
|
||||||
i = y1
|
i = y1
|
||||||
|
abbrev = {}
|
||||||
while i < y2:
|
while i < y2:
|
||||||
tokens = highlights.tokens[i]
|
tokens = highlights.tokens[i]
|
||||||
g = highlights.tokens[i]
|
g = highlights.tokens[i]
|
||||||
|
@ -511,16 +512,22 @@ class PythonContext(context.Context):
|
||||||
last = None
|
last = None
|
||||||
|
|
||||||
if len(g[j:]) > 3:
|
if len(g[j:]) > 3:
|
||||||
d, found = None, False
|
found = False
|
||||||
if g[j].name == 'python.keyword' and g[j].string == 'class':
|
if g[j].name == 'python.keyword' and g[j].string == 'class':
|
||||||
d, found = self.classes, True
|
found = True
|
||||||
elif g[j].name == 'python.keyword' and g[j].string == 'def':
|
elif g[j].name == 'python.keyword' and g[j].string == 'def':
|
||||||
d, found = self.functions, True
|
found = True
|
||||||
if found:
|
if found:
|
||||||
stack.append([lvl, g[j+2].string])
|
stack.append([lvl, g[j+2].string])
|
||||||
curr = '.'.join([x[1] for x in stack])
|
curr = '.'.join([x[1] for x in stack])
|
||||||
d[curr] = i
|
|
||||||
self.names[curr] = i
|
self.names[curr] = i
|
||||||
|
|
||||||
|
for k in range(1, len(stack)):
|
||||||
|
curr = '.'.join(x[1] for x in stack[k:])
|
||||||
|
if curr not in abbrev:
|
||||||
|
abbrev[curr] = i
|
||||||
|
else:
|
||||||
|
abbrev[curr] = None
|
||||||
else:
|
else:
|
||||||
curr = '.'.join([x[1] for x in stack])
|
curr = '.'.join([x[1] for x in stack])
|
||||||
|
|
||||||
|
@ -530,6 +537,10 @@ class PythonContext(context.Context):
|
||||||
self.namelines[i] = (curr, None)
|
self.namelines[i] = (curr, None)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
for name in abbrev:
|
||||||
|
if abbrev[name] is not None:
|
||||||
|
self.names[name] = abbrev[name]
|
||||||
|
|
||||||
if last is not None and y2 < len(self.namelines):
|
if last is not None and y2 < len(self.namelines):
|
||||||
if self.namelines[y2] and self.namelines[y2][0]:
|
if self.namelines[y2] and self.namelines[y2][0]:
|
||||||
n = len(self.namelines[y2][0].split('.'))
|
n = len(self.namelines[y2][0].split('.'))
|
||||||
|
|
Loading…
Reference in New Issue