From e25684d4709a3aaf082c85d9d3756e79b69ccf00 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 3 Nov 2014 15:58:56 +0100 Subject: [PATCH] Start to check for name positions with names_dict name finder. --- jedi/evaluate/finder.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/jedi/evaluate/finder.py b/jedi/evaluate/finder.py index e033d115..542f5fa8 100644 --- a/jedi/evaluate/finder.py +++ b/jedi/evaluate/finder.py @@ -75,10 +75,23 @@ class NameFinder(object): return [] names = [name for name in names if name.is_definition()] names = pr.filter_after_position(names, position) + + # Only the names defined in the last position are valid definitions. + last_names = [] + for name in reversed(sorted(names, key=lambda name: name.start_pos)): + check = flow_analysis.break_check(self._evaluator, + scope, + er.wrap(self._evaluator, scope), + self.scope) + if check is not flow_analysis.UNREACHABLE: + last_names.append(name) + if check is flow_analysis.REACHABLE: + break + if isinstance(scope, er.FunctionExecution): # Replace params - return [get_param(n) for n in names] - return names + return [get_param(n) for n in last_names] + return last_names def filter_name(self, scope_names_generator, search_global=False): """