Exuberant-ctags 错误地标记了 python 多行 class 定义

Exuberant-ctags incorrectly tags python multi line class definitions

当 python class 定义跨越多行时,Exuberant-ctags 生成错误的标签,只有最后一行进入搜索模式:

考虑文件 test.py:

class FirstSubclass(
    LongLineBaseClass, AnotherLongClassName,
    MoreBaseClassWithVeryLongName
):
    pass


class SecondSubclass(
    LongLineBaseClass, AnotherLongClassName,
    MoreBaseClassWithVeryLongName
):
    pass


class OneLineClass(LongLineBaseClass):
    pass

ctags test.py 的结果 tags 文件(已添加注释):

FirstSubclass   test.py /^):$/;"    c !PROBLEM
OneLineClass    test.py /^class OneLineClass(LongLineBaseClass):$/;"    c !OK
SecondSubclass  test.py /^):$/;"    c !PROBLEM

FirstSubclassSecondSubclass 都收到相同的搜索模式(ex 命令):/^):$ 即每个 class 定义最后一行的唯一两个字符。这使得在 vim 中导航的标签无法使用。

丰富的ctags版本和信息:

Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Oct  7 2014, 13:52:37
  Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
  Optional compiled features: +wildcards, +regex

我试过的方法: 我使用了带和不带 language-python kinds 参数的 ctags,没有任何参数。


有什么想法吗? 提前致谢。

Universal-ctags (https://ctags.io),Exuebrante-ctags 的一个非官方分支,可以预期地提取模式:

[yamato@slave]~% cat /tmp/foo.py 
cat /tmp/foo.py 
class FirstSubclass(
    LongLineBaseClass, AnotherLongClassName,
    MoreBaseClassWithVeryLongName
):
    pass


class SecondSubclass(
    LongLineBaseClass, AnotherLongClassName,
    MoreBaseClassWithVeryLongName
):
    pass


class OneLineClass(LongLineBaseClass):
    pass

[yamato@slave]~% u-ctags -o - /tmp/foo.py
u-ctags -o - /tmp/foo.py
FirstSubclass   /tmp/foo.py /^class FirstSubclass($/;"  c
OneLineClass    /tmp/foo.py /^class OneLineClass(LongLineBaseClass):$/;"    c
SecondSubclass  /tmp/foo.py /^class SecondSubclass($/;" c

而且它可以填充继承字段:

[yamato@slave]~% u-ctags --fields=+i -o - /tmp/foo.py
u-ctags --fields=+i -o - /tmp/foo.py
FirstSubclass   /tmp/foo.py /^class FirstSubclass($/;"  c   inherits:LongLineBaseClass, AnotherLongClassName, MoreBaseClassWithVeryLongName 
OneLineClass    /tmp/foo.py /^class OneLineClass(LongLineBaseClass):$/;"    c   inherits:LongLineBaseClass
SecondSubclass  /tmp/foo.py /^class SecondSubclass($/;" c   inherits:LongLineBaseClass, AnotherLongClassName, MoreBaseClassWithVeryLongName