使用universal-ctags,如何标记引用整个文件的变量?

时间:2018-02-04 22:06:51

标签: ctags

使用Universal Ctags,我试图标记Ember.js组件,使其名称链接回组件定义的位置。

问题是Ember使用组件的文件名作为"定义"。

例如,在template.hbs

{{#example-component}}
  Some text
{{/example-component}}

此组件example-component将在路径中定义:

/app/components/example-component.js

不幸的是,这是唯一定义变量名example-component的地方。它没有直接在其他地方的代码中定义。

Ctags似乎很好地处理传统的变量声明,就像在let example-component = {...}中一样。但我不知道如何告诉ctags Ember组件是由文件名定义的,而不是直接在代码中定义。

有没有办法编写查看变量文件名的ctags定义?

1 个答案:

答案 0 :(得分:0)

我制作了一个原型,用于在https://github.com/universal-ctags/ctags/issues/1680中通过文件名定义标签。你可以告诉我你的要求。要实现所需的功能,必须指定模式。 ctags中的解析器使用模式来检测输入js文件是否为Ember.js组件。