Re: [gedit-list] class browser plugin



Ok my apologies: PEBKAC here - it does work on Python and the problem
is that some things have changed in the browerwidget that needs
updates in the ruby parser. The attached patch takes care of this.

Simply put the attached patch in the same directory as the
parser_ruby.rb file and execute:

$ patch -p0 < ruby_move_in_file.patch

and it should be fixed. The patch is against revision 23 in Subversion.

Sorry for the misunderstanding.

Btw, Frederic, I see you are putting attributes in their own sublevel
for Python, a nice touch, I think I'll try to copy that. :)

-- Kristoffer


On 6/25/07, Kristoffer Lundén <kristoffer lunden gmail com> wrote:
Hello,

sorry for taking so awfully long to get back to you - I'm not the
author of the plugin itself, but I am the author of the Ruby parser.

On 6/15/07, Andre Pinheiro <andrelimapinheiro gmail com> wrote:
> I've checked out the class browser plugin from SVN (revision 23), but, whenever I click on a tree branch (e.g., a method in a ruby file), nothing happens -- I don't get positioned in the file where that method is at.
>

I just tried installing version 23 as well, and you are right: it
doesn't position the cursor in the file, but this is the same for
Python files as well, so there seems to be something broken in the
plugin itself, not in the Ruby parser.

I haven't investigated further, but just a heads for where to
(probably) look for the problem.

> I don't remember if in the stable version this worked or not, and (with the unstable ver.) there were a few times when I got some error saying that there was a method which required 2 arguments but 3 were specified. Strangely, I'm not getting this error now...
>

If you have any Ruby files that misbehave I'd be happy to have a look
at it if you can share testable example source. The plugin isn't 100%
complete, though it currently works well enough for all files I'm
working on. Suggestions for more functionality is welcome, though I
will not make any promises, depends a bit on how hard it is to do. :)
Patches even better, but those should probably be sent directly to
Frederic, as he is managing the source.


-- Kristoffer



--
Kristoffer Lundén
✉ kristoffer lunden gmail com
✉ kristoffer lunden gamemaker nu
http://www.gamemaker.nu/
☎ 0704 48 98 77



--
Kristoffer Lundén
✉ kristoffer lunden gmail com
✉ kristoffer lunden gamemaker nu
http://www.gamemaker.nu/
☎ 0704 48 98 77
Index: parser_ruby.py
===================================================================
--- parser_ruby.py	(revision 23)
+++ parser_ruby.py	(working copy)
@@ -127,10 +127,17 @@
         """ get the token at the specified line number """
         for token in self.tokens:
             if token.start <= line and token.end > line:
-                return token
+                return self.__findInnermostTokenAtLine(token, line)
         return None
 
+    def __findInnermostTokenAtLine(self, token, line):
+        """" ruby is parsed as nested, unlike python """
+        for child in token.children:
+            if child.start <= line and child.end > line:
+                return self.__findInnermostTokenAtLine(child, line)
+        return token
 
+
     def parse(self, verbose=True):
 
         #if verbose: print "parse ----------------------------------------------"
@@ -250,8 +257,9 @@
 
 
     def appendTokenToBrowser(self, token, parentit ):
-        it = self.browsermodel.append(parentit,(token,))
-        token.path = self.browsermodel.get_path(it)
+        it = self.__browsermodel.append(parentit,(token,))
+        token.path = self.__browsermodel.get_path(it)
+        #print token.path
         #if token.parent:
         #    if token.parent.expanded:
         #        self.browser.expand_row(token.parent.path,False)
@@ -270,19 +278,20 @@
     
         self.rubyfile = RubyFile(doc)
         self.rubyfile.parse(options.singleton().verbose)
-        self.browsermodel = gtk.TreeStore(gobject.TYPE_PYOBJECT)
+        self.__browsermodel = gtk.TreeStore(gobject.TYPE_PYOBJECT)
         for child in self.rubyfile.children:
             self.appendTokenToBrowser(child,None)
-        return self.browsermodel
+        return self.__browsermodel
 
         
     def __private_test_method(self):
         pass
 
 
-    def get_tag_position(self, model, doc, path):
+    def get_tag_position(self, model, path):
         tok = model.get_value( model.get_iter(path), 0 )
-        return tok.rubyfile.uri, tok.start+1
+        try: return tok.rubyfile.uri, tok.start+1
+        except: return None
 
 
     def current_line_changed(self, model, doc, line):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]