Commits

Anonymous committed 9fb32fb

find_occurrences: added support for resources option

Comments (0)

Files changed (2)

 -------------------
 
 The find occurrences command (``C-c f`` by default) can be used to
-find the occurrences of a python name.  If prefixed, it will also show
-unsure occurrences; unsure occurrences are indicated with a ``?`` mark
-in the end.
+find the occurrences of a python name.  If ``unsure`` option is
+``yes``, it will also show unsure occurrences; unsure occurrences are
+indicated with a ``?`` mark in the end.
 
 
 Dialog ``batchset`` Command

ropemacs/interface.py

         buffer = lisputils.make_buffer('*rope-pydoc*', docs, empty_goto=False)
         lisp.local_set_key('q', lisp.bury_buffer)
 
-    @prefixed
+    @interactive
     def find_occurrences(self, prefix):
         self._check_project()
         self._save_buffers()
         resource, offset = self._get_location()
-        def calculate(handle):
-            return codeassist.find_occurrences(
-                self.project, resource, offset,
-                unsure=(prefix != 1), task_handle=handle)
-        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)
+
+        optionals = {
+            'unsure': ropemacs.dialog.Data('Find uncertain occurrences: ',
+                                           default='no', values=['yes', 'no']),
+            'resources': ropemacs.dialog.Data('Files to search: ')}
+        action, values = ropemacs.dialog.show_dialog(
+            lisputils.askdata, ['search', 'cancel'], optionals=optionals)
+        if action == 'search':
+            unsure = values.get('unsure') == 'yes'
+            resources = ropemacs.refactor._resources(self.project,
+                                                     values.get('resources'))
+            def calculate(handle):
+                return codeassist.find_occurrences(
+                    self.project, resource, offset,
+                    unsure=unsure, resources=resources, task_handle=handle)
+            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)
+
 
     @interactive
     def occurrences_goto_occurrence(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.