def wait_ghcmod_and_parse(view, file_dir, msg, cmds_with_args, alter_messages_cb): sublime.set_timeout(lambda: hide_output(view), 0) exit_success = True parsed_messages = [] for (cmd, args) in cmds_with_args: stdout = call_ghcmod_and_wait(args, file_dir) # stdout contains NULL as line endings within one message # error_output_regex using indents to determine one message scope # Replace NULLs to indents out = stdout.replace('\0', '\n ').decode('utf-8') exit_success = exit_success and len(out) == 0 parsed = parse_output_messages(file_dir, out) for p in parsed: parsed_messages.append((cmd, p)) exit_code = 0 if exit_success else 1 if alter_messages_cb: alter_messages_cb(parsed_messages) concated_messages = map(lambda m: m[1], parsed_messages) output_text = format_output_messages(concated_messages) show_output_result_text(view, msg, output_text, exit_code, file_dir) sublime.set_timeout(lambda: mark_messages_in_views(concated_messages), 0)
def run_chain(self, cmds, msg, fly_mode = False): self.messages = [] self.msgs = [] self.corrections = [] self.fly_mode = fly_mode self.filename = self.view.file_name() if not self.filename: return self.contents = {} if self.view.is_dirty(): self.contents[self.filename] = self.view.substr(sublime.Region(0, self.view.size())) if not self.fly_mode: hide_output(self.view) if not cmds: return else: self.status_msg = status_message_process(msg + ': ' + self.filename, priority = 2) self.status_msg.start() self.go_chain(cmds)
def run_chain(self, cmds, msg, fly_mode=False): self.messages = [] self.msgs = [] self.corrections = [] self.fly_mode = fly_mode self.filename = self.view.file_name() if not self.filename: return self.contents = {} if self.view.is_dirty(): self.contents[self.filename] = self.view.substr( sublime.Region(0, self.view.size())) if not self.fly_mode: hide_output(self.view) if not cmds: return else: self.status_msg = status_message_process(msg + ': ' + self.filename) self.status_msg.start() self.go_chain(cmds)
def wait_ghcmod_and_parse(view, filename, msg, cmds_with_args, alter_messages_cb): sublime.set_timeout(lambda: hide_output(view), 0) parsed_messages = [] file_dir = os.path.dirname(filename) all_cmds_successful = True all_cmds_outputs = [] for (cmd, args) in cmds_with_args: stdout = call_ghcmod_and_wait(args, filename) # stdout contains NULL as line endings within one message # error_output_regex using indents to determine one message scope # Replace NULLs to indents out1 = stdout.replace('\0', '\n ') # Hlint outputs Error instead Warning for tips # so lets replace them out = out1.replace('Error', 'Warning') success = len(out.strip()) == 0 if not success: all_cmds_outputs.append(out) log(u"ghc-mod %s didn't exit with success on '%s'" % (u' '.join(cmd), filename)) all_cmds_successful &= success parsed = parse_output_messages(file_dir, out) for p in parsed: parsed_messages.append((cmd, p)) if alter_messages_cb: alter_messages_cb(parsed_messages) concated_messages = [m[1] for m in parsed_messages] # Set global error list set_global_error_messages(concated_messages) sublime.set_timeout(lambda: mark_messages_in_views(concated_messages), 0) output_text = (format_output_messages(concated_messages) if parsed_messages else '\n'.join(all_cmds_outputs)) exit_code = 0 if all_cmds_successful else 1 show_output_result_text(view, msg, output_text, exit_code, file_dir)
def run_chain(self, cmds, msg, fly_mode = False): self.messages = [] self.msgs = [] self.corrections = [] self.fly_mode = fly_mode self.filename = self.view.file_name() if not self.filename: return self.contents = {} if self.view.is_dirty(): self.contents[self.filename] = self.view.substr(sublime.Region(0, self.view.size())) if not self.fly_mode: hide_output(self.view) if not cmds: return else: self.status_msg = status_message_process(msg + ': ' + self.filename, priority = 2) self.status_msg.start() if not hsdev.agent_connected(): log('hsdev chain fails: hsdev not connected', log_error) self.status_msg.fail() self.status_msg.stop() else: self.go_chain(cmds)
def wait_ghcmod_and_parse(view, filename, msg, cmds_with_args, alter_messages_cb): sublime.set_timeout(lambda: hide_output(view), 0) parsed_messages = [] file_dir = os.path.dirname(filename) all_cmds_successful = True all_cmds_outputs = [] for (cmd, args) in cmds_with_args: stdout = call_ghcmod_and_wait(args, filename) # stdout contains NULL as line endings within one message # error_output_regex using indents to determine one message scope # Replace NULLs to indents out = stdout.replace('\0', '\n ') success = len(out.strip()) == 0 if not success: all_cmds_outputs.append(out) log(u"ghc-mod %s didn't exit with success on '%s'" % (u' '.join(cmd), filename), log_error) all_cmds_successful &= success parsed = parse_output_messages(view, file_dir, out) for p in parsed: parsed_messages.append((cmd, p)) if alter_messages_cb: alter_messages_cb(parsed_messages) concated_messages = [m[1] for m in parsed_messages] # Set global error list set_global_error_messages(concated_messages) sublime.set_timeout(lambda: mark_messages_in_views(concated_messages), 0) output_text = (format_output_messages(concated_messages) if parsed_messages else '\n'.join(all_cmds_outputs)) exit_code = 0 if all_cmds_successful else 1 show_output_result_text(view, msg, output_text, exit_code, file_dir)