[214286] Validation status
diff --git a/plugins/org.eclipse.wst.validation.ui/property_files/validate_ui.properties b/plugins/org.eclipse.wst.validation.ui/property_files/validate_ui.properties
index 732a7fb..6819f0a 100644
--- a/plugins/org.eclipse.wst.validation.ui/property_files/validate_ui.properties
+++ b/plugins/org.eclipse.wst.validation.ui/property_files/validate_ui.properties
@@ -83,7 +83,7 @@
VBF_EXC_INTERNAL=IWAE0003E An unexpected error occurred during validation. Read the log file.
VBF_EXC_INTERNAL_PROJECT=IWAE0004E An unexpected error occurred during validation of project {0}. Read the log file.
VBF_EXC_INTERNAL_TITLE=IWAE0005E Internal error
-VBF_EXC_INTERNAL_PAGE=IWAE0006E An unexpected error occured; click Cancel to close the wizard.
+VBF_EXC_INTERNAL_PAGE=IWAE0006E An unexpected error occurred; click Cancel to close the wizard.
VBF_EXC_INVALID_REGISTER=IWAE0007E Validators can run only on open resources.
diff --git a/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ValidationUIMessages.java b/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ValidationUIMessages.java
index 874cfe9..238c083 100644
--- a/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ValidationUIMessages.java
+++ b/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/ValidationUIMessages.java
@@ -26,6 +26,22 @@
public static String PrefPage_always_save;
public static String RunValidationDialogTitle;
public static String UnableToSave;
+
+ public static String ValResultsStatus;
+ public static String ValErrors1;
+ public static String ValErrors;
+ public static String ValWarn1;
+ public static String ValWarn;
+ public static String ValInfo1;
+ public static String ValInfo;
+ public static String ValTime1;
+ public static String ValTime;
+ public static String ValSuccess;
+
+ public static String TimeUnder;
+ public static String TimeSec;
+ public static String TimeMin;
+
static {
// load message values from bundle file
diff --git a/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/validationui.properties b/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/validationui.properties
index 3c29d62..5082c21 100644
--- a/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/validationui.properties
+++ b/plugins/org.eclipse.wst.validation.ui/validateui/org/eclipse/wst/validation/internal/ui/validationui.properties
@@ -19,3 +19,19 @@
RunValidationDialogTitle=Running Validation
UnableToSave=Unable to set save automatically preference in save files for validation dialog:
+ValResultsStatus=Validation Status
+ValErrors1=The validation was not successful, one error was encountered.
+ValErrors=The validation was not successful, {0} errors were encountered.
+ValWarn1=The validation completed with one warning.
+ValWarn=The validation completed with {0} warnings.
+ValInfo1=The validation completed with one informational message.
+ValInfo=The validation completed with {0} informational messages.
+ValSuccess=The validation completed with no errors or warnings.
+ValTime1=One resource was validated in {0}.
+ValTime={0} resources were validated in {1}.
+
+TimeUnder=under a second
+TimeSec={0} seconds
+TimeMin={0} minutes
+
+
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java
index 476fd82..d221e68 100644
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java
+++ b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java
@@ -11,12 +11,11 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.internal.ValOperation;
import org.eclipse.wst.validation.internal.ValidationRunner;
+import org.eclipse.wst.validation.ui.internal.dialog.ResultsDialog;
/**
* Run a manual validation.
@@ -59,7 +58,14 @@
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ long start = System.currentTimeMillis();
final ValOperation vo = ValidationRunner.validate(_projects, _isManual, _isBuild, monitor);
+ final long time = System.currentTimeMillis() - start;
+ int resourceCount = 0;
+ for (Set s : _projects.values()){
+ resourceCount += s.size();
+ }
+ final int finalResourceCount = resourceCount;
if (vo.getResult().isCanceled())return Status.CANCEL_STATUS;
if (_showResults){
@@ -69,18 +75,20 @@
public void run() {
String message = null;
ValidationResult vr = vo.getResult();
- if (vr.getSeverityError() + vr.getSeverityWarning() + vr.getSeverityInfo() == 0){
- message = ValUIMessages.ValidationSuccessful;
- }
- else {
-
- String[] parms = new String[3];
- parms[0] = _nf.format(vr.getSeverityError());
- parms[1] = _nf.format(vr.getSeverityWarning());
- parms[2] = _nf.format(vr.getSeverityInfo());
- message = NLS.bind(ValUIMessages.ErrSummary, parms);
- }
- MessageDialog.openInformation(null, ValUIMessages.ValidationStatus, message);
+ ResultsDialog rd = new ResultsDialog(null, vr, time, finalResourceCount);
+ rd.open();
+// if (vr.getSeverityError() + vr.getSeverityWarning() + vr.getSeverityInfo() == 0){
+// message = ValUIMessages.ValidationSuccessful;
+// }
+// else {
+//
+// String[] parms = new String[3];
+// parms[0] = _nf.format(vr.getSeverityError());
+// parms[1] = _nf.format(vr.getSeverityWarning());
+// parms[2] = _nf.format(vr.getSeverityInfo());
+// message = NLS.bind(ValUIMessages.ErrSummary, parms);
+// }
+// MessageDialog.openInformation(null, ValUIMessages.ValidationStatus, message);
}
};
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java
new file mode 100644
index 0000000..3570257
--- /dev/null
+++ b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java
@@ -0,0 +1,106 @@
+package org.eclipse.wst.validation.ui.internal.dialog;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IconAndMessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.internal.ui.ValidationUIMessages;
+
+/**
+ * A dialog for displaying the results of a manual validation.
+ * @author karasiuk
+ *
+ */
+public class ResultsDialog extends IconAndMessageDialog {
+
+ private ValidationResult _result;
+ private long _time;
+ private int _resourceCount;
+
+ /**
+ * Create a dialog for displaying validation results.
+ *
+ * @param parentShell this can be null
+ * @param results the results of the validation
+ * @param time the time that the validation took in milliseconds
+ * @param resourceCount the number of resources that were validated
+ */
+ public ResultsDialog(Shell parentShell, ValidationResult results, long time, int resourceCount) {
+ super(parentShell);
+ _result = results;
+ _time = time;
+ _resourceCount = resourceCount;
+ }
+
+ @Override
+ protected Image getImage() {
+ if (_result.getSeverityError() > 0)return getErrorImage();
+ if (_result.getSeverityWarning() > 0)return getWarningImage();
+ return getInfoImage();
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ message = getMessage();
+ createMessageArea(parent);
+
+ StringBuffer b = new StringBuffer(200);
+ String infoMessage = getInfoMessage();
+ if (infoMessage != null){
+ b.append(infoMessage);
+ b.append(' ');
+ }
+
+ if (_resourceCount > 0){
+ if (_resourceCount == 1)b.append(NLS.bind(ValidationUIMessages.ValTime1, getTime(_time)));
+ else b.append(NLS.bind(ValidationUIMessages.ValTime, _resourceCount, getTime(_time)));
+ }
+
+ Label msg = new Label(parent, SWT.NONE);
+ msg.setText(b.toString());
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ msg.setLayoutData(gd);
+ Control c = super.createDialogArea(parent);
+ return c;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(ValidationUIMessages.ValResultsStatus);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ private String getTime(long time) {
+ if (_time <= 1000)return ValidationUIMessages.TimeUnder;
+ if (_time <= 60000)return NLS.bind(ValidationUIMessages.TimeSec, _time/1000);
+ return NLS.bind(ValidationUIMessages.TimeMin, _time/60000);
+ }
+
+ private String getInfoMessage() {
+ int n = _result.getSeverityInfo();
+ if (n == 0)return null;
+ if (n == 1)return ValidationUIMessages.ValInfo1;
+ return NLS.bind(ValidationUIMessages.ValInfo, n);
+ }
+
+ private String getMessage(){
+ if (_result.getSeverityError() > 1)return NLS.bind(ValidationUIMessages.ValErrors, _result.getSeverityError());
+ if (_result.getSeverityError() == 1)return ValidationUIMessages.ValErrors1;
+ if (_result.getSeverityWarning() > 1)return NLS.bind(ValidationUIMessages.ValWarn, _result.getSeverityWarning());
+ if (_result.getSeverityWarning() == 1)return ValidationUIMessages.ValWarn1;
+ return ValidationUIMessages.ValSuccess;
+ }
+}
diff --git a/plugins/org.eclipse.wst.validation/reminders.txt b/plugins/org.eclipse.wst.validation/reminders.txt
index 97d00a0..936df08 100644
--- a/plugins/org.eclipse.wst.validation/reminders.txt
+++ b/plugins/org.eclipse.wst.validation/reminders.txt
@@ -3,12 +3,6 @@
4) Adding a new validator had no filters, until a restore defaults was forced.
5) How do you get your builder added to a new project?
-6) Since I hijacked column 3, what should I do about delegating validators?
-- If it is an old validator call the old dialog
-- If it is a new validator, add a combo box to the settings page
-- Note - the delegating EP has a target, which is really no more than a name, and a class which is what really gets
-selected, and then called. In the case of the XSD validator, the target is XSDDelegatingValidator. (This phoney
-target is what you add your filters to)
Remember to delete this file when you are done.
@@ -19,3 +13,9 @@
1) I changed the plug-in to use the new EP
2) I keep the validator as implementing an IValidator (to make some of the other calls easier)
3) Add project level options
+6) Since I hijacked column 3, what should I do about delegating validators?
+- If it is an old validator call the old dialog
+- If it is a new validator, add a combo box to the settings page
+- Note - the delegating EP has a target, which is really no more than a name, and a class which is what really gets
+selected, and then called. In the case of the XSD validator, the target is XSDDelegatingValidator. (This phoney
+target is what you add your filters to)
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/FilterUtil.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/FilterUtil.java
index 38b8567..461cee2 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/FilterUtil.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/FilterUtil.java
@@ -45,9 +45,9 @@
private static VMDResourceVisitor _resourceVisitor = null;
private interface VMDRecorder {
- public Map getResult();
+ public Map<ValidatorMetaData, Set<IFileDelta>> getResult();
- public void setEnabledValidators(Set enabledValidators);
+ public void setEnabledValidators(Set<ValidatorMetaData> enabledValidators);
public void setProgressMonitor(IProgressMonitor monitor);
@@ -55,53 +55,40 @@
}
private interface VMDDeltaVisitor extends VMDRecorder, IResourceDeltaVisitor {
- //constructor
}
private interface VMDResourceVisitor extends VMDRecorder, IResourceVisitor {
- //constructor
}
- /**
- * Don't let anyone create an instance of this class.
- */
private FilterUtil() {
- //default
}
/**
* Given a Set of enabled ValidatorMetaData, create a Map with each ValidatorMetaData as a key
* with an associated null value.
*/
- static Map wrapInMap(Set enabledValidators) {
- Map result = new HashMap();
- if ((enabledValidators == null) || (enabledValidators.size() == 0)) {
- return result;
- }
+ static Map<ValidatorMetaData, Set<IFileDelta>> wrapInMap(Set<ValidatorMetaData> enabledValidators) {
+ Map<ValidatorMetaData, Set<IFileDelta>> result = new HashMap<ValidatorMetaData, Set<IFileDelta>>();
+ if ((enabledValidators == null) || (enabledValidators.size() == 0))return result;
- Iterator iterator = enabledValidators.iterator();
- while (iterator.hasNext()) {
- result.put(iterator.next(), null);
- }
+ for (ValidatorMetaData vmd : enabledValidators)result.put(vmd, null);
return result;
}
static void checkCanceled(IProgressMonitor monitor) throws OperationCanceledException {
- if (monitor == null) {
- return;
- } else if (monitor.isCanceled()) {
- throw new OperationCanceledException(""); //$NON-NLS-1$
- }
+ if (monitor == null)return;
+ else if (monitor.isCanceled())throw new OperationCanceledException(""); //$NON-NLS-1$
}
/**
* Given a Map of VMD <=>Set(IFileDelta), either return the existing Set or create a Set and
* return it.
*/
- private static Set getResourceDeltas(Map enabledValidators, ValidatorMetaData vmd) {
- Set fileDeltas = (Set) enabledValidators.get(vmd);
+ private static Set<IFileDelta> getResourceDeltas(Map<ValidatorMetaData, Set<IFileDelta>> enabledValidators,
+ ValidatorMetaData vmd) {
+ Set<IFileDelta> fileDeltas = enabledValidators.get(vmd);
if (fileDeltas == null) {
- fileDeltas = new HashSet();
+ fileDeltas = new HashSet<IFileDelta>();
enabledValidators.put(vmd, fileDeltas);
}
return fileDeltas;
@@ -168,8 +155,9 @@
* Return the validators which are both configured on this type of project, (as stored in
* getProject()), and enabled by the user on this project.
*/
- static void addFileDelta(Map enabledValidators, ValidatorMetaData vmd, WorkbenchFileDelta fileDelta) {
- Set fileDeltas = getResourceDeltas(enabledValidators, vmd);
+ static void addFileDelta(Map<ValidatorMetaData, Set<IFileDelta>> enabledValidators,
+ ValidatorMetaData vmd, WorkbenchFileDelta fileDelta) {
+ Set<IFileDelta> fileDeltas = getResourceDeltas(enabledValidators, vmd);
fileDeltas.add(fileDelta);
enabledValidators.put(vmd, fileDeltas);
}
@@ -181,7 +169,8 @@
* If filterIn is true, do not check if the resources are filtered in by the validator. If
* filterIn is false, check if the resources are filtered in by the validator (recommended).
*/
- public static Map getFileDeltas(Set enabledValidators, Object[] changedResources, boolean filterIn) {
+ public static Map<ValidatorMetaData, Set<IFileDelta>>
+ getFileDeltas(Set enabledValidators, Object[] changedResources, boolean filterIn) {
// by default assume that the resources have changed, i.e. not added or deleted
return getFileDeltas(enabledValidators, changedResources, IFileDelta.CHANGED, filterIn);
}
@@ -190,7 +179,8 @@
* Return a Map wrapper, with each VMD from enabledValidators as the key, and the value a Set of
* IFileDelta wrapper around the changed Object[], with each delta of type deltaType.
*/
- public static Map getFileDeltas(Set enabledValidators, Object[] changedResources, int ifileDeltaType) {
+ public static Map<ValidatorMetaData, Set<IFileDelta>>
+ getFileDeltas(Set enabledValidators, Object[] changedResources, int ifileDeltaType) {
// by default check if the Objects are filtered in by the validator
return getFileDeltas(enabledValidators, changedResources, ifileDeltaType, false);
}
@@ -198,13 +188,13 @@
/**
* Return a Map wrapper, with each VMD from enabledValidators as the key, and the value a Set of
* IFileDelta wrapper around the changed Object[].
- *
+ * <p>
* If "force" is true, then don't check if the object is filtered in by the validator or not.
* ValidatorSubsetOperation can use validators that don't filter in these particular resources,
* but can use a defaultExtension's validators instead.
*/
- public static Map getFileDeltas(Set enabledValidators, Object[] changedResources, int ifileDeltaType, boolean force) {
- Map result = new HashMap();
+ public static Map<ValidatorMetaData, Set<IFileDelta>> getFileDeltas(Set enabledValidators, Object[] changedResources, int ifileDeltaType, boolean force) {
+ Map<ValidatorMetaData, Set<IFileDelta>> result = new HashMap<ValidatorMetaData, Set<IFileDelta>>();
if ((enabledValidators == null) || (enabledValidators.size() == 0)) {
return result;
}
@@ -215,7 +205,7 @@
while (iterator.hasNext()) {
ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
try {
- Set deltas = new HashSet();
+ Set<IFileDelta> deltas = new HashSet<IFileDelta>();
IProgressMonitor monitor = new NullProgressMonitor();
for (int i = 0; i < changedResources.length; i++) {
Object obj = changedResources[i];
@@ -267,7 +257,6 @@
}
}
-
return result;
}
@@ -281,7 +270,6 @@
if (logger.isLoggingLevel(Level.SEVERE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("FilterUtil::getFileDelta(IWorkbenchContext, ValidatorMetaData, IResource, int)"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_SYNTAX_NULL_NAME);
String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SYNTAX_NULL_NAME),
new Object[]{resource.getName(), vmd.getValidatorDisplayName()});
entry.setText(result);
@@ -314,7 +302,7 @@
* Add the IResource to the vmd's list of resources to validate. Return true if the add was
* successful or false if the add was not successful.
*/
- static boolean addToFileList(Map enabledValidators, IWorkbenchContext helper, ValidatorMetaData vmd, IResource resource, int resourceDelta, boolean isFullBuild) {
+ static boolean addToFileList(Map<ValidatorMetaData, Set<IFileDelta>> enabledValidators, IWorkbenchContext helper, ValidatorMetaData vmd, IResource resource, int resourceDelta, boolean isFullBuild) {
if ((vmd == null) || (resource == null)) {
return false;
}
@@ -397,10 +385,8 @@
* completion of the <code>validate</code>), increment the IProgressMonitor's status by one
* (i.e., one resource has been processed.)
*/
- static void filterOut(IProgressMonitor monitor, Map enabledValidators, IResource resource, int resourceDelta, boolean isFullBuild) {
- if (monitor == null) {
- return;
- }
+ static void filterOut(IProgressMonitor monitor, Map<ValidatorMetaData, Set<IFileDelta>> enabledValidators, IResource resource, int resourceDelta, boolean isFullBuild) {
+ if (monitor == null)return;
checkCanceled(monitor);
@@ -470,12 +456,12 @@
* completion of the <code>validate</code>), increment the IProgressMonitor's status by one
* (i.e., one resource has been processed.)
*/
- static void filterOut(IProgressMonitor monitor, Map enabledValidators, IResource resource, IResourceDelta delta) {
+ static void filterOut(IProgressMonitor monitor, Map<ValidatorMetaData, Set<IFileDelta>> enabledValidators,
+ IResource resource, IResourceDelta delta) {
// filter in only resources which have been added, deleted, or its content changed.
// moves will be registered as an add & delete combination
- if (filterOut(delta)) {
- return;
- }
+ if (filterOut(delta))return;
+
filterOut(monitor, enabledValidators, resource, delta.getKind(), false); // false =
// incremental
// build
@@ -591,17 +577,17 @@
return true;
}
- private static VMDResourceVisitor getResourceVisitor(IProgressMonitor monitor, Set enabledValidators) {
+ private static VMDResourceVisitor getResourceVisitor(IProgressMonitor monitor, Set<ValidatorMetaData> enabledValidators) {
if (_resourceVisitor == null) {
_resourceVisitor = new VMDResourceVisitor() {
- private Map _vmdDeltas = null;
+ private Map<ValidatorMetaData, Set<IFileDelta>> _vmdDeltas = null;
private IProgressMonitor _progressMonitor = null;
- public Map getResult() {
+ public Map<ValidatorMetaData, Set<IFileDelta>> getResult() {
return _vmdDeltas;
}
- public void setEnabledValidators(Set validators) {
+ public void setEnabledValidators(Set<ValidatorMetaData> validators) {
_vmdDeltas = wrapInMap(validators);
}
@@ -630,17 +616,17 @@
return _resourceVisitor;
}
- private static VMDDeltaVisitor getDeltaVisitor(IProgressMonitor monitor, Set enabledValidators) {
+ private static VMDDeltaVisitor getDeltaVisitor(IProgressMonitor monitor, Set<ValidatorMetaData> enabledValidators) {
if (_deltaVisitor == null) {
_deltaVisitor = new VMDDeltaVisitor() {
- private Map _vmdDeltas = null;
+ private Map<ValidatorMetaData, Set<IFileDelta>> _vmdDeltas = null;
private IProgressMonitor _progressMonitor = null;
- public Map getResult() {
+ public Map<ValidatorMetaData, Set<IFileDelta>> getResult() {
return _vmdDeltas;
}
- public void setEnabledValidators(Set validators) {
+ public void setEnabledValidators(Set<ValidatorMetaData> validators) {
_vmdDeltas = wrapInMap(validators);
}
@@ -695,13 +681,15 @@
return _deltaVisitor;
}
- public static Map loadDeltas(final IProgressMonitor monitor, final Set enabledValidators, IResourceDelta delta) throws CoreException {
+ public static Map<ValidatorMetaData, Set<IFileDelta>> loadDeltas(final IProgressMonitor monitor,
+ final Set<ValidatorMetaData> enabledValidators, IResourceDelta delta) throws CoreException {
VMDDeltaVisitor visitor = getDeltaVisitor(monitor, enabledValidators);
delta.accept(visitor, true); // true means include phantom resources
return visitor.getResult();
}
- public static Map loadDeltas(final IProgressMonitor monitor, final Set enabledValidators, IProject project) throws CoreException {
+ public static Map<ValidatorMetaData, Set<IFileDelta>> loadDeltas(final IProgressMonitor monitor,
+ final Set<ValidatorMetaData> enabledValidators, IProject project) throws CoreException {
VMDResourceVisitor visitor = getResourceVisitor(monitor, enabledValidators);
project.accept(visitor, IResource.DEPTH_INFINITE, true); // true means include phantom
// resources
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/InternalValidatorManager.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/InternalValidatorManager.java
index 476cda8..4731192 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/InternalValidatorManager.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/InternalValidatorManager.java
@@ -14,7 +14,6 @@
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
@@ -57,15 +56,11 @@
/**
* Return a new Set that contains all of the elements from the array.
*/
- public static Set wrapInSet(Object[] obj) {
- Set result = new HashSet();
- if ((obj == null) || (obj.length == 0)) {
- return result;
- }
+ public static Set<ValidatorMetaData> wrapInSet(ValidatorMetaData[] vmds) {
+ Set<ValidatorMetaData> result = new HashSet<ValidatorMetaData>();
+ if ((vmds == null) || (vmds.length == 0))return result;
- for (int i = 0; i < obj.length; i++) {
- result.add(obj[i]);
- }
+ for (ValidatorMetaData vmd : vmds)result.add(vmd);
return result;
}
@@ -111,11 +106,10 @@
* Return an array of the fully-qualified names of the validator classes.
*/
public String[] getValidatorNames(ValidatorMetaData[] vmds) {
- Set temp = new HashSet();
- for (int i = 0; i < vmds.length; i++) {
- String[] names = vmds[i].getValidatorNames();
- for (int j = 0; j < names.length; j++) {
- temp.add(names[j]);
+ Set<String> temp = new HashSet<String>();
+ for (ValidatorMetaData vmd : vmds) {
+ for (String name : vmd.getValidatorNames()) {
+ temp.add(name);
}
}
@@ -127,14 +121,11 @@
/**
* Return an array of the fully-qualified names of the validator classes.
*/
- public String[] getValidatorNames(Collection vmds) {
- Set temp = new HashSet();
- Iterator iterator = vmds.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- String[] names = vmd.getValidatorNames();
- for (int j = 0; j < names.length; j++) {
- temp.add(names[j]);
+ public String[] getValidatorNames(Collection<ValidatorMetaData> vmds) {
+ Set<String> temp = new HashSet<String>();
+ for (ValidatorMetaData vmd : vmds) {
+ for (String name : vmd.getValidatorNames()) {
+ temp.add(name);
}
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TaskListUtility.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TaskListUtility.java
index 05f096b..ef964e7 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TaskListUtility.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TaskListUtility.java
@@ -48,6 +48,7 @@
* This method is here for use by the SABER validator's reporter instance ONLY. Do not use. See
* defect 260144 for details.
*/
+ @SuppressWarnings("unchecked")
public static IMarker setPriority(IMarker item, int priority) throws CoreException {
Map attrib = item.getAttributes();
attrib.put(IMarker.PRIORITY, new Integer(priority));
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/VThreadManager.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/VThreadManager.java
index 77a738a..b7e7076 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/VThreadManager.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/VThreadManager.java
@@ -111,11 +111,11 @@
}
private class Jobs {
- private Vector __jobs = null; // The queued Runnables that need to be run.
- private boolean _isActive = false; // Is a job being run in the validation thread?
+ private Vector<Runnable> _queuedJobs; // The queued Runnables that need to be run.
+ private boolean _isActive; // Is a job being run in the validation thread?
public Jobs() {
- __jobs = new Vector();
+ _queuedJobs = new Vector<Runnable>();
}
public synchronized void queue(Runnable runnable) {
@@ -125,7 +125,7 @@
// instead of the last state of changes.
// Have to wait for the current Runnable to finish, so add this to the end of the queue
- __jobs.add(runnable);
+ _queuedJobs.add(runnable);
notifyAll();
}
@@ -133,7 +133,7 @@
* Pop the Runnable off of the head of the queue.
*/
synchronized Runnable dequeue() {
- while (__jobs.size() == 0) {
+ while (_queuedJobs.size() == 0) {
try {
wait();
} catch (InterruptedException exc) {
@@ -142,10 +142,10 @@
} // Block on the semaphore; break when a job has been added to the queue.
Runnable job = null;
- if (__jobs.size() > 0) {
- job = (Runnable) __jobs.get(0);
+ if (_queuedJobs.size() > 0) {
+ job = _queuedJobs.get(0);
if (job != null) {
- __jobs.remove(0);
+ _queuedJobs.remove(0);
}
}
return job;
@@ -163,7 +163,7 @@
* Return true if all of the Runnables have been run.
*/
public synchronized boolean isDone() {
- return ((__jobs.size() == 0) && !isActive());
+ return ((_queuedJobs.size() == 0) && !isActive());
}
}
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java
index c1fc4d6..69fd4f8 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java
@@ -14,10 +14,10 @@
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
@@ -73,14 +73,19 @@
*/
public final class ValidationRegistryReader implements RegistryConstants {
private static ValidationRegistryReader inst;
- private HashMap _validators; // list of all validators registered, with their associated
- // ValidatorMetaData, indexed by project nature id
- private HashMap _indexedValidators; // list of all validators, indexed by validator class name,
+
+ /** list of all validators registered, with their associated ValidatorMetaData, indexed by project nature id */
+ private Map<String,Set<ValidatorMetaData>> _validators;
+
+ // list of all validators, indexed by validator class name,
// with the validator's ValidatorMetaData as the value.
// Needed by the WorkbenchReporter, because sometimes the
// IValidator is not enough to remove all messages from the
// task list.
- private Set _defaultEnabledValidators;
+ private Map<String, ValidatorMetaData> _indexedValidators;
+
+ private Set<ValidatorMetaData> _defaultEnabledValidators;
+
// Since IProject's contents are all instances of IResource, every type filter for a validator
// must be an instance of IResource. This applies to both the rebuildCache pass and to the
// validation pass.
@@ -89,7 +94,7 @@
private static final String UNKNOWN_PROJECT = "UNKNOWN"; //$NON-NLS-1$ // This 'project nature id' is used as a key to get the validators which can run on a project type which hasn't been explicitly filtered in or out by any validator.
private static final String EXCLUDED_PROJECT = "EXCLUDED"; //$NON-NLS-1$ // This 'project nature id' is used as a key to get the validators which are excluded on certain projects.
- public HashMap projectValidationMetaData;
+ public HashMap<IProject, Set<ValidatorMetaData>> projectValidationMetaData;
/**
* The registry is read once - when this class is instantiated.
@@ -98,9 +103,9 @@
super();
try {
- _validators = new HashMap();
- _indexedValidators = new HashMap();
- _defaultEnabledValidators = new HashSet();
+ _validators = new HashMap<String,Set<ValidatorMetaData>>();
+ _indexedValidators = new HashMap<String, ValidatorMetaData>();
+ _defaultEnabledValidators = new HashSet<ValidatorMetaData>();
// Read the registry and build a map of validators. The key into
// the map is the IValidator instance and the value is the ValidatorMetaData
@@ -126,9 +131,7 @@
* created to increase runtime performance.
*/
private void buildCache() {
- Iterator iterator = _indexedValidators.values().iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
+ for (ValidatorMetaData vmd : _indexedValidators.values()) {
buildProjectNatureCache(vmd);
buildDefaultEnabledCache(vmd);
}
@@ -138,7 +141,7 @@
addRemainder();
// this temporary list isn't needed any more. All of the excluded
- // projects have been added to the project natures which they don't exlcude.
+ // projects have been added to the project natures which they don't exclude.
_validators.remove(EXCLUDED_PROJECT);
Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
@@ -189,13 +192,9 @@
* Build the list of validators which are enabled by default.
*/
private void buildDefaultEnabledCache(ValidatorMetaData vmd) {
- if (vmd == null) {
- return;
- }
+ if (vmd == null)return;
- if (vmd.isEnabledByDefault()) {
- _defaultEnabledValidators.add(vmd);
- }
+ if (vmd.isEnabledByDefault())_defaultEnabledValidators.add(vmd);
}
/**
@@ -229,23 +228,20 @@
}
private void addExcludedRemainder() {
- Set excludedProjVmds = (Set) _validators.get(EXCLUDED_PROJECT);
+ Set<ValidatorMetaData> excludedProjVmds = _validators.get(EXCLUDED_PROJECT);
if (excludedProjVmds == null) {
// no excluded project natures
return;
}
- Iterator exIterator = excludedProjVmds.iterator();
- while (exIterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) exIterator.next();
+ for (ValidatorMetaData vmd : excludedProjVmds) {
- boolean noneIncluded = true; // assume that, by default, if someone explicitly excludes
- // a project nature then they don't include any project
- // natures
- Set keys = _validators.keySet();
- Iterator iterator = keys.iterator();
- while (iterator.hasNext()) {
- String projId = (String) iterator.next();
+ // assume that, by default, if someone explicitly excludes
+ // a project nature then they don't include any project natures
+ boolean noneIncluded = true;
+
+ // a project nature then they don't include any project natures
+ for (String projId : _validators.keySet()) {
if (projId.equals(UNKNOWN_PROJECT) || projId.equals(EXCLUDED_PROJECT)) {
// Don't add list to a project nature which is excluded or applicable to all.
continue;
@@ -278,16 +274,13 @@
}
private void addAnyRemainder() {
- Set anyProjVmds = (Set) _validators.get(UNKNOWN_PROJECT);
+ Set<ValidatorMetaData> anyProjVmds = _validators.get(UNKNOWN_PROJECT);
if (anyProjVmds == null) {
// no validators run on all projects
return;
}
- Set keys = _validators.keySet();
- Iterator iterator = keys.iterator();
- while (iterator.hasNext()) {
- String projId = (String) iterator.next();
+ for (String projId : _validators.keySet()) {
if (projId.equals(UNKNOWN_PROJECT) || projId.equals(EXCLUDED_PROJECT)) {
// Don't add list to itself or to a project nature which is excluded.
continue;
@@ -297,26 +290,22 @@
}
}
- private void add(String projectNatureId, Set vmdList) {
- if ((vmdList == null) || (vmdList.size() == 0)) {
- return;
- }
+ private void add(String projectNatureId, Set<ValidatorMetaData> vmdList) {
+ if ((vmdList == null) || (vmdList.size() == 0))return;
- Set pnVal = createSet(projectNatureId); // whether the validator includes or excludes this
- // project nature id, make sure that an entry is
- // created for it in the table
+ // whether the validator includes or excludes this
+ // project nature id, make sure that an entry is created for it in the table
+ Set<ValidatorMetaData> pnVal = createSet(projectNatureId);
pnVal.addAll(vmdList);
_validators.put(projectNatureId, pnVal);
}
private void add(String projectNatureId, ValidatorMetaData vmd) {
- if (vmd == null) {
- return;
- }
+ if (vmd == null)return;
- Set pnVal = createSet(projectNatureId); // whether the validator includes or excludes this
- // project nature id, make sure that an entry is
- // created for it in the table
+ // whether the validator includes or excludes this
+ // project nature id, make sure that an entry is created for it in the table
+ Set<ValidatorMetaData> pnVal = createSet(projectNatureId);
pnVal.add(vmd);
_validators.put(projectNatureId, pnVal);
}
@@ -334,25 +323,21 @@
// a lot of processing time... Instead, traverse the list of proj nature ids,
// and search the Set of that proj nature id, and remove the vmd if it's in the
// Set.
- Object[] keys = _validators.keySet().toArray();
- for (int i = 0; i < keys.length; i++) {
- Object key = keys[i];
- Set value = (Set) _validators.get(key);
- if (value == null) {
- continue;
- }
+ for (String projId : _validators.keySet()) {
+ Set<ValidatorMetaData> value = _validators.get(projId);
+ if (value == null)continue;
if (value.contains(vmd)) {
value.remove(vmd);
- _validators.put(key, value);
+ _validators.put(projId, value);
}
}
}
- private Set createSet(String projNature) {
- Set v = (Set) _validators.get(projNature);
+ private Set<ValidatorMetaData> createSet(String projNature) {
+ Set<ValidatorMetaData> v = _validators.get(projNature);
if (v == null) {
- v = new HashSet();
+ v = new HashSet<ValidatorMetaData>();
}
return v;
}
@@ -505,12 +490,10 @@
if (logger.isLoggingLevel(Level.SEVERE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationRegistryReader.createHelper(IConfigurationElement, String)"); //$NON-NLS-1$
- entry.setMessageTypeIdentifier(ResourceConstants.VBF_EXC_SYNTAX_NO_HELPER_THROWABLE);
entry.setTargetException(exc);
String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SYNTAX_NO_HELPER_THROWABLE),
new Object[]{helperClassName});
entry.setText(result);
- //entry.setTokens(new String[]{helperClassName});
logger.write(Level.SEVERE, entry);
}
return null;
@@ -527,8 +510,6 @@
if (logger.isLoggingLevel(Level.SEVERE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationRegistryReader.createValidator(IConfigurationElement, String, String)"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_SYNTAX_NO_VAL_THROWABLE);
- //entry.setTokens(new String[]{validatorClassName});
String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SYNTAX_NO_VAL_THROWABLE),
new Object[]{validatorClassName});
entry.setText(result);
@@ -793,8 +774,6 @@
if (logger.isLoggingLevel(Level.FINE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationRegistryReader.getValidatorExtensionPoint()"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_MISSING_VALIDATOR_EP);
- //entry.setTokens(new String[]{ValidationPlugin.PLUGIN_ID + "." + VALIDATOR_EXT_PT_ID}); //$NON-NLS-1$
String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_MISSING_VALIDATOR_EP),
new Object[]{ValidationPlugin.PLUGIN_ID + "." + VALIDATOR_EXT_PT_ID}); //$NON-NLS-1$
entry.setText(result);
@@ -852,8 +831,8 @@
*
* This is a long-running process. If you can, cache the result.
*/
- public Set getValidatorMetaData(IProject project) {
- Set copy = new HashSet();
+ public Set<ValidatorMetaData> getValidatorMetaData(IProject project) {
+ Set<ValidatorMetaData> copy = new HashSet<ValidatorMetaData>();
getValidatorMetaData(project, copy);
return copy;
}
@@ -861,10 +840,8 @@
/**
* Copy the set of configured validator metadata into the Set.
*/
- public void getValidatorMetaData(IProject project, Set vmds) {
- if (vmds == null) {
- return;
- }
+ public void getValidatorMetaData(IProject project, Set<ValidatorMetaData> vmds) {
+ if (vmds == null)return;
vmds.clear();
int executionMap = 0x0;
Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
@@ -912,10 +889,8 @@
// <test forcePluginActivation="true" property="foo.testProperty"/>
// </enablement>
- Set validatorsWithEnablementExpression = new HashSet();
- Iterator allValidators = getAllValidators().iterator();
- while (allValidators.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) allValidators.next();
+ Set<ValidatorMetaData> validatorsWithEnablementExpression = new HashSet<ValidatorMetaData>();
+ for (ValidatorMetaData vmd : getAllValidators()) {
if (isFacetEnabled(vmd, project)) {
validatorsWithEnablementExpression.add(vmd);
}
@@ -969,31 +944,22 @@
* @param vmds
* @param projectNatures
*/
- private void calculateVmdsForNatureAndFacets(Set vmds, String[] projectNatures, IProject project) {
- Set projVmds;
+ private void calculateVmdsForNatureAndFacets(Set<ValidatorMetaData> vmds, String[] projectNatures, IProject project) {
+ Set<ValidatorMetaData> projVmds;
String[] projectFacetIds = getProjectFacetIds(project);
- Iterator allValidators = getAllValidators().iterator();
- while (allValidators.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) allValidators.next();
+ for (ValidatorMetaData vmd : getAllValidators()) {
if (containsProjectFacet(vmd, projectFacetIds) || isFacetEnabled(vmd, project)) {
vmds.add(vmd);
}
}
- for (int i = 0; i < projectNatures.length; i++) {
- String projectNatureId = projectNatures[i];
- projVmds = (Set) _validators.get(projectNatureId);
- if (projVmds == null)
- continue;
+ for (String projectNatureId : projectNatures) {
+ projVmds = _validators.get(projectNatureId);
+ if (projVmds == null)continue;
- Iterator iterator = projVmds.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
+ for (ValidatorMetaData vmd : projVmds) {
if (!vmds.contains(vmd) && (vmd.getFacetFilters() == null || vmd.getFacetFilters().length == 0)) {
- if (vmd.getEnablementExpresion() == null)
- vmds.add(vmd);
- else if (isFacetEnabled(vmd, project))
- vmds.add(vmd);
-
+ if (vmd.getEnablementExpresion() == null)vmds.add(vmd);
+ else if (isFacetEnabled(vmd, project))vmds.add(vmd);
}
}
}
@@ -1121,14 +1087,9 @@
}
}
+ @SuppressWarnings("unchecked")
private Collection clone(Collection input, Collection copy) {
- if (input == null) {
- return null;
- }
-
- if (copy == null) {
- return null;
- }
+ if (input == null || copy == null)return null;
copy.clear();
copy.addAll(input);
return copy;
@@ -1138,16 +1099,12 @@
StringBuffer buffer = new StringBuffer();
buffer.append("Project nature => validators configured"); //$NON-NLS-1$
buffer.append("\n"); //$NON-NLS-1$
- Iterator viterator = _validators.keySet().iterator();
- while (viterator.hasNext()) {
- String projId = (String) viterator.next();
+ for (String projId : _validators.keySet()) {
buffer.append("projId: "); //$NON-NLS-1$
buffer.append(projId);
buffer.append("\n"); //$NON-NLS-1$
- Set validators = (Set) _validators.get(projId);
- Iterator innerIterator = validators.iterator();
- while (innerIterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) innerIterator.next();
+ Set<ValidatorMetaData> validators = _validators.get(projId);
+ for (ValidatorMetaData vmd : validators) {
buffer.append("\t"); //$NON-NLS-1$
buffer.append(vmd.getValidatorUniqueName());
buffer.append("\n"); //$NON-NLS-1$
@@ -1157,9 +1114,7 @@
buffer.append("Enable/disable validator by default"); //$NON-NLS-1$
buffer.append("\n"); //$NON-NLS-1$
- viterator = _indexedValidators.values().iterator();
- while (viterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) viterator.next();
+ for (ValidatorMetaData vmd : _indexedValidators.values()) {
buffer.append(vmd.getValidatorUniqueName());
buffer.append(" enabled? "); //$NON-NLS-1$
buffer.append(vmd.isEnabledByDefault());
@@ -1171,21 +1126,14 @@
public boolean isConfiguredOnProject(ValidatorMetaData vmd, IProject project) {
if (projectValidationMetaData == null)
- projectValidationMetaData = new HashMap();
+ projectValidationMetaData = new HashMap<IProject, Set<ValidatorMetaData>>();
- Object vmds = projectValidationMetaData.get(project);
+ Set<ValidatorMetaData> vmds = projectValidationMetaData.get(project);
if (vmds != null) {
- Set pvmds = (Set) vmds;
- return pvmds.contains(vmd);
+ return vmds.contains(vmd);
} else {
- Set prjVmds = getValidatorMetaData(project);
- if (prjVmds == null) {
- return false;
- }
-
- if (prjVmds.size() == 0) {
- return false;
- }
+ Set<ValidatorMetaData> prjVmds = getValidatorMetaData(project);
+ if (prjVmds == null || prjVmds.size() == 0)return false;
projectValidationMetaData.put(project, prjVmds);
return prjVmds.contains(vmd);
}
@@ -1199,10 +1147,10 @@
*
* @see addExcludedRemainder()
*/
- private Set getValidatorMetaDataUnknownProject() {
- Set projVmds = (Set) _validators.get(UNKNOWN_PROJECT);
+ private Set<ValidatorMetaData> getValidatorMetaDataUnknownProject() {
+ Set<ValidatorMetaData> projVmds = _validators.get(UNKNOWN_PROJECT);
if (projVmds == null) {
- projVmds = Collections.EMPTY_SET;
+ projVmds = new HashSet<ValidatorMetaData>();
}
return projVmds;
}
@@ -1237,18 +1185,12 @@
return null;
}
- ValidatorMetaData vmd = (ValidatorMetaData) _indexedValidators.get(validatorClassName);
- if (vmd != null) {
- return vmd;
- }
+ ValidatorMetaData vmd2 = _indexedValidators.get(validatorClassName);
+ if (vmd2 != null)return vmd2;
// Check for an aggregate validator
- Iterator iterator = _indexedValidators.values().iterator();
- while (iterator.hasNext()) {
- vmd = (ValidatorMetaData) iterator.next();
- if (vmd == null) {
- continue;
- }
+ for (ValidatorMetaData vmd : _indexedValidators.values()) {
+ if (vmd == null)continue;
if (vmd.getValidatorUniqueName().equals(validatorClassName)) {
return vmd;
@@ -1322,7 +1264,6 @@
if (logger.isLoggingLevel(Level.FINE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationRegistryReader.initializeValidator(IConfigurationElement, String, String)"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_SYNTAX_NO_VAL_RUN);
//entry.setTokens(new String[]{validatorName});
String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SYNTAX_NO_VAL_RUN),
new Object[]{validatorName});
@@ -1476,8 +1417,6 @@
String[] msgParm = {extension.getUniqueIdentifier()};
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationRegistryReader.readExtension(IExtension)"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_VALIDATORNAME_IS_NULL);
- //entry.setTokens(msgParm);
String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_VALIDATORNAME_IS_NULL),
(Object[])msgParm);
entry.setText(result);
@@ -1525,7 +1464,7 @@
}
public IValidator getValidator(String validatorClassName) throws InstantiationException {
- ValidatorMetaData vmd = (ValidatorMetaData) _indexedValidators.get(validatorClassName);
+ ValidatorMetaData vmd = _indexedValidators.get(validatorClassName);
if(vmd != null)
return vmd.getValidator();
return null;
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationSelectionHandlerRegistryReader.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationSelectionHandlerRegistryReader.java
index 15fd626..4fc2d32 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationSelectionHandlerRegistryReader.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationSelectionHandlerRegistryReader.java
@@ -27,7 +27,7 @@
static final String ATT_SELECTION_TYPE = "selectionType"; //$NON-NLS-1$
private static ValidationSelectionHandlerRegistryReader INSTANCE;
- private List validationSelectionHandlers;
+ private List<IValidationSelectionHandler> _validationSelectionHandlers;
public ValidationSelectionHandlerRegistryReader() {
super(ValidationPlugin.PLUGIN_ID, VALIDATION_SELECTION_HANDLER);
@@ -65,19 +65,17 @@
return false;
}
- private List getValidationSelectionHandlers() {
- if (validationSelectionHandlers == null)
- validationSelectionHandlers = new ArrayList();
- return validationSelectionHandlers;
+ private List<IValidationSelectionHandler> getValidationSelectionHandlers() {
+ if (_validationSelectionHandlers == null)
+ _validationSelectionHandlers = new ArrayList<IValidationSelectionHandler>();
+ return _validationSelectionHandlers;
}
public Object getExtendedType(Object selection) {
Object result = null;
- for (int i=0; i<getValidationSelectionHandlers().size(); i++ ) {
- IValidationSelectionHandler handler = (IValidationSelectionHandler) getValidationSelectionHandlers().get(i);
+ for (IValidationSelectionHandler handler : getValidationSelectionHandlers()) {
result = handler.getBaseValidationType(selection);
- if (result != null)
- break;
+ if (result != null)break;
}
return result;
}
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 bbd636c..6432de0 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
@@ -45,37 +45,37 @@
* ValidatorMetaData; it is for use by the base framework only.
*/
public class ValidatorMetaData {
- private ValidatorFilter[] _filters;
- private ValidatorNameFilter[] _projectNatureFilters;
- private String[] facetFilters;
- private IValidator _validator;
- private IWorkbenchContext _helper;
- private String _validatorDisplayName;
- private String _validatorUniqueName;
- private String[] _aggregatedValidators;
- private String[] contentTypeIds = null;
- private String[] _validatorNames;
- private String _pluginId;
- private boolean _supportsIncremental = RegistryConstants.ATT_INCREMENTAL_DEFAULT;
- private boolean _supportsFullBuild = RegistryConstants.ATT_FULLBUILD_DEFAULT;
- private Logger _logger;
- private boolean _isEnabledByDefault = RegistryConstants.ATT_ENABLED_DEFAULT;
+ private ValidatorFilter[] _filters;
+ private ValidatorNameFilter[] _projectNatureFilters;
+ private String[] _facetFilters;
+ private IValidator _validator;
+ private IWorkbenchContext _helper;
+ private String _validatorDisplayName;
+ private String _validatorUniqueName;
+ private String[] _aggregatedValidators;
+ private String[] _contentTypeIds = null;
+ private String[] _validatorNames;
+ private String _pluginId;
+ private boolean _supportsIncremental = RegistryConstants.ATT_INCREMENTAL_DEFAULT;
+ private boolean _supportsFullBuild = RegistryConstants.ATT_FULLBUILD_DEFAULT;
+ private Logger _logger;
+ private boolean _isEnabledByDefault = RegistryConstants.ATT_ENABLED_DEFAULT;
private MigrationMetaData _migrationMetaData;
- private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT;
- private boolean _async = RegistryConstants.ATT_ASYNC_DEFAULT;
- private boolean dependentValidator = RegistryConstants.DEP_VAL_VALUE_DEFAULT;
- private String[] markerIds;
- private String _helperClassName;
+ private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT;
+ private boolean _async = RegistryConstants.ATT_ASYNC_DEFAULT;
+ private boolean _dependentValidator = RegistryConstants.DEP_VAL_VALUE_DEFAULT;
+ private String[] _markerIds;
+ private String _helperClassName;
private IConfigurationElement _helperClassElement;
private IConfigurationElement _validatorClassElement;
- private boolean _cannotLoad = false;
- private boolean manualValidation = true;
- private boolean buildValidation = true;
- private Map helpers = Collections.synchronizedMap( new HashMap() );
- private Expression enablementExpression;
+ private boolean _cannotLoad;
+ private boolean _manualValidation = true;
+ private boolean _buildValidation = true;
+ private Map<IValidatorJob, IWorkbenchContext> _helpers =
+ Collections.synchronizedMap( new HashMap<IValidatorJob, IWorkbenchContext>() );
+ private Expression _enablementExpression;
ValidatorMetaData() {
- //default
}
/**
@@ -105,23 +105,21 @@
* Add the facet filter(s).
*/
protected void addFacetFilters(String[] filters) {
- facetFilters = filters;
+ _facetFilters = filters;
}
protected String[] getFacetFilters() {
- return facetFilters;
+ return _facetFilters;
}
- public List getNameFilters() {
- List nameFilters = new ArrayList();
+ public List<String> getNameFilters() {
+ List<String> nameFilters = new ArrayList<String>();
if (_filters != null && _filters.length > 0) {
- for (int i = 0; i < _filters.length; i++) {
- ValidatorFilter filter = _filters[i];
+ for (ValidatorFilter filter : _filters) {
ValidatorNameFilter nameFilter = filter.get_nameFilter();
if (nameFilter != null) {
nameFilters.add(nameFilter.getNameFilter());
}
-
}
}
return nameFilters;
@@ -493,51 +491,36 @@
private Set _ids = null;
public MigrationMetaData() {
- //default
}
+ @SuppressWarnings("unchecked")
public void addId(String oldId, String newId) {
- if (oldId == null) {
- // log
- return;
- }
-
- if (newId == null) {
- // log
- return;
- }
+ if (oldId == null)return;
+ if (newId == null)return;
String[] ids = new String[]{oldId, newId};
getIds().add(ids);
}
public Set getIds() {
- if (_ids == null) {
- _ids = new HashSet();
- }
+ if (_ids == null)_ids = new HashSet();
return _ids;
}
}
- /**
- * @param b
- */
public void addDependentValidator(boolean b) {
- dependentValidator = b;
+ _dependentValidator = b;
}
- /**
- * @param b
- */
public boolean isDependentValidator() {
- return dependentValidator;
+ return _dependentValidator;
}
/**
* @return Returns the markerId.
*/
public String[] getMarkerIds() {
- return markerIds;
+ return _markerIds;
}
/**
@@ -545,23 +528,23 @@
* The markerId to set.
*/
public void setMarkerIds(String[] markerId) {
- this.markerIds = markerId;
+ this._markerIds = markerId;
}
public boolean isBuildValidation() {
- return buildValidation;
+ return _buildValidation;
}
public void setBuildValidation(boolean buildValidation) {
- this.buildValidation = buildValidation;
+ this._buildValidation = buildValidation;
}
public boolean isManualValidation() {
- return manualValidation;
+ return _manualValidation;
}
public void setManualValidation(boolean manualValidation) {
- this.manualValidation = manualValidation;
+ this._manualValidation = manualValidation;
}
/**
@@ -588,15 +571,15 @@
}
public void addHelper( IValidatorJob validator, IWorkbenchContext helper ){
- helpers.put( validator, helper );
+ _helpers.put( validator, helper );
}
public void removeHelper( IValidatorJob validator ){
- helpers.remove( validator );
+ _helpers.remove( validator );
}
private IWorkbenchContext getHelper( IValidatorJob validator ){
- return (IWorkbenchContext)helpers.get( validator );
+ return _helpers.get( validator );
}
public IWorkbenchContext getHelper( IProject project, IValidator validator ){
@@ -626,19 +609,19 @@
}
public Expression getEnablementExpresion() {
- return enablementExpression;
+ return _enablementExpression;
}
public void setEnablementElement(Expression enablementElement) {
- enablementExpression = enablementElement;
+ _enablementExpression = enablementElement;
}
public String[] getContentTypeIds() {
- return contentTypeIds;
+ return _contentTypeIds;
}
public void setContentTypeIds(String[] contentTypeIds) {
- this.contentTypeIds = contentTypeIds;
+ this._contentTypeIds = contentTypeIds;
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/OneValidatorOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/OneValidatorOperation.java
index c11ec1d..144240e 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/OneValidatorOperation.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/OneValidatorOperation.java
@@ -117,7 +117,7 @@
throw new IllegalArgumentException(validatorId);
}
- Set enabled = new HashSet();
+ Set<ValidatorMetaData> enabled = new HashSet<ValidatorMetaData>();
enabled.add(vmd);
setEnabledValidators(enabled);
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidator.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidator.java
index ab5f941..2d2da6a 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidator.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidator.java
@@ -18,6 +18,8 @@
import java.util.List;
+import org.eclipse.core.resources.IFile;
+
/**
* @author vijayb
*/
@@ -29,5 +31,5 @@
* @param inputFiles
* @return a list of IFile's.
*/
- public List getReferencedFile(List inputFiles);
+ public List<IFile> getReferencedFile(List inputFiles);
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidatorHelper.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidatorHelper.java
index 6406ffa..b927783 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidatorHelper.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidatorHelper.java
@@ -30,16 +30,15 @@
*/
public class ReferencialFileValidatorHelper {
public ReferencialFileValidatorHelper() {
- super();
}
/**
* Return a list of all files contained in project to infinite depth
*/
public static List getAllProjectFiles(IProject project) {
- List result = new ArrayList();
- if (project == null)
- return result;
+ List<IFile> result = new ArrayList<IFile>();
+ if (project == null)return result;
+
try {
result = collectFiles(project.members(), result);
} catch (CoreException e) {
@@ -48,15 +47,11 @@
return result;
}
- private static List collectFiles(IResource[] members, List result) throws CoreException {
+ private static List<IFile> collectFiles(IResource[] members, List<IFile> result) throws CoreException {
// recursively collect files for the given members
- for (int i = 0; i < members.length; i++) {
- IResource res = members[i];
- if (res instanceof IFolder) {
- collectFiles(((IFolder) res).members(), result);
- } else if (res instanceof IFile) {
- result.add(res);
- }
+ for (IResource res : members) {
+ if (res instanceof IFolder)collectFiles(((IFolder) res).members(), result);
+ else if (res instanceof IFile)result.add((IFile)res);
}
return result;
}
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 fb5ba07..39cc826 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
@@ -48,22 +48,19 @@
*/
public class ValidationBuilder extends IncrementalProjectBuilder {
public static final int NO_DELTA_CHANGE = -1;
- protected List referencedProjects;
+ protected List<IProject> referencedProjects;
protected IWorkbenchContext workbenchContext = null;
public ValidationBuilder() {
super();
}
- private IProject[] getAllReferencedProjects(IProject project, Set visitedProjects) {
- if (visitedProjects == null)
- visitedProjects = new HashSet();
- else if (visitedProjects.contains(project))
- return getReferencedProjects();
- else
- visitedProjects.add(project);
+ private IProject[] getAllReferencedProjects(IProject project, Set<IProject> visitedProjects) {
+ if (visitedProjects == null)visitedProjects = new HashSet<IProject>();
+ else if (visitedProjects.contains(project))return getReferencedProjects();
+ else visitedProjects.add(project);
if (referencedProjects == null)
- referencedProjects = new ArrayList();
+ referencedProjects = new ArrayList<IProject>();
try {
if (project.isAccessible()) {
IProject[] refProjArray = project.getReferencedProjects();
@@ -138,10 +135,7 @@
private IProject[] getReferencedProjects() {
IProject[] refProjArray = new IProject[referencedProjects.size()];
- for (int i = 0; i < referencedProjects.size(); i++) {
- refProjArray[i] = (IProject) referencedProjects.get(i);
- }
- return refProjArray;
+ return referencedProjects.toArray(refProjArray);
}
public IProject[] build(int kind, Map parameters, IProgressMonitor 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 fcccffd..11ea93f 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
@@ -12,9 +12,9 @@
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -61,7 +61,6 @@
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;
-import org.eclipse.wst.validation.internal.provisional.core.MessageLimitException;
/**
* Implemented Validators methods must not be called directly by anyone other than this class, since
@@ -100,29 +99,23 @@
* @deprecated Will be removed in Milestone 3. Use DEFAULT_ASYNC
*/
protected static final boolean DEFAULT_FORK = false; // @deprecated
- private IProject _project = null; // project to be validated
- private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT; // which
- // pass
- // should
- // the
- // validation
- // invoke
+ private IProject _project; // project to be validated
+ private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT;
private boolean _fork = DEFAULT_ASYNC; // do not fork the validation into a
// different thread by default
- private Map _fileDeltas = null; // To reduce object creation,
- private IResourceDelta _delta = null;
+ private Map<ValidatorMetaData, Set<IFileDelta>> _fileDeltas; // To reduce object creation,
+ private IResourceDelta _delta;
+
// the resource delta tree to be processed, or null if a full build/menu
// option was triggered. This value is cached so that validation can be run
// either from a builder, or from a menu item. (The Operation interface
// doesn't allow any parameter on execute except the IProgressMonitor.)
- private Set _enabledValidators = null;
- private boolean _force = DEFAULT_FORCE; // force this operation to run even
- // if it doesn't need to?
- private boolean _isFullValidate = false; // Run a full validation or an
- // incremental? (true = full)
- private Boolean _isAutoBuild = null; // Is the global auto-build preference
- // enabled?
- private Set _launchedValidators = null; // A list of the validators that
+ private Set<ValidatorMetaData> _enabledValidators;
+
+ private boolean _force = DEFAULT_FORCE; // force this operation to run even if it doesn't need to?
+ private boolean _isFullValidate; // Run a full validation or an incremental? (true = full)
+ private Boolean _isAutoBuild; // Is the global auto-build preference enabled?
+ private Set<ValidatorMetaData> _launchedValidators;
protected IWorkbenchContext context;
@@ -208,7 +201,7 @@
_ruleGroup = ruleGroup;
_fork = fork;
_force = force;
- _enabledValidators = new HashSet();
+ _enabledValidators = new HashSet<ValidatorMetaData>();
}
/**
@@ -222,7 +215,7 @@
_ruleGroup = ruleGroup;
_fork = fork;
_force = force;
- _enabledValidators = new HashSet();
+ _enabledValidators = new HashSet<ValidatorMetaData>();
context = aContext;
}
@@ -468,19 +461,8 @@
* run automatically.)
*/
private boolean isValidationNecessary(ValidatorMetaData vmd, IFileDelta[] delta) {
- // Validation is not necessary if:
- // 1. auto-validation has run and the validator is incremental,
- // 2. There are no files for the validator to validate.
- // There are files to validate if this is a full validation or if the
- // validator filtered in some of the deltas.
- boolean autoValidateRan = false;
- if (_isAutoBuild != null) {
- // User set the autoBuild default, so check if validation is
- // necessary or not.
- autoValidateRan = ValidatorManager.getManager().isAutoValidate(getProject(), _isAutoBuild.booleanValue()) && vmd.isIncremental();
- }
- boolean hasFiles = (isFullValidate() || (delta.length > 0));
- return (!autoValidateRan && hasFiles);
+ // Validation is not necessary if there are no files for the validator to validate.
+ return isFullValidate() || (delta.length > 0);
}
/**
@@ -505,18 +487,15 @@
return false;
}
- private Map getFileDeltas(IProgressMonitor monitor) throws CoreException {
- if (_fileDeltas == null) {
- loadFileDeltas(monitor);
- }
+ private Map<ValidatorMetaData, Set<IFileDelta>> getFileDeltas(IProgressMonitor monitor) throws CoreException {
+ if (_fileDeltas == null)loadFileDeltas(monitor);
return _fileDeltas;
}
private IFileDelta[] getFileDeltas(IProgressMonitor monitor, ValidatorMetaData vmd) throws CoreException {
- Set result = (Set) getFileDeltas(monitor).get(vmd);
- if (result == null) {
- return new IFileDelta[0];
- }
+ Set<IFileDelta> result = getFileDeltas(monitor).get(vmd);
+ if (result == null)return new IFileDelta[0];
+
IFileDelta[] temp = new IFileDelta[result.size()];
result.toArray(temp);
return temp;
@@ -542,7 +521,7 @@
}
}
- protected void setFileDeltas(Map deltas) {
+ protected void setFileDeltas(Map<ValidatorMetaData, Set<IFileDelta>> deltas) {
_fileDeltas = deltas;
}
@@ -562,7 +541,7 @@
* Return the validators which are both configured on this type of project, (as stored in
* getProject()), and enabled by the user on this project.
*/
- public Set getEnabledValidators() {
+ public Set<ValidatorMetaData> getEnabledValidators() {
return _enabledValidators;
}
@@ -570,9 +549,9 @@
* This is an internal method, subject to change without notice. It is provided only for the
* automated validation framework tests.
*/
- public Set getLaunchedValidators() {
+ public Set<ValidatorMetaData> getLaunchedValidators() {
if (_launchedValidators == null) {
- _launchedValidators = new HashSet();
+ _launchedValidators = new HashSet<ValidatorMetaData>();
}
return _launchedValidators;
}
@@ -694,10 +673,9 @@
*/
private void refFileValidateFileDelta(WorkbenchReporter reporter, ReferencialFileValidator refFileValidator) {
IResourceDelta[] resourceDelta = _delta.getAffectedChildren(IResourceDelta.ADDED | IResourceDelta.CHANGED | IResourceDelta.REMOVED);
- List inputFiles = new ArrayList();
+ List<IResource> inputFiles = new ArrayList<IResource>();
- // A list of IFile's
- List referencingFiles = new ArrayList();
+ List<IFile> referencingFiles = new ArrayList<IFile>();
if (resourceDelta != null && resourceDelta.length > 0) {
for (int i = 0; i < resourceDelta.length; i++) {
IResource resource = resourceDelta[i].getResource();
@@ -706,7 +684,7 @@
} else if (resource instanceof IFile)
inputFiles.add(resource);
}
- List rFilesToValidate = refFileValidator.getReferencedFile(inputFiles);
+ List<IFile> rFilesToValidate = refFileValidator.getReferencedFile(inputFiles);
if (rFilesToValidate != null && !rFilesToValidate.isEmpty())
referencingFiles.addAll(rFilesToValidate);
try {
@@ -722,14 +700,12 @@
* @param delta
* @return
*/
- private void getFileResourceDeltaInFolder(IResourceDelta delta, List inputFiles) {
+ private void getFileResourceDeltaInFolder(IResourceDelta delta, List<IResource> inputFiles) {
IResourceDelta[] resourceDelta = delta.getAffectedChildren();
for (int i = 0; i < resourceDelta.length; i++) {
IResource resource = resourceDelta[i].getResource();
- if (resource instanceof IFile) {
- inputFiles.add(resource);
- } else if (resource instanceof IFolder)
- getFileResourceDeltaInFolder(resourceDelta[i], inputFiles);
+ if (resource instanceof IFile)inputFiles.add(resource);
+ else if (resource instanceof IFolder)getFileResourceDeltaInFolder(resourceDelta[i], inputFiles);
}
}
@@ -745,7 +721,7 @@
List filters = data.getNameFilters();
List files = getAllFilesForFilter(filters);
if (!files.isEmpty()) {
- List fileForValidation = refFileValidator.getReferencedFile(files);
+ List<IFile> fileForValidation = refFileValidator.getReferencedFile(files);
try {
validateReferencingFiles(reporter, fileForValidation);
} catch (Exception e) {
@@ -759,10 +735,10 @@
* @param filters
* @return
*/
- private List getAllFilesForFilter(List filters) {
+ private List<IFile> getAllFilesForFilter(List filters) {
if (!filters.isEmpty()) {
List allProjectFiles = ReferencialFileValidatorHelper.getAllProjectFiles(_project);
- List filterFiles = new ArrayList();
+ List<IFile> filterFiles = new ArrayList<IFile>();
for (int i = 0; i < filters.size(); i++) {
String fileName = (String) filters.get(i);
if (fileName == null)
@@ -781,13 +757,12 @@
}
return filterFiles;
}
- return Collections.EMPTY_LIST;
+ return new LinkedList<IFile>();
}
- private void validateReferencingFiles(IReporter reporter, List referencingFiles) throws Exception {
- HashSet validatedFiles = new HashSet();
- for (int i = 0; i < referencingFiles.size(); i++) {
- IFile refFile = (IFile) referencingFiles.get(i);
+ private void validateReferencingFiles(IReporter reporter, List<IFile> referencingFiles) throws Exception {
+ Set<IFile> validatedFiles = new HashSet<IFile>();
+ for (IFile refFile : referencingFiles) {
if (!validatedFiles.contains(refFile)) {
IResource resource = refFile.getParent();
IProject project = null;
@@ -841,8 +816,8 @@
final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
IFileDelta[] delta = null;
- HashSet jobValidators = new HashSet();
- HashSet validators = new HashSet();
+ Set<ValidatorMetaData> jobValidators = new HashSet<ValidatorMetaData>();
+ Set<ValidatorMetaData> validators = new HashSet<ValidatorMetaData>();
iterator = getEnabledValidators().iterator();
@@ -866,9 +841,7 @@
e.printStackTrace();
}
boolean willRun = (isForce() || isValidationNecessary(vmd, delta));
- if( willRun ){
- jobValidators.add( vmd );
- }
+ if( willRun )jobValidators.add( vmd );
}else if (valInstance != null){
validators.add( vmd );
}
@@ -915,8 +888,6 @@
buffer.append(_isAutoBuild);
buffer.append(" "); //$NON-NLS-1$
buffer.append("isAutoValidate? "); //$NON-NLS-1$
- boolean autoBuild = (_isAutoBuild == null) ? ValidatorManager.getManager().isGlobalAutoBuildEnabled() : _isAutoBuild.booleanValue();
- buffer.append(ValidatorManager.getManager().isAutoValidate(getProject(), autoBuild));
buffer.append(" "); //$NON-NLS-1$
buffer.append("isIncremental? "); //$NON-NLS-1$
buffer.append(vmd.isIncremental());
@@ -1010,9 +981,8 @@
private void initValidateContext(IFileDelta[] delta) {
if (context instanceof WorkbenchContext) {
- ((WorkbenchContext)context).setValidationFileURIs(new ArrayList());
- for(int i = 0; i < delta.length; i++) {
- IFileDelta file = delta[i];
+ ((WorkbenchContext)context).setValidationFileURIs(new ArrayList<String>());
+ for(IFileDelta file : delta) {
if(file.getDeltaType() != IFileDelta.DELETED ) {
((WorkbenchContext)context).getValidationFileURIs().add(file.getFileName());
}
@@ -1274,8 +1244,7 @@
String message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_STARTING_VALIDATION, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
reporter.displaySubtask(message);
if (logger.isLoggingLevel(Level.FINEST)) {
- // This internal "launched validators" value is used only in
- // tests.
+ // This internal "launched validators" value is used only in tests.
getLaunchedValidators().add(vmd);
}
//initValidateContext(delta);
@@ -1304,8 +1273,6 @@
}
message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
reporter.displaySubtask(message);
- } catch (MessageLimitException exc) {
- throw exc;
} catch (OperationCanceledException exc) {
throw exc;
} catch (ValidationException exc) {
@@ -1313,48 +1280,16 @@
// accidentally wrapped a MessageLimitException instead of
// propagating it.
if (exc.getAssociatedException() != null) {
- if (exc.getAssociatedException() instanceof MessageLimitException) {
- MessageLimitException mssgExc = (MessageLimitException) exc.getAssociatedException();
- throw mssgExc;
- } else if (exc.getAssociatedException() instanceof ValidationException) {
+ if (exc.getAssociatedException() instanceof ValidationException) {
ValidationException vexc = (ValidationException) exc.getAssociatedException();
vexc.setClassLoader(validator.getClass().getClassLoader()); // first,
- // set
- // the
- // class
- // loader,
- // so
- // that
- // the
- // exception's
- // getMessage()
- // method
- // can
- // retrieve
- // the
- // resource
- // bundle
+ // set the class loader, so that the exception's getMessage() method
+ // can retrieve the resource bundle
}
}
// If there is a problem with this particular validator, log the
- // error and continue
- // with the next validator.
+ // error and continue with the next validator.
exc.setClassLoader(validator.getClass().getClassLoader()); // first,
- // set
- // the
- // class
- // loader,
- // so
- // that
- // the
- // exception's
- // getMessage()
- // method
- // can
- // retrieve
- // the
- // resource
- // bundle
if (logger.isLoggingLevel(Level.SEVERE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationOperation.validate(WorkbenchMonitor)"); //$NON-NLS-1$
@@ -1371,14 +1306,11 @@
reporter.addMessage(validator, exc.getAssociatedMessage());
}
} catch (Exception exc) {
- // If there is a problem with this particular validator, log the
- // error and continue
+ // If there is a problem with this particular validator, log the error and continue
// with the next validator.
// If a runtime exception has occured, e.g. NullPointer or
- // ClassCast, display it with the "A runtime exception has occurred
- // " messsage.
- // This will provide more information to the user when he/she calls
- // IBM Service.
+ // ClassCast, display it with the "A runtime exception has occurred" messsage.
+ // This will provide more information to the user when he/she calls Service.
if (logger.isLoggingLevel(Level.SEVERE)) {
LogEntry entry = ValidationPlugin.getLogEntry();
entry.setSourceID("ValidationOperation.validate(WorkbenchMonitor)"); //$NON-NLS-1$
@@ -1404,8 +1336,6 @@
} finally {
try {
validator.cleanup(reporter);
- } catch (MessageLimitException e) {
- throw e;
} catch (OperationCanceledException e) {
throw e;
} catch (Exception exc) {
@@ -1441,8 +1371,6 @@
}
try {
helper.cleanup(reporter);
- } catch (MessageLimitException e) {
- throw e;
} catch (OperationCanceledException e) {
throw e;
} catch (Exception exc) {
@@ -1562,7 +1490,7 @@
this.context = context;
}
- void launchJobs(HashSet validators, final WorkbenchReporter reporter) throws OperationCanceledException{
+ void launchJobs(Set<ValidatorMetaData> validators, final WorkbenchReporter reporter) throws OperationCanceledException{
final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
Iterator iterator = validators.iterator();
@@ -1681,9 +1609,8 @@
private void initValidateContext(IFileDelta[] delta, IWorkbenchContext context ) {
if (context instanceof WorkbenchContext) {
- ((WorkbenchContext)context).setValidationFileURIs(new ArrayList());
- for(int i = 0; i < delta.length; i++) {
- IFileDelta file = delta[i];
+ ((WorkbenchContext)context).setValidationFileURIs(new ArrayList<String>());
+ for(IFileDelta file : delta) {
if(file.getDeltaType() != IFileDelta.DELETED ) {
((WorkbenchContext)context).getValidationFileURIs().add(file.getFileName());
}
@@ -1727,7 +1654,7 @@
QualifiedName validatorKey = new QualifiedName(null, "Validator"); //$NON-NLS-1$
IValidatorJob validator = (IValidatorJob)job.getProperty( validatorKey );
ValidatorManager mgr = ValidatorManager.getManager();
- final ArrayList list = mgr.getMessages(validator);
+ final List list = mgr.getMessages(validator);
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationUtility.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationUtility.java
index 440c188..224e35b 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationUtility.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationUtility.java
@@ -45,7 +45,7 @@
return new String[0];
}
- Set tempSet = new HashSet();
+ Set<String> tempSet = new HashSet<String>();
for (int i = 0; i < markers.length; i++) {
IMarker marker = markers[i];
try {
@@ -54,7 +54,7 @@
// The ValidationMigrator will remove any "unowned" validation markers.
continue;
}
- tempSet.add(owner);
+ tempSet.add((String)owner);
} catch (CoreException exc) {
Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
if (logger.isLoggingLevel(Level.SEVERE)) {
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorManager.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorManager.java
index 6ba1813..1f87708 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorManager.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorManager.java
@@ -57,19 +57,21 @@
// MOF objects.
private static final Class RESOURCEUTIL_DEFAULTCLASS = org.eclipse.wst.validation.internal.operations.DefaultResourceUtil.class;
private static Class _resourceUtilClass = RESOURCEUTIL_DEFAULTCLASS;
- private static final Set EMPTY_SET = Collections.EMPTY_SET; // an empty set, provided for
- // convenience, so that we only
- // construct one empty set once.
- private Set _suspendedProjects;
- private boolean _suspendAllValidation = false;
- private static Class _messageLimitOwner;
- private String[] _internalOwners;
- private Map validatorMsgs = Collections.synchronizedMap( new HashMap() );
- private Set problemValidators = new HashSet();
+
+ // an empty set, provided for convenience, so that we only construct one empty set once.
+ private static final Set<ValidatorMetaData> EMPTY_SET = new HashSet<ValidatorMetaData>();
+
+ private Set<IProject> _suspendedProjects;
+ private boolean _suspendAllValidation = false;
+ private static Class _messageLimitOwner;
+ private String[] _internalOwners;
+ private Map<IValidatorJob, List<MessageInfo>> _validatorMsgs =
+ Collections.synchronizedMap( new HashMap<IValidatorJob, List<MessageInfo>>() );
+ private Set<ValidatorMetaData> _problemValidators = new HashSet<ValidatorMetaData>();
private ValidatorManager() {
super();
- _suspendedProjects = new HashSet();
+ _suspendedProjects = new HashSet<IProject>();
_internalOwners = new String[0];
addInternalOwner(getMessageLimitOwner());
@@ -475,12 +477,10 @@
/**
* @deprecated For use by the validation framework only.
*/
- public Set getIncrementalValidators(Collection vmds) {
- if (vmds == null) {
- return Collections.EMPTY_SET;
- }
+ public Set<ValidatorMetaData> getIncrementalValidators(Collection vmds) {
+ if (vmds == null)return new HashSet<ValidatorMetaData>();
- Set result = new HashSet();
+ Set<ValidatorMetaData> result = new HashSet<ValidatorMetaData>();
Iterator iterator = vmds.iterator();
while (iterator.hasNext()) {
ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
@@ -625,21 +625,18 @@
* Given a checked list of enabled validators, return a set of the ones which are configured on
* the project and, if getIncremental is true, which also run incrementally.
*/
- public Set getProjectConfiguredValidators(IProject project, Object[] enabledVal, boolean getIncremental) {
+ public Set<ValidatorMetaData> getProjectConfiguredValidators(IProject project, Object[] enabledVal,
+ boolean getIncremental) {
if ((project == null) || (enabledVal == null) || (enabledVal.length == 0)) {
- return Collections.EMPTY_SET;
+ return new HashSet<ValidatorMetaData>();
}
- Set val = new HashSet();
+ Set<ValidatorMetaData> val = new HashSet<ValidatorMetaData>();
for (int i = 0; i < enabledVal.length; i++) {
ValidatorMetaData vmd = (ValidatorMetaData) enabledVal[i];
- if (!vmd.isConfiguredOnProject(project)) {
- continue;
- }
+ if (!vmd.isConfiguredOnProject(project))continue;
- if (!getIncremental || vmd.isIncremental()) {
- val.add(vmd);
- }
+ if (!getIncremental || vmd.isIncremental())val.add(vmd);
}
return val;
}
@@ -690,22 +687,21 @@
}
private ValidatorMetaData[] getStateOfProjectLevelValidatorsFromGlobal(ProjectConfiguration prjp) throws InvocationTargetException {
- List enabledGlobalValidatorsForProject = new ArrayList();
+ List<ValidatorMetaData> enabledGlobalValidatorsForProject = new ArrayList<ValidatorMetaData>();
GlobalConfiguration gf = ConfigurationManager.getManager().getGlobalConfiguration();
List allProjectValidator = getAllValidatorUniqueNames(prjp.getValidators());
- ValidatorMetaData[] vmd = gf.getBuildEnabledValidators();
- for(int i = 0; i < vmd.length; i++) {
- if(allProjectValidator.contains(vmd[i].getValidatorUniqueName())) {
- enabledGlobalValidatorsForProject.add(vmd[i]);
+ for(ValidatorMetaData vmd : gf.getBuildEnabledValidators()) {
+ if(allProjectValidator.contains(vmd.getValidatorUniqueName())) {
+ enabledGlobalValidatorsForProject.add(vmd);
}
}
return (ValidatorMetaData[]) enabledGlobalValidatorsForProject.toArray(new ValidatorMetaData[enabledGlobalValidatorsForProject.size()]);
}
- private List getAllValidatorUniqueNames(ValidatorMetaData[] metaData) {
- List names = new ArrayList();
- for(int i = 0; i < metaData.length; i++) {
- names.add(metaData[i].getValidatorUniqueName());
+ private List<String> getAllValidatorUniqueNames(ValidatorMetaData[] metaData) {
+ List<String> names = new ArrayList<String>();
+ for(ValidatorMetaData vmd : metaData) {
+ names.add(vmd.getValidatorUniqueName());
}
return names;
}
@@ -946,13 +942,9 @@
* org.eclipse.wst.validation.internal.provisional.core.core.prop plugin). If you don't, validation may not be suspended.
*/
public void suspendValidation(IProject project, boolean suspend) {
- if (project == null) {
- return;
- }
+ if (project == null)return;
- if (!project.exists()) {
- return;
- }
+ if (!project.exists())return;
// Ignore whether or not the project is closed. If it's closed then it will not be built
// and the "Run Validation" option will not be available.
@@ -994,14 +986,8 @@
* will return true even though validation will not run.
*/
public boolean isSuspended(IProject project) {
- if (project == null) {
- return false;
- }
-
- if (_suspendAllValidation) {
- return true;
- }
-
+ if (project == null)return false;
+ if (_suspendAllValidation)return true;
return _suspendedProjects.contains(project);
}
@@ -1028,7 +1014,7 @@
* Given a list of validators' plugin ids, make those validators enabled for this project. All
* others, disable for this project.
*/
- public void setEnabledValidators(IProject project, Set vmdsSet, IProgressMonitor monitor) {
+ public void setEnabledValidators(IProject project, Set<ValidatorMetaData> vmdsSet, IProgressMonitor monitor) {
try {
ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
ValidatorMetaData[] vmds = null;
@@ -1208,32 +1194,31 @@
}
public void cacheMessage(IValidatorJob validator, MessageInfo info){
- ArrayList list = (ArrayList) validatorMsgs.get(validator);
+ List<MessageInfo> list = _validatorMsgs.get(validator);
if( list == null ){
- list = new ArrayList();
- validatorMsgs.put(validator, list);
+ list = new ArrayList<MessageInfo>();
+ _validatorMsgs.put(validator, list);
}
list.add(info);
}
- public ArrayList getMessages(IValidatorJob validator){
- ArrayList list = (ArrayList) validatorMsgs.get(validator);
- if( list == null )
- list = new ArrayList();
+ public List getMessages(IValidatorJob validator){
+ List<MessageInfo> list = _validatorMsgs.get(validator);
+ if( list == null )list = new ArrayList<MessageInfo>();
return list;
}
public void clearMessages(IValidatorJob validator){
- ArrayList list = (ArrayList) validatorMsgs.get(validator);
+ List<MessageInfo> list = _validatorMsgs.get(validator);
if( list != null ){
list.clear();
}
- validatorMsgs.remove( validator );
+ _validatorMsgs.remove( validator );
}
- public Set getProblemValidators() {
- return problemValidators;
+ public Set<ValidatorMetaData> getProblemValidators() {
+ return _problemValidators;
}
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorSubsetOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorSubsetOperation.java
index d80a789..46a46b4 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorSubsetOperation.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorSubsetOperation.java
@@ -249,7 +249,7 @@
}
if ((changedResources != null) && (changedResources.length > 0)) {
- Set tempSet = new HashSet();
+ Set<IProject> tempSet = new HashSet<IProject>();
for (int i = 0; i < changedResources.length; i++) {
IProject p = changedResources[i].getProject();
if (!p.isOpen()) {
@@ -266,9 +266,9 @@
}
if (tempSet.size() != 1) {
StringBuffer buffer = new StringBuffer("\n"); //$NON-NLS-1$
- Iterator iterator = tempSet.iterator();
+ Iterator<IProject> iterator = tempSet.iterator();
while (iterator.hasNext()) {
- IProject p = (IProject) iterator.next();
+ IProject p = iterator.next();
buffer.append("\t"); //$NON-NLS-1$
buffer.append(p.getName());
if (iterator.hasNext()) {
@@ -288,22 +288,7 @@
setEnabledValidators(InternalValidatorManager.wrapInSet(vmds));
setFileDeltas(FilterUtil.getFileDeltas(getEnabledValidators(), changedResources, ifileDeltaType)); // construct
- // an
- // array
- // of
- // IFileDelta[]
- // to
- // wrap
- // the
- // IResource[];
- // one
- // IFileDelta
- // for
- // each
- // IResource
- // in
- // the
- // array
+ // an array of IFileDelta[] to wrap the IResource[]; one IFileDelta for each IResource in the array
}
/**
@@ -313,14 +298,14 @@
* of IProject.)
*/
public void setValidators(String[] validatorNames) throws IllegalArgumentException {
- Set enabled = new HashSet();
- for (int i = 0; i < validatorNames.length; i++) {
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorNames[i]);
+ Set<ValidatorMetaData> enabled = new HashSet<ValidatorMetaData>();
+ for (String name : validatorNames) {
+ ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(name);
if (vmd == null) {
// No validator, with that plugin id, can be run on that project.
// Either the validator isn't installed, or the IProject passed in
// doesn't have the necessary nature.
- throw new IllegalArgumentException(validatorNames[i]);
+ throw new IllegalArgumentException(name);
}
enabled.add(vmd);
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchContext.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchContext.java
index 11ca168..0191874 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchContext.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchContext.java
@@ -37,10 +37,10 @@
* symbolic model name.
*/
public class WorkbenchContext implements IWorkbenchContext {
- private IProject _project;
- private Hashtable _modelRegistry;
- private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT;
- public List validationFileURIs;
+ private IProject _project;
+ private Hashtable<String,Method> _modelRegistry;
+ private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT;
+ public List<String> validationFileURIs;
public static final String GET_PROJECT_FILES = "getAllFiles"; //$NON-NLS-1$
public static final String GET_FILE = "getFile"; //$NON-NLS-1$
public static final String VALIDATION_MARKER = "com.ibm.etools.validation.problemmarker"; //$NON-NLS-1$
@@ -48,7 +48,7 @@
public WorkbenchContext() {
super();
- _modelRegistry = new Hashtable();
+ _modelRegistry = new Hashtable<String, Method>();
registerModel(IRuleGroup.PASS_LEVEL, "loadRuleGroup"); //$NON-NLS-1$
@@ -388,10 +388,10 @@
* @param validatorClassName The name of the validator class.
* @return The collection of files relevant for the validator class specified.
*/
- public Collection getFiles(String validatorClassName)
+ public Collection<IFile> getFiles(String validatorClassName)
{
IProject project = getProject();
- List files = new ArrayList();
+ List<IFile> files = new ArrayList<IFile>();
getFiles(files, project, validatorClassName);
return files;
}
@@ -404,7 +404,7 @@
* @param resource The resource to look for files in.
* @param validatorClassName The name of the validator class.
*/
- protected void getFiles(Collection files, IContainer resource, String validatorClassName)
+ protected void getFiles(Collection<IFile> files, IContainer resource, String validatorClassName)
{
try
{
@@ -414,7 +414,7 @@
if (ValidatorManager.getManager().isApplicableTo(validatorClassName, resourceArray[i]))
{
if (resourceArray[i] instanceof IFile)
- files.add(resourceArray[i]);
+ files.add((IFile)resourceArray[i]);
}
if (resourceArray[i].getType() == IResource.FOLDER)
getFiles(files,(IContainer)resourceArray[i], validatorClassName) ;
@@ -547,9 +547,7 @@
* "registerModel" method.
*/
public final boolean isRegistered(String symbolicName) {
- if (symbolicName == null) {
- return false;
- }
+ if (symbolicName == null)return false;
return _modelRegistry.containsKey(symbolicName);
}
@@ -575,10 +573,8 @@
*/
public Object loadModel(String symbolicName, Object[] parms) {
try {
- Method loader = (Method) _modelRegistry.get(symbolicName);
- if (loader == null) {
- return null;
- }
+ Method loader = _modelRegistry.get(symbolicName);
+ if (loader == null)return null;
return loader.invoke(this, parms);
} catch (IllegalAccessException exc) {
@@ -761,28 +757,26 @@
}
public String getTargetObjectName(Object object) {
- // TODO Auto-generated method stub
return null;
}
public String[] getURIs() {
String[] uris = new String[validationFileURIs.size()];
- for(int i = 0; i < validationFileURIs.size(); i++)
- uris[i] = (String) validationFileURIs.get(i);
+ validationFileURIs.toArray(uris);
return uris;
}
/**
* @return Returns the validationFileURIs.
*/
- public List getValidationFileURIs() {
+ public List<String> getValidationFileURIs() {
return validationFileURIs;
}
/**
* @param validationFileURIs The validationFileURIs to set.
*/
- public void setValidationFileURIs(List validationFileURIs) {
+ public void setValidationFileURIs(List<String> validationFileURIs) {
this.validationFileURIs = validationFileURIs;
}
}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationHelperRegistryReader.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationHelperRegistryReader.java
index dccd886..d38026c 100644
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationHelperRegistryReader.java
+++ b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationHelperRegistryReader.java
@@ -28,7 +28,7 @@
static final String ATT_HELPER_CLASS = "helperClass"; //$NON-NLS-1$
private static ValidationHelperRegistryReader INSTANCE = null;
- private List validationHelpers = null;
+ private List<IProjectValidationHelper> _validationHelpers;
public ValidationHelperRegistryReader() {
super(ValidationPlugin.PLUGIN_ID, VALIDATION_HELPER);
@@ -42,10 +42,10 @@
return INSTANCE;
}
- private List getValidationHelpers() {
- if (validationHelpers == null)
- validationHelpers = new ArrayList();
- return validationHelpers;
+ private List<IProjectValidationHelper> getValidationHelpers() {
+ if (_validationHelpers == null)
+ _validationHelpers = new ArrayList<IProjectValidationHelper>();
+ return _validationHelpers;
}
public boolean readElement(IConfigurationElement element) {
@@ -63,9 +63,8 @@
}
public IProjectValidationHelper getValidationHelper() {
- if (getValidationHelpers().isEmpty())
- return null;
- return (IProjectValidationHelper) getValidationHelpers().get(0);
+ if (getValidationHelpers().isEmpty())return null;
+ return getValidationHelpers().get(0);
}
}
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 ee22b90..8ba1959 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,8 +10,8 @@
*******************************************************************************/
package org.eclipse.wst.validation.internal.core;
-import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.logging.Level;
import org.eclipse.core.runtime.CoreException;
@@ -86,7 +86,7 @@
//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);
+ final List list = mgr.getMessages((IValidatorJob)validator);
Iterator it = list.iterator();
while( it.hasNext() ){
diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IReporter.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IReporter.java
index 13ea2dc..0786ab9 100644
--- a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IReporter.java
+++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IReporter.java
@@ -53,12 +53,6 @@
* The validator which is the source of the message.
* @param message
* A message to be reported
- * @exception MessageLimitException
- * is thrown when the total number of messages reported exceeds the maximum
- * allowed.
- * [issue: LM - This exception seems questionable to me. Why do validators need to know how
- * to handle a MessageLimitException? Seems to me that this is a validation framework
- * specific issue and that client validators shouldn't know about this at all. ]
*/
void addMessage(IValidator origin, IMessage message);
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ReporterHelper.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ReporterHelper.java
index c290435..bf99db5 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ReporterHelper.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ReporterHelper.java
@@ -50,13 +50,11 @@
}
public void removeAllMessages(IValidator origin, Object object) {
- // TODO Auto-generated method stub
-
+ _list.clear();
}
public void removeMessageSubset(IValidator validator, Object obj, String groupName) {
- // TODO Auto-generated method stub
-
+ _list.clear();
}
public void makeMarkers(){
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java
index d6b5fbd..b1ac4ba 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java
@@ -131,7 +131,6 @@
*/
public ValidationResults validate(IProject[] projects, final boolean isManual, final boolean isBuild,
IProgressMonitor monitor) throws CoreException{
- //FIXME must handle the old validators as well
ValOperation vo = ValidationRunner.validate(createMap(projects), isManual, isBuild, monitor);
return vo.getResults();
}
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationResult.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationResult.java
index c41789c..7fe251c 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationResult.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationResult.java
@@ -11,7 +11,7 @@
* @author karasiuk
*
*/
-public class ValidationResult {
+public final class ValidationResult {
private List<ValidatorMessage> _messages;
@@ -36,6 +36,9 @@
private int _severityWarning;
private int _severityInfo;
+ /** A count of the number of resources that were validated. */
+ private int _numberOfValidatedResources;
+
/**
* This is an optional method, that a validator can use to return error messages. When the validation framework
* is invoking the validator these will be converted into IMarkers. If the validator is being called directly then
@@ -84,6 +87,9 @@
incrementWarning(result.getSeverityWarning());
incrementInfo(result.getSeverityInfo());
+ _numberOfValidatedResources++;
+ if (result.getValidated() != null)_numberOfValidatedResources += result.getValidated().length;
+
}
@@ -248,4 +254,11 @@
_canceled = canceled;
}
+ /**
+ * Answer the number of resources that have been validated.
+ */
+ public int getNumberOfValidatedResources() {
+ return _numberOfValidatedResources;
+ }
+
}