How to add a user-overridable ProblemHighlightType for an inspection descriptor which is error by default?
**What steps will reproduce the issue?**
1. Write an inspection in a plugin
2. Use `ProblemHighlightType.GENERIC_ERROR` for the descriptor
3. When user uses the plugin, he changes the inspection severity level to e.g. warning
**What is the expected result?**
Inspection severity level is changed to warning
**What happens instead?**
Inspection severity level is not changed.
**Details**
For warnings, there is the `GENERIC_ERROR_OR_WARNING` type, which is by default a warning.
When the user changes the severity level, then it works.
However, this is not the case for `GENERIC_ERROR`, of which the Javadoc says
> The same as GENERIC_ERROR_OR_WARNING with enforced com.intellij.codeHighlighting.HighlightDisplayLevel.ERROR severity level.
which does not appear to be true: since the severity level is enforced just like `ERROR`, this is not at all like `GENERIC_ERROR_OR_WARNING`.
Something similar would be desired for the `WEAK_WARNING` type, so it becomes overridable, but the javadoc of ProblemHighlightType says (as recently added by @yannc76)
> Please use GENERIC_ERROR_OR_WARNING if you are not sure which one to pick, otherwise user's settings would be ignored.
but we're pretty sure which one to pick as default, it's just that users should be able to override them. This also suggests that there is no other way to get this behaviour.
I could not find further information in https://plugins.jetbrains.com/docs/intellij/code-inspections-and-intentions.html
See [ProblemHighlightType source](https://upsource.jetbrains.com/idea-ce/file/idea-ce-c0afaa74dcba11b82c5321aef902bde500f01e1d/platform/analysis-api/src/com/intellij/codeInspection/ProblemHighlightType.java)
I also checked the mentioned `ProblemDescriptorUtil#getHightlightInfoType()`, but I don't see how it would help setting a suggested default.
Please sign in to leave a comment.
Solution: set inspection level in plugin.xml, e.g. <localInspection implementationClass="myclass" level="WARNING" /> and always use GENERIC_ERROR_OR_WARNING in source code.
Other options are e.g. "WEAK WARNING" and "ERROR"