mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
weakref problem, references were killed to early
This commit is contained in:
14
functions.py
14
functions.py
@@ -66,13 +66,7 @@ class Definition(object):
|
|||||||
self.definition = definition
|
self.definition = definition
|
||||||
self._def_parent = self.definition.parent() # just here to limit gc
|
self._def_parent = self.definition.parent() # just here to limit gc
|
||||||
|
|
||||||
par = self.definition
|
self.module_path = str(self.definition.get_parent_until().path)
|
||||||
while True:
|
|
||||||
if par.parent() is not None:
|
|
||||||
par = par.parent()
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
self.module_path = str(par.path)
|
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
try:
|
try:
|
||||||
@@ -251,8 +245,9 @@ def get_definitions(source, line, column, source_path):
|
|||||||
goto_path = f.get_path_under_cursor()
|
goto_path = f.get_path_under_cursor()
|
||||||
|
|
||||||
scopes = _prepare_goto(source, pos, source_path, f, goto_path)
|
scopes = _prepare_goto(source, pos, source_path, f, goto_path)
|
||||||
|
d = [Definition(s) for s in set(scopes)]
|
||||||
_clear_caches()
|
_clear_caches()
|
||||||
return [Definition(s) for s in set(scopes)]
|
return d
|
||||||
|
|
||||||
|
|
||||||
def goto(source, line, column, source_path):
|
def goto(source, line, column, source_path):
|
||||||
@@ -311,8 +306,9 @@ def goto(source, line, column, source_path):
|
|||||||
names += s.get_defined_names()
|
names += s.get_defined_names()
|
||||||
names = remove_unreal_imports(names)
|
names = remove_unreal_imports(names)
|
||||||
definitions = [n for n in names if n.names[-1] == search_name]
|
definitions = [n for n in names if n.names[-1] == search_name]
|
||||||
|
d = [Definition(d) for d in set(definitions)]
|
||||||
_clear_caches()
|
_clear_caches()
|
||||||
return [Definition(d) for d in set(definitions)]
|
return d
|
||||||
|
|
||||||
|
|
||||||
def set_debug_function(func_cb):
|
def set_debug_function(func_cb):
|
||||||
|
|||||||
@@ -108,3 +108,15 @@ mod1.a
|
|||||||
|
|
||||||
#! ['a=1.0']
|
#! ['a=1.0']
|
||||||
from import_tree.pkg.mod1 import a
|
from import_tree.pkg.mod1 import a
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# anonymous classes
|
||||||
|
# -----------------
|
||||||
|
def func():
|
||||||
|
class A():
|
||||||
|
def b(self):
|
||||||
|
return 1
|
||||||
|
return A()
|
||||||
|
|
||||||
|
#! 8 ['def b']
|
||||||
|
func().b()
|
||||||
|
|||||||
Reference in New Issue
Block a user