コード例 #1
0
 def inspect_path(self, path):
     with Common.status_message_process('Inspecting path {0}'.format(path), priority=1) as smgr:
         self.client_back.scan(paths=[path],
                               on_notify=ScanStatus(smgr),
                               wait=True,
                               ghc=Settings.PLUGIN.ghc_opts,
                               docs=Settings.PLUGIN.enable_hdocs)
コード例 #2
0
ファイル: fly_check.py プロジェクト: reygoch/SublimeHaskell
    def scan_contents(self):
        current_file_name = self.view.file_name()
        view_contents = {
            current_file_name:
            self.view.substr(sublime.Region(0, self.view.size()))
        }

        status_msg = Common.status_message_process(
            "Scanning {0}".format(current_file_name))
        status_msg.start()

        def scan_resp(_resp):
            status_msg.result_ok()
            _project_dir, project_name = Common.locate_cabal_project_from_view(
                self.view)
            self.autocompleter.drop_completions_async(current_file_name)
            self.autocompleter.generate_completions_cache(
                project_name, current_file_name, contents=view_contents)

        def scan_err(_err, _details):
            status_msg.result_fail()

        BackendManager.active_backend().scan(files=[current_file_name],
                                             contents=view_contents,
                                             on_response=scan_resp,
                                             on_error=scan_err)
コード例 #3
0
 def inspect_cabal(self, cabal=None):
     with Common.status_message_process('Inspecting {0}'.format(cabal or 'cabal'), priority=1) as smgr:
         self.client_back.scan(cabal=(cabal == 'cabal'),
                               sandboxes=[] if cabal == 'cabal' else [cabal],
                               on_notify=ScanStatus(smgr),
                               wait=True,
                               docs=Settings.PLUGIN.enable_hdocs)
コード例 #4
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 self.filename:
         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:
             ParseOutput.hide_output(self.view)
             if not hsdev.agent_connected():
                 Logging.log('hsdev chain fails: hsdev not connected',
                             Logging.LOG_ERROR)
                 sublime.error_message(
                     'check_lint.run_chain: Cannot execute command chain, hsdev not connected.'
                 )
             else:
                 if cmds:
                     self.status_msg = Common.status_message_process(
                         msg + ': ' + self.filename, priority=2)
                     self.status_msg.start()
                     self.go_chain(cmds)
                 else:
                     sublime.error_message(
                         'Empty command chain (check_lint.run_chain)')
コード例 #5
0
 def inspect_files(self, filenames):
     with Common.status_message_process('Inspecting files', priority=1) as smgr:
         self.client_back.scan(files=filenames,
                               on_notify=ScanStatus(smgr),
                               wait=True,
                               ghc=Settings.PLUGIN.ghc_opts,
                               docs=Settings.PLUGIN.enable_hdocs)
コード例 #6
0
ファイル: check_lint.py プロジェクト: cstheory/SublimeHaskell
    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:
            ParseOutput.hide_output(self.view)
        if cmds:
            self.status_msg = Common.status_message_process(msg + ': ' +
                                                            self.filename,
                                                            priority=2)
            self.status_msg.start()

            if not hsdev.agent_connected():
                Logging.log('hsdev chain fails: hsdev not connected',
                            Logging.LOG_ERROR)
                self.status_msg.fail()
                self.status_msg.stop()
            else:
                self.go_chain(cmds)
コード例 #7
0
ファイル: commands.py プロジェクト: reygoch/SublimeHaskell
    def run(self, _edit, **kwargs):
        self.current_file_name = kwargs.get('filename') or self.view.file_name()
        self.status_msg = Common.status_message_process("Scanning docs for {0}".format(self.current_file_name), priority=3)
        self.status_msg.start()

        def run_infer():
            self.status_msg = Common.status_message_process("Inferring types for {0}".format(self.current_file_name),
                                                            priority=3)
            self.status_msg.start()

            def infer_on_resp(_resp):
                self.status_msg.result_ok()

            def infer_on_err(_err, _details):
                self.status_msg.result_fail()

            BackendManager.active_backend().infer(files=[self.current_file_name], on_response=infer_on_resp,
                                                  on_error=infer_on_err)

        def on_resp(_resp):
            self.status_msg.result_ok()
            run_infer()

        def on_err(_err, _details):
            self.status_msg.result_fail()
            run_infer()

        BackendManager.active_backend().docs(files=[self.current_file_name], on_response=on_resp, on_error=on_err)
コード例 #8
0
ファイル: backend_cmds.py プロジェクト: dten/SublimeHaskell
 def start_new_backend(self, backend_name):
     with Common.status_message_process(
             'Changing backend to \'{0}\''.format(backend_name),
             priority=2):
         BackendManager.BackendManager().change_current_backend(
             backend_name)
         cabal_project_status(self.window.active_view(),
                              BackendManager.BackendManager())
コード例 #9
0
    def inspect_project(self, cabal_dir):
        (project_name, _) = Common.get_cabal_in_dir(cabal_dir)

        with Common.status_message_process('Inspecting project {0}'.format(project_name), priority=1) as smgr:
            self.client_back.scan(projects=[cabal_dir],
                                  on_notify=ScanStatus(smgr),
                                  wait=True,
                                  docs=Settings.PLUGIN.enable_hdocs)
コード例 #10
0
 def inspect_files(self, filenames):
     with Common.status_message_process('Inspecting files',
                                        priority=1) as smgr:
         self.backend.scan(files=filenames,
                           on_notify=ScanStatus(smgr),
                           wait_complete=True,
                           timeout=None,
                           ghc=Settings.PLUGIN.ghc_opts,
                           docs=Settings.PLUGIN.enable_hdocs)
コード例 #11
0
 def do_shutdown(self):
     backend_mgr = BackendManager.BackendManager()
     with Common.status_message_process('Shutting down {0} backend'.format(backend_mgr.current_backend_name), priority=1):
         try:
             self.busy = True
             backend_mgr.shutdown_backend()
         finally:
             self.busy = False
             cabal_project_status(self.window.active_view(), BackendManager.BackendManager())
コード例 #12
0
 def inspect_files(self, filenames):
     with Common.status_message_process('Inspecting files', priority=1) as smgr:
         self.backend.scan(files=filenames,
                           on_notify=ScanStatus(smgr),
                           wait_complete=True,
                           timeout=None,
                           ghc=Settings.PLUGIN.ghc_opts,
                           docs=Settings.PLUGIN.enable_hdocs)
         smgr.result_ok()
コード例 #13
0
 def inspect_path(self, path):
     with Common.status_message_process('Inspecting path {0}'.format(path), priority=1) as smgr:
         self.backend.scan(paths=[path],
                           on_notify=ScanStatus(smgr),
                           wait_complete=True,
                           timeout=None,
                           ghc=Settings.PLUGIN.ghc_opts,
                           docs=Settings.PLUGIN.enable_hdocs)
         smgr.result_ok()
コード例 #14
0
 def inspect_user_db(self):
     with Common.status_message_process('Inspecting user-db', priority=1) as smgr:
         self.backend.scan_package_dbs(
             ['global-db', 'user-db'],
             on_notify=ScanStatus(smgr),
             wait_complete=True,
             timeout=None,
         )
         smgr.result_ok()
コード例 #15
0
 def inspect_cabal(self, cabal):
     with Common.status_message_process('Inspecting {0}'.format(cabal or 'cabal'), priority=1) as smgr:
         self.backend.scan(cabal=(cabal == 'cabal'),
                           sandboxes=[] if cabal == 'cabal' else [cabal],
                           on_notify=ScanStatus(smgr),
                           wait_complete=True,
                           timeout=None,
                           docs=Settings.PLUGIN.enable_hdocs)
         smgr.result_ok()
コード例 #16
0
 def do_startup(self):
     backend_mgr = BackendManager.BackendManager()
     with Common.status_message_process('Starting up {0} backend'.format(backend_mgr.current_backend_name), priority=1):
         try:
             self.busy = True
             backend_mgr.set_state(BackendManager.BackendManager.INITIAL)
             backend_mgr.initialize()
         finally:
             self.busy = False
             cabal_project_status(self.window.active_view(), BackendManager.BackendManager())
コード例 #17
0
    def inspect_project(self, cabal_dir):
        (project_name, _) = Common.get_cabal_in_dir(cabal_dir)

        with Common.status_message_process('Inspecting project {0}'.format(project_name), priority=1) as smgr:
            self.backend.scan(projects=[cabal_dir],
                              on_notify=ScanStatus(smgr),
                              wait_complete=True,
                              timeout=None,
                              docs=Settings.PLUGIN.enable_hdocs)
            smgr.result_ok()
コード例 #18
0
ファイル: inspector.py プロジェクト: reygoch/SublimeHaskell
 def inspect_path(self, path):
     with Common.status_message_process('Inspecting path {0}'.format(path),
                                        priority=1) as smgr:
         self.backend.scan(paths=[path],
                           on_notify=ScanStatus(smgr),
                           wait_complete=True,
                           timeout=None,
                           ghc=Settings.PLUGIN.ghc_opts,
                           docs=Settings.PLUGIN.enable_hdocs)
         smgr.result_ok()
コード例 #19
0
 def inspect(self, paths, projects, files):
     if paths or projects or files:
         with Common.status_message_process('Inspecting', priority=1) as smgr:
             self.client_back.scan(paths=paths,
                                   projects=projects,
                                   files=files,
                                   on_notify=ScanStatus(smgr),
                                   wait=True,
                                   ghc=Settings.PLUGIN.ghc_opts,
                                   docs=Settings.PLUGIN.enable_hdocs)
コード例 #20
0
ファイル: inspector.py プロジェクト: reygoch/SublimeHaskell
 def inspect_cabal(self, cabal):
     with Common.status_message_process('Inspecting {0}'.format(cabal
                                                                or 'cabal'),
                                        priority=1) as smgr:
         self.backend.scan(cabal=(cabal == 'cabal'),
                           sandboxes=[] if cabal == 'cabal' else [cabal],
                           on_notify=ScanStatus(smgr),
                           wait_complete=True,
                           timeout=None,
                           docs=Settings.PLUGIN.enable_hdocs)
         smgr.result_ok()
コード例 #21
0
ファイル: inspector.py プロジェクト: reygoch/SublimeHaskell
    def inspect_project(self, cabal_dir):
        (project_name, _) = Common.get_cabal_in_dir(cabal_dir)

        with Common.status_message_process(
                'Inspecting project {0}'.format(project_name),
                priority=1) as smgr:
            self.backend.scan(projects=[cabal_dir],
                              on_notify=ScanStatus(smgr),
                              wait_complete=True,
                              timeout=None,
                              docs=Settings.PLUGIN.enable_hdocs)
            smgr.result_ok()
コード例 #22
0
    def inspect(self, paths, projects, files, contents):
        if paths or projects or files:
            if Settings.COMPONENT_DEBUG.inspection:
                print('{0}.inspect:'.format(type(self).__name__))
                print('  :: paths: {0}'.format(paths))
                print('  :: projects: {0}'.format(projects))
                print('  :: files: {0}'.format(files))

            build_tool = Settings.PLUGIN.haskell_build_tool
            with Common.status_message_process('Inspecting', priority=1) as smgr:
                for project in projects:
                    self.backend.scan_project(
                        project=project,
                        build_tool=build_tool,
                        wait_complete=True,
                        timeout=None,
                        on_notify=ScanStatus(smgr),
                    )
                    smgr.result_ok()
            with Common.status_message_process('Inspecting', priority=1) as smgr:
                for file in files:
                    self.backend.scan_file(
                        file=file,
                        build_tool=build_tool,
                        wait_complete=True,
                        timeout=None,
                        on_notify=ScanStatus(smgr),
                    )
                    file_contents = contents.get(file, None)
                    if file_contents is not None:
                        self.backend.set_file_contents(
                            file,
                            file_contents,
                            wait_complete=True,
                            timeout=None,
                            on_notify=ScanStatus(smgr),
                        )

                    smgr.result_ok()
コード例 #23
0
ファイル: commands.py プロジェクト: reygoch/SublimeHaskell
        def run_infer():
            self.status_msg = Common.status_message_process("Inferring types for {0}".format(self.current_file_name),
                                                            priority=3)
            self.status_msg.start()

            def infer_on_resp(_resp):
                self.status_msg.result_ok()

            def infer_on_err(_err, _details):
                self.status_msg.result_fail()

            BackendManager.active_backend().infer(files=[self.current_file_name], on_response=infer_on_resp,
                                                  on_error=infer_on_err)
コード例 #24
0
def run_binary(name, bin_file, base_dir):
    with Common.status_message_process('Running {0}'.format(name),
                                       priority=5) as smsg:
        exit_code, out, err = ProcHelper.ProcHelper.run_process([bin_file],
                                                                cwd=base_dir)
        window = sublime.active_window()
        if not window:
            return
        if exit_code == 0:
            smsg.ok()
            sublime.set_timeout(lambda: write_output(window, out, base_dir), 0)
        else:
            smsg.fail()
            sublime.set_timeout(lambda: write_output(window, err, base_dir), 0)
コード例 #25
0
    def scan_contents(self, view):
        current_file_name = view.file_name()
        status_msg = Common.status_message_process("Scanning {0}".format(current_file_name), priority=3)
        status_msg.start()

        def scan_resp(_resp):
            status_msg.stop()
            self.update_completions_async([current_file_name])

        def scan_err(_err, _details):
            status_msg.fail()
            status_msg.stop()

        scan_contents = {current_file_name: view.substr(sublime.Region(0, view.size()))}
        BackendManager.active_backend().scan(contents=scan_contents, on_response=scan_resp, on_error=scan_err)
コード例 #26
0
 def run_chain(self, cmds, fly_mode=False):
     ParseOutput.MARKER_MANAGER.clear_error_marks()
     if self.filename:
         self.fly_mode = fly_mode
         if not self.fly_mode:
             Common.hide_panel(self.view.window())
         if cmds:
             self.status_msg = Common.status_message_process(self.caption + ': ' + self.filename)
             self.status_msg.start()
             self.commands = cmds
             self.go_chain()
         else:
             sublime.error_message('Empty command chain (check_lint.run_chain)')
     else:
         print('run_chain: no file name? {0}'.format(self.filename))
コード例 #27
0
ファイル: commands.py プロジェクト: reygoch/SublimeHaskell
    def run(self, **_kwargs):
        if self.window.active_view().file_name():
            def on_resp(msgs):
                self.status_msg.result_ok()
                if msgs:
                    sublime.set_timeout(functools.partial(self.on_got_messages, msgs), 0)

            def on_err(err, _details):
                self.status_msg.result_fail()
                Common.sublime_status_message('Check & Lint: {0}'.format(err))

            self.status_msg = Common.status_message_process('Autofix: ' + self.window.active_view().file_name(), priority=3)
            self.status_msg.start()
            BackendManager.active_backend().check_lint(files=[self.window.active_view().file_name()],
                                                       ghc=Settings.PLUGIN.ghc_opts,
                                                       on_response=on_resp,
                                                       on_error=on_err)
コード例 #28
0
    def scan_contents(self):
        current_file_name = self.view.file_name()
        view_contents = {current_file_name: self.view.substr(sublime.Region(0, self.view.size()))}

        status_msg = Common.status_message_process("Scanning {0}".format(current_file_name))
        status_msg.start()

        def scan_resp(_resp):
            status_msg.result_ok()
            _project_dir, project_name = Common.locate_cabal_project_from_view(self.view)
            self.autocompleter.drop_completions_async(current_file_name)
            self.autocompleter.generate_completions_cache(project_name, current_file_name, contents=view_contents)

        def scan_err(_err, _details):
            status_msg.result_fail()

        BackendManager.active_backend().scan(files=[current_file_name], contents=view_contents,
                                             on_response=scan_resp, on_error=scan_err)
コード例 #29
0
ファイル: commands.py プロジェクト: aplgsd/SublimeHaskell
    def run(self):
        if self.window.active_view().file_name():
            def on_resp(msgs):
                self.status_msg.stop()
                if msgs is not None:
                    sublime.set_timeout(lambda: self.on_got_messages(msgs), 0)

            def on_err(err, _details):
                self.status_msg.fail()
                self.status_msg.stop()
                Common.show_status_message('Check & Lint: {0}'.format(err), False)

            self.status_msg = Common.status_message_process('Autofix: ' + self.window.active_view().file_name(), priority=3)
            self.status_msg.start()
            BackendManager.active_backend().check_lint(files=[self.window.active_view().file_name()],
                                                       ghc=Settings.PLUGIN.ghc_opts,
                                                       on_response=on_resp,
                                                       on_error=on_err)
コード例 #30
0
 def run_chain(self, cmds, fly_mode=False):
     ParseOutput.MARKER_MANAGER.clear_error_marks()
     if self.filename:
         self.fly_mode = fly_mode
         if not self.fly_mode:
             Common.hide_panel(self.view.window())
         if cmds:
             self.status_msg = Common.status_message_process(self.caption +
                                                             ': ' +
                                                             self.filename)
             self.status_msg.start()
             self.commands = cmds
             self.go_chain()
         else:
             sublime.error_message(
                 'Empty command chain (check_lint.run_chain)')
     else:
         print('run_chain: no file name? {0}'.format(self.filename))
コード例 #31
0
    def inspect(self, paths, projects, files, contents):
        if paths or projects or files:
            if Settings.COMPONENT_DEBUG.inspection:
                print('{0}.inspect:'.format(type(self).__name__))
                print('  :: paths: {0}'.format(paths))
                print('  :: projects: {0}'.format(projects))
                print('  :: files: {0}'.format(files))

            with Common.status_message_process('Inspecting', priority=1) as smgr:
                self.backend.scan(paths=paths,
                                  projects=projects,
                                  files=files,
                                  contents=contents,
                                  on_notify=ScanStatus(smgr),
                                  wait_complete=True,
                                  timeout=None,
                                  ghc=Settings.PLUGIN.ghc_opts,
                                  docs=Settings.PLUGIN.enable_hdocs)
                smgr.result_ok()
コード例 #32
0
ファイル: inspector.py プロジェクト: reygoch/SublimeHaskell
    def inspect(self, paths, projects, files, contents):
        if paths or projects or files:
            if Settings.COMPONENT_DEBUG.inspection:
                print('{0}.inspect:'.format(type(self).__name__))
                print('  :: paths: {0}'.format(paths))
                print('  :: projects: {0}'.format(projects))
                print('  :: files: {0}'.format(files))

            with Common.status_message_process('Inspecting',
                                               priority=1) as smgr:
                self.backend.scan(paths=paths,
                                  projects=projects,
                                  files=files,
                                  contents=contents,
                                  on_notify=ScanStatus(smgr),
                                  wait_complete=True,
                                  timeout=None,
                                  ghc=Settings.PLUGIN.ghc_opts,
                                  docs=Settings.PLUGIN.enable_hdocs)
                smgr.result_ok()
コード例 #33
0
 def run_chain(self, cmds, msg, fly_mode=False):
     self.filename = self.view.file_name()
     if self.filename:
         self.msgs = []
         self.corrections = []
         self.fly_mode = fly_mode
         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:
             ParseOutput.hide_output(self.view)
             if cmds:
                 self.status_msg = Common.status_message_process(
                     msg + ': ' + self.filename, priority=2)
                 self.status_msg.start()
                 self.go_chain(cmds)
             else:
                 sublime.error_message(
                     'Empty command chain (check_lint.run_chain)')
コード例 #34
0
    def scan_contents(self):
        current_file_name = self.view.file_name()

        status_msg = Common.status_message_process(
            "Scanning {0}".format(current_file_name))
        status_msg.start()

        def scan_resp(_resp):
            status_msg.result_ok()
            _project_dir, project_name = Common.locate_cabal_project_from_view(
                self.view)
            EventCommon.update_completions_async(self.autocompleter,
                                                 project_name,
                                                 files=[current_file_name])

        def scan_err(_err, _details):
            status_msg.result_fail()

        BackendManager.active_backend().scan_file(
            file=current_file_name,
            build_tool=Settings.PLUGIN.haskell_build_tool,
            on_response=scan_resp,
            on_error=scan_err,
        )
コード例 #35
0
    def run_binary(self, name, bin_file, base_dir):
        def write_output(window, text, base_dir):
            "Write text to Sublime's output panel."
            output_view = Common.output_panel(window,
                                              text,
                                              panel_name=OUTPUT_PANEL_NAME,
                                              panel_display=True)
            output_view.settings().set("result_base_dir", base_dir)

        with Common.status_message_process('Running {0}'.format(name),
                                           priority=5) as smsg:
            exit_code, out, err = ProcHelper.ProcHelper.run_process(
                [bin_file], cwd=base_dir)
            window = sublime.active_window()
            if not window:
                return
            if exit_code == 0:
                smsg.ok()
                sublime.set_timeout(
                    lambda: write_output(window, out, base_dir), 0)
            else:
                smsg.fail()
                sublime.set_timeout(
                    lambda: write_output(window, err, base_dir), 0)
コード例 #36
0
ファイル: commands.py プロジェクト: reygoch/SublimeHaskell
 def on_done(self, search_str):
     self.search_str = search_str
     self.status_msg = Common.status_message_process("Hayoo '{0}'".format(search_str), priority=3)
     self.status_msg.start()
     BackendManager.active_backend().hayoo(self.search_str, page=0, pages=5, on_response=self.on_resp, on_error=self.on_err)
コード例 #37
0
ファイル: commands.py プロジェクト: reygoch/SublimeHaskell
 def on_done(self, search_str):
     self.search_str = search_str
     self.status_msg = Common.status_message_process("Search '{0}'".format(search_str), priority=3)
     self.status_msg.start()
     BackendManager.active_backend().symbol(lookup=self.search_str, search_type='infix',
                                            on_response=self.on_symbol, on_error=self.on_err)
コード例 #38
0
 def start_new_backend(self, backend_name):
     with Common.status_message_process('Changing backend to \'{0}\''.format(backend_name), priority=2):
         BackendManager.BackendManager().change_current_backend(backend_name)
         cabal_project_status(self.window.active_view(), BackendManager.BackendManager())