Java Code Examples for org.eclipse.jface.text.source.Annotation#isMarkedDeleted()

The following examples show how to use org.eclipse.jface.text.source.Annotation#isMarkedDeleted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopiedOverviewRuler.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void cacheAnnotations() {
    fCachedAnnotations.clear();
    if (fModel != null) {
        Iterator iter = fModel.getAnnotationIterator();
        while (iter.hasNext()) {
            Annotation annotation = (Annotation) iter.next();

            if (annotation.isMarkedDeleted()) {
                continue;
            }

            if (skip(annotation.getType())) {
                continue;
            }

            fCachedAnnotations.add(annotation);
        }
    }
}
 
Example 2
Source File: XtextQuickAssistProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean canFix(Annotation annotation) {
	if (annotation.isMarkedDeleted())
		return false;

	// non-persisted annotation
	if (annotation instanceof XtextAnnotation) {
		XtextAnnotation a = (XtextAnnotation) annotation;
		return getResolutionProvider().hasResolutionFor(a.getIssueCode());
	}

	// persisted markerAnnotation
	if (annotation instanceof MarkerAnnotation) {
		MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
		if (!markerAnnotation.isQuickFixableStateSet())
			markerAnnotation.setQuickFixable(getResolutionProvider().hasResolutionFor(
					issueUtil.getCode(markerAnnotation)));
		return markerAnnotation.isQuickFixable();
	}

	if (annotation instanceof SpellingAnnotation) {
		return true;
	}

	return false;
}
 
Example 3
Source File: TypeScriptAnnotationIterator.java    From typescript.java with MIT License 6 votes vote down vote up
private void skip() {
	while (fIterator.hasNext()) {
		Annotation next = (Annotation) fIterator.next();
		if (isTypeScriptAnnotation(next) || next instanceof IQuickFixableAnnotation) {
			if (fSkipIrrelevants) {
				if (!next.isMarkedDeleted()) {
					fNext = next;
					return;
				}
			} else {
				fNext = next;
				return;
			}
		} else if (fReturnAllAnnotations) {
			fNext = next;
			return;
		}
	}
	fNext = null;
}
 
Example 4
Source File: JsonQuickAssistProcessor.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean canFix(Annotation annotation) {
    if (annotation.isMarkedDeleted()) {
        return false;
    }
    if (annotation instanceof MarkerAnnotation) {
        MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
        if (!markerAnnotation.isQuickFixableStateSet()) {
            markerAnnotation.setQuickFixable(
                    generators.stream().anyMatch(e -> e.hasResolutions(markerAnnotation.getMarker())));
        }
        return markerAnnotation.isQuickFixable();
    }
    return false;
}
 
Example 5
Source File: JavaAnnotationIterator.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
private void skip() {
	while (fIterator.hasNext()) {
		Annotation next= fIterator.next();

		if (next.isMarkedDeleted())
			continue;

		if (fReturnAllAnnotations || /*next instanceof IJavaAnnotation ||*/ isProblemMarkerAnnotation(next)) {
			fNext= next;
			return;
		}
	}
	fNext= null;
}
 
Example 6
Source File: CopiedOverviewRuler.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void skip() {

            boolean temp = (fStyle & TEMPORARY) != 0;
            boolean pers = (fStyle & PERSISTENT) != 0;
            boolean ignr = (fStyle & IGNORE_BAGS) != 0;

            while (fIterator.hasNext()) {
                Annotation next = (Annotation) fIterator.next();

                if (next.isMarkedDeleted()) {
                    continue;
                }

                if (ignr && (next instanceof AnnotationBag)) {
                    continue;
                }

                fNext = next;
                Object annotationType = next.getType();
                if (fType == null || fType.equals(annotationType)
                        || !fConfiguredAnnotationTypes.contains(annotationType) && isSubtype(annotationType)) {
                    if (temp && pers) {
                        return;
                    }
                    if (pers && next.isPersistent()) {
                        return;
                    }
                    if (temp && !next.isPersistent()) {
                        return;
                    }
                }
            }
            fNext = null;
        }
 
Example 7
Source File: SARLEditorErrorTickUpdater.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static Set<String> extractErrorMarkerMessages(IAnnotationModel currentModel) {
	//FIXME: for helping to resolve #661
	final Iterator<Annotation> annotations = currentModel.getAnnotationIterator();
	final Set<String> errors = new TreeSet<>();
	while (annotations.hasNext()) {
		final Annotation annotation = annotations.next();
		if (!annotation.isMarkedDeleted() && MARKER_TYPE.equals(annotation.getType())) {
			errors.add(annotation.getText());
		}
	}
	return errors;
}
 
Example 8
Source File: AbstractAnnotationHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the annotation preference for the given annotation.
 *
 * @param annotation the annotation
 * @return the annotation preference or <code>null</code> if none
 */
private static AnnotationPreference getAnnotationPreference(Annotation annotation) {

	if (annotation.isMarkedDeleted())
		return null;
	return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
}
 
Example 9
Source File: JavaAnnotationIterator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void skip() {
	while (fIterator.hasNext()) {
		Annotation next= fIterator.next();

		if (next.isMarkedDeleted())
			continue;

		if (fReturnAllAnnotations || next instanceof IJavaAnnotation || isProblemMarkerAnnotation(next)) {
			fNext= next;
			return;
		}
	}
	fNext= null;
}
 
Example 10
Source File: XtextEditorErrorTickUpdater.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Severity getSeverity(XtextEditor xtextEditor) {
	if (xtextEditor == null || xtextEditor.getInternalSourceViewer() == null)
		return null;
	IAnnotationModel model = xtextEditor.getInternalSourceViewer().getAnnotationModel();
	if (model != null) {
		Iterator<Annotation> iterator = model.getAnnotationIterator();
		boolean hasWarnings = false;
		boolean hasInfos = false;
		while (iterator.hasNext()) {
			Annotation annotation = iterator.next();
			if (!annotation.isMarkedDeleted()) {
				Issue issue = issueUtil.getIssueFromAnnotation(annotation);
				if (issue != null) {
					if (issue.getSeverity() == Severity.ERROR) {
						return Severity.ERROR;
					} else if (issue.getSeverity() == Severity.WARNING) {
						hasWarnings = true;
					} else if (issue.getSeverity() == Severity.INFO) {
						hasInfos = true;
					}
				}
			}
		}
		if (hasWarnings)
			return Severity.WARNING;
		if (hasInfos)
			return Severity.INFO;
	}
	return null;
}
 
Example 11
Source File: XtextMarkerAnnotationImageProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private Map<String, Image> getImages(Annotation annotation) {
	if(annotation.isMarkedDeleted())
		return XtextPluginImages.getAnnotationImagesDeleted();
	else {
		if (annotation instanceof MarkerAnnotation) {
			MarkerAnnotation ma = (MarkerAnnotation) annotation;
			if(ma.isQuickFixableStateSet() && ma.isQuickFixable())
				return XtextPluginImages.getAnnotationImagesFixable();
		}
		return XtextPluginImages.getAnnotationImagesNonfixable();
	}
}
 
Example 12
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected boolean isNavigationTarget(Annotation annotation) {
	boolean result = super.isNavigationTarget(annotation);
	if (result) {
		if (annotation.isMarkedDeleted()) {
			return false;
		}
	}
	return result;
}
 
Example 13
Source File: AbstractAnnotationHover.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the annotation preference for the given annotation.
 *
 * @param annotation the annotation
 * @return the annotation preference or <code>null</code> if none
 */
private static AnnotationPreference getAnnotationPreference(Annotation annotation) {

	if (annotation.isMarkedDeleted())
		return null;
	return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
}
 
Example 14
Source File: AbstractQuickAssistProcessor.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canFix(Annotation annotation) {
  return !annotation.isMarkedDeleted();
}
 
Example 15
Source File: JavaSelectAnnotationRulerAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void findJavaAnnotation() {
	fPosition= null;
	fAnnotation= null;
	fHasCorrection= false;

	AbstractMarkerAnnotationModel model= getAnnotationModel();
	IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();

	IDocument document= getDocument();
	if (model == null)
		return ;

	boolean hasAssistLightbulb= fStore.getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);

	Iterator<Annotation> iter= model.getAnnotationIterator();
	int layer= Integer.MIN_VALUE;

	while (iter.hasNext()) {
		Annotation annotation= iter.next();
		if (annotation.isMarkedDeleted())
			continue;

		int annotationLayer= layer;
		if (annotationAccess != null) {
			annotationLayer= annotationAccess.getLayer(annotation);
			if (annotationLayer < layer)
				continue;
		}

		Position position= model.getPosition(annotation);
		if (!includesRulerLine(position, document))
			continue;

		AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
		if (preference == null)
			continue;

		String key= preference.getVerticalRulerPreferenceKey();
		if (key == null)
			continue;

		if (!fStore.getBoolean(key))
			continue;

		boolean isReadOnly= fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
		if (!isReadOnly
				&& (
					((hasAssistLightbulb && annotation instanceof AssistAnnotation)
					|| JavaCorrectionProcessor.hasCorrections(annotation)))) {
			fPosition= position;
			fAnnotation= annotation;
			fHasCorrection= true;
			layer= annotationLayer;
			continue;
		} else if (!fHasCorrection) {
				fPosition= position;
				fAnnotation= annotation;
				layer= annotationLayer;
		}
	}
}
 
Example 16
Source File: XtextQuickAssistProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Check whether the given annotation type is supported, i.e. {@link #canFix(Annotation)} might return {@code true}.
 * This could be made protected in a future release.
 */
private boolean isSupported(Annotation annotation) {
	return !annotation.isMarkedDeleted()
			&& (annotation instanceof XtextAnnotation || annotation instanceof MarkerAnnotation
				|| annotation instanceof SpellingAnnotation);
}
 
Example 17
Source File: AbstractProblemHover.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.1
 */
protected boolean isHandled(Annotation annotation) {
	return null != annotation
			&& !annotation.isMarkedDeleted()
			&& (isError(annotation) || isWarning(annotation) || isInfo(annotation) || isBookmark(annotation) || isSpelling(annotation));
}
 
Example 18
Source File: JavaCorrectionProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isQuickFixableType(Annotation annotation) {
	return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}
 
Example 19
Source File: CopiedOverviewRuler.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns the position of the first annotation found in the given line range.
 *
 * @param lineNumbers the line range
 * @return the position of the first found annotation
 */
protected Position getAnnotationPosition(int[] lineNumbers) {
    if (lineNumbers[0] == -1) {
        return null;
    }

    Position found = null;

    try {
        IDocument d = fTextViewer.getDocument();
        IRegion line = d.getLineInformation(lineNumbers[0]);

        int start = line.getOffset();

        line = d.getLineInformation(lineNumbers[lineNumbers.length - 1]);
        int end = line.getOffset() + line.getLength();

        for (int i = fAnnotationsSortedByLayer.size() - 1; i >= 0; i--) {

            Object annotationType = fAnnotationsSortedByLayer.get(i);

            Iterator e = new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY);
            while (e.hasNext() && found == null) {
                Annotation a = (Annotation) e.next();
                if (a.isMarkedDeleted()) {
                    continue;
                }

                if (skip(a.getType())) {
                    continue;
                }

                Position p = fModel.getPosition(a);
                if (p == null) {
                    continue;
                }

                int posOffset = p.getOffset();
                int posEnd = posOffset + p.getLength();
                IRegion region = d.getLineInformationOfOffset(posEnd);
                // trailing empty lines don't count
                if (posEnd > posOffset && region.getOffset() == posEnd) {
                    posEnd--;
                    region = d.getLineInformationOfOffset(posEnd);
                }

                if (posOffset <= end && posEnd >= start) {
                    found = p;
                }
            }
        }
    } catch (BadLocationException x) {
    }

    return found;
}
 
Example 20
Source File: AbstractAnnotationHover.java    From typescript.java with MIT License 3 votes vote down vote up
/**
 * Returns the annotation preference for the given annotation.
 *
 * @param annotation
 *            the annotation
 * @return the annotation preference or <code>null</code> if none
 */
private static AnnotationPreference getAnnotationPreference(Annotation annotation) {

	if (annotation.isMarkedDeleted())
		return null;
	return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
}