Use the langs_compatible() function when passing typenames to scintilla
This requires making the function public and tm_tag.c seems to be a better place for the function than tm_workspace so move there and add the prefix.
This commit is contained in:
parent
5030f7f3da
commit
cb307e5b92
@ -293,11 +293,7 @@ GString *symbols_find_typenames_as_string(gint lang, gboolean global)
|
|||||||
tag = TM_TAG(typedefs->pdata[j]);
|
tag = TM_TAG(typedefs->pdata[j]);
|
||||||
tag_lang = tag->lang;
|
tag_lang = tag->lang;
|
||||||
|
|
||||||
/* the check for tag_lang == lang is necessary to avoid wrong type colouring of
|
if (tag->name && tm_tag_langs_compatible(lang, tag_lang))
|
||||||
* e.g. PHP classes in C++ files
|
|
||||||
* lang = TM_PARSER_NONE disables the check */
|
|
||||||
if (tag->name && (tag_lang == lang || lang == TM_PARSER_NONE ||
|
|
||||||
(lang == TM_PARSER_CPP && tag_lang == TM_PARSER_C)))
|
|
||||||
{
|
{
|
||||||
if (j != 0)
|
if (j != 0)
|
||||||
g_string_append_c(s, ' ');
|
g_string_append_c(s, ' ');
|
||||||
|
@ -1226,6 +1226,22 @@ gboolean tm_tag_is_anon(const TMTag *tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean tm_tag_langs_compatible(langType lang, langType other)
|
||||||
|
{
|
||||||
|
if (lang == TM_PARSER_NONE || other == TM_PARSER_NONE)
|
||||||
|
return FALSE;
|
||||||
|
if (lang == other)
|
||||||
|
return TRUE;
|
||||||
|
/* Accept CPP tags for C lang and vice versa */
|
||||||
|
else if (lang == TM_PARSER_C && other == TM_PARSER_CPP)
|
||||||
|
return TRUE;
|
||||||
|
else if (lang == TM_PARSER_CPP && other == TM_PARSER_C)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TM_DEBUG /* various debugging functions */
|
#ifdef TM_DEBUG /* various debugging functions */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -195,6 +195,8 @@ const gchar *tm_tag_context_separator(langType lang);
|
|||||||
|
|
||||||
gboolean tm_tag_is_anon(const TMTag *tag);
|
gboolean tm_tag_is_anon(const TMTag *tag);
|
||||||
|
|
||||||
|
gboolean tm_tag_langs_compatible(langType lang, langType other);
|
||||||
|
|
||||||
#ifdef TM_DEBUG /* various debugging functions */
|
#ifdef TM_DEBUG /* various debugging functions */
|
||||||
|
|
||||||
const char *tm_tag_type_name(const TMTag *tag);
|
const char *tm_tag_type_name(const TMTag *tag);
|
||||||
|
@ -685,22 +685,6 @@ gboolean tm_workspace_create_global_tags(const char *pre_process, const char **i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean langs_compatible(langType lang, langType other)
|
|
||||||
{
|
|
||||||
if (lang == TM_PARSER_NONE || other == TM_PARSER_NONE)
|
|
||||||
return FALSE;
|
|
||||||
if (lang == other)
|
|
||||||
return TRUE;
|
|
||||||
/* Accept CPP tags for C lang and vice versa */
|
|
||||||
else if (lang == TM_PARSER_C && other == TM_PARSER_CPP)
|
|
||||||
return TRUE;
|
|
||||||
else if (lang == TM_PARSER_CPP && other == TM_PARSER_C)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void fill_find_tags_array(GPtrArray *dst, const GPtrArray *src,
|
static void fill_find_tags_array(GPtrArray *dst, const GPtrArray *src,
|
||||||
const char *name, const char *scope, TMTagType type, langType lang)
|
const char *name, const char *scope, TMTagType type, langType lang)
|
||||||
{
|
{
|
||||||
@ -714,7 +698,7 @@ static void fill_find_tags_array(GPtrArray *dst, const GPtrArray *src,
|
|||||||
for (i = 0; i < num; ++i)
|
for (i = 0; i < num; ++i)
|
||||||
{
|
{
|
||||||
if ((type & (*tag)->type) &&
|
if ((type & (*tag)->type) &&
|
||||||
langs_compatible(lang, (*tag)->lang) &&
|
tm_tag_langs_compatible(lang, (*tag)->lang) &&
|
||||||
(!scope || g_strcmp0((*tag)->scope, scope) == 0))
|
(!scope || g_strcmp0((*tag)->scope, scope) == 0))
|
||||||
{
|
{
|
||||||
g_ptr_array_add(dst, *tag);
|
g_ptr_array_add(dst, *tag);
|
||||||
@ -761,7 +745,7 @@ static void fill_find_tags_array_prefix(GPtrArray *dst, const GPtrArray *src,
|
|||||||
tag = tm_tags_find(src, name, TRUE, &count);
|
tag = tm_tags_find(src, name, TRUE, &count);
|
||||||
for (i = 0; i < count && num < max_num; ++i)
|
for (i = 0; i < count && num < max_num; ++i)
|
||||||
{
|
{
|
||||||
if (langs_compatible(lang, (*tag)->lang) &&
|
if (tm_tag_langs_compatible(lang, (*tag)->lang) &&
|
||||||
!tm_tag_is_anon(*tag) &&
|
!tm_tag_is_anon(*tag) &&
|
||||||
(!last || g_strcmp0(last->name, (*tag)->name) != 0))
|
(!last || g_strcmp0(last->name, (*tag)->name) != 0))
|
||||||
{
|
{
|
||||||
@ -827,7 +811,7 @@ find_scope_members_tags (const GPtrArray *all, TMTag *type_tag, gboolean namespa
|
|||||||
|
|
||||||
if (tag && (tag->type & member_types) &&
|
if (tag && (tag->type & member_types) &&
|
||||||
tag->scope && tag->scope[0] != '\0' &&
|
tag->scope && tag->scope[0] != '\0' &&
|
||||||
langs_compatible(tag->lang, type_tag->lang) &&
|
tm_tag_langs_compatible(tag->lang, type_tag->lang) &&
|
||||||
strcmp(scope, tag->scope) == 0 &&
|
strcmp(scope, tag->scope) == 0 &&
|
||||||
(!namespace || !tm_tag_is_anon(tag)))
|
(!namespace || !tm_tag_is_anon(tag)))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user