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"

 

 

0
13 comments

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?

0

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"?

0

@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

0

could you help me?

0

See com.intellij.codeInspection.actions.CodeInspectionAction#runInspections as inspiration

1

@Yann Cebron

 

Thank you for you anwser! But how can i get the inspect result as          com.intellij.codeInspection.ProblemDescriptor

0

And if only want to inspect one file , What should i do ?

0

The requirement is that I want to check the committed code specification when committing code to git

0

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

0

@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

0

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

0

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

0

Please double check the inspections are switched on for corresponding file(s) and have at least WARNING level

0

Please sign in to leave a comment.