Order of LocalQuickFixes appearing in QuickFix menu

Hi,

I am creating a ProblemDescriptor using com.intellij.codeInspection.InspectionManager#createProblemDescriptor(PsiElement psiElement, java.lang.String descriptionTemplate, LocalQuickFix[] fixes, ProblemHighlightType highlightType) method. In IDEA 6.x I sorted array of fixes in the order I need and they appeared in this order in context menu. However in IDEA 7.0.2 they seem to be always sorted alphabetically by name. This happens even my implementation of LocalQuickFix implements Comparable]]>.

This is an annoyance for me because the order I use is based on similarity between the erroneous string and proposed. For instance if misspelled property is "hopital" and class has properties named "address", "dob", "hospital", "name", "speciality" then "hospital" is a top choice for me but in alphabetical order it appears only the third.

Anybody knows how I can make fixes appear in a defined order?

Thanks,

Misha

2 comments
Comment actions Permalink

Hello Misha,

I am creating a ProblemDescriptor using
com.intellij.codeInspection.InspectionManager#createProblemDescriptor(
PsiElement psiElement, java.lang.String descriptionTemplate,
LocalQuickFix[] fixes, ProblemHighlightType highlightType) method. In
IDEA 6.x I sorted array of fixes in the order I need and they appeared
in this order in context menu. However in IDEA 7.0.2 they seem to be
always sorted alphabetically by name. This happens even my
implementation of LocalQuickFix implements Comparable<LocalQuickFix>.

This is an annoyance for me because the order I use is based on
similarity between the erroneous string and proposed. For instance if
misspelled property is "hopital" and class has properties named
"address", "dob", "hospital", "name", "speciality" then "hospital" is
a top choice for me but in alphabetical order it appears only the
third.

Anybody knows how I can make fixes appear in a defined order?


No, there is currently no way to do so. In IDEA 7, different inspections
run in multiple threads in parallel, and contribute their quickfixes for
a particular problem in a random order, so the only way to make the order
predictable for the user is to apply alphabetical sorting.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Oh well. Seems like a regression to me. The workaround I will try will be adding a number to the name of the fix, but I think you should really use a Comparator and allow plugin developer to set his own.

Misha

0

Please sign in to leave a comment.