@Override
  public IMarkerResolution[] getResolutions(@Nullable IMarker marker) {
    if (!hasResolutions(marker)) {
      return NO_RESOLUTIONS;
    }
    String markedText = null;
    if (marker != null) {
      markedText = marker.getAttribute(AnnotationManager.MARKED_TEXT, null);
    }

    if (markedText == null) {
      JavaEditor activeEditor = (JavaEditor) getActiveEditor();

      if (activeEditor != null) {
        int caretOffset = activeEditor.getViewer().getTextWidget().getCaretOffset();
        DiagnosticAnnotation annotation = getAnnotationByOffset(caretOffset);
        if (annotation != null) {
          markedText = annotation.getMarkedText();
        }
      }
    }

    if (markedText == null) {
      return NO_RESOLUTIONS;
    }

    Collection<IType> typeResolutions =
        Collections2.filter(
            findAllTypes(markedText),
            new Predicate<IType>() {

              @Override
              public boolean apply(IType type) {
                try {
                  return Flags.isPublic(type.getFlags());
                } catch (JavaModelException e) {
                  KotlinLogger.logAndThrow(e);
                }

                return false;
              }
            });

    List<AutoImportMarkerResolution> markerResolutions =
        new ArrayList<AutoImportMarkerResolution>();
    for (IType type : typeResolutions) {
      markerResolutions.add(new AutoImportMarkerResolution(type));
    }

    return markerResolutions.toArray(new IMarkerResolution[markerResolutions.size()]);
  }
  @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;
  }