13
votes

I'm writing a PMD plug-in for Eclipse which lets users suppress PMD warnings by adding annotations like @SuppressWarnings("PMD.ReturnEmptyArrayRatherThanNull"). Since Eclipse doesn't know that PMD.ReturnEmptyArrayRatherThanNull is a valid token, it warns the token is unsupported and offers a quick fix to remove it.

How can it let Eclipse know that this is in fact a supported SuppressWarnings token and that it should not mark it with a warning?

I'm not looking for a way the user can suppress the warning. I know about the "Ignore unhandled token in SuppressWarnings" preference in Eclipse. This is a workaround and has the disadvantage that Eclipse does not report any unsupported token at all making it rather difficult to e.g. find a typo in a SuppressWarnings token.

What I'm looking for is a way I as a plug-in developer can extend Eclipse so it recognizes the PMD token as supported SuppressWarnings token.

So far I have only found that the token supported by Eclipse are hard coded into the Eclipse Java compiler but have not found an extension point or something else that lets me add the PMD token to the list of supported SuppressWarnings token.

1
Did you ever resolve this issue?matt freake
Unfortunately not. I tried a workaround where the warnings are deleted right after they are created but I never managed to get it to work correctly.eclipse-pmd
How about a feature request at eclipse.org that enables the extension of the list via plugin?kon
I would appreciate such a feature requestDanny Lo
I just wanted to create a feature request at eclipse.org. As it turns out there already is an almost 10 year old feature request: Extensionpoint for additional SuppressWarnings tokens. I added my requirements and upvoted the request. I suggest you do the same.eclipse-pmd

1 Answers

0
votes

What you could do is write a small plugin that used Equinox Weaving Service to intercept this method calls and return custom IrritantSet instances from it. That would require a bit of snooping around compiler code, but should not be too difficult.

The disadvantage is that it might break with JDT updates and will only work in Eclipse that has that plugin installed.

See this tutorial to learn how to write a plugin that uses weaving service.