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.

 

0

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.

0

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?

 

0

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?

<externalAnnotator
language="JAVA"
implementationClass="my.class"/>

 

Thanks!

0

Yes, it seems currently specifying language attribute is required. Investigating...

Sample usages: https://plugins.jetbrains.com/intellij-platform-explorer/?extensions=com.intellij.externalAnnotator

 

 

0

Another way is to define your own com.intellij.lang.MetaLanguage that references all languages that you want your extension(s) to work for.

0

That would do it indeed. Is there any example that shows how to do that?

 

Thank you.

0

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

0

Thank you again for your help!

0

请先登录再写评论。