[136447] XML validator gets called whenever an XSD file is validated
diff --git a/bundles/org.eclipse.wst.sse.ui/.options b/bundles/org.eclipse.wst.sse.ui/.options
index 34c8ec1..32f2194 100644
--- a/bundles/org.eclipse.wst.sse.ui/.options
+++ b/bundles/org.eclipse.wst.sse.ui/.options
@@ -8,12 +8,12 @@
#org.eclipse.wst.sse.ui.extension.TransferBuilder.debugTime
org.eclipse.wst.sse.ui/transferbuilder/time=false
-org.eclipse.wst.sse.ui/extendedconfigurationbuilder=true
+org.eclipse.wst.sse.ui/extendedconfigurationbuilder=false
#org.eclipse.wst.sse.ui.extension.ExtendedConfigurationBuilder.debugTime
org.eclipse.wst.sse.ui/extendedconfigurationbuilder/time=false
-org.eclipse.wst.sse.ui/extendededitoractionbuilder=true
+org.eclipse.wst.sse.ui/extendededitoractionbuilder=false
#org.eclipse.wst.sse.ui.extension.ExtendedEditorActionBuilder.debugReadTime
org.eclipse.wst.sse.ui/extendededitoractionbuilder/readtime=false
@@ -61,4 +61,6 @@
org.eclipse.wst.sse.ui/preferences-properties=false
-org.eclipse.wst.sse.ui/debug/reconcilerSpelling=false
\ No newline at end of file
+org.eclipse.wst.sse.ui/debug/reconcilerSpelling=false
+
+org.eclipse.wst.sse.ui/debug/reconcilerValidators=false
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java
index 39c56f8..c115211 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java
@@ -1,7 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
package org.eclipse.wst.sse.ui.internal.reconcile;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentDescription;
@@ -12,6 +25,7 @@
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.wst.sse.ui.internal.IReleasable;
+import org.eclipse.wst.sse.ui.internal.Logger;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorBuilder;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorMetaData;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy;
@@ -24,6 +38,9 @@
*/
public class DocumentRegionProcessor extends DirtyRegionProcessor {
+ private static final boolean DEBUG_VALIDATORS = true;// Boolean.TRUE.toString().equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/reconcilerValidators"));
+ // //$NON-NLS-1$
+
/**
* A strategy to use the defined default Spelling service.
*/
@@ -115,9 +132,28 @@
validatorStrategy = new ValidatorStrategy(viewer, contentTypeId);
ValidatorBuilder vBuilder = new ValidatorBuilder();
ValidatorMetaData[] vmds = vBuilder.getValidatorMetaData(SSE_UI_ID);
+ List enabledValidators = new ArrayList(1);
+ /* if any "must" handle this content type, just add them */
+ boolean foundSpecificContentTypeValidators = false;
for (int i = 0; i < vmds.length; i++) {
- if (vmds[i].canHandleContentType(contentTypeId))
- validatorStrategy.addValidatorMetaData(vmds[i]);
+ if (vmds[i].mustHandleContentType(contentTypeId)) {
+ if (DEBUG_VALIDATORS)
+ Logger.log(Logger.INFO, contentTypeId + " using specific validator " + vmds[i].getValidatorId()); //$NON-NLS-1$
+ foundSpecificContentTypeValidators = true;
+ enabledValidators.add(vmds[i]);
+ }
+ }
+ if (!foundSpecificContentTypeValidators) {
+ for (int i = 0; i < vmds.length; i++) {
+ if (vmds[i].canHandleContentType(contentTypeId)) {
+ if (DEBUG_VALIDATORS)
+ Logger.log(Logger.INFO, contentTypeId + " using inherited(?) validator " + vmds[i].getValidatorId()); //$NON-NLS-1$
+ enabledValidators.add(vmds[i]);
+ }
+ }
+ }
+ for (int i = 0; i < enabledValidators.size(); i++) {
+ validatorStrategy.addValidatorMetaData((ValidatorMetaData) enabledValidators.get(i));
}
}
}
@@ -146,7 +182,7 @@
getValidatorStrategy().reconcile(partitions[i], dirty);
}
}
-
+
// single spell-check for everything
if (getSpellcheckStrategy() != null) {
getSpellcheckStrategy().reconcile(dirtyRegion, dirtyRegion);
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java
index b5bc89b..47bcdcb 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2006 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
@@ -34,7 +34,7 @@
* Object that holds information relevant to the creation of a validator for
* the reconciling framework.
*
- * @author pavery
+ * @author pavery,nitind
*/
public class ValidatorMetaData {
private String fClass = null;
@@ -42,7 +42,7 @@
private String fId = null;
private String fScope;
- // a hash map of content type Ids (String) that points to lists of
+ // a hash map of explicitly declared content type Ids (String) that points to lists of
// partition types (List of Strings)
// contentTypeId -> List(paritionType, paritionType, partitionType, ...)
// contentTypeId2 -> List(partitionType, partitionType, ...)
@@ -96,6 +96,11 @@
partitionList.add(partitionType);
}
+ /**
+ * @param contentType
+ * @return whether this validator explicitly declared that it could handle
+ * this content type or any of its parent content types
+ */
public boolean canHandleContentType(String contentType) {
// need to iterate hierarchy
String[] contentHierarchy = calculateParentContentTypeIds(contentType);
@@ -106,6 +111,22 @@
return false;
}
+ /**
+ * @param contentType
+ * @return whether this validator explicitly declared that it could handle
+ * this content type
+ */
+ public boolean mustHandleContentType(String contentType) {
+ return fMatrix.containsKey(contentType);
+ }
+
+ /**
+ * @param contentTypeIds
+ * @param partitionType
+ * @return whether this validator declared that it could handle this
+ * content type, or one of its parent content types, and partition
+ * type
+ */
public boolean canHandlePartitionType(String contentTypeIds[], String paritionType) {
for(int i=0; i<contentTypeIds.length; i++) {
if (fMatrix.containsKey(contentTypeIds[i])) {