Exemplo n.º 1
0
    def show_types(self, types):
        if not types:
            Common.show_status_message("Can't infer type", False)
            return

        types = sorted(filter(
            lambda t: t.region(self.view).contains(self.view.sel()[0]), types),
                       key=lambda t: t.region(self.view).size())
        self.output_view = Common.output_panel(self.view.window(),
                                               '',
                                               panel_name=TYPES_PANEL_NAME,
                                               syntax='Haskell-SublimeHaskell',
                                               panel_display=False)

        regions = []
        for typ in types:
            Common.output_text(self.output_view,
                               '{0}\n'.format(typ.show(self.view)),
                               clear=False)
            regions.append(
                sublime.Region(
                    self.output_view.size() - 1 -
                    len(UnicodeOpers.use_unicode_operators(typ.typename)),
                    self.output_view.size() - 1))
        self.output_view.add_regions('types', regions, 'comment', '',
                                     sublime.DRAW_OUTLINED)
        Common.show_panel(self.view.window(), panel_name=TYPES_PANEL_NAME)
Exemplo n.º 2
0
    def on_changed(self, idx):
        if idx == -1:
            return

        typ = self.types[idx]
        Common.output_text(self.output_view, typ.show(self.view), clear=True)
        self.view.add_regions('typed', [typ.region(self.view)], 'string', 'dot', sublime.DRAW_OUTLINED)
Exemplo n.º 3
0
def wait_for_chain_to_complete(view, cabal_project_dir, msg, cmds, on_done):
    """Chains several commands, wait for them to complete, then parse and display
    the resulting errors."""

    # First hide error panel to show that something is going on
    sublime.set_timeout(lambda: hide_output(view), 0)

    # run and wait commands, fail on first fail
    # stdout = ''
    collected_out = []
    output_log = Common.output_panel(view.window(), '',
                                     panel_name=BUILD_LOG_PANEL_NAME,
                                     panel_display=Settings.PLUGIN.show_output_window)
    for cmd in cmds:
        Common.output_text(output_log, ' '.join(cmd) + '...\n')

        # Don't tie stderr to stdout, since we're interested in the error messages
        out = OutputCollector.OutputCollector(output_log, cmd, cwd=cabal_project_dir)
        exit_code, cmd_out = out.wait()
        collected_out.append(cmd_out)

        # Bail if the command failed...
        if exit_code != 0:
            break

    if len(collected_out) > 0:
        # We're going to show the errors in the output panel...
        Common.hide_panel(view.window(), panel_name=BUILD_LOG_PANEL_NAME)

    # Notify UI thread that commands are done
    sublime.set_timeout(on_done, 0)
    parse_output_messages_and_show(view, msg, cabal_project_dir, exit_code, ''.join(collected_out))
Exemplo n.º 4
0
    def on_changed(self, idx):
        if idx == -1:
            return

        typ = self.types[idx]
        Common.output_text(self.output_view, typ.show(self.view), clear=True)
        self.view.add_regions('typed', [typ.region(self.view)], 'string', 'dot', sublime.DRAW_OUTLINED)
Exemplo n.º 5
0
    def on_done(self, idx):
        self.view.erase_regions('typed')

        if idx == -1:
            return

        typ = self.types[idx]
        Common.output_text(self.output_view, typ.show(self.view), clear=True)
Exemplo n.º 6
0
    def on_done(self, idx):
        self.view.erase_regions('typed')

        if idx == -1:
            return

        typ = self.types[idx]
        Common.output_text(self.output_view, typ.show(self.view), clear=True)
Exemplo n.º 7
0
    def wait_for_chain_to_complete(self, view, cabal_project_name,
                                   cabal_project_dir, banner, cmds):
        '''Chains several commands, wait for them to complete, then parse and display
        the resulting errors.'''

        # First hide error panel to show that something is going on
        sublime.set_timeout(lambda: hide_output(view), 0)

        # run and wait commands, fail on first fail
        # exit_code has scope outside of the loop
        collected_out = []
        exit_code = 0
        output_log = Common.output_panel(
            view.window(),
            '',
            panel_name=BUILD_LOG_PANEL_NAME,
            panel_display=Settings.PLUGIN.show_output_window)
        for cmd in cmds:
            if isinstance(cmd, list):
                Common.output_text(output_log, ' '.join(cmd) + '\u2026\n')

                # Don't tie stderr to stdout, since we're interested in the error messages
                out = OutputCollector.OutputCollector(output_log,
                                                      cmd,
                                                      cwd=cabal_project_dir)
                exit_code, cmd_out = out.wait()
            elif callable(cmd):
                Common.output_text(
                    output_log, 'Function/method {0}\n'.format(cmd.__name__))
                exit_code, cmd_out = cmd(cabal_project_dir)
            else:
                # Clearly something not a list or callable:
                pass

            collected_out.append(cmd_out)
            # Bail if the command failed...
            if exit_code != 0:
                break

        if collected_out or exit_code == 0:
            # We're going to show the errors in the output panel...
            Common.hide_panel(view.window(), panel_name=BUILD_LOG_PANEL_NAME)

        # Notify UI thread that commands are done
        self.PROJECTS_BEING_BUILT.remove(cabal_project_name)
        ParseOutput.MARKER_MANAGER.mark_compiler_output(
            view, banner, cabal_project_dir, ''.join(collected_out), exit_code)
Exemplo n.º 8
0
    def show_types(self, types):
        if not types:
            Common.sublime_status_message("Can't infer type")
            return

        self.types = types
        self.output_view = Common.output_panel(self.view.window(), '',
                                               panel_name=TYPES_PANEL_NAME,
                                               syntax='Haskell-SublimeHaskell',
                                               panel_display=False)
        regions = []
        for typ in self.types:
            Common.output_text(self.output_view, '{0}\n'.format(typ.show(self.view)), clear=False)
            regions.append(sublime.Region(self.output_view.size() - 1 - len(UnicodeOpers.use_unicode_operators(typ.typename)),
                                          self.output_view.size() - 1))
        self.output_view.add_regions('types', regions, 'comment', '', sublime.DRAW_OUTLINED)
        Common.show_panel(self.view.window(), panel_name=TYPES_PANEL_NAME)
Exemplo n.º 9
0
    def wait_for_chain_to_complete(self, view, cabal_project_name, cabal_project_dir, banner, cmds):
        '''Chains several commands, wait for them to complete, then parse and display
        the resulting errors.'''

        # First hide error panel to show that something is going on
        Common.hide_panel(view.window(), panel_name=OUTPUT_PANEL_NAME)

        # run and wait commands, fail on first fail
        # exit_code has scope outside of the loop
        collected_out = []
        exit_code = 0
        output_log = Common.output_panel(view.window(), '',
                                         panel_name=BUILD_LOG_PANEL_NAME,
                                         panel_display=Settings.PLUGIN.show_output_window)
        try:
            for cmd in cmds:
                if isinstance(cmd, list):
                    Common.output_text(output_log, ' '.join(cmd) + '\u2026\n')

                    # Don't tie stderr to stdout, since we're interested in the error messages
                    out = OutputCollector.OutputCollector(output_log, cmd, cwd=cabal_project_dir)
                    exit_code, cmd_out = out.wait()
                elif callable(cmd):
                    Common.output_text(output_log, 'Function/method {0}\n'.format(cmd.__name__))
                    exit_code, cmd_out = cmd(cabal_project_dir)
                else:
                    # Clearly something not a list or callable:
                    pass

                collected_out.append(cmd_out)
                # Bail if the command failed...
                if exit_code != 0:
                    break

            if exit_code == 0:
                # Hide the build panel if successful
                Common.hide_panel(view.window(), panel_name=BUILD_LOG_PANEL_NAME)
        finally:
            self.PROJECTS_BEING_BUILT.remove(cabal_project_name)

        # Execute post-build steps in the UI thread (paranoia)
        sublime.set_timeout(functools.partial(self.post_build, banner, cabal_project_dir, collected_out, exit_code), 0)
Exemplo n.º 10
0
    def wait_for_chain_to_complete(self, view, cabal_project_name, cabal_project_dir, banner, cmds):
        '''Chains several commands, wait for them to complete, then parse and display
        the resulting errors.'''

        # First hide error panel to show that something is going on
        Common.hide_panel(view.window(), panel_name=OUTPUT_PANEL_NAME)

        # run and wait commands, fail on first fail
        # exit_code has scope outside of the loop
        collected_out = []
        exit_code = 0
        output_log = Common.output_panel(view.window(), '',
                                         panel_name=BUILD_LOG_PANEL_NAME,
                                         panel_display=Settings.PLUGIN.show_output_window)
        try:
            for cmd in cmds:
                if isinstance(cmd, list):
                    Common.output_text(output_log, ' '.join(cmd) + '\u2026\n')

                    # Don't tie stderr to stdout, since we're interested in the error messages
                    out = OutputCollector.OutputCollector(output_log, cmd, cwd=cabal_project_dir)
                    exit_code, cmd_out = out.wait()
                elif callable(cmd):
                    Common.output_text(output_log, 'Function/method {0}\n'.format(cmd.__name__))
                    exit_code, cmd_out = cmd(cabal_project_dir)
                else:
                    # Clearly something not a list or callable:
                    pass

                collected_out.append(cmd_out)
                # Bail if the command failed...
                if exit_code != 0:
                    break

            if exit_code == 0:
                # Hide the build panel if successful
                Common.hide_panel(view.window(), panel_name=BUILD_LOG_PANEL_NAME)
        finally:
            self.PROJECTS_BEING_BUILT.remove(cabal_project_name)

        # Execute post-build steps in the UI thread (paranoia)
        sublime.set_timeout(functools.partial(self.post_build, banner, cabal_project_dir, collected_out, exit_code), 0)
Exemplo n.º 11
0
    def wait_for_chain_to_complete(self, view, cabal_project_dir, msg, cmds,
                                   on_done):
        '''Chains several commands, wait for them to complete, then parse and display
        the resulting errors.'''

        # First hide error panel to show that something is going on
        sublime.set_timeout(lambda: hide_output(view), 0)

        # run and wait commands, fail on first fail
        # exit_code has scope outside of the loop
        # stdout = ''
        collected_out = []
        exit_code = 0
        output_log = Common.output_panel(
            view.window(),
            '',
            panel_name=BUILD_LOG_PANEL_NAME,
            panel_display=Settings.PLUGIN.show_output_window)
        for cmd in cmds:
            Common.output_text(output_log, ' '.join(cmd) + '...\n')

            # Don't tie stderr to stdout, since we're interested in the error messages
            out = OutputCollector.OutputCollector(output_log,
                                                  cmd,
                                                  cwd=cabal_project_dir)
            exit_code, cmd_out = out.wait()
            collected_out.append(cmd_out)

            # Bail if the command failed...
            if exit_code != 0:
                break

        if collected_out or exit_code == 0:
            # We're going to show the errors in the output panel...
            Common.hide_panel(view.window(), panel_name=BUILD_LOG_PANEL_NAME)

        # Notify UI thread that commands are done
        sublime.set_timeout(on_done, 0)
        the_stderr = ''.join(collected_out)

        # The process has terminated; parse and display the output:
        parsed_messages = ParseOutput.parse_output_messages(
            view, cabal_project_dir, the_stderr)
        # The unparseable part (for other errors)
        unparsable = Regexes.OUTPUT_REGEX.sub('', the_stderr).strip()

        # Set global error list
        ParseOutput.set_global_error_messages(parsed_messages)

        # If we couldn't parse any messages, just show the stderr
        # Otherwise the parsed errors and the unparsable stderr remainder
        outputs = []

        if parsed_messages:
            outputs += [ParseOutput.format_output_messages(parsed_messages)]
            if unparsable:
                outputs += ['', '']
        if unparsable:
            outputs += ["Collected output:\n", unparsable]

        ParseOutput.show_output_result_text(view, msg, '\n'.join(outputs),
                                            exit_code, cabal_project_dir)
        sublime.set_timeout(
            lambda: ParseOutput.mark_messages_in_views(parsed_messages), 0)