mirror of
https://github.com/davidhalter/jedi.git
synced 2026-03-05 11:24:16 +08:00
Move a paragraph
This commit is contained in:
@@ -43,7 +43,6 @@ class NameFinder(object):
|
|||||||
else:
|
else:
|
||||||
self._string_name = name_or_str
|
self._string_name = name_or_str
|
||||||
self._position = position
|
self._position = position
|
||||||
self._found_predefined_types = None
|
|
||||||
self._analysis_errors = analysis_errors
|
self._analysis_errors = analysis_errors
|
||||||
|
|
||||||
def find(self, names, attribute_lookup):
|
def find(self, names, attribute_lookup):
|
||||||
@@ -51,7 +50,24 @@ class NameFinder(object):
|
|||||||
:params bool attribute_lookup: Tell to logic if we're accessing the
|
:params bool attribute_lookup: Tell to logic if we're accessing the
|
||||||
attribute or the contents of e.g. a function.
|
attribute or the contents of e.g. a function.
|
||||||
"""
|
"""
|
||||||
if self._found_predefined_types is not None and names:
|
found_predefined_types = None
|
||||||
|
# This paragraph is currently needed for proper branch type inference
|
||||||
|
# (static analysis).
|
||||||
|
if self._context.predefined_names and isinstance(self._name, tree.Name):
|
||||||
|
node = self._name
|
||||||
|
while node is not None and not is_scope(node):
|
||||||
|
node = node.parent
|
||||||
|
if node.type in ("if_stmt", "for_stmt", "comp_for", 'sync_comp_for'):
|
||||||
|
try:
|
||||||
|
name_dict = self._context.predefined_names[node]
|
||||||
|
types = name_dict[self._string_name]
|
||||||
|
except KeyError:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
found_predefined_types = types
|
||||||
|
break
|
||||||
|
|
||||||
|
if found_predefined_types is not None and names:
|
||||||
check = flow_analysis.reachability_check(
|
check = flow_analysis.reachability_check(
|
||||||
context=self._context,
|
context=self._context,
|
||||||
value_scope=self._context.tree_node,
|
value_scope=self._context.tree_node,
|
||||||
@@ -59,7 +75,7 @@ class NameFinder(object):
|
|||||||
)
|
)
|
||||||
if check is flow_analysis.UNREACHABLE:
|
if check is flow_analysis.UNREACHABLE:
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
return self._found_predefined_types
|
return found_predefined_types
|
||||||
|
|
||||||
types = self._names_to_types(names)
|
types = self._names_to_types(names)
|
||||||
self.check_issues(names, types, attribute_lookup)
|
self.check_issues(names, types, attribute_lookup)
|
||||||
@@ -84,22 +100,6 @@ class NameFinder(object):
|
|||||||
``filters``), until a name fits.
|
``filters``), until a name fits.
|
||||||
"""
|
"""
|
||||||
names = []
|
names = []
|
||||||
# This paragraph is currently needed for proper branch type inference
|
|
||||||
# (static analysis).
|
|
||||||
if self._context.predefined_names and isinstance(self._name, tree.Name):
|
|
||||||
node = self._name
|
|
||||||
while node is not None and not is_scope(node):
|
|
||||||
node = node.parent
|
|
||||||
if node.type in ("if_stmt", "for_stmt", "comp_for", 'sync_comp_for'):
|
|
||||||
try:
|
|
||||||
name_dict = self._context.predefined_names[node]
|
|
||||||
types = name_dict[self._string_name]
|
|
||||||
except KeyError:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
self._found_predefined_types = types
|
|
||||||
break
|
|
||||||
|
|
||||||
for filter in filters:
|
for filter in filters:
|
||||||
names = filter.get(self._string_name)
|
names = filter.get(self._string_name)
|
||||||
if names:
|
if names:
|
||||||
|
|||||||
Reference in New Issue
Block a user