mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-09 21:42:20 +08:00
Goto definitions goto stubs now have a proper implementation
This commit is contained in:
@@ -20,7 +20,7 @@ def test_preload_modules():
|
||||
# Filter the typeshed parser cache.
|
||||
typeshed_cache_count = sum(
|
||||
1 for path in grammar_cache
|
||||
if path is not None and path.startswith(typeshed._TYPESHED_PATH)
|
||||
if path is not None and path.startswith(typeshed.TYPESHED_PATH)
|
||||
)
|
||||
# +1 for None module (currently used)
|
||||
assert len(grammar_cache) - typeshed_cache_count == len(modules) + 1
|
||||
|
||||
@@ -7,13 +7,13 @@ from jedi.evaluate.gradual import typeshed, stub_context
|
||||
from jedi.evaluate.context import TreeInstance, BoundMethod, FunctionContext
|
||||
from jedi.evaluate.filters import TreeNameDefinition
|
||||
|
||||
TYPESHED_PYTHON3 = os.path.join(typeshed._TYPESHED_PATH, 'stdlib', '3')
|
||||
TYPESHED_PYTHON3 = os.path.join(typeshed.TYPESHED_PATH, 'stdlib', '3')
|
||||
|
||||
|
||||
def test_get_typeshed_directories():
|
||||
def get_dirs(version_info):
|
||||
return {
|
||||
d.replace(typeshed._TYPESHED_PATH, '').lstrip(os.path.sep)
|
||||
d.replace(typeshed.TYPESHED_PATH, '').lstrip(os.path.sep)
|
||||
for d in typeshed._get_typeshed_directories(version_info)
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ def test_keywords_variable(Script):
|
||||
def_, = Script(code).goto_definitions()
|
||||
assert def_.name == 'Sequence'
|
||||
# This points towards the typeshed implementation
|
||||
assert typeshed._TYPESHED_PATH in def_.module_path
|
||||
assert typeshed.TYPESHED_PATH in def_.module_path
|
||||
|
||||
|
||||
def test_class(Script):
|
||||
@@ -134,7 +134,7 @@ def test_sys_hexversion(Script):
|
||||
def_, = script.completions()
|
||||
assert isinstance(def_._name, stub_context.CompiledStubName), def_._name
|
||||
assert isinstance(def_._name._wrapped_name, TreeNameDefinition)
|
||||
assert typeshed._TYPESHED_PATH in def_.module_path
|
||||
assert typeshed.TYPESHED_PATH in def_.module_path
|
||||
def_, = script.goto_definitions()
|
||||
assert def_.name == 'int'
|
||||
|
||||
@@ -204,30 +204,27 @@ def test_goto_stubs_on_itself(Script, code):
|
||||
"""
|
||||
s = Script(code)
|
||||
def_, = s.goto_definitions()
|
||||
#stub, = def_.goto_stubs()
|
||||
stub, = def_.goto_stubs()
|
||||
|
||||
script_on_source = Script(
|
||||
path=def_.module_path,
|
||||
line=def_.line,
|
||||
column=def_.column
|
||||
)
|
||||
print('GO')
|
||||
definition, = script_on_source.goto_definitions()
|
||||
print('\ta', definition._name._context, definition._name._context.parent_context)
|
||||
return
|
||||
same_stub, = definition.goto_stubs()
|
||||
_assert_is_same(same_stub, stub)
|
||||
_assert_is_same(definition, def_)
|
||||
assert same_stub.module_path != def_.module_path
|
||||
|
||||
# And the reverse.
|
||||
script_on_source = Script(
|
||||
script_on_stub = Script(
|
||||
path=same_stub.module_path,
|
||||
line=same_stub.line,
|
||||
column=same_stub.column
|
||||
)
|
||||
|
||||
same_definition, = script_on_source.goto_definitions()
|
||||
same_definition, = script_on_stub.goto_definitions()
|
||||
same_definition2, = same_stub.infer()
|
||||
_assert_is_same(same_definition, definition)
|
||||
_assert_is_same(same_definition, same_definition2)
|
||||
|
||||
Reference in New Issue
Block a user