[146063] commited for NA
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java
index b17adb0..063e168 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java
@@ -574,14 +574,22 @@
public IWorkbenchContext getHelper( IProject project, IValidator validator ){
if( validator instanceof IValidatorJob ){
- return getHelper( (IValidatorJob)validator );
+ IWorkbenchContext helper = getHelper( (IValidatorJob)validator );
+ if( helper == null ){
+ try{
+ helper = getHelper( project );
+ return helper;
+ }catch (InstantiationException e) {
+ e.printStackTrace();
+ }
+ }
+ return helper;
}
else{
try {
IWorkbenchContext helper = getHelper( project );
return helper;
} catch (InstantiationException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java
index a4e3cfd..9566a7b 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java
@@ -59,9 +59,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
public EnabledValidatorsOperation(IProject project, boolean async) {
this(project, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
@@ -72,9 +72,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
public EnabledValidatorsOperation(IProject project, IWorkbenchContext aWorkbenchContext, boolean async) {
this(project, aWorkbenchContext, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
@@ -85,9 +85,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
public EnabledValidatorsOperation(IProject project, IWorkbenchContext aWorkbenchContext, int ruleGroup, boolean force, boolean async) {
this(project, aWorkbenchContext, ValidatorManager.getManager().getEnabledValidators(project), ruleGroup, force, async);
@@ -99,9 +99,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
public EnabledValidatorsOperation(IProject project, int ruleGroup, boolean force, boolean async) {
this(project, ValidatorManager.getManager().getEnabledValidators(project), ruleGroup, force, async);
@@ -112,9 +112,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
protected EnabledValidatorsOperation(IProject project, Set enabledValidators, boolean async) {
this(project, enabledValidators, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
@@ -126,9 +126,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
protected EnabledValidatorsOperation(IProject project,IWorkbenchContext aWorkbenchContext, Set enabledValidators, boolean async) {
this(project,aWorkbenchContext, enabledValidators, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
@@ -140,9 +140,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
protected EnabledValidatorsOperation(IProject project, Set enabledValidators, int ruleGroup, boolean force, boolean async) {
super(project, force, ruleGroup, async);
@@ -154,9 +154,9 @@
*
* IProject must exist and be open.
*
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
+ * If async is true, the validation will run all validators implementing IValidatorJob interface
+ * in the background validation thread, if async is false, it would run in the main thread.
+ * All validators implementing IValidator interface will run in in the main thread regardless of this flag.
*/
protected EnabledValidatorsOperation(IProject project, IWorkbenchContext aWorkbenchContext, Set enabledValidators, int ruleGroup, boolean force, boolean async) {
super(project,aWorkbenchContext,force, ruleGroup, async);
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ManualValidatorsOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ManualValidatorsOperation.java
index 6acd3ac..35b85d0 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ManualValidatorsOperation.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ManualValidatorsOperation.java
@@ -29,11 +29,11 @@
public class ManualValidatorsOperation extends ValidatorSubsetOperation {
public ManualValidatorsOperation(IProject project) {
- super(project, DEFAULT_FORCE, RegistryConstants.ATT_RULE_GROUP_DEFAULT, false);
+ super(project, DEFAULT_FORCE, RegistryConstants.ATT_RULE_GROUP_DEFAULT, true);
setEnabledValidators(ValidatorManager.getManager().getManualEnabledValidators(project));
}
public ManualValidatorsOperation(IProject project, Object[] changedResources) {
- super(project, shouldForce(changedResources), RegistryConstants.ATT_RULE_GROUP_DEFAULT, false);
+ super(project, shouldForce(changedResources), RegistryConstants.ATT_RULE_GROUP_DEFAULT, true);
setEnabledValidators(ValidatorManager.getManager().getManualEnabledValidators(project));
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java
index 5554976..738ccc7 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java
@@ -259,7 +259,7 @@
ValidatorMetaData[] enabledValidators = prjp.getEnabledFullBuildValidators(true, onlyDependentValidators);
if ((enabledValidators != null) && (enabledValidators.length > 0)) {
Set enabledValidatorsSet = InternalValidatorManager.wrapInSet(enabledValidators);
- EnabledValidatorsOperation op = new EnabledValidatorsOperation(getProject(), enabledValidatorsSet,false);
+ EnabledValidatorsOperation op = new EnabledValidatorsOperation(getProject(), enabledValidatorsSet, true);
op.run(monitor);
}
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationOperation.java
index b72a4ef..50acf02 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationOperation.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationOperation.java
@@ -78,7 +78,7 @@
// the flag.
private static final String DELTA_AS_STRING = "IFileDelta[{0}] '{'{1}'}'"; //$NON-NLS-1$
private static final String COMMA = ", "; //$NON-NLS-1$
- protected static final boolean DEFAULT_ASYNC = false; // For the deprecated
+ protected static final boolean DEFAULT_ASYNC = true; // For the deprecated
// constructors, by
// default the
// operation will not
@@ -835,34 +835,39 @@
HashSet jobValidators = new HashSet();
HashSet validators = new HashSet();
+
iterator = getEnabledValidators().iterator();
- while( iterator.hasNext() ){
- vmd = (ValidatorMetaData) iterator.next();
- try {
- if( vmd.getValidator() instanceof IValidatorJob ){
- try {
- delta = getFileDeltas(reporter.getProgressMonitor(), vmd);
- } catch (CoreException e) {
- e.printStackTrace();
+
+ while( iterator.hasNext() ){
+ vmd = (ValidatorMetaData) iterator.next();
+ try {
+ if( isFork() && vmd.getValidator() instanceof IValidatorJob ){
+ try {
+ delta = getFileDeltas(reporter.getProgressMonitor(), vmd);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ boolean willRun = (isForce() || isValidationNecessary(vmd, delta));
+ if( willRun ){
+ jobValidators.add( vmd );
+ }
+ }else{
+ validators.add( vmd );
}
- boolean willRun = (isForce() || isValidationNecessary(vmd, delta));
- if( willRun ){
- jobValidators.add( vmd );
- }
- }else{
- validators.add( vmd );
+ } catch (InstantiationException e) {
+ Logger.getLogger().logError(e);
+ if (logger.isLoggingLevel(Level.SEVERE)) {
+ LogEntry entry = ValidationPlugin.getLogEntry();
+ entry.setSourceID("ValidationOperation.validate(WorkbenchReporter)"); //$NON-NLS-1$
+ entry.setTargetException(e);
+ logger.write(Level.SEVERE, entry);
+ }
}
- } catch (InstantiationException e) {
- Logger.getLogger().logError(e);
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation.validate(WorkbenchReporter)"); //$NON-NLS-1$
- entry.setTargetException(e);
- logger.write(Level.SEVERE, entry);
- }
}
- }
- launchJobs( jobValidators, reporter );
+ if( jobValidators.size() > 0 ){
+ launchJobs( jobValidators, reporter );
+ }
+
try {
//iterator = getEnabledValidators().iterator();
diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java
index cae3972..140bb28 100644
--- a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java
+++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java
@@ -10,9 +10,21 @@
*******************************************************************************/
package org.eclipse.wst.validation.internal.core;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jem.util.logger.LogEntry;
+import org.eclipse.jem.util.logger.proxy.Logger;
+import org.eclipse.wst.validation.internal.TaskListUtility;
+import org.eclipse.wst.validation.internal.operations.MessageInfo;
+import org.eclipse.wst.validation.internal.operations.ValidatorManager;
+import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidator;
+import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
@@ -86,8 +98,37 @@
if ((helper.getURIs() == null) || (helper.getURIs().length == 0)) {
reporter.removeAllMessages(validator);
}
+ if( validator instanceof IValidatorJob ){
+ ((IValidatorJob)validator).validateInJob(helper, reporter);
+ }else{
+ validator.validate(helper, reporter);
+ }
+ if( validator instanceof IValidatorJob ){
+ //the validators who have implemented IValidatorJob but are running synchronously
+ //would log messages now ...
+ ValidatorManager mgr = ValidatorManager.getManager();
+ final ArrayList list = mgr.getMessages((IValidatorJob)validator);
- validator.validate(helper, reporter);
+ Iterator it = list.iterator();
+ while( it.hasNext() ){
+ MessageInfo info = (MessageInfo)it.next();
+ try {
+ TaskListUtility.addTask( info.getMessageOwnerId(), info.getResource(),
+ info.getLocation(), info.getMsg().getId(), info.getText(),
+ info.getMsg().getSeverity(), info.getTargetObjectName(),
+ info.getMsg().getGroupName(), info.getMsg().getOffset(), info.getMsg().getLength());
+
+ } catch (CoreException exc) {
+ Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
+ if (logger.isLoggingLevel(Level.SEVERE)) {
+ LogEntry entry = ValidationPlugin.getLogEntry();
+ entry.setTargetException(exc);
+ logger.write(Level.SEVERE, entry);
+ }
+ }
+ }
+ mgr.clearMessages( (IValidatorJob)validator );
+ }
validator.cleanup(reporter);
}