addition to fix another docstr problem

This commit is contained in:
David Halter
2012-08-14 12:55:25 +02:00
parent e2fb6c7d9a
commit 79d30f1b24
2 changed files with 9 additions and 7 deletions

View File

@@ -217,15 +217,15 @@ def prepare_goto(source, position, source_path, module, goto_path,
scopes = [imports.ImportPath(user_stmt, is_like_search)] scopes = [imports.ImportPath(user_stmt, is_like_search)]
else: else:
# just parse one statement, take it and evaluate it # 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: try:
stmt = r.module.statements[0] stmt = r.module.statements[0]
except IndexError: except IndexError:
raise NotFoundError() raise NotFoundError()
else:
stmt.start_pos = position stmt.start_pos = position
stmt.parent = weakref.ref(scope) stmt.parent = weakref.ref(scope)
scopes = evaluate.follow_statement(stmt) scopes = evaluate.follow_statement(stmt)
return scopes return scopes

View File

@@ -950,10 +950,12 @@ class PyFuzzyParser(object):
:param user_position: The line/column, the user is currently on. :param user_position: The line/column, the user is currently on.
:type user_position: tuple(int, int) :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_position = user_position
self.user_stmt = None self.user_stmt = None
self.code = code + '\n' # end with \n, because the parser needs it self.code = code + '\n' # end with \n, because the parser needs it
self.no_docstr = no_docstr
if is_py3k(): if is_py3k():
self.code = self.code.encode() self.code = self.code.encode()
@@ -1263,7 +1265,7 @@ class PyFuzzyParser(object):
if not string: if not string:
return None, tok return None, tok
#print 'new_stat', string, set_vars, used_funcs, used_vars #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: and self.last_token[0] == tokenize.STRING:
self.scope.add_docstr(self.last_token[1]) self.scope.add_docstr(self.last_token[1])
return None, tok return None, tok