def show_type_hint(self, view, point):
project_path = find_project_dir(view)
module_info = get_module_imports(project_path, view.file_name())
module, word = module_word(view, point)
if word == '':
return
if word[0] == '(' and word[-1] == ')':
word = word[1:-1]
# TODO: use module from module_word to improve accuracy
type_info = get_type(
project_path,
module_info['moduleName'],
word,
[m['module'] for m in module_info['imports']]
)
if len(type_info) == 0:
return
first_result = type_info[0]
def on_navigate(string):
view.window().open_file(string, sublime.ENCODED_POSITION)
#file_path:row:col
link_url = first_result['definedAt']['name'] + ':' + \
str(first_result['definedAt']['start'][0]) + ':' + \
str(first_result['definedAt']['start'][1])
view.show_popup('''
<p>From: <a href="%s">%s</a> </p>
<p>Type: %s </p>
''' % ( link_url,
",".join(first_result['exportedFrom']),
first_result['type']),
sublime.HIDE_ON_MOUSE_MOVE_AWAY,
point,
500, # max width
500, # max height
on_navigate)
评论列表
文章目录