New API to replace annotations
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
index e813e89..5a040bd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
@@ -92,6 +92,53 @@
 		}
 	}
 
+	/*
+	 * @see IAnnotationModelExtension#replaceAnnotations(Annotation[], Map)
+	 * @since 3.0
+	 */
+	public void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd) {
+		
+		boolean modelChanged= true;
+		
+		if (annotationsToRemove != null) {
+			for (int i= 0, length= annotationsToRemove.length; i < length; i++) {
+				Annotation annotation= annotationsToRemove[i];
+				if (fAnnotations.containsKey(annotation)) {
+				
+					if (fDocument != null) {
+						Position p= (Position) fAnnotations.get(annotation);
+						fDocument.removePosition(p);
+					}
+					
+					fAnnotations.remove(annotation);
+					
+					modelChanged= true;
+				}
+			}
+		}
+		
+		if (annotationsToAdd != null) {
+			Iterator iter= annotationsToAdd.entrySet().iterator();
+			while (iter.hasNext()) {
+				try {
+					Map.Entry mapEntry= (Map.Entry)iter.next();
+					Annotation annotation= (Annotation)mapEntry.getKey();
+					if (!fAnnotations.containsKey(annotation)) {
+						Position position= (Position)mapEntry.getValue();
+						addPosition(fDocument, position);
+						fAnnotations.put(annotation, position);
+						modelChanged= true;
+					}
+				} catch (BadLocationException e) {
+					// ignore invalid position
+				}
+			}
+		}
+		
+		if (modelChanged)
+			fireModelChanged();
+	}
+	
 	/**
 	 * Adds the given annotation to this model. Associates the 
 	 * annotation with the given position. If requested, all annotation
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
index 3890833..d0ff4de 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
@@ -11,6 +11,8 @@
 
 package org.eclipse.jface.text.source;
 
+import java.util.Map;
+
 
 /**
  * Extends <code>IAnnotationModel</code> with the ability to attach additional annotation models to it.
@@ -45,4 +47,21 @@
 	 * @return an <code>IAnnotationModel</code> attached under <code>key</code>, or <code>null</code>
 	 */
 	IAnnotationModel removeAnnotationModel(Object key);
+
+	/**
+	 * Replaces annotations with new annotations for this annotation model. The new
+	 * annotations are map entries where the annotation is the key and the value is the
+	 * position for the annotation. Each position describes the range covered by the annotation. 
+	 * All registered annotation model listeners are informed about the change (if any).
+	 * If the model is connected to a document, the positions are automatically
+	 * updated on document changes. For each annotation which is already managed by
+	 * this annotation model or is not associated with a valid position in the connected
+	 * document nothing happens.
+	 *
+	 * @param annotationsToRemove the annotations to be removed, may be <code>null</code>
+	 * @param annotationsToAdd the annotations which will be added, may be <code>null</code>
+	 *			each map entry has an <code>Annotation</code> as key and a <code>Position</code> as value
+	 * @throws ClassCastException if one of the map key or values has a wrong type
+	 */
+	void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd) throws ClassCastException;
 }