Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Mon, 21 Mar 2016 17:28:36 UTC Commit: f61a64be29cbba0162f92eb5c1fe4aa2af33fd33 https://github.com/geany/geany/commit/f61a64be29cbba0162f92eb5c1fe4aa2af33fd...
Log Message: ----------- Remove the TagEntrySetArglistFunction hook
The direct python parser -> tagmanager callback is rather hacky and unnecessary as we can do the same in the normal ctags callback upon receiving a tag.
Modified Paths: -------------- tagmanager/ctags/entry.c tagmanager/ctags/entry.h tagmanager/ctags/parse.c tagmanager/ctags/parse.h tagmanager/ctags/python.c tagmanager/src/tm_source_file.c
Modified: tagmanager/ctags/entry.c 6 lines changed, 0 insertions(+), 6 deletions(-) =================================================================== @@ -400,12 +400,6 @@ extern void makeTagEntry (const tagEntryInfo *const tag) } }
-extern void setTagArglistByName (const char *tag_name, const char *arglist) -{ - if (NULL != TagEntrySetArglistFunction) - TagEntrySetArglistFunction(tag_name, arglist); -} - extern void initTagEntry (tagEntryInfo *const e, const char *const name) { Assert (File.source.name != NULL);
Modified: tagmanager/ctags/entry.h 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -95,7 +95,6 @@ extern void closeTagFile (const boolean resize); extern void beginEtagsFile (void); extern void endEtagsFile (const char *const name); extern void makeTagEntry (const tagEntryInfo *const tag); -extern void setTagArglistByName (const char *tag_name, const char *arglist); extern void initTagEntry (tagEntryInfo *const e, const char *const name);
#endif /* _ENTRY_H */
Modified: tagmanager/ctags/parse.c 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -33,7 +33,6 @@ static parserDefinitionFunc* BuiltInParsers[] = { PARSER_LIST }; parserDefinition** LanguageTable = NULL; static unsigned int LanguageCount = 0; tagEntryFunction TagEntryFunction = NULL; -tagEntrySetArglistFunction TagEntrySetArglistFunction = NULL;
/* * FUNCTION DEFINITIONS
Modified: tagmanager/ctags/parse.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -37,7 +37,6 @@ typedef void (*simpleParser) (void); typedef boolean (*rescanParser) (const unsigned int passCount); typedef void (*parserInitialize) (langType language); typedef int (*tagEntryFunction) (const tagEntryInfo *const tag); -typedef void (*tagEntrySetArglistFunction) (const char *tag_name, const char *arglist);
typedef struct sKindOption { boolean enabled; /* are tags for kind enabled? */ @@ -129,7 +128,6 @@ extern void checkRegex (void);
/* Extra stuff for Tag Manager */ extern tagEntryFunction TagEntryFunction; -extern tagEntrySetArglistFunction TagEntrySetArglistFunction; extern void setTagEntryFunction(tagEntryFunction entry_function);
#endif /* _PARSE_H */
Modified: tagmanager/ctags/python.c 30 lines changed, 0 insertions(+), 30 deletions(-) =================================================================== @@ -63,29 +63,6 @@ static boolean isIdentifierCharacter (int c) return (boolean) (isalnum (c) || c == '_'); }
-static const char *get_class_name_from_parent (const char *parent) -{ - const char *result; - - if (parent == NULL) - return NULL; - - result = strrchr (parent, '.'); - if (result != NULL) - { - result++; - parent = result; - } - - result = strrchr (parent, '/'); - if (result != NULL) - result++; - else - result = parent; - - return result; -} - /* follows PEP-8, and always reports single-underscores as protected * See: * - http://www.python.org/dev/peps/pep-0008/#method-names-and-instance-variables @@ -140,13 +117,6 @@ static void makeFunctionTag (vString *const function, tag.kindName = PythonKinds[K_FUNCTION].name; tag.kind = PythonKinds[K_FUNCTION].letter; tag.extensionFields.arglist = arglist; - /* add argument list of __init__() methods to the class tag */ - if (strcmp (vStringValue (function), "__init__") == 0 && parent != NULL) - { - const char *parent_tag_name = get_class_name_from_parent (vStringValue (parent)); - if (parent_tag_name != NULL) - setTagArglistByName (parent_tag_name, arglist); - }
if (vStringLength (parent) > 0) {
Modified: tagmanager/src/tm_source_file.c 68 lines changed, 35 insertions(+), 33 deletions(-) =================================================================== @@ -109,6 +109,35 @@ gchar *tm_get_real_path(const gchar *file_name) return NULL; }
+/* add argument list of __init__() Python methods to the class tag */ +static void update_python_arglist(const TMTag *tag) +{ + guint i; + const char *parent_tag_name; + + if (tag->type != tm_tag_method_t || tag->scope == NULL || + g_strcmp0(tag->name, "__init__") != 0) + return; + + parent_tag_name = strrchr(tag->scope, '.'); + if (parent_tag_name) + parent_tag_name++; + else + parent_tag_name = tag->scope; + + /* going in reverse order because the tag was added recently */ + for (i = current_source_file->tags_array->len; i > 0; i--) + { + TMTag *prev_tag = (TMTag *) current_source_file->tags_array->pdata[i - 1]; + if (g_strcmp0(prev_tag->name, parent_tag_name) == 0) + { + g_free(prev_tag->arglist); + prev_tag->arglist = g_strdup(tag->arglist); + break; + } + } +} + /* This function is registered into the ctags parser when a file is parsed for the first time. The function is then called by the ctags parser each time @@ -119,34 +148,15 @@ static int tm_source_file_tags(const tagEntryInfo *tag) { if (NULL == current_source_file) return 0; - g_ptr_array_add(current_source_file->tags_array, - tm_tag_new(current_source_file, tag)); - return TRUE; -}
-/* Set the argument list of tag identified by its name */ -static void tm_source_file_set_tag_arglist(const char *tag_name, const char *arglist) -{ - guint i; + TMTag *tm_tag = tm_tag_new(current_source_file, tag);
- if (NULL == arglist || - NULL == tag_name || - NULL == current_source_file) - { - return; - } + if (tm_tag->lang == TM_PARSER_PYTHON) + update_python_arglist(tm_tag);
- /* going in reverse order because the tag was added recently */ - for (i = current_source_file->tags_array->len; i > 0; i--) - { - TMTag *tag = (TMTag *) current_source_file->tags_array->pdata[i - 1]; - if (g_strcmp0(tag->name, tag_name) == 0) - { - g_free(tag->arglist); - tag->arglist = g_strdup(arglist); - break; - } - } + g_ptr_array_add(current_source_file->tags_array, tm_tag); + + return TRUE; }
/* Initializes a TMSourceFile structure from a file name. */ @@ -189,8 +199,6 @@ static gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_ installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; - if (NULL == TagEntrySetArglistFunction) - TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; }
if (name == NULL) @@ -339,8 +347,6 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gsize installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; - if (NULL == TagEntrySetArglistFunction) - TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } current_source_file = source_file; if (! LanguageTable [source_file->lang]->enabled) @@ -407,8 +413,6 @@ const gchar *tm_source_file_get_lang_name(TMParserType lang) installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; - if (NULL == TagEntrySetArglistFunction) - TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } return getLanguageName(lang); } @@ -425,8 +429,6 @@ TMParserType tm_source_file_get_named_lang(const gchar *name) installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; - if (NULL == TagEntrySetArglistFunction) - TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } return getNamedLanguage(name); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).