@Nullable private DiagnosticAnnotation getAnnotationByOffset(int offset) { AbstractTextEditor editor = getActiveEditor(); if (editor == null) { return null; } IDocumentProvider documentProvider = editor.getDocumentProvider(); IAnnotationModel annotationModel = documentProvider.getAnnotationModel(editor.getEditorInput()); for (Iterator<?> i = annotationModel.getAnnotationIterator(); i.hasNext(); ) { Annotation annotation = (Annotation) i.next(); if (annotation instanceof DiagnosticAnnotation) { DiagnosticAnnotation diagnosticAnnotation = (DiagnosticAnnotation) annotation; TextRange range = diagnosticAnnotation.getRange(); if (range.getStartOffset() <= offset && range.getEndOffset() >= offset) { return diagnosticAnnotation; } } } return null; }