1
0
forked from VimPlug/jedi

add keyword_names method to keyword module (includes test), fixes #248

This commit is contained in:
David Halter
2013-08-06 10:55:05 +04:30
parent 66a984b8ef
commit 0dc3106569
3 changed files with 19 additions and 6 deletions
+11 -1
View File
@@ -4,6 +4,7 @@ import pydoc
import keyword
from jedi._compatibility import is_py3k
from jedi import parsing_representation as pr
from jedi import common
import builtin
@@ -19,7 +20,7 @@ else:
keys = keyword.kwlist + ['None', 'False', 'True']
def get_keywords(string='', pos=(0, 0), all=False):
def keywords(string='', pos=(0, 0), all=False):
if all:
return set([Keyword(k, pos) for k in keys])
if string in keys:
@@ -27,6 +28,15 @@ def get_keywords(string='', pos=(0, 0), all=False):
return set()
def keyword_names(*args, **kwargs):
kwds = []
for k in keywords(*args, **kwargs):
start = k.start_pos
end = start[0], start[1] + len(k.name)
kwds.append(pr.Name(k.parent, [(k.name, start)], start, end, k))
return kwds
def get_operator(string, pos):
return Keyword(string, pos)