def get_completions(self, document, complete_event):
cur_text = document.text_before_cursor
cur_word = None
word_dict = None
for regex, method_name in RULES:
match = regex.search(cur_text)
if match:
gen_completions = getattr(self.comp_gen, method_name)
completions = gen_completions(self.context, match)
word_dict = OrderedDict(completions)
groups = match.groups()
if len(groups) > 1:
cur_word = groups[-1]
else:
cur_word = document.get_word_before_cursor(WORD=True)
break
if word_dict:
for comp in match_completions(cur_word, word_dict):
yield comp
评论列表
文章目录