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

(-)validate/org/eclipse/wst/validation/internal/RegistryConstants.java (-1 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2001, 2007 IBM Corporation and others.
2
 * Copyright (c) 2001, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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
	/** runStrategy - identifies the run strategy of  Validator*/
58
	String TAG_RUN_STRATEGY = "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. the 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/ValidationRegistryReader.java (-2 / +19 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2001, 2009 IBM Corporation and others.
2
 * Copyright (c) 2001, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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
	 * <p>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_STRATEGY);
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)return RegistryConstants.ATT_PROJECT_DEFAULT;
1364
1365
		return Boolean.valueOf(project.trim()); 
1366
	
1367
	}
1368
	
1352
1369
1353
}
1370
}
(-)validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java (-2 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2001, 2008 IBM Corporation and others.
2
 * Copyright (c) 2001, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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;
81
82
82
	ValidatorMetaData(boolean async, String[] aggregatedValidators, boolean isEnabledByDefault, boolean supportsIncremental,
83
	ValidatorMetaData(boolean async, String[] aggregatedValidators, boolean isEnabledByDefault, boolean supportsIncremental,
83
			boolean supportsFullBuild, IConfigurationElement helperClassElement, String helperClassName, 
84
			boolean supportsFullBuild, IConfigurationElement helperClassElement, String helperClassName, 
84
			MigrationMetaData migrationMetaData, String pluginId, int ruleGroup, IConfigurationElement validatorClassElement,
85
			MigrationMetaData migrationMetaData, String pluginId, int ruleGroup, IConfigurationElement validatorClassElement,
85
			String validatorDisplayName, String validatorUniqueName, String[] contentTypeIds, boolean dependentValidator,
86
			String validatorDisplayName, String validatorUniqueName, String[] contentTypeIds, boolean dependentValidator,
86
			Expression enablementExpression, String[] facetFilters, ValidatorFilter[] filters,
87
			Expression enablementExpression, String[] facetFilters, ValidatorFilter[] filters,
87
			ValidatorNameFilter[] projectNatureFilters, String[] markerIds) {
88
			ValidatorNameFilter[] projectNatureFilters, String[] markerIds, boolean validateByProject) {
88
		_async = async;
89
		_async = async;
89
		_aggregatedValidators = aggregatedValidators;
90
		_aggregatedValidators = aggregatedValidators;
90
		_isEnabledByDefault = isEnabledByDefault;
91
		_isEnabledByDefault = isEnabledByDefault;
Lines 106-111 Link Here
106
		_projectNatureFilters = projectNatureFilters;
107
		_projectNatureFilters = projectNatureFilters;
107
		_markerIds = markerIds;
108
		_markerIds = markerIds;
108
		_validatorNames = buildValidatorNames();
109
		_validatorNames = buildValidatorNames();
110
		_validateByProject = validateByProject;
109
	}
111
	}
110
		
112
		
111
	protected String[] getFacetFilters() {
113
	protected String[] getFacetFilters() {
Lines 544-548 Link Here
544
	}
546
	}
545
	return false;
547
	return false;
546
}
548
}
549
550
public boolean isValidateByProject() {
551
	return _validateByProject;
552
}
547
   
553
   
548
}
554
}
(-)xsds/validatorExtSchema.exsd (-34 / +24 lines)
Lines 1-6 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.validation">
3
<schema targetNamespace="org.eclipse.wst.validation" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.wst.validation" id="validator" name="Validator"/>
6
         <meta.schema plugin="org.eclipse.wst.validation" id="validator" name="Validator"/>
Lines 13-18 Link Here
13
   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
13
   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
14
14
15
   <element name="extension">
15
   <element name="extension">
16
      <annotation>
17
         <appInfo>
18
            <meta.element />
19
         </appInfo>
20
      </annotation>
16
      <complexType>
21
      <complexType>
17
         <sequence>
22
         <sequence>
18
            <element ref="validator"/>
23
            <element ref="validator"/>
Lines 49-61 Link Here
49
         <sequence>
54
         <sequence>
50
            <element ref="projectNature" minOccurs="0" maxOccurs="unbounded"/>
55
            <element ref="projectNature" minOccurs="0" maxOccurs="unbounded"/>
51
            <element ref="filter" minOccurs="0" maxOccurs="unbounded"/>
56
            <element ref="filter" minOccurs="0" maxOccurs="unbounded"/>
52
            <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>/>
57
            <element ref="enablement" minOccurs="0" maxOccurs="unbounded"/>
53
            <element ref="helper"/>
58
            <element ref="helper"/>
54
            <element ref="dependentValidator" minOccurs="0" maxOccurs="1"/>
59
            <element ref="dependentValidator" minOccurs="0" maxOccurs="1"/>
55
            <element ref="run"/>
60
            <element ref="run"/>
56
            <element ref="markerId" minOccurs="0" maxOccurs="1"/>
61
            <element ref="markerId" minOccurs="0" maxOccurs="1"/>
57
            <element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
62
            <element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
58
            <element ref="contentTypeBinding" minOccurs="0" maxOccurs="unbounded"/>
63
            <element ref="contentTypeBinding" minOccurs="0" maxOccurs="unbounded"/>
64
            <element ref="runStrategy"/>
59
         </sequence>
65
         </sequence>
60
         <attribute name="to" type="string">
66
         <attribute name="to" type="string">
61
            <annotation>
67
            <annotation>
Lines 94-108 Link Here
94
         </attribute>
100
         </attribute>
95
      </complexType>
101
      </complexType>
96
   </element>
102
   </element>
97
   
103
98
   
99
   <element name="contentTypeBinding">
104
   <element name="contentTypeBinding">
100
      <annotation>
105
      <annotation>
101
         <appInfo>
106
         <appInfo>
102
            <meta.element labelAttribute="contentTypeId"/>
107
            <meta.element labelAttribute="contentTypeId"/>
103
         </appInfo>
108
         </appInfo>
104
         <documentation>
109
         <documentation>
105
                        Associates a particular content type with the current validator, and enables the validator to be run on resources of the specified content type.
110
            Associates a particular content type with the current validator, and enables the validator to be run on resources of the specified content type.
106
         </documentation>
111
         </documentation>
107
      </annotation>
112
      </annotation>
108
      <complexType>
113
      <complexType>
Lines 115-123 Link Here
115
         </attribute>
120
         </attribute>
116
      </complexType>
121
      </complexType>
117
   </element>
122
   </element>
118
   
119
   
120
   
121
123
122
   <element name="filter">
124
   <element name="filter">
123
      <complexType>
125
      <complexType>
Lines 284-289 Link Here
284
      </complexType>
286
      </complexType>
285
   </element>
287
   </element>
286
288
289
   <element name="runStrategy">
290
      <complexType>
291
         <attribute name="project" type="boolean">
292
            <annotation>
293
               <documentation>
294
                  If true then the validator is only called once per project. If false (or missing) then the validator could be called once per resource (based on the other filter rules).
295
               </documentation>
296
            </annotation>
297
         </attribute>
298
      </complexType>
299
   </element>
300
301
287
   <annotation>
302
   <annotation>
288
      <appInfo>
303
      <appInfo>
289
         <meta.section type="since"/>
304
         <meta.section type="since"/>
Lines 293-331 Link Here
293
      </documentation>
308
      </documentation>
294
   </annotation>
309
   </annotation>
295
310
296
   <annotation>
297
      <appInfo>
298
         <meta.section type="examples"/>
299
      </appInfo>
300
      <documentation>
301
         
302
      </documentation>
303
   </annotation>
304
311
305
   <annotation>
306
      <appInfo>
307
         <meta.section type="apiInfo"/>
308
      </appInfo>
309
      <documentation>
310
         
311
      </documentation>
312
   </annotation>
313
314
   <annotation>
315
      <appInfo>
316
         <meta.section type="implementation"/>
317
      </appInfo>
318
      <documentation>
319
         
320
      </documentation>
321
   </annotation>
322
312
323
   <annotation>
313
   <annotation>
324
      <appInfo>
314
      <appInfo>
325
         <meta.section type="copyright"/>
315
         <meta.section type="copyright"/>
326
      </appInfo>
316
      </appInfo>
327
      <documentation>
317
      <documentation>
328
         Copyright (c) 2005 IBM Corporation and others.&lt;br&gt;
318
         Copyright (c) 2005, 2010 IBM Corporation and others.&lt;br&gt;
329
All rights reserved. This program and the accompanying materials are made 
319
All rights reserved. This program and the accompanying materials are made 
330
available under the terms of the Eclipse Public License v1.0 which accompanies 
320
available under the terms of the Eclipse Public License v1.0 which accompanies 
331
this distribution, and is available at &lt;a
321
this distribution, and is available at &lt;a
(-)vf2/org/eclipse/wst/validation/Validator.java (-1 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
2
 * Copyright (c) 2007, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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 VALIDATE_PROJECT_ONCE = "ValidateProjectOnce"; //$NON-NLS-1$
792
793
		@SuppressWarnings("unchecked")	
794
		private boolean shouldSkipValidator(IResource resource, ValOperation operation) {
795
796
			if (_vmd.isValidateByProject())
797
			{
798
				ValidationState validationState = operation.getState();
799
				Set<String> projectsNameSet = (Set<String>)validationState.get(VALIDATE_PROJECT_ONCE);
800
				String projectName = resource.getProject().getName();
801
802
				if (projectsNameSet == null) {
803
					projectsNameSet = new HashSet<String>();
804
					validationState.put(VALIDATE_PROJECT_ONCE, projectsNameSet);
805
				}
806
807
				if (projectsNameSet.contains(projectName))return true;
808
				else projectsNameSet.add(projectName);
809
			}
810
			return false;
811
		}
812
786
	/*
813
	/*
787
	 * GRK - Because I didn't want to try to make a true copy of the V1 validator, (because I didn't
814
	 * 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
815
	 * want to copy the vmd object), I came up with this approach to only copy the fields that

Return to bug 308326