From d9b3bb40162b4cb1b283942cf08872ca2751b14a Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 10 Mar 2013 01:24:56 +0100 Subject: [PATCH] Refactor _get_function_call_and_param_index_at_point --- jedi/api.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/jedi/api.py b/jedi/api.py index 4bcce36f..2be8cb83 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -243,10 +243,7 @@ class Script(object): # Fetch definition of callee if not goto_path: - try: - (call, _) = self._get_function_call_and_param_index_at_point() - except NotFoundError: - call = None + (call, _) = self._get_function_call_and_param_index_at_point() if call is not None: while call.next is not None: call = call.next @@ -398,9 +395,8 @@ class Script(object): :rtype: :class:`api_classes.CallDef` """ - try: - (call, index) = self._get_function_call_and_param_index_at_point() - except NotFoundError: + (call, index) = self._get_function_call_and_param_index_at_point() + if call is None: return None user_stmt = self._parser.user_stmt @@ -456,12 +452,18 @@ class Script(object): raise NotFoundError() debug.speed('func_call start') + call = None + index = 0 if settings.use_function_definition_cache: - call, index = check_cache() + try: + call, index = check_cache() + except NotFoundError: + pass if call is None: - call, index = check_user_stmt(self._parser.user_stmt) - if call is None: - raise NotFoundError() + try: + call, index = check_user_stmt(self._parser.user_stmt) + except NotFoundError: + pass debug.speed('func_call parsed') return call, index