Пример #1
0
def run_ghcmods(cmds, msg, alter_messages_cb=None):
    """
    Run several ghcmod commands, concats result messages with callback
    and show output.
    alter_messages_cb accepts dictionary (cmd => list of output messages)
    """
    _window, view, file_shown_in_view = Common.get_haskell_command_window_view_file_project(
    )
    if not file_shown_in_view:
        return

    file_name = os.path.split(file_shown_in_view)[1]

    ghc_mod_args = []
    for cmd in cmds:
        ghc_mod_args.append((cmd, cmd + [file_shown_in_view]))

    def show_current_file_first_and_alter(msgs):
        if alter_messages_cb:
            alter_messages_cb(msgs)

        def sort_key(msg):
            return (msg[1].filename != file_shown_in_view, msg[1].filename,
                    msg[1].start.line, msg[1].start.column)

        msgs.sort(key=sort_key)

    run_ghcmods_thread(view, file_shown_in_view,
                       'Ghc-Mod: ' + msg + ' ' + file_name, ghc_mod_args,
                       show_current_file_first_and_alter)
Пример #2
0
 def is_in_project(self, view):
     file_shown_in_view = Common.get_haskell_command_window_view_file_project(view)[2]
     if file_shown_in_view is None:
         return False
     else:
         src_module = Utils.head_of(BackendManager.active_backend().module(file=file_shown_in_view))
         return src_module is not None and src_module.location.project is not None
Пример #3
0
 def is_scanned_source(self, view):
     file_shown_in_view = Common.get_haskell_command_window_view_file_project(
         view)[2]
     return file_shown_in_view is not None and \
            Utils.head_of(BackendManager.active_backend().module(file=file_shown_in_view)) is not None