How can i get a java file some problem or suggest , such as un used variable , un used import?
Answered
I want get all the inspect result for the java file , such as unused import , unused variable , unused method , lambda suggest。
all of the code inspect!
I'm develop a plugin for code inspect prompt with dialog ! So i need to get the java file code inspect problem of inspect , is seems "com.intellij.codeInspection.ProblemDescriptor"
Please sign in to leave a comment.
I want get all the inspect result for the java file , such as unused import , unused variable , unused method , lambda suggest。
all of the code inspect!
Did I describe it wrong?
Please explain your use case, do you want to obtain results for file of current editor, any file, or group of files like in "Analyze->Inspect"?
@Yann Cebron
I want to develop a plug-in that takes all the unused variables that are checked out of a class. This includes, but is not limited to, code that may be null, and so on。
I used "UnusedDeclarationInspection" , but it can not
could you help me?
See com.intellij.codeInspection.actions.CodeInspectionAction#runInspections as inspiration
@Yann Cebron
Thank you for you anwser! But how can i get the inspect result as com.intellij.codeInspection.ProblemDescriptor
And if only want to inspect one file , What should i do ?
The requirement is that I want to check the committed code specification when committing code to git
How is that different from builtin functionality to run "Perform Code Analysis" in Commit dialog? https://www.jetbrains.com/help/idea/commit-changes-dialog.html#before_commit
@Yann Cebron
Thank for you anwser !
The purpose is different. If someone submits the problem code, it will affect his performance. I need to count it for company
Use com.intellij.openapi.vcs.checkin.CheckinHandler to extend Commit behavior. Actual collection of highlighting warnings/errors is done from com.intellij.openapi.vcs.checkin.CodeAnalysisBeforeCheckinHandler via com.intellij.openapi.vcs.CodeSmellDetector
Thank you !
But now I can get some highlight code, but some still can't get it, such as unused import , unused variable , It is not a highlighting code
Please double check the inspections are switched on for corresponding file(s) and have at least WARNING level