Beispiel #1
0
 def redo(self):
     self._check_project()
     change = self.project.history.tobe_redone
     if change is None:
         lisputils.message('Nothing to redo!')
         return
     if lisp.y_or_n_p('Redo <%s>? ' % str(change)):
         def redo(handle):
             for changes in self.project.history.redo(task_handle=handle):
                 self._reload_buffers(changes)
         lisputils.runtask(redo, 'Redo refactoring', interrupts=False)
Beispiel #2
0
    def _perform(self, changes):
        if changes is None:
            lisputils.message("No changes!")
            return

        def perform(handle, self=self, changes=changes):
            self.project.do(changes, task_handle=handle)
            self.interface._reload_buffers(changes)
            self._done()

        lisputils.runtask(perform, "Making %s changes" % self.name, interrupts=False)
        lisputils.message(str(changes.description) + " finished")
Beispiel #3
0
 def generate_autoimport_cache(self):
     if not self._check_autoimport():
         return
     modules = lisp['ropemacs-autoimport-modules'].value()
     modnames = []
     if modules:
         for i in range(len(modules)):
             modname = modules[i]
             if not isinstance(modname, basestring):
                 modname = modname.value()
             modnames.append(modname)
     def generate(handle):
         self.autoimport.generate_cache(task_handle=handle)
         self.autoimport.generate_modules_cache(modules, task_handle=handle)
     lisputils.runtask(generate, 'Generate autoimport cache')
Beispiel #4
0
    def _base_findit(self, do_find, optionals, get_kwds):
        self._check_project()
        self._save_buffers()
        resource, offset = self._get_location()

        action, values = dialog.show_dialog(
            lisputils.askdata, ['search', 'cancel'], optionals=optionals)
        if action == 'search':
            kwds = get_kwds(values)
            def calculate(handle):
                resources = refactor._resources(self.project,
                                                values.get('resources'))
                return do_find(self.project, resource, offset,
                               resources=resources, task_handle=handle, **kwds)
            result = lisputils.runtask(calculate, 'Find Occurrences')
            text = []
            for occurrence in result:
                line = '%s : %s' % (occurrence.resource.path, occurrence.offset)
                if occurrence.unsure:
                    line += ' ?'
                text.append(line)
            text = '\n'.join(text) + '\n'
            buffer = lisputils.make_buffer('*rope-occurrences*',
                                           text, switch=True)
            lisp.set_buffer(buffer)
            lisp.local_set_key('\r', lisp.rope_occurrences_goto_occurrence)
            lisp.local_set_key('q', lisp.rope_occurrences_quit)
Beispiel #5
0
    def show(self, initial_asking=True):
        self.interface._check_project()
        self.interface._save_buffers(only_current=not self.saveall)
        self._create_refactoring()
        action, result = dialog.show_dialog(
            lisputils.askdata,
            ["perform", "preview", "cancel"],
            self._get_confs(),
            self._get_optionals(),
            initial_asking=initial_asking,
        )
        if action == "cancel":
            lisputils.message("Cancelled!")
            return

        def calculate(handle):
            return self._calculate_changes(result, handle)

        name = "Calculating %s changes" % self.name
        changes = lisputils.runtask(calculate, name=name)
        if action == "perform":
            self._perform(changes)
        if action == "preview":
            if changes is not None:
                diffs = str(changes.get_description())
                lisputils.make_buffer("*rope-preview*", diffs, switch=True, modes=["diff"], window="current")
                if lisputils.yes_or_no("Do the changes? "):
                    self._perform(changes)
                else:
                    lisputils.message("Thrown away!")
                lisputils.hide_buffer("*rope-preview*", delete=False)
            else:
                lisputils.message("No changes!")
Beispiel #6
0
 def analyze_modules(self):
     """Perform static object analysis on all project modules"""
     self._check_project()
     def _analyze_modules(handle):
         libutils.analyze_modules(self.project, task_handle=handle)
     lisputils.runtask(_analyze_modules, 'Analyze project modules')