forked from akissinger/sublime-polyml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoly_get_type.py
33 lines (26 loc) · 1.09 KB
/
poly_get_type.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sublime
import sublime_plugin
import os
import poly
import polyio
class DescribePolySymbolCommand(sublime_plugin.WindowCommand):
def __init__(self, window):
sublime_plugin.WindowCommand.__init__(self, window)
self.poly = poly.global_instance(window.active_view().settings().get('poly_bin'))
def run(self):
view = self.window.active_view()
polyio.show_output_view()
path = self.window.active_view().file_name()
if self.poly.has_built(path):
position = view.sel()[0].begin()
try:
node = self.poly.node_for_position(path, position)
name = view.substr(sublime.Region(node.start, node.end))
ml_type = self.poly.type_for_node(node)
if ml_type != None:
polyio.println('val %s : %s' % (name, ml_type))
except poly.process.Timeout:
pass
polyio.println()
else:
polyio.println('Recompile this file to get info about its symbols.')