Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Mon, 15 May 2023 21:09:21 UTC Commit: db5d7e5cac00de7f9e2aee48b05bde5397370dd2 https://github.com/geany/geany/commit/db5d7e5cac00de7f9e2aee48b05bde5397370d...
Log Message: ----------- Add a flag indicating whether to trust isFileScope from ctags
ctags treats unknown C/C++ file extensions as if they were source files. Because of this, the isFileScope flag is incorrectly set to TRUE for such files even if they are headers and the defined tags don't have a file-only scope.
To fix this, we intorduce a flag called trust_file_scope which we set to TRUE only when the source file name matches one of the known C/C++ extensions.
For all other languages the flag is set to TRUE.
Modified Paths: -------------- src/tagmanager/tm_source_file.c src/tagmanager/tm_source_file.h
Modified: src/tagmanager/tm_source_file.c 19 lines changed, 19 insertions(+), 0 deletions(-) =================================================================== @@ -609,6 +609,25 @@ static gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_ else source_file->lang = tm_ctags_get_named_lang(name);
+ source_file->trust_file_scope = TRUE; + + if (source_file->lang == TM_PARSER_C || source_file->lang == TM_PARSER_CPP) + { + const gchar **ext; + const gchar *common_src_exts[] = + {".c", ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", ".CPP", ".CXX", NULL}; + + source_file->trust_file_scope = FALSE; + for (ext = common_src_exts; *ext; ext++) + { + if (g_str_has_suffix(source_file->short_name, *ext)) + { + source_file->trust_file_scope = TRUE; + break; + } + } + } + return TRUE; }
Modified: src/tagmanager/tm_source_file.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -35,6 +35,7 @@ typedef struct TMSourceFile char *file_name; /**< Full file name (inc. path) */ char *short_name; /**< Just the name of the file (without the path) */ GPtrArray *tags_array; /**< Sorted tag array obtained by parsing the object. @elementtype{TMTag} */ + gboolean trust_file_scope; } TMSourceFile;
GType tm_source_file_get_type(void);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).