Bug 27935 [Markers] MarkerHelpRegistry.hasResolutions is a performance problem
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.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMarkerResolutionGenerator.java
IResource res= marker.getResource();
		if (res instanceof IFile && res.isAccessible()) {
			return JavaCore.createCompilationUnitFrom((IFile) res);
		}
		return null;
	}
	
	private CorrectionContext findCorrectionContext(IEditorInput input, IMarker marker) throws JavaModelException {
		IAnnotationModel model= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(input);
		if (model != null) {
			Iterator iter= model.getAnnotationIterator();
			while (iter.hasNext()) {
				Object curr= iter.next();
				if (curr instanceof JavaMarkerAnnotation) {
					JavaMarkerAnnotation annot= (JavaMarkerAnnotation) curr;
					
					if (marker.equals(annot.getMarker())) {
						Position pos= model.getPosition(annot);
						if (pos != null) {
							ICompilationUnit cu= getCompilationUnit(marker);
							return new CorrectionContext(JavaModelUtil.toWorkingCopy(cu), pos.getOffset(), pos.getLength(), annot.getId(), annot.getArguments());
						}
					}
				}
			}
		}
		return null;
	}
}