Intellij插件开发 - 如何查找和分析电话?

发布于 2025-02-07 07:14:50 字数 927 浏览 1 评论 0原文

我正在为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水般的淡然安静女子 2025-02-14 07:14:50

看看基于文件的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文