From 7d116cb4829d684864a0ab8319c688d523ca5d8c Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Fri, 24 Jul 2015 02:02:08 +0200 Subject: [PATCH] ruby: Report proper scope type --- tagmanager/ctags/ruby.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tagmanager/ctags/ruby.c b/tagmanager/ctags/ruby.c index 782b146b..8994a553 100644 --- a/tagmanager/ctags/ruby.c +++ b/tagmanager/ctags/ruby.c @@ -170,6 +170,8 @@ static void emitRubyTag (vString* name, rubyKind kind) { tagEntryInfo tag; vString* scope; + rubyKind parent_kind = K_UNDEFINED; + NestingLevel *lvl; const char *unqualified_name; const char *qualified_name; @@ -179,6 +181,9 @@ static void emitRubyTag (vString* name, rubyKind kind) vStringTerminate (name); scope = nestingLevelsToScope (nesting); + lvl = nestingLevelsGetCurrent (nesting); + if (lvl) + parent_kind = lvl->type; qualified_name = vStringValue (name); unqualified_name = strrchr (qualified_name, SCOPE_SEPARATOR); @@ -190,6 +195,8 @@ static void emitRubyTag (vString* name, rubyKind kind) vStringPut (scope, SCOPE_SEPARATOR); vStringNCatS (scope, qualified_name, unqualified_name - qualified_name); + /* assume module parent type for a lack of a better option */ + parent_kind = K_MODULE; } unqualified_name++; } @@ -198,7 +205,10 @@ static void emitRubyTag (vString* name, rubyKind kind) initTagEntry (&tag, unqualified_name); if (vStringLength (scope) > 0) { - tag.extensionFields.scope [0] = "class"; + Assert (0 <= parent_kind && + (size_t) parent_kind < (sizeof RubyKinds / sizeof RubyKinds[0])); + + tag.extensionFields.scope [0] = RubyKinds [parent_kind].name; tag.extensionFields.scope [1] = vStringValue (scope); } tag.kindName = RubyKinds [kind].name;