Changeset 4037 for devel-tools


Ignore:
Timestamp:
Nov 24, 2008, 8:13:40 PM (12 years ago)
Author:
yura
Message:
  • Write occurrence for vars.
  • Status line for errors.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/editor/RfpEditor.java

    r4036 r4037  
    22
    33import java.util.ArrayList;
     4import java.util.Iterator;
    45
    56import org.eclipse.core.resources.IFile;
     7import org.eclipse.core.resources.IMarker;
    68import org.eclipse.core.resources.IProject;
    79import org.eclipse.core.runtime.CoreException;
     
    1921import org.eclipse.jface.text.source.Annotation;
    2022import org.eclipse.jface.text.source.IAnnotationModel;
     23import org.eclipse.jface.text.source.IAnnotationModelExtension2;
    2124import org.eclipse.jface.text.source.ISourceViewer;
    2225import org.eclipse.jface.util.IPropertyChangeListener;
     
    3538import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
    3639import org.eclipse.ui.texteditor.ChainedPreferenceStore;
     40import org.eclipse.ui.texteditor.MarkerAnnotation;
    3741import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
    3842import org.refal.rfpdt.ast.AstImplem;
    3943import org.refal.rfpdt.ast.AstNode;
     44import org.refal.rfpdt.ast.AstVar;
    4045import org.refal.rfpdt.core.RfpCore;
    4146import org.refal.rfpdt.core.RfpProject;
     
    6772        private final ArrayList<Annotation> annotations = new ArrayList<Annotation>();
    6873
     74        private Annotation getAnnotation(int offset, int length) {
     75            IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
     76            if (model == null)
     77                return null;
     78            Iterator<?> iterator;
     79            if (model instanceof IAnnotationModelExtension2)
     80                iterator = ((IAnnotationModelExtension2)model).getAnnotationIterator(offset, length, true, true);
     81            else
     82                iterator = model.getAnnotationIterator();
     83            while (iterator.hasNext()) {
     84                Annotation annot = (Annotation) iterator.next();
     85                try {
     86                    if (annot.isMarkedDeleted() || !(annot instanceof MarkerAnnotation)
     87                            || !(((MarkerAnnotation) annot).getMarker().isSubtypeOf(IMarker.PROBLEM)))
     88                        continue;
     89                } catch (CoreException e) {
     90                    continue;
     91                }
     92                Position pos = model.getPosition(annot);
     93                if (pos != null && pos.overlapsWith(offset, length))
     94                    return annot;
     95            }
     96            return null;
     97        }
     98
    6999        // public void selectionChanged (IWorkbenchPart part, ISelection selection) {}
    70100
     
    81111                return;
    82112            int offset = textSelection.getOffset();
     113            setStatusLineErrorMessage(null);
     114            setStatusLineMessage(null);
     115            Annotation selectionAnnotation = getAnnotation(textSelection.getOffset(), textSelection.getLength());
     116            if (selectionAnnotation != null)
     117                setStatusLineMessage(selectionAnnotation.getText());
    83118            AstNode[] astNodeList = astInfo.getUses(offset);
    84119            if (astNodeList == null)
     
    92127                    if (!astImplem.pos.rfpResource.equals(astNode.pos.rfpResource))
    93128                        continue;
    94                     Annotation annotation = new Annotation("org.eclipse.jdt.ui.occurrences", false, astNode.toString());
     129                    String annot = "org.eclipse.jdt.ui.occurrences";
     130                    if (astNode instanceof AstVar && ((AstVar) astNode).varDefinition == astNode)
     131                        annot = "org.eclipse.jdt.ui.occurrences.write";
     132                    Annotation annotation = new Annotation(annot, false, astNode.toString());
    95133                    annotations.add(annotation);
    96134                    annotationModel.addAnnotation(annotation, new Position(astNode.pos.charStart, astNode.pos.charEnd
     
    98136                }
    99137            }
    100         }
     138        }       
    101139    }
    102140
Note: See TracChangeset for help on using the changeset viewer.