History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-5530
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Maxim Shafirov
Reporter: Keith Lea
Votes: 25
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

Allow custom "suppress" actions for inspections

Created: 07 May 05 00:39   Updated: 23 Aug 06 16:59
Component/s: Code Analysis. Inspection, Plugin Support. API
Fix Version/s: Demetra 5646

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 3,316
Fixed in build: 5,629
Severity: Low


 Description  « Hide
Inspections should be able to implement some interface SuppressableInspection which has methods:

LocalQuickFix getSuppressForMethodFix(..)
LocalQuickFix getSuppressForFieldFix(..)
etc.

This would be useful when there are specific ways to specify suppression of certain warnings, other than adding comments or Javadoc comments.



 All   Comments   Work Log   Change History      Sort Order:
Maxim Shafirov - 09 May 06 21:44
Keith,
There are actually different way of implementing things like generalizing suppression stuff, which will allow meaningful suppression means for custom languages (like javascript) or in contrary the ability to hook into standard "java-level" suppression, which you're requesting AFAIK.

So, would you please describe a real use case demand you're willing to support?


Keith Lea - 10 May 06 01:04
Maybe the Language could specify a set of suppression types, and then they are overridable by the individual inspection as well.

Now I want this for my XML inspections, so I can say "suppress for this section" where section is specfic to this file type.


Sascha Weinreuter - 11 May 06 22:12
  • Suppressing inspections in XML should be available by default: IDEA-7652.
  • Linking the suppression action + suppression recognition logic to the language sounds good.
  • Having custom "Suppress for ..." QuickFixes doesn't sound good as it's too specific. An inspection should instead be able to pass arbitrary "quickfix options" to a ProblemDescriptor, possibly with some kind of anchor to specify where they should appear in the quickfix's "option menu".

Keith Lea - 12 May 06 01:17
Sascha, you're not thinking of XML "languages" implemented through XmlElementDescriptors and custom inspections. In this case the only option would be "suppress for line" and "suppress for file" probably, even if there is some structure in the file that the plugin providing the quickfix knows about, even though it's just an XML file.

Sascha Weinreuter - 12 May 06 06:23
I didn't say it shouldn't be possible for such cases, but inspections for "normal" XML would greatly benefit from a mechanism that I think IDEA should provide by default. Additionally, such a hard-coded way would possibly allow a better performance of the check whether an inspection is suppressed or not.

If your case requires additional logic, a possibility to specify certain "option" actions per ProblemDescriptor that would appear in the same menu as the "Edit Inspection Settings" and "Suppress for ..." actions could of course provide that logic. I just think that the API should not imply that these option-actions suppress anything (they could actually do anything) as you originally suggested in the request.

If, however, a solution is favored that does call these actions "suppress actions", I think the API should require the imlementor of the inspection to also provide a way to determine if the inspection is suppressed:

public class CustomSuppressableInspection extends LocaInspectionTool {
  public abstract IntentionAction[] getSuppressActions(ProblemDesciptor p);

  public abstract boolean isSuppressedFor(PsiElement element);
}

Just my 2c


Sascha Weinreuter - 12 Aug 06 17:31
This has become much more important with the new Language Injection API. In an XSLT file, I want to be able to suppress an inspection for an injected XPath fragment and the suppression has to be resonably done by an XML comment. Either I need a way to tell the inspection how/where to suppress it, or I need the ability to provide a couple of IntentionActions that appear in the QuickFix'es "option menu". I don't like the thought of having to provide these suppress-actions as additional quickfixes because that's totally against established UI conventions in IDEA.

Sascha Weinreuter - 15 Aug 06 01:32
Maxim, can we please get some feedback whether this will make it into the final 6.0 and how the solution might look like? Please excuse that even though this issue is currently in IDEADEV, the discussion here has been kind of a one-way street so far and I fear that any moment it will get the dreaded "Next Version" tag...

Thanks,
Sascha


Maxim Shafirov - 20 Aug 06 00:07
Well, I really like your CustomSuppressableInspection API and will do my best to implement this in Demetra.

Sascha Weinreuter - 21 Aug 06 00:59
Awesome. Thanks a lot for the heads up Maxim.