mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
bug fixing
This commit is contained in:
@@ -42,7 +42,7 @@ class Parser(object):
|
|||||||
name = os.path.basename(self.path)
|
name = os.path.basename(self.path)
|
||||||
self.name = name.rpartition('.')[0] # cut file type (normally .so)
|
self.name = name.rpartition('.')[0] # cut file type (normally .so)
|
||||||
self.path = os.path.dirname(self.path)
|
self.path = os.path.dirname(self.path)
|
||||||
print self.name, self.path
|
#print self.name, self.path
|
||||||
self._content = {}
|
self._content = {}
|
||||||
self._parser = None
|
self._parser = None
|
||||||
self._module = None
|
self._module = None
|
||||||
@@ -54,13 +54,13 @@ class Parser(object):
|
|||||||
self.sys_path.insert(0, self.path)
|
self.sys_path.insert(0, self.path)
|
||||||
|
|
||||||
temp, sys.path = sys.path, self.sys_path
|
temp, sys.path = sys.path, self.sys_path
|
||||||
print 'sypa', sys.path
|
#print 'sypa', sys.path TODO reenable and check (stackoverflow ticket)
|
||||||
exec 'import %s as module' % self.name in self._content
|
exec 'import %s as module' % self.name in self._content
|
||||||
self.sys_path, sys.path = sys.path, temp
|
self.sys_path, sys.path = sys.path, temp
|
||||||
|
|
||||||
self.sys_path.pop(0)
|
self.sys_path.pop(0)
|
||||||
self._module = self._content['module']
|
self._module = self._content['module']
|
||||||
print 'mod', self._content['module']
|
#print 'mod', self._content['module']
|
||||||
return self._module
|
return self._module
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -69,7 +69,7 @@ class Parser(object):
|
|||||||
if not self._parser:
|
if not self._parser:
|
||||||
try:
|
try:
|
||||||
timestamp, parser = Parser.cache[self.name, self.path]
|
timestamp, parser = Parser.cache[self.name, self.path]
|
||||||
if timestamp == os.path.getmtime(self.path):
|
if not self.path or timestamp == os.path.getmtime(self.path):
|
||||||
debug.dbg('hit builtin cache')
|
debug.dbg('hit builtin cache')
|
||||||
self._parser = parser
|
self._parser = parser
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ def strip_imports(scopes):
|
|||||||
result = []
|
result = []
|
||||||
for s in scopes:
|
for s in scopes:
|
||||||
if isinstance(s, parsing.Import):
|
if isinstance(s, parsing.Import):
|
||||||
print 'dini mueter, steile griech!'
|
#print 'dini mueter, steile griech!'
|
||||||
try:
|
try:
|
||||||
result += follow_import(s)
|
result += follow_import(s)
|
||||||
except modules.ModuleNotFound:
|
except modules.ModuleNotFound:
|
||||||
|
|||||||
2
ftest.py
2
ftest.py
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import functions
|
import functions
|
||||||
|
|
||||||
#functions.debug.debug_function = functions.debug.print_to_stdout
|
functions.debug.debug_function = functions.debug.print_to_stdout
|
||||||
functions.debug.ignored_modules = ['parsing', 'builtin']
|
functions.debug.ignored_modules = ['parsing', 'builtin']
|
||||||
functions.debug.ignored_modules = ['parsing', 'builtin', 'evaluate', 'modules']
|
functions.debug.ignored_modules = ['parsing', 'builtin', 'evaluate', 'modules']
|
||||||
functions.modules.module_find_path.insert(0, '.')
|
functions.modules.module_find_path.insert(0, '.')
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ def complete(source, row, column, source_path):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
completions = evaluate.get_names_for_scope(scope)
|
completions = evaluate.get_names_for_scope(scope)
|
||||||
else:
|
else:
|
||||||
|
stmt.parent = scope
|
||||||
scopes = evaluate.follow_statement(stmt, scope)
|
scopes = evaluate.follow_statement(stmt, scope)
|
||||||
|
|
||||||
completions = []
|
completions = []
|
||||||
|
|||||||
@@ -147,4 +147,4 @@ c = b().c3()
|
|||||||
1.0.fromhex(); import flask ; flsk = flask.Flask + flask.Request;
|
1.0.fromhex(); import flask ; flsk = flask.Flask + flask.Request;
|
||||||
abc = [1,2+3]; abc[0].
|
abc = [1,2+3]; abc[0].
|
||||||
import pylab
|
import pylab
|
||||||
pylab.one
|
abc = datetime; return [abc][0].
|
||||||
|
|||||||
24
parsing.py
24
parsing.py
@@ -65,7 +65,7 @@ class Simple(object):
|
|||||||
self.parent = None
|
self.parent = None
|
||||||
|
|
||||||
def get_parent_until(self, *classes):
|
def get_parent_until(self, *classes):
|
||||||
""" Takes always the parent, until one class """
|
""" Takes always the parent, until one class (not a Class) """
|
||||||
scope = self
|
scope = self
|
||||||
while not (scope.parent is None or scope.__class__ in classes):
|
while not (scope.parent is None or scope.__class__ in classes):
|
||||||
scope = scope.parent
|
scope = scope.parent
|
||||||
@@ -209,14 +209,14 @@ class Scope(Simple):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
try:
|
try:
|
||||||
name = self.name
|
name = self.name
|
||||||
except:
|
except AttributeError:
|
||||||
try:
|
try:
|
||||||
name = self.command
|
name = self.command
|
||||||
except:
|
except AttributeError:
|
||||||
name = self.module_path
|
name = self.module_path
|
||||||
|
|
||||||
return "<%s: %s@%s-%s>" % \
|
return "<%s: %s@%s-%s>" % \
|
||||||
(self.__class__.__name__, name, self.line_nr, self.line_end)
|
(self.__class__.__name__, name, self.line_nr, self.__hash__())
|
||||||
|
|
||||||
|
|
||||||
class GlobalScope(Scope):
|
class GlobalScope(Scope):
|
||||||
@@ -242,8 +242,7 @@ class GlobalScope(Scope):
|
|||||||
# set no parent here, because globals are not defined in this scope.
|
# set no parent here, because globals are not defined in this scope.
|
||||||
|
|
||||||
def get_set_vars(self):
|
def get_set_vars(self):
|
||||||
n = []
|
n = super(GlobalScope, self).get_set_vars()
|
||||||
n += super(GlobalScope, self).get_set_vars()
|
|
||||||
n += self.global_vars
|
n += self.global_vars
|
||||||
return n
|
return n
|
||||||
|
|
||||||
@@ -321,10 +320,9 @@ class Function(Scope):
|
|||||||
return str
|
return str
|
||||||
|
|
||||||
def get_set_vars(self):
|
def get_set_vars(self):
|
||||||
n = []
|
n = super(Function, self).get_set_vars()
|
||||||
for i, p in enumerate(self.params):
|
for i, p in enumerate(self.params):
|
||||||
n += p.set_vars or p.used_vars
|
n += p.set_vars or p.used_vars
|
||||||
n += super(Function, self).get_set_vars()
|
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
||||||
@@ -393,8 +391,7 @@ class Flow(Scope):
|
|||||||
generate the output.
|
generate the output.
|
||||||
"""
|
"""
|
||||||
if is_internal_call:
|
if is_internal_call:
|
||||||
n = []
|
n = list(self.set_vars)
|
||||||
n += self.set_vars
|
|
||||||
if self.statement:
|
if self.statement:
|
||||||
n += self.statement.set_vars
|
n += self.statement.set_vars
|
||||||
if self.next:
|
if self.next:
|
||||||
@@ -519,7 +516,7 @@ class Statement(Simple):
|
|||||||
|
|
||||||
def get_set_vars(self):
|
def get_set_vars(self):
|
||||||
""" Get the names for the statement. """
|
""" Get the names for the statement. """
|
||||||
return self.set_vars
|
return list(self.set_vars)
|
||||||
|
|
||||||
def get_assignment_calls(self):
|
def get_assignment_calls(self):
|
||||||
"""
|
"""
|
||||||
@@ -1148,9 +1145,12 @@ class PyFuzzyParser(object):
|
|||||||
if is_return:
|
if is_return:
|
||||||
# add returns to the scope
|
# add returns to the scope
|
||||||
func = self.scope.get_parent_until(Function)
|
func = self.scope.get_parent_until(Function)
|
||||||
func.returns.append(stmt)
|
|
||||||
if is_return == 'yield':
|
if is_return == 'yield':
|
||||||
func.is_generator = True
|
func.is_generator = True
|
||||||
|
try:
|
||||||
|
func.returns.append(stmt)
|
||||||
|
except AttributeError:
|
||||||
|
debug.warning('return in non-function')
|
||||||
|
|
||||||
return stmt, tok
|
return stmt, tok
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
|
||||||
#? ['imag']
|
#? ['imag']
|
||||||
[1,2][0].imag
|
[1,2][0].imag
|
||||||
|
|
||||||
|
a = list()
|
||||||
|
#? ['append']
|
||||||
|
[a][0].append
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def completion_test(source):
|
|||||||
tests += 1
|
tests += 1
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
correct = re.search(r'#\?\s*([^\n]+)', line).group(1)
|
correct = re.search(r'(?:^|\s)#\?\s*([^\n]+)', line).group(1)
|
||||||
except:
|
except:
|
||||||
correct = None
|
correct = None
|
||||||
return tests, fails
|
return tests, fails
|
||||||
|
|||||||
Reference in New Issue
Block a user