protected IAnnotationModel getAnnotationModel(XtextEditor editor) { if(editor != null) { IEditorInput editorInput = editor.getEditorInput(); if(editorInput != null) { IDocumentProvider documentProvider = editor.getDocumentProvider(); if(documentProvider != null) { return documentProvider.getAnnotationModel(editorInput); } } } return null; }
@SuppressWarnings("rawtypes") private Annotation getAnnotation(final int offset, final int length) { final IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput()); if (model == null) return null; Iterator iterator; if (model instanceof IAnnotationModelExtension2) { iterator = ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true); } else { iterator = model.getAnnotationIterator(); } while (iterator.hasNext()) { final Annotation a = (Annotation) iterator.next(); final Position p = model.getPosition(a); if (p != null && p.overlapsWith(offset, length)) return a; } return null; }
public IMarkerResolution[] getResolutions(IMarker marker) { final IMarkerResolution[] emptyResult = new IMarkerResolution[0]; try { if(!marker.isSubtypeOf(MarkerTypes.ANY_VALIDATION)) return emptyResult; } catch (CoreException e) { return emptyResult; } if(!languageResourceHelper.isLanguageResource(marker.getResource())) { return emptyResult; } XtextEditor editor = getEditor(marker.getResource()); if(editor == null) return emptyResult; IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); if(annotationModel != null && !isMarkerStillValid(marker, annotationModel)) return emptyResult; final Iterable<IssueResolution> resolutions = getResolutions(getIssueUtil().createIssue(marker), editor.getDocument()); return getAdaptedResolutions(Lists.newArrayList(resolutions)); }