Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 308326 | Differences between
and this patch

Collapse All | Expand All

(-)vf2/org/eclipse/wst/validation/Validator.java (+32 lines)
Lines 13-22 Link Here
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.LinkedList;
18
import java.util.List;
19
import java.util.List;
19
import java.util.Map;
20
import java.util.Map;
21
import java.util.Set;
20
import java.util.concurrent.atomic.AtomicBoolean;
22
import java.util.concurrent.atomic.AtomicBoolean;
21
23
22
import org.eclipse.core.resources.IMarker;
24
import org.eclipse.core.resources.IMarker;
Lines 748-753 Link Here
748
		IValidator v = asIValidator();
750
		IValidator v = asIValidator();
749
		if (v == null)return null;
751
		if (v == null)return null;
750
		
752
		
753
		if (shouldSkipValidator(resource, operation))return null;
754
		
751
		try {
755
		try {
752
			IProject project = resource.getProject();
756
			IProject project = resource.getProject();
753
			SummaryReporter reporter = new SummaryReporter(project, monitor);
757
			SummaryReporter reporter = new SummaryReporter(project, monitor);
Lines 783-788 Link Here
783
		return vr;
787
		return vr;
784
	}
788
	}
785
	
789
	
790
791
	private static final String TEST_FIX_STATE_ID = "TestFixStateID"; //$NON-NLS-1$
792
793
		@SuppressWarnings("unchecked")
794
		
795
		//TODO A temporary workaround for the problem of manual validations calling V1 validators too often
796
		private boolean shouldSkipValidator(IResource resource, ValOperation operation) {
797
798
			if (_vmd.isValidateByProject())
799
			{
800
				ValidationState validationState = operation.getState();
801
				Object testFixState = validationState.get(TEST_FIX_STATE_ID);
802
				Set<String> projectsNameSet = null;
803
				String projectName = resource.getProject().getName();
804
805
				if (testFixState == null) {
806
					projectsNameSet = new HashSet<String>();
807
					validationState.put(TEST_FIX_STATE_ID, projectsNameSet);
808
				} else {
809
					projectsNameSet = (Set<String>) testFixState;
810
				}
811
812
				if (projectsNameSet.contains(projectName))return true;
813
				else projectsNameSet.add(projectName);
814
			}
815
			return false;
816
		}
817
786
	/*
818
	/*
787
	 * GRK - Because I didn't want to try to make a true copy of the V1 validator, (because I didn't
819
	 * GRK - Because I didn't want to try to make a true copy of the V1 validator, (because I didn't
788
	 * want to copy the vmd object), I came up with this approach to only copy the fields that
820
	 * want to copy the vmd object), I came up with this approach to only copy the fields that
(-)xsds/validatorExtSchema.exsd (+13 lines)
Lines 56-61 Link Here
56
            <element ref="markerId" minOccurs="0" maxOccurs="1"/>
56
            <element ref="markerId" minOccurs="0" maxOccurs="1"/>
57
            <element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
57
            <element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
58
            <element ref="contentTypeBinding" minOccurs="0" maxOccurs="unbounded"/>
58
            <element ref="contentTypeBinding" minOccurs="0" maxOccurs="unbounded"/>
59
            <element ref="runStrategy"/>
59
         </sequence>
60
         </sequence>
60
         <attribute name="to" type="string">
61
         <attribute name="to" type="string">
61
            <annotation>
62
            <annotation>
Lines 284-289 Link Here
284
      </complexType>
285
      </complexType>
285
   </element>
286
   </element>
286
287
288
   <element name="runStrategy">
289
      <complexType>
290
         <attribute name="project" type="boolean">
291
            <annotation>
292
               <documentation>
293
                  
294
               </documentation>
295
            </annotation>
296
         </attribute>
297
      </complexType>
298
   </element>
299
287
   <annotation>
300
   <annotation>
288
      <appInfo>
301
      <appInfo>
289
         <meta.section type="since"/>
302
         <meta.section type="since"/>
(-)validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java (-1 / +20 lines)
Lines 1221-1227 Link Here
1221
				getIncremental(element), getFullBuild(element), element, helperImplName, getMigrationMetaData(element),
1221
				getIncremental(element), getFullBuild(element), element, helperImplName, getMigrationMetaData(element),
1222
				pluginId, getRuleGroup(element), runChildren[0], validatorName.intern(), validatorImplName.intern(),
1222
				pluginId, getRuleGroup(element), runChildren[0], validatorName.intern(), validatorImplName.intern(),
1223
				getContentTypeBindings(element), getDependentValidatorValue(element), getEnablementElement(element),
1223
				getContentTypeBindings(element), getDependentValidatorValue(element), getEnablementElement(element),
1224
				getFacetIds(element), getFilters(element), getProjectNatureFilters(element), markerIds);
1224
				getFacetIds(element), getFilters(element), getProjectNatureFilters(element), markerIds, getRunStragety(element));
1225
		
1225
		
1226
		
1226
		
1227
		if (Tracing.isTraceV1()) {
1227
		if (Tracing.isTraceV1()) {
Lines 1349-1353 Link Here
1349
			return vmd.getValidator();
1349
			return vmd.getValidator();
1350
		return null;
1350
		return null;
1351
	}
1351
	}
1352
	/**
1353
	 * Given an IConfigurationElement from plugin.xml, return whether or not the validator is called by project
1354
	 * 
1355
	 * If no project attribute is specified, the default is false (validator is called by resource)
1356
	 */
1357
	private boolean getRunStragety(IConfigurationElement element) {
1358
		
1359
		IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_STRAGETY);
1360
		
1361
		if ((runChildren == null) || (runChildren.length < 1)) return RegistryConstants.ATT_PROJECT_DEFAULT;
1362
		String project = runChildren[0].getAttribute(ATT_PROJECT);
1363
		if (project == null) {
1364
			return RegistryConstants.ATT_PROJECT_DEFAULT;
1365
		}
1366
1367
		return Boolean.valueOf(project.trim().toLowerCase()).booleanValue(); 
1368
	
1369
	}
1370
	
1352
1371
1353
}
1372
}
(-)validate/org/eclipse/wst/validation/internal/RegistryConstants.java (+13 lines)
Lines 54-59 Link Here
54
	 * only one validator may use an aggregate of that type. */
54
	 * only one validator may use an aggregate of that type. */
55
	String TAG_AGGREGATE_VALIDATORS = "aggregateValidator"; //$NON-NLS-1$ 
55
	String TAG_AGGREGATE_VALIDATORS = "aggregateValidator"; //$NON-NLS-1$ 
56
56
57
	/** runStragety - identifies the run stragety of  Validator*/
58
	String TAG_RUN_STRAGETY = "runStrategy"; //$NON-NLS-1$
59
	
57
	/** objectClass - identifies a type */ 
60
	/** objectClass - identifies a type */ 
58
	String ATT_OBJECT_CLASS = "objectClass"; //$NON-NLS-1$
61
	String ATT_OBJECT_CLASS = "objectClass"; //$NON-NLS-1$
59
	
62
	
Lines 119-124 Link Here
119
	/** false - The "can validator run asynchronously" default. In the future this may be changed to true. */
122
	/** false - The "can validator run asynchronously" default. In the future this may be changed to true. */
120
	boolean ATT_ASYNC_DEFAULT = false;
123
	boolean ATT_ASYNC_DEFAULT = false;
121
124
125
	/** 
126
	 * project - identifies whether or not the validator is called per project. 
127
	 * Default is false (i.e., validator is called per resource). 
128
	 */
129
	String ATT_PROJECT = "project"; //$NON-NLS-1$
130
	
131
	/** false - The project default. */
132
	boolean ATT_PROJECT_DEFAULT = false;
133
	
134
	
122
	/** migrate - the "migrate" section of the validator */
135
	/** migrate - the "migrate" section of the validator */
123
	String TAG_MIGRATE = "migrate"; //$NON-NLS-1$
136
	String TAG_MIGRATE = "migrate"; //$NON-NLS-1$
124
	
137
	
(-)validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java (-1 / +8 lines)
Lines 78-90 Link Here
78
	private final Map<IValidatorJob, IWorkbenchContext> _helpers = 
78
	private final Map<IValidatorJob, IWorkbenchContext> _helpers = 
79
		Collections.synchronizedMap( new HashMap<IValidatorJob, IWorkbenchContext>() );
79
		Collections.synchronizedMap( new HashMap<IValidatorJob, IWorkbenchContext>() );
80
	private final Expression 		_enablementExpression;
80
	private final Expression 		_enablementExpression;
81
	private boolean _validateByProject = true;
82
	//
81
83
82
	ValidatorMetaData(boolean async, String[] aggregatedValidators, boolean isEnabledByDefault, boolean supportsIncremental,
84
	ValidatorMetaData(boolean async, String[] aggregatedValidators, boolean isEnabledByDefault, boolean supportsIncremental,
83
			boolean supportsFullBuild, IConfigurationElement helperClassElement, String helperClassName, 
85
			boolean supportsFullBuild, IConfigurationElement helperClassElement, String helperClassName, 
84
			MigrationMetaData migrationMetaData, String pluginId, int ruleGroup, IConfigurationElement validatorClassElement,
86
			MigrationMetaData migrationMetaData, String pluginId, int ruleGroup, IConfigurationElement validatorClassElement,
85
			String validatorDisplayName, String validatorUniqueName, String[] contentTypeIds, boolean dependentValidator,
87
			String validatorDisplayName, String validatorUniqueName, String[] contentTypeIds, boolean dependentValidator,
86
			Expression enablementExpression, String[] facetFilters, ValidatorFilter[] filters,
88
			Expression enablementExpression, String[] facetFilters, ValidatorFilter[] filters,
87
			ValidatorNameFilter[] projectNatureFilters, String[] markerIds) {
89
			ValidatorNameFilter[] projectNatureFilters, String[] markerIds, boolean onProject) {
88
		_async = async;
90
		_async = async;
89
		_aggregatedValidators = aggregatedValidators;
91
		_aggregatedValidators = aggregatedValidators;
90
		_isEnabledByDefault = isEnabledByDefault;
92
		_isEnabledByDefault = isEnabledByDefault;
Lines 106-111 Link Here
106
		_projectNatureFilters = projectNatureFilters;
108
		_projectNatureFilters = projectNatureFilters;
107
		_markerIds = markerIds;
109
		_markerIds = markerIds;
108
		_validatorNames = buildValidatorNames();
110
		_validatorNames = buildValidatorNames();
111
		_validateByProject = onProject;
109
	}
112
	}
110
		
113
		
111
	protected String[] getFacetFilters() {
114
	protected String[] getFacetFilters() {
Lines 544-548 Link Here
544
	}
547
	}
545
	return false;
548
	return false;
546
}
549
}
550
551
public boolean isValidateByProject() {
552
	return _validateByProject;
553
}
547
   
554
   
548
}
555
}

Return to bug 308326