简体   繁体   English

如何使用 intellij-idea 在 kotlin 中查找已弃用代码的用法

[英]How to find usage of deprecated code in kotlin with intellij-idea

I want to automatically find all occurrences in my kotlin application where i use deprecated code (mostly methods which are annotated as deprecated)我想在我的 kotlin 应用程序中自动查找我使用弃用代码的所有事件(主要是注释为弃用的方法)

I'm talking not about kotlin code which is deprecated in the kotlin spec, i mean kotlin code which calls a deprecated function/method.我说的不是在 kotlin 规范中弃用的 kotlin 代码,我的意思是调用弃用函数/方法的 kotlin 代码。

The source where the deprecated function is located could be kotlin- or java- libraries.已弃用的 function 所在的源可能是 kotlin- 或 java- 库。

I found really great tooling for finding similar issues in java code via intellij idea, like:我发现通过 intellij idea 在 java 代码中发现类似问题的工具非常棒,例如:

  • code -> inspect code代码 -> 检查代码
  • code -> analyse code -> inspection by name -> deprecated API usage代码 -> 分析代码 -> 按名称检查 -> 弃用 API 用法
  • edit -> find -> find structurally -> select template deprecated methods (only available for java) edit -> find -> find structurally -> select template deprecated methods (仅适用于java)

But i don't find a way for any similar search option for kotlin.但是我找不到任何类似的搜索选项的方法 kotlin。

I tried to build a "deprecated api usage structural search"-template myself, but base functionalities to archive this seems not be supported for kotlin.我试图自己构建一个“已弃用的 api 用法结构搜索”模板,但 kotlin 似乎不支持存档的基本功能。

The only none manual function which works is the local code analyse of the file i'm currently in (this little hind in the upper right corner where you can see number of issues (and can click on them to have them in the a list))唯一有效的无手册 function 是我当前所在文件的本地代码分析(右上角的这个小后腿,您可以在其中看到问题的数量(并且可以单击它们将它们放入列表中) )

This works but if i make a code analyse for a hole folder the deprecated usages are not there.这可行,但如果我对孔文件夹进行代码分析,则不推荐使用。

I need a solution for scanning the hole code base and not manually clicking from file to file.我需要一个扫描孔代码库而不是手动从一个文件点击到另一个文件的解决方案。

@Deprecated warning is a compiler warning, and you can not find it via IDE inspection search yet. @Deprecated warning是编译器警告,通过IDE检查搜索还没有找到。 Please follow an issue — https://youtrack.jetbrains.com/issue/KTIJ-12494/Analyze-Inspect-code-Inspection-results-show-compiler-warnings请关注一个问题 — https://youtrack.jetbrains.com/issue/KTIJ-12494/Analyze-Inspect-code-Inspection-results-show-compiler-warnings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM