Generic inspection tool
Hello,
I am developing a plugin that does a generic inspection of the code and is not specific to a language. I read https://plugins.jetbrains.com/docs/intellij/code-inspections.html#running-the-comparing-references-inspection-code-sample and it seems this is very specific to a language.
What I want to accomplish is to do the following actions each time a file is open or modified
1. Run an analysis tool
2. Report the potential issues
The tool that I run identifies issues with the file name and line number. I did not see a way to annotate only the line for a file. I tried to look into the classes PsiFile and PsiPlainText file but it seems a bad idea.
Can you tell me what would be the best approach to proceed? Is the inspection the right approach? Is there any code sample and/or doc to look at?
Thanks.
请先登录再写评论。
What does "Run an analysis tool" really mean? Is it part of your plugin's code or some external tool? Then "External Tool" is possible option https://plugins.jetbrains.com/docs/intellij/syntax-highlighting-and-error-highlighting.html. Annotator can be used also for "generic" highlighting.
Thanks for your message. This is an external tool. I will check out the Annotator approach. Is there any existing plugin or code samples I could use for reference?
Hi Yann,
Thanks for replying. The externalAnnotator is what I need indeed. However, it seems that I need to specify a language. Is there a way to make the externalAnnotator work for all languages so that I do not have to specify a language as shown below?
Thanks!
Yes, it seems currently specifying language attribute is required. Investigating...
Sample usages: https://plugins.jetbrains.com/intellij-platform-explorer/?extensions=com.intellij.externalAnnotator
Another way is to define your own com.intellij.lang.MetaLanguage that references all languages that you want your extension(s) to work for.
That would do it indeed. Is there any example that shows how to do that?
Thank you.
Unfortunately I found only one open source plugin using MetaLanguage https://plugins.jetbrains.com/plugin/13308-indent-rainbow
IJ Community comes also with com.intellij.lang.jvm.JvmMetaLanguage and com.intellij.uast.UastMetaLanguage as reference
Thank you again for your help!