[340230] - The validator cache should be reset when there is a REMOVED
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 9fd45a7..e40b2ba 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -317,6 +317,12 @@
boolean isChanged = (kind & IResourceDelta.CHANGED) != 0;
if (isChanged && (delta.getFlags() & InterestedFlags) == 0)return true;
+ // Check for file ADDED and REMOVED events, which means that the file may have moved to a new
+ // project. To be safe we clear it's cached list of validators.
+ if (((kind & (IResourceDelta.ADDED | IResourceDelta.REMOVED)) != 0) && resource.getType() == IResource.FILE) {
+ ValManager.getDefault().clearValProperty(resource);
+ }
+
if ((kind & (IResourceDelta.ADDED | IResourceDelta.CHANGED)) != 0){
ValManager.getDefault().validate(_request.getProject(), resource, delta.getKind(), ValType.Build,
_request.getBuildKind(), _operation, _subMonitor.newChild(1));
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java
index a46fdf4..a177c7c 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -921,6 +921,20 @@
_cache.reset(project);
}
+ /**
+ * Clear the validation properties.
+ * @param resource
+ */
+ public void clearValProperty(IResource resource){
+ if (!resource.isAccessible())return;
+ try {
+ resource.setSessionProperty(StatusBuild, null);
+ resource.setSessionProperty(StatusManual, null);
+ }
+ catch (CoreException e) {
+ }
+ }
+
private void putValProperty(ValProperty vp, IResource resource, ValType valType) {
try {
if (!(resource.isAccessible())) return;
@@ -981,7 +995,7 @@
configHasChanged();
}
}
-
+
private final class HasValidatorVisitor implements IResourceVisitor {
private boolean _hasValidator;