[Geany-devel] Scoped Ruby declarations, with a hackish patch

Colomban Wendling lists.ban at xxxxx
Thu Sep 6 18:58:56 UTC 2012


Hi guys,

I saw that the ruby parser don't properly generate tags declarations like:

	class Foo::Bar
	end

which should generate a tag "Bar" with the scope "Foo";  but it
generates a tag "Foo" and simply ignores "Bar".  This seems to apply to
modules, classes and methods at least -- almost everything.

So I wanted to fix that.  Unfortunately the scoping code in CTags don't
really support to easily put several scopes at the same "level", e.g. if
you want to push several scope you gotta handle the popping yourself.
And since there is one single block end, it's tricky to do.

Since I was way too lazy (and didn't even found a good implementation)
to fix that, I just did it the dirty way: reading the whole "Foo::Bar"
as a single tag name ("Foo.Bar") and tuning the code registering the tag
to split this on the last ".", putting the left part (if any) in the
scope.  Patch attached.  This is quite dirty, but works fine unless a
legitimate tag may include a "." in its name, which doesn't seem the
case currently looking at the parser.

Note that Ruby isn't the only language that allows such kind of scoping.
 For example, Vala allows to prefix stuff with a namespace -- and there
is the same problem here.

So, especially Nick, what do you guys think of this?  Is this patch too
dirty?  Do somebody have a better idea?  Or is this too dirty and "we
don't care because nobody writes ruby anyway"?  In one word: opinions?

Thanks,
Colomban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Correctly-parse-Ruby-declarations-with-inline-scopin.patch
Type: text/x-patch
Size: 2356 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20120906/cf5dfd0e/attachment.bin>


More information about the Devel mailing list