Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sun, 10 Jan 2016 11:31:47 UTC
Commit: 30fa28bac7d8c5928dd613c34d5d833b3dfead2b
https://github.com/geany/geany/commit/30fa28bac7d8c5928dd613c34d5d833b3dfea…
Log Message:
-----------
Don't use enums for scoped search
Even though enums contain members, their members are accessed in a
different way than members of classes and structs. E.g. consider:
typedef enum {A, B, C, D} MyEnum;
Variable of this type is declared as
MyEnum myVar;
myVar can be assigned a value from MyEnum; however, we don't access myVar
over the dot operator so we don't need the list of all members after
typing
myVar.
This patch eliminates some false positives after typing .
Modified Paths:
--------------
tagmanager/src/tm_workspace.c
Modified: tagmanager/src/tm_workspace.c
5 lines changed, 2 insertions(+), 3 deletions(-)
===================================================================
@@ -59,7 +59,7 @@ static TMTagAttrType global_tags_sort_attrs[] =
static TMTagType TM_MEMBER_TYPE_MASK =
tm_tag_function_t | tm_tag_prototype_t |
tm_tag_member_t | tm_tag_field_t |
- tm_tag_method_t | tm_tag_enumerator_t;
+ tm_tag_method_t;
static TMWorkspace *theWorkspace = NULL;
@@ -824,8 +824,7 @@ find_scope_members (const GPtrArray *tags_array, GPtrArray *member_array,
TMTag *tag = NULL;
GPtrArray *type_tags;
TMTagType types = (tm_tag_class_t | tm_tag_namespace_t |
- tm_tag_struct_t | tm_tag_typedef_t |
- tm_tag_union_t | tm_tag_enum_t);
+ tm_tag_struct_t | tm_tag_union_t | tm_tag_typedef_t);
type_tags = g_ptr_array_new();
if (typedef_file)
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sun, 10 Jan 2016 11:31:46 UTC
Commit: 809a9a7ea5e65a1500349b38afd415095d00d48e
https://github.com/geany/geany/commit/809a9a7ea5e65a1500349b38afd415095d00d…
Log Message:
-----------
Merge add_member() and find_scope_members_tags()
By comparing the file pointer in the loop we can speed it up a bit
because we can avoid the strcmp() (this function is the slowest part of
the scope completion based on profiling).
Also move the pointer array creation to this function and return it which
is a bit cleaner.
Modified Paths:
--------------
tagmanager/src/tm_workspace.c
Modified: tagmanager/src/tm_workspace.c
55 lines changed, 22 insertions(+), 33 deletions(-)
===================================================================
@@ -761,42 +761,39 @@ GPtrArray *tm_workspace_find(const char *name, const char *scope, TMTagType type
}
-static void add_member(GPtrArray * tags, TMTag *tag)
-{
- gboolean add = TRUE;
-
- if (tags->len > 0)
- {
- TMTag *last_tag = TM_TAG(tags->pdata[tags->len-1]);
- /* add only if it's from the same file - this prevents mixing tags from
- * structs with identical name (typically the anonymous ones) so we
- * only get members from a single one. For workspace tags it adds
- * all members because there's no file associated. */
- add = last_tag->file == tag->file;
- }
- if (add)
- /* the first file name "wins" */
- g_ptr_array_add (tags, tag);
-}
-
-
-static void
-find_scope_members_tags (const GPtrArray * all, GPtrArray * tags,
- const char *scope, langType lang)
+static GPtrArray *
+find_scope_members_tags (const GPtrArray * all, const char *scope, langType lang)
{
+ GPtrArray *tags = g_ptr_array_new();
+ TMSourceFile *last_file = NULL;
guint i;
for (i = 0; i < all->len; ++i)
{
TMTag *tag = TM_TAG (all->pdata[i]);
- if (tag && tag->scope && tag->scope[0] != '\0' &&
+ if (tag && (tag->file == last_file || last_file == NULL) &&
+ tag->scope && tag->scope[0] != '\0' &&
langs_compatible(tag->lang, lang) &&
strcmp(scope, tag->scope) == 0)
{
- add_member (tags, tag);
+ g_ptr_array_add (tags, tag);
+ /* once set, always the same thanks to the if above
+ * add only if it's from the same file - this prevents mixing tags from
+ * structs with identical name (typically the anonymous ones) so we
+ * only get members from a single one. For workspace tags it adds
+ * all members because there's no file associated. */
+ last_file = tag->file;
}
}
+
+ if (tags->len == 0)
+ {
+ g_ptr_array_free(tags, TRUE);
+ return NULL;
+ }
+
+ return tags;
}
@@ -871,15 +868,7 @@ find_scope_members (const GPtrArray *tags_array, GPtrArray *member_array,
}
if (has_members)
- {
- tags = g_ptr_array_new();
- find_scope_members_tags(member_array, tags, type_name, lang);
- if (tags->len == 0)
- {
- g_ptr_array_free(tags, TRUE);
- tags = NULL;
- }
- }
+ tags = find_scope_members_tags(member_array, type_name, lang);
g_free(type_name);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sun, 10 Jan 2016 11:31:46 UTC
Commit: 140a7b6617e89dfcb31d876364d62b3902af0d3c
https://github.com/geany/geany/commit/140a7b6617e89dfcb31d876364d62b3902af0…
Log Message:
-----------
When extracting members, get them from single file only
The previous commit fixed the situation when e.g. anon_struct_0 was in the
current file by checking the current file first.
In the case the struct type definition isn't found in the current file,
at the moment we get all members from all anon_struct_0 which can be a
really long list. This list isn't very helpful to users because all the
members from all the structs are mixed. Moreover, not all possible members
are in the list because there are e.g. just members from anon_struct_0 but
not from anon_struct_1 etc. which from the point of view of this function
is a different type.
Instead, restrict the returned members to just a single file (anonymous
structs have unique name per file so it means there will be just one
from the file). Of course the picked file can be wrong and the returned
members might be from a different struct the user wanted but at least
the list will make more sense to users.
Modified Paths:
--------------
tagmanager/src/tm_workspace.c
Modified: tagmanager/src/tm_workspace.c
23 lines changed, 21 insertions(+), 2 deletions(-)
===================================================================
@@ -761,6 +761,25 @@ GPtrArray *tm_workspace_find(const char *name, const char *scope, TMTagType type
}
+static void add_member(GPtrArray * tags, TMTag *tag)
+{
+ gboolean add = TRUE;
+
+ if (tags->len > 0)
+ {
+ TMTag *last_tag = TM_TAG(tags->pdata[tags->len-1]);
+ /* add only if it's from the same file - this prevents mixing tags from
+ * structs with identical name (typically the anonymous ones) so we
+ * only get members from a single one. For workspace tags it adds
+ * all members because there's no file associated. */
+ add = last_tag->file == tag->file;
+ }
+ if (add)
+ /* the first file name "wins" */
+ g_ptr_array_add (tags, tag);
+}
+
+
static int
find_scope_members_tags (const GPtrArray * all, GPtrArray * tags,
const char *name, langType lang)
@@ -795,7 +814,7 @@ find_scope_members_tags (const GPtrArray * all, GPtrArray * tags,
scope = tag->scope;
if (scope && 0 == strcmp (name, scope))
{
- g_ptr_array_add (tags, tag);
+ add_member (tags, tag);
continue;
}
s_backup = NULL;
@@ -862,7 +881,7 @@ find_scope_members_tags (const GPtrArray * all, GPtrArray * tags,
}
if (j == local->len)
{
- g_ptr_array_add (tags, tag);
+ add_member (tags, tag);
}
}
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).