Intellij插件开发 - 如何查找和分析电话?
我正在为Intellij Ideas编写一个插件,主要目的是帮助我使用自己的API,现在我被卡住了。我的API使用以下方式:
public class SomeClass {
@Override
public void specialMethod() {
CustomCommand command = CommandManager.registerCommand(CommandClass.class, this);
command.addMapper("mapper1", ...); // it doesn't matter what is here, the string is the only important thing here
}
}
public class CommandClass extends AbstractCommandClass {
public CommandClass(SpecialClass specialClass) {
super(SpecialClass);
}
@Mapper("mapper1") // HERE
public void someMethod() {
// ...
}
}
在注释@mapper
中,我正在使用一个易于遵循的键,并希望我的插件验证是否已在specialclass
中使用此字符串 AddMapper
方法。此外,可以有多个唯一的映射器,所以我也需要建议。我知道如何创建检查,意图和提供者,这里的主要问题是:如何正确收集所有使用的字符串?
I am writing a plugin for IntelliJ IDEA that's main purpose is to help me to use my own API, and now I'm stuck. My API is used the following way:
public class SomeClass {
@Override
public void specialMethod() {
CustomCommand command = CommandManager.registerCommand(CommandClass.class, this);
command.addMapper("mapper1", ...); // it doesn't matter what is here, the string is the only important thing here
}
}
public class CommandClass extends AbstractCommandClass {
public CommandClass(SpecialClass specialClass) {
super(SpecialClass);
}
@Mapper("mapper1") // HERE
public void someMethod() {
// ...
}
}
In annotation @Mapper
I am using a stringly-typed key and would like my plugin to verify if this string has been registered in SpecialClass
using addMapper
method. Additionally, there can be multiple unique mappers, so I also want the suggestion. I know how to create inspections, intentions and providers, the main problem here is: How to correctly collect all the used strings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看基于文件的indexes 。
它以地图还原方式起作用。基本上,您指定文件对键功能,想法将为您构建密钥文件索引。如果文件更改,它将保持索引的最新状态,因此您不必担心它。甚至可以存储与密钥相关的其他数据。
然后,可以通过键查询文件,枚举索引中的所有密钥或文件,依此类推。
Take a look at File-Based Indexes.
It works on map-reduce manner. Basically you specify a file-to-keys function and IDEA will build a key-to-file index for you. It will keep the index up to date in case of file changes so you don't need to worry about it. It's even possible to store additional data related to keys.
Then it's possible to query files by key, enumerate all keys or files in the index and so on.