예제 #1
0
    def run(self):
        subscribe_setting('enable_hsdev', self.on_hsdev_enabled)
        subscribe_setting('inspect_modules', self.on_inspect_modules_changed)

        if get_setting_async('enable_hsdev'):
            self.start_hsdev()

        while True:
            if get_setting_async('enable_hsdev') and not self.client.ping():
                log('hsdev ping: no pong', log_warning)

            location = self.view.sel()[0].begin()
            if self.view.match_selector(location, 'source.cs')
                scan_paths = []
                with self.dirty_paths as dirty_paths:
                    scan_paths = dirty_paths[:]
                    dirty_paths[:] = []

                files_to_reinspect = []
                with self.dirty_files as dirty_files:
                    files_to_reinspect = dirty_files[:]
                    dirty_files[:] = []

                projects = []
                files = []

                if len(files_to_reinspect) > 0:
                    projects = []
                    files = []
                    for f in files_to_reinspect:
                        d = get_cabal_project_dir_of_file(f)
                        if d is not None:
                            projects.append(d)
                        else:
                            files.append(f)

                projects = list(set(projects))
                files = list(set(files))

                try:
                    self.inspect(paths = scan_paths, projects = projects, files = files)
                except Exception as e:
                    log('HsDevAgent inspect exception: {0}'.format(e))

                load_cabal = []
                with self.cabal_to_load as cabal_to_load:
                    load_cabal = cabal_to_load[:]
                    cabal_to_load[:] = []

                for c in load_cabal:
                    run_async('inspect cabal {0}'.format(c), self.inspect_cabal, c)

                if files_to_reinspect:
                    if get_setting_async('enable_hdocs'):
                        self.client_back.docs(files = files_to_reinspect)
                self.reinspect_event.wait(HsDevAgent.sleep_timeout)
                self.reinspect_event.clear()
예제 #2
0
    def run(self):
        subscribe_setting('enable_hsdev', self.on_hsdev_enabled)
        subscribe_setting('inspect_modules', self.on_inspect_modules_changed)

        if get_setting_async('enable_hsdev'):
            self.start_hsdev()

        while True:
            if get_setting_async('enable_hsdev') and not self.client.ping():
                log('hsdev ping: no pong', log_warning)

            scan_paths = []
            with self.dirty_paths as dirty_paths:
                scan_paths = dirty_paths[:]
                dirty_paths[:] = []

            files_to_reinspect = []
            with self.dirty_files as dirty_files:
                files_to_reinspect = dirty_files[:]
                dirty_files[:] = []

            projects = []
            files = []

            if len(files_to_reinspect) > 0:
                projects = []
                files = []
                for f in files_to_reinspect:
                    d = get_cabal_project_dir_of_file(f)
                    if d is not None:
                        projects.append(d)
                    else:
                        files.append(f)

            projects = list(set(projects))
            files = list(set(files))

            try:
                self.inspect(paths=scan_paths, projects=projects, files=files)
            except Exception as e:
                log('HsDevAgent inspect exception: {0}'.format(e))

            load_cabal = []
            with self.cabal_to_load as cabal_to_load:
                load_cabal = cabal_to_load[:]
                cabal_to_load[:] = []

            for c in load_cabal:
                run_async('inspect cabal {0}'.format(c), self.inspect_cabal, c)

            if files_to_reinspect:
                if get_setting_async('enable_hdocs'):
                    self.client_back.docs(files=files_to_reinspect)
            self.reinspect_event.wait(HsDevAgent.sleep_timeout)
            self.reinspect_event.clear()
예제 #3
0
def update_completions_async(files = [], drop_all = False):
    if drop_all:
        run_async('drop all completions', autocompletion.drop_completions_async)
    else:
        for f in files:
            run_async('drop completions', autocompletion.drop_completions_async, f)
    run_async('init completions', autocompletion.init_completions_async)
예제 #4
0
def update_completions_async(files=[], drop_all=False):
    if drop_all:
        run_async('drop all completions',
                  autocompletion.drop_completions_async)
    else:
        for f in files:
            run_async('drop completions',
                      autocompletion.drop_completions_async, f)
    run_async('init completions', autocompletion.init_completions_async)
예제 #5
0
 def on_activated_async(self, view):
     if is_haskell_source(view):
         filename = view.file_name()
         if filename:
             run_async('get completions for {0}'.format(filename),
                       autocompletion.get_completions_async, filename)
예제 #6
0
 def on_activated_async(self, view):
     if is_haskell_source(view):
         filename = view.file_name()
         if filename:
             run_async('get completions for {0}'.format(filename), autocompletion.get_completions_async, filename)