如何以编程方式执行Java IDE为方法引用执行的搜索?

编程入门 行业动态 更新时间:2024-10-27 10:20:19
本文介绍了如何以编程方式执行Java IDE为方法引用执行的搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您知道eclipse的所有引用功能(搜索>参考>工作区或Ctrl-Shift-G)吗?我如何以编程方式运行?

You know the find all references feature of eclipse (Search > References > Workspace or Ctrl-Shift-G)? How can I run that programmatically?

我有一个大型代码库,我需要审计安全违规并需要链接大约十几个条件。

I have a large codebase that I need to audit for security violations and need to chain about a dozen conditions.

那里有库可以用Java分析大型项目(我有1GB的源文件)吗?以下是我需要回答的问题:

Are there libraries out there that can analyze large projects (I have 1GB of source files) in Java? Here's the questions I need to answer:

  • 传入接口列表,查找这些接口的所有实现
  • 搜索该列表以获取我们安全库的调用
  • 搜索上面列表中引用的每个方法,以确认已进行了正确的授权库调用。

我可以在一天内手动执行此操作,但宁可花2写一个漂亮的脚本来为我完成工作。

I can do this manually in a day, but would rather spend 2 writing a nice script to do the work for me.

我可以使用哪些线索来编写Eclipse这些常见任务的脚本?理想情况下,我想执行命令行,因此它们可以重复和编写脚本,但显然会采取我能得到的。

Any leads on libraries I can use to script these common tasks that Eclipse does so nicely? Ideally, I would like to perform them command-line, so they can be repeatable and scripted, but obviously will take what I can get.

推荐答案

您可以在IntelliJ IDEA中编写自己的插件来实现此目的。

You could write your own plugin in IntelliJ IDEA to accomplish this.

以编程方式,您可以使用 PSI (程序结构界面)树来搜索各种代码元素(类,变量,方法,语句等),浏览代码库然后执行任何操作你需要做。

Programmatically, you can utilize the PSI (program structure interface) tree to search for various code elements (classes, variables, methods, statements, etc), navigate around your code base and then do whatever you need to do.

以下是一些参考资料:

  • IntelliJ IDEA插件开发

    PSI Cookbook

    PsiViewer插件

    您可以做的所有事情(查找实现,搜索调用,特定语句的搜索方法)。

    All of the things that you need to do (find implementations, search for invocations, search methods for a particular statement) are possible.

    如果您下载了IntelliJ IDEA社区版的源代码,您可以查看代码并查看这些内容是如何完成的。

    If you download the source code for the community edition of IntelliJ IDEA you can look around in the code and see how these things are done.

    或者您可以在此处发布特定问题(使用 intellij-plugin 标记),像CrazyCoder这样的人可能非常友好地帮助您:)

    Or you can post specific questions here (tag with intellij-plugin) and people like CrazyCoder might be kind enough to help you out :)

    关于代码库的范围(你说1 GB?),你只需要尝试一下,看看你如何去。最糟糕的情况是,您可以分析部分代码库。

    With regards to the scope of the code base (1 GB you say?), you'd just have to try it and see how you go. Worst case, you could analyze your code base in parts.

    无论如何,插件开发 非常 强大在IntelliJ IDEA中,我推荐这种方法用于您想要自己编程控制的任何类型的Java代码分析或重构(并且尚未被开箱即用的重构所涵盖)。

    In any case, plugin development is extremely powerful in IntelliJ IDEA and I recommend this approach for any sort of java code analysis or refactorings that you want to control programmatically yourself (and aren't already covered by the out-of-the-box refactorings).

    祝你好运!

  • 更多推荐

    如何以编程方式执行Java IDE为方法引用执行的搜索?

    本文发布于:2023-07-27 05:24:31,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1220594.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:方式   方法   Java   IDE

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!