예제 #1
0
 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)
예제 #2
0
    def test_parse_exp_types_readFile(self):
        exp_types = list(res.parse_exp_types(readFile_exp_types.get('contents')))
        self.assertEqual(3, len(exp_types))
        (type, span) = exp_types[0]

        self.assertEqual('FilePath -> IO String', type)
        self.assertEqual('src/Lib.hs', span.filePath)
예제 #3
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.
     """
     types = list(parse_exp_types(exp_types))
     if types:
         # Display the first type in a region and in the status bar
         view = self.window.active_view()
         (type, span) = types[0]
         if span:
             if Win.show_popup:
                 view.show_popup(type)
             view.set_status("type_at_cursor", type)
             view.add_regions("type_at_cursor", [view_region_from_span(view, span)], "storage.type", "", sublime.DRAW_OUTLINED)
     else:
         # 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)
예제 #4
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)
예제 #5
0
 def _handle_response(self,response):
     types = list(parse_exp_types(response))
     if types:
         (type, span) = types[0] # types are ordered by relevance?
         sublime.set_clipboard(type)
예제 #6
0
 def test_parse_exp_types_empty(self):
     exp_types = res.parse_exp_types([])
     self.assertEqual(0, len(list(exp_types)))