Examples of IAnnotationModel


Examples of org.eclipse.jface.text.source.IAnnotationModel

    public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext context) {
        List<ICompletionProposal> proposals = new LinkedList<ICompletionProposal>();

        ISourceViewer viewer = context.getSourceViewer();
        IDocument document = viewer.getDocument();
        IAnnotationModel model = viewer.getAnnotationModel();

        @SuppressWarnings("rawtypes")
        Iterator iter = model.getAnnotationIterator();
        while (iter.hasNext()) {
            Annotation annotation = (Annotation) iter.next();
            if (annotation instanceof MarkerAnnotation && canFix(annotation)) {
                Position position = model.getPosition(annotation);
                if (isAtPosition(context.getOffset(), position)) {
                    IMarker marker = ((MarkerAnnotation) annotation).getMarker();
                    String errorType = marker.getAttribute("$bndType", null);
                    if (errorType != null) {
                        BuildErrorDetailsHandler handler = BuildErrorDetailsHandlers.INSTANCE.findHandler(errorType);
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

        List<ICompletionProposal> proposals = new LinkedList<ICompletionProposal>();

        ISourceViewer viewer = context.getSourceViewer();
        @SuppressWarnings("unused")
        IDocument document = viewer.getDocument();
        IAnnotationModel model = viewer.getAnnotationModel();

        @SuppressWarnings("rawtypes")
        Iterator iter = model.getAnnotationIterator();
        while (iter.hasNext()) {
            Annotation annotation = (Annotation) iter.next();
            if (annotation instanceof MarkerAnnotation && canFix(annotation)) {
                Position position = model.getPosition(annotation);
                if (isAtPosition(context.getOffset(), position)) {
                    IMarker marker = ((MarkerAnnotation) annotation).getMarker();
                    String errorType = marker.getAttribute("$bndType", null);
                    if (errorType != null) {
                        BuildErrorDetailsHandler handler = BuildErrorDetailsHandlers.INSTANCE.findHandler(errorType);
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

     * or <code>null</code> if none.
     *
     * @return breakpoint associated with activity in the ruler or <code>null</code>
     */
    protected IBreakpoint getBreakpoint() {
        IAnnotationModel annotationModel = fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
        IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
        if (annotationModel != null) {
            Iterator iterator = annotationModel.getAnnotationIterator();
            while (iterator.hasNext()) {
                Object object = iterator.next();
                if (object instanceof SimpleMarkerAnnotation) {
                    SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object;
                    IMarker marker = markerAnnotation.getMarker();
                    try {
                        if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
                            Position position = annotationModel.getPosition(markerAnnotation);
                            int line = document.getLineOfOffset(position.getOffset());
                            if (line == fRulerInfo.getLineOfLastMouseButtonActivity()) {
                                IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
                                if (breakpoint != null) {
                                    return breakpoint;
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

   */
  private List getMarkersForLine(int aLine) {
   
    markers = new ArrayList();
    IDocumentProvider provider= editor.getDocumentProvider();
    IAnnotationModel model= provider.getAnnotationModel(editor.getEditorInput());

    if (model != null) {
      Iterator e = model.getAnnotationIterator();
      while (e.hasNext()) {
        Object o = e.next();
        if (o instanceof MarkerAnnotation) {
          MarkerAnnotation a = (MarkerAnnotation) o;
          try {
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

        String expected = readFile(outFile);
        PerlEditor editor = openEditor(inFile);
       
        try
        {
            IAnnotationModel model = (IAnnotationModel)
                editor.getAdapter(ProjectionAnnotationModel.class);
           
            List lines = new ArrayList();
            for (Iterator i = model.getAnnotationIterator(); i.hasNext();)
            {
                Annotation a = (Annotation) i.next();
                Position p = model.getPosition(a);
               
                StringBuffer buf = new StringBuffer();
                buf.append(p.getOffset());
                buf.append(':');
                buf.append(p.getLength());
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

        {
            view = (ExplainErrorsView) findView(VIEW_ID);
            if (view != null) closeView(view);
           
            IVerticalRuler ruler = testIface.getVerticalRuler();
            IAnnotationModel model = ruler.getModel();
           
            IMarker marker = getErrorMarker(model);
            assertNotNull(marker);

            editor.addRulerContextMenuListener(new PopupActionRunner(ACTION_ID));
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

        final IDocumentProvider documentProvider = editor.getDocumentProvider();
        if (documentProvider == null) {
            return;
        }

        final IAnnotationModel annotationModel = documentProvider
                .getAnnotationModel(editor.getEditorInput());
        if (annotationModel == null || fOccurrenceAnnotations == null) {
            return;
        }

        synchronized (editor.getLockObject(annotationModel)) {
            if (annotationModel instanceof IAnnotationModelExtension) {
                ((IAnnotationModelExtension) annotationModel).replaceAnnotations(
                        fOccurrenceAnnotations, null);
            } else {
                for (int i = 0, length = fOccurrenceAnnotations.length; i < length; i++) {
                    annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
                }
            }
            fOccurrenceAnnotations = null;
        }
    }
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

            final IDocumentProvider documentProvider = editor.getDocumentProvider();
            if (documentProvider == null) {
                return Status.CANCEL_STATUS;
            }

            final IAnnotationModel annotationModel = documentProvider
                    .getAnnotationModel(editor.getEditorInput());
            if (annotationModel == null) {
                return Status.CANCEL_STATUS;
            }

            // Add occurrence annotations
            final HashMap<Annotation, Position> annotationMap = new HashMap<Annotation, Position>(
                    fRefs.size());
            for (final MarkOccurencesSupport.ErlangRef ref : fRefs) {
                if (isCanceled(progressMonitor)) {
                    return Status.CANCEL_STATUS;
                }

                final Position position = new Position(ref.getOffset(), ref.getLength());

                final String description = ref.getDescription();
                final String annotationType = ref.isDef() ? "org.erlide.ui.occurrences.definition" //$NON-NLS-1$
                        : "org.erlide.ui.occurrences";

                annotationMap.put(new Annotation(annotationType, false, description),
                        position);
            }

            if (isCanceled(progressMonitor)) {
                return Status.CANCEL_STATUS;
            }

            synchronized (editor.getLockObject(annotationModel)) {
                if (annotationModel instanceof IAnnotationModelExtension) {
                    ((IAnnotationModelExtension) annotationModel).replaceAnnotations(
                            editor.markOccurencesHandler.fOccurrenceAnnotations,
                            annotationMap);
                } else {
                    editor.markOccurencesHandler.removeOccurrenceAnnotations();
                    for (final Map.Entry<Annotation, Position> mapEntry : annotationMap
                            .entrySet()) {
                        annotationModel.addAnnotation(mapEntry.getKey(),
                                mapEntry.getValue());
                    }
                }
                editor.markOccurencesHandler.fOccurrenceAnnotations = annotationMap
                        .keySet().toArray(new Annotation[annotationMap.keySet().size()]);
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

        if (currentEditor.getTitle().equals(fileName)
                && currentEditor instanceof ITextEditor) {

            final ITextEditor editor = (ITextEditor) currentEditor;
            final IAnnotationModel annMod = editor.getDocumentProvider()
                    .getAnnotationModel(editor.getEditorInput());

            final Set<LineResult> list = coverage.getLineSet(editor.getTitle());

            for (final LineResult lr : list) {

                if (lr.getLineNum() < start || end != -1 && lr.getLineNum() > end) {
                    continue;
                }

                log.info(lr.getLineNum());
                if (coverage.containsAnnotation(editor.getTitle(), lr)) {
                    final Annotation ann = coverage.getAnnotation(editor.getTitle(), lr);
                    annMod.removeAnnotation(ann);
                    coverage.removeAnnotation(editor.getTitle(), lr);
                }
            }
        }
    }
View Full Code Here

Examples of org.eclipse.jface.text.source.IAnnotationModel

    private void markLine(final ITextEditor editor, final LineResult lr) {

        final IDocument doc = editor.getDocumentProvider().getDocument(
                editor.getEditorInput());

        final IAnnotationModel annMod = editor.getDocumentProvider().getAnnotationModel(
                editor.getEditorInput());

        log.info("mark line " + lr.getLineNum());

        try {

            final IRegion reg = doc.getLineInformation(lr.getLineNum() - 1);
            final int length = reg.getLength();
            final int offset = reg.getOffset();
            final Position pos = new Position(offset, length);

            Annotation annotation;
            if (lr.called()) {
                annotation = CoverageAnnotationFactory
                        .create(CoverageTypes.FULL_COVERAGE);
            } else {
                annotation = CoverageAnnotationFactory.create(CoverageTypes.NO_COVERAGE);
            }

            final Annotation lastAnn = coverage.getAnnotation(editor.getTitle(), lr);

            log.info(lastAnn);

            if (lastAnn == null) {
                annMod.addAnnotation(annotation, pos);
                coverage.addAnnotation(editor.getTitle(), lr, annotation);
            } else if (annMod.getPosition(lastAnn) == null) {
                annMod.addAnnotation(lastAnn, pos);
            } else if (lastAnn.getType().equals(CoverageTypes.NO_COVERAGE)
                    && annotation.getType().equals(CoverageTypes.FULL_COVERAGE)) {

                annMod.removeAnnotation(lastAnn);
                annMod.addAnnotation(annotation, pos);
                coverage.addAnnotation(editor.getTitle(), lr, annotation);
            }

        } catch (final BadLocationException e) {
            log.error(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.