예제 #1
0
 def run(self):
     # Compile the ModuleInspector:
     sublime.status_message('Compiling Haskell ModuleInspector...')
     exit_code, out, err = call_and_wait(['ghc',
         '--make', MODULE_INSPECTOR_SOURCE_PATH,
         '-o', MODULE_INSPECTOR_EXE_PATH,
         '-outputdir', MODULE_INSPECTOR_OBJ_DIR])
     # TODO: If compilation failed, we can't proceed; handle this.
     # Periodically wake up and see if there is anything to inspect.
     while True:
         files_to_reinspect = []
         with self.dirty_files_lock:
             files_to_reinspect = self.dirty_files
             self.dirty_files = []
         # Find the cabal project corresponding to each "dirty" file:
         cabal_dirs = []
         for filename in files_to_reinspect:
             d = get_cabal_project_dir_of_file(filename)
             if d is not None:
                 cabal_dirs.append(d)
         # Eliminate duplicate project directories:
         cabal_dirs = list(set(cabal_dirs))
         for d in cabal_dirs:
             self._refresh_all_module_info(d)
         time.sleep(AGENT_SLEEP_DURATION)
예제 #2
0
    def run(self):
        # Compile the CabalInspector:
        # TODO: Where to compile it?
        sublime.set_timeout(lambda: sublime.status_message('Compiling Haskell CabalInspector...'), 0)

        exit_code, out, err = call_and_wait(['ghc',
            '--make', CABAL_INSPECTOR_SOURCE_PATH,
            '-o', CABAL_INSPECTOR_EXE_PATH,
            '-outputdir', CABAL_INSPECTOR_OBJ_DIR])

        if exit_code != 0:
            error_msg = u"SublimeHaskell: Failed to compile CabalInspector\n{0}".format(err)
            wait_for_window(lambda w: self.show_errors(w, error_msg))
        else:
            sublime.set_timeout(lambda: sublime.status_message('Compiling Haskell CabalInspector' + u" \u2714"), 0)
        # Continue anyway

        # Compile the ModuleInspector:
        sublime.set_timeout(lambda: sublime.status_message('Compiling Haskell ModuleInspector...'), 0)

        exit_code, out, err = call_and_wait(['ghc',
            '--make', MODULE_INSPECTOR_SOURCE_PATH,
            '-o', MODULE_INSPECTOR_EXE_PATH,
            '-outputdir', MODULE_INSPECTOR_OBJ_DIR])

        if exit_code != 0:
            error_msg = u"SublimeHaskell: Failed to compile ModuleInspector\n{0}".format(err)
            wait_for_window(lambda w: self.show_errors(w, error_msg))
            return

        sublime.set_timeout(lambda: sublime.status_message('Compiling Haskell ModuleInspector' + u" \u2714"), 0)

        # For first time, inspect all open folders and files
        wait_for_window(lambda w: self.mark_all_files(w))

        # TODO: If compilation failed, we can't proceed; handle this.
        # Periodically wake up and see if there is anything to inspect.
        while True:
            files_to_reinspect = []
            with self.dirty_files_lock:
                files_to_reinspect = self.dirty_files
                self.dirty_files = []
            # Find the cabal project corresponding to each "dirty" file:
            cabal_dirs = []
            standalone_files = []
            for filename in files_to_reinspect:
                d = get_cabal_project_dir_of_file(filename)
                if d is not None:
                    cabal_dirs.append(d)
                else:
                    standalone_files.append(filename)
            # Eliminate duplicate project directories:
            cabal_dirs = list(set(cabal_dirs))
            standalone_files = list(set(standalone_files))
            for d in cabal_dirs:
                self._refresh_all_module_info(d)
            for f in standalone_files:
                self._refresh_module_info(f)
            self.reinspect_event.wait(AGENT_SLEEP_TIMEOUT)
            self.reinspect_event.clear()