[258841] V2 framework always clears markers for dependent resource
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/AbstractValidator.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/AbstractValidator.java
index bda42a5..83c1d55 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/AbstractValidator.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/AbstractValidator.java
@@ -160,6 +160,23 @@
*/
public void validationFinishing(IProject project, ValidationState state, IProgressMonitor monitor){
}
+
+ /**
+ * Should the validation framework first clear the markers that this
+ * validator has placed on this resource? This method can be overridden by
+ * validator implementors to provide a validator specific behavior.
+ *
+ * @param event
+ * The validation event that triggered the validation.
+ * @return true if the validation framework should first clear all the
+ * markers that this validator produced. This is the default
+ * behavior. Return false to leave the markers unchanged. It then
+ * becomes the responsibility of the validator to manage it's own
+ * markers for this resource, for this validation event.
+ */
+ public boolean shouldClearMarkers(ValidationEvent event){
+ return true;
+ }
/**
* Answer the validator that you belong to. The validator controls the
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/Validator.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/Validator.java
index f79cc6d..151317f 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/Validator.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/Validator.java
@@ -208,6 +208,23 @@
}
/**
+ * Should the validation framework first clear the markers that this
+ * validator has placed on this resource? This method can be overridden by
+ * validator implementors to provide a validator specific behavior.
+ *
+ * @param event
+ * The validation event that triggered the validation.
+ * @return true if the validation framework should first clear all the
+ * markers that this validator produced. This is the default
+ * behavior. Return false to leave the markers unchanged. It then
+ * becomes the responsibility of the validator to manage it's own
+ * markers for this resource, for this validation event.
+ */
+ public boolean shouldClearMarkers(ValidationEvent event){
+ return true;
+ }
+
+ /**
* Answer true if this validator, based on it's filters, should validate
* this resource. This method does not check to see if global validation or
* project validation has been suspended or not.
@@ -1014,6 +1031,11 @@
boolean isLoaded() {
return _validator != null;
}
+
+ @Override
+ public boolean shouldClearMarkers(ValidationEvent event) {
+ return getValidator().shouldClearMarkers(event);
+ }
/**
* Answer true if this validator, based on it's filters, should validate this resource.
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValBuilderJob.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValBuilderJob.java
index 5d3ab2b..5ab8edb 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValBuilderJob.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValBuilderJob.java
@@ -189,6 +189,7 @@
}
+ @SuppressWarnings("deprecation")
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if (DisabledResourceManager.getDefault().isDisabled(resource)){
@@ -208,11 +209,12 @@
if (index.isDependedOn(resource)){
MarkerManager mm = MarkerManager.getDefault();
for (DependentResource dr : index.get(resource)){
- if (Friend.shouldValidate(dr.getValidator(), dr.getResource(), ValType.Build, new ContentTypeWrapper())){
- mm.clearMarker(dr.getResource(), dr.getValidator());
+ Validator val = dr.getValidator();
+ if (Friend.shouldValidate(val, dr.getResource(), ValType.Build, new ContentTypeWrapper())){
_request.getOperation().getState().put(ValidationState.TriggerResource, resource);
ValidationEvent event = new ValidationEvent(dr.getResource(), IResourceDelta.NO_CHANGE, delta);
- ValManager.getDefault().validate(dr.getValidator(), _request.getOperation(), dr.getResource(),
+ if (val.shouldClearMarkers(event))mm.clearMarker(dr.getResource(), val);
+ ValManager.getDefault().validate(val, _request.getOperation(), dr.getResource(),
IResourceDelta.NO_CHANGE, _monitor, event);
}
}