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

The following examples show how to use org.eclipse.jface.text.source.Annotation#getType() . 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: AnnotationIssueProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected List<Annotation> getAnnotationsToRemove(IProgressMonitor monitor) {
	if (monitor.isCanceled() || annotationModel == null) {
		return Lists.newArrayList();
	}
	Iterator<Annotation> annotationIterator = annotationModel.getAnnotationIterator();
	List<Annotation> toBeRemoved = Lists.newArrayList();
	while (annotationIterator.hasNext()) {
		if (monitor.isCanceled()) {
			return toBeRemoved;
		}
		Annotation annotation = annotationIterator.next();
		String type = annotation.getType();
		if (isRelevantAnnotationType(type)) {
			if (!(annotation instanceof MarkerAnnotation)) {
				toBeRemoved.add(annotation);
			}
		}
	}
	return toBeRemoved;
}
 
Example 2
Source File: CheckstyleMarkerImageProvider.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Image getManagedImage(Annotation annotation) {
  String type = annotation.getType();
  if (CheckstyleMarker.ERROR_TYPE.equals(type)) {
    return CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.MARKER_ERROR);
  } else if (CheckstyleMarker.WARNING_TYPE.equals(type)) {
    return CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.MARKER_WARNING);
  } else if (CheckstyleMarker.INFO_TYPE.equals(type)) {
    return CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.MARKER_INFO);
  }

  return null;
}
 
Example 3
Source File: ModulaOccurrencesMarker.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private Annotation[] findExistentAnnotations(Set<String> types) {
    final IAnnotationModel model = viewer.getAnnotationModel();
    final List<Annotation> annotations = new ArrayList<Annotation>();
    if (model != null) {
        final Iterator<?> it = model.getAnnotationIterator();
        while (it.hasNext()) {
            final Annotation annotation = (Annotation) it.next();
            String type = annotation.getType();
            if (types.contains(type)) {
                annotations.add(annotation);
            }
        }
    }
    return annotations.toArray(new Annotation[annotations.size()]);
}
 
Example 4
Source File: DirtyStateEditorValidationTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private List<Annotation> getErrorAnnotations(final XtextEditor editor) {
  final Function1<Annotation, Boolean> _function = (Annotation it) -> {
    String _type = it.getType();
    return Boolean.valueOf(Objects.equal(_type, "org.eclipse.xtext.ui.editor.error"));
  };
  return IteratorExtensions.<Annotation>toList(IteratorExtensions.<Annotation>filter(Iterators.<Annotation>filter(editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()).getAnnotationIterator(), Annotation.class), _function));
}
 
Example 5
Source File: DirtyStateEditorSupportTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private List<Annotation> getErrorAnnotations(final XtextEditor editor) {
  final Function1<Annotation, Boolean> _function = (Annotation it) -> {
    String _type = it.getType();
    return Boolean.valueOf(Objects.equal(_type, "org.eclipse.xtext.ui.editor.error"));
  };
  return IteratorExtensions.<Annotation>toList(IteratorExtensions.<Annotation>filter(Iterators.<Annotation>filter(editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()).getAnnotationIterator(), Annotation.class), _function));
}
 
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: TypeScriptAnnotationIterator.java    From typescript.java with MIT License 2 votes vote down vote up
/**
 * Returns true if the given annotation is a Tern Annotation and false
 * otherwise.
 * 
 * @param a
 *            annotation to check
 * @return true if the given annotation is a Tern Annotation and false
 *         otherwise.
 */
protected boolean isTypeScriptAnnotation(Annotation a) {
	String type = a.getType();
	// Annotation coming from WTP TernSourceValidator
	return ((type != null && type.startsWith(ORG_ECLIPSE_WST_SSE_UI_TEMP)));
}