ctags 没有索引 class 成员函数
ctags is not indexing class member function
我正在使用 ctags 来索引我的源代码。
为简单起见,我 assemble 一些示例代码如下。
namespace test_space
{
template<typename TYPE>
class A
{
public:
void test_func(TYPE a);
void test_func_2(TYPE a);
void test_func_3(TYPE a);
}
class B
{
public:
void test_func_b();
}
void easy_func()
{
}
}
我将其命名为a.h
文件,并使用ctags a.h
生成标签文件,但ctags仅索引命名空间,classes和函数,但不是我的class成员函数(如test_func
),为什么?如何启用它?
这是生成的标签文件内容:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.6 //
A a.h /^class A$/;" c namespace:test_space
B a.h /^class B$/;" c namespace:test_space
easy_func a.h /^void easy_func()$/;" f namespace:test_space
test_space a.h /^namespace test_space$/;" n
似乎 exuberant-ctags 默认情况下只在看到 定义 时才添加标签,而不是声明。将 class A
更改为
template<typename TYPE>
class A
{
public:
void test_func(TYPE a)
{
}
void test_func_2(TYPE a);
void test_func_3(TYPE a);
};
使 test_func
出现在 tags
文件中:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
A a.h /^class A$/;" c namespace:test_space
B a.h /^class B$/;" c namespace:test_space
easy_func a.h /^void easy_func()$/;" f namespace:test_space
test_func a.h /^ void test_func(TYPE a)$/;" f class:test_space::A
test_space a.h /^namespace test_space$/;" n
但其他功能没有出现。我自己不使用 ctags,但您通常希望能够找到定义而不是声明,这是有道理的。
如果你告诉 ctags 索引原型,你可以得到你要找的东西:
ctags --c-kinds=+p a.h
对于您的示例,这会导致
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
A a.h /^class A$/;" c namespace:test_space
B a.h /^class B$/;" c namespace:test_space
easy_func a.h /^void easy_func()$/;" f namespace:test_space
test_func a.h /^ void test_func(TYPE a);$/;" p class:test_space::A
test_func_2 a.h /^ void test_func_2(TYPE a);$/;" p class:test_space::A
test_func_3 a.h /^ void test_func_3(TYPE a);$/;" p class:test_space::A
test_func_b a.h /^ void test_func_b();$/;" p class:test_space::B
test_space a.h /^namespace test_space$/;" n
您可以获得有关哪些事物被标记为这样的更多详细信息:
$ ctags --list-kinds=c
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
l local variables [off]
m class, struct, and union members
n namespaces
p function prototypes [off]
s structure names
t typedefs
u union names
v variable definitions
x external and forward variable declarations [off]
您可以看到默认情况下,函数原型没有标记。
我正在使用 ctags 来索引我的源代码。 为简单起见,我 assemble 一些示例代码如下。
namespace test_space
{
template<typename TYPE>
class A
{
public:
void test_func(TYPE a);
void test_func_2(TYPE a);
void test_func_3(TYPE a);
}
class B
{
public:
void test_func_b();
}
void easy_func()
{
}
}
我将其命名为a.h
文件,并使用ctags a.h
生成标签文件,但ctags仅索引命名空间,classes和函数,但不是我的class成员函数(如test_func
),为什么?如何启用它?
这是生成的标签文件内容:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.6 //
A a.h /^class A$/;" c namespace:test_space
B a.h /^class B$/;" c namespace:test_space
easy_func a.h /^void easy_func()$/;" f namespace:test_space
test_space a.h /^namespace test_space$/;" n
似乎 exuberant-ctags 默认情况下只在看到 定义 时才添加标签,而不是声明。将 class A
更改为
template<typename TYPE>
class A
{
public:
void test_func(TYPE a)
{
}
void test_func_2(TYPE a);
void test_func_3(TYPE a);
};
使 test_func
出现在 tags
文件中:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
A a.h /^class A$/;" c namespace:test_space
B a.h /^class B$/;" c namespace:test_space
easy_func a.h /^void easy_func()$/;" f namespace:test_space
test_func a.h /^ void test_func(TYPE a)$/;" f class:test_space::A
test_space a.h /^namespace test_space$/;" n
但其他功能没有出现。我自己不使用 ctags,但您通常希望能够找到定义而不是声明,这是有道理的。
如果你告诉 ctags 索引原型,你可以得到你要找的东西:
ctags --c-kinds=+p a.h
对于您的示例,这会导致
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
A a.h /^class A$/;" c namespace:test_space
B a.h /^class B$/;" c namespace:test_space
easy_func a.h /^void easy_func()$/;" f namespace:test_space
test_func a.h /^ void test_func(TYPE a);$/;" p class:test_space::A
test_func_2 a.h /^ void test_func_2(TYPE a);$/;" p class:test_space::A
test_func_3 a.h /^ void test_func_3(TYPE a);$/;" p class:test_space::A
test_func_b a.h /^ void test_func_b();$/;" p class:test_space::B
test_space a.h /^namespace test_space$/;" n
您可以获得有关哪些事物被标记为这样的更多详细信息:
$ ctags --list-kinds=c
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
l local variables [off]
m class, struct, and union members
n namespaces
p function prototypes [off]
s structure names
t typedefs
u union names
v variable definitions
x external and forward variable declarations [off]
您可以看到默认情况下,函数原型没有标记。