org.eclipse.jface.text.source.Annotation类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中org.eclipse.jface.text.source.Annotation类的一些代码示例,展示了Annotation类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation类的具体详情如下:
包路径:org.eclipse.jface.text.source.Annotation
类名称:Annotation

Annotation介绍

[英]Annotation managed by an org.eclipse.jface.text.source.IAnnotationModel.

Annotations are typed, can have an associated text and can be marked as persistent and deleted. Annotations which are not explicitly initialized with an annotation type are of type "org.eclipse.text.annotation.unknown".
[中]由组织管理的注释。日食jface。文本来源iAnotationModel。
注释是类型化的,可以有关联的文本,并且可以标记为持久的并被删除。未使用注释类型显式初始化的注释的类型为"org.eclipse.text.annotation.unknown"

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor

@Override
public boolean canFix(Annotation annotation) {
  return annotation instanceof SpellingAnnotation && !annotation.isMarkedDeleted();
}

代码示例来源:origin: org.eclipse.mylyn.wikitext/ui

public Object getType(Annotation annotation) {
  return annotation.getType();
}

代码示例来源:origin: org.eclipse.xtext/ui

@Override
protected Object getHoverInfoInternal(final ITextViewer textViewer, final int lineNumber, final int offset) {
  final Set<String> messages = Sets.newLinkedHashSet();
  List<Annotation> annotations = getAnnotations(lineNumber, offset);
  for (Annotation annotation : annotations) {
    if (annotation.getText() != null) {
      messages.add(annotation.getText().trim());
    }
  }
  if (messages.size()>0)
    return formatInfo(messages);
  return null;
}

代码示例来源:origin: org.eclipse.xtext/ui

/**
 * @since 2.1
 */
protected boolean isHandled(Annotation annotation) {
  return null != annotation
      && !annotation.isMarkedDeleted()
      && (markerAnnotationAccess.isSubtype(annotation.getType(), "org.eclipse.ui.workbench.texteditor.error") 
          || markerAnnotationAccess.isSubtype(annotation.getType(), "org.eclipse.ui.workbench.texteditor.warning")
          || markerAnnotationAccess.isSubtype(annotation.getType(), "org.eclipse.ui.workbench.texteditor.info")
          || markerAnnotationAccess.isSubtype(annotation.getType(), "org.eclipse.ui.workbench.texteditor.bookmark")
          || markerAnnotationAccess.isSubtype(annotation.getType(), "org.eclipse.ui.workbench.texteditor.spelling"));
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

private void skip() {
  boolean temp= (fStyle & TEMPORARY) != 0;
  boolean pers= (fStyle & PERSISTENT) != 0;
  boolean ignr= (fStyle & IGNORE_BAGS) != 0;
  while (fIterator.hasNext()) {
    Annotation next= 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;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

toRemove.remove(fTargetAnnotations.get(p));
} else {
  Annotation a= new Annotation(TARGET_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
  toAdd.put(a, p);
  fTargetAnnotations.put(p, a);

代码示例来源:origin: org.eclipse/org.eclipse.ui.editors

public boolean isTemporary(Annotation annotation) {
  return !annotation.isPersistent();
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
  Annotation annotation= new Annotation(annotationType, false, null);
  AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
  if (preference != null)
    return preference.getPresentationLayer() + 1;
  else
    return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

private void cacheAnnotations() {
  fCachedAnnotations.clear();
  if (fModel != null) {
    Iterator<Annotation> iter= fModel.getAnnotationIterator();
    while (iter.hasNext()) {
      Annotation annotation= iter.next();
      if (annotation.isMarkedDeleted())
        continue;
      if (skip(annotation.getType()))
        continue;
      fCachedAnnotations.add(annotation);
    }
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

private void skip() {
  boolean temp= (fStyle & TEMPORARY) != 0;
  boolean pers= (fStyle & PERSISTENT) != 0;
  boolean ignr= (fStyle & IGNORE_BAGS) != 0;
  while (fIterator.hasNext()) {
    Annotation next= 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;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.editors

/**
 * {@inheritDoc}
 *
 * @deprecated assumed to always return <code>true</code>
 */
@Deprecated
@Override
public boolean isTemporary(Annotation annotation) {
  return !annotation.isPersistent();
}

代码示例来源:origin: org.eclipse/org.eclipse.ajdt.ui

public static boolean isQuickFixableType(Annotation annotation) {
  return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}

代码示例来源:origin: org.eclipse/org.eclipse.ui.editors

public Object getType(Annotation annotation) {
  return annotation.getType();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
  Annotation annotation= new Annotation(annotationType, false, null);
  AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
  if (preference != null)
    return preference.getPresentationLayer() + 1;
  else
    return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

@Override
protected void computeInformation() {
  if (fSelection != null) {
    Rectangle subjectArea= fSelection.canvas.getBounds();
    Annotation annotation= fSelection.fAnnotation;
    String msg;
    if (annotation != null)
      msg= annotation.getText();
    else
      msg= null;
    setInformation(msg, subjectArea);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

private void cacheAnnotations() {
  fCachedAnnotations.clear();
  if (fModel != null) {
    Iterator<Annotation> iter= fModel.getAnnotationIterator();
    while (iter.hasNext()) {
      Annotation annotation= iter.next();
      if (annotation.isMarkedDeleted())
        continue;
      if (skip(annotation.getType()))
        continue;
      fCachedAnnotations.add(annotation);
    }
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

public static boolean isQuickFixableType(Annotation annotation) {
  return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

private boolean isBreakpointAnnotation(Annotation a) {
    // HACK to get breakpoints to show up first
    return a.getType().equals("org.eclipse.debug.core.breakpoint"); //$NON-NLS-1$
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Sets the positions that should be highlighted as the target positions, i.e.
 * as the positions that can be jumped to in a linked set up.
 *
 * @param positions the new target positions, or <code>null</code> if no target positions are to be set
 * @throws BadLocationException in case any of the given positions is invalid
 */
private void setTargetPositions(List<Position> positions) throws BadLocationException {
  if (!fMarkTargets)
    return;
  // remove all positions which are already there
  // Algorithm: toRemove contains all mappings at first, but all that are in
  // positions get removed -> toRemove contains the difference set of previous - new
  // toAdd are the new positions, which don't exist in previous = new - previous
  List<Annotation> toRemove= new ArrayList<>(fTargetAnnotations.values());
  Map<Annotation, Position> toAdd= new HashMap<>();
  if (positions != null) {
    for (Position p : positions) {
      if (fTargetAnnotations.containsKey(p)) {
        toRemove.remove(fTargetAnnotations.get(p));
      } else {
        Annotation a= new Annotation(TARGET_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
        toAdd.put(a, p);
        fTargetAnnotations.put(p, a);
      }
    }
  }
  fTargetAnnotations.values().removeAll(toRemove);
  replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

private boolean includeAnnotation(Annotation annotation, Position position, HashMap<Position, Object> messagesAtPosition) {
  if (!isIncluded(annotation))
    return false;
  String text= annotation.getText();
  return (text != null && !isDuplicateAnnotation(messagesAtPosition, position, text));
}

相关文章