ctags не индексирует функцию-член класса

Я использую ctags для индексации моего исходного кода.
Для простоты я собираю несколько примеров кодов, как показано ниже.

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 только индексированные пространство имен, классы и функции, но не мои функции-члены класса (как 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

2

Решение

Кажется, что exuberant-ctags по умолчанию добавляет теги только тогда, когда видит определение, не декларация. Смена класса 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]

Вы можете видеть, что прототипы функций по умолчанию не помечены.

2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector