[Geany] Scoped Ruby declarations, with a hackish patch

Lex Trotman elextr at xxxxx
Thu Sep 6 22:49:15 UTC 2012


On 7 September 2012 04:58, Colomban Wendling <lists.ban at herbesfolles.org> wrote:
> 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"

This is of course what C++ does when the declarations are not visible eg

a::b::f(){}; makes a function 'a::b::f' if the declarations of a and b
are not visible (eg in a closed .hpp file), if they are visible it
puts f inside the declaration of b. Compare the symbols pane entrys
for the definitions of f() and g() in the attached.

I'm not a rubyist but I assume that Foo doesn't need to be declared
before Bar in the above example and thats the problem.  From the C++
example what you would need to do is "autodeclare" Foo (as what?) so
you had somewhere to put 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.

But it is statically declared so it should work like C++ should it not?

Cheers
Lex

>
> 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
>
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nesting.cpp
Type: text/x-c++src
Size: 82 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/users/attachments/20120907/f2d9d016/attachment.cpp>


More information about the Users mailing list