Java 类org.eclipse.ui.texteditor.SimpleMarkerAnnotation 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:JavaCorrectionProcessor.java   
public static boolean hasCorrections(Annotation annotation) {
    if (annotation instanceof IJavaAnnotation) {
        IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation;
        int problemId= javaAnnotation.getId();
        if (problemId != -1) {
            ICompilationUnit cu= javaAnnotation.getCompilationUnit();
            if (cu != null) {
                return hasCorrections(cu, problemId, javaAnnotation.getMarkerType());
            }
        }
    }
    if (annotation instanceof SimpleMarkerAnnotation) {
        return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker());
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaCorrectionProcessor.java   
public static boolean hasCorrections(Annotation annotation) {
    if (annotation instanceof IJavaAnnotation) {
        IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation;
        int problemId= javaAnnotation.getId();
        if (problemId != -1) {
            ICompilationUnit cu= javaAnnotation.getCompilationUnit();
            if (cu != null) {
                return hasCorrections(cu, problemId, javaAnnotation.getMarkerType());
            }
        }
    }
    if (annotation instanceof SimpleMarkerAnnotation) {
        return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker());
    }
    return false;
}
项目:VariantSync    文件:CodeMarkerFactory.java   
public static void addAnnotation(IMarker marker, ITextEditor editor,
        String annotation, int offset, int length) {
    // The DocumentProvider enables to get the document currently loaded in
    // the editor
    IDocumentProvider idp = editor.getDocumentProvider();

    // This is the document we want to connect to. This is taken from the
    // current editor input.
    IDocument document = idp.getDocument(editor.getEditorInput());

    // The IannotationModel enables to add/remove/change annotation to a
    // Document loaded in an Editor
    IAnnotationModel iamf = idp.getAnnotationModel(editor.getEditorInput());

    // Note: The annotation type id specify that you want to create one of
    // your annotations
    String an = "";
    if (annotation.equals("1")) {
        an = ANNOTATION_COLOR1;
    } else if (annotation.equals("2")) {
        an = ANNOTATION_COLOR2;
    } else if (annotation.equals("3")) {
        an = ANNOTATION_COLOR3;
    }
    SimpleMarkerAnnotation ma = new SimpleMarkerAnnotation(an, marker);

    // Finally add the new annotation to the model
    iamf.connect(document);
    iamf.addAnnotation(ma, new Position(offset, length));
    iamf.disconnect(document);
}
项目:APICloud-Studio    文件:CommonAnnotationHover.java   
public int compare(Annotation o1, Annotation o2)
{
    if (o1 instanceof SimpleMarkerAnnotation && o2 instanceof SimpleMarkerAnnotation)
    {
        // Compare the marker offset first. In case it was not set with an offset, compare via the line numbers.
        IMarker m1 = ((SimpleMarkerAnnotation) o1).getMarker();
        IMarker m2 = ((SimpleMarkerAnnotation) o2).getMarker();
        if (m1 != null && m2 != null)
        {
            // try comparing by offset
            int pos1 = m1.getAttribute(IMarker.CHAR_START, -1);
            int pos2 = m2.getAttribute(IMarker.CHAR_START, -1);
            if (pos1 > -1 && pos2 > -1)
            {
                return pos1 - pos2;
            }
            // in case one of the char-start values was not set, try comparing using the line number
            pos1 = m1.getAttribute(IMarker.LINE_NUMBER, -1);
            pos2 = m2.getAttribute(IMarker.LINE_NUMBER, -1);
            if (pos1 > -1 && pos2 > -1)
            {
                return pos1 - pos2;
            }
        }
    }
    // just return 0, as we can't really compare those.
    return 0;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaCorrectionProcessor.java   
private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<IJavaCompletionProposal> proposals) {
    IMarker marker= annotation.getMarker();
    IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
    if (res.length > 0) {
        for (int i= 0; i < res.length; i++) {
            proposals.add(new MarkerResolutionProposal(res[i], marker));
        }
    }
}
项目:SPLevo    文件:JavaEditorConnector.java   
/**
 * Create a new source location annotation.
 *
 * @param marker
 *            The marker to assign to the annotation.
 * @param selection
 *            The selection to highlight.
 * @param editor
 *            The editor to set the annotations in.
 * @param variant
 *            The variant to decide about the marker presentation.
 */
private void createLocationAnnotation(IMarker marker, ITextSelection selection, ITextEditor editor, Variant variant) {

    IDocumentProvider idp = editor.getDocumentProvider();
    IEditorInput editorInput = editor.getEditorInput();

    IDocument document = idp.getDocument(editorInput);
    IAnnotationModel annotationModel = idp.getAnnotationModel(editorInput);

    String annotationType = getAnnotationType(variant);
    SimpleMarkerAnnotation annotation = new SimpleMarkerAnnotation(annotationType, marker);
    annotationModel.connect(document);
    annotationModel.addAnnotation(annotation, new Position(selection.getOffset(), selection.getLength()));
    annotationModel.disconnect(document);        
}
项目:SPLevo    文件:UnifiedDiffHighlighter.java   
/**
 * Creates the corresponding annotation for a given marker according to the given marker type.
 * 
 * @param marker the given marker.
 * @param selection the selection to highlight.
 * @param editor the underlying editor.
 * @param markerType the given marker type.
 */
private void createAnnotation(IMarker marker, ITextSelection selection, ITextEditor editor, MarkerType markerType) {
    IDocumentProvider idp = editor.getDocumentProvider();
    IDocument document = idp.getDocument(editorInput);
    IAnnotationModel annotationModel = idp.getAnnotationModel(editorInput);
    String annotationType = UIConstants.ANNOTATION_TO_ID.get(markerType);
    SimpleMarkerAnnotation annotation = new SimpleMarkerAnnotation(annotationType, marker);
    annotationModel.connect(document);
    annotationModel.addAnnotation(annotation, new Position(selection.getOffset(), selection.getLength()));
    annotationModel.disconnect(document);        
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaCorrectionProcessor.java   
private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<IJavaCompletionProposal> proposals) {
    IMarker marker= annotation.getMarker();
    IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
    if (res.length > 0) {
        for (int i= 0; i < res.length; i++) {
            proposals.add(new MarkerResolutionProposal(res[i], marker));
        }
    }
}
项目:rustyeclipse    文件:RustTextHover.java   
private boolean isIncluded(Annotation annotation) {
    if(annotation instanceof SimpleMarkerAnnotation){
        SimpleMarkerAnnotation markerannotation = (SimpleMarkerAnnotation)annotation;
        return markerannotation.getMarker().exists() 
                && RustBuilder.isRustMarker(markerannotation.getMarker());
    }
    return false;
}
项目:Archie-Smart-IDE    文件:EclipsePlatformUtils.java   
/*******************************************************
 * Adds an annotation of the specified type to the specified marker in the
 * specified editor.
 * 
 * @param editor
 *            The text editor in which text will be annotated.
 * @param marker
 *            The marker that will be used for annotation.
 * @param annotationType
 *            The type of the annotation as specified in the Manifest file.
 * @param startPos
 *            The starting position of the text to annotate.
 * @param length
 *            The length of the text to annotate
 *******************************************************/
public static void addAnnotation(ITextEditor editor, IMarker marker, String annotationType, int startPos, int length)
{
    if (editor == null || marker == null || annotationType == null)
        throw new IllegalArgumentException();

    if (startPos < 0 || length <= 0)
        throw new IllegalArgumentException("Invalid marker positions!");

    // The DocumentProvider enables to get the document currently loaded in
    // the editor
    IDocumentProvider docProvider = editor.getDocumentProvider();

    // This is the document we want to connect to. This is taken from
    // the current editor input.
    IDocument document = docProvider.getDocument(editor.getEditorInput());

    // The IannotationModel enables to add/remove/change annotation to a
    // Document loaded in an Editor
    IAnnotationModel annotationModel = docProvider.getAnnotationModel(editor.getEditorInput());

    // Note: The annotation type id specify that you want to create one of
    // your annotations
    SimpleMarkerAnnotation markerAnnotation = new SimpleMarkerAnnotation(annotationType, marker);

    // Finally add the new annotation to the model
    annotationModel.connect(document);
    annotationModel.addAnnotation(markerAnnotation, new Position(startPos, length));
    annotationModel.disconnect(document);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaCorrectionProcessor.java   
public static boolean isQuickFixableType(Annotation annotation) {
    return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaCorrectionProcessor.java   
public static boolean isQuickFixableType(Annotation annotation) {
    return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}
项目:Pydev    文件:MarkerAnnotationAndPosition.java   
public MarkerAnnotationAndPosition(SimpleMarkerAnnotation markerAnnotation, Position position) {
    this.markerAnnotation = markerAnnotation;
    this.position = position;
}