Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cxx parser from uctags #3032

Merged
merged 10 commits into from
Dec 19, 2021
14 changes: 13 additions & 1 deletion src/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "support.h"
#include "tm_parser.h"
#include "tm_tag.h"
#include "tm_ctags.h"
#include "ui_utils.h"
#include "utils.h"

Expand Down Expand Up @@ -116,7 +117,7 @@ symbol_menu;

static void load_user_tags(GeanyFiletypeID ft_id);

/* get the tags_ignore list, exported by tagmanager's geany.c */
/* get the tags_ignore list, exported by geany_lcpp.c */
extern gchar **c_tags_ignore;

/* ignore certain tokens when parsing C-like syntax.
Expand All @@ -128,11 +129,22 @@ static void load_c_ignore_tags(void)

if (g_file_get_contents(path, &content, NULL, NULL))
{
gchar **line;

/* historically we ignore the glib _DECLS for tag generation */
SETPTR(content, g_strconcat("G_BEGIN_DECLS G_END_DECLS\n", content, NULL));

g_strfreev(c_tags_ignore);
tm_ctags_clear_ignore_symbols();

/* for old c.c parser */
c_tags_ignore = g_strsplit_set(content, " \n\r", -1);
/* for new cxx parser */
foreach_strv(line, c_tags_ignore)
{
tm_ctags_add_ignore_symbol(*line);
}

g_free(content);
}
g_free(path);
Expand Down
22 changes: 22 additions & 0 deletions src/tagmanager/tm_ctags.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "trashbox_p.h"
#include "writer_p.h"
#include "xtag_p.h"
#include "param_p.h"

#include <string.h>

Expand Down Expand Up @@ -221,6 +222,27 @@ void tm_ctags_init(void)
}


void tm_ctags_add_ignore_symbol(const char *value)
{
langType lang = getNamedLanguage ("CPreProcessor", 0);
gchar *val = g_strdup(value);

/* make sure we don't enter empty string - passing NULL or "" clears
* the ignore list in ctags */
val = g_strstrip(val);
if (*val)
applyParameter (lang, "ignore", val);
g_free(val);
}


void tm_ctags_clear_ignore_symbols(void)
{
langType lang = getNamedLanguage ("CPreProcessor", 0);
applyParameter (lang, "ignore", NULL);
}


void tm_ctags_parse(guchar *buffer, gsize buffer_size,
const gchar *file_name, TMParserType language, TMSourceFile *source_file)
{
Expand Down
2 changes: 2 additions & 0 deletions src/tagmanager/tm_ctags.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ G_BEGIN_DECLS
#ifdef GEANY_PRIVATE

void tm_ctags_init(void);
void tm_ctags_add_ignore_symbol(const char *value);
void tm_ctags_clear_ignore_symbols(void);
void tm_ctags_parse(guchar *buffer, gsize buffer_size,
const gchar *file_name, TMParserType language, TMSourceFile *source_file);
const gchar *tm_ctags_get_lang_name(TMParserType lang);
Expand Down