diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index a9ae4dae..6c9518c6 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -574,7 +574,7 @@ class Script(object): :rtype: list of :class:`classes.CallSignature` """ user_stmt = self._parser.user_stmt_with_whitespace() - call, execution_arr, index = search_call_signatures(user_stmt, self._pos) + call, trailer, index = search_call_signatures(user_stmt, self._pos) if call is None: return [] @@ -585,14 +585,13 @@ class Script(object): key_name = None try: - detail = execution_arr[index].assignment_details[0] - except IndexError: + # Access the trailers arglist node. + argument = trailer.children[0].children[index] + except (IndexError, AttributeError): pass else: - try: - key_name = unicode(detail[0][0].name) - except (IndexError, AttributeError): - pass + if argument.children[1] == '=': + key_name = argument.children[0] return [classes.CallSignature(self._evaluator, o.name, call, index, key_name) for o in origins if hasattr(o, 'py__call__')] diff --git a/jedi/api/classes.py b/jedi/api/classes.py index f7d24fee..03fe0e44 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -675,7 +675,7 @@ class CallSignature(Definition): def index(self): """ The Param index of the current call. - Returns None if the index doesn't is not defined. + Returns None if the index cannot be found in the curent call. """ if self._key_name is not None: for i, param in enumerate(self.params): diff --git a/jedi/cache.py b/jedi/cache.py index 4c1c1797..94d1aac1 100644 --- a/jedi/cache.py +++ b/jedi/cache.py @@ -112,7 +112,7 @@ def cache_call_signatures(evaluator, call, source, user_pos, stmt): module_path = stmt.get_parent_until().path yield None if module_path is None else (module_path, before_bracket, stmt.start_pos) - yield evaluator.eval_call(call) + yield evaluator.eval_element(call) def underscore_memoization(func): diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index 6a381f74..09736cbc 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -86,16 +86,18 @@ class CompiledObject(Base): params_str, ret = self._parse_function_doc() tokens = params_str.split(',') params = [] - module = SubModule(self.get_parent_until().name) + module = self.get_parent_until() # it seems like start_pos/end_pos is always (0, 0) for a compiled # object start_pos, end_pos = (0, 0), (0, 0) for p in tokens: parts = [FakeName(part) for part in p.strip().split('=')] - if len(parts) >= 2: - parts.insert(1, Operator(module, '=', module, (0, 0))) - params.append(Param(module, parts, start_pos, - end_pos, builtin)) + name = parts[0] + if len(parts) > 2: + default = parts[2] + else: + default = None + params.append(Param(name, module, default)) return params def __repr__(self): diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index 087a8a2a..1832e039 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -203,10 +203,12 @@ def _call_signature_array_for_pos(stmt, pos): def scan_node_for_call_signature(node, pos): """to something with call_signatures""" if node.type == 'power' and node.start_pos < pos < node.end_pos: - for trailer in node.children[1:]: + for i, trailer in enumerate(node.children[1:], 1): if trailer.type == 'trailer' and trailer.children[0] == '(' \ and trailer.children[0].start_pos < pos \ and pos <= trailer.children[-1].start_pos: + # Delete all the nodes including the current one + node.children[i:] = [] return node, trailer for child in node.children: node, trailer = scan_node_for_call_signature(child, pos) @@ -226,7 +228,8 @@ def search_call_signatures(user_stmt, position): # some parts will of the statement will be removed user_stmt = deep_ast_copy(user_stmt) - print(scan_node_for_call_signature(user_stmt, position)) + return scan_node_for_call_signature(user_stmt, position) + (0,) + print() #arr, index, call = _call_signature_array_for_pos(user_stmt, position) # Now remove the part after the call. Including the array from the diff --git a/jedi/evaluate/param.py b/jedi/evaluate/param.py index 0c88ecf6..280657e1 100644 --- a/jedi/evaluate/param.py +++ b/jedi/evaluate/param.py @@ -18,6 +18,8 @@ class Arguments(pr.Base): The argument_node is either a parser node or a list of evaluated objects. Those evaluated objects may be lists of evaluated objects themselves (one list for the first argument, one for the second, etc). + + :param argument_node: May be an argument_node or a list of nodes. """ self.argument_node = argument_node self._evaluator = evaluator