LocalInspectionTool showing messages as warning irrespective of ProblemHighlightType in ProblemDescriptor


I want to show warnings and errors when a user runs inspect code but it is always showing all the messages as warning irrespective of what ProblemHighlightType is given.

public class SpecInspectionProvider extends LocalInspectionTool {
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
new ProblemDescriptor[]{manager.createProblemDescriptor(e, "message", null, ProblemHighlightType.ERROR, false, false)};

Is there a way to change warnings to errors i.e Specification 8 errors?

Comment actions Permalink


inspect code shows configured by user severity. Looks like you have set WARNING by default and didn't change that in the File | Settings | Editor | Inspections.


Comment actions Permalink

Thanks for the reply Anna.

The inspection can give both errors and warnings. So I don't want to change it in settings. Can It be changed by providing different ProblemHighlightType to ProblemDescriptor.

manager.createProblemDescriptor(e, "message", null, ProblemHighlightType.ERROR, false, false)
manager.createProblemDescriptor(e, "message", null, ProblemHighlightType.WEAK_WARNING, false, false)
Comment actions Permalink

It would contradict user's settings, so it's not possible. The problem is more general: if you want your inspection to report different level of errors, you need to create 2 different inspections, no other solution is currently supported.


Please sign in to leave a comment.