mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make sure goto definitions works on with, fixes #1280
This commit is contained in:
@@ -76,7 +76,7 @@ from jedi.inference.base_value import ContextualizedNode, \
|
||||
ValueSet, iterate_values
|
||||
from jedi.inference.value import ClassValue, FunctionValue
|
||||
from jedi.inference.syntax_tree import infer_expr_stmt, \
|
||||
check_tuple_assignments
|
||||
check_tuple_assignments, tree_name_to_values
|
||||
from jedi.inference.imports import follow_error_node_imports_if_possible
|
||||
from jedi.plugins import plugin_manager
|
||||
|
||||
@@ -170,6 +170,8 @@ class InferenceState(object):
|
||||
return check_tuple_assignments(n, for_types)
|
||||
if type_ in ('import_from', 'import_name'):
|
||||
return imports.infer_import(context, name)
|
||||
if type_ == 'with_stmt':
|
||||
return tree_name_to_values(self, context, name)
|
||||
else:
|
||||
result = follow_error_node_imports_if_possible(context, name)
|
||||
if result is not None:
|
||||
|
||||
@@ -341,3 +341,19 @@ with open('') as f1, open('') as f2:
|
||||
f1.closed
|
||||
#? ['closed']
|
||||
f2.closed
|
||||
|
||||
|
||||
class Foo():
|
||||
def __enter__(self):
|
||||
return ''
|
||||
|
||||
#? 14 str()
|
||||
with Foo() as f3:
|
||||
#? str()
|
||||
f3
|
||||
#! 14 ['with Foo() as f3: f3']
|
||||
with Foo() as f3:
|
||||
f3
|
||||
#? 6 Foo
|
||||
with Foo() as f3:
|
||||
f3
|
||||
|
||||
2
test/static_analysis/with_.py
Normal file
2
test/static_analysis/with_.py
Normal file
@@ -0,0 +1,2 @@
|
||||
with open() as fin:
|
||||
fin.read()
|
||||
Reference in New Issue
Block a user