*fixes
diff --git a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/IValidator.java b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/IValidator.java
index d715eff..38c4cf6 100644
--- a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/IValidator.java
+++ b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/IValidator.java
@@ -12,6 +12,7 @@
import java.io.OutputStream;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.dltk.core.ISourceModule;
import org.w3c.dom.Document;
@@ -46,4 +47,6 @@
*/
void clean(ISourceModule module);
void clean(IResource resource);
+
+ public void setProgressMonitor(IProgressMonitor monitor);
}
diff --git a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java
index 5c639ba..ac3d11d 100644
--- a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java
+++ b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java
@@ -23,9 +23,11 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.dltk.core.DLTKLanguageManager;
import org.eclipse.dltk.core.IDLTKLanguageToolkit;
import org.eclipse.dltk.core.IModelElement;
@@ -55,7 +57,8 @@
// private static ThreadLocal fgEntryCount = new ThreadLocal(); // Integers
private static Set fgContributedValidators = new HashSet();
-// private static List markerList = new ArrayList();
+
+ // private static List markerList = new ArrayList();
private ValidatorRuntime() {
}
@@ -331,32 +334,43 @@
}
return (IValidator[]) possible.toArray(new IValidator[possible.size()]);
}
-
+
public static IValidator[] getAllValidators() {
List possible = new ArrayList();
IValidatorType[] vals = getValidatorTypes();
for (int i = 0; i < vals.length; i++) {
IValidator[] v = vals[i].getValidators();
- for (int j = 0; j < v.length; j++) {
+ for (int j = 0; j < v.length; j++) {
if (!possible.contains(v[j])) {
possible.add(v[j]);
- }
+ }
}
}
return (IValidator[]) possible.toArray(new IValidator[possible.size()]);
}
public static void executeActiveValidatorsWithConsole(OutputStream stream,
- List elements, List resources) {
+ List elements, List resources, IProgressMonitor monitor) {
IValidator[] activeValidators = getActiveValidators();
- process(stream, elements, resources, activeValidators, processValidate);
+ process(stream, elements, resources, activeValidators, processValidate,
+ monitor);
+ }
+
+ public static void executeActiveValidatorsWithConsole(OutputStream stream,
+ List elements, List resources) {
+ executeActiveValidatorsWithConsole(stream, elements, resources, null);
+ }
+
+ public static void executeAllValidatorsWithConsole(OutputStream stream,
+ List elements, List resources, IProgressMonitor monitor) {
+ IValidator[] activeValidators = getValidValidators();
+ process(stream, elements, resources, activeValidators, processValidate,
+ monitor);
}
public static void executeAllValidatorsWithConsole(OutputStream stream,
List elements, List resources) {
- IValidator[] activeValidators = getValidValidators();
- process(stream, elements, resources, activeValidators, processValidate);
-
+ executeAllValidatorsWithConsole(stream, elements, resources, null);
}
private interface IProcessAction {
@@ -383,7 +397,7 @@
return null;
}
- public IStatus execute(IValidator validator, IResource o,
+ public IStatus execute(IValidator validator, IResource o,
OutputStream out) {
validator.clean(o);
return null;
@@ -391,9 +405,26 @@
};
private static void process(OutputStream stream, List elements,
- List resources, IValidator[] activeValidators, IProcessAction action) {
+ List resources, IValidator[] activeValidators,
+ IProcessAction action, IProgressMonitor monitor) {
+ if (monitor != null) {
+ int len = 0;
+ if (elements != null) {
+ len += (elements.size()) * activeValidators.length;
+ }
+ if (resources != null) {
+ len += (resources.size()) * activeValidators.length;
+ }
+
+ monitor.beginTask("Validating", len);
+ }
if (elements != null) {
for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+ if (monitor != null) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ }
IModelElement el = (IModelElement) iterator.next();
if (el instanceof ISourceModule) {
ISourceModule module = (ISourceModule) el;
@@ -421,6 +452,11 @@
|| nature.equals("#")) {
// IStatus e = v.validate(module, stream);
+ IProgressMonitor sub = null;
+ if (monitor != null) {
+ sub = new SubProgressMonitor(monitor, 1);
+ }
+ v.setProgressMonitor(sub);
IStatus e = action.execute(v, module, stream);
if (e != null) {
if (e.getSeverity() == IStatus.ERROR) {
@@ -434,27 +470,54 @@
}
}
}
+ if (sub != null) {
+ sub.done();
+ }
}
}
}
-
+ // if( mon != null ) {
+ // mon.worked(1);
+ // }
}
}
if (resources != null) {
for (Iterator iterator = resources.iterator(); iterator.hasNext();) {
+ if (monitor != null) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ }
IResource el = (IResource) iterator.next();
for (int i = 0; i < activeValidators.length; i++) {
IValidator v = activeValidators[i];
- // v.validate(el, stream);
+ IProgressMonitor sub = null;
+ if (monitor != null) {
+ sub = new SubProgressMonitor(monitor, 1);
+ }
+ v.setProgressMonitor(sub);
+ v.validate(el, stream);
action.execute(v, el, stream);
+ if (sub != null) {
+ sub.done();
+ }
}
}
}
+ if (monitor != null) {
+ monitor.done();
+ }
}
public static void executeCleanAllValidatorsWithConsole(List elements,
List resources) {
+ executeCleanAllValidatorsWithConsole(elements, resources);
+ }
+
+ public static void executeCleanAllValidatorsWithConsole(List elements,
+ List resources, IProgressMonitor monitor) {
IValidator[] activeValidators = getAllValidators();
- process(null, elements, resources, activeValidators, processClean);
+ process(null, elements, resources, activeValidators, processClean,
+ monitor);
}
}
\ No newline at end of file
diff --git a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/ValidatorBuilder.java b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/ValidatorBuilder.java
index 41a49fd..537a0fd 100644
--- a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/ValidatorBuilder.java
+++ b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/ValidatorBuilder.java
@@ -21,13 +21,13 @@
public IStatus[] buildModelElements(IScriptProject project, List elements,
IProgressMonitor monitor) {
- ValidatorRuntime.executeActiveValidatorsWithConsole(null, elements, null);
+ ValidatorRuntime.executeActiveValidatorsWithConsole(null, elements, null, monitor);
return null;
}
public IStatus[] buildResources(IScriptProject project, List resources,
IProgressMonitor monitor) {
- ValidatorRuntime.executeActiveValidatorsWithConsole(null, null, resources);
+ ValidatorRuntime.executeActiveValidatorsWithConsole(null, null, resources, monitor);
return null;
}
@@ -35,5 +35,4 @@
//We don't provide dependencies here.
return null;
}
-
}
diff --git a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/externalchecker/ExternalChecker.java b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/externalchecker/ExternalChecker.java
index aeff9de..0c34d56 100644
--- a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/externalchecker/ExternalChecker.java
+++ b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/internal/core/externalchecker/ExternalChecker.java
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -369,4 +370,9 @@
public void setExtensions(String scriptPattern) {
this.extensions = scriptPattern;
}
+
+ public void setProgressMonitor(IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+
+ }
}