Java 类org.eclipse.jface.text.source.Annotation 实例源码

项目:Hydrograph    文件:SourceViewer.java   
private void calculatePositions() {
    if (hasSnippetsModifications()) {
        final Map<ProjectionAnnotation, Position> annotations = getAllSnippetsAnnotations();

        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (!annotations.isEmpty() && getProjectionAnnotationModel() == null) {
                    enableProjection();
                }
                if (getProjectionAnnotationModel() != null) {
                    Annotation[] oldAnno = oldAnnotations.keySet().toArray(new Annotation[0]);
                    getProjectionAnnotationModel().modifyAnnotations(oldAnno, annotations, null);
                    oldAnnotations.clear();
                    oldAnnotations.putAll(annotations);
                    if (annotations.isEmpty()) {
                        disableProjection();
                    }
                }
            }

        });
    }
}
项目:Tarski    文件:ReasonReconcilingStrategy.java   
private void removeOldAnnotation(final int offset) {
  this.annotationModel.connect(this.document);

  final Iterator<Annotation> iter = this.annotationModel.getAnnotationIterator();
  Annotation beRemoved = null;
  while (iter.hasNext()) {
    beRemoved = iter.next();
    if (!beRemoved.getType().equals(this.MME_REASON_ANNOT_TYPE)) {
      continue;
    }
    final Position position = this.annotationModel.getPosition(beRemoved);

    if (position.getOffset() + position.getLength() == offset || position.includes(offset)) {
      this.annotationModel.removeAnnotation(beRemoved);
    }
  }
  this.annotationModel.disconnect(this.document);
}
项目:Tarski    文件:SyntacticReconcilingStrategy.java   
/**
 * We add new error annotation related to error which alloy parser is giving us.
 *
 * @param e the exception which is parse operation occurred
 */
private void addNewAnnotation(final Err e) {
  final int line = e.pos.y;
  int offset = 0;
  final int length = e.pos.x2 - e.pos.x + 1;
  final String message = e.getLocalizedMessage();
  try {
    offset = this.document.getLineOffset(line - 1) + e.pos.x - 1;
  } catch (final BadLocationException e1) {
    e1.printStackTrace();
  }

  final Annotation annotation = new Annotation(this.MME_PARSE_ANNOT_TYPE, true, message);
  this.annotationModel.connect(this.document);
  this.annotationModel.addAnnotation(annotation, new Position(offset, length));
  this.annotationModel.disconnect(this.document);
}
项目:ec4e    文件:EditorConfigTextHover.java   
/***
 * Returns true if it exists a marker annotation in the given offset and false
 * otherwise.
 *
 * @param textViewer
 * @param offset
 * @return true if it exists a marker annotation in the given offset and false
 *         otherwise.
 */
private static boolean hasProblem(ITextViewer textViewer, int offset) {
    if (!(textViewer instanceof ISourceViewer)) {
        return false;
    }

    IAnnotationModel annotationModel = ((ISourceViewer) textViewer).getAnnotationModel();
    Iterator<Annotation> iter = (annotationModel instanceof IAnnotationModelExtension2)
            ? ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(offset, 1, true, true)
            : annotationModel.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation ann = iter.next();
        if (ann instanceof MarkerAnnotation) {
            return true;
        }
    }
    return false;
}
项目:ec4e    文件:EditorConfigFoldingStrategy.java   
private void updateFolding(EditorConfig editorConfig) {
    if (projectionAnnotationModel == null) {
        return;
    }
    List<Section> sections = editorConfig.getSections();
    CommentBlocks commentBlocks = editorConfig.getAdapter(CommentBlocks.class);
    List<CommentBlock> comments = commentBlocks != null ? commentBlocks.getCommentBlocks()
            : Collections.emptyList();
    Map<Annotation, Position> newAnnotations = new HashMap<>();
    // Collection section and comment spans;
    List<Span> spans = /*Stream.concat(sections.stream(), comments.stream())*/
            sections.stream()
            .map(a -> a.getAdapter(Span.class))
            .sorted((s1, s2) -> s1.getStart().getLine() - s2.getStart().getLine()).collect(Collectors.toList());
    Annotation[] annotations = new Annotation[spans.size()];
    for (int i = 0; i < spans.size(); i++) {
        Span span = spans.get(i);
        int startOffset = span.getStart().getOffset();
        int endOffset = span.getEnd().getOffset();
        ProjectionAnnotation annotation = new ProjectionAnnotation();
        newAnnotations.put(annotation, new Position(startOffset, endOffset - startOffset));
        annotations[i] = annotation;
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
    oldAnnotations = annotations;
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelAnnotationHOver.java   
@SuppressWarnings("rawtypes")
@Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
    IAnnotationModel model = sourceViewer.getAnnotationModel();
    Iterator iterator = model.getAnnotationIterator();
    while (iterator.hasNext()) {
        Annotation annotation = (Annotation) iterator.next();
        Position position = model.getPosition(annotation);
        try {
            int lineOfAnnotation = sourceViewer.getDocument().
                    getLineOfOffset(position.getOffset());
            if (lineNumber == lineOfAnnotation) {
                return annotation.getText();
            }
        } catch (BadLocationException e) {
            // TODO: handle exception
        }

    }
    return null;
}
项目:DarwinSPL    文件:DwprofileCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:DwprofileQuickAssistProcessor.java   
private List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> foundFixes = new ArrayList<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HyexpressionQuickAssistProcessor.java   
private List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HyexpressionCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:HyvalidityformulaCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:HyvalidityformulaQuickAssistProcessor.java   
private List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> foundFixes = new ArrayList<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HydatavalueQuickAssistProcessor.java   
private List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> foundFixes = new ArrayList<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HydatavalueCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:HymappingQuickAssistProcessor.java   
private List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HymappingCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:HyconstraintsCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:HyconstraintsQuickAssistProcessor.java   
private List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:DarwinSPL    文件:HymanifestCodeFoldingManager.java   
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
    IDocument document = sourceViewer.getDocument();
    if (document == null) {
        return;
    }
    oldAnnotations.clear();
    Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
    }
    // Add new Position with a unique line offset
    for (Position position : positions) {
        if (!isInAdditions(position)) {
            addPosition(position);
        }
    }
    projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
    additions.clear();
}
项目:DarwinSPL    文件:HymanifestQuickAssistProcessor.java   
private List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
    List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> foundFixes = new ArrayList<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix>();
    IAnnotationModel model = annotationModelProvider.getAnnotationModel();

    if (model == null) {
        return foundFixes;
    }

    Iterator<?> iter = model.getAnnotationIterator();
    while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        Position position = model.getPosition(annotation);
        if (offset >= 0) {
            if (!position.overlapsWith(offset, length)) {
                continue;
            }
        }
        Collection<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> quickFixes = getQuickFixes(annotation);
        if (quickFixes != null) {
            foundFixes.addAll(quickFixes);
        }
    }
    return foundFixes;
}
项目:mesfavoris    文件:SpellcheckableMessageArea.java   
private void addProposals(final SubMenuManager quickFixMenu) {
    IAnnotationModel sourceModel = sourceViewer.getAnnotationModel();
    Iterator annotationIterator = sourceModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
        Annotation annotation = (Annotation) annotationIterator.next();
        boolean isDeleted = annotation.isMarkedDeleted();
        boolean isIncluded = includes(sourceModel.getPosition(annotation),
                getTextWidget().getCaretOffset());
        boolean isFixable = sourceViewer.getQuickAssistAssistant().canFix(
                annotation);
        if (!isDeleted && isIncluded && isFixable) {
            IQuickAssistProcessor processor = sourceViewer
            .getQuickAssistAssistant()
            .getQuickAssistProcessor();
            IQuickAssistInvocationContext context = sourceViewer
            .getQuickAssistInvocationContext();
            ICompletionProposal[] proposals = processor
            .computeQuickAssistProposals(context);

            for (ICompletionProposal proposal : proposals)
                quickFixMenu.add(createQuickFixAction(proposal));
        }
    }
}
项目:mesfavoris    文件:BookmarkAnnotationImageProvider.java   
@Override
public Image getManagedImage(Annotation annotation) {
    if (!(annotation instanceof MarkerAnnotation)) {
        return null;
    }
    try {
        MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
        IMarker marker = markerAnnotation.getMarker();
        if (!BookmarksMarkers.MARKER_TYPE.equals(marker.getType())) {
            return null;
        }
        String attributeBookmarkId = (String) marker.getAttribute(BookmarksMarkers.BOOKMARK_ID);
        Optional<BookmarkNumber> bookmarkNumber = numberedBookmarks
                .getBookmarkNumber(new BookmarkId(attributeBookmarkId));
        return getBookmarkAnnotationImage(bookmarkNumber);
    } catch (CoreException e) {
        return null;
    }
}
项目:tlaplus    文件:TLAEditor.java   
/**
 * Update the annotation structure in the editor.
 * 
 * This is only currently used by comment
 * folding and should be removed because it
 * is incorrect.
 * 
 * @param positions
 * @deprecated
 */
public void updateFoldingStructure(List<Position> positions)
{
    if (annotationModel == null) {
        return;
    }

    Annotation[] annotations = new Annotation[positions.size()];

    // this will hold the new annotations along
    // with their corresponding positions
    Map<ProjectionAnnotation, Position> newAnnotations = new HashMap<ProjectionAnnotation, Position>();

    for (int i = 0; i < positions.size(); i++)
    {
        ProjectionAnnotation annotation = new ProjectionAnnotation();
        newAnnotations.put(annotation, positions.get(i));
        annotations[i] = annotation;
    }
    // If this method is called too early, then annotationModel
    // can be null. This should obviously be addressed.
    this.annotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
    oldAnnotations = annotations;
}
项目:tlaplus    文件:TLAProofFoldingStructureProvider.java   
/**
 * Collapses all proofs.
 * 
 * @param cursorOffset
 */
private void foldAllProofs()
{
    Vector<Annotation> modifiedAnnotations = new Vector<Annotation>();
    for (Iterator<TLAProofPosition> it = foldPositions.iterator(); it.hasNext();)
    {
        TLAProofPosition proofPosition = it.next();
        if (!proofPosition.getAnnotation().isCollapsed())
        {
            // should fold every proof
            // so that only theorem statements are shown
            proofPosition.getAnnotation().markCollapsed();
            modifiedAnnotations.add(proofPosition.getAnnotation());
        }
    }

    editor.modifyProjectionAnnotations((Annotation[]) modifiedAnnotations
            .toArray(new ProjectionAnnotation[modifiedAnnotations.size()]));
}
项目:tlaplus    文件:TLAProofFoldingStructureProvider.java   
private void expandAllProofs()
{
    Vector<Annotation> modifiedAnnotations = new Vector<Annotation>();
    for (Iterator<TLAProofPosition> it = foldPositions.iterator(); it.hasNext();)
    {
        TLAProofPosition proofPosition = it.next();
        if (proofPosition.getAnnotation().isCollapsed())
        {
            // should fold every proof
            // so that only theorem statements are shown
            proofPosition.getAnnotation().markExpanded();
            modifiedAnnotations.add(proofPosition.getAnnotation());
        }
    }

    editor.modifyProjectionAnnotations((Annotation[]) modifiedAnnotations
            .toArray(new ProjectionAnnotation[modifiedAnnotations.size()]));
}
项目:fluentmark    文件:AnnotationIterator.java   
private void skip() {
    while (fIterator.hasNext()) {
        Annotation next = fIterator.next();
        if (next instanceof IAnnotation) {
            if (fSkipIrrelevants) {
                if (!next.isMarkedDeleted()) {
                    fNext = next;
                    return;
                }
            } else {
                fNext = next;
                return;
            }
        } else if (fReturnAllAnnotations) {
            fNext = next;
            return;
        }
    }
    fNext = null;
}
项目:fluentmark    文件:FluentMkEditor.java   
/**
 * Returns the annotation overlapping with the given range or <code>null</code>.
 *
 * @param offset the region offset
 * @param length the region length
 * @return the found annotation or <code>null</code>
 */
private Annotation getAnnotation(int offset, int length) {
    IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
    if (model == null) {
        return null;
    }

    Iterator<Annotation> e = new AnnotationIterator(model, true, false);
    while (e.hasNext()) {
        Annotation a = e.next();
        Position p = model.getPosition(a);
        if (p != null && p.overlapsWith(offset, length)) {
            return a;
        }
    }
    return null;
}
项目:overviewruler    文件:AnnotationContentProvider.java   
private List<AnnotationWithPosition> findAnnotations() {
  List<AnnotationWithPosition> annos = new ArrayList<AnnotationWithPosition>();
  try {
    IAnnotationModel model = infoControl.getEditor().getViewer().getAnnotationModel();
    for (Iterator iterator = model.getAnnotationIterator(); iterator.hasNext();) {
      Annotation anno = (Annotation) iterator.next();
      if (containsAnnotationType(anno)) {
        Position position = model.getPosition(anno);
        AnnotationWithPosition newAnno = new AnnotationWithPosition(anno, position);
        if (!containsAnnotation(annos, newAnno)) {
          annos.add(newAnno);
        }
      }
    }
  } catch (Exception e) {
    QuickAnnotationInformationControl.logError(e);
  }
  return annos;
}
项目:typescript.java    文件:TypeScriptAnnotationIterator.java   
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;
}
项目:typescript.java    文件:IndentFoldingStrategy.java   
/**
 * This is the default behavior for updating a dirtied IndexedRegion. This
 * function can be overridden if slightly different functionality is
 * required in a specific instance of this class.
 * 
 * @param existingAnnotationsIter
 *            the existing annotations that need to be updated based on the
 *            given dirtied IndexRegion
 * @param dirtyRegion
 *            the IndexedRegion that caused the annotations need for
 *            updating
 * @param modifications
 *            the list of annotations to be modified
 * @param deletions
 *            the list of annotations to be deleted
 */
protected void updateAnnotations(Annotation existingAnnotation, Position newPos, Map additions, List modifications,
        List deletions) {
    if (existingAnnotation instanceof FoldingAnnotation) {
        FoldingAnnotation foldingAnnotation = (FoldingAnnotation) existingAnnotation;
        // Position newPos = null; //calcNewFoldPosition(null);

        // if a new position can be calculated then update the position of
        // the annotation,
        // else the annotation needs to be deleted
        if (newPos != null && newPos.length > 0 && projectionAnnotationModel != null) {
            Position oldPos = projectionAnnotationModel.getPosition(foldingAnnotation);
            // only update the position if we have to
            if (!newPos.equals(oldPos)) {
                oldPos.setOffset(newPos.offset);
                oldPos.setLength(newPos.length);
                modifications.add(foldingAnnotation);
            }
        } else {
            deletions.add(foldingAnnotation);
        }
    }
}
项目:typescript.java    文件:IndentFoldingStrategy.java   
/**
 * <p>
 * Searches the given {@link DirtyRegion} for annotations that now have a
 * length of 0. This is caused when something that was being folded has been
 * deleted. These {@link FoldingAnnotation}s are then added to the
 * {@link List} of {@link FoldingAnnotation}s to be deleted
 * </p>
 * 
 * @param dirtyRegion
 *            find the now invalid {@link FoldingAnnotation}s in this
 *            {@link DirtyRegion}
 * @param deletions
 *            the current list of {@link FoldingAnnotation}s marked for
 *            deletion that the newly found invalid
 *            {@link FoldingAnnotation}s will be added to
 */
protected void markInvalidAnnotationsForDeletion(DirtyRegion dirtyRegion, List<FoldingAnnotation> deletions,
        List<FoldingAnnotation> existing) {
    Iterator iter = getAnnotationIterator(dirtyRegion);
    if (iter != null) {
        while (iter.hasNext()) {
            Annotation anno = (Annotation) iter.next();
            if (anno instanceof FoldingAnnotation) {
                FoldingAnnotation folding = (FoldingAnnotation) anno;
                Position pos = projectionAnnotationModel.getPosition(anno);
                if (pos.length == 0) {
                    deletions.add(folding);
                } else {
                    existing.add(folding);
                }
            }
        }
    }
}
项目:bts    文件:AnnotationIssueProcessor.java   
protected void updateAnnotations(IProgressMonitor monitor, List<Annotation> toBeRemoved,
        Map<Annotation, Position> annotationToPosition) {
    if (monitor.isCanceled()) {
        return;
    }
    if (annotationModel instanceof IAnnotationModelExtension) {
        Annotation[] removedAnnotations = toBeRemoved.toArray(new Annotation[toBeRemoved.size()]);
        ((IAnnotationModelExtension) annotationModel).replaceAnnotations(removedAnnotations, annotationToPosition);
    } else {
        for (Annotation annotation : toBeRemoved) {
            if (monitor.isCanceled()) {
                return;
            }
            annotationModel.removeAnnotation(annotation);
        }
        for (Map.Entry<Annotation, Position> entry : annotationToPosition.entrySet()) {
            if (monitor.isCanceled()) {
                return;
            }
            annotationModel.addAnnotation(entry.getKey(), entry.getValue());
        }
    }
}
项目:bts    文件:AnnotationIssueProcessor.java   
protected List<Annotation> getAnnotationsToRemove(IProgressMonitor monitor) {
    if (monitor.isCanceled() || annotationModel == null) {
        return Lists.newArrayList();
    }
    @SuppressWarnings("unchecked")
    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;
}
项目:bts    文件:XtextEditor.java   
@SuppressWarnings("rawtypes")
private Annotation getAnnotation(final int offset, final int length) {
    final IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
    if (model == null)
        return null;

    Iterator iterator;
    if (model instanceof IAnnotationModelExtension2) {
        iterator = ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
    } else {
        iterator = model.getAnnotationIterator();
    }

    while (iterator.hasNext()) {
        final Annotation a = (Annotation) iterator.next();
        final Position p = model.getPosition(a);
        if (p != null && p.overlapsWith(offset, length))
            return a;
    }
    return null;
}
项目:bts    文件:AnnotationWithQuickFixesHover.java   
@Override
protected Object getHoverInfoInternal(ITextViewer textViewer, final int lineNumber, final int offset) {
    AnnotationInfo result = recentAnnotationInfo;
    if (result != null)
        return result;
    List<Annotation> annotations = getAnnotations(lineNumber, offset);
    if (annotations != null) {
        for (Annotation annotation : annotations) {
            if (annotation.getText() != null) {
                Position position = getAnnotationModel().getPosition(annotation);
                final IQuickAssistInvocationContext invocationContext = new QuickAssistInvocationContext(sourceViewer, position.getOffset(), position.getLength(), true);
                CompletionProposalRunnable runnable = new CompletionProposalRunnable(invocationContext);    
                // Note: the resolutions have to be retrieved from the UI thread, otherwise
                // workbench.getActiveWorkbenchWindow() will return null in LanguageSpecificURIEditorOpener and
                // cause an exception
                Display.getDefault().syncExec(runnable);
                result = new AnnotationInfo (annotation, position, sourceViewer, runnable.proposals);
                recentAnnotationInfo = result;
                return result;
            }
        }
    }
    return null;
}
项目:velocity-edit    文件:VelocityFoldingStructureProvider.java   
private Annotation[] computeDifferences(ProjectionAnnotationModel model, Set current)
{
    List deletions = new ArrayList();
    for (Iterator iter = model.getAnnotationIterator(); iter.hasNext();)
    {
        Object annotation = iter.next();
        if (annotation instanceof ProjectionAnnotation)
        {
            Position position = model.getPosition((Annotation) annotation);
            if (current.contains(position))
                current.remove(position);
            else
                deletions.add(annotation);
        }
    }
    return (Annotation[]) deletions.toArray(new Annotation[deletions.size()]);
}
项目:bts    文件:EgyTextEditorPart.java   
/**
 * Load annotations2 editor.
 *
 * @param editorModel the editor model
 * @param model the model
 * @param monitor 
 */
@SuppressWarnings("rawtypes")
private void loadAnnotations2Editor(IAnnotationModel editorModel,
        IAnnotationModel model, IProgressMonitor monitor) {
    Iterator i = model.getAnnotationIterator();
    Issue issue;
    issue = new Issue.IssueImpl();
    if (monitor != null)
    {
        if (monitor.isCanceled()) return;
        monitor.beginTask("Load visible annotations to Text-Editor", IProgressMonitor.UNKNOWN);
    }
    while (i.hasNext()) {
        Object a = i.next();
        Position pos = model.getPosition((Annotation) a);
        loadSingleAnnotation2Editor(editorModel, (BTSModelAnnotation)a, pos, issue);
        if (monitor != null)
        {
            monitor.worked(1);
        }
    }

}
项目:eclipse-wtp-json    文件:SyntaxQuickAssistProcessor.java   
public boolean canFix(Annotation annotation) {
        boolean result = false;

//      switch (fProblemId) {
//          case ProblemIDsXML.EmptyTag :
//          case ProblemIDsXML.MissingEndTag :
//          case ProblemIDsXML.AttrsInEndTag :
//          case ProblemIDsXML.MissingAttrValue :
//          case ProblemIDsXML.NoAttrValue :
//          case ProblemIDsXML.SpacesBeforeTagName :
//          case ProblemIDsXML.SpacesBeforePI :
//          case ProblemIDsXML.NamespaceInPI :
//          case ProblemIDsXML.UnknownElement :
//          case ProblemIDsXML.UnknownAttr :
//          case ProblemIDsXML.InvalidAttrValue :
//          case ProblemIDsXML.MissingRequiredAttr :
//          case ProblemIDsXML.AttrValueNotQuoted :
//          case ProblemIDsXML.MissingClosingBracket :
//              result = true;
//      }

        return result;
    }
项目:bts    文件:CommentDrawingStrategy.java   
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget,
        int offset, int length, Color color) {
    if (gc != null) {

        Rectangle bounds;
        if (length > 0)
            bounds = textWidget.getTextBounds(offset, offset + length - 1);
        else {
            Point loc = textWidget.getLocationAtOffset(offset);
            bounds = new Rectangle(loc.x, loc.y, 1,
                    textWidget.getLineHeight(offset));
        }
        int y = bounds.y + bounds.height + 3;
        gc.setForeground(color);
        gc.setLineWidth(1);
        gc.setLineStyle(SWT.LINE_SOLID);

        gc.drawLine(bounds.x + 1, y, bounds.x + bounds.width - 2, y);

    } else {
        textWidget.redrawRange(offset, length, true);
    }

}
项目:bts    文件:SubtextdrawingStrategy.java   
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget,
        int offset, int length, Color color) {
    if (gc != null) {

        Rectangle bounds;
        if (length > 0)
            bounds = textWidget.getTextBounds(offset, offset + length - 1);
        else {
            Point loc = textWidget.getLocationAtOffset(offset);
            bounds = new Rectangle(loc.x, loc.y, 1,
                    textWidget.getLineHeight(offset));
        }
        int y = bounds.y + bounds.height + 5;
        gc.setForeground(color);
        gc.setLineStyle(SWT.LINE_SOLID);
        gc.setLineWidth(1);
        gc.drawLine(bounds.x + 1, y, bounds.x + bounds.width - 2, y);

    } else {
        textWidget.redrawRange(offset, length, true);
    }

}