Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Show a simple gutter icon for each parsing error.
"""
view.erase_regions('ocaml-underlines-errors')
errors = merlin_view(view).report_errors()
error_messages = []
underlines = []
for e in errors:
if 'start' in e and 'end' in e:
pos_start = e['start']
pos_stop = e['end']
pnt_start = merlin_pos(view, pos_start)
pnt_stop = merlin_pos(view, pos_stop)
r = sublime.Region(pnt_start, pnt_stop)
line_r = view.full_line(r)
line_r = sublime.Region(line_r.a - 1, line_r.b)
underlines.append(r)
# Remove line and character number
message = e['message']
error_messages.append((line_r, message))
self.error_messages = error_messages
flag = sublime.DRAW_OUTLINED
# add_regions(key, regions, scope, icon, flags)
view.add_regions('ocaml-underlines-errors', underlines, 'invalid',
self.gutter_icon_path(), flag)
"""
Show a simple gutter icon for each parsing error.
"""
view.erase_regions('ocaml-underlines-errors')
errors = merlin_view(view).report_errors()
error_messages = []
underlines = []
for e in errors:
if 'start' in e and 'end' in e:
pos_start = e['start']
pos_stop = e['end']
pnt_start = merlin_pos(view, pos_start)
pnt_stop = merlin_pos(view, pos_stop)
r = sublime.Region(pnt_start, pnt_stop)
line_r = view.full_line(r)
line_r = sublime.Region(line_r.a - 1, line_r.b)
underlines.append(r)
# Remove line and character number
message = e['message']
error_messages.append((line_r, message))
self.error_messages = error_messages
flag = sublime.DRAW_OUTLINED
# add_regions(key, regions, scope, icon, flags)
view.add_regions('ocaml-underlines-errors', underlines, 'invalid',
self.gutter_icon_path(), flag)
def _item_region(self, item):
start = merlin_pos(self.view, item['start'])
end = merlin_pos(self.view, item['end'])
return sublime.Region(start, end)
def _item_region(self, item):
start = merlin_pos(self.view, item['start'])
end = merlin_pos(self.view, item['end'])
return sublime.Region(start, end)
def merlin_locate_result(result, window):
if isinstance(result, dict):
pos = result['pos']
if 'file' in result:
filename = "%s:%d:%d" % (result['file'], pos['line'], pos['col'] + 1)
window.open_file(filename, sublime.ENCODED_POSITION | sublime.TRANSIENT)
else:
view = window.active_view()
sel = view.sel()
sel.clear()
pos = merlin_pos(view, pos)
sel.add(sublime.Region(pos, pos))
view.show_at_center(pos)
else:
sublime.message_dialog(result)