def _handle_response(self,response):
     type_spans = list(parse_exp_types(response))
     if type_spans:
         type_span = next(filter_enclosing(self.view, self.view.sel()[0], type_spans), None)
         if type_span is not None:
             _type, span = type_span
             self.view.show_popup(_type)
Exemple #2
0
    def highlight_type(self, exp_types):
        """
        ide-backend gives us a wealth of type info for the cursor. We only use the first,
        most specific one for now, but it gives us the types all the way out to the topmost
        expression.
        """
        type_spans = list(parse_exp_types(exp_types))
        if type_spans:
            view = self.window.active_view()
            type_span = next(filter_enclosing(view, view.sel()[0], type_spans), None)
            if type_span is not None:
                (_type, span) = type_span
                view.set_status("type_at_cursor", _type)
                view.add_regions("type_at_cursor", [view_region_from_span(view, span)], "storage.type", "", sublime.DRAW_OUTLINED)
                if Win.show_popup:
                    view.show_popup(format_type(_type), on_navigate= (lambda href: webbrowser.open(Win.hoogle_url + href)))
                return

        # Clear type-at-cursor display
        for view in self.window.views():
            view.set_status("type_at_cursor", "")
            view.add_regions("type_at_cursor", [], "storage.type", "", sublime.DRAW_OUTLINED)