[jbosstools-commits] JBoss Tools SVN: r43035 - trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Aug 14 21:06:34 EDT 2012


Author: akazakov
Date: 2012-08-14 21:06:33 -0400 (Tue, 14 Aug 2012)
New Revision: 43035

Modified:
   trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java
   trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java
   trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
   trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java
Log:


Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java	2012-08-14 23:33:07 UTC (rev 43034)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AbstractTemporaryAnnotation.java	2012-08-15 01:06:33 UTC (rev 43035)
@@ -41,6 +41,7 @@
 
     private static final int WARNING_LAYER;
     private static final int ERROR_LAYER;
+	private String problemType;
 
     private Map<String, Object> fAttributes = new HashMap<String, Object>();
 
@@ -62,8 +63,9 @@
         }
     }
 
-	public AbstractTemporaryAnnotation(String type, boolean isPersistent, String text, boolean warning) {
+	public AbstractTemporaryAnnotation(String type, String problemType, boolean isPersistent, String text, boolean warning) {
 		super(type, isPersistent, text);
+		this.setProblemType(problemType);
 		this.seveirty = warning?WARNING_LAYER:ERROR_LAYER;
 	}
 
@@ -102,4 +104,12 @@
 	public void setAttribute(String key, Object value) {
 		fAttributes.put(key, value);
 	}
+
+	public String getProblemType() {
+		return problemType;
+	}
+
+	public void setProblemType(String problemType) {
+		this.problemType = problemType;
+	}
 }
\ No newline at end of file

Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java	2012-08-14 23:33:07 UTC (rev 43034)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/DisabledAnnotation.java	2012-08-15 01:06:33 UTC (rev 43035)
@@ -10,6 +10,7 @@
  ******************************************************************************/
 package org.jboss.tools.common.validation;
 
+import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.ui.internal.WorkbenchImages;
 
 /**
@@ -20,8 +21,12 @@
 	private static final String warningPath = WorkbenchImages.ICONS_PATH + "dlcl16/showwarn_tsk.gif";
 	private static final String errorPath = WorkbenchImages.ICONS_PATH + "dlcl16/showerr_tsk.gif";
 
-	public DisabledAnnotation(String type, boolean isPersistent, String text,	boolean warning) {
-		super(type, isPersistent, text, warning);
+	private Annotation overlaidAnnotation = null;
+
+	public DisabledAnnotation(Annotation overlaidAnnotation, String problemType, boolean warning) {
+		super(overlaidAnnotation.getType(), problemType, false, overlaidAnnotation.getText(), warning);
+		this.overlaidAnnotation = overlaidAnnotation;
+		this.markDeleted(true);
 	}
 
 	/*
@@ -41,4 +46,11 @@
 	protected String getErrorIconPath() {
 		return errorPath;
 	}
+
+	/**
+	 * @return the overlaidAnnotation
+	 */
+	public Annotation getOverlaidAnnotation() {
+		return overlaidAnnotation;
+	}
 }
\ No newline at end of file

Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java	2012-08-14 23:33:07 UTC (rev 43034)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java	2012-08-15 01:06:33 UTC (rev 43035)
@@ -269,7 +269,7 @@
 							AbstractMarkerAnnotationModel anModel = ((AbstractMarkerAnnotationModel)model);
 							synchronized (anModel.getLockObject()) {
 								Iterator iterator = anModel.getAnnotationIterator(reference.getStartPosition(), reference.getLength(), true, true);
-								Set<MarkerAnnotation> annotationsToRemove = new HashSet<MarkerAnnotation>();
+								Set<Annotation> annotationsToRemove = new HashSet<Annotation>();
 								Map<Annotation, Position> newAnnotations = new HashMap<Annotation, Position>();
 								while (iterator.hasNext()) {
 									Object o = iterator.next();
@@ -291,12 +291,13 @@
 													}
 												}
 												if(removedProblem) {
-													Annotation newAnnotation = new DisabledAnnotation(annotation.getType(), false, annotation.getText(), marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING) == IMarker.SEVERITY_WARNING);
-													int length = 0; // marker.getAttribute(IMarker.CHAR_END, 0) - offset;
-													Position p = new Position(offset, length);
+													Annotation newAnnotation = new DisabledAnnotation(annotation, type, marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING) == IMarker.SEVERITY_WARNING);
+													Position p = anModel.getPosition(annotation);
 													newAnnotations.put(newAnnotation, p);
+													annotationsToRemove.add(annotation);
+												} else {
+													annotation.markDeleted(true);
 												}
-												annotationsToRemove.add(annotation);
 											} else if("org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor".equals(e.getClass().getName()) && "org.eclipse.jst.jsf.facelet.ui.FaceletValidationMarker".equals(type)) {
 												// Remove WTP's annotations for JBT JSP/XHTML editors.
 												annotationsToRemove.add(annotation);
@@ -304,13 +305,28 @@
 										} catch (CoreException ce) {
 											CommonPlugin.getDefault().logError(ce);
 										}
+									} else if(o instanceof DisabledAnnotation) {
+										DisabledAnnotation annotation = (DisabledAnnotation)o;
+										Position p = anModel.getPosition(annotation);
+										for (Object object : messageArray) {
+											IMessage message = (IMessage)object;
+											if(getMarkerType().equals(annotation.getProblemType()) && message.getOffset() == p.getOffset() && annotation.getText().equals(message.getText())) {
+												annotationsToRemove.add(annotation);
+												Annotation markerAnnotation = annotation.getOverlaidAnnotation();
+												markerAnnotation.markDeleted(true);
+												Position newPossition = new Position(message.getOffset(), message.getLength());
+												newAnnotations.put(markerAnnotation, newPossition);
+												break;
+											}
+										}
+
 									}
 								}
 //								if(!newAnnotations.isEmpty()) {
 //									Annotation[] annotationsToRemoveArray = annotationsToRemove.toArray(new Annotation[annotationsToRemove.size()]);
 //									anModel.replaceAnnotations(annotationsToRemoveArray, newAnnotations);
 //								}
-								for (MarkerAnnotation annotation : annotationsToRemove) {
+								for (Annotation annotation : annotationsToRemove) {
 									anModel.removeAnnotation(annotation);
 								}
 								for (Annotation annotation : newAnnotations.keySet()) {

Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java	2012-08-14 23:33:07 UTC (rev 43034)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationAnnotation.java	2012-08-15 01:06:33 UTC (rev 43035)
@@ -26,8 +26,8 @@
 	 * @param text
 	 * @param warning
 	 */
-	public ValidationAnnotation(String type, boolean isPersistent, String text, boolean warning) {
-		super(type, isPersistent, text, warning);
+	public ValidationAnnotation(String type, String problemType, boolean isPersistent, String text, boolean warning) {
+		super(type, problemType, isPersistent, text, warning);
 	}
 
 	/* (non-Javadoc)



More information about the jbosstools-commits mailing list