use of org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProviderExtension in project xtext-eclipse by eclipse.
the class AnnotationIssueProcessor method getAnnotationsToAdd.
protected Map<Annotation, Position> getAnnotationsToAdd(Multimap<Position, Annotation> positionToAnnotations, List<Issue> issues, IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return HashBiMap.create();
}
Map<Annotation, Position> annotationToPosition = Maps.newHashMapWithExpectedSize(issues.size());
for (Issue issue : issues) {
if (monitor.isCanceled()) {
return annotationToPosition;
}
if (isSet(issue.getOffset()) && isSet(issue.getLength()) && issue.getMessage() != null) {
String type = lookup.getAnnotationType(EValidator.MARKER, getMarkerSeverity(issue.getSeverity()));
boolean isQuickfixable = false;
if (issueResolutionProvider instanceof IssueResolutionProviderExtension) {
isQuickfixable = ((IssueResolutionProviderExtension) issueResolutionProvider).hasResolutionFor(issue);
} else {
isQuickfixable = issueResolutionProvider.hasResolutionFor(issue.getCode());
}
Annotation annotation = new XtextAnnotation(type, false, xtextDocument, issue, isQuickfixable);
if (issue.getOffset() < 0 || issue.getLength() < 0) {
LOG.error("Invalid annotation position offset=" + issue.getOffset() + " length = " + issue.getLength());
}
Position position = new Position(Math.max(0, issue.getOffset()), Math.max(0, issue.getLength()));
annotationToPosition.put(annotation, position);
positionToAnnotations.put(position, annotation);
}
}
return annotationToPosition;
}
Aggregations