@Override public Set<Suggestion> getSuggestions() { Set<Suggestion> suggestions = new LinkedHashSet<Suggestion>(); IMarkerHelpRegistry registry = IDE.getMarkerHelpRegistry(); IMarker marker = getMarker(); EPlan plan = ((MarkerPlanAdvisor)getAdvisor()).getPlan(); if (registry.hasResolutions(marker)) { IMarkerResolution[] resolutions = registry.getResolutions(marker); for (IMarkerResolution resolution : resolutions) { String description = resolution.getLabel() + " for " + getDescription() + " at " + getPrintString(ViolationKey.TIME); IUndoableOperation operation = new MarkerResolutionOperation(this, resolution, plan); Suggestion suggestion = new Suggestion(null, description, operation); suggestions.add(suggestion); } } return suggestions; }
private void fixMarkerViolation(IMarkerHelpRegistry registry, final MarkerViolation markerViolation, boolean reportNoFix) { IMarker marker = markerViolation.getMarker(); if (registry.hasResolutions(marker)) { IMarkerResolution[] resolutions = registry.getResolutions(marker); switch (resolutions.length) { case 0: if (reportNoFix) { reportNoFix(markerViolation); } break; case 1: IMarkerResolution resolution = resolutions[0]; if (resolution instanceof IPlanMarkerResolution) { ((IPlanMarkerResolution)resolution).run(marker, plan); } else { resolution.run(marker); } break; default: chooseResolution(marker, resolutions); } } else if (reportNoFix) { reportNoFix(markerViolation); } }
private static boolean hasCorrections(IMarker marker) { if (marker == null || !marker.exists()) return false; IMarkerHelpRegistry registry= IDE.getMarkerHelpRegistry(); return registry != null && registry.hasResolutions(marker); }