1
0
forked from VimPlug/jedi

Add keywords, improve import support.

This commit is contained in:
Dave Halter
2014-10-10 17:48:40 +02:00
parent 54c91b1509
commit a192f4f347
2 changed files with 32 additions and 17 deletions

View File

@@ -51,6 +51,8 @@ _ast_mapping = {
'classdef': pr.Class,
'funcdef': pr.Function,
'file_input': pr.SubModule,
'import_name': pr.Import,
'import_from': pr.Import,
}
ast_mapping = dict((getattr(python_symbols, k), v) for k, v in _ast_mapping.items())
@@ -162,7 +164,10 @@ def convert(grammar, raw_node):
print('leaf', raw_node, type_repr(type))
prefix, start_pos = context
if type == tokenize.NAME:
return pr.Name(value, start_pos, prefix)
if value in grammar.keywords:
return pr.Keyword(value, start_pos, prefix)
else:
return pr.Name(value, start_pos, prefix)
elif type in (tokenize.STRING, tokenize.NUMBER):
return pr.Literal(value, start_pos, prefix)
elif type in (tokenize.NEWLINE, tokenize.ENDMARKER):