diff --git a/functions.py b/functions.py index 4b979a22..529622f9 100644 --- a/functions.py +++ b/functions.py @@ -217,15 +217,15 @@ def prepare_goto(source, position, source_path, module, goto_path, scopes = [imports.ImportPath(user_stmt, is_like_search)] else: # just parse one statement, take it and evaluate it - r = parsing.PyFuzzyParser(goto_path, source_path) + r = parsing.PyFuzzyParser(goto_path, source_path, no_docstr=True) try: stmt = r.module.statements[0] except IndexError: raise NotFoundError() - else: - stmt.start_pos = position - stmt.parent = weakref.ref(scope) - scopes = evaluate.follow_statement(stmt) + + stmt.start_pos = position + stmt.parent = weakref.ref(scope) + scopes = evaluate.follow_statement(stmt) return scopes diff --git a/parsing.py b/parsing.py index 8b2ef75a..5660a678 100644 --- a/parsing.py +++ b/parsing.py @@ -950,10 +950,12 @@ class PyFuzzyParser(object): :param user_position: The line/column, the user is currently on. :type user_position: tuple(int, int) """ - def __init__(self, code, module_path=None, user_position=None): + def __init__(self, code, module_path=None, user_position=None, + no_docstr=False): self.user_position = user_position self.user_stmt = None self.code = code + '\n' # end with \n, because the parser needs it + self.no_docstr = no_docstr if is_py3k(): self.code = self.code.encode() @@ -1263,7 +1265,7 @@ class PyFuzzyParser(object): if not string: return None, tok #print 'new_stat', string, set_vars, used_funcs, used_vars - if self.freshscope and len(tok_list) == 1 \ + if self.freshscope and not self.no_docstr and len(tok_list) == 1 \ and self.last_token[0] == tokenize.STRING: self.scope.add_docstr(self.last_token[1]) return None, tok