1
0
forked from VimPlug/jedi

statement parser - first version

This commit is contained in:
David Halter
2012-03-11 03:03:54 +01:00
parent 5332a87d39
commit b2a77acff6
4 changed files with 232 additions and 53 deletions

View File

@@ -1,9 +1,5 @@
import parsing
def Statement(object):
""" The statement object of functions, to """
pass
def get_names_for_scope(scope):
""" Get all completions possible for the current scope. """
comp = []
@@ -38,6 +34,7 @@ def follow_path(scope, path):
scopes.append(c.parent)
#elif p_class == parsing.Function:
elif p_class == parsing.Statement:
print 'state', c.parent.token_list, c.parent.get_assignment_calls()
pass
else:
print 'error follow_path:', p_class, repr(c.parent)
@@ -49,6 +46,42 @@ def follow_path(scope, path):
scopes = new_scopes
return set(scopes)
def _parseassignment(self):
""" TODO remove or replace, at the moment not used """
assign = ''
token_type, tok, indent = self.next()
if token_type == tokenize.STRING or tok == 'str':
return '""'
elif tok == '(' or tok == 'tuple':
return '()'
elif tok == '[' or tok == 'list':
return '[]'
elif tok == '{' or tok == 'dict':
return '{}'
elif token_type == tokenize.NUMBER:
return '0'
elif tok == 'open' or tok == 'file':
return 'file'
elif tok == 'None':
return '_PyCmplNoType()'
elif tok == 'type':
return 'type(_PyCmplNoType)' # only for method resolution
else:
assign += tok
level = 0
while True:
token_type, tok, indent = self.next()
if tok in ('(', '{', '['):
level += 1
elif tok in (']', '}', ')'):
level -= 1
if level == 0:
break
elif level == 0:
if tok in (';', '\n'):
break
assign += tok
return "%s" % assign
def dbg(*args):
if debug_function: