[367856] [validation] Track javascript dependencies for validation in HTML
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java
index 0186a71..6eb852a 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/preferences/HTMLCorePreferenceInitializer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 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
@@ -81,7 +81,7 @@
 		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_DUPLICATE, ValidationMessage.WARNING);
 		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_VALUE_MISMATCH, ValidationMessage.ERROR);
 		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_VALUE_UNCLOSED, ValidationMessage.WARNING);
-		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_VALUE_RESOURCE_NOT_FOUND, ValidationMessage.IGNORE);
+		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_VALUE_RESOURCE_NOT_FOUND, ValidationMessage.WARNING);
 		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_OBSOLETE_NAME, ValidationMessage.WARNING);
 		node.putInt(HTMLCorePreferenceNames.ATTRIBUTE_VALUE_EQUALS_MISSING, ValidationMessage.WARNING);
 		
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java
index 272a45b..347db0d 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLAttributeValidator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 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
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.wst.html.core.internal.validate;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
 
@@ -41,6 +42,7 @@
 
 public class HTMLAttributeValidator extends PrimeValidator {
 
+	private static final String JAVASCRIPT_PREFIX = "javascript:"; //$NON-NLS-1$
 	private static final int REGION_NAME = 1;
 	private static final int REGION_VALUE = 2;
 	// <<D210422
@@ -210,17 +212,24 @@
 						}
 					}
 					else if (CMDataType.URI.equals(attrType.getDataTypeName())) {
-						// TODO: URI validation?
-						if (false && actualValue.indexOf('#') < 0 && actualValue.indexOf(":/") == -1 && CMUtil.isHTML(edec)) { //$NON-NLS-1$ //$NON-NLS-2$
+						if (actualValue.indexOf('#') < 0 && actualValue.indexOf(":/") < 0 && !actualValue.toLowerCase(Locale.ENGLISH).startsWith(JAVASCRIPT_PREFIX) && CMUtil.isHTML(edec)) { //$NON-NLS-1$ //$NON-NLS-2$
 							IStructuredDocumentRegion start = ((IDOMNode) node).getStartStructuredDocumentRegion();
+							// roundabout start tag check
 							if (start != null && start.getFirstRegion().getTextLength() == 1) {
-								IPath basePath = new Path(((IDOMNode) node).getModel().getBaseLocation());
-								if (basePath.segmentCount() > 1) {
-									IPath path = ModuleCoreSupport.resolve(basePath, actualValue);
-									IResource found = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
-									if (found == null || !found.isAccessible()) {
-										rgnType = REGION_VALUE;
-										state = ErrorState.RESOURCE_NOT_FOUND;
+								// only check when we have a way to set dependencies
+								Collection dependencies = (Collection) ((IDOMNode) node).getOwnerDocument().getUserData(HTMLValidationAdapterFactory.DEPENDENCIES);
+								if (dependencies != null) {
+									IPath basePath = new Path(((IDOMNode) node).getModel().getBaseLocation());
+									if (basePath.segmentCount() > 1) {
+										IPath path = ModuleCoreSupport.resolve(basePath, actualValue);
+										IResource found = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+										if (found == null) {
+											rgnType = REGION_VALUE;
+											state = ErrorState.RESOURCE_NOT_FOUND;
+										}
+										else {
+											dependencies.add(found);
+										}
 									}
 								}
 							}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLValidationAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLValidationAdapterFactory.java
index 1010e04..061574d 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLValidationAdapterFactory.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validate/HTMLValidationAdapterFactory.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 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
@@ -23,6 +23,8 @@
 
 	private static HTMLValidationAdapterFactory instance = null;
 
+	public static final String DEPENDENCIES = "org.eclipse.wst.html.validator.dependencies"; //$NON-NLS-1$
+
 	/**
 	 * HTMLValidationAdapterFactory constructor comment.
 	 */
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidator.java
index 55bc125..147f0b6 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidator.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/validation/HTMLValidator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2001, 2011 IBM Corporation and others.
+ * Copyright (c) 2001, 2012 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
@@ -13,6 +13,8 @@
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 
 import org.eclipse.core.resources.IContainer;
@@ -268,7 +270,7 @@
 					Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, resource.getFullPath().toString()
 							.substring(1));
 					reporter.displaySubtask(this, message);
-					validateFile(helper, reporter, (IFile) resource);
+					validateFile(helper, reporter, (IFile) resource, null);
 				}
 				else if (resource instanceof IContainer) {
 					validateContainer(helper, reporter, (IContainer) resource);
@@ -296,13 +298,14 @@
 			IResource resource = getResource(delta);
 			if (resource == null || !(resource instanceof IFile))
 				continue;
-			validateFile(helper, reporter, (IFile) resource);
+			validateFile(helper, reporter, (IFile) resource, null);
 		}
 	}
 
 	/**
+	 * @param result 
 	 */
-	private void validateFile(IValidationContext helper, IReporter reporter, IFile file) {
+	private void validateFile(IValidationContext helper, IReporter reporter, IFile file, ValidationResult result) {
 		if ((reporter != null) && (reporter.isCancelled() == true)) {
 			throw new OperationCanceledException();
 		}
@@ -314,7 +317,16 @@
 			return;
 
 		try {
+			Collection dependencies = null;
+			if (result != null) {
+				dependencies = new HashSet();
+				model.getDocument().setUserData(HTMLValidationAdapterFactory.DEPENDENCIES, dependencies, null);
+			}
 			validate(reporter, file, model);
+			if (result != null) {
+				model.getDocument().setUserData(HTMLValidationAdapterFactory.DEPENDENCIES, null, null);
+				result.setDependsOn((IResource[]) dependencies.toArray(new IResource[dependencies.size()]));
+			}
 		}
 		finally {
 			releaseModel(model);
@@ -382,7 +394,7 @@
 			return null;
 		ValidationResult result = new ValidationResult();
 		IReporter reporter = result.getReporter(monitor);
-		validateFile(null, reporter, (IFile) resource);
+		validateFile(null, reporter, (IFile) resource, result);
 		return result;
 	}
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
index 9186cce..e3db43c 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2012 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
@@ -174,8 +174,7 @@
 		addComboBox(inner, label, HTMLCorePreferenceNames.ATTRIBUTE_VALUE_EQUALS_MISSING, SEVERITIES, errorWarningIgnoreLabel, 0);
 		
 		label = HTMLUIMessages.HTMLValidationPreferencePage_35;
-		// TODO: validate resources?
-		// addComboBox(inner, label, HTMLCorePreferenceNames.ATTRIBUTE_VALUE_RESOURCE_NOT_FOUND, SEVERITIES, errorWarningIgnoreLabel, 0);
+		 addComboBox(inner, label, HTMLCorePreferenceNames.ATTRIBUTE_VALUE_RESOURCE_NOT_FOUND, SEVERITIES, errorWarningIgnoreLabel, 0);
 
 		// End Attribute section