Package org.bndtools.core.editors

Source Code of org.bndtools.core.editors.BndMarkerAnnotationHover

package org.bndtools.core.editors;

import java.util.Iterator;

import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.texteditor.MarkerAnnotation;

public class BndMarkerAnnotationHover implements IAnnotationHover {

    public String getHoverInfo(ISourceViewer sourceViewer, int lineNum) {
        @SuppressWarnings("rawtypes")
        Iterator iter = sourceViewer.getAnnotationModel().getAnnotationIterator();
        while (iter.hasNext()) {
            Object annotation = iter.next();
            if (annotation instanceof MarkerAnnotation) {
                IMarker marker = ((MarkerAnnotation) annotation).getMarker();

                int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, 0);
                // Hover line is zero-based and marker line is one-based. FML.
                if (markerLine == lineNum + 1) {
                    return marker.getAttribute(IMarker.MESSAGE, null);
                }
            }
        }

        return null;
    }

}
TOP

Related Classes of org.bndtools.core.editors.BndMarkerAnnotationHover

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.