Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 168441 Details for
Bug 308326
Validation Framework invokes the V1 validators too often
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Use the extension point to allow the validator to specify if the validation is done by Project
patch_extension_point.txt (text/plain), 9.01 KB, created by
Wini Mark
on 2010-05-13 14:57:11 EDT
(
hide
)
Description:
Use the extension point to allow the validator to specify if the validation is done by Project
Filename:
MIME Type:
Creator:
Wini Mark
Created:
2010-05-13 14:57:11 EDT
Size:
9.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.validation >Index: vf2/org/eclipse/wst/validation/Validator.java >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/Validator.java,v >retrieving revision 1.45 >diff -u -r1.45 Validator.java >--- vf2/org/eclipse/wst/validation/Validator.java 29 Sep 2009 21:11:39 -0000 1.45 >+++ vf2/org/eclipse/wst/validation/Validator.java 12 May 2010 19:24:13 -0000 >@@ -13,10 +13,12 @@ > import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; > import java.util.HashMap; >+import java.util.HashSet; > import java.util.Iterator; > import java.util.LinkedList; > import java.util.List; > import java.util.Map; >+import java.util.Set; > import java.util.concurrent.atomic.AtomicBoolean; > > import org.eclipse.core.resources.IMarker; >@@ -748,6 +750,8 @@ > IValidator v = asIValidator(); > if (v == null)return null; > >+ if (shouldSkipValidator(resource, operation))return null; >+ > try { > IProject project = resource.getProject(); > SummaryReporter reporter = new SummaryReporter(project, monitor); >@@ -783,6 +787,34 @@ > return vr; > } > >+ >+ private static final String TEST_FIX_STATE_ID = "TestFixStateID"; //$NON-NLS-1$ >+ >+ @SuppressWarnings("unchecked") >+ >+ //TODO A temporary workaround for the problem of manual validations calling V1 validators too often >+ private boolean shouldSkipValidator(IResource resource, ValOperation operation) { >+ >+ if (_vmd.isValidateByProject()) >+ { >+ ValidationState validationState = operation.getState(); >+ Object testFixState = validationState.get(TEST_FIX_STATE_ID); >+ Set<String> projectsNameSet = null; >+ String projectName = resource.getProject().getName(); >+ >+ if (testFixState == null) { >+ projectsNameSet = new HashSet<String>(); >+ validationState.put(TEST_FIX_STATE_ID, projectsNameSet); >+ } else { >+ projectsNameSet = (Set<String>) testFixState; >+ } >+ >+ if (projectsNameSet.contains(projectName))return true; >+ else projectsNameSet.add(projectName); >+ } >+ return false; >+ } >+ > /* > * GRK - Because I didn't want to try to make a true copy of the V1 validator, (because I didn't > * want to copy the vmd object), I came up with this approach to only copy the fields that >Index: xsds/validatorExtSchema.exsd >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.validation/xsds/validatorExtSchema.exsd,v >retrieving revision 1.20 >diff -u -r1.20 validatorExtSchema.exsd >--- xsds/validatorExtSchema.exsd 21 Jul 2008 10:17:28 -0000 1.20 >+++ xsds/validatorExtSchema.exsd 12 May 2010 19:24:13 -0000 >@@ -56,6 +56,7 @@ > <element ref="markerId" minOccurs="0" maxOccurs="1"/> > <element ref="facet" minOccurs="0" maxOccurs="unbounded"/> > <element ref="contentTypeBinding" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="runStrategy"/> > </sequence> > <attribute name="to" type="string"> > <annotation> >@@ -284,6 +285,18 @@ > </complexType> > </element> > >+ <element name="runStrategy"> >+ <complexType> >+ <attribute name="project" type="boolean"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ > <annotation> > <appInfo> > <meta.section type="since"/> >Index: validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java,v >retrieving revision 1.53 >diff -u -r1.53 ValidationRegistryReader.java >--- validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java 27 Jan 2009 09:25:46 -0000 1.53 >+++ validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java 12 May 2010 19:24:13 -0000 >@@ -1221,7 +1221,7 @@ > getIncremental(element), getFullBuild(element), element, helperImplName, getMigrationMetaData(element), > pluginId, getRuleGroup(element), runChildren[0], validatorName.intern(), validatorImplName.intern(), > getContentTypeBindings(element), getDependentValidatorValue(element), getEnablementElement(element), >- getFacetIds(element), getFilters(element), getProjectNatureFilters(element), markerIds); >+ getFacetIds(element), getFilters(element), getProjectNatureFilters(element), markerIds, getRunStragety(element)); > > > if (Tracing.isTraceV1()) { >@@ -1349,5 +1349,24 @@ > return vmd.getValidator(); > return null; > } >+ /** >+ * Given an IConfigurationElement from plugin.xml, return whether or not the validator is called by project >+ * >+ * If no project attribute is specified, the default is false (validator is called by resource) >+ */ >+ private boolean getRunStragety(IConfigurationElement element) { >+ >+ IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_STRAGETY); >+ >+ if ((runChildren == null) || (runChildren.length < 1)) return RegistryConstants.ATT_PROJECT_DEFAULT; >+ String project = runChildren[0].getAttribute(ATT_PROJECT); >+ if (project == null) { >+ return RegistryConstants.ATT_PROJECT_DEFAULT; >+ } >+ >+ return Boolean.valueOf(project.trim().toLowerCase()).booleanValue(); >+ >+ } >+ > > } >Index: validate/org/eclipse/wst/validation/internal/RegistryConstants.java >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/RegistryConstants.java,v >retrieving revision 1.10 >diff -u -r1.10 RegistryConstants.java >--- validate/org/eclipse/wst/validation/internal/RegistryConstants.java 7 Jun 2007 19:28:36 -0000 1.10 >+++ validate/org/eclipse/wst/validation/internal/RegistryConstants.java 12 May 2010 19:24:13 -0000 >@@ -54,6 +54,9 @@ > * only one validator may use an aggregate of that type. */ > String TAG_AGGREGATE_VALIDATORS = "aggregateValidator"; //$NON-NLS-1$ > >+ /** runStragety - identifies the run stragety of Validator*/ >+ String TAG_RUN_STRAGETY = "runStrategy"; //$NON-NLS-1$ >+ > /** objectClass - identifies a type */ > String ATT_OBJECT_CLASS = "objectClass"; //$NON-NLS-1$ > >@@ -119,6 +122,16 @@ > /** false - The "can validator run asynchronously" default. In the future this may be changed to true. */ > boolean ATT_ASYNC_DEFAULT = false; > >+ /** >+ * project - identifies whether or not the validator is called per project. >+ * Default is false (i.e., validator is called per resource). >+ */ >+ String ATT_PROJECT = "project"; //$NON-NLS-1$ >+ >+ /** false - The project default. */ >+ boolean ATT_PROJECT_DEFAULT = false; >+ >+ > /** migrate - the "migrate" section of the validator */ > String TAG_MIGRATE = "migrate"; //$NON-NLS-1$ > >Index: validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java >=================================================================== >RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java,v >retrieving revision 1.40 >diff -u -r1.40 ValidatorMetaData.java >--- validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java 29 Jul 2009 14:13:04 -0000 1.40 >+++ validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java 12 May 2010 19:24:13 -0000 >@@ -78,13 +78,15 @@ > private final Map<IValidatorJob, IWorkbenchContext> _helpers = > Collections.synchronizedMap( new HashMap<IValidatorJob, IWorkbenchContext>() ); > private final Expression _enablementExpression; >+ private boolean _validateByProject = true; >+ // > > ValidatorMetaData(boolean async, String[] aggregatedValidators, boolean isEnabledByDefault, boolean supportsIncremental, > boolean supportsFullBuild, IConfigurationElement helperClassElement, String helperClassName, > MigrationMetaData migrationMetaData, String pluginId, int ruleGroup, IConfigurationElement validatorClassElement, > String validatorDisplayName, String validatorUniqueName, String[] contentTypeIds, boolean dependentValidator, > Expression enablementExpression, String[] facetFilters, ValidatorFilter[] filters, >- ValidatorNameFilter[] projectNatureFilters, String[] markerIds) { >+ ValidatorNameFilter[] projectNatureFilters, String[] markerIds, boolean onProject) { > _async = async; > _aggregatedValidators = aggregatedValidators; > _isEnabledByDefault = isEnabledByDefault; >@@ -106,6 +108,7 @@ > _projectNatureFilters = projectNatureFilters; > _markerIds = markerIds; > _validatorNames = buildValidatorNames(); >+ _validateByProject = onProject; > } > > protected String[] getFacetFilters() { >@@ -544,5 +547,9 @@ > } > return false; > } >+ >+public boolean isValidateByProject() { >+ return _validateByProject; >+} > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 308326
:
165605
|
168441
|
168905