Project: JDT
Bug 27935 [Markers] MarkerHelpRegistry.hasResolutions is a performance problem
Reported: 2002-12-09 08:20:40 | Status: resolved fixed

MarkerHelpRegistry.hasResolutions is used to get the enablement state for the 'quick fix' menu entry in the task view as well as to evaluate if a light bulb needs to be shown in the (Java) editor. The current implementation of MarkerHelpRegistry.hasResolutions is MarkerHelpRegistry.getResolutions().length; creating all proposals, which can be very expensive as it involves evaluating the problem context and returning the full and exact number of proposals. It would be better if the IMarkerResolutionGenerator would also offer a 'hasResolutions', so the implementor of the genenator can do a cheap guess, and do the more expensive proposal creations only when the dialog is shown. We do the same thing with the quick fixes in the editor, where the light bulb shows up on all error types that are handles, even it is still possible that the exact evaluation will find out that for this particular scenario, no corrections can be offered. Supporting now also contributed MarkerResultions, the performance problem of MarkerHelpRegistry.hasResolutions will show up as more and more contributions are coming. The problem is already now showing up for the context menu of the task bar for Java errors, as for calculating the resolution an AST has to be built.

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMarkerResolutionGenerator.java