pse*_*udo 10 c ctags exuberant-ctags uncrustify
有没有办法让ctags在C中处理多行函数原型?
我已经四处寻找并且--fields=+S应该做多线原型,但我不能让它工作:
ctags -x --c-kinds=pf --fields=+S file
Run Code Online (Sandbox Code Playgroud)
文件:
int
foo(int
x, int y
);
Run Code Online (Sandbox Code Playgroud)
ctags只返回:
foo(int
Run Code Online (Sandbox Code Playgroud)
(注意,返回类型也缺失)
最终我想获得类似的输出
int foo(int x, int y);
Run Code Online (Sandbox Code Playgroud)
要么
int foo(int x, int y
Run Code Online (Sandbox Code Playgroud)
是--fields=+S不是正确的方法?我缺少哪些ctags字段?一般的指针?
如果没有办法在ctags中做任何推荐的程序?(我目前正在寻找unrustify)
我无法找到任何与 ctags 相关的内容,因此我编写了一个 python 脚本来重新排列我的文件,以便 ctags 可以捕获原型。
注意:我的代码有注释,所以要注意删除它们(否则它们会妨碍 ctags)。
操作按以下顺序完成:
# concat to one line
file_str = ''
for line in read_from.readlines():
file_str += line
# remove all /* */ comments
file_str = re.sub('/\*(.|[\r\n])*?\*/', '', file_str)
# remove '//' comments
file_str = re.sub('//.*', '', file_str)
# split on '\n'
file_as_list = file_str.splitlines(True)
# strip everything
for index in range(len(file_as_list)):
file_as_list[index] = file_as_list[index].strip()
# add in newlines where appropriate
for line in file_as_list:
# if the line ends in ';' or '}'
if line.endswith(';') or line.endswith('}'):
# append a newline to the stripped line
write_to.write(line.strip() + '\n')
else:
# append a space to the stripped line
write_to.write(line.strip() + ' ')
Run Code Online (Sandbox Code Playgroud)