Anonymous avatar Anonymous committed cc48867

interface: added rope-jump-to-global

Comments (0)

Files changed (1)

ropemacs/interface.py

             self.project, self._get_text(), offset, resource, maxfixes)
         if tuple(definition) != (None, None):
             lisp.push_mark()
-            self._goto_location(definition)
+            self._goto_location(definition[0], definition[1])
 
     @local_command('a d', 'P', 'C-c d')
     def show_doc(self, prefix):
             files = self.project.pycore.get_python_files()
         else:
             files = self.project.get_files()
+        return self._ask_file(files)
+
+    def _ask_file(self, files):
         names = []
         for file in files:
             names.append('<'.join(reversed(file.path.split('/'))))
             return file
         lisputils.message('No file selected')
 
+    @local_command()
+    def jump_to_global(self):
+        if not self._check_autoimport():
+            return
+        name = lisputils.ask('Global name: ')
+        result = dict(self.autoimport.get_name_locations(name))
+        file = self._ask_file(result.keys())
+        if file:
+            self._goto_location(file, result[file])
+
     @global_command('c')
     def project_config(self):
         self._check_project()
             if resource:
                 lisp.find_file(resource.real_path)
 
-    def _goto_location(self, location, readonly=False):
-        if location[0]:
-            resource = location[0]
+    def _goto_location(self, resource, lineno):
+        if resource:
+            resource = resource
             if resource.project == self.project:
-                lisp.find_file(str(location[0].real_path))
+                lisp.find_file(str(resource.real_path))
             else:
-                lisp.find_file_read_only(str(location[0].real_path))
-        if location[1]:
-            lisp.goto_line(location[1])
+                lisp.find_file_read_only(str(resource.real_path))
+        if lineno:
+            lisp.goto_line(lineno)
 
     def _get_location(self):
         resource = self._get_resource()
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.