Beispiel #1
0
    def run(self, edit):
        class Worker(threading.Thread):
            def __init__(self, view, context, changes):
                self.view = view
                self.context = context
                self.changes = changes
                self.handler = TaskHandle(name='organizer_imports_handler')
                self.handler.add_observer(self.finish)
                threading.Thread.__init__(self)

            def run(self):
                self.context.project.do(self.changes, task_handle=self.handler)

            def finish(self):

                percent_done = self.handler.current_jobset().get_percent_done()
                if percent_done == 100:
                    sublime.set_timeout(self.view.run_command('revert'), 10)

        with ropemate.context_for(self.view) as context:
            self.view.run_command("save")
            organizer = ImportOrganizer(context.project)
            changes = organizer.organize_imports(context.resource)

            if changes is not None:
                Worker(self.view, context, changes).start()
Beispiel #2
0
    def run(self, edit):
        class Worker(threading.Thread):

            def __init__(self, view, context, changes):
                self.view = view
                self.context = context
                self.changes = changes
                self.handler = TaskHandle(name='organizer_imports_handler')
                self.handler.add_observer(self.finish)
                threading.Thread.__init__(self)

            def run(self):
                self.context.project.do(self.changes, task_handle=self.handler)

            def finish(self):

                percent_done = self.handler.current_jobset().get_percent_done()
                if percent_done == 100:
                    sublime.set_timeout(self.view.run_command('revert'), 10)

        with ropemate.context_for(self.view) as context:
            self.view.run_command("save")
            organizer = ImportOrganizer(context.project)
            changes = organizer.organize_imports(context.resource)

            if changes is not None:
                Worker(self.view, context, changes).start()
Beispiel #3
0
def organize_imports():
    """ Organize imports in current file. """
    with RopeContext() as ctx:
        organizer = ImportOrganizer(ctx.project)
        changes = organizer.organize_imports(ctx.resource)
        if changes is not None:
            progress = ProgressHandler('Organize imports')
            ctx.project.do(changes, task_handle=progress.handle)
            reload_changes(changes)
Beispiel #4
0
def organize_imports():
    """ Organize imports in current file. """
    with RopeContext() as ctx:
        organizer = ImportOrganizer(ctx.project)
        changes = organizer.organize_imports(ctx.resource)
        if changes is not None:
            progress = ProgressHandler('Organize imports')
            ctx.project.do(changes, task_handle=progress.handle)
            reload_changes(changes)