Is it possible to expand the search for unused methods to non-Java-files?
Answered
Hi
we use a self-written template mechanism for generating HTML pages. In the templates method names are used (without get prefix) to get the data displayed.
IntelliJ shows this methods as "not used". Is it possible to plugin additional search filter (or something similar) to find these methods or must we write a complete plugin to do this?
Regards
Andreas
Please sign in to leave a comment.
What is the template file type? If these template files are not specifically supported by IDE you will need to write special plugin to support this. If template is for example an html file - you can try to investigate approach of using Structural Search and Replace to find such calls using scripted template constraints.
Hi Andrey
the template language is completely proprietary. For example, the following includes some HTML code
if getProvider() on a data object returns true
%%IFTRUE provider
...some HTML ...
%%ENDIFTRUE
Since getProvider() is only used in the HTML template, it is shown as unused by IntelliJ.
We certainly have to write some code to scan for this.
The question is whether there is some extension API in the normal inspection which detects unused methods,
so that we can extend the analysis to these template files.
Regards
Andreas
Hello Andreas Winter,
Unfortunately there is no ready mechanism in IntelliJ to support the custom usage templates. Probably the following "extension points" may be useful for your implementation (https://github.com/JetBrains/intellij-community):
com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil#isMethodReferenced
com.intellij.codeInsight.daemon.ImplicitUsageProvider
Hi, Olga
thanks for the hints.
com.intellij.codeInsight.daemon.ImplicitUsageProvider looks promising. I will further dive into the code.
Regards
Andreas