[Github-comments] [geany] Rewrite scope completion 3 (#862)

Colomban Wendling notifications at xxxxx
Tue Jan 26 15:10:11 UTC 2016


> Now thinking about it again we can just strip away the scope part and search for the type only - in find_scope_members() we don't look for the type's scope anyway. So it will be simple on the TM side when the parser gets fixed (can post the patch separately from this pull request to avoid adding more and more stuff).

OK.  To try my parser fix I did the following, and it seemed to work.  Maybe it's stupid, maybe it's naive, or maybe not.  If it's that simple, I'd love to see it added here (doesn't add any kind of burden on the review IMO).
```diff
diff --git a/tagmanager/src/tm_workspace.c b/tagmanager/src/tm_workspace.c
index 898b6ab..6bd2e4e 100644
--- a/tagmanager/src/tm_workspace.c
+++ b/tagmanager/src/tm_workspace.c
@@ -846,6 +846,15 @@ find_scope_members_tags (const GPtrArray *all, TMTag *type_tag, gboolean namespa
 }
 
 
+static const gchar *strip_scope(const gchar *scoped_name, langType lang)
+{
+    const gchar *sep = tm_tag_context_separator(lang);
+    const gchar *base = g_strrstr(scoped_name, sep);
+
+    return base ? &base[strlen(sep)] : scoped_name;
+}
+
+
 /* Gets all members of the type with the given name; search them inside tags_array */
 static GPtrArray *
 find_scope_members (const GPtrArray *tags_array, const gchar *type_name, TMSourceFile *file,
@@ -897,9 +906,11 @@ find_scope_members (const GPtrArray *tags_array, const gchar *type_name, TMSourc
         /* intermediate typedef - resolve to the real type */
         if (tag->type == tm_tag_typedef_t)
         {
-            if (tag->var_type && tag->var_type[0] != '\0')
+            const gchar *var_type = tag->var_type ? strip_scope(tag->var_type, tag->lang) : NULL;
+
+            if (var_type && var_type[0] != '\0')
             {
-                type_name = tag->var_type;
+                type_name = var_type;
                 file = tag->file;
                 continue;
             }
@@ -998,7 +1009,7 @@ find_scope_members_all(const GPtrArray *tags, const GPtrArray *searched_array, l
             if (!(tag->type & member_types) || member ||
                 member_at_method_scope(tags, current_scope, tag, lang))
             {
-                gchar *tag_type = g_strdup(tag->var_type);
+                gchar *tag_type = g_strdup(strip_scope(tag->var_type, tag->lang));
 
                 /* remove pointers in case the type contains them */
                 g_strdelimit(tag_type, "*^", ' ');
```

---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/862#issuecomment-175066866
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160126/724feeb1/attachment.html>


More information about the Github-comments mailing list