Are custom QuickFixes possible?

Continuing from an old problem: I had trouble creating quickfixes from a custom sensor and then later learned that that just isn’t possible. However, this answer suggested that I look at internal SonarJava rules for hints, which brings me to my new problem.

The built-in rules use the class QuickFixHelper which is internal API and that I therefore can’t use. The same goes for the other classes I found going through how QuickFixHelper works (namely InternalJavaIssueBuilder, JavaQuickFix, and SonarComponents).

Then I saw that at the base level a SensorContext is used which is part of the plugin API and that I could therefore theoretically use. However, I couldn’t find a way to get a SensorContext object from within a JavaFileScanner.

For the above reasons I wanted to just very plainly ask: Is is actually possible to create custom QuickFixes? If yes, then how? Because up until now I have only found dead-ends.

Hi,

It was not our intent to expose quick fix creation to custom plugins. If you’re able to find a way around that, it will be very brittle.

Could you share with us what quick fixes you’d like to create? Or are they for your custom rules?

 
Ann

Hi,

I want to create quick fixes for custom rules, so if adding them through the plugin API isn’t possible I guess that won’t ever happen.

Could I suggest making a note on “no creating quick fxes for custom plugin” in the documentation (javadoc) of the NewIssue, NewQuickfix, NewTextEdit, and NewInputFileEdit classes? Because otherwise it looks like creating your own quick fixes is very much possible. Also, in the post I linked above I received answers from SonarSourcers (the tag I assume means working for SonarSource) that made it seem like I was just going about it the wrong way, so that was also very misleading.

Either way, thank you for your answer.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.