updated build.xml
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / CompilationUnitAnnotationModelEvent.java
index 069e68b..56204d3 100644 (file)
@@ -12,39 +12,95 @@ package net.sourceforge.phpeclipse.phpeditor;
 
 
 
-import org.eclipse.core.resources.IResource;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.jface.text.source.AnnotationModelEvent;
 import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+
 
 /**
  * Event sent out by changes of the compilation unit annotation model.
  */
 public class CompilationUnitAnnotationModelEvent  extends AnnotationModelEvent {
        
-       private boolean fIncludesMarkerAnnotationChanges;
+       private boolean fIncludesProblemMarkerAnnotations;
        private IResource fUnderlyingResource;
        
-       
        /**
         * Constructor for CompilationUnitAnnotationModelEvent.
         * @param model
         * @param underlyingResource The annotation model's underlying resource 
-        * @param includesMarkerAnnotationChanges
         */
-       public CompilationUnitAnnotationModelEvent(IAnnotationModel model, IResource underlyingResource, boolean includesMarkerAnnotationChanges) {
+       public CompilationUnitAnnotationModelEvent(IAnnotationModel model, IResource underlyingResource) {
                super(model);
-               fIncludesMarkerAnnotationChanges= includesMarkerAnnotationChanges;
                fUnderlyingResource= underlyingResource;
+               fIncludesProblemMarkerAnnotations= false;
+       }
+       
+       private void testIfProblemMarker(Annotation annotation) {
+               if (fIncludesProblemMarkerAnnotations) {
+                       return;
+               }
+               if (annotation instanceof JavaMarkerAnnotation) {
+                       fIncludesProblemMarkerAnnotations= ((JavaMarkerAnnotation) annotation).isProblem();
+               } else if (annotation instanceof MarkerAnnotation) {
+                       try {
+                               IMarker marker= ((MarkerAnnotation) annotation).getMarker();
+                               if (!marker.exists() || marker.isSubtypeOf(IMarker.PROBLEM)) {
+                                       fIncludesProblemMarkerAnnotations= true;
+                               }
+                       } catch (CoreException e) {
+                               PHPeclipsePlugin.log(e);
+                       }
+               }       
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationAdded(org.eclipse.jface.text.source.Annotation)
+        */
+       public void annotationAdded(Annotation annotation) {
+               super.annotationAdded(annotation);
+               testIfProblemMarker(annotation);
+       }
+
+
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation)
+        */
+       public void annotationRemoved(Annotation annotation) {
+               super.annotationRemoved(annotation);
+               testIfProblemMarker(annotation);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position)
+        */
+       public void annotationRemoved(Annotation annotation, Position position) {
+               super.annotationRemoved(annotation, position);
+               testIfProblemMarker(annotation);
        }
        
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationChanged(org.eclipse.jface.text.source.Annotation)
+        */
+       public void annotationChanged(Annotation annotation) {
+               testIfProblemMarker(annotation);
+               super.annotationChanged(annotation);
+       }
+               
        /**
-        * Returns whether the change included marker annotations.
+        * Returns whether the change included problem marker annotations.
         * 
         * @return <code>true</code> if the change included marker annotations
         */
-       public boolean includesMarkerAnnotationChanges() {
-               return fIncludesMarkerAnnotationChanges;
+       public boolean includesProblemMarkerAnnotationChanges() {
+               return fIncludesProblemMarkerAnnotations;
        }
        
        /**