Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.wst.validation/validate/org/eclipse')
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java78
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationManager.java275
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/EventManager.java430
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/FilterUtil.java732
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java185
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IProjectValidationHelper.java22
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IValidationSelectionHandler.java35
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/InternalValidatorManager.java206
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java615
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorExtension.java86
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorRegistryReader.java130
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/RegistryConstants.java71
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceConstants.java117
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceHandler.java111
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TaskListUtility.java571
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TimeEntry.java102
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/VThreadManager.java169
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java769
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationFactoryImpl.java34
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java1394
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationSelectionHandlerRegistryReader.java90
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorActionFilter.java130
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorFilter.java111
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java510
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorNameFilter.java170
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorTypeFilter.java157
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/AllValidatorsOperation.java72
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/DefaultResourceUtil.java25
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledIncrementalValidatorsOperation.java236
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java165
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IResourceUtil.java22
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IRuleGroup.java41
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java176
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/LocalizedMessage.java64
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/OneValidatorOperation.java124
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidator.java29
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidatorHelper.java69
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ResourceHandler.java20
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/TaskListHelper.java107
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java300
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationConstants.java25
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationOperation.java1475
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationUtility.java121
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorManager.java1363
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorSubsetOperation.java317
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchContext.java790
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchFileDelta.java78
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchReporter.java733
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationHelperRegistryReader.java69
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationPlugin.java159
-rw-r--r--plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/provisional/ValidationFactory.java46
51 files changed, 0 insertions, 13926 deletions
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java
deleted file mode 100644
index 00d4b3698..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationConstants.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * Validation constants needed to implement the marker extension point and the user's preferences.
- *
- * Only the validation framework should use this interface.
- */
-public interface ConfigurationConstants {
- /* package */static final String ASYNC_SETTING = "runAsync"; //$NON-NLS-1$ // boolean (Use the global preferences or override)
- /* package */static final String AUTO_SETTING = "autoValidate"; //$NON-NLS-1$ // boolean
- /* package */static final String BUILD_SETTING = "runWhenBuild"; //$NON-NLS-1$ // boolean
-
- // Defaults for the preference and project values
-
- /* package */static String CURRENT_VERSION = (String) ValidationPlugin.getPlugin().getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); //$NON-NLS-1$ // this is a constant, so it should be intern
- /* package */static final boolean DEFAULT_ASYNC = true;
- /* package */static final boolean DEFAULT_AUTO_SETTING = true;
- /* package */static final boolean DEFAULT_BUILD_SETTING = true;
- /* package */static ValidatorMetaData[] DEFAULT_ENABLED_VALIDATORS = ValidationRegistryReader.getReader().getValidatorMetaDataArrayEnabledByDefault(); //$NON-NLS-1$ // store a copy here so that we don't modify the original and don't create a copy every time we need this value
- /* package */static final int DEFAULT_MAXNUMMESSAGES = 50;
- public static final int DEPTH_INFINITE = IResource.DEPTH_INFINITE;
- public static final int DEPTH_ZERO = IResource.DEPTH_ZERO;
- /* package */static final String ELEMENT_SEPARATOR = ";"; //$NON-NLS-1$ // separates the name of one IValidator from the next in the list of enabled validators for a project or preference
-
- // The following values must match the attributes in the preference marker as shown in
- // plugin.xml
- // Even though the plugin.xml values are not used to create new Preference or Project markers,
- // maintaining one local name ensures that there's no confusion writing the migration code.
- // These are the QualifiedNames used to persist the user's settings.
- /* package */static final String ENABLED_VALIDATORS = "enabledValidatorList"; //$NON-NLS-1$ // String
- public static final String J2EE_PLUGIN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$ // For 4.03, this is the plugin id that the validation constants were declared in.
- /* package */static final String MAXNUMMESSAGES = "maxNumMessages"; //$NON-NLS-1$ // integer
- public static final String PLUGIN_ID = ValidationPlugin.PLUGIN_ID;
- /* package */static final String PREF_PROJECTS_CAN_OVERRIDE = "projectsCanOverride"; //$NON-NLS-1$ // boolean
- // end validation message marker constants
-
- // Preference and Project constants
- /* package */static final String PREFERENCE_MARKER = PLUGIN_ID + ".preferencemarker"; //$NON-NLS-1$
- /* package */static final String PRJ_MARKER = PLUGIN_ID + ".projectmarker"; //$NON-NLS-1$ // The extension which saves user validation preferences for a particular project (e.g. which validators run on the project)
- /* package */static final String PRJ_MARKER_403 = J2EE_PLUGIN_ID + ".projectmarker"; //$NON-NLS-1$ // The extension which saves user validation preferences for a particular project (e.g. which validators run on the project)
- /* package */static final String PRJ_OVERRIDEGLOBAL = "overrideGlobalPreferences"; //$NON-NLS-1$ // boolean (Use the global preferences or override)
-
- /* package */static final QualifiedName USER_PREFERENCE = new QualifiedName(PLUGIN_ID, "ValidationConfiguration"); //$NON-NLS-1$ // ValidationConfiguration for the IResource
-
- // Validation message marker constants
- /* package */static final String VALIDATION_MARKER = PLUGIN_ID + ".problemmarker"; //$NON-NLS-1$ // The extension which is used to add validation markers to the task list
- /* package */static final String VALIDATION_MARKER_GROUP = "groupName"; //$NON-NLS-1$ // For incremental validation, this field associates a message with a group, so that a subset of messages may be removed from a file.
- /* package */static final String VALIDATION_MARKER_MESSAGEID = "messageId"; //$NON-NLS-1$ // Persist the message id of the message, not just the translated text.
-
- // The following values must match the attributes in the validation message marker as shown in
- // plugin.xml
- /* package */static final String VALIDATION_MARKER_OWNER = "owner"; //$NON-NLS-1$ // The IValidator who owns the IMarker on the task list
- /* package */static final String VALIDATION_MARKER_SEVERITY = "validationSeverity"; //$NON-NLS-1$ // one of the SeverityEnum values
- /* package */static final String VALIDATION_MARKER_TARGETOBJECT = "targetObject"; //$NON-NLS-1$ // When more than one target object resolves to the same IResource, this field identifies which targetObject owns a particular message.
- /* package */static final String VERSION = "version"; //$NON-NLS-1$
-
- // WSAD versions which created markers of these types
- /* package */static final String VERSION4_03 = "4.03"; //$NON-NLS-1$
- /* package */static final String VERSION5_0 = "5.0"; //$NON-NLS-1$
- /* package */static final String VERSION5_01 = "5.0.1"; //$NON-NLS-1$
- // end preference and project defaults
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationManager.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationManager.java
deleted file mode 100644
index a5f7fc125..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ConfigurationManager.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * Only the validation framework can use this class.
- */
-public final class ConfigurationManager implements ConfigurationConstants {
- private static ConfigurationManager inst = null;
-
- private ConfigurationManager() {
- //Default constructor
- }
-
- public static ConfigurationManager getManager() {
- if (inst == null) {
- inst = new ConfigurationManager();
- }
- return inst;
- }
-
- /**
- * Given a validation marker, return the fully-qualified class name of the validator who owns
- * the message. If the validator cannot be found or if the marker is not a validation marker,
- * return null.
- */
- public String getValidator(IMarker marker) {
- if (marker == null) {
- return null;
- }
-
- try {
- if (!marker.getType().equals(VALIDATION_MARKER)) {
- return null;
- }
-
- Object attrib = marker.getAttribute(VALIDATION_MARKER_OWNER);
- if (attrib == null) {
- // owner not set
- return null;
- }
- return attrib.toString();
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("InternalPreferenceManager.getValidator(IMarker)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- }
-
- /**
- * Return true if the given marker is a validation marker. Otherwise return false.
- */
- public boolean isValidationMarker(IMarker marker) {
- if (marker == null) {
- return false;
- }
-
- try {
- return marker.getType().equals(VALIDATION_MARKER);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("InternalPreferenceManager.isValidationMarker(IMarker)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return false;
- }
- }
-
- /**
- * This method is for use by the TVT Validation plugin ONLY!!! No code should access the
- * validation markers in the list directly except for the validation framework and the TVT
- * Validation plugin.
- */
- public void removeAllValidationMarkers(IProject project) {
- if ((project == null) || (!project.isOpen())) {
- return;
- }
-
- try {
- project.deleteMarkers(VALIDATION_MARKER, false, DEPTH_INFINITE); // false means only
- // consider VALIDATION_MARKER, not variants of VALIDATION_MARKER.
- //Since addTask only adds VALIDATION_MARKER, we don't need to consider its subtypes.
- } catch (CoreException exc) {
- // Couldn't retrieve the markers from the resource for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("WorkbenchMonitor.removeAllValidationMarkers(IProject)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- /**
- * This method returns the global preferences for the workspace.
- */
- public GlobalConfiguration getGlobalConfiguration() throws InvocationTargetException {
- IWorkspaceRoot root = ValidationConfiguration.getRoot();
- GlobalConfiguration gp = null;
- try {
- gp = (GlobalConfiguration) root.getSessionProperty(USER_PREFERENCE);
- if (gp == null) {
- gp = new GlobalConfiguration(root);
- gp.getVersion(); // initialize the configuration's version attribute
- gp.load(); // initialize this instance from the stored values
- gp.passivate(); // store this instance as a property on the IResource
- }
- return gp;
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{root.getName()}));
- }
- }
-
- public ProjectConfiguration getProjectConfiguration(IProject project) throws InvocationTargetException {
- ProjectConfiguration prjp = null;
- try {
- prjp = (ProjectConfiguration) project.getSessionProperty(USER_PREFERENCE);
- if (prjp == null || !prjp.getResource().exists()) {
- prjp = new ProjectConfiguration(project);
- prjp.getVersion(); // initialize the configuration's version attribute
- prjp.load(); // initialize this instance from the stored values
- prjp.passivate(); // store this instance as a property on the IResource
- }
- return prjp;
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{project.getName()}));
- }
- }
-
- public ProjectConfiguration getProjectConfigurationWithoutMigrate(IProject project) throws InvocationTargetException {
- ProjectConfiguration prjp = null;
- try {
- prjp = (ProjectConfiguration) project.getSessionProperty(USER_PREFERENCE);
- if (prjp == null || !prjp.getResource().exists()) {
- prjp = new ProjectConfiguration(project);
- prjp.getVersion(); // initialize the configuration's version attribute
- prjp.load(); // initialize this instance from the stored values
- prjp.passivate(); // store this instance as a property on the IResource
- }
- return prjp;
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{project.getName()}));
- }
- }
-
-
- /**
- * The nature of the project has changed; update the enabled validators on the project.
- */
- public void resetProjectNature(IProject project) throws InvocationTargetException {
- resetProjectNature(getProjectConfiguration(project));
- }
-
- /**
- * When a project has been created for the first time, its natures may not have been complete at
- * the time that this Preference was recreated. Call this method to recalculate the vmds.
- */
- protected void resetProjectNature(ProjectConfiguration prjp) throws InvocationTargetException {
- prjp.resetProjectNature();
- }
-
- public void closing(IProject project) {
- try {
- if (isMigrated(project)) {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- prjp.store();
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("InternalPreferenceManager::closing(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- public void deleting(IProject project) {
- }
-
- public void opening(IProject project) {
- // Do not load or migrate the project in this method; let the getConfiguration(IProject)
- // method do that. Do not load the project before it's necessary.
- }
-
- /**
- * Return true if the global preferences are at the current level of metadata, false otherwise.
- */
- public boolean isGlobalMigrated() throws InvocationTargetException {
- IWorkspaceRoot root = ValidationConfiguration.getRoot();
- if (root == null) {
- return false;
- }
-
- try {
- GlobalConfiguration gp = (GlobalConfiguration) root.getSessionProperty(USER_PREFERENCE);
- if (gp != null) {
- return gp.isVersionCurrent();
- }
-
- String serializedPrjp = root.getPersistentProperty(USER_PREFERENCE);
- if (serializedPrjp != null) {
- gp = new GlobalConfiguration(root);
- gp.getVersion(); // initialize the configuration's version attribute
- return gp.isVersionCurrent();
- }
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{root.getName()}));
- }
-
- return false;
- }
-
- /**
- * Return true if the given project has the current level of metadata, false otherwise.
- */
- public boolean isMigrated(IProject project) throws InvocationTargetException {
- if (project == null) {
- return false;
- }
- try {
- if (project.isAccessible()) {
- ProjectConfiguration prjp = (ProjectConfiguration) project.getSessionProperty(USER_PREFERENCE);
- if (prjp != null) {
- return prjp.isVersionCurrent();
- }
- String serializedPrjp = project.getPersistentProperty(USER_PREFERENCE);
- if (serializedPrjp != null) {
- prjp = new ProjectConfiguration(project);
- prjp.getVersion(); // initialize the configuration's
- // version attribute
- return prjp.isVersionCurrent();
- }
- }
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{project.getName()}));
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/EventManager.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/EventManager.java
deleted file mode 100644
index fa7a23288..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/EventManager.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.UIContextDetermination;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * This class manages resource change events for the validation framework.
- */
-public class EventManager implements IResourceChangeListener {
- private static EventManager _inst = null;
- private boolean _shutdown = false; // false means that eclipse is not shutting down, and true
- // means that it is shutting down. Used in two methods:
- // shutdown(),and resourceChanged(IResourceChangeEvent)
- private IResourceDeltaVisitor _postAutoBuildVisitor = null;
- private boolean _isActive = false; // has the registry been read?
-
- private EventManager() {
- super();
- }
-
- public static EventManager getManager() {
- if (_inst == null) {
- _inst = new EventManager();
- }
- return _inst;
- }
-
- public void opening(IProject project) {
- if (project == null || !ValidationPlugin.isActivated()) {
- return;
- }
-
- // When the project is opened, check for any orphaned tasks
- // or tasks whose owners need to be updated.
- ConfigurationManager.getManager().opening(project);
- }
-
- public void closing(IProject project) {
- if (project == null || !ValidationPlugin.isActivated()) {
- return;
- }
-
- try {
- boolean isMigrated = ConfigurationManager.getManager().isMigrated(project);
- // If it's not migrated, then it hasn't been loaded, and we don't want to load the
- // validator and its prerequisite plugins until they're needed.
- if (isMigrated) {
- ValidatorMetaData[] vmds = ConfigurationManager.getManager().getProjectConfiguration(project).getValidators();
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
-
- if (!vmd.isActive()) {
- // If this validator has not been activated, or if it has been shut down,
- // don't activate it again.
- continue;
- }
-
- IWorkbenchContext helper = null;
- try {
- helper = vmd.getHelper(project);
- helper.closing();
- } catch (InstantiationException exc) {
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EventManager::closing(IProject)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
-
- continue;
- } catch (Throwable exc) {
- // If there is a problem with this particular helper, log the error and
- // continue
- // with the next validator.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EventManager::closing(IProject)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
- }
-
- ConfigurationManager.getManager().closing(project);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("EventManager::closing(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- public void deleting(IProject project) {
- if (project == null) {
- return;
- }
-
- try {
- boolean isMigrated = ConfigurationManager.getManager().isMigrated(project);
- // If it's not migrated, then it hasn't been loaded, and we don't want to load the
- // validator and its prerequisite plugins until they're needed.
- if (isMigrated) {
- ValidatorMetaData[] vmds = ConfigurationManager.getManager().getProjectConfiguration(project).getValidators();
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
-
- if (!vmd.isActive()) {
- // If this validator has not been activated, or if it has been shut down,
- // don't activate it again.
- continue;
- }
-
- IWorkbenchContext helper = null;
- try {
- helper = vmd.getHelper(project);
- helper.deleting();
- } catch (InstantiationException exc) {
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EventManager::deleting(IProject)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
-
- continue;
- } catch (Throwable exc) {
- // If there is a problem with this particular helper, log the error and
- // continue
- // with the next validator.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EventManager::deleting(IProject)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
- }
-
- ConfigurationManager.getManager().deleting(project);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("EventManager::deleting(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- /**
- * If a project's description changes, The project may have changed its nature. Update the cache
- * to reflect the new natures. The project could be opening. Migrate.
- */
- private void postAutoChange(IResourceDelta delta) {
- if (_postAutoBuildVisitor == null) {
- _postAutoBuildVisitor = new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta subdelta) throws CoreException {
- if (subdelta == null)
- return true;
-
- IResource resource = subdelta.getResource();
- if (resource instanceof IProject) {
- IProject project = (IProject) resource;
- if ((subdelta.getFlags() & IResourceDelta.DESCRIPTION) == IResourceDelta.DESCRIPTION) {
- try {
- ConfigurationManager.getManager().resetProjectNature(project); // flush
- // existing
- // "enabled
- // validator"
- // settings
- // and
- // reset
- // to
- // default
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("EventManager::postAutoChange"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- return false;
- }
-
- if ((subdelta.getFlags() & IResourceDelta.OPEN) == IResourceDelta.OPEN) {
- if (project.isOpen()) {
- // Project was just opened. If project.isOpen() had returned false,
- // project
- // would just have been closed.
- opening(project);
- }
- // closing is called by PRE_CLOSE in resourceChanged
- // else {
- // closing(project);
- // }
- }
- }
-
- return true;
- }
- };
- }
-
- try {
- delta.accept(_postAutoBuildVisitor, true);
- } catch (CoreException exc) {
- exc.printStackTrace();
- }
- }
-
- /**
- * Notifies this manager that some resource changes have happened on the platform. If the change
- * is a project deletion, that project should be removed from the cache.
- *
- * @see IResourceDelta
- * @see IResource
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (_shutdown && (!isActive())) {
- // If we're shutting down, and nothing has been activated, don't need to
- // do anything.
- return;
- }
-
- /*
- * StringBuffer buffer = new StringBuffer(); buffer.append("IResourceChangeEvent type = ");
- * buffer.append(event.getType()); buffer.append(", resource = ");
- * buffer.append(event.getResource()); buffer.append(", source = ");
- * buffer.append(event.getSource()); buffer.append(", delta = ");
- * buffer.append(event.getDelta()); System.out.println(buffer.toString());
- */
-
- if (event.getSource() instanceof IWorkspace) {
- if ((event.getType() == IResourceChangeEvent.PRE_DELETE) && (event.getResource() instanceof IProject)) {
- deleting((IProject) event.getResource());
- } else if ((event.getType() == IResourceChangeEvent.PRE_CLOSE) && (event.getResource() instanceof IProject)) {
- closing((IProject) event.getResource());
- } else if (event.getType() == IResourceChangeEvent.POST_BUILD) {
- postAutoChange(event.getDelta());
- }
-
- }
- }
-
- /**
- * Notifies this manager that the ValidationPlugin is shutting down. (Usually implies that
- * either the plugin could not load, or that the workbench is shutting down.)
- *
- * The manager will then notify all active helpers of the shutdown, so that they may perform any
- * last-minute writes to disk, cleanup, etc.
- */
- public void shutdown() {
- try {
- _shutdown = true; // resourceChanged(IResourceChangeEvent) needs to know when a shutdown
- // has started.
-
- /*
- * if( !isHeadless() && ConfigurationManager.getManager().isGlobalMigrated()) {
- * GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration();
- * gp.store(); // First, see if any validators are loaded. If none are, there is nothing
- * to // clean up. if(gp.numberOfValidators() == 0) { return; } }
- */
-
- // If the validators are loaded, then for every project in the workbench,
- // we must see if it has been loaded. If it has, every enabled IWorkbenchContext
- // must be called to clean up. If the project hasn't been loaded, then no
- // IWorkbenchContext built anything, and there's nothing to clean up.
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceRoot workspaceRoot = workspace.getRoot();
- IProject[] projects = workspaceRoot.getProjects();
- ProjectConfiguration prjp = null;
- IProject project = null;
- for (int i = 0; i < projects.length; i++) {
- project = projects[i];
- if (!project.isOpen()) {
- // If the project isn't opened, there's nothing to clean up.
- // If the project was opened, it would have been migrated, and there's something
- // to clean up.
- continue;
- }
-
- try {
- boolean isMigrated = ConfigurationManager.getManager().isMigrated(project);
- // If it's not migrated, then it hasn't been loaded, and we don't want to load
- // the
- // validator and its prerequisite plugins until they're needed.
- if (isMigrated) {
- prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- prjp.store();
-
- ValidatorMetaData[] vmdList = prjp.getEnabledValidators();
- // if vmdList is null, IProject has never been loaded, so nothing to clean
- // up
- if (vmdList != null) {
- for (int j = 0; j < vmdList.length; j++) {
- ValidatorMetaData vmd = vmdList[j];
-
- if (!vmd.isActive()) {
- // If this validator has not been activated, or if it has been
- // shut down, don't activate it again.
- continue;
- }
-
- IWorkbenchContext helper = vmd.getHelper(project);
- if (helper != null) {
- try {
- helper.shutdown();
- } catch (Throwable exc) {
- // Since we're shutting down, ignore the exception.
- }
- }
- }
- }
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("EventManager::shutdown(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
- } catch (Throwable exc) {
- // Since we're shutting down, ignore the exception.
- }
- }
-
- public boolean isActive() {
- // Have to use this convoluted technique for the shutdown problem.
- // i.e., when eclipse is shut down, if validation plugin hasn't been loaded,
- // the EventManager is activated for the first time, and it
- // sends many exceptions to the .log. At first, I wrote a
- // static method on ValidationRegistryReader, which returned true
- // if the registry had been read, and false otherwise. However,
- // that didn't solve the exception problem, because eclipse's
- // class loader failed to load the ValidationRegistryReader class.
- //
- // The fix is to keep all shutdown mechanisms in this class.
- // Track everything in here.
- return _isActive;
- }
-
- /**
- * This method should only be called by the ValidationRegistryReader once the registry has been
- * read.
- */
- public void setActive(boolean b) {
- _isActive = b;
- }
-
- /**
- * This method should be used to determine if the workbench is running in UI or Headless
- */
- public static boolean isHeadless() {
- boolean ret = UIContextDetermination.getCurrentContext() == UIContextDetermination.HEADLESS_CONTEXT;
- return ret;
- //return UIContextDetermination.getCurrentContext() ==
- // UIContextDetermination.HEADLESS_CONTEXT;
- }
-} \ 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
deleted file mode 100644
index 3a828138b..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/FilterUtil.java
+++ /dev/null
@@ -1,732 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-import org.eclipse.wst.validation.internal.operations.WorkbenchFileDelta;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * Utility class for the ValidationOperation hierarchy.
- */
-public final class FilterUtil {
- private static VMDDeltaVisitor _deltaVisitor = null;
- private static VMDResourceVisitor _resourceVisitor = null;
-
- private interface VMDRecorder {
- public Map getResult();
-
- public void setEnabledValidators(Set enabledValidators);
-
- public void setProgressMonitor(IProgressMonitor monitor);
-
- public IProgressMonitor getProgressMonitor();
- }
-
- 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;
- }
-
- Iterator iterator = enabledValidators.iterator();
- while (iterator.hasNext()) {
- result.put(iterator.next(), null);
- }
- return result;
- }
-
- static void checkCanceled(IProgressMonitor monitor) throws OperationCanceledException {
- 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);
- if (fileDeltas == null) {
- fileDeltas = new HashSet();
- enabledValidators.put(vmd, fileDeltas);
- }
- return fileDeltas;
- }
-
- /**
- * Given the IFileDelta type, return the corresponding IResourceDelta type.
- */
- private static int getResourceDeltaType(int ifileDeltaType) {
- switch (ifileDeltaType) {
- case (IFileDelta.ADDED) : {
- return IResourceDelta.ADDED;
- }
-
- case (IFileDelta.DELETED) : {
- return IResourceDelta.REMOVED;
- }
-
- case (IFileDelta.CHANGED) :
- default : {
- return IResourceDelta.CHANGED;
- }
- }
- }
-
- /**
- * Given the IResourceDelta type, return the corresponding IFileDelta type.
- */
- static int getFileDeltaType(int iresourceDeltaType) {
- switch (iresourceDeltaType) {
- case IResourceDelta.ADDED : // resource has been added to the workbench
- {
- return IFileDelta.ADDED;
- }
-
- case IResourceDelta.CHANGED : // resources has been changed in the workbench
- {
- return IFileDelta.CHANGED;
- }
-
- case IResourceDelta.REMOVED : // resource has been deleted from the workbench
- {
- return IFileDelta.DELETED;
- }
-
- case IResourceDelta.ADDED_PHANTOM : // incoming workbench resource
- {
- return IFileDelta.ADDED;
- }
-
- case IResourceDelta.REMOVED_PHANTOM : // outgoing workbench resource
- {
- return IFileDelta.DELETED;
- }
-
- default : {
- return IFileDelta.CHANGED;
- }
- }
- }
-
-
- /**
- * 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);
- fileDeltas.add(fileDelta);
- enabledValidators.put(vmd, fileDeltas);
- }
-
- /**
- * Return a Map wrapper, with each VMD from enabledValidators as the key, and the value a Set of
- * IFileDelta wrapper around the changed Object[].
- *
- * 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) {
- return getFileDeltas(enabledValidators, changedResources, IFileDelta.CHANGED, filterIn); // by
- // default,
- // assume
- // that
- // the
- // resources
- // have
- // changed,
- // not
- // added
- // or
- // deleted
- }
-
- /**
- * 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) {
- return getFileDeltas(enabledValidators, changedResources, ifileDeltaType, false); // by
- // default,
- // check
- // if the
- // Object[]
- // are
- // filtered
- // in by
- // the
- // validator
- }
-
- /**
- * Return a Map wrapper, with each VMD from enabledValidators as the key, and the value a Set of
- * IFileDelta wrapper around the changed Object[].
- *
- * 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();
- if ((enabledValidators == null) || (enabledValidators.size() == 0)) {
- return result;
- }
-
- Iterator iterator = enabledValidators.iterator();
- boolean cannotLoad = false;
- IWorkbenchContext helper = null;
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- try {
- Set deltas = new HashSet();
- IProgressMonitor monitor = new NullProgressMonitor();
- for (int i = 0; i < changedResources.length; i++) {
- Object obj = changedResources[i];
- WorkbenchFileDelta wfd = null;
- if (obj instanceof IResource) {
- IResource res = (IResource) obj;
- if (force || !filterOut(monitor, vmd, res, getResourceDeltaType(ifileDeltaType))) {
- helper = vmd.getHelper(res.getProject());
-
- wfd = getFileDelta(helper, vmd, res, getResourceDeltaType(ifileDeltaType));
- }
- } else {
- wfd = new WorkbenchFileDelta(obj);
- }
-
- if (wfd != null) {
- deltas.add(wfd);
- }
- }
- result.put(vmd, deltas);
- } catch (InstantiationException exc) {
- cannotLoad = true;
-
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("FilterUtil::getFileDeltas(Set, Object[], int, boolean)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
-
- }
-
- if (cannotLoad) {
- // Some of the validators should not be in the result set because either their
- // validator class or helper class could not be instantiated.
- Object[] vmds = enabledValidators.toArray();
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = (ValidatorMetaData) vmds[i];
- if (vmd.cannotLoad()) {
- result.remove(vmd);
- }
- }
- }
-
-
- return result;
- }
-
- public static WorkbenchFileDelta getFileDelta(IWorkbenchContext helper, ValidatorMetaData vmd, IResource resource, int iresourceDeltaType) {
- // strip off the eclipse-specific information
- String fileName = helper.getPortableName(resource);
- if (fileName == null) {
- // The resource is not contained in the current project.
- // Can't see how this would happen, but check for it anyway.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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 String[]{resource.getName(), vmd.getValidatorDisplayName()});
- entry.setText(result);
- //entry.setTokens(new String[]{resource.getName(), vmd.getValidatorDisplayName()});
- logger.write(Level.SEVERE, entry);
- }
-
- IPath resourcePath = resource.getFullPath();
- if (resourcePath != null) {
- // Since null file names are not allowed, default to the fully-qualified name of the
- // resource.
- fileName = resourcePath.toString();
- } else {
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("FilterUtil::getFileDelta(IWorkbenchContext, ValidtaorMetaData, IResource, int)"); //$NON-NLS-1$
- entry.setText("portableName is null and path is null for resource " + resource); //$NON-NLS-1$
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- }
-
- int ifileDeltaType = getFileDeltaType(iresourceDeltaType);
- return new WorkbenchFileDelta(fileName, ifileDeltaType, resource);
- }
-
-
- /**
- * 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) {
- if ((vmd == null) || (resource == null)) {
- return false;
- }
-
- try {
- helper.registerResource(resource);
- } catch (Throwable exc) {
- // How to log this????
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("FilterUtil.addToFileList"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
-
- InternalValidatorManager.getManager().addInternalErrorTask(resource.getProject(), vmd, exc);
-
- // Don't return ... even though the register threw an exception, that's not to say
- // that the validator can't validate.
- }
-
- if (isFullBuild) {
- // To indicate a full build to the validator, don't build up a list of files;
- // pass in null instead. Given that the list of files should not be used,
- // don't calculate it.
- return true;
- }
-
-
- WorkbenchFileDelta newFileDelta = getFileDelta(helper, vmd, resource, resourceDelta);
- if (newFileDelta != null) {
- // if delta is null, getFileDelta will have logged the problem already
- addFileDelta(enabledValidators, vmd, newFileDelta);
- }
-
- return true;
- }
-
- /**
- * Whether a full verification or a delta verification is in progress, both will call this
- * method to process the resource. This method calls the current Validator to filter the
- * resource (i.e., this method returns if the resource fails the filter test).
- * <code>process</code> also sends output to the <code>IProgressMonitor</code>, and calls
- * the current Validator to validate the resource.
- *
- * To process a resource, there are several steps: 1. check if the resource is registered for
- * this validator (i.e., the validator has either specified it in a filter, or has not filtered
- * it out explicitly) 2. call <code>isValidationSource</code> on the current validator with
- * the current resource. This method performs further filtering by the Validator itself, in
- * addition to the static filtering done by the framework, based on the information in
- * plugin.xml. 3. If the resource passes both filters, call <code>validate</code> on the
- * validator, with the resource. 4. When complete (either by failing to pass a filter, or by the
- * completion of the <code>validate</code>), increment the IProgressMonitor's status by one
- * (i.e., one resource has been processed.)
- */
- static boolean filterOut(IProgressMonitor monitor, ValidatorMetaData vmd, IResource resource, int resourceDelta) {
- if (monitor == null) {
- return false;
- }
-
- checkCanceled(monitor);
- return !(vmd.isApplicableTo(resource, resourceDelta));
- }
-
- /**
- * Whether a full verification or a delta verification is in progress, both will call this
- * method to process the resource. This method calls the current Validator to filter the
- * resource (i.e., this method returns if the resource fails the filter test).
- * <code>process</code> also sends output to the <code>IProgressMonitor</code>, and calls
- * the current Validator to validate the resource.
- *
- * To process a resource, there are several steps: 1. check if the resource is registered for
- * this validator (i.e., the validator has either specified it in a filter, or has not filtered
- * it out explicitly) 2. call <code>isValidationSource</code> on the current validator with
- * the current resource. This method performs further filtering by the Validator itself, in
- * addition to the static filtering done by the framework, based on the information in
- * plugin.xml. 3. If the resource passes both filters, call <code>validate</code> on the
- * validator, with the resource. 4. When complete (either by failing to pass a filter, or by the
- * 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;
- }
-
- checkCanceled(monitor);
-
- Iterator iterator = enabledValidators.keySet().iterator();
- boolean cannotLoad = false;
- while (iterator.hasNext()) {
- checkCanceled(monitor);
-
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
-
- if (!filterOut(monitor, vmd, resource, resourceDelta)) {
- try {
- // Notify the helper that a resource is about to be filtered in
- IWorkbenchContext helper = vmd.getHelper(resource.getProject());
- addToFileList(enabledValidators, helper, vmd, resource, resourceDelta, isFullBuild);
- } catch (InstantiationException exc) {
- cannotLoad = true;
-
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("FilterUtil::filterOut(IProgressMonitor, Map, IResource, int, boolean)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- if (cannotLoad) {
- // Some of the validators need to be removed from the set because the validator
- // or helper cannot be instantiated.
- Object[] vmds = enabledValidators.keySet().toArray();
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = (ValidatorMetaData) vmds[i];
- if (vmd.cannotLoad()) {
- enabledValidators.remove(vmd);
- }
- }
- }
- }
-
- /**
- * Whether a full verification or a delta verification is in progress, both will call this
- * method to process the resource. This method calls the current Validator to filter the
- * resource (i.e., this method returns if the resource fails the filter test).
- * <code>process</code> also sends output to the <code>IProgressMonitor</code>, and calls
- * the current Validator to validate the resource.
- *
- * This method is called during an incremental, not a full, validation. The full validation
- * fakes an IResourceDelta, and the incremental needs to check that the delta is one of the
- * deltas which is filtered in by the validation framework.
- *
- * @see filterOut(IResourceDelta)
- *
- * To process a resource, there are several steps: 1. check if the resource is registered for
- * this validator (i.e., the validator has either specified it in a filter, or has not filtered
- * it out explicitly) 2. call <code>isValidationSource</code> on the current validator with
- * the current resource. This method performs further filtering by the Validator itself, in
- * addition to the static filtering done by the framework, based on the information in
- * plugin.xml. 3. If the resource passes both filters, call <code>validate</code> on the
- * validator, with the resource. 4. When complete (either by failing to pass a filter, or by the
- * 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) {
- // 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;
- }
- filterOut(monitor, enabledValidators, resource, delta.getKind(), false); // false =
- // incremental
- // build
- }
-
- /**
- * Filter out resource deltas which don't correspond to changes that validators can validate.
- *
- * This method will filter in deltas only if the delta is an add, a delete, or if the content of
- * the file has changed.
- *
- * Return true if the delta should be filtered out, and false if we should validate it.
- *
- * @see IResourceDelta
- */
- static boolean filterOut(IResourceDelta delta) {
- if (delta == null) {
- return true;
- }
-
- switch (delta.getKind()) {
- case IResourceDelta.ADDED : // resource has been added to the workbench
- {
- return false;
- }
-
- case IResourceDelta.REMOVED : // resource has been deleted from the workbench
- {
- // If the delta is an IProject, and the IProject is getting deleted or closed, don't
- // validate it or its children.
- if (delta.getResource() instanceof IProject) {
- return true;
- }
- return false;
- }
-
- case IResourceDelta.CHANGED : // resources has been changed in the workbench
- {
- // We want to add the enterprise bean only if its source file's
- // contents have changed. (for example, if a folder has been
- // added to the project, the IFile will be changed because
- // its position has been changed, but the enterprise bean
- // doesn't need to be redeployed. See IResourceDelta.getFlags()
- // for more information.)
- //
- // Or, if ejb-jar.xml has changed, the EJBJar is destroyed & created
- // from scratch, so the list of EnterpriseBean is new. Purge the old
- // EJBJar from the EJBCache (since it will never be referenced again),
- // and load the new EJBJar into the cache.
- if ((delta.getResource() instanceof IFile) && ((delta.getFlags() & IResourceDelta.CONTENT) != 0)) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * This method returns true if the given resource and its children should be processed by the
- * validators. That is, there are several types of changes which can occur to an IProject which
- * should not trigger a revalidation of the project or its children. (e.g. project is deleted or
- * closed.) For those cases, or if the IResourceDelta is invalid, this method will return false
- * (do not validate the IProject or its children). Otherwise, return true (validate the resource &
- * its children). If an IProject itself has not changed, but one of its children has
- * (delta.getKind() of NO_CHANGE), then return true so that the children are validated.
- */
- static boolean shouldProcess(IResource resource, IResourceDelta delta) {
- if ((resource != null) && !(resource instanceof IProject)) {
- return true;
- }
-
- if (delta == null) {
- return false;
- }
-
- switch (delta.getKind()) {
- case IResourceDelta.ADDED : // resource has been deleted from the workbench; may be part
- // of a move
- {
- if (0 != (delta.getFlags() & IResourceDelta.MOVED_FROM)) {
- // If it's being moved, don't revalidate its children. If it's being added, fall
- // through to the "return true;" at the end of this method.
- return false;
- }
- break;
- }
-
- case IResourceDelta.REMOVED : // resource has been deleted from the workbench; may be
- // part of a move
- {
- // Whether it's being deleted or moved, don't revalidate its children.
- return false;
- }
-
- case IResourceDelta.CHANGED : // resource has been changed in the workbench; may be part
- // of a move
- {
- if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
- // Change is related to the OPEN bit. Whether the project was closed and is now
- // open,
- // or the project was open and is now closed, don't need to revalidate the
- // children.
- return false;
- } else if ((delta.getFlags() & IResourceDelta.REPLACED) != 0) {
- // project was moved
- return false;
- }
-
- break;
- }
- }
-
- return true;
- }
-
- private static VMDResourceVisitor getResourceVisitor(IProgressMonitor monitor, Set enabledValidators) {
- if (_resourceVisitor == null) {
- _resourceVisitor = new VMDResourceVisitor() {
- private Map _vmdDeltas = null;
- private IProgressMonitor _progressMonitor = null;
-
- public Map getResult() {
- return _vmdDeltas;
- }
-
- public void setEnabledValidators(Set validators) {
- _vmdDeltas = wrapInMap(validators);
- }
-
- public IProgressMonitor getProgressMonitor() {
- return _progressMonitor;
- }
-
- public void setProgressMonitor(IProgressMonitor m) {
- _progressMonitor = m;
- }
-
- public boolean visit(IResource res) throws CoreException {
- FilterUtil.checkCanceled(getProgressMonitor());
-
- // We don't need to filter out anything, because a full validation
- // is about to be performed.
- filterOut(getProgressMonitor(), _vmdDeltas, res, IResourceDelta.CHANGED, true); // true
- // -
- // this
- // is a
- // full
- // build
-
- return true; // visit the resource's children as well
- }
- };
- }
- _resourceVisitor.setProgressMonitor(monitor);
- _resourceVisitor.setEnabledValidators(enabledValidators);
-
- return _resourceVisitor;
- }
-
- private static VMDDeltaVisitor getDeltaVisitor(IProgressMonitor monitor, Set enabledValidators) {
- if (_deltaVisitor == null) {
- _deltaVisitor = new VMDDeltaVisitor() {
- private Map _vmdDeltas = null;
- private IProgressMonitor _progressMonitor = null;
-
- public Map getResult() {
- return _vmdDeltas;
- }
-
- public void setEnabledValidators(Set validators) {
- _vmdDeltas = wrapInMap(validators);
- }
-
- public IProgressMonitor getProgressMonitor() {
- return _progressMonitor;
- }
-
- public void setProgressMonitor(IProgressMonitor m) {
- _progressMonitor = m;
- }
-
- public boolean visit(IResourceDelta subdelta) throws CoreException {
- checkCanceled(getProgressMonitor());
- if (subdelta == null)
- return true;
-
- IResource resource = subdelta.getResource();
-
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- StringBuffer buffer = new StringBuffer("subdelta of "); //$NON-NLS-1$
- buffer.append(resource.getName());
- buffer.append(" is "); //$NON-NLS-1$
- buffer.append(subdelta.getKind());
- buffer.append(" resource exists? "); //$NON-NLS-1$
- buffer.append(resource.exists());
- buffer.append(" resource.isPhantom?"); //$NON-NLS-1$
- buffer.append(resource.isPhantom());
-
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("FilterUtil::visit(IResourceDelta)"); //$NON-NLS-1$
- entry.setText(buffer.toString());
- logger.write(Level.FINEST, entry);
- }
-
- }
-
- // If the delta is an IProject, and the IProject is getting deleted or closed,
- // don't validate it or its children.
- if (shouldProcess(resource, subdelta)) {
- filterOut(getProgressMonitor(), _vmdDeltas, resource, subdelta);
- return true; // visit the delta's children as well
- }
- return false; // do not visit the delta's children
- }
- };
- }
- _deltaVisitor.setProgressMonitor(monitor);
- _deltaVisitor.setEnabledValidators(enabledValidators);
-
- return _deltaVisitor;
- }
-
- public static Map loadDeltas(final IProgressMonitor monitor, final Set 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 {
- VMDResourceVisitor visitor = getResourceVisitor(monitor, enabledValidators);
- project.accept(visitor, IResource.DEPTH_INFINITE, true); // true means include phantom
- // resources
- return visitor.getResult();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java
deleted file mode 100644
index cf9829fbe..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/GlobalConfiguration.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * This class represents the global Preferences as set on the Validation Preferences page.
- */
-public class GlobalConfiguration extends ValidationConfiguration {
- /* package */static final boolean PREF_PROJECTS_CAN_OVERRIDE_DEFAULT = true;
-
- private boolean _canProjectsOverride = getCanProjectsOverrideDefault();
-
- /**
- * This constructor should be used in all cases except for the Preference page's values.
- */
- public GlobalConfiguration(IWorkspaceRoot root) throws InvocationTargetException {
- super(root, convertToArray(ValidationRegistryReader.getReader().getAllValidators()));
-
- // Can't put the call to load() and passivate() in the ValidationConfiguration constructor
- // due
- // to the order of initialization.
- // 1. First the ValidationConfiguration constructor is called, and that loads the stored
- // values.
- // 2. Then this class's <init> method is called, and that initializes the "override" field
- // to the default,
- // which may be different than the stored value.
- }
-
- /**
- * This constructor is provided only for the Preference page, so that the page can store values
- * without persisting them (i.e., if the user presses Cancel then nothing needs to be done.)
- */
- public GlobalConfiguration(GlobalConfiguration original) throws InvocationTargetException {
- super();
- original.copyTo(this);
- }
-
- public boolean canProjectsOverride() {
- return _canProjectsOverride;
- }
-
- public void setCanProjectsOverride(boolean can) {
- _canProjectsOverride = can;
- }
-
- public void resetToDefault() {
- setAutoValidate(getAutoValidateDefault());
- setEnabledValidators(getEnabledValidatorsDefault());
- setMaximumNumberOfMessages(getMaximumNumberOfMessagesDefault());
- setBuildValidate(getBuildValidateDefault());
- setCanProjectsOverride(getCanProjectsOverrideDefault());
- }
-
- /**
- * This method exists only for migration purposes. The root marker must be deleted after
- * migration is complete.
- */
- protected IMarker[] getMarker() {
- try {
- IWorkspaceRoot root = getRoot();
- IMarker[] markers = root.findMarkers(ConfigurationConstants.PREFERENCE_MARKER, false, IResource.DEPTH_ONE);
-
- if (markers.length == 1) {
- return markers;
- }
- // job is done. Nothing to migrate.
- return null;
-
- } catch (CoreException exc) {
- // Can't find the IMarker? Assume it's deleted.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("GlobalConfiguration.getMarker()"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- }
-
- protected void load(IMarker[] marker) {
- // The 5.0 preferences were stored in an IMarker, and the current.preferences are stored in
- // PersistentProperties on the IResource.
- // A 5.0 root can have no marker values if the preference page, properties page, and
- // validation were never viewed or run.
- try {
- IWorkspaceRoot root = getRoot();
- if (marker == null) {
- // There were no global preferences in 4.03, so the migration is to create some.
- resetToDefault(); // assign the default values to the new Global Preference
- return;
- }
-
- IMarker rootMarker = marker[0]; // getMarker() has already checked that there's a marker
- // in the array
- ValidatorMetaData[] enabledValidators = null;
- String enabledValidatorsString = (String) getValue(rootMarker, ConfigurationConstants.ENABLED_VALIDATORS);
- if (enabledValidatorsString == null) {
- enabledValidators = ConfigurationConstants.DEFAULT_ENABLED_VALIDATORS;
- } else {
- enabledValidators = getStringAsEnabledElementsArray(enabledValidatorsString);
- }
-
- setEnabledValidators(enabledValidators);
- setAutoValidate(getValue(rootMarker, ConfigurationConstants.AUTO_SETTING, ConfigurationConstants.DEFAULT_AUTO_SETTING));
- setBuildValidate(getValue(rootMarker, ConfigurationConstants.BUILD_SETTING, ConfigurationConstants.DEFAULT_BUILD_SETTING));
- setMaximumNumberOfMessages(getValue(rootMarker, ConfigurationConstants.MAXNUMMESSAGES, ConfigurationConstants.DEFAULT_MAXNUMMESSAGES));
- setCanProjectsOverride(getValue(rootMarker, ConfigurationConstants.PREF_PROJECTS_CAN_OVERRIDE, PREF_PROJECTS_CAN_OVERRIDE_DEFAULT));
-
- root.getWorkspace().deleteMarkers(marker);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("GlobalConfiguration.loadV50"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- protected void copyTo(GlobalConfiguration gp) throws InvocationTargetException {
- super.copyTo(gp);
-
- // Need to have a distinct method for this child class (i.e., the parameter
- // is not a ValidationConfiguration) because if this initialization is
- // called as part of ValidationConfiguration's constructor, then the value of
- // this field is overwritten. Fields of this class are initialized to the
- // default after the ValidationConfiguration parent is created.
- gp.setCanProjectsOverride(canProjectsOverride());
- }
-
- public static boolean getCanProjectsOverrideDefault() {
- return PREF_PROJECTS_CAN_OVERRIDE_DEFAULT;
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#deserialize(String)
- */
- public void deserialize(String storedConfiguration) throws InvocationTargetException {
- super.deserialize(storedConfiguration);
-
- if (storedConfiguration != null && storedConfiguration.length() > 0) {
- // If it's null, then super.deserialize has already called resetToDefault to initialize
- // this instance.
- int canOverrideIndex = storedConfiguration.indexOf(ConfigurationConstants.PREF_PROJECTS_CAN_OVERRIDE);
- int autoIndex = storedConfiguration.indexOf(ConfigurationConstants.AUTO_SETTING);
-
- String canOverride = storedConfiguration.substring(canOverrideIndex + ConfigurationConstants.PREF_PROJECTS_CAN_OVERRIDE.length(), autoIndex);
- setCanProjectsOverride(Boolean.valueOf(canOverride).booleanValue());
- }
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#serialize()
- */
- public String serialize() throws InvocationTargetException {
- StringBuffer buffer = new StringBuffer();
- buffer.append(ConfigurationConstants.PREF_PROJECTS_CAN_OVERRIDE);
- buffer.append(String.valueOf(canProjectsOverride()));
- buffer.append(super.serialize());
- return buffer.toString();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IProjectValidationHelper.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IProjectValidationHelper.java
deleted file mode 100644
index f85fddf7f..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IProjectValidationHelper.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-
-public interface IProjectValidationHelper {
-
- public IContainer[] getOutputContainers(IProject project);
-
- public IContainer[] getSourceContainers(IProject project);
-
-}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IValidationSelectionHandler.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IValidationSelectionHandler.java
deleted file mode 100644
index 38292b607..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/IValidationSelectionHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * This is used by extensions to add valid validation types to the validate
- * menu action.
- */
-public interface IValidationSelectionHandler {
-
- /**
- * Return a valid IResource type for the extensible object selection,
- * should be instance of IFolder, IFile, or IProject if this extension knows
- * how to handle the selection, otherwise it should return null
- */
- public IResource getBaseValidationType(Object selection);
-
- /**
- * @return the classname of the validation type to register for validation
- */
- public String getValidationTypeString();
-
- public void setValidationTypeString(String validationType);
-
-}
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
deleted file mode 100644
index 07d3845bf..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/InternalValidatorManager.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-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;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- */
-public final class InternalValidatorManager {
- private static InternalValidatorManager _inst = null;
- private static final String OP_GROUP = "ValidationOperation"; //$NON-NLS-1$ // when the ValidationOperation
-
- // adds a message to the task
- // list; e.g. cancel, or internal
- // error, this group name is used
- // to distinguish between the
- // messages that the validator
- // itself put, and the ones which
- // the validator owns, but the
- // operation put. //$NON-NLS-1$
-
- private InternalValidatorManager() {
- //default
- }
-
- public static InternalValidatorManager getManager() {
- if (_inst == null) {
- _inst = new InternalValidatorManager();
- }
- return _inst;
- }
-
- /**
- * 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;
- }
-
- for (int i = 0; i < obj.length; i++) {
- result.add(obj[i]);
- }
-
- return result;
- }
-
- /**
- * If the current validator throws a Throwable, log the internal error to the task list.
- *
- * This method is for use by the validation framework only.
- */
- public void addInternalErrorTask(IProject project, ValidatorMetaData vmd, Throwable exc) {
- addOperationTask(project, vmd, ResourceConstants.VBF_EXC_INTERNAL, new String[]{project.getName(), vmd.getValidatorDisplayName(), ((exc.getMessage() == null) ? "" : exc.getMessage())}); //$NON-NLS-1$
- }
-
- /**
- * If the user is cancelling validation on the current project/resource, Add an information task
- * to the task list informing the user that validation has not been run on the current project.
- *
- * If the current validator throws a Throwable, log the internal error to the task list.
- */
- public void addOperationTask(IProject project, ValidatorMetaData vmd, String messageId, String[] parms) {
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.LOW_SEVERITY);
- message.setId(messageId);
- message.setParams(parms);
- message.setGroupName(OP_GROUP);
-
- // Although the message is owned by the validator, the string of the message has to be
- // loaded by this class' ClassLoader
- WorkbenchReporter.addMessage(project, vmd.getValidatorUniqueName(), getClass().getClassLoader(), message);
- }
-
-
- /**
- * If the user cancelled the previous validation with this validator, or if there was a
- * Throwable caught during the last execution of this validator, and the validator is in the
- * process of validating now, remove the former information task messages.
- */
- public void removeOperationTasks(IProject project, ValidatorMetaData vmd) {
- WorkbenchReporter.removeMessageSubset(project, vmd.getValidatorUniqueName(), OP_GROUP);
- }
-
- /**
- * 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]);
- }
- }
-
- String[] vmdNames = new String[temp.size()];
- temp.toArray(vmdNames);
- return vmdNames;
- }
-
- /**
- * 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]);
- }
- }
-
- String[] vmdNames = new String[temp.size()];
- temp.toArray(vmdNames);
- return vmdNames;
- }
-
- /**
- * Return a list of validators that validate files with the given extension.
- */
- public ValidatorMetaData[] getValidatorsForExtension(IProject project, String fileExtension) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
-
- // Get all of the validators configured on the project for the given file extension
- ValidatorMetaData[] vmds = prjp.getValidators();
-
- // Construct a fake IFile type to represent a file with this extension.
- StringBuffer buffer = new StringBuffer(project.getName());
- buffer.append(IPath.SEPARATOR);
- buffer.append(fileExtension);
- IPath path = new Path(buffer.toString());
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
-
- ValidatorMetaData[] temp = new ValidatorMetaData[vmds.length];
- int count = 0;
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- if (vmd.isApplicableTo(file)) {
- temp[count++] = vmd;
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- return result;
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("InternalValidatorManager::getValidatorsForExtension(" + project.getName() + ", " + fileExtension + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return new ValidatorMetaData[0];
- }
- }
-
- /**
- * Return a list of validator names that validate files with the given extension.
- */
- public String[] getValidatorNamesForExtension(IProject project, String fileExtension) {
- ValidatorMetaData[] vmds = getValidatorsForExtension(project, fileExtension);
-
- String[] names = new String[vmds.length];
- for (int i = 0; i < names.length; i++) {
- names[i] = vmds[i].getValidatorUniqueName();
- }
- return names;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java
deleted file mode 100644
index 0e7d71146..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ProjectConfiguration.java
+++ /dev/null
@@ -1,615 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * This class represents the Project Preferences as set on the Project's Validation Properties page.
- */
-public class ProjectConfiguration extends ValidationConfiguration {
- /* package */static final boolean PRJ_OVERRIDEGLOBAL_DEFAULT = false; // If the user has never
- // set
- // a preference before, this
- // is the override default
- // (on)
- private boolean _doesProjectOverride = getDoesProjectOverrideDefault();
-
- /**
- * This constructor should be used in all cases except for the Properties page's values.
- */
- protected ProjectConfiguration(IProject project) throws InvocationTargetException {
- // The extractProjectValidators method extracts just this project's validators from the
- // global list.
- super(project, extractProjectValidators(convertToArray(ValidationRegistryReader.getReader().getAllValidators()), project));
-
- // Can't put the call to load() and passivate() in the ValidationConfiguration constructor
- // due
- // to the order of initialization.
- // 1. First the ValidationConfiguration constructor is called, and that loads the stored
- // values.
- // 2. Then this class's <init> method is called, and that initializes the "override" field
- // to the default,
- // which may be different than the stored value.
- }
-
- /**
- * This constructor is provided only for the Properties page, so that the page can store values
- * without persisting them (i.e., if the user presses Cancel then nothing needs to be done.)
- */
- public ProjectConfiguration(ProjectConfiguration original) throws InvocationTargetException {
- super();
- original.copyTo(this);
- }
-
- /**
- * Return the ValidationConfiguration to use, whether global or project.
- */
- protected boolean useGlobalPreference() {
- try {
- GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration();
- if (gp == null) {
- return false;
- }
-
- if (!gp.canProjectsOverride()) {
- // If project's can't override the global, use the global
- return true;
- }
-
- // If the project overrides, then don't use the global.
- // If the project does not override, use the global.
- return !_doesProjectOverride;
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ProjectConfiguration.userGlobalPreference"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return false;
- }
- }
-
- public boolean doesProjectOverride() {
- // If the global preference doesn't allow projects to override, it doesn't matter what the
- // value of _doesProjectOverride is.
- return !useGlobalPreference();
- }
-
- public void setDoesProjectOverride(boolean does) {
- _doesProjectOverride = does;
- }
-
- /**
- * If the preferences should be used then the preference settings are returned; otherwise return
- * the project settings.
- */
- public ValidatorMetaData[] getEnabledValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getEnabledValidators(), getResource());
- }
- return super.getEnabledValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#getDisabledValidators()
- */
- public ValidatorMetaData[] getDisabledValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getDisabledValidators(), getResource());
- }
- return super.getDisabledValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#getValidators()
- */
- public ValidatorMetaData[] getValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getValidators(), getResource());
- }
- return super.getValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#getEnabledIncrementalValidators(boolean)
- */
- public ValidatorMetaData[] getEnabledIncrementalValidators(boolean incremental) throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getEnabledIncrementalValidators(incremental), getResource());
- }
- return super.getEnabledIncrementalValidators(incremental);
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#isEnabled(ValidatorMetaData)
- */
- public boolean isEnabled(ValidatorMetaData vmd) throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().isEnabled(vmd);
- }
- return super.isEnabled(vmd);
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#numberOfDisabledValidators()
- */
- public int numberOfDisabledValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().numberOfDisabledValidators();
- }
- return super.numberOfDisabledValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#numberOfEnabledIncrementalValidators()
- */
- public int numberOfEnabledIncrementalValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().numberOfEnabledIncrementalValidators();
- }
- return super.numberOfEnabledIncrementalValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#numberOfEnabledValidators()
- */
- public int numberOfEnabledValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().numberOfEnabledValidators();
- }
- return super.numberOfEnabledValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#numberOfIncrementalValidators()
- */
- public int numberOfIncrementalValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().numberOfIncrementalValidators();
- }
- return super.numberOfIncrementalValidators();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.preference.ValidationConfiguration#numberOfValidators()
- */
- public int numberOfValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().numberOfValidators();
- }
- return super.numberOfValidators();
- }
-
- /**
- * This method could be called with the project's values, or with the global preference values.
- * Validators that are not configured on this project will be ignored.
- */
- public void setEnabledValidators(ValidatorMetaData[] vmds) {
- super.setEnabledValidators(extractProjectValidators(vmds, getResource()));
- }
-
- /**
- * This method could be called with the project's values, or with the global preference values.
- * Validators that are not configured on this project will be ignored.
- */
- public void setValidators(ValidatorMetaData[] vmds) {
- super.setValidators(extractProjectValidators(vmds, getResource()));
- }
-
- /**
- * Given a set of validators, usually the global preference set, change the set so that it
- * contains only the validators configured on this project.
- */
- private static ValidatorMetaData[] extractProjectValidators(ValidatorMetaData[] vmds, IResource resource) {
- ValidationRegistryReader reader = ValidationRegistryReader.getReader();
- int length = (vmds == null) ? 0 : vmds.length;
- ValidatorMetaData[] temp = new ValidatorMetaData[length];
- if (length == 0) {
- return temp;
- }
-
- int count = 0;
- IProject project = (IProject) resource;
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- if (reader.isConfiguredOnProject(vmd, project)) {
- temp[count++] = vmd;
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- temp = null;
-
- return result;
- }
-
- /**
- * If the preferences should be used then the preference settings are returned; otherwise return
- * the project settings.
- */
- public int getMaximumNumberOfMessages() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().getMaximumNumberOfMessages();
- }
- return super.getMaximumNumberOfMessages();
- }
-
- /**
- * If the preferences should be used then the preference settings are returned; otherwise return
- * the project settings.
- */
- public boolean isAutoValidate() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().isAutoValidate();
- }
- return super.isAutoValidate();
- }
-
- /**
- * If the preferences should be used then the preference settings are returned; otherwise return
- * the project settings.
- */
- public boolean isBuildValidate() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().isBuildValidate();
- }
- return super.isBuildValidate();
- }
-
- /**
- * If the preferences should be used then the preference settings are returned; otherwise return
- * the project settings.
- */
- public boolean runAsync() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return ConfigurationManager.getManager().getGlobalConfiguration().runAsync();
- }
- return super.runAsync();
- }
-
- public void resetToDefault() throws InvocationTargetException {
- // The default values of the project is whatever the preference values are
- GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration();
-
- setAutoValidate(gp.isAutoValidate());
- setEnabledValidators(gp.getEnabledValidators());
- setMaximumNumberOfMessages(gp.getMaximumNumberOfMessages());
- setBuildValidate(gp.isBuildValidate());
-
- // except for this field, which is unique to the project preferences
- setDoesProjectOverride(getDoesProjectOverrideDefault());
- }
-
- public void resetToDefaultForProjectDescriptionChange() throws InvocationTargetException {
- // The default values of the project is whatever the preference values are
- GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration();
-
- setAutoValidate(gp.isAutoValidate());
- setEnabledValidators(gp.getEnabledValidators());
- setMaximumNumberOfMessages(gp.getMaximumNumberOfMessages());
- setBuildValidate(gp.isBuildValidate());
-
- // except for this field, which is unique to the project preferences
- //setDoesProjectOverride(getDoesProjectOverrideDefault());
- }
-
- /**
- * The project's nature has changed, so recalculate the validators that are configured on the
- * project, and reset the values of the project to the default.
- */
- public void resetProjectNature() {
- /*
- * We do not want to perform the resetting the of the validators as the nature never gets
- * reset due to change in the project references - VKB GlobalConfiguration gp =
- * ConfigurationManager.getManager().getGlobalConfiguration();
- * setValidators(gp.getValidators()); // Reset the validators that are configured on the
- * project (the ProjectConfiguration automatically saves only the validators that are
- * configured on the project). resetToDefault(); // Given that the project is "new", reset
- * its values to the Preferences.
- */
- }
-
- /**
- * This method exists only for migration purposes. The project marker must be deleted after
- * migration is complete.
- */
- protected IMarker[] getMarker() {
- try {
- // First try to find the 4.03 project marker.
- IMarker[] allMarkers = getResource().findMarkers(ConfigurationConstants.PRJ_MARKER_403, false, IResource.DEPTH_ZERO);
-
- // If it doesn't exist, then this might be a 5.0 project marker.
- if ((allMarkers == null) || (allMarkers.length == 0)) {
- allMarkers = getResource().findMarkers(ConfigurationConstants.PRJ_MARKER, false, IResource.DEPTH_ZERO);
- }
-
- // There should be only one projectmarker.
- if (allMarkers.length == 1) {
- return allMarkers;
- }
- // Job is done. Nothing to migrate.
- return null;
- } catch (CoreException exc) {
- // Can't find the IMarker? Assume it's deleted.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ProjectConfiguration::getMarker"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- }
-
- protected void load(IMarker[] marker) {
- // 4.03 project preferences are different from the current in the following ways:
- // 1. Only preferences that could be set were the enabled validators and the auto-validate
- // option.
- // 2. The preferences were stored in an IMarker instead of a PersistentProperty.
- // The 5.0 project settings were stored in an IMarker, and the current settings are stored
- // in a PersistentProperty.
- // A 5.0 project could have a null validation marker if the validation page was never
- // opened on it, and if validation was never run.
- try {
- if (marker == null) {
- // Assume default values
- resetToDefault();
- return;
- }
-
- IMarker prjMarker = marker[0]; // getProjectMarker() has already checked that there's a
- // marker in the array
- GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration();
-
- String enabledValStr = (String) getValue(prjMarker, ConfigurationConstants.ENABLED_VALIDATORS);
- ValidatorMetaData[] enabledVal = null;
- if (enabledValStr == null) {
- enabledVal = gp.getEnabledValidators();
- } else {
- enabledVal = getStringAsEnabledElementsArray(enabledValStr);
- }
- setEnabledValidators(enabledVal);
-
- String version = loadVersion(marker); // In 4.03, every project had its own validators &
- // auto-validate settings.
- Boolean boolVal = (Boolean) getValue(prjMarker, ConfigurationConstants.PRJ_OVERRIDEGLOBAL);
- if ((boolVal == null) && (version.equals(ConfigurationConstants.VERSION4_03))) {
- // Different default for 4.03. In 4.03, all projects overrode the global, because
- // the
- // global preferences didn't exist.
- setDoesProjectOverride(true);
- } else if (boolVal == null) {
- setDoesProjectOverride(getDoesProjectOverrideDefault());
- } else {
- setDoesProjectOverride(boolVal.booleanValue());
- }
- boolean override = doesProjectOverride();
-
-
- boolVal = (Boolean) getValue(prjMarker, ConfigurationConstants.AUTO_SETTING);
- if ((boolVal == null) || (!override)) {
- setAutoValidate(gp.isAutoValidate());
- } else {
- setAutoValidate(boolVal.booleanValue());
- }
-
- boolVal = (Boolean) getValue(prjMarker, ConfigurationConstants.BUILD_SETTING);
- if ((boolVal == null) || (!override)) {
- setBuildValidate(gp.isBuildValidate());
- } else {
- setBuildValidate(boolVal.booleanValue());
- }
-
- Integer intVal = (Integer) getValue(prjMarker, ConfigurationConstants.MAXNUMMESSAGES);
- if ((intVal == null) || (!override)) {
- setMaximumNumberOfMessages(gp.getMaximumNumberOfMessages());
- } else {
- setMaximumNumberOfMessages(intVal.intValue());
- }
-
- getResource().getWorkspace().deleteMarkers(marker);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ProjectConfiguration.loadMarker "); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ProjectConfiguration.loadMarker InvocationTargetException"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- protected void copyTo(ProjectConfiguration prjp) throws InvocationTargetException {
- super.copyTo(prjp);
-
- // Need to have a distinct method for this child class (i.e., the parameter
- // is not a ValidationConfiguration) because if this initialization is
- // called as part of ValidationConfiguration's constructor, then the value of
- // this field is overwritten. Fields of this class are initialized to the
- // default after the ValidationConfiguration parent is created.
- prjp.setDoesProjectOverride(doesProjectOverride());
- }
-
- public static boolean getDoesProjectOverrideDefault() {
- return PRJ_OVERRIDEGLOBAL_DEFAULT;
- }
-
- /**
- * Return true if the enabled validators have not changed since this ValidationConfiguration was
- * constructed, false otherwise. (This method is needed for the Properties and Preference pages;
- * if the list of validators hasn't changed, then there is no need to update the task list;
- * updating the task list is a costly operation.)
- *
- * The "allow" parameter represents whether or not the global "allow projects to override" has
- * been changed: - TRUE means that the preference "allow" parameter has been changed - FALSE
- * means that the preference "allow" paramter has not been changed
- */
- public boolean hasEnabledValidatorsChanged(ValidatorMetaData[] oldEnabledVmd, boolean allow) throws InvocationTargetException {
- // First check the obvious: is every enabled validator still enabled, and is
- // the number of enabled validators the same as it was before? If not, return true.
- if (super.hasEnabledValidatorsChanged(oldEnabledVmd)) {
- return true;
- }
-
-
- // If the global preference validators have changed, does the task list need to be updated?
- // PREF | PROJ | UPDATE
- // ALLOW | OVERRIDE | TASK LIST
- //------------------------------
- // 0 | 0 | 1
- // 0 | 1 | 1
- // 1 | 0 | 1
- // 1 | 1 | 0
- //
- // If the global "allow" preference changes from "allow" to "don't allow", or vice versa,
- // and the project overrides the preferences, and the validators differ between the project
- // and the preferences, then the task list must be updated.
- if (allow) {
- // "allow" has changed, so see if the preference and the project validators match.
- ValidatorMetaData[] projEnabledVmd = super.getEnabledValidators(); // bypass the check
- // for whether the
- // global preferences
- // are to be used or
- // not
- GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration();
- return gp.hasEnabledValidatorsChanged(projEnabledVmd);
- }
-
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#deserialize(String)
- */
- public void deserialize(String storedConfiguration) throws InvocationTargetException {
- if (storedConfiguration == null) {
- resetToDefault();
- } else if (storedConfiguration != null) {
- int prjOverrideIndex = storedConfiguration.indexOf(ConfigurationConstants.PRJ_OVERRIDEGLOBAL);
- int autoIndex = storedConfiguration.indexOf(ConfigurationConstants.AUTO_SETTING);
-
- String prjOverride = null;
- if (autoIndex < 0) {
- // project doesn't override the global
- prjOverride = storedConfiguration.substring(prjOverrideIndex + ConfigurationConstants.PRJ_OVERRIDEGLOBAL.length());
- } else {
- // project overrides the global, so retrieve the values
- super.deserialize(storedConfiguration);
- prjOverride = storedConfiguration.substring(prjOverrideIndex + ConfigurationConstants.PRJ_OVERRIDEGLOBAL.length(), autoIndex);
- }
- setDoesProjectOverride(Boolean.valueOf(prjOverride).booleanValue());
- }
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#serialize()
- */
- public String serialize() throws InvocationTargetException {
- StringBuffer buffer = new StringBuffer();
- buffer.append(ConfigurationConstants.PRJ_OVERRIDEGLOBAL);
- buffer.append(String.valueOf(doesProjectOverride()));
- if (doesProjectOverride()) {
- // Store common values for the Project configuration only if they differ from the global
- buffer.append(super.serialize());
- }
- return buffer.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#getEnabledFullBuildValidators(boolean)
- */
- public ValidatorMetaData[] getEnabledFullBuildValidators(boolean fullBuild) throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getEnabledFullBuildValidators(fullBuild), getResource());
- }
- return super.getEnabledFullBuildValidators(fullBuild);
- }
-
- /**
- * Given a set of validators, usually the global preference set, change the set so that it
- * contains only the validators configured on this project.
- */
- private static ValidatorMetaData[] extractProjectValidators(ValidatorMetaData[] vmds, IResource resource, boolean onlyReferenced) {
- ValidationRegistryReader reader = ValidationRegistryReader.getReader();
- int length = (vmds == null) ? 0 : vmds.length;
- ValidatorMetaData[] temp = new ValidatorMetaData[length];
- if (length == 0) {
- return temp;
- }
-
- int count = 0;
- IProject project = (IProject) resource;
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- if (reader.isConfiguredOnProject(vmd, project)) {
- if (!onlyReferenced || vmd.isDependentValidator())
- temp[count++] = vmd;
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- temp = null;
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#getEnabledFullBuildValidators(boolean)
- */
- public ValidatorMetaData[] getEnabledFullBuildValidators(boolean fullBuild, boolean onlyReferenced) throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getEnabledFullBuildValidators(fullBuild), getResource(), onlyReferenced);
- }
- return super.getEnabledFullBuildValidators(fullBuild, onlyReferenced);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#getIncrementalValidators()
- */
- public ValidatorMetaData[] getIncrementalValidators() throws InvocationTargetException {
- if (useGlobalPreference()) {
- return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getIncrementalValidators(), getResource());
- }
- return super.getIncrementalValidators();
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorExtension.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorExtension.java
deleted file mode 100644
index 9927fd453..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorExtension.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on May 3, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.validation.internal;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.operations.ReferencialFileValidator;
-
-/**
- * @author vijayb
- *
- * To change the template for this generated type comment go to Window - Preferences - Java - Code
- * Generation - Code and Comments
- */
-public class ReferencialFileValidatorExtension {
- private String id = null;
- private ReferencialFileValidator instance;
- private boolean errorCondition = false;
- private IConfigurationElement element;
- public static final String REF_FILE_VALIDATOR_EXTENSION = "referencialFileValidator"; //$NON-NLS-1$
- public static final String RUN = "run"; //$NON-NLS-1$
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_CLASS = "class"; //$NON-NLS-1$
-
- /**
- *
- */
- public ReferencialFileValidatorExtension() {
- super();
- }
-
- public ReferencialFileValidator getInstance() {
- try {
- if (instance == null && !errorCondition)
- instance = (ReferencialFileValidator) element.createExecutableExtension("run"); //$NON-NLS-1$
- } catch (Throwable e) {
- Logger.getLogger().logError(e);
- errorCondition = true;
- }
- return instance;
- }
-
- public ReferencialFileValidatorExtension(IConfigurationElement element) {
- if(!REF_FILE_VALIDATOR_EXTENSION.equals(element.getName()))
- throw new IllegalArgumentException("Extensions must be of the type \"" + REF_FILE_VALIDATOR_EXTENSION + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
- this.element = element;
- init();
- }
-
- private void init() {
- this.id = this.element.getAttribute(ATT_ID);
- }
-
- /**
- * @return Returns the id.
- */
- public String getId() {
- return id;
- }
-
- public IConfigurationElement getElement() {
- return element;
- }
-
- /**
- * @param id
- * The id to set.
- */
- public void setId(String id) {
- this.id = id;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorRegistryReader.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorRegistryReader.java
deleted file mode 100644
index 59f803aa2..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ReferencialFileValidatorRegistryReader.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on May 3, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.validation.internal;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.wst.validation.internal.operations.ReferencialFileValidator;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * @author vijayb
- *
- * To change the template for this generated type comment go to Window - Preferences - Java - Code
- * Generation - Code and Comments
- */
-public class ReferencialFileValidatorRegistryReader extends RegistryReader {
- static ReferencialFileValidatorRegistryReader instance = null;
- protected List referencialFileValidationExtensions;
-
- /**
- * @param arg0
- * @param arg1
- * @param arg2
- */
- public ReferencialFileValidatorRegistryReader() {
- super(ValidationPlugin.PLUGIN_ID, "referencialFileValidator"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- if (ReferencialFileValidatorExtension.REF_FILE_VALIDATOR_EXTENSION.equals(element.getName())) {
- addExtension(element);
- return true;
- }
- return false;
- }
-
- /**
- * Sets the extension point.
- *
- * @param extensions
- * The extensions to set
- */
- protected void addExtension(IConfigurationElement newExtension) {
-
- //add to the list of post validator extesions only if the ext is not added yet
- boolean containsExt = true;
- List extensions = getReferencialFileValidationExtensions();
- Iterator it = extensions.iterator();
- while(it.hasNext()) {
- ReferencialFileValidatorExtension ext = (ReferencialFileValidatorExtension)it.next();
- if(!ext.getElement().getAttribute("id").equals(newExtension.getAttribute("id")))
- containsExt = false;
- }
- if(!containsExt ||getReferencialFileValidationExtensions().isEmpty())
- getReferencialFileValidationExtensions().add(new ReferencialFileValidatorExtension(newExtension));
-
- getReferencialFileValidationExtensions().add(new ReferencialFileValidatorExtension(newExtension));
- }
-
- /**
- * Sets the extension point.
- *
- * @param extensions
- * The extensions to set
- */
- protected void addExtensionPoint(ReferencialFileValidatorExtension newExtension) {
- if (referencialFileValidationExtensions == null)
- referencialFileValidationExtensions = new ArrayList();
- referencialFileValidationExtensions.add(newExtension);
- }
-
- /**
- * @return the appropriate handler for the project based on priorities of those which are
- * available and enabled
- */
- public ReferencialFileValidator getReferencialFileValidator() {
- ReferencialFileValidatorExtension refFileValExt;
- for (Iterator refFileValItr = getReferencialFileValidationExtensions().iterator(); refFileValItr.hasNext();) {
- refFileValExt = (ReferencialFileValidatorExtension) refFileValItr.next();
- return refFileValExt.getInstance();
- }
- return null;
- }
-
- /**
- * Gets the instance.
- *
- * @return Returns a EJBCodegenHandlerExtensionReader
- */
- public static ReferencialFileValidatorRegistryReader getInstance() {
- if (instance == null) {
- instance = new ReferencialFileValidatorRegistryReader();
- instance.readRegistry();
- }
- return instance;
- }
-
- /**
- * @return Returns the handlerExtensions.
- */
- protected List getReferencialFileValidationExtensions() {
- if (referencialFileValidationExtensions == null)
- referencialFileValidationExtensions = new ArrayList();
- return referencialFileValidationExtensions;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/RegistryConstants.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/RegistryConstants.java
deleted file mode 100644
index aba5d1c08..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/RegistryConstants.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import org.eclipse.wst.validation.internal.operations.IRuleGroup;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * Validation constants needed to declare an extension point, and to implement an extension.
- */
-public interface RegistryConstants {
- public static final String PLUGIN_ID = ValidationPlugin.PLUGIN_ID;
- public static final String VALIDATOR_EXT_PT_ID = "validator"; //$NON-NLS-1$ // extension point declaration of the validator
-
- /* package */static final String TAG_RUN_CLASS = "run"; //$NON-NLS-1$ // identifies the Validator class
- /* package */static final String TAG_FILTER = "filter"; //$NON-NLS-1$ // identifies a filter -- type and/or name -- used to filter out resources which are not to be validated. (i.e., if the resource doesn't pass this filter test, don't validate it.)
- /* package */static final String TAG_HELPER_CLASS = "helper"; //$NON-NLS-1$ // IValidationContext which loads the MOF model for the IValidator
- /* package */static final String TAG_PROJECT_NATURE = "projectNature"; //$NON-NLS-1$ // identifies the projects which the validator should run on
- /* package */static final String TAG_AGGREGATE_VALIDATORS = "aggregateValidator"; //$NON-NLS-1$ // identifies a validator(s) which this validator aggregates. This value is used to remove all messages owned by a particular validator. Aggregate validators cannot be shared. Only one validator may use an aggregate of that type.
-
- /* package */static final String ATT_OBJECT_CLASS = "objectClass"; //$NON-NLS-1$ // identifies a type
- /* package */static final String ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$ // identifies a name (may include the '*' wildcard anywhere in the name)
- /* package */static final String ATT_ID = "id"; //$NON-NLS-1$ // identifies a unique id to filter on
- /* package */static final String ATT_CLASS = "class"; //$NON-NLS-1$ // identifies a class name of a tag, e.g. "helper class", or "run class"
- /* package */static final String ATT_ACTION_FILTER = "action"; //$NON-NLS-1$ // identifies the incremental validation actions for which a resource should be filtered in
- /* package */static final String ATT_INCREMENTAL = "incremental"; //$NON-NLS-1$ // identifies whether or not the validator supports incremental build validation. Default is true (i.e., incremental builds are supported).
- /* package */static final boolean ATT_INCREMENTAL_DEFAULT = true; // The incremental default.
- /* package */static final String ATT_FULLBUILD = "fullBuild"; //$NON-NLS-1$ // identifies whether or not the validator supports full build validation. Default is true (i.e., full build validation is supported).
- /* package */static final boolean ATT_FULLBUILD_DEFAULT = true; // The build default.
- /* package */static final String ATT_ENABLED = "enabled"; //$NON-NLS-1$ // identifies whether or not the validator is enabled by default. Default is "true" (enabled).
- /* package */static final boolean ATT_ENABLED_DEFAULT = true; // The "enabled" default.
- /* package */static final String ATT_INCLUDE = "include"; //$NON-NLS-1$ // Include projects with this nature
- /* package */static final boolean ATT_INCLUDE_DEFAULT = true; // By default, if "include" is not
- // specified in the projectNature
- // element, then assume that the
- // nature is included.
- /* package */static final String ATT_RULE_GROUP = "ruleGroup"; //$NON-NLS-1$ // identifies the different validation passes which this validator recognizes. The values are identified in IRuleGroup.
- /* package */static final int ATT_RULE_GROUP_DEFAULT = IRuleGroup.PASS_FAST; // the default pass
- // includes only the
- // FAST PASS. FULL
- // can be invoked
- // only explicitly by
- // an operation.
- /* package */static final String ATT_CASE_SENSITIVE = "caseSensitive"; //$NON-NLS-1$
- /* package */static final String ATT_ASYNC = "async"; //$NON-NLS-1$ // Is the validator thread-safe?
- /* package */static final boolean ATT_ASYNC_DEFAULT = false; // The "can validator run
- // asynchronously" default. Initially
- // set to false, but in future this
- // will be changed to true.
-
-
- /* package */static final String TAG_MIGRATE = "migrate"; //$NON-NLS-1$ // the "migrate" section of the validator
- /* package */static final String TAG_VALIDATOR = "validator"; //$NON-NLS-1$ // the "validator" element of the "migrate" section
- /* package */static final String ATT_FROM = "from"; //$NON-NLS-1$ // the fully-qualified class name of the former validator class
- /* package */static final String ATT_TO = "to"; //$NON-NLS-1$ // the fully-qualified class name of the current validator class
- static final String DEP_VALIDATOR = "dependentValidator"; //$NON-NLS-1$
- static final String DEP_VAL_VALUE = "depValValue"; //$NON-NLS-1$
- static final String MARKER_ID = "markerId"; //$NON-NLS-1$
- static final String MARKER_ID_VALUE = "markerIdValue"; //$NON-NLS-1$
- static final boolean DEP_VAL_VALUE_DEFAULT = false;
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceConstants.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceConstants.java
deleted file mode 100644
index 7d7ba3006..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceConstants.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-
-/**
- * Constants used to access the string resources associated with the plugin.
- *
- * See the plugin.properties file, in the plugin's directory, for the contents of the strings.
- */
-public interface ResourceConstants {
- // A marker cannot be added to the task list.
- public static final String VBF_EXC_CANNOT_ADD_MARKER = "VBF_EXC_CANNOT_ADD_MARKER"; //$NON-NLS-1$
-
- // A marker cannot be removed from the task list.
- public static final String VBF_EXC_CANNOT_REMOVE_MARKER = "VBF_EXC_CANNOT_REMOVE_MARKER"; //$NON-NLS-1$
-
- // Internal error has occurred.
- public static final String VBF_EXC_INTERNAL = "VBF_EXC_INTERNAL"; //$NON-NLS-1$
-
- // If the validator cannot be loaded because it didn't specify a helper
- public static final String VBF_EXC_HELPER_MISSING = "VBF_EXC_HELPER_MISSING"; //$NON-NLS-1$
-
- // If the validator cannot be loaded because its helper cannot be loaded
- public static final String VBF_EXC_HELPER_CANNOTLOAD = "VBF_EXC_HELPER_CANNOTLOAD"; //$NON-NLS-1$
-
- // A java.lang.Runtime error has occured during the build.
- public static final String VBF_EXC_RUNTIME = "VBF_EXC_RUNTIME"; //$NON-NLS-1$
-
- // If the "Validator" extension point has been removed from the plugin.xml file.
- public static final String VBF_EXC_MISSING_VALIDATOR_EP = "VBF_EXC_MISSING_VALIDATOR_EP"; //$NON-NLS-1$
-
- // If the user has specified an invalid type filter in their plugin.xml file.
- // i.e., it isn't an instance of IResource.
- public static final String VBF_EXC_INVALID_TYPE_FILTER = "VBF_EXC_INVALID_TYPE_FILTER"; //$NON-NLS-1$
-
- // The validator extension has made a mistake in its plugin.xml's projectNature tag
- public static final String VBF_EXC_MISSING_PROJECTNATURE_ID = "VBF_EXC_MISSING_PROJECTNATURE_ID"; //$NON-NLS-1$
-
- // The validator extension has made a mistake in its plugin.xml's syntax.
- public static final String VBF_EXC_VALIDATORNAME_IS_NULL = "VBF_EXC_VALIDATORNAME_IS_NULL"; //$NON-NLS-1$
-
- // Title for the IProgressMonitor.
- public static final String VBF_STATUS_PROGRESSMONITOR_TITLE = "VBF_STATUS_PROGRESSMONITOR_TITLE"; //$NON-NLS-1$
-
- // Status line for the IProgressMonitor
- public static final String VBF_STATUS_INITIALIZING = "VBF_STATUS_INITIALIZING"; //$NON-NLS-1$
-
- // If the user has cancelled validation, each validator might have cleanup to do. This message
- // is shown to tell the user which validator is being cleaned up at the moment.
- public static final String VBF_STATUS_VALIDATOR_CLEANUP = "VBF_STATUS_VALIDATOR_CLEANUP"; //$NON-NLS-1$
-
- // If the user cancelled validation, remove all of the validator's tasks from the task list, and
- // put an entry saying that validation on {project} using {validator} was cancelled.
- public static final String VBF_STATUS_VALIDATOR_TERMINATED = "VBF_STATUS_VALIDATOR_TERMINATED"; //$NON-NLS-1$
-
- // Before a validator is begun, this message informs the user that validation, using a
- // particular validator, has begun
- public static final String VBF_STATUS_STARTING_VALIDATION = "VBF_STATUS_STARTING_VALIDATION"; //$NON-NLS-1$
-
- // After a validator is finished, this message informs the user that validtaion, using a
- // particular validator, has completed.
- public static final String VBF_STATUS_ENDING_VALIDATION = "VBF_STATUS_ENDING_VALIDATION"; //$NON-NLS-1$
-
- // If a validator throws an unchecked exception, this message is displayed to the user.
- public static final String VBF_STATUS_ENDING_VALIDATION_ABNORMALLY = "VBF_STATUS_ENDING_VALIDATION_ABNORMALLY"; //$NON-NLS-1$
-
- // If the build's getDelta(getProject()) method returns null, let the user know that a full
- // validation will be performed because there's no delta information.
- public static final String VBF_STATUS_NULL_DELTA = "VBF_STATUS_NULL_DELTA"; //$NON-NLS-1$
-
- public static final String VBF_EXC_SYNTAX_NULL_NAME = "VBF_EXC_SYNTAX_NULL_NAME"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_HELPER = "VBF_EXC_SYNTAX_NO_HELPER"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_HELPER_CLASS = "VBF_EXC_SYNTAX_NO_HELPER_CLASS"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_HELPER_THROWABLE = "VBF_EXC_SYNTAX_NO_HELPER_THROWABLE"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_VAL_RUN = "VBF_EXC_SYNTAX_NO_VAL_RUN"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_VAL_CLASS = "VBF_EXC_SYNTAX_NO_VAL_CLASS"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_VAL_THROWABLE = "VBF_EXC_SYNTAX_NO_VAL_THROWABLE"; //$NON-NLS-1$
- public static final String VBF_EXC_SYNTAX_NO_VAL_NULL = "VBF_EXC_SYNTAX_NO_VAL_NULL"; //$NON-NLS-1$
- public static final String VBF_EXC_INVALID_RESOURCE = "VBF_EXC_INVALID_RESOURCE"; //$NON-NLS-1$
-
- public static final String VBF_EXC_NULLCREATE = "VBF_EXC_NULLCREATE"; //$NON-NLS-1$
- public static final String VBF_EXC_NULLSAVE = "VBF_EXC_NULLSAVE"; //$NON-NLS-1$
- public static final String VBF_EXC_SAVE = "VBF_EXC_SAVE"; //$NON-NLS-1$
- public static final String VBF_EXC_NULLRETRIEVE = "VBF_EXC_NULLRETRIEVE"; //$NON-NLS-1$
- public static final String VBF_EXC_RETRIEVE = "VBF_EXC_RETRIEVE"; //$NON-NLS-1$
-
- public static final String VBF_EXC_BADVMD = "VBF_EXC_BADVMD"; //$NON-NLS-1$
- public static final String VBF_EXC_OPENPRJ = "VBF_EXC_OPENPRJ"; //$NON-NLS-1$
- public static final String VBF_EXC_EXISTPRJ = "VBF_EXC_EXISTPRJ"; //$NON-NLS-1$
- public static final String VBF_EXC_BADPRJ = "VBF_EXC_BADPRJ"; //$NON-NLS-1$
- public static final String VBF_EXC_MULTIPRJ = "VBF_EXC_MULTIPRJ"; //$NON-NLS-1$
- public static final String VBF_EXC_BADVAL = "VBF_EXC_BADVAL"; //$NON-NLS-1$
-
- public static final String VBF_STATUS_START_REMOVING_OLD_MESSAGES = "VBF_STATUS_START_REMOVING_OLD_MESSAGES"; //$NON-NLS-1$
- public static final String VBF_STATUS_FINISH_REMOVING_OLD_MESSAGES = "VBF_STATUS_FINISH_REMOVING_OLD_MESSAGES"; //$NON-NLS-1$
-
- public static final String VBF_TASK_WARN_MESSAGE_LIMIT_VAL = "VBF_TASK_WARN_MESSAGE_LIMIT_VAL"; //$NON-NLS-1$
-
- public static final String VBF_EXC_DISABLEV = "VBF_EXC_DISABLEV"; //$NON-NLS-1$
- public static final String VBF_EXC_DISABLEH = "VBF_EXC_DISABLEH"; //$NON-NLS-1$
- public static final String VBF_EXC_ORPHAN_IVALIDATOR = "VBF_EXC_ORPHAN_IVALIDATOR"; //$NON-NLS-1$
-
- public static final String VBF_STATUS_LOOKING = "VBF_STATUS_LOOKING"; //$NON-NLS-1$
- public static final String VBF_STATUS_LOOKINGDONE = "VBF_STATUS_LOOKINGDONE"; //$NON-NLS-1$
- public static final String VBF_STATUS_REMOVING = "VBF_STATUS_REMOVING"; //$NON-NLS-1$
- public static final String VBF_STATUS_REMOVINGDONE = "VBF_STATUS_REMOVINGDONE"; //$NON-NLS-1$
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceHandler.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceHandler.java
deleted file mode 100644
index 0cf1cd42e..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ResourceHandler.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * This class retrieves the Strings from the .properties file appropriate for the machine's Locale.
- *
- *
- */
-public class ResourceHandler {
- //TODO Make this class final once the public ResourceHandler has been deleted.
- private static ResourceBundle _bundle = null;
-
- protected ResourceHandler() {
- //TODO Make this method private once the public ResourceHandler has been deleted.
- super();
- }
-
- /**
- * Return the resource bundle which contains the messages, as identified by
- */
- public static ResourceBundle getBundle() {
- if (_bundle == null) {
- try {
- _bundle = ResourceBundle.getBundle(ValidationPlugin.getBundleName());
- } catch (MissingResourceException exc) {
- _bundle = null;
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("org.eclipse.wst.validation.internal.operations.internal.ResourceHandler.getBundle()"); //$NON-NLS-1$
- entry.setText("Cannot find bundle " + ValidationPlugin.getBundleName()); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.FINE, entry);
- }
- }
- }
- return _bundle;
- }
-
- public static String getExternalizedMessage(String key) {
- try {
- ResourceBundle bundle = getBundle();
- if (bundle == null) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("org.eclipse.wst.validation.internal.operations.internal.ResourceHandler.getExternalizedMessage(String)"); //$NON-NLS-1$
- entry.setText("Resource bundle is null"); //$NON-NLS-1$
- logger.write(Level.FINE, entry);
- }
- return key;
- }
-
- return bundle.getString(key);
- } catch (NullPointerException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("org.eclipse.wst.validation.internal.operations.ui.ResourceHandler.getExternalizedMessage(String)"); //$NON-NLS-1$
- entry.setText("Cannot find message id " + key); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.FINE, entry);
- }
- }
- return key;
- }
-
- public static String getExternalizedMessage(String key, String[] parms) {
- String res = ""; //$NON-NLS-1$
- try {
- res = java.text.MessageFormat.format(getExternalizedMessage(key), parms);
- } catch (MissingResourceException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("org.eclipse.wst.validation.internal.operations.internal.ResourceHandler.getExternalizedMessage(String, String[])"); //$NON-NLS-1$
- entry.setText("Cannot find message id " + key); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.FINE, entry);
- }
- } catch (NullPointerException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("org.eclipse.wst.validation.internal.operations.internal.ResourceHandler.getExternalizedMessage(String, String[])"); //$NON-NLS-1$
- entry.setText("Cannot format message id " + key + " with " + parms.length + " parameters."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- entry.setTargetException(exc);
- logger.write(Level.FINE, entry);
- }
- }
- return res;
- }
-} \ No newline at end of file
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
deleted file mode 100644
index cdbf991ac..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TaskListUtility.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * This class must be called only by the validation framework.
- *
- * This singleton interacts with the eclipse workbench's Task list. TaskListUtility adds and removes
- * tasks from the list.
- *
- * This class must not be called outside of an IWorkspaceRunnable or IRunnableWithProgress. Many
- * resource deltas can be generated by the methods in this class.
- */
-public class TaskListUtility implements ConfigurationConstants {
- protected static final int DEPTH_INFINITE = IResource.DEPTH_INFINITE;
- protected static final int DEPTH_ZERO = IResource.DEPTH_ZERO;
- protected static final String VALIDATION_MARKER_TARGETOBJECT = "targetObject"; //$NON-NLS-1$
- private final static IMarker[] NO_MARKERS = new IMarker[0];
-
- public static IWorkspaceRoot getRoot() {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- return root;
- }
-
- /**
- * This method is here for use by the SABER validator's reporter instance ONLY. Do not use. See
- * defect 260144 for details.
- */
- public static IMarker setPriority(IMarker item, int priority) throws CoreException {
- Map attrib = item.getAttributes();
- attrib.put(IMarker.PRIORITY, new Integer(priority));
- item.setAttributes(attrib);
- return item;
- }
-
- /**
- * This method adds a message to a resource in the task list.
- */
- public static IMarker addTask(String pluginId, IResource resource, String location, String messageId, String message, int markerType, String markerName, String targetObjectName, String groupName, int offset, int length) throws CoreException {
- if ((message == null) || (resource == null)) {
- return null;
- }
-
- int severity = getSeverity(markerType);
-
- // Allow duplicate entries in the task list.
- // Prior to a full validation, the validation framework will remove all messages owned
- // by a validator before it is executed.
- // Prior to an incremental validation, the validation framework will remove all messages,
- // on each of the changed resources, owned by a validator before it is invoked.
- //
- // It is up to the validator to make sure that it is not adding the same message
- // in more than one place, and also to clear out any old messages which are not cleared
- // by the validation framework.
- IMarker item = null;
- if(markerName != null && markerName.length() >0 )
- item = resource.createMarker(markerName); // add a validation marker
- else
- item = resource.createMarker(VALIDATION_MARKER); // add a validation marker
-
- // For performance reasons, replace the multiple setAttribute
- // calls above with a single setAttributes call.
- boolean offsetSet = ((offset != IMessage.OFFSET_UNSET) && (length != IMessage.OFFSET_UNSET));
- int size = (offsetSet) ? 10 : 8; // add CHAR_START, CHAR_END only if the offset is set. If
- // the offset is set, it takes precendence over the line
- // number. (eclipse's rule, not mine.)
- String[] attribNames = new String[size];
- Object[] attribValues = new Object[size];
-
- // Very first thing, add the owner. That way, if the code dies
- // before things are persisted, hopefully this marker will be persisted.
- // Hopefully, eclipse WILL persist this field, as requested.
- attribNames[0] = VALIDATION_MARKER_OWNER;
- attribValues[0] = pluginId;
- attribNames[1] = VALIDATION_MARKER_SEVERITY; // this validation severity is stored, in
- // addition to the marker severity, to enable
- // more than one severity of message to be
- // displayed. e.g. ERROR | WARNING (using
- // binary OR). The IMarker constants are
- // regular decimal constants.
- attribValues[1] = new Integer(markerType);
- attribNames[2] = VALIDATION_MARKER_TARGETOBJECT; // to distinguish between messages which
- // are registered on an IResource, but
- // against different target objects
- attribValues[2] = ((targetObjectName == null) ? "" : targetObjectName); //$NON-NLS-1$
- attribNames[3] = VALIDATION_MARKER_GROUP;
- attribValues[3] = ((groupName == null) ? "" : groupName); //$NON-NLS-1$
- attribNames[4] = IMarker.MESSAGE;
- attribValues[4] = message;
- attribNames[5] = VALIDATION_MARKER_MESSAGEID;
- attribValues[5] = messageId;
-
- attribNames[6] = IMarker.SEVERITY; // IMarker.SEVERITY_ERROR, IMarker.SEVERITY_WARNING,
- // IMarker.SEVERITY_INFO
- attribValues[6] = new Integer(severity);
- try {
- // If the location is a line number, store it as a line number
- Integer lineNumber = Integer.valueOf(location);
- attribNames[7] = IMarker.LINE_NUMBER;
- attribValues[7] = lineNumber;
- } catch (NumberFormatException exc) {
- // Otherwise, store it as a text location
- attribNames[7] = IMarker.LOCATION;
- attribValues[7] = location;
- }
-
- if (offsetSet) {
- attribNames[8] = IMarker.CHAR_START;
- attribValues[8] = new Integer(offset);
- attribNames[9] = IMarker.CHAR_END;
- attribValues[9] = new Integer(offset + length);
- }
-
- item.setAttributes(attribNames, attribValues);
-
- return item;
- }
-
- /**
- * This method adds a message to a resource in the task list.
- */
- public static IMarker addTask(String pluginId, IResource resource, String location, String messageId, String message, int markerType, String targetObjectName, String groupName, int offset, int length) throws CoreException {
- if ((message == null) || (resource == null)) {
- return null;
- }
-
- int severity = getSeverity(markerType);
-
- // Allow duplicate entries in the task list.
- // Prior to a full validation, the validation framework will remove all messages owned
- // by a validator before it is executed.
- // Prior to an incremental validation, the validation framework will remove all messages,
- // on each of the changed resources, owned by a validator before it is invoked.
- //
- // It is up to the validator to make sure that it is not adding the same message
- // in more than one place, and also to clear out any old messages which are not cleared
- // by the validation framework.
- IMarker item = resource.createMarker(VALIDATION_MARKER); // add a validation marker
-
- // For performance reasons, replace the multiple setAttribute
- // calls above with a single setAttributes call.
- boolean offsetSet = ((offset != IMessage.OFFSET_UNSET) && (length != IMessage.OFFSET_UNSET));
- int size = (offsetSet) ? 10 : 8; // add CHAR_START, CHAR_END only if the offset is set. If
- // the offset is set, it takes precendence over the line
- // number. (eclipse's rule, not mine.)
- String[] attribNames = new String[size];
- Object[] attribValues = new Object[size];
-
- // Very first thing, add the owner. That way, if the code dies
- // before things are persisted, hopefully this marker will be persisted.
- // Hopefully, eclipse WILL persist this field, as requested.
- attribNames[0] = VALIDATION_MARKER_OWNER;
- attribValues[0] = pluginId;
- attribNames[1] = VALIDATION_MARKER_SEVERITY; // this validation severity is stored, in
- // addition to the marker severity, to enable
- // more than one severity of message to be
- // displayed. e.g. ERROR | WARNING (using
- // binary OR). The IMarker constants are
- // regular decimal constants.
- attribValues[1] = new Integer(markerType);
- attribNames[2] = VALIDATION_MARKER_TARGETOBJECT; // to distinguish between messages which
- // are registered on an IResource, but
- // against different target objects
- attribValues[2] = ((targetObjectName == null) ? "" : targetObjectName); //$NON-NLS-1$
- attribNames[3] = VALIDATION_MARKER_GROUP;
- attribValues[3] = ((groupName == null) ? "" : groupName); //$NON-NLS-1$
- attribNames[4] = IMarker.MESSAGE;
- attribValues[4] = message;
- attribNames[5] = VALIDATION_MARKER_MESSAGEID;
- attribValues[5] = messageId;
-
- attribNames[6] = IMarker.SEVERITY; // IMarker.SEVERITY_ERROR, IMarker.SEVERITY_WARNING,
- // IMarker.SEVERITY_INFO
- attribValues[6] = new Integer(severity);
- try {
- // If the location is a line number, store it as a line number
- Integer lineNumber = Integer.valueOf(location);
- attribNames[7] = IMarker.LINE_NUMBER;
- attribValues[7] = lineNumber;
- } catch (NumberFormatException exc) {
- // Otherwise, store it as a text location
- attribNames[7] = IMarker.LOCATION;
- attribValues[7] = location;
- }
-
- if (offsetSet) {
- attribNames[8] = IMarker.CHAR_START;
- attribValues[8] = new Integer(offset);
- attribNames[9] = IMarker.CHAR_END;
- attribValues[9] = new Integer(offset + length);
- }
-
- item.setAttributes(attribNames, attribValues);
-
- return item;
- }
-
- /**
- * Given one of the SeverityEnum severities, return the IMarker severity int that is its
- * equivalent.
- *
- * This method was made public for the SaberReporter. No one other than TaskListUtility, or the
- * SaberReporter, should use this method!
- *
- */
- private static int getSeverity(int severityEnumValue) {
- switch (severityEnumValue) {
- case (IMessage.HIGH_SEVERITY) : {
- return IMarker.SEVERITY_ERROR;
- }
-
- case (IMessage.LOW_SEVERITY) : {
- return IMarker.SEVERITY_INFO;
- }
-
- case (IMessage.NORMAL_SEVERITY) : {
- return IMarker.SEVERITY_WARNING;
- }
-
- case (IMessage.ALL_MESSAGES) :
- case (IMessage.ERROR_AND_WARNING) :
- default : {
- // assume it's a warning.
- return IMarker.SEVERITY_WARNING;
- }
- }
- }
-
- private static int getDepth(IResource resource) {
- if (resource instanceof IProject) {
- return DEPTH_INFINITE; // DEPTH_INFINITE means get this project's markers, and the
- // markers belonging to the project's children.
- } else if (resource instanceof IWorkspaceRoot) {
- // Needed for the ValidationMigrator when it checks for orphan tasks.
- return DEPTH_INFINITE; // DEPTH_INFINITE means get all of the markers in the workspace
- }
-
- return DEPTH_ZERO; // DEPTH_ZERO means just this resource, not its children
- }
-
- public static IMarker[] getValidationTasks(int severity, IProject project) {
- // DEPTH_INFINITE means get this project's markers, and the markers
- // belonging to the project's children.
- return getValidationTasks(project, severity);
- }
-
- public static IMarker[] getValidationTasks(IResource resource, int severity) {
- return getValidationTasks(resource, severity, getDepth(resource));
- }
-
- /**
- * Return true if the marker is owned by the ownerId.
- */
- public static boolean isOwner(IMarker marker, String ownerId) {
- try {
- Object owner = marker.getAttribute(VALIDATION_MARKER_OWNER);
- if ((owner == null) || !(owner instanceof String)) {
- // The ValidationMigrator will remove any "unowned" validation markers.
- return false;
- }
-
- return ((String) owner).equals(ownerId);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("TaskListUtility.isOwner(IMarker, ownerId)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return false;
- }
- }
-
- private static IMarker[] getValidationTasks(IResource resource, int severity, int depth) {
- IMarker[] tempMarkers = null;
- int validCount = 0;
- try {
- IMarker[] allMarkers = null;
- try {
- allMarkers = resource.findMarkers(VALIDATION_MARKER, true, depth); // false means
- // only consider
- // PROBLEM_MARKER,
- // not variants
- // of
- // PROBLEM_MARKER.
- // Since addTask
- // only adds
- // PROBLEM_MARKER,
- // we don't need
- // to consider
- // its subtypes.
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("TaskListUtility.getValidationTasks(IResource, int)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return NO_MARKERS;
- }
-
- // Now filter in the markers, based on severity type.
- if (allMarkers.length != 0) {
- tempMarkers = new IMarker[allMarkers.length];
- for (int i = 0; i < allMarkers.length; i++) {
- IMarker marker = allMarkers[i];
- Integer filterSeverity = (Integer) marker.getAttribute(VALIDATION_MARKER_SEVERITY);
- if (filterSeverity == null) {
- // odd...marker wasn't created correctly. How could this happen?
- // Default to the current severity and add it to the list.
- try {
- marker.setAttribute(IMarker.SEVERITY, getSeverity(severity));
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("TaskListUtility.getValidationTasks(int, IResource, int)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("TaskListUtility.getValidationTasks(int, IResource, int)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
- } else if ((severity & filterSeverity.intValue()) == 0) {
- continue;
- }
- tempMarkers[validCount++] = marker;
- }
- }
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("TaskListUtility.getValidationTasks(int, IResource, int)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
-
- if (validCount == 0) {
- return NO_MARKERS;
- }
-
- IMarker[] validMarkers = new IMarker[validCount];
- System.arraycopy(tempMarkers, 0, validMarkers, 0, validCount);
- return validMarkers;
- }
-
- public static IMarker[] getValidationTasks(IResource resource, String messageOwner) {
- return getValidationTasks(resource, new String[]{messageOwner}, getDepth(resource));
- }
-
- public static IMarker[] getValidationTasks(IResource resource, String[] messageOwners) {
- return getValidationTasks(resource, messageOwners, getDepth(resource));
- }
-
- private static IMarker[] getValidationTasks(IResource resource, String[] messageOwners, int depth) {
- IMarker[] markers = getValidationTasks(resource, IMessage.ALL_MESSAGES, depth);
- if (markers.length == 0) {
- return NO_MARKERS;
- }
-
- IMarker[] temp = new IMarker[markers.length];
- int validCount = 0;
- for (int i = 0; i < markers.length; i++) {
- IMarker marker = markers[i];
-
- try {
- Object owner = marker.getAttribute(VALIDATION_MARKER_OWNER);
- if ((owner == null) || !(owner instanceof String)) {
- // The ValidationMigrator will remove any "unowned" validation markers.
- continue;
- }
-
- for (int j = 0; j < messageOwners.length; j++) {
- String messageOwner = messageOwners[j];
- if (((String) owner).equals(messageOwner)) {
- temp[validCount++] = marker;
- break;
- }
- }
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("TaskListUtility.getValidationTasks(project, String[])"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return NO_MARKERS;
- }
- }
-
- IMarker[] result = new IMarker[validCount];
- System.arraycopy(temp, 0, result, 0, validCount);
- return result;
- }
-
- /**
- * This method retrieves all validation tasks from the resource. If depth is INFINITE, child
- * tasks are returned as well. Only the tasks which are owned by the specified messageOwner, and
- * apply to the named IMessage's target object (objectName) will be returned.
- */
- private static IMarker[] getValidationTasks(IResource resource, String[] messageOwner, String objectName, String groupName, int depth) throws CoreException {
- if ((messageOwner == null) || (resource == null)) {
- return NO_MARKERS;
- }
-
- int validCount = 0;
- IMarker[] validList = null;
- IMarker[] markers = getValidationTasks(resource, messageOwner, depth);
- if (markers != null) {
- validList = new IMarker[markers.length];
- for (int i = 0; i < markers.length; i++) {
- IMarker marker = markers[i];
-
- // If more than one target object resolves to the same resource, removing one
- // target's
- // messages should not remove the other target object's messages.
- if (objectName != null) {
- Object targetObject = marker.getAttribute(VALIDATION_MARKER_TARGETOBJECT);
- if ((targetObject == null) || !(targetObject instanceof String) || !(((String) targetObject).equals(objectName))) {
- continue;
- }
- }
-
- if (groupName != null) {
- Object group = marker.getAttribute(VALIDATION_MARKER_GROUP);
- if ((group == null) || !(group instanceof String) || !(((String) group).equals(groupName))) {
- continue;
- }
- }
-
- validList[validCount++] = marker;
- }
- }
-
- if (validCount == 0) {
- return NO_MARKERS;
- }
-
- IMarker[] result = new IMarker[validCount];
- System.arraycopy(validList, 0, result, 0, validCount);
- return result;
- }
-
- /**
- * Remove all validation messages from the resource and its children.
- */
- public static void removeAllTasks(IResource resource) {
- if (resource == null) {
- return;
- }
-
- try {
- IMarker[] markers = getValidationTasks(resource, IMessage.ALL_MESSAGES);
- ResourcesPlugin.getWorkspace().deleteMarkers(markers);
- } catch (CoreException exc) {
- // Couldn't remove the task from the task list for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchMonitor.removeAllMessages(String[], IResource, String)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- /**
- * This method removes all tasks from the resource. If the resource is an IProject, all tasks
- * are also removed from the project's children.
- */
- public static void removeAllTasks(IResource resource, String[] owners) throws CoreException {
- removeAllTasks(resource, owners, null); // null means remove messages from all target
- // objects
- }
-
- /**
- * This method removes all messages from a resource in the task list.
- */
- public static void removeAllTasks(IResource resource, String owner, String objectName) throws CoreException {
- removeAllTasks(resource, new String[]{owner}, objectName);
- }
-
- public static void removeAllTasks(IResource resource, String[] owners, String objectName) throws CoreException {
- removeAllTasks(resource, owners, objectName, getDepth(resource));
- }
-
- protected static void removeAllTasks(IResource resource, String[] owners, String objectName, int depth) throws CoreException {
- removeTaskSubset(resource, owners, objectName, null, depth); // null means no group name
- }
-
- /**
- * This method removes a subset of tasks from the project, including child tasks. Every task
- * which belongs to the group, identified by groupName, will be removed.
- */
- public static void removeTaskSubset(IResource resource, String[] owners, String objectName, String groupName) throws CoreException {
- removeTaskSubset(resource, owners, objectName, groupName, getDepth(resource));
- }
-
- /**
- * This method removes a subset of tasks from the project, including child tasks. Every task
- * which belongs to the group, identified by groupName, will be removed.
- */
- protected static void removeTaskSubset(IResource resource, String[] owners, String objectName, String groupName, int depth) throws CoreException {
- if ((owners == null) || (resource == null)) {
- return;
- }
-
- IMarker[] allTasks = getValidationTasks(resource, owners, objectName, groupName, depth);
- if (allTasks.length > 0) {
- ResourcesPlugin.getWorkspace().deleteMarkers(allTasks);
- }
- }
-
- /**
- * This method changes all validator markers which are owned by "from" to make their owner "to".
- */
- public static void updateOwner(String from, String to) throws CoreException {
- updateOwner(from, to, getRoot());
- }
-
- /**
- * This method changes all validator markers on the IResource and its children. All markers
- * owned by "from" have their owner reassigned to "to".
- */
- public static void updateOwner(String from, String to, IResource resource) throws CoreException {
- IMarker[] ownedMarkers = getValidationTasks(resource, from);
- if (ownedMarkers == null) {
- return;
- }
-
- for (int i = 0; i < ownedMarkers.length; i++) {
- IMarker marker = ownedMarkers[i];
- marker.setAttribute(VALIDATION_MARKER_OWNER, to);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TimeEntry.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TimeEntry.java
deleted file mode 100644
index d63ed1711..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/TimeEntry.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import org.eclipse.jem.util.logger.LogEntry;
-
-
-/**
- * This class should be used when logging "elapsed time" information and nothing else. Instead of
- * creating a new instance of this class every time it is needed, for performance reasons, create an
- * instance and reuse it. The text in this class is never translated.
- */
-public class TimeEntry extends LogEntry {
- private String _toolName = null;
- private String _details = null;
- private String _projectName = null;
- private String _sourceId = null;
- private int _executionMap = 0x0;
-
- public TimeEntry() {
- super();
- }
-
- /**
- * The name of the tool (e.g., a validator, a builder) whose time is measured.
- */
- public String getToolName() {
- return _toolName;
- }
-
- public void setToolName(String name) {
- _toolName = name;
- }
-
-
- /**
- * If there are any details that need to be recorded about the tool, such as what input it runs
- * on, this field stores the value. This field is optional.
- */
- public String getDetails() {
- return _details;
- }
-
- public void setDetails(String d) {
- _details = d;
- }
-
- /**
- * The name of the project on which the tool ran.
- */
- public String getProjectName() {
- return _projectName;
- }
-
- public void setProjectName(String name) {
- _projectName = name;
- }
-
- /**
- * The id of the code that launched the tool.
- */
- public String getSourceID() {
- return _sourceId;
- }
-
- public void setSourceID(String id) {
- _sourceId = id;
- }
-
- /**
- * If, in addition to elapsed time, the tool needs to track the execution path of a method, this
- * field stores the hexadecimal number that tracks the path. See ValidationBuilder::build for an
- * example that uses an execution path.
- */
- public int getExcecutionMap() {
- return _executionMap;
- }
-
- public void setExecutionMap(int map) {
- _executionMap = map;
- }
-
- /**
- * Clear all of the fields back to their initial setting so that this TimeEntry instance can be
- * reused.
- */
- public void reset() {
- _toolName = null;
- _details = null;
- _projectName = null;
- _sourceId = null;
- _executionMap = 0;
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 05b3891dc..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/VThreadManager.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import java.util.Vector;
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * This class manages (queue, invoke, etc.) the Runnables that perform the validation for a
- * particular validator.
- */
-public class VThreadManager {
- private static VThreadManager _manager = null;
- private static final int MAX_NUM_OF_RESTART = 5; // the maximum number of times that the thread
- // should attempt to ignore a Throwable and
- // carry on
-
- private Thread _validationThread = null; // This thread checks if the current Runnable is
- // finished, and if so, loads the first Runnable off of
- // the queue and starts it.
- volatile int restart = 0; // how many times has the thread been restarted?
- volatile Jobs _jobs = null;
-
- private VThreadManager() {
- _jobs = new Jobs();
-
- // Start the validation thread to check for queued ValidationOperation
- Runnable validationRunnable = new Runnable() {
- public void run() {
- while (true) {
- try {
- if (restart > MAX_NUM_OF_RESTART) {
- // something has gone seriously, seriously wrong
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("VThreadManager::validationRunnable"); //$NON-NLS-1$
- entry.setText("restart = " + restart); //$NON-NLS-1$
- logger.write(Level.SEVERE, entry);
- }
- break;
- }
-
- Runnable job = getJobs().dequeue(); // If currentRunnable is null, there's
- // nothing on the queue. Shouldn't
- // happen with a semaphore.
- if (job != null) {
- getJobs().setActive(true);
- job.run();
- getJobs().setActive(false);
- }
- } catch (Throwable exc) {
- // This exception is added as FINE instead of SEVERE because it's not
- // improbable
- // that an exception will be thrown
- restart++;
- getJobs().setActive(false);
-
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("VThreadManager::validationRunnable"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.FINE, entry);
- }
- } finally {
- //do nothing
- }
- }
- }
- };
-
- _validationThread = new Thread(validationRunnable, "ValidationThread"); //$NON-NLS-1$
- _validationThread.start();
- }
-
- public static VThreadManager getManager() {
- if (_manager == null) {
- _manager = new VThreadManager();
- }
- return _manager;
- }
-
- Jobs getJobs() {
- return _jobs;
- }
-
- public void queue(Runnable runnable) {
- getJobs().queue(runnable);
- }
-
- /**
- * Return true if all of the Runnables have been run.
- */
- public boolean isDone() {
- return getJobs().isDone();
- }
-
- 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?
-
- public Jobs() {
- __jobs = new Vector();
- }
-
- public synchronized void queue(Runnable runnable) {
- // If there is a thread running already, then it must finish before another validation
- // thread is launched, or the validation messages could reflect the last thread
- // finished,
- // 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);
- notifyAll();
- }
-
- /**
- * Pop the Runnable off of the head of the queue.
- */
- synchronized Runnable dequeue() {
- while (__jobs.size() == 0) {
- try {
- wait();
- } catch (InterruptedException exc) {
- //Ignore
- }
- } // 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 (job != null) {
- __jobs.remove(0);
- }
- }
- return job;
- }
-
- public synchronized boolean isActive() {
- return _isActive;
- }
-
- public synchronized void setActive(boolean active) {
- _isActive = active;
- }
-
- /**
- * Return true if all of the Runnables have been run.
- */
- public synchronized boolean isDone() {
- return ((__jobs.size() == 0) && !isActive());
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java
deleted file mode 100644
index a9b784745..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationConfiguration.java
+++ /dev/null
@@ -1,769 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-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;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-
-/**
- * This class represents the user's preference or project settings.
- *
- * This class is populated from the multiple persistent properties, and is kept as a session
- * property while the resource is open.
- */
-public abstract class ValidationConfiguration {
- private IResource _resource = null;
- private boolean _autoValidate = getAutoValidateDefault();
- private boolean _buildValidate = getBuildValidateDefault();
- private int _maxMessages = getMaximumNumberOfMessagesDefault();
- private String _version = null;
- private Map _validators = null; // Map of all validators (ValidatorMetaData) configured on the
- // project or installed globally. The value is a Boolean; TRUE
- // means that the VMD is enabled, FALSE means that the VMD is
- // disabled.
- private boolean _runAsync = getAsyncDefault();
-
- public static String getEnabledElementsAsString(Set elements) {
- if (elements == null) {
- return null;
- }
-
- StringBuffer buffer = new StringBuffer();
- Iterator iterator = elements.iterator();
- while (iterator.hasNext()) {
- buffer.append(((ValidatorMetaData) iterator.next()).getValidatorUniqueName());
- buffer.append(ConfigurationConstants.ELEMENT_SEPARATOR);
- }
- return buffer.toString();
- }
-
- public static String getEnabledElementsAsString(Object[] elements) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < elements.length; i++) {
- buffer.append(((ValidatorMetaData) elements[i]).getValidatorUniqueName());
- buffer.append(ConfigurationConstants.ELEMENT_SEPARATOR);
- }
- return buffer.toString();
- }
-
- public static Set getStringAsEnabledElements(String elements) {
- if (elements == null) {
- return null;
- }
-
- HashSet result = new HashSet();
- StringTokenizer tokenizer = new StringTokenizer(elements, ConfigurationConstants.ELEMENT_SEPARATOR);
- while (tokenizer.hasMoreTokens()) {
- String elem = tokenizer.nextToken();
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(elem);
- if (vmd != null) {
- result.add(vmd);
- }
- }
- return result;
- }
-
- public static ValidatorMetaData[] getStringAsEnabledElementsArray(String elements) {
- if (elements == null) {
- return null;
- }
-
- StringTokenizer tokenizer = new StringTokenizer(elements, ConfigurationConstants.ELEMENT_SEPARATOR);
- ValidatorMetaData[] result = new ValidatorMetaData[tokenizer.countTokens()];
- int count = 0;
- while (tokenizer.hasMoreTokens()) {
- String elem = tokenizer.nextToken();
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(elem);
- if (vmd != null) {
- result[count++] = vmd;
- }
- }
-
- if (count != result.length) {
- ValidatorMetaData[] trimResult = new ValidatorMetaData[count];
- System.arraycopy(result, 0, trimResult, 0, count);
- return trimResult;
- }
-
- return result;
- }
-
- public static IWorkspaceRoot getRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- protected ValidationConfiguration() throws InvocationTargetException {
- _validators = new HashMap();
- }
-
- protected ValidationConfiguration(IResource resource, ValidatorMetaData[] validators) throws InvocationTargetException {
- this();
-
- if (resource == null) {
- throw new InvocationTargetException(null, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_NULLCREATE));
- }
-
- setResource(resource);
- setValidators(validators);
- }
-
- private void setResource(IResource resource) {
- _resource = resource;
- }
-
- public boolean isAutoValidate() throws InvocationTargetException {
- return _autoValidate;
- }
-
- public void setAutoValidate(boolean auto) {
- _autoValidate = auto;
- }
-
- public boolean isBuildValidate() throws InvocationTargetException {
- return _buildValidate;
- }
-
- public void setBuildValidate(boolean build) {
- _buildValidate = build;
- }
-
- public boolean runAsync() throws InvocationTargetException {
- return _runAsync;
- }
-
- public void setAsync(boolean doRunInBackgroundThread) throws InvocationTargetException {
- _runAsync = doRunInBackgroundThread;
- }
-
- public ValidatorMetaData[] getEnabledValidators() throws InvocationTargetException {
- return getValidators(true);
- }
-
- /**
- * If "incremental" is true, return the enabled incremental validators. If "incremental" is
- * false, return the enabled non-incremental validators.
- */
- public ValidatorMetaData[] getEnabledIncrementalValidators(boolean incremental) throws InvocationTargetException {
- ValidatorMetaData[] temp = new ValidatorMetaData[numberOfValidators()];
- Iterator iterator = getValidatorMetaData().keySet().iterator();
- int count = 0;
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- Boolean bvalue = (Boolean) getValidatorMetaData().get(vmd);
- if (bvalue.booleanValue() == true) {
- // If the validator is enabled
- if ((vmd.isIncremental() && incremental) || (!vmd.isIncremental() && !incremental)) {
- temp[count++] = vmd;
- }
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- return result;
- }
-
- /**
- * If "fullBuild" is true, return the enabled validators that support full builds. If
- * "fullBuild" is false, return the enabled validators that do not support full builds.
- */
- public ValidatorMetaData[] getEnabledFullBuildValidators(boolean fullBuild) throws InvocationTargetException {
- return getEnabledFullBuildValidators(fullBuild, false);
- }
-
- public ValidatorMetaData[] getEnabledFullBuildValidators(boolean fullBuild, boolean onlyReferenced) throws InvocationTargetException {
- ValidatorMetaData[] temp = new ValidatorMetaData[numberOfValidators()];
- Iterator iterator = getValidatorMetaData().keySet().iterator();
- int count = 0;
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- Boolean bvalue = (Boolean) getValidatorMetaData().get(vmd);
- if (bvalue.booleanValue() == true) {
- // If the validator is enabled
- if (vmd == null)
- continue;
- if ((vmd.isFullBuild() && fullBuild) || (!vmd.isFullBuild() && !fullBuild)) {
- if (!onlyReferenced || vmd.isDependentValidator())
- temp[count++] = vmd;
- }
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- return result;
- }
-
- public void setEnabledValidators(ValidatorMetaData[] vmds) {
- // First, "disable" all validators
- Map all = getValidatorMetaData();
- Iterator iterator = all.keySet().iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- all.put(vmd, Boolean.FALSE);
- }
-
- // Then enable only the validators in the array
- if ((vmds == null) || (vmds.length == 0)) {
- return;
- }
- for (int i = 0; i < vmds.length; i++) {
- all.put(vmds[i], Boolean.TRUE);
- }
- }
-
- private Map getValidatorMetaData() {
- return _validators;
- }
-
- public ValidatorMetaData[] getDisabledValidators() throws InvocationTargetException {
- return getValidators(false);
- }
-
- /**
- * Return an array of ValidatorMetaData - if value is false, return the disabled validators; if
- * value is true, return the enabled validators.
- */
- private ValidatorMetaData[] getValidators(boolean value) throws InvocationTargetException {
- ValidatorMetaData[] temp = new ValidatorMetaData[numberOfValidators()];
- Iterator iterator = getValidatorMetaData().keySet().iterator();
- int count = 0;
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- Boolean bvalue = (Boolean) getValidatorMetaData().get(vmd);
- if (bvalue.booleanValue() == value) {
- temp[count++] = vmd;
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- return result;
- }
-
- /**
- * Return all incremental validators for this preference; either every installed validator
- * (global) or every validator configured on the project (project).
- */
- public ValidatorMetaData[] getIncrementalValidators() throws InvocationTargetException {
- ValidatorMetaData[] temp = new ValidatorMetaData[numberOfValidators()];
- Iterator iterator = getValidatorMetaData().keySet().iterator();
- int count = 0;
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- Boolean bvalue = (Boolean) getValidatorMetaData().get(vmd);
- if (bvalue.booleanValue() == true) {
- // If the validator is enabled
- if (vmd.isIncremental()) {
- temp[count++] = vmd;
- }
- }
- }
-
- ValidatorMetaData[] result = new ValidatorMetaData[count];
- System.arraycopy(temp, 0, result, 0, count);
- return result;
- }
-
- /**
- * Return all validators for this preference; either every installed validator (global) or every
- * validator configured on the project (project).
- */
- public ValidatorMetaData[] getValidators() throws InvocationTargetException {
- return convertToArray(_validators.keySet());
- }
-
- public void setValidators(ValidatorMetaData[] vmds) {
- _validators.clear();
- for (int i = 0; i < vmds.length; i++) {
- if (vmds[i] == null)
- continue;
- _validators.put(vmds[i], (vmds[i].isEnabledByDefault() ? Boolean.TRUE : Boolean.FALSE));
- }
- }
-
- /**
- * Returns the number of configured validators on the given project or installed validators in
- * the workspace.
- */
- public int numberOfValidators() throws InvocationTargetException {
- return _validators.size();
- }
-
- public int numberOfEnabledIncrementalValidators() throws InvocationTargetException {
- return numberOfIncrementalValidators(getEnabledValidators());
- }
-
- public int numberOfIncrementalValidators() throws InvocationTargetException {
- return numberOfIncrementalValidators(getValidators());
- }
-
- private static int numberOfIncrementalValidators(ValidatorMetaData[] vmds) {
- int count = 0;
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- if (vmd.isIncremental()) {
- count++;
- }
- }
- return count;
- }
-
- /**
- * Returns the number of enabled validators on the project or workspace.
- */
- public int numberOfEnabledValidators() throws InvocationTargetException {
- return getEnabledValidators().length;
- }
-
- /**
- * Returns the number of disabled validators on the project or workspace.
- */
- public int numberOfDisabledValidators() throws InvocationTargetException {
- return getDisabledValidators().length;
- }
-
- public int getMaximumNumberOfMessages() throws InvocationTargetException {
- return _maxMessages;
- }
-
- public void setMaximumNumberOfMessages(int max) {
- _maxMessages = max;
- }
-
- /**
- * The value returned from this method is guaranteed to be non-null.
- */
- public final String getVersion() throws InvocationTargetException {
- if (_version == null) {
- loadVersion();
- }
- return _version;
- }
-
- private void setVersion(String version) {
- _version = version;
- }
-
- /**
- * This preference has been migrated; change the version to the current version.
- */
- public void markVersionCurrent() {
- // The version should not be marked current until the migration is complete
- // (i.e., ValidationMigrator has been invoked.) Migrating the user's configuration
- // is only the first step of the migration.
- setVersion(ConfigurationConstants.CURRENT_VERSION);
- }
-
- public boolean isVersionCurrent() throws InvocationTargetException {
- return getVersion().equals(ConfigurationConstants.CURRENT_VERSION);
- }
-
- // IResource could be an IProject or an IWorkspaceRoot
- public IResource getResource() {
- return _resource;
- }
-
- /**
- * Return true if the validator is enabled on this preference.
- */
- public boolean isEnabled(String validatorClassName) throws InvocationTargetException {
- if (validatorClassName == null) {
- return false;
- }
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorClassName);
- return isEnabled(vmd);
- }
-
- /**
- * Return true if the validator is enabled on this preference.
- */
- public boolean isEnabled(ValidatorMetaData vmd) throws InvocationTargetException {
- if (vmd == null) {
- return false;
- }
-
- Boolean value = (Boolean) getValidatorMetaData().get(vmd);
- if (value == null) {
- return false;
- }
-
- return value.booleanValue();
- }
-
- /**
- * Once all of the fields have been updated on this ValidationConfiguration instance, this
- * preference should be stored back on the IResource for later use. This method must be called
- * manually by the validation framework once the fields of this type have been updated.
- */
- public final void passivate() throws InvocationTargetException {
- try {
- if (getResource() == null) {
- throw new InvocationTargetException(null, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_NULLSAVE));
- }
-
- getResource().setSessionProperty(ConfigurationConstants.USER_PREFERENCE, this);
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SAVE, new String[]{getResource().getName()}));
- }
- }
-
- /**
- * Reset the values to the default values.
- */
- public abstract void resetToDefault() throws InvocationTargetException;
-
- protected Boolean convertToBoolean(boolean value) {
- return (value == true ? Boolean.TRUE : Boolean.FALSE);
- }
-
- protected Integer convertToInteger(int value) {
- return new Integer(value);
- }
-
- protected boolean convertToBoolean(String value) {
- Boolean b = Boolean.valueOf(value);
- return b.booleanValue();
- }
-
- protected int convertToInt(String value) {
- Integer t = Integer.valueOf(value);
- return t.intValue();
- }
-
- public static ValidatorMetaData[] convertToArray(Collection c) {
- int length = (c == null) ? 0 : c.size();
- ValidatorMetaData[] result = new ValidatorMetaData[length];
- if (length == 0) {
- return result;
- }
-
- Iterator iterator = c.iterator();
- int count = 0;
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- result[count++] = vmd;
- }
-
- return result;
- }
-
- public static ValidatorMetaData[] convertToArray(Object[] c) {
- int length = (c == null) ? 0 : c.length;
- ValidatorMetaData[] result = new ValidatorMetaData[length];
- if (length == 0) {
- return result;
- }
-
- System.arraycopy(c, 0, result, 0, length);
- return result;
- }
-
- /**
- * Save the values of these fields before the project or workspace is closed.
- */
- public void store() throws InvocationTargetException {
- if (getResource() == null) {
- throw new InvocationTargetException(null, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_NULLSAVE));
- }
-
- try {
- getResource().setPersistentProperty(ConfigurationConstants.USER_PREFERENCE, serialize());
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_SAVE, new String[]{getResource().getName()}));
- }
- }
-
- /**
- * Load and store the version number, but nothing else. The version isn't a preference, but it's
- * stored and loaded as if it is. Because the load mechanism is different between an IProject
- * and the IWorkspaceRoot, keep the load mechanism inside the ValidationConfiguration
- * implementation, but initialize only the minimum at first. After the project has been
- * migrated, load the other fields (loading the other fields before the migration may overwrite
- * the values of those fields).
- */
- protected final void loadVersion() throws InvocationTargetException {
- if (getResource() == null) {
- throw new InvocationTargetException(null, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_NULLRETRIEVE));
- }
-
- IMarker[] marker = getMarker();
- String version = null;
- if (marker == null) {
- // either a new workspace or already migrated; proceed as normal
- version = loadVersion(getResource());
- } else {
- // migrate
- version = loadVersion(marker);
- }
- setVersion(version);
- }
-
- protected final String loadVersion(IMarker[] marker) throws InvocationTargetException {
- String version = (String) getValue(marker[0], ConfigurationConstants.VERSION);
- if (version == null) {
- return ConfigurationConstants.VERSION4_03;
- }
-
- return version;
- }
-
- protected final String loadVersion(IResource resource) throws InvocationTargetException {
- try {
- // This method will be called in one of two situations:
- // 1. This is a new workspace and no preferences exist.
- // 2. This is a migrated workspace and the old preferences have already been created as
- // persistent properties.
- String storedConfiguration = resource.getPersistentProperty(ConfigurationConstants.USER_PREFERENCE);
- String version = null;
- if (storedConfiguration == null) {
- version = getVersionDefault();
- } else {
- int versionIndex = storedConfiguration.indexOf(ConfigurationConstants.VERSION);
- if (versionIndex != -1)
- version = storedConfiguration.substring(versionIndex + ConfigurationConstants.VERSION.length());
- }
-
- if (version == null) {
- return getVersionDefault();
- }
-
- return version;
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{getResource().getName()}));
- }
- }
-
- /**
- * Load the values of these fields when the project or workspace is opened.
- */
- protected final void load() throws InvocationTargetException {
- try {
- if (getResource() == null) {
- throw new InvocationTargetException(null, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_NULLRETRIEVE));
- }
-
- IMarker[] marker = getMarker();
- if (marker == null) {
- // either a new workspace or already migrated; proceed as normal
- load(getResource());
- } else {
- // migrate
- load(marker);
- }
- } catch (InvocationTargetException exc) {
- throw exc;
- } catch (Throwable exc) {
- String resourceName = (getResource() == null) ? "null" : getResource().getName(); //$NON-NLS-1$
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{resourceName}));
- }
- }
-
- /**
- * Return the IMarker that used to store the preference information, if the marker exists. (If
- * it doesn't exist, then it's already been migrated.)
- */
- protected abstract IMarker[] getMarker();
-
- protected abstract void load(IMarker[] marker) throws InvocationTargetException;
-
- protected Object getValue(IMarker marker, String attribName) {
- if (marker == null) {
- return null;
- }
-
- try {
- return marker.getAttribute(attribName);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidationConfiguration::getValue(" + attribName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- }
-
- protected boolean getValue(IMarker marker, String attribName, boolean defaultValue) {
- Boolean bool = (Boolean) getValue(marker, attribName);
- if (bool == null) {
- return defaultValue;
- }
-
- return bool.booleanValue();
- }
-
- protected int getValue(IMarker marker, String attribName, int defaultValue) {
- Integer integer = (Integer) getValue(marker, attribName);
- if (integer == null) {
- return defaultValue;
- }
-
- return integer.intValue();
- }
-
- protected String getValue(IMarker marker, String attribName, String defaultValue) {
- String string = (String) getValue(marker, attribName);
- if (string == null) {
- return defaultValue;
- }
-
- return string;
- }
-
- protected final void load(IResource resource) throws InvocationTargetException {
- // This method will be called in one of two situations:
- // 1. This is a new workspace and no preferences exist.
- // 2. This is a migrated workspace and the old preferences have already been created as
- // persistent properties.
- try {
- String storedConfiguration = resource.getPersistentProperty(ConfigurationConstants.USER_PREFERENCE);
- deserialize(storedConfiguration);
- } catch (CoreException exc) {
- throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{getResource().getName()}));
- }
- }
-
- protected void copyTo(ValidationConfiguration up) throws InvocationTargetException {
- up.setVersion(getVersion());
- up.setResource(getResource());
- up.setValidators(getValidators());
- up.setAutoValidate(isAutoValidate());
- up.setBuildValidate(isBuildValidate());
- up.setEnabledValidators(getEnabledValidators());
- up.setMaximumNumberOfMessages(getMaximumNumberOfMessages());
- }
-
- /**
- * Return true if the enabled validators have not changed since this ValidationConfiguration was
- * constructed, false otherwise. (This method is needed for the Properties and Preference pages;
- * if the list of validators hasn't changed, then there is no need to update the task list;
- * updating the task list is a costly operation.)
- */
- protected boolean hasEnabledValidatorsChanged(ValidatorMetaData[] oldEnabledVmd) throws InvocationTargetException {
- // First check the obvious: is every enabled validator still enabled, and is
- // the number of enabled validators the same as it was before? If not, return true.
- if (oldEnabledVmd == null) {
- // Something's gone wrong...
- return true;
- }
-
- for (int i = 0; i < oldEnabledVmd.length; i++) {
- ValidatorMetaData vmd = oldEnabledVmd[i];
- if (!isEnabled(vmd)) {
- return true;
- }
- }
-
- // Everything that was enabled is still enabled; have any additional
- // validators been enabled?
- if (numberOfEnabledValidators() != oldEnabledVmd.length) {
- return true;
- }
-
- return false;
- }
-
- protected String serialize() throws InvocationTargetException {
- StringBuffer buffer = new StringBuffer();
- buffer.append(ConfigurationConstants.AUTO_SETTING);
- buffer.append(String.valueOf(isAutoValidate()));
- buffer.append(ConfigurationConstants.BUILD_SETTING);
- buffer.append(String.valueOf(isBuildValidate()));
- buffer.append(ConfigurationConstants.MAXNUMMESSAGES);
- buffer.append(String.valueOf(getMaximumNumberOfMessages()));
- buffer.append(ConfigurationConstants.ASYNC_SETTING);
- buffer.append(String.valueOf(runAsync()));
- buffer.append(ConfigurationConstants.ENABLED_VALIDATORS);
- buffer.append(getEnabledElementsAsString(getEnabledValidators()));
- buffer.append(ConfigurationConstants.VERSION);
- buffer.append(getVersion());
- return buffer.toString();
- }
-
- /**
- * Deserialize everything except the version number; the version is deserialized first, in the
- * loadVersion() method.
- */
- protected void deserialize(String storedConfiguration) throws InvocationTargetException {
- if (storedConfiguration == null || storedConfiguration.length() == 0) {
- // Assume that the configuration has never been set (new workspace).
- resetToDefault();
- return;
- }
-
- int autoIndex = storedConfiguration.indexOf(ConfigurationConstants.AUTO_SETTING);
- int buildIndex = storedConfiguration.indexOf(ConfigurationConstants.BUILD_SETTING);
- int maxIndex = storedConfiguration.indexOf(ConfigurationConstants.MAXNUMMESSAGES);
- int asyncIndex = storedConfiguration.indexOf(ConfigurationConstants.ASYNC_SETTING);
- int enabledIndex = storedConfiguration.indexOf(ConfigurationConstants.ENABLED_VALIDATORS);
- int versionIndex = storedConfiguration.indexOf(ConfigurationConstants.VERSION);
-
- String auto = storedConfiguration.substring(autoIndex + ConfigurationConstants.AUTO_SETTING.length(), buildIndex);
- String build = storedConfiguration.substring(buildIndex + ConfigurationConstants.BUILD_SETTING.length(), maxIndex);
- String max = storedConfiguration.substring(maxIndex + ConfigurationConstants.MAXNUMMESSAGES.length(), asyncIndex);
- String async = storedConfiguration.substring(asyncIndex + ConfigurationConstants.ASYNC_SETTING.length(), enabledIndex);
- String enabled = storedConfiguration.substring(enabledIndex + ConfigurationConstants.ENABLED_VALIDATORS.length(), versionIndex);
-
- setAutoValidate(Boolean.valueOf(auto).booleanValue());
- setBuildValidate(Boolean.valueOf(build).booleanValue());
- setMaximumNumberOfMessages(Integer.valueOf(max).intValue());
- setAsync(Boolean.valueOf(async).booleanValue());
- setEnabledValidators(getStringAsEnabledElementsArray(enabled));
- }
-
- public static boolean getAutoValidateDefault() {
- return ConfigurationConstants.DEFAULT_AUTO_SETTING;
- }
-
- public static boolean getBuildValidateDefault() {
- return ConfigurationConstants.DEFAULT_BUILD_SETTING;
- }
-
- public static ValidatorMetaData[] getEnabledValidatorsDefault() {
- return ConfigurationConstants.DEFAULT_ENABLED_VALIDATORS;
- }
-
- public static int getMaximumNumberOfMessagesDefault() {
- return ConfigurationConstants.DEFAULT_MAXNUMMESSAGES;
- }
-
- public static String getVersionDefault() {
- // If the version can't be retrieved, assume that it's a new workspace. (A null version
- // could also mean a 4.03 workspace, but that's taken care of in the load(IMarker[])
- // method.)
- return ConfigurationConstants.CURRENT_VERSION;
- }
-
- public static boolean getAsyncDefault() {
- return ConfigurationConstants.DEFAULT_ASYNC;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationFactoryImpl.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationFactoryImpl.java
deleted file mode 100644
index 058e8f806..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationFactoryImpl.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import org.eclipse.wst.validation.internal.provisional.ValidationFactory;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-public class ValidationFactoryImpl implements ValidationFactory {
- static ValidationFactory inst = null;
-
- public ValidationFactoryImpl() {
- super();
- }
-
- public static ValidationFactory getInstance() {
- if(inst == null)
- inst = new ValidationFactoryImpl();
- return inst;
- }
-
- public IValidator getValidator(String validatorUniqueId) throws InstantiationException {
- ValidationRegistryReader reader = ValidationRegistryReader.getReader();
- return reader.getValidator(validatorUniqueId);
- }
-
-}
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
deleted file mode 100644
index cbe091496..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationRegistryReader.java
+++ /dev/null
@@ -1,1394 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.operations.IRuleGroup;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-
-/**
- * ValidationRegistryReader is a singleton who reads the plugin registry for Validator extensions.
- * The read is done once (in the constructor), and the list of validators can be accessed by calling
- * "getValidatorMetaData(String)" on this class. The read is triggered by a call from
- * ValidatorManager's loadValidatorMetaData(IProject) method. ValidatorManager delegates the load
- * call to this class, and if this class is null, the singleton is new'ed up, and the registry is
- * read.
- *
- * No Validator should need to know about this class. The only class which should call
- * ValidationRegistryReader is ValidatorManager.
- *
- * The Validator itself is initialized in the "initializeValidator" method.
- *
- * <extension point="org.eclipse.wst.validation.internal.provisional.core.core.validator" id="EJBValidator" name="EJB
- * Validator"> <validator><projectNature id="com.ibm.etools.j2ee.EJBNature" include="false"/>
- * <filter objectClass="org.eclipse.core.resources.IFile" nameFilter = "ejb-jar.xml"/> <filter
- * objectClass="org.eclipse.core.resources.IFile" nameFilter = "*.java"/> <helper
- * class="org.eclipse.wst.validation.internal.provisional.core.core.ejb.workbenchimpl.EJBHelper"/> <run
- * class="org.eclipse.wst.validation.internal.provisional.core.core.ejb.EJBValidator" incremental="false" enabled="false"
- * pass="fast,full" async="false"/> <aggregateValidator class="my.aggregate.ValidatorClass"/>
- * <migrate><validator from="old.class.name" to="new.class.name"/> </migrate> </validator>
- * </extension>
- */
-public final class ValidationRegistryReader implements RegistryConstants {
- private static ValidationRegistryReader inst = null;
- 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,
- // 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;
- // 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.
- private static final String IRESOURCE = "org.eclipse.core.resources.IResource"; //$NON-NLS-1$
-
- 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.
-
- private List _tempList = null; // list for temporary values. Retrieve and use via the
-
- public HashMap projectValidationMetaData = null;
-
- /**
- * The registry is read once - when this class is instantiated.
- */
- private ValidationRegistryReader() {
- super();
-
- try {
- _validators = new HashMap();
- _indexedValidators = new HashMap();
- _defaultEnabledValidators = new HashSet();
-
- // Read the registry and build a map of validators. The key into
- // the map is the IValidator instance and the value is the ValidatorMetaData
- // which describes the IValidator.
- readRegistry();
-
- // Once all of the validators have been read, the caches of the
- // validators need to be updated.
- buildCache();
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader()"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- /**
- * Traverse over the list of VMDs which have been added and create copies of it. The copies are
- * created to increase runtime performance.
- */
- private void buildCache() {
- Iterator iterator = _indexedValidators.values().iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- buildProjectNatureCache(vmd);
- buildDefaultEnabledCache(vmd);
- }
-
- // Now add the validators which are configured on all projects,
- // and all projects but X.
- 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.
- _validators.remove(EXCLUDED_PROJECT);
-
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.buildCache()"); //$NON-NLS-1$
- entry.setText(debug());
- logger.write(Level.FINEST, entry);
- }
-
- }
-
- /**
- * Build the cache of VMDs which is indexed by project nature ids. If the validator is
- * registered on all project types, the vmd's project nature filters will be null.
- */
- private void buildProjectNatureCache(ValidatorMetaData vmd) {
- // Build the cache with the identified project natures in validators'
- // extensions.
- ValidatorNameFilter[] projNatureIds = vmd.getProjectNatureFilters();
- if (projNatureIds == null) {
- // Can run on any project
- add(UNKNOWN_PROJECT, vmd);
- } else {
- boolean noneIncluded = true; // assume that the validator does not include any project
- // natures
- for (int i = 0; i < projNatureIds.length; i++) {
- ValidatorNameFilter pn = projNatureIds[i];
- if (pn.isInclude()) {
- noneIncluded = false;
- add(pn.getNameFilter(), vmd);
- }
- }
-
- if (noneIncluded) {
- // add it to the list of EXCLUDED projects
- // (that is, a validator which excludes project natures but doesn't
- // explicitly include any. This type of validator runs on any unrecognized (UNKNOWN)
- // projects, but the rest of the cache needs to be built before this is added
- // to the UNKNOWN list. See addExcludedRemainder().
- add(EXCLUDED_PROJECT, vmd);
- }
- }
- }
-
- /**
- * Build the list of validators which are enabled by default.
- */
- private void buildDefaultEnabledCache(ValidatorMetaData vmd) {
- if (vmd == null) {
- return;
- }
-
- if (vmd.isEnabledByDefault()) {
- _defaultEnabledValidators.add(vmd);
- }
- }
-
- /**
- * Add vmd to the list of validators, indexed by validator class name
- */
- private void add(ValidatorMetaData vmd) {
- if (vmd == null) {
- return;
- }
-
- _indexedValidators.put(vmd.getValidatorUniqueName(), vmd);
- }
-
- /*
- * Some validators can run on any type of project. In order to have a static list, add the "any
- * project" validators to each "project nature" validators' list. This avoids adding the "any
- * project" validators to the "project nature" validators at runtime, which results in
- * performance savings.
- *
- * Some validators run on any type of project but X, where X is an excluded project nature.
- * Those validators should also be added via this method.
- */
- private void addRemainder() {
- // First, add all "can-run-on-any-project-type" to every registered project nature type in
- // the cache.
- addAnyRemainder();
-
- // Then add the "can-run-on-any-project-type-but-X" to every non-X registered project nature
- // type in the cache.
- addExcludedRemainder();
- }
-
- private void addExcludedRemainder() {
- Set excludedProjVmds = (Set) _validators.get(EXCLUDED_PROJECT);
- if (excludedProjVmds == null) {
- // no excluded project natures
- return;
- }
-
- Iterator exIterator = excludedProjVmds.iterator();
- while (exIterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) exIterator.next();
-
- 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();
- 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;
- }
-
- ValidatorNameFilter filter = vmd.findProjectNature(projId);
- if (filter != null) {
- // Don't add list to itself (filter.isIncluded() == true) or
- // to a list from which it's excluded (filter.isIncluded() == false)
- if (filter.isInclude()) {
- noneIncluded = false;
- }
- continue;
- }
-
- add(projId, vmd);
- }
-
- if (noneIncluded) {
- // At this point, the "can-run-on-any-project" becomes
- // "not-excluded-on-these-projects". That is, if the project
- // nature id isn't in the list of _validators, then it isn't
- // included or excluded by any validators, so all validators
- // which can run on any project AND all validators which can
- // run on any but certain excluded projects can run on the
- // given IProject.
- add(UNKNOWN_PROJECT, vmd);
- }
- }
- }
-
- private void addAnyRemainder() {
- Set anyProjVmds = (Set) _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();
- if (projId.equals(UNKNOWN_PROJECT) || projId.equals(EXCLUDED_PROJECT)) {
- // Don't add list to itself or to a project nature which is excluded.
- continue;
- }
-
- add(projId, anyProjVmds);
- }
- }
-
- private void add(String projectNatureId, Set 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
- pnVal.addAll(vmdList);
- _validators.put(projectNatureId, pnVal);
- }
-
- private void add(String projectNatureId, ValidatorMetaData vmd) {
- 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
- pnVal.add(vmd);
- _validators.put(projectNatureId, pnVal);
- }
-
- /**
- * When a validator's class or helper class cannot be loaded, the vmd calls this method to
- * disable the validator. The validator will be removed from the preference page, properties
- * page, and enabled list of any project thereafter validated.
- */
- public void disableValidator(ValidatorMetaData vmd) {
- _indexedValidators.remove(vmd.getValidatorUniqueName());
- _defaultEnabledValidators.remove(vmd);
-
- // The whole "on-any-project" and "exclude-this-project-nature" would take
- // 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;
- }
-
- if (value.contains(vmd)) {
- value.remove(vmd);
- _validators.put(key, value);
- }
- }
- }
-
- private Set createSet(String projNature) {
- Set v = (Set) _validators.get(projNature);
- if (v == null) {
- v = new HashSet();
- }
- return v;
- }
-
- /**
- * Given an IConfigurationElement, if it has a project nature(s) specified, return the
- * ValidatorNameFilters which represent those natures. Otherwise return null.
- *
- * A project nature can be specified in plugin.xml to indicate what types of IProjects a
- * validator can run on.
- */
- private String[] getAggregateValidatorsNames(IConfigurationElement element) {
- IConfigurationElement[] filters = element.getChildren(TAG_AGGREGATE_VALIDATORS);
- if (filters.length == 0)
- return null;
-
- String[] names = new String[filters.length];
- for (int i = 0; i < names.length; i++) {
- // In order to speed up our String comparisons, load these
- // names into Java's constants space. This way, we'll be able to
- // use pointer comparison instead of the traditional
- // character-by-character comparison. Since these names should
- // never be set by anyone other than this class, and this class
- // sets them only once, it is safe to declare these Strings
- // constants.
- //
- // To load a String into the constants space, call intern() on the String.
- //
- String nameFilter = filters[i].getAttribute(ATT_CLASS);
- if (nameFilter != null) {
- nameFilter = nameFilter.intern();
- }
- names[i] = nameFilter;
- }
- return names;
- }
-
- /**
- * Given an IConfigurationElement from plugin.xml, if it has any filter tags, construct the
- * appropriate ValidatorFilters to represent those tags; else return null.
- *
- * A filter can be specified in plugin.xml to filter out certain resources.
- */
- private ValidatorFilter[] getFilters(IConfigurationElement element) {
- IConfigurationElement[] filters = element.getChildren(TAG_FILTER);
- if (filters.length == 0)
- return null;
-
- ValidatorFilter[] vf = new ValidatorFilter[filters.length];
- for (int i = 0; i < filters.length; i++) {
- vf[i] = new ValidatorFilter(IRESOURCE);
-
- // In order to speed up our String comparisons, load these
- // names into Java's constants space. This way, we'll be able to
- // use pointer comparison instead of the traditional
- // character-by-character comparison. Since these names should
- // never be set by anyone other than this class, and this class
- // sets them only once, it is safe to declare these Strings
- // constants.
- //
- // To load a String into the constants space, call intern() on the String.
- //
- String nameFilter = filters[i].getAttribute(ATT_NAME_FILTER);
- if (nameFilter != null) {
- nameFilter = nameFilter.intern();
- }
- String isCaseSensitive = filters[i].getAttribute(ATT_CASE_SENSITIVE);
- vf[i].setNameFilter(nameFilter, isCaseSensitive);
-
- String objectClass = filters[i].getAttribute(ATT_OBJECT_CLASS);
- if (objectClass != null) {
- objectClass = objectClass.intern();
- }
- vf[i].setTypeFilter(objectClass);
-
- String actionFilter = filters[i].getAttribute(ATT_ACTION_FILTER);
- if (actionFilter != null) {
- actionFilter = actionFilter.intern();
- }
- vf[i].setActionFilter(actionFilter);
- }
- return vf;
- }
-
- public boolean getDependentValidatorValue(IConfigurationElement element) {
- IConfigurationElement[] depValidatorElement = element.getChildren(DEP_VALIDATOR);
- if (depValidatorElement.length == 0)
- return false;
- String depValue = depValidatorElement[0].getAttribute(DEP_VAL_VALUE);
- boolean depBoolValue = (new Boolean(depValue)).booleanValue();
- return depBoolValue;
- }
-
- /**
- * Return the name of the marker ID associated with the IValidator.
- */
- public String getMarkerIdValue(IConfigurationElement element) {
- IConfigurationElement[] markerId = element.getChildren(MARKER_ID);
- if (markerId.length == 0)
- return null;
- return markerId[0].getAttribute(MARKER_ID_VALUE);
- }
-
- /**
- * Return the name of the helper class associated with the IValidator.
- */
- private String getHelperName(IConfigurationElement element) {
- IConfigurationElement[] helpers = element.getChildren(TAG_HELPER_CLASS);
- if (helpers.length == 0)
- return null;
-
- return helpers[0].getAttribute(ATT_CLASS);
- }
-
- /* package */static IWorkbenchContext createHelper(IConfigurationElement element, String helperClassName) {
- IWorkbenchContext wh = null;
- try {
- wh = (IWorkbenchContext) element.createExecutableExtension(TAG_HELPER_CLASS);
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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 String[]{helperClassName});
- entry.setText(result);
- //entry.setTokens(new String[]{helperClassName});
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- return wh;
- }
-
- /* package */static IValidator createValidator(IConfigurationElement element, String validatorClassName) {
- IValidator validator = null;
- try {
- validator = (IValidator) element.createExecutableExtension(TAG_RUN_CLASS);
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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 String[]{validatorClassName});
- entry.setText(result);
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
-
- if (validator == null) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.createValidator(IConfigurationElement, String)"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_SYNTAX_NO_VAL_NULL);
- entry.setTokens(new String[]{validatorClassName});
- logger.write(Level.FINE, entry);
- }
- return null;
- }
-
- return validator;
- }
-
- /**
- * Given an IConfigurationElement from plugin.xml, return whether or not the validator is
- * enabled by default.
- *
- * If no enabled attribute is specified, the default, true (i.e., enabled) is returned.
- */
- private boolean getEnabledByDefault(IConfigurationElement element) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_CLASS);
- // Don't need to check if runChildren is null or empty, because that was checked in the
- // initializeValidator method.
-
- String inc = runChildren[0].getAttribute(ATT_ENABLED);
- if (inc == null) {
- return RegistryConstants.ATT_ENABLED_DEFAULT;
- }
-
- return Boolean.valueOf(inc.trim().toLowerCase()).booleanValue(); // this will return true
- // if, and only if, the
- // attribute value is
- // "true". For example,
- // "yes" will be considered
- // "false".
- }
-
- /**
- * Given an IConfigurationElement from plugin.xml, return whether or not the validator supports
- * incremental validation.
- *
- * If no incremental attribute is specified, the default, true (i.e., incremental is supported)
- * is returned.
- */
- private boolean getIncremental(IConfigurationElement element) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_CLASS);
- // Don't need to check if runChildren is null or empty, because that was checked in the
- // initializeValidator method.
-
- String inc = runChildren[0].getAttribute(ATT_INCREMENTAL);
- if (inc == null) {
- return RegistryConstants.ATT_INCREMENTAL_DEFAULT;
- }
-
- return Boolean.valueOf(inc.trim().toLowerCase()).booleanValue(); // this will return true
- // if, and only if, the
- // attribute value is
- // "true". For example,
- // "yes" will be considered
- // "false".
- }
-
- /**
- * Given an IConfigurationElement from plugin.xml, return whether or not the validator supports
- * full build validation.
- *
- * If no incremental attribute is specified, the default, true (i.e., incremental is supported)
- * is returned.
- */
- private boolean getFullBuild(IConfigurationElement element) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_CLASS);
- // Don't need to check if runChildren is null or empty, because that was checked in the
- // initializeValidator method.
-
- String fb = runChildren[0].getAttribute(ATT_FULLBUILD);
- if (fb == null) {
- return RegistryConstants.ATT_FULLBUILD_DEFAULT;
- }
-
- return Boolean.valueOf(fb.trim().toLowerCase()).booleanValue(); // this will return true if,
- // and only if, the
- // attribute value is
- // "true". For example,
- // "yes" will be considered
- // "false".
- }
-
- /**
- * Given an IConfigurationElement from plugin.xml, return whether or not the validator supports
- * asynchronous validation.
- *
- * If no async attribute is specified, the default, true (i.e., the validator is thread-safe) is
- * returned.
- */
- private boolean getAsync(IConfigurationElement element) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_CLASS);
- // Don't need to check if runChildren is null or empty, because that was checked in the
- // initializeValidator method.
-
- String async = runChildren[0].getAttribute(ATT_ASYNC);
- if (async == null) {
- return RegistryConstants.ATT_ASYNC_DEFAULT;
- }
-
- return Boolean.valueOf(async.trim().toLowerCase()).booleanValue(); // this will return true
- // if, and only if, the
- // attribute value is
- // "true". For example,
- // "yes" will be
- // considered "false".
- }
-
- /**
- * Given an IConfigurationElement from plugin.xml, return the types of validation passes, as
- * defined in IRuleGroup, that the validator performs.
- *
- * If no pass attribute is specified, the default, IRuleGroup.PASS_FULL, is returned.
- */
- private int getRuleGroup(IConfigurationElement element) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_CLASS);
- // Don't need to check if runChildren is null or empty, because that was checked in the
- // initializeValidator method.
-
- String pass = runChildren[0].getAttribute(ATT_RULE_GROUP);
- if (pass == null) {
- return RegistryConstants.ATT_RULE_GROUP_DEFAULT;
- }
-
- final String COMMA = ","; //$NON-NLS-1$
- StringTokenizer tokenizer = new StringTokenizer(pass, COMMA, false); // false means don't
- // return the comma as
- // part of the string
- int result = 0; // no passes identified
- while (tokenizer.hasMoreTokens()) {
- String nextAction = tokenizer.nextToken().trim();
- if (nextAction.equals(IRuleGroup.PASS_FAST_NAME)) {
- result = result | IRuleGroup.PASS_FAST;
- } else if (nextAction.equals(IRuleGroup.PASS_FULL_NAME)) {
- result = result | IRuleGroup.PASS_FULL;
- }
- }
-
- if (result == 0) {
- // No recognized passes. Return the default.
- return RegistryConstants.ATT_RULE_GROUP_DEFAULT;
- }
-
- return result;
- }
-
- private ValidatorMetaData.MigrationMetaData getMigrationMetaData(IConfigurationElement element, ValidatorMetaData vmd) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_MIGRATE);
- if ((runChildren == null) || (runChildren.length == 0)) {
- return null;
- }
-
- // Only supposed to be one "migrate" section in a validator, so ignore the rest
- IConfigurationElement migrate = runChildren[0];
-
- // Now look for the "validator" elements. Zero or more can be specified.
- IConfigurationElement[] migrateChildren = migrate.getChildren(TAG_VALIDATOR);
- if ((migrateChildren == null) || (migrateChildren.length == 0)) {
- return null;
- }
-
- ValidatorMetaData.MigrationMetaData mmd = vmd.new MigrationMetaData();
- for (int i = 0; i < migrateChildren.length; i++) {
- IConfigurationElement migrateChild = migrateChildren[i];
- String from = migrateChild.getAttribute(ATT_FROM);
- if (from == null) {
- continue;
- }
-
- String to = migrateChild.getAttribute(ATT_TO);
- if (to == null) {
- continue;
- }
- mmd.addId(from, to);
- }
- return mmd;
- }
-
- /**
- * Given an IConfigurationElement, if it has a project nature(s) specified, return the
- * ValidatorNameFilters which represent those natures. Otherwise return null.
- *
- * A project nature can be specified in plugin.xml to indicate what types of IProjects a
- * validator can run on.
- */
- private ValidatorNameFilter[] getProjectNatureFilters(IConfigurationElement element) {
- IConfigurationElement[] filters = element.getChildren(TAG_PROJECT_NATURE);
- if (filters.length == 0) {
- return null;
- }
-
- ValidatorNameFilter[] vf = new ValidatorNameFilter[filters.length];
- for (int i = 0; i < filters.length; i++) {
- vf[i] = new ValidatorNameFilter();
- // In order to speed up our String comparisons, load these
- // names into Java's constants space. This way, we'll be able to
- // use pointer comparison instead of the traditional
- // character-by-character comparison. Since these names should
- // never be set by anyone other than this class, and this class
- // sets them only once, it is safe to declare these Strings
- // constants.
- //
- // To load a String into the constants space, call intern() on the String.
- //
- String nameFilter = filters[i].getAttribute(ATT_ID);
- if (nameFilter != null) {
- nameFilter = nameFilter.intern();
- }
- vf[i].setNameFilter(nameFilter);
-
- String include = filters[i].getAttribute(ATT_INCLUDE);
- vf[i].setInclude(include);
- }
- return vf;
- }
-
- /**
- * Returns the singleton ValidationRegistryReader.
- */
- public static ValidationRegistryReader getReader() {
- if (inst == null) {
- inst = new ValidationRegistryReader();
-
- EventManager.getManager().setActive(true);
- }
- return inst;
- }
-
- public static boolean isActivated() {
- // Whether the registry has been read or not is kept in the EventManager
- // class instead of this class in order to work around a shutdown problem.
- // See the comment in the isActive() method of the EventManager class
- // for details.
- return EventManager.getManager().isActive();
- }
-
- /**
- * Returns the Validator extension point
- */
- private IExtensionPoint getValidatorExtensionPoint() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint(PLUGIN_ID, VALIDATOR_EXT_PT_ID);
- if (extensionPoint == null) {
- // If this happens it means that someone removed the "validator" extension point
- // declaration
- // from our plugin.xml file.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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 String[]{ValidationPlugin.PLUGIN_ID + "." + VALIDATOR_EXT_PT_ID});
- entry.setText(result);
- logger.write(Level.FINE, entry);
- }
- }
- return extensionPoint;
- }
-
- /**
- * It's okay to return a handle to the ValidatorMetaData because the vmd can't be modified by
- * any code not in this package.
- */
- public ValidatorMetaData getValidatorMetaData(IValidator validator) {
- // retrieval will be in log(n) time
- if (validator == null) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(IValidator)"); //$NON-NLS-1$
- entry.setText(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_ORPHAN_IVALIDATOR, new String[]{"null"})); //$NON-NLS-1$
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
-
- String validatorClassName = validator.getClass().getName();
- ValidatorMetaData vmd = getValidatorMetaData(validatorClassName);
- if (vmd != null) {
- return vmd;
- }
-
- // If we got here, then vmd is neither a root nor an aggregate validator,
- // yet the IValidator exists. Internal error.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(IValidator)"); //$NON-NLS-1$
- entry.setText(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_ORPHAN_IVALIDATOR, new String[]{validatorClassName}));
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
-
- public Set getValidatorMetaData(IWorkspaceRoot root) {
- // Every validator on the Preferences page must be returned
- Set copy = new HashSet();
- clone(_indexedValidators.values(), copy);
- return copy;
- }
-
- /**
- * Return a collection of Validators configured on a certain type of IProject (e.g. EJB Project
- * vs. Web Project).
- *
- * This is a long-running process. If you can, cache the result.
- */
- public Set getValidatorMetaData(IProject project) {
- Set copy = new HashSet();
- getValidatorMetaData(project, copy);
- return copy;
- }
-
- /**
- * Copy the set of configured validator metadata into the Set.
- */
- public void getValidatorMetaData(IProject project, Set vmds) {
- if (vmds == null) {
- return;
- }
- vmds.clear();
- int executionMap = 0x0;
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- try {
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(IProject)"); //$NON-NLS-1$
- entry.setText("IProject is " + String.valueOf(project)); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
-
- if (project == null) {
- executionMap |= 0x1;
- // vmds is already clear
- return;
- }
-
- String[] projectNatures = null;
- try {
- projectNatures = project.getDescription().getNatureIds();
- } catch (CoreException exc) {
- executionMap |= 0x2;
- // vmds is already clear
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- entry.setExecutionMap(executionMap);
- logger.write(Level.SEVERE, entry);
- }
- return;
- }
-
- // If there are no project natures on a particular project,
- // or if this project nature has no validators configured
- // on it, return the validators which are configured on all
- // projects.
- Set projVmds = null;
- if ((projectNatures == null) || (projectNatures.length == 0)) {
- executionMap |= 0x4;
- clone(getValidatorMetaDataUnknownProject(), vmds);
- } else {
- executionMap |= 0x8;
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(IProject)"); //$NON-NLS-1$
- //entry.setTokens(projectNatures);
- entry.setText(projectNatures.toString());
- logger.write(Level.FINEST, entry);
- }
-
- for (int i = 0; i < projectNatures.length; i++) {
- String projectNatureId = projectNatures[i];
- projVmds = (Set) _validators.get(projectNatureId);
-
- if (projVmds == null) {
- // no validators registered for that type of project id
- executionMap |= 0x10;
- continue;
- }
-
- Iterator iterator = projVmds.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- if (!vmds.contains(vmd)) {
- vmds.add(vmd);
- }
- }
- }
-
- // Now filter out the validators which must not run on this project
- removeExcludedProjects(project, vmds);
-
- if (vmds.size() == 0) {
- executionMap |= 0x20;
- clone(getValidatorMetaDataUnknownProject(), vmds);
- }
- }
- } finally {
- if (logger.isLoggingLevel(Level.FINER)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(IProject)"); //$NON-NLS-1$
- entry.setExecutionMap(executionMap);
-
- StringBuffer buffer = new StringBuffer();
- Iterator iterator = vmds.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- buffer.append(vmd.getValidatorUniqueName());
- buffer.append("\n"); //$NON-NLS-1$
- }
- entry.setText(buffer.toString());
- logger.write(Level.FINER, entry);
- }
- }
- }
-
- /*
- * If one project nature on the project includes a particular validator, but another project
- * nature excludes that validator, then the validator needs to be removed from the vmd set.
- *
- * For example, if AValidator can run on any java project but not on a J2EE project, which is an
- * instance of a java project, then the AValidator is included by the java nature and excluded
- * by the J2EE nature. The AValidator would have to be removed from the set.
- */
- private void removeExcludedProjects(IProject project, Set vmds) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.removeExcludedProjects"); //$NON-NLS-1$
-
- StringBuffer buffer = new StringBuffer("\nBefore:\n"); //$NON-NLS-1$
- Iterator viterator = vmds.iterator();
- while (viterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) viterator.next();
- buffer.append(vmd.getValidatorUniqueName());
- buffer.append("\n"); //$NON-NLS-1$
- }
- entry.setText(buffer.toString());
- logger.write(Level.FINEST, entry);
- }
-
- String[] projectNatures = null;
- try {
- projectNatures = project.getDescription().getNatureIds();
- } catch (CoreException exc) {
- // if there's no natures, there's no list.
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.getValidatorMetaData(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return;
- }
- if ((projectNatures == null) || (projectNatures.length == 0)) {
- // nothing needs to be removed from the list
- return;
- }
-
- // First of all, clone the Set because we need to remove entries
- // from it, and we can't alter the set while we're iterating over
- // it.
- List tempList = getTempList();
- clone(vmds, tempList);
-
- for (int i = 0; i < projectNatures.length; i++) {
- String nature = projectNatures[i];
- Iterator iterator = tempList.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- ValidatorNameFilter[] natureFilters = vmd.getProjectNatureFilters();
- if (natureFilters == null) {
- // Can run on any project
- continue;
- }
-
- for (int j = 0; j < natureFilters.length; j++) {
- ValidatorNameFilter pn = natureFilters[j];
- if (nature.equals(pn.getNameFilter()) && !pn.isInclude()) {
- vmds.remove(vmd);
- }
- }
- }
- }
-
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.removeExcludedProjects"); //$NON-NLS-1$
-
- StringBuffer buffer = new StringBuffer("\nAfter:\n"); //$NON-NLS-1$
- Iterator viterator = vmds.iterator();
- while (viterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) viterator.next();
- buffer.append(vmd.getValidatorUniqueName());
- buffer.append("\n"); //$NON-NLS-1$
- }
- entry.setText(buffer.toString());
- logger.write(Level.FINEST, entry);
- }
- }
-
- private Collection clone(Collection input, Collection copy) {
- if (input == null) {
- return null;
- }
-
- if (copy == null) {
- return null;
- }
- copy.clear();
- copy.addAll(input);
- return copy;
- }
-
- public String debug() {
- 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();
- 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();
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(vmd.getValidatorUniqueName());
- buffer.append("\n"); //$NON-NLS-1$
- }
- }
- buffer.append("\n"); //$NON-NLS-1$
-
- 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();
- buffer.append(vmd.getValidatorUniqueName());
- buffer.append(" enabled? "); //$NON-NLS-1$
- buffer.append(vmd.isEnabledByDefault());
- buffer.append("\n"); //$NON-NLS-1$
- }
-
- return buffer.toString();
- }
-
- public boolean isConfiguredOnProject(ValidatorMetaData vmd, IProject project) {
- if (projectValidationMetaData == null)
- projectValidationMetaData = new HashMap();
-
- Object vmds = projectValidationMetaData.get(project);
- if (vmds != null) {
- Set pvmds = (Set) vmds;
- return pvmds.contains(vmd);
- } else {
- Set prjVmds = getValidatorMetaData(project);
- if (prjVmds == null) {
- return false;
- }
-
- if (prjVmds.size() == 0) {
- return false;
- }
- projectValidationMetaData.put(project, prjVmds);
- return prjVmds.contains(vmd);
- }
- }
-
- /**
- * Return a set of ValidatorMetaData which are configured on all projects or which run on any
- * projects except certain project types.
- *
- * Unlike other get methods, because this method is private it doesn't return a clone.
- *
- * @see addExcludedRemainder()
- */
- private Set getValidatorMetaDataUnknownProject() {
- Set projVmds = (Set) _validators.get(UNKNOWN_PROJECT);
- if (projVmds == null) {
- projVmds = Collections.EMPTY_SET;
- }
- return projVmds;
- }
-
- /**
- * Return a set of ValidatorMetaData which are enabled by default.
- */
- public Set getValidatorMetaDataEnabledByDefault() {
- Set copy = new HashSet();
- clone(_defaultEnabledValidators, copy);
- return copy;
- }
-
- public ValidatorMetaData[] getValidatorMetaDataArrayEnabledByDefault() {
- ValidatorMetaData[] result = new ValidatorMetaData[_defaultEnabledValidators.size()];
- _defaultEnabledValidators.toArray(result);
- return result;
- }
-
- /**
- * This method should be called ONLY by the validation framework, UI, or TVT plugin. In general,
- * only the validation framework and the validation TVT should handle ValidatorMetaData objects.
- *
- * Given a string which identifies a fully-qualified class name of a validator, return the
- * ValidatorMetaData that uses a validator of that name, if it exists.
- *
- * It's okay to return a handle to the ValidatorMetaData because the vmd can't be modified by
- * any code not in this package.
- */
- public ValidatorMetaData getValidatorMetaData(String validatorClassName) {
- if (validatorClassName == null) {
- return null;
- }
-
- ValidatorMetaData vmd = (ValidatorMetaData) _indexedValidators.get(validatorClassName);
- if (vmd != null) {
- return vmd;
- }
-
- // Check for an aggregate validator
- Iterator iterator = _indexedValidators.values().iterator();
- while (iterator.hasNext()) {
- vmd = (ValidatorMetaData) iterator.next();
- if (vmd == null) {
- continue;
- }
-
- if (vmd.getValidatorUniqueName().equals(validatorClassName)) {
- return vmd;
- }
-
- String[] aggregateNames = vmd.getAggregatedValidatorNames();
- if (aggregateNames != null) {
- for (int i = 0; i < aggregateNames.length; i++) {
- String aggregateName = aggregateNames[i];
- if (validatorClassName.equals(aggregateName)) {
- return vmd;
- }
- }
- }
-
- // Current name of validator doesn't match; has this validator been
- // migrated from another package?
- ValidatorMetaData.MigrationMetaData mmd = vmd.getMigrationMetaData();
- if (mmd == null) {
- // Validator class name hasn't been migrated
- continue;
- }
-
- Set idList = mmd.getIds();
- if (idList == null) {
- // Invalid <migrate> element.
- continue;
- }
-
- Iterator idIterator = idList.iterator();
- while (idIterator.hasNext()) {
- String[] ids = (String[]) idIterator.next();
- if (ids.length != 2) {
- // log
- continue;
- }
-
- String from = ids[0];
- if (from == null) {
- // log
- continue;
- }
-
- if (from.equals(validatorClassName)) {
- return vmd;
- }
- }
- }
-
- // If we got to this point, no validator using that class name is loaded.
- return null;
- }
-
- /**
- * Return true if the named validator is installed, otherwise false.
- */
- public boolean isExistingValidator(String validatorClassName) {
- return (getValidatorMetaData(validatorClassName) != null);
- }
-
- /**
- * Initialize the validator with the static metadata (runtime metadata is initialized in the
- * ValidationOperation class).
- */
- private ValidatorMetaData initializeValidator(IConfigurationElement element, String validatorName, String pluginId) {
- IConfigurationElement[] runChildren = element.getChildren(TAG_RUN_CLASS);
- if ((runChildren == null) || (runChildren.length < 1)) {
- // How can an IValidatorImpl be created when there no class name to
- // instantiate?
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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 String[]{validatorName});
- entry.setText(result);
-
- logger.write(Level.FINE, entry);
- }
- return null;
- }
-
- //WTP Bugzilla defect: 82338
- //Using the Unique Identifier give the flexibility of the same validator class used by other validator extentions without writing a new validation class
- //Reverting the fix back as the class name defined in the ext is unique to this validator and has to be used for the unique id in the validation metadata
- String validatorImplName = runChildren[0].getAttribute(ATT_CLASS);
-
- if (validatorImplName == null) {
- // Same as before; how can we instantiate when...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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_CLASS);
- entry.setTokens(new String[]{validatorName});
- logger.write(Level.FINE, entry);
- }
- return null;
- }
-
- String helperImplName = getHelperName(element);
- if (helperImplName == null) {
- // Same as before; how can we instantiate when...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- 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[]{validatorImplName});
- logger.write(Level.FINE, entry);
- }
- return null;
- }
-
- // In order to speed up our String comparisons, load these
- // names into Java's constants space. This way, we'll be able to
- // use pointer comparison instead of the traditional
- // character-by-character comparison. Since these names should
- // never be set by anyone other than this class, and this class
- // sets them only once, it is safe to declare these Strings
- // constants.
- //
- // To load a String into the constants space, call intern() on the String.
- //
- ValidatorMetaData vmd = new ValidatorMetaData();
- vmd.addFilters(getFilters(element)); // validator may, or may not, have filters
- vmd.addProjectNatureFilters(getProjectNatureFilters(element)); // validator may, or may not,
- // specify a project nature
- vmd.addAggregatedValidatorNames(getAggregateValidatorsNames(element)); // if a validator
- // aggregated another
- // validator, it
- // should identify
- // the
- // sub-validator(s)'
- // class name
- vmd.setValidatorDisplayName(validatorName.intern()); // validator must have a display name.
- vmd.setValidatorUniqueName(validatorImplName.intern());
- vmd.setPluginId(pluginId);
- vmd.setIncremental(getIncremental(element));
- vmd.setFullBuild(getFullBuild(element));
- vmd.setAsync(getAsync(element));
- vmd.setRuleGroup(getRuleGroup(element));
- vmd.setEnabledByDefault(getEnabledByDefault(element));
- vmd.setMigrationMetaData(getMigrationMetaData(element, vmd));
- vmd.setHelperClass(element, helperImplName);
- vmd.setValidatorClass(element); // associate the above attributes with the validator
- vmd.addDependentValidator(getDependentValidatorValue(element));
- String customMarkerId = getMarkerIdValue(element);
- if(customMarkerId != null)
- vmd.setMarkerId(pluginId+"."+customMarkerId); //$NON-NLS-1$
-
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.initializeValidator(IConfigurationElement, String, String)"); //$NON-NLS-1$
- entry.setText("validator loaded: " + validatorImplName); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
-
- return vmd;
- }
-
- private List getTempList() {
- // Return a list for temporary use
- if (_tempList == null) {
- _tempList = new ArrayList();
- } else {
- // Prepare list for use
- _tempList.clear();
- }
-
- return _tempList;
- }
-
- /**
- * This method should be called ONLY BY THE VALIDATION FRAMEWORK! The value from this method is
- * used to populate the validation preference page.
- */
- public Collection getAllValidators() {
- Set validators = new HashSet();
- clone(_indexedValidators.values(), validators);
- return validators;
- }
-
- public int numberOfValidators() {
- return _indexedValidators.size();
- }
-
- /**
- * Reads one extension by looping through its configuration elements.
- */
- private void readExtension(IExtension extension) {
- IConfigurationElement[] elements = extension.getConfigurationElements();
-
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
-
- String label = extension.getLabel();
- if (label == null || label.equals("")) { //$NON-NLS-1$
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- 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),
- msgParm);
- entry.setText(result);
- logger.write(Level.FINE, entry);
- }
- } else {
- // If getLabel() returns an empty string, this is an illegal validator.
- // The PropertyPage, and other status messages, need to have a displayable name for
- // the validator.
- String pluginId = extension.getNamespace();
- ValidatorMetaData vmd = initializeValidator(element, label, pluginId);
-
- if (vmd != null) {
- // Add this validator to the list of validators; if vmd is null, the validator
- // couldn't be created.
- add(vmd);
- }
- }
- }
- }
-
- /**
- * Reads the registry to find the Validators which have been implemented.
- */
- private void readRegistry() {
- _validators.clear();
-
- // Get the extensions that have been registered.
- IExtensionPoint validatorEP = getValidatorExtensionPoint();
- if (validatorEP == null) {
- return;
- }
- IExtension[] extensions = validatorEP.getExtensions();
-
- // find all runtime implementations
- for (int i = 0; i < extensions.length; i++) {
- readExtension(extensions[i]);
- }
- }
-
- public IValidator getValidator(String validatorClassName) throws InstantiationException {
- ValidatorMetaData vmd = (ValidatorMetaData) _indexedValidators.get(validatorClassName);
- if(vmd != null)
- return vmd.getValidator();
- return null;
- }
-
-} \ No newline at end of file
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
deleted file mode 100644
index 3876c4e1d..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidationSelectionHandlerRegistryReader.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Created on Nov 23, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.wst.validation.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-public class ValidationSelectionHandlerRegistryReader extends RegistryReader {
-
- public static final String VALIDATION_SELECTION_HANDLER = "validationSelectionHandler"; //$NON-NLS-1$
- static final String ATT_ID = "id"; //$NON-NLS-1$
- static final String ATT_HANDLER_CLASS = "handlerClass"; //$NON-NLS-1$
- static final String ATT_SELECTION_TYPE = "selectionType"; //$NON-NLS-1$
- private static ValidationSelectionHandlerRegistryReader INSTANCE = null;
- private List validationSelectionHandlers = null;
-
- /**
- * Default constructor
- */
- public ValidationSelectionHandlerRegistryReader() {
- super(ValidationPlugin.PLUGIN_ID, VALIDATION_SELECTION_HANDLER);
- }
-
- public static ValidationSelectionHandlerRegistryReader getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new ValidationSelectionHandlerRegistryReader();
- INSTANCE.readRegistry();
- }
- return INSTANCE;
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- if (!element.getName().equals(VALIDATION_SELECTION_HANDLER))
- return false;
-
-// String handlerClass = element.getAttribute(ATT_HANDLER_CLASS);
- String selectionType = element.getAttribute(ATT_SELECTION_TYPE);
-
- IValidationSelectionHandler handler = null;
- try {
- handler = (IValidationSelectionHandler) element.createExecutableExtension(ATT_HANDLER_CLASS);
- handler.setValidationTypeString(selectionType);
- getValidationSelectionHandlers().add(handler);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
-
- private List getValidationSelectionHandlers() {
- if (validationSelectionHandlers == null)
- validationSelectionHandlers = new ArrayList();
- return validationSelectionHandlers;
- }
-
- public Object getExtendedType(Object selection) {
- Object result = null;
- for (int i=0; i<getValidationSelectionHandlers().size(); i++ ) {
- IValidationSelectionHandler handler = (IValidationSelectionHandler) getValidationSelectionHandlers().get(i);
- result = handler.getBaseValidationType(selection);
- if (result != null)
- break;
- }
- return result;
- }
-}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorActionFilter.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorActionFilter.java
deleted file mode 100644
index ee241be6d..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorActionFilter.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IResourceDelta;
-
-/**
- * This class stores the value of the "action" attribute in the validator's plugin.xml contribution.
- */
-public class ValidatorActionFilter {
- public static final String ADD = "add"; //$NON-NLS-1$ // if the resource delta is an addition; this value is used in plugin.xml
- public static final String CHANGE = "change"; //$NON-NLS-1$ // if the resource delta is a change; this value is used in plugin.xml
- public static final String DELETE = "delete"; //$NON-NLS-1$ // if the resource delta is a removal; this value is used in plugin.xml
- public static final int ALL_ACTIONS = (IResourceDelta.ADDED | IResourceDelta.CHANGED | IResourceDelta.REMOVED);
-
- private int _actionType = 0; // Default to 0, so that if an invalid filter is specified, then no
-
- // matter what the IResourceDelta is, the delta & _actionType will
- // always == 0. (i.e., the resource will never be filtered in)
-
- public ValidatorActionFilter() {
- super();
- }
-
- /**
- * Return the hexadecimal number which represents the type(s) of actions which this filter
- * allows in.
- */
- public int getActionType() {
- // Since IResourceDelta's constants are hexadecimal numbers,
- // it's nicer to return a corresponding hexadecimal, for bitwise OR,
- // than it is to have three boolean methods on this class, i.e.,
- // isAdd, isChange, isDelete.
- return _actionType;
- }
-
- /**
- * <p>
- * Parse the incoming string, which is extracted from the plugin.xml file, to determine the
- * value of the actionType.
- * <p>
- * The string can contain one, two, or three constants. If there is more than one constant, the
- * constants should be separated by a comma.
- * <p>
- * These are the three constants: add, change, delete. The order that the constants are
- * specified in does not matter. The constants are case-sensitive; i.e., ADD is not considered
- * the same as add.
- * <p>
- * If the action attribute is not defined, the default behaviour is to filter in all types of
- * actions: add, change, delete. (i.e., the same behaviour can be achieved by specifying "add,
- * change, delete" as the action attribute's value.
- * <p>
- * If the action attribute is defined, and none of the constants are defined, then the filter is
- * invalid, and will be ignored by the Validation Framework. (If none of the actions should be
- * filtered in, then the filter itself should not exist.)
- * <p>
- * If the action attribute is defined, and one of the constants is defined, then the form of the
- * action should be like this: <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="add"/>
- * <p>
- * If the action attribute is defined, and more than one constant is defined, then the form of
- * the action should be like this: <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="add, delete"/>
- * <p>
- * If the action attribute is defined, and an unknown constant is defined, then the unknown
- * constant will be ignored. For example, <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="ADD, delete"/> <br>
- * is the same as specifying <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="delete"/> <br>
- * and if all of the constants are unknown, the filter is invalid, and will be ignored by the
- * Validation Framework. e.g., <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="ADD, DELETE"/> <br>
- * is the same as not specifying a filter.
- * <p>
- * If the action attribute is defined, and a constant is defined more than once, the extra
- * constant is ignored. For example, <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="add, change, add"/> <br>
- * is the same as specifying <br>
- * &nbsp;&nbsp;&nbsp;&lt;filter ... action="add, change"/>
- */
- public void setActionTypes(String actions) {
- if (actions == null) {
- // user has not defined the "action" element, so default to everything
- _actionType = ALL_ACTIONS;
- return;
- }
-
- final String COMMA = ","; //$NON-NLS-1$
- StringTokenizer tokenizer = new StringTokenizer(actions, COMMA, false); // false means don't
- // return the comma
- // as part of the
- // string
- int isAdd = 0;
- int isChange = 0;
- int isDelete = 0;
- while (tokenizer.hasMoreTokens()) {
- String nextAction = tokenizer.nextToken().trim();
- if (nextAction.equals(ADD)) {
- isAdd = IResourceDelta.ADDED;
- } else if (nextAction.equals(CHANGE)) {
- isChange = IResourceDelta.CHANGED;
- } else if (nextAction.equals(DELETE)) {
- isDelete = IResourceDelta.REMOVED;
- }
- }
- _actionType = isAdd | isChange | isDelete;
- }
-
- public String toString() {
- final String ON = "on"; //$NON-NLS-1$
- final String OFF = "off"; //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer();
- buffer.append(" ActionFilter:"); //$NON-NLS-1$
- buffer.append(" add: " + (((getActionType() & IResourceDelta.ADDED) != 0) ? ON : OFF)); //$NON-NLS-1$
- buffer.append(" change: " + (((getActionType() & IResourceDelta.CHANGED) != 0) ? ON : OFF)); //$NON-NLS-1$
- buffer.append(" delete: " + (((getActionType() & IResourceDelta.REMOVED) != 0) ? ON : OFF)); //$NON-NLS-1$
- return buffer.toString();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorFilter.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorFilter.java
deleted file mode 100644
index 8035a0cbb..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorFilter.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import org.eclipse.core.resources.IResource;
-
-
-
-/**
- * This class represents the plugin.xml tags, for a validator, for both name filters and type
- * filters. i.e., if an object has name filter and type filter specified, the filter filters out
- * objects which are not both of that type and named like the filter.
- */
-public class ValidatorFilter {
- private ValidatorNameFilter _nameFilter = null;
- private ValidatorTypeFilter _typeFilter = null;
- private ValidatorActionFilter _actionFilter = null;
-
- /* package */ValidatorFilter() {
- super();
- _nameFilter = new ValidatorNameFilter();
- _typeFilter = new ValidatorTypeFilter();
- _actionFilter = new ValidatorActionFilter();
- }
-
- /* package */ValidatorFilter(String mustImplementClass) {
- this();
- _nameFilter = new ValidatorNameFilter();
- _typeFilter.setMustImplementClass(mustImplementClass);
- _actionFilter = new ValidatorActionFilter();
- }
-
- public boolean isApplicableAction(int resourceDelta) {
- return ((resourceDelta & _actionFilter.getActionType()) != 0);
- }
-
- /**
- * Returns true if the given resource's name matches the name filter.
- *
- * e.g. if the name filter is "*.java", and this resource is "readme.txt", this method will
- * return false. If the resource is named "readme.java", this method will return true.
- */
- /* package */boolean isApplicableName(IResource resource) {
- return _nameFilter.isApplicableName(resource);
- }
-
- /**
- * Returns true if the given resource's type matches the type filter.
- *
- * e.g. if the type filter is "IFile", and this resource is "IProject", this method will return
- * false. If the resource is an IFile, this method will return true.
- */
- /* package */boolean isApplicableType(IResource resource) {
- return _typeFilter.isApplicableType(resource);
- }
-
- public void setActionFilter(String actions) {
- _actionFilter.setActionTypes(actions);
- }
-
- /**
- * Sets the name filter.
- */
- /* package */void setNameFilter(String filter, String isCaseSensitiveString) {
- _nameFilter.setNameFilter(filter);
- if(filter != null)
- _nameFilter.setNameFilterExtension(getFilterExt(filter));
- _nameFilter.setCaseSensitive(isCaseSensitiveString);
- }
-
- private String getFilterExt(String filter) {
- return filter.substring(filter.indexOf(".") + 1);
- }
-
-
- /**
- * Sets the type filter.
- */
- /* package */void setTypeFilter(String filter) {
- _typeFilter.setTypeFilter(filter);
- }
-
- public String toString() {
- final String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer();
- buffer.append("ValidatorFilter:"); //$NON-NLS-1$
- buffer.append(lineSep);
- buffer.append(" nameFilter = " + _nameFilter); //$NON-NLS-1$
- buffer.append(lineSep);
- buffer.append(" typeFilter = " + _typeFilter); //$NON-NLS-1$
- buffer.append(lineSep);
- buffer.append(" actionFilter = " + _actionFilter); //$NON-NLS-1$
- buffer.append(lineSep);
- return buffer.toString();
- }
-
- /**
- * @return Returns the _nameFilter.
- */
- public ValidatorNameFilter get_nameFilter() {
- return _nameFilter;
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 9c231ae8e..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorMetaData.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
-import org.eclipse.wst.validation.internal.plugin.ValidationHelperRegistryReader;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.osgi.framework.Bundle;
-
-/**
- * This class stores information, as specified by a validator's plugin.xml tags. There is one
- * ValidatorMetaData for each Validator. No Validator should attempt to access its
- * ValidatorMetaData; it is for use by the base framework only.
- */
-public class ValidatorMetaData {
- private ValidatorFilter[] _filters = null;
- private ValidatorNameFilter[] _projectNatureFilters = null;
- private IValidator _validator = null;
- private IWorkbenchContext _helper = null;
- private String _validatorDisplayName = null;
- private String _validatorUniqueName = null;
- private String[] _aggregatedValidators = null;
- private String[] _validatorNames = null;
- private String _pluginId = null;
- private boolean _supportsIncremental = RegistryConstants.ATT_INCREMENTAL_DEFAULT;
- private boolean _supportsFullBuild = RegistryConstants.ATT_FULLBUILD_DEFAULT;
- private Logger _logger = null;
- private boolean _isEnabledByDefault = RegistryConstants.ATT_ENABLED_DEFAULT;
- private MigrationMetaData _migrationMetaData = null;
- 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 markerId = null;
- private String _helperClassName = null;
- private IConfigurationElement _helperClassElement = null;
- private IConfigurationElement _validatorClassElement = null;
- private boolean _cannotLoad = false;
-
- /* package */ValidatorMetaData() {
- //default
- }
-
- /**
- * Add to the list of class names of every validator which this validator aggregates. For
- * example, if the EJB Validator instantiated another validator, and started its validate
- * method, then that instantiated class' name should be in this list.
- */
- /* package */void addAggregatedValidatorNames(String[] val) {
- _aggregatedValidators = val;
- }
-
- /**
- * Add the name/type filter pair(s).
- */
- /* package */void addFilters(ValidatorFilter[] filters) {
- _filters = filters;
- }
-
- /**
- * Add the project nature filter(s).
- */
- /* package */void addProjectNatureFilters(ValidatorNameFilter[] filters) {
- _projectNatureFilters = filters;
- }
-
- public List getNameFilters() {
- List nameFilters = new ArrayList();
- if (_filters != null && _filters.length > 0) {
- for (int i = 0; i < _filters.length; i++) {
- ValidatorFilter filter = _filters[i];
- ValidatorNameFilter nameFilter = filter.get_nameFilter();
- if (nameFilter != null) {
- nameFilters.add(nameFilter.getNameFilter());
- }
-
- }
- }
- return nameFilters;
- }
-
- /**
- * Return the list of class names of the primary validator and its aggregates.
- */
- public String[] getValidatorNames() {
- if (_validatorNames == null) {
- int aLength = (_aggregatedValidators == null) ? 0 : _aggregatedValidators.length;
- _validatorNames = new String[aLength + 1]; // add 1 for the primary validator name
- _validatorNames[0] = getValidatorUniqueName();
- if (_aggregatedValidators != null) {
- System.arraycopy(_aggregatedValidators, 0, _validatorNames, 1, aLength);
- }
- }
- return _validatorNames;
- }
-
- /**
- * Return the list of class names of every validator which this validator aggregates. For
- * example, if the EJB Validator instantiated another validator, and started its validate
- * method, then that instantiated class' name should be in this list.
- */
- public String[] getAggregatedValidatorNames() {
- return _aggregatedValidators;
- }
-
- /**
- * Return the name/type filter pairs.
- */
- public ValidatorFilter[] getFilters() {
- return _filters;
- }
-
- /**
- * Return true if this vmd's helper and validator have been instantiated, and also if this
- * validator's plugin is active.
- */
- public boolean isActive() {
- if (_helperClassElement != null) {
- return false;
- }
-
- if (_validatorClassElement != null) {
- return false;
- }
-
- Bundle bundle = Platform.getBundle(_pluginId);
- if (bundle != null)
- return bundle.getState() == Bundle.ACTIVE;
-
- return false;
- }
-
- /**
- * This method will throw an InstantiationException if the helper cannot be instantiated, e.g.,
- * if the helper's plugin is disabled for some reason. Before the InstantiationException is
- * thrown, this validator will be disabled.
- *
- * The IWorkbenchContext must ALWAYS have its project set before it is used; but it can't be
- * created with the IProject. So, before using the single instance, always initialize that
- * instance with the IProject.
- *
- * If this validator supports asynchronous validation, then instead of maintaining a single the
- * helper instance, create a new IWorkbenchContext instance every time that the helper is needed.
- * This feature is provided because several validation Runnables may be queued to run, and if
- * those Runnables's project is different from the current validation's project, then the
- * current validation will suddenly start validating another project.
- */
- //TODO just want to remember to figure out the many-temporary-objects problem if this method
- // continues to new an IValidationContext every time - Ruth
- public IWorkbenchContext getHelper(IProject project) throws InstantiationException {
- if (isAsync()) {
- IWorkbenchContext helper = ValidationRegistryReader.createHelper(_helperClassElement, _helperClassName);
- if (helper == null) {
- helper = new WorkbenchContext();
- //setCannotLoad();
- //throw new InstantiationException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_DISABLEH, new String[]{_helperClassName, getValidatorUniqueName()}));
- }
- helper.setProject(project);
- return helper;
- }
- if (_helper == null) {
- _helper = ValidationRegistryReader.createHelper(_helperClassElement, _helperClassName);
- if (_helper == null) {
- _helper = new WorkbenchContext();
- //setCannotLoad();
- //throw new InstantiationException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_DISABLEH, new String[]{_helperClassName, getValidatorUniqueName()}));
- }
- // Won't be using the element & name again, so clear them.
- _helperClassElement = null;
- _helperClassName = null;
- }
- if ((_helper.getProject() == null) || !(_helper.getProject().equals(project))) {
- // Initialize helper with the new project
- _helper.setProject(project);
- }
- return _helper;
- }
-
- /**
- * cannotLoad is false if both the IValidator and IWorkbenchContext instance can be instantiated.
- * This method should be called only by the validation framework, and only if an
- * InstantiationException was thrown.
- *
- * @param can
- */
- private void setCannotLoad() {
- _cannotLoad = true;
- }
-
- /**
- * Return false if both the IValidator and IWorkbenchContext instance can be instantiated.
- *
- * @return boolean
- */
- public boolean cannotLoad() {
- return _cannotLoad;
- }
-
- /**
- * This method must not be called until the unique id of the validator has been initialized.
- */
- public Logger getMsgLogger() {
- if (_logger == null) {
- _logger = ValidationPlugin.getPlugin().getMsgLogger();
- /*
- * // Decided against having a logger for each validator because each validator // would
- * need to contribute an extension in their plugins for it to be recognized // by the
- * logging preference page. For now, just use the validation framework's logger. _logger =
- * (MsgLogger)MsgLogger.getFactory().getLogger(getValidatorUniqueName());
- * _logger.write(Level.CONFIG, getValidatorDisplayName());
- */
- }
- return _logger;
- }
-
- public MigrationMetaData getMigrationMetaData() {
- return _migrationMetaData;
- }
-
- /**
- * Return the IRuleGroup integer indicating which groups of rules this validator recognizes.
- */
- public int getRuleGroup() {
- return _ruleGroup;
- }
-
- /**
- * Return the filters which identify which project(s) this validator may run on.
- */
- /* package */ValidatorNameFilter[] getProjectNatureFilters() {
- return _projectNatureFilters;
- }
-
- /**
- * This method returns the validator if it can be loaded; if the validator cannot be loaded,
- * e.g., if its plugin is disabled for some reason, then this method throws an
- * InstantiationException. Before the CoreException is thrown, this validator is disabled.
- *
- * @return IValidator
- * @throws InstantiationException
- */
- public IValidator getValidator() throws InstantiationException {
- if (_validator == null) {
- _validator = ValidationRegistryReader.createValidator(_validatorClassElement, getValidatorUniqueName());
-
- // Since the element won't be used any more, clear it.
- _validatorClassElement = null;
-
- if (_validator == null) {
- setCannotLoad();
- throw new InstantiationException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_DISABLEV, new String[]{getValidatorUniqueName()}));
- }
- }
- return _validator;
- }
-
- public String getValidatorDisplayName() {
- return _validatorDisplayName;
- }
-
- public String getValidatorUniqueName() {
- return _validatorUniqueName;
- }
-
- /**
- * If the resource is applicable to the Validator which this ValidatorMetaData is associated
- * with, return true; else return false.
- *
- * A resource is applicable if it passes the name/type filters. This method is called if there
- * is no resource delta (i.e., a full validation).
- */
- public boolean isApplicableTo(IResource resource) {
- return isApplicableTo(resource, ValidatorActionFilter.ALL_ACTIONS);
- }
-
- /**
- * If the resource is applicable to the Validator which this ValidatorMetaData is associated
- * with, return true; else return false.
- *
- * A resource is applicable if it passes the name/type filters.
- */
- public boolean isApplicableTo(IResource resource, int resourceDelta) {
- // If no filters are specified, then every type of resource should be validated/trigger a
- // rebuild of the model cache
- if (_filters == null)
- return true;
-
- return isApplicableTo(resource, resourceDelta, _filters);
- }
-
- /**
- * Return true if the resource passes the name/type filters for this validator.
- */
- /* package */boolean isApplicableTo(IResource resource, int resourceDelta, ValidatorFilter[] filters) {
- // Are any of the filters satisfied? (i.e., OR them, not AND them.)
- for (int i = 0; i < filters.length; i++) {
- ValidatorFilter filter = filters[i];
- if (checkIfValidSourceFile(resource) && filter.isApplicableType(resource) && filter.isApplicableName(resource) && filter.isApplicableAction(resourceDelta)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean checkIfValidSourceFile(IResource file) {
- if (file.getType() == IResource.FILE) {
- IProjectValidationHelper helper = ValidationHelperRegistryReader.getInstance().getValidationHelper();
- IProject project = file.getProject();
- if (helper == null || project == null)
- return true;
- IContainer[] outputContainers = helper.getOutputContainers(project);
- IContainer[] sourceContainers = helper.getSourceContainers(project);
- for (int i=0; i<outputContainers.length; i++) {
- String outputPath = outputContainers[i].getProjectRelativePath().makeAbsolute().toString();
- for (int j=0; j<sourceContainers.length; j++) {
- String sourceContainerPath = sourceContainers[j].getProjectRelativePath().makeAbsolute().toString();
- if (outputPath.equals(sourceContainerPath))
- continue;
- }
- String filePath = file.getProjectRelativePath().makeAbsolute().toString();
- if (filePath.startsWith(outputPath))
- return false;
- }
- }
- return true;
- }
-
- /**
- * If this validator recognizes the project nature, whether included or excluded, return the
- * name filter which describes the nature. Otherwise return null.
- */
- ValidatorNameFilter findProjectNature(String projId) {
- if (projId == null) {
- return null;
- }
-
- if (_projectNatureFilters == null) {
- // If no tag is specified, this validator is configured on all IProjects
- return null;
- }
-
- for (int i = 0; i < _projectNatureFilters.length; i++) {
- ValidatorNameFilter filter = _projectNatureFilters[i];
- // In this case, we're not checking if the project is an instance of the filter class,
- // but if it has the Nature specified in the filter class.
- String projectNatureID = filter.getNameFilter();
- if (projId.equals(projectNatureID)) {
- return filter;
- }
- }
- return null;
- }
-
- /**
- * Convenience method. Rather than store the is-this-vmd-configured-on-this-IProject algorithm
- * in two places, refer back to the reader's cache.
- */
- public boolean isConfiguredOnProject(IProject project) {
- return ValidationRegistryReader.getReader().isConfiguredOnProject(this, project);
- }
-
- public boolean isEnabledByDefault() {
- return _isEnabledByDefault;
- }
-
- public boolean isIncremental() {
- return _supportsIncremental;
- }
-
- public boolean isFullBuild() {
- return _supportsFullBuild;
- }
-
- /**
- * Return true if the validator is thread-safe and can be run asynchronously.
- */
- public boolean isAsync() {
- return _async;
- }
-
- /* package */void setHelperClass(IConfigurationElement element, String helperClassName) {
- _helperClassElement = element;
- _helperClassName = helperClassName;
- }
-
- /* package */void setEnabledByDefault(boolean enabledByDefault) {
- _isEnabledByDefault = enabledByDefault;
- }
-
- /* package */void setIncremental(boolean isIncremental) {
- _supportsIncremental = isIncremental;
- }
-
- /* package */void setFullBuild(boolean fullBuild) {
- _supportsFullBuild = fullBuild;
- }
-
- /* package */void setAsync(boolean isAsync) {
- _async = isAsync;
- }
-
- /* package */void setMigrationMetaData(MigrationMetaData mmd) {
- _migrationMetaData = mmd;
- }
-
- /* package */void setRuleGroup(int ruleGroup) {
- _ruleGroup = ruleGroup;
- }
-
- /* package */void setValidatorClass(IConfigurationElement element) {
- _validatorClassElement = element;
- // validator class name == validatorUniqueName
- }
-
- /* package */void setValidatorDisplayName(String validatorName) {
- _validatorDisplayName = validatorName;
- }
-
- /* package */void setValidatorUniqueName(String validatorUniqueName) {
- _validatorUniqueName = validatorUniqueName;
- }
-
- /* package */void setPluginId(String validatorPluginId) {
- _pluginId = validatorPluginId;
- }
-
- public String toString() {
- return getValidatorUniqueName();
- }
-
- public class MigrationMetaData {
- private Set _ids = null;
-
- public MigrationMetaData() {
- //default
- }
-
- public void addId(String oldId, String newId) {
- if (oldId == null) {
- // log
- return;
- }
-
- if (newId == null) {
- // log
- return;
- }
-
- String[] ids = new String[]{oldId, newId};
- getIds().add(ids);
- }
-
- public Set getIds() {
- if (_ids == null) {
- _ids = new HashSet();
- }
- return _ids;
- }
- }
-
- /**
- * @param b
- */
- public void addDependentValidator(boolean b) {
- dependentValidator = b;
- }
-
- /**
- * @param b
- */
- public boolean isDependentValidator() {
- return dependentValidator;
- }
-
- /**
- * @return Returns the markerId.
- */
- public String getMarkerId() {
- return markerId;
- }
-
- /**
- * @param markerId
- * The markerId to set.
- */
- public void setMarkerId(String markerId) {
- this.markerId = markerId;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorNameFilter.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorNameFilter.java
deleted file mode 100644
index 75d857aeb..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorNameFilter.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * Represents a name filter tag in a validator's plugin.xml file. e.g. &lt;filter name="*.*"> Then
- * this class would store the "*.*", and provide the wildcard matching functionality.
- */
-public class ValidatorNameFilter {
- private String _nameFilter = null;
- private String nameFilterExtension = null;
- private boolean _include = true; // by default, filter in the IFile specified
- private final static String WILDCARD = "*"; //$NON-NLS-1$
- private boolean _isCaseSensitive = true; // by default, the filter name is case-sensitive
-
- /**
- * Insert the method's description here. Creation date: (12/4/00 11:08:41 AM)
- */
- /* package */ValidatorNameFilter() {
- //default
- }
-
- /**
- * Get the filter, as specified in plugin.xml
- */
- /* package */String getNameFilter() {
- return _nameFilter;
- }
-
- /* package */boolean isCaseSensitive() {
- return _isCaseSensitive;
- }
-
- /* package */boolean isInclude() {
- return _include;
- }
-
- /**
- * Return true if the given resource is both applicable and include="true".
- */
- /* package */boolean isApplicableTo(IResource resource) {
- return (isApplicableName(resource) && isInclude());
- }
-
- protected void setNameFilterExtension(String filterExt) {
- nameFilterExtension = filterExt;
- }
-
- /**
- * Returns true if the name of the resource matches the filter, or if there is no filter
- * specified.
- */
- public boolean isApplicableName(IResource resource) {
- // If name filter is null, means filter out no names.
- // Otherwise, return true only if the given name matches
- // the name filter.
- if (_nameFilter == null)
- return true;
-
- String name = resource.getName();
-// return true if the file name is exact match of the _nameFilter
- if (name.equalsIgnoreCase(_nameFilter))
- return true;
-
- int indexOfStarDot = _nameFilter.indexOf("*.");
-
- //return value if the fileter name extension matches the extension
- //of the resource
- if (indexOfStarDot != -1) {
- String nameExtension = name.substring(name.indexOf(".") + 1);
- return nameFilterExtension.equalsIgnoreCase(nameExtension);
- }
-
- if (!isCaseSensitive()) {
- name = name.toLowerCase();
- }
-
- return verifyNameMatch(_nameFilter, name);
- }
-
- /* package */void setInclude(String includeValue) {
- if (includeValue != null) {
- setInclude(Boolean.valueOf(includeValue).booleanValue());
- }
- }
-
- void setInclude(boolean includeBool) {
- _include = includeBool;
- }
-
- /**
- * Set the filter, as specified in plugin.xml
- */
- /* package */void setNameFilter(String filter) {
- _nameFilter = filter;
- }
-
- /* package */void setCaseSensitive(String isCaseSensitiveString) {
- if (isCaseSensitiveString != null) {
- // only change the value from the default if the case-sensitive attribute is defined
- _isCaseSensitive = Boolean.valueOf(isCaseSensitiveString).booleanValue();
- }
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("NameFilter:\n\tnameFilter = "); //$NON-NLS-1$
- buffer.append(_nameFilter);
- return buffer.toString();
- }
-
- /**
- * Return true if the given name matches the given filter.
- *
- * The only filter wildcard allowed is '*'.
- */
- /* package */static boolean verifyNameMatch(final String filter, String name) {
- /*
- * There are eight possible wildcard combinations, given that a wildcard may, if present, be
- * at the beginning, middle, or end of a name; or any combination of those positions. i.e.,
- *
- * beginning middle end 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1
- *
- */
- StringTokenizer tokenizer = new StringTokenizer(filter, WILDCARD, true);
- boolean wildcardFlag = false;
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (token.equals(WILDCARD)) {
- wildcardFlag = true;
- } else {
- if (wildcardFlag) {
- int tokenIndex = name.indexOf(token);
- if (tokenIndex >= 0) {
- name = name.substring(tokenIndex + token.length());
- } else {
- return false;
- }
- } else {
- if (name.startsWith(token)) {
- int tokenIndex = token.length();
- name = name.substring(tokenIndex);
- } else {
- return false;
- }
- }
- wildcardFlag = false;
- }
- }
- if (!name.equals("")) { //$NON-NLS-1$
- if (!wildcardFlag) {
- return false;
- }
- }
- return true;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorTypeFilter.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorTypeFilter.java
deleted file mode 100644
index 0f00ce3ee..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/ValidatorTypeFilter.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal;
-
-import java.text.MessageFormat;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * Represents a type filter tag in a validator's plugin.xml file. e.g. &lt;filter
- * objectClass="com.ibm.foo.MyClass"> Then this class would store the "com.ibm.foo.MyClass", and
- * provide the "instanceof" matching functionality.
- */
-public class ValidatorTypeFilter {
- private Class _typeFilterClass = null;
- private String _mustImplementClass = null; // the type set in setTypeFilter must implement the
-
- // class/interface identified by this fully-qualified
- // Java string.
-
- /* package */ValidatorTypeFilter() {
- //default
- }
-
- /* package */ValidatorTypeFilter(String mustImplementClass) {
- setMustImplementClass(mustImplementClass);
- }
-
- /**
- * Type filters are allowed only for certain types of classes. This method returns the name of
- * the class which this type must implement before it can be a filter.
- */
- /* package */String getMustImplementClass() {
- return _mustImplementClass;
- }
-
- /**
- * Return the type filter as a java.lang.Class object.
- */
- /* package */Class getTypeFilterClass() {
- return _typeFilterClass;
- }
-
- /**
- * Returns true if the resource passed in either an instance of the type filter class, or if
- * there is no type filter class defined in plugin.xml.
- */
- public boolean isApplicableType(IResource resource) {
- // If type filter is null, means filter out no types.
- // Otherwise, return true only if the given type is an instance of
- // the type filter.
- if (_typeFilterClass == null)
- return true;
-
- // If the resource is an instance of the type filter class.
- return isInstance(resource.getClass(), _typeFilterClass);
- }
-
- /**
- * Checks if filterClass is a parent (interface or superclass) of objectClass.
- */
- /* package */boolean isInstance(Class objectClass, Class filterClass) {
- // The java.lang.Class.isInstance call doesn't check interfaces fully.
- // i.e., if I have two interfaces, A and B, and B extends A but
- // doesn't implement A, then the isInstance call will return false.
- //
- // So, instead of using Class.isInstance, do the checking myself.
- for (Class cl = objectClass; cl != null; cl = cl.getSuperclass()) {
- if (cl.getName().equals(filterClass.getName())) {
- return true;
- }
- Class[] clInterfaces = cl.getInterfaces();
- for (int i = 0; i < clInterfaces.length; i++) {
- if (clInterfaces[i].getName().equals(filterClass.getName())) {
- return true;
- }
- return isInstance(clInterfaces[i], filterClass);
- }
- }
- return false;
- }
-
- /**
- * Type filters are allowed only for certain types of classes. This method sets the name of the
- * class which this type must implement before it can be a filter.
- */
- /* package */void setMustImplementClass(String className) {
- _mustImplementClass = className;
- }
-
- /**
- * If the filter implements the mustImplementClass (in ValidatorFilter's case, IResource), then
- * this is a valid filter, and store the filter value.
- */
- /* package */void setTypeFilter(String filter) {
- Class filterClass = null;
- Class mustImplementClass = null;
-
- if (filter == null) {
- _typeFilterClass = null;
- return;
- }
-
- try {
- filterClass = Class.forName(filter);
- if (getMustImplementClass() != null) {
- mustImplementClass = Class.forName(getMustImplementClass());
-
- // If the filter class is not an instance of mustImplementClass
- if (!isInstance(filterClass, mustImplementClass)) {
- _typeFilterClass = null;
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorTypeFilter.setTypeFilter(String)"); //$NON-NLS-1$
- entry.setMessageTypeID(ResourceConstants.VBF_EXC_INVALID_TYPE_FILTER);
- String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_INVALID_TYPE_FILTER), new String[]{filter, getMustImplementClass()});
- entry.setText(result);
- //entry.setTokens(new String[]{filter, getMustImplementClass()});
- logger.write(Level.FINE, entry);
- }
- }
- }
- } catch (ClassNotFoundException exc) {
- _typeFilterClass = null;
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorTypeFilter.setTypeFilter(String)"); //$NON-NLS-1$
- entry.setText("The class named " + filter + " cannot be instantiated because it does not exist. Check the spelling of the name, in the validator's plugin.xml contribution, and try restarting eclipse again."); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINE, entry);
- }
- return;
- }
- _typeFilterClass = filterClass;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("TypeFilter:"); //$NON-NLS-1$
- buffer.append(" _typeFilterClass = " + _typeFilterClass.getName()); //$NON-NLS-1$
- buffer.append(" _mustImplementClass = " + _mustImplementClass); //$NON-NLS-1$
- return buffer.toString();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/AllValidatorsOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/AllValidatorsOperation.java
deleted file mode 100644
index f32ae59b6..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/AllValidatorsOperation.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.InternalValidatorManager;
-import org.eclipse.wst.validation.internal.ProjectConfiguration;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * Implemented Validators must not be called directly by anyone other than instances of
- * ValidationOperation, because some initialization of the validator, and handling of error
- * conditions, is done in the operation. The initialization is separated because some of the
- * information needed to initialize the validator (i.e., the project) isn't known until runtime.
- *
- * This operation runs all validators: enabled validators, disabled validators, incremental
- * validators, full validators.
- *
- * This operation is not intended to be subclassed outside of the validation framework.
- */
-public class AllValidatorsOperation extends ValidatorSubsetOperation {
- /**
- * @deprecated Will be removed in Milestone 3. Use AllValidatorsOperation(IProject, boolean)
- */
- public AllValidatorsOperation(IProject project) {
- this(project, DEFAULT_ASYNC);
- }
-
- /**
- * Run all configured validators on the project, regardless of whether the validator is enabled
- * or disabled by the user.
- *
- * If async is true, the validation will run all thread-safe validators in a background thread.
- * If async is false, no validators will run in a background thread.
- */
- public AllValidatorsOperation(IProject project, boolean async) {
- super(project, true, async);// always force validation to run
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- setEnabledValidators(InternalValidatorManager.wrapInSet(prjp.getValidators()));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EventManager::closing(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
- }
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/DefaultResourceUtil.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/DefaultResourceUtil.java
deleted file mode 100644
index 39231d422..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/DefaultResourceUtil.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-/**
- * The default line number calculator (always returns "0").
- */
-public class DefaultResourceUtil implements IResourceUtil {
-
- /**
- * @see org.eclipse.wst.validation.internal.operations.IResourceUtil#getLineNo(Object)
- */
- public int getLineNo(Object obj) {
- return 0;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledIncrementalValidatorsOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledIncrementalValidatorsOperation.java
deleted file mode 100644
index 7fcd3f428..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledIncrementalValidatorsOperation.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.FilterUtil;
-import org.eclipse.wst.validation.internal.InternalValidatorManager;
-import org.eclipse.wst.validation.internal.ProjectConfiguration;
-import org.eclipse.wst.validation.internal.RegistryConstants;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * Implemented Validators must not be called directly by anyone other than instances of
- * ValidationOperation, because some initialization of the validator, and handling of error
- * conditions, is done in the operation. The initialization is separated because some of the
- * information needed to initialize the validator (i.e., the project) isn't known until runtime.
- *
- * Instances of this operation load the project's configured validators, and run the validators if
- * they are both enabled and incremental.
- *
- * This operation is not intended to be subclassed outside of the validation framework.
- */
-public class EnabledIncrementalValidatorsOperation extends EnabledValidatorsOperation {
- /**
- * @deprecated Will be removed in Milestone 3. Use
- * EnabledIncrementalValidatorsOperation(IProject, IResourceDelta, boolean)
- */
- public EnabledIncrementalValidatorsOperation(IProject project, IResourceDelta delta) {
- this(project, delta, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use
- * EnabledIncrementalValidatorsOperation(IProject, IResourceDelta, int, boolean)
- */
- public EnabledIncrementalValidatorsOperation(IProject project, IResourceDelta delta, int ruleGroup) {
- this(project, delta, ruleGroup, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use
- * EnabledIncrementalValidatorsOperation(IProject, IResourceDelta, int, boolean)
- * instead.
- */
- public EnabledIncrementalValidatorsOperation(IProject project, Set validators, IResourceDelta delta, int ruleGroup) {
- this(project, delta, ruleGroup, DEFAULT_ASYNC);
- setEnabledValidators(validators);
- }
-
- /**
- * IProject must exist and be open.
- *
- * If delta is null, a full validation of the project using only the incremental validators is
- * performed. If delta is not null, all enabled incremental validators that validate resources
- * in the delta will validate those resources.
- *
- * If async is true, all thread-safe validators will run in the background validation thread,
- * and all other validators will run in the main thread. If async is false, all validators will
- * run in the main thread.
- */
- public EnabledIncrementalValidatorsOperation(IProject project, IResourceDelta delta, boolean async) {
- this(project, delta, RegistryConstants.ATT_RULE_GROUP_DEFAULT, async);
- }
-
- /**
- * IProject must exist and be open.
- *
- * If delta is null, a full validation of the project using only the incremental validators is
- * performed. If delta is not null, all enabled incremental validators that validate resources
- * in the delta will validate those resources.
- *
- * If async is true, all thread-safe validators will run in the background validation thread,
- * and all other validators will run in the main thread. If async is false, all validators will
- * run in the main thread.
- */
- public EnabledIncrementalValidatorsOperation(IProject project, IWorkbenchContext context, IResourceDelta delta, boolean async) {
- this(project,context, delta, RegistryConstants.ATT_RULE_GROUP_DEFAULT, async);
- }
-
- /**
- * IProject must exist and be open.
- *
- * If delta is null, a full validation of the project using only the incremental validators is
- * performed. If delta is not null, all enabled incremental validators that validate resources
- * in the delta will validate those resources.
- *
- * If async is true, all thread-safe validators will run in the background validation thread,
- * and all other validators will run in the main thread. If async is false, all validators will
- * run in the main thread.
- */
- public EnabledIncrementalValidatorsOperation(IProject project,IWorkbenchContext context, IResourceDelta delta, int ruleGroup, boolean async) {
- super(project, ruleGroup, shouldForce(delta), async);
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- setEnabledValidators(InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(true)));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EnabledIncrementalVAlidatorsOperation(IProject<" + project.getName() + ">, IResourceDelta, int, boolean)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
- }
- }
- }
- setDelta(delta);
- setContext(context);
- }
-
- /**
- * IProject must exist and be open.
- *
- * If delta is null, a full validation of the project using only the incremental validators is
- * performed. If delta is not null, all enabled incremental validators that validate resources
- * in the delta will validate those resources.
- *
- * If async is true, all thread-safe validators will run in the background validation thread,
- * and all other validators will run in the main thread. If async is false, all validators will
- * run in the main thread.
- */
- public EnabledIncrementalValidatorsOperation(IProject project, IResourceDelta delta, int ruleGroup, boolean async) {
- super(project, ruleGroup, shouldForce(delta), async);
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- setEnabledValidators(InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(true)));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EnabledIncrementalVAlidatorsOperation(IProject<" + project.getName() + ">, IResourceDelta, int, boolean)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
- }
- }
- }
- setDelta(delta);
- }
-
- /**
- * IProject must exist, be open, and contain all of the resources in changedResources. If some
- * of the resources in changedResources belong to different projects, the result is undefined.
- *
- * If changedResources is null, a full validation of the project using only the incremental
- * validators is performed. If changedResources is not null, all enabled incremental validators
- * that validate resources in the changedResources array will validate those resources.
- *
- * If async is true, all thread-safe validators will run in the background validation thread,
- * and all other validators will run in the main thread. If async is false, all validators will
- * run in the main thread.
- */
- public EnabledIncrementalValidatorsOperation(IResource[] changedResources,IWorkbenchContext aWorkbenchContext, IProject project, boolean async) {
- super(project, RegistryConstants.ATT_RULE_GROUP_DEFAULT, shouldForce(changedResources), async);
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- setEnabledValidators(InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(true)));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EnabledIncrementalValidatorsOperation(IResource[], IProject<" + project.getName() + ">, boolean)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- //construct an array of IFileDelta[] to wrap the Object[]; one IFileDelta for each Object in the array
- setFileDeltas(FilterUtil.getFileDeltas(getEnabledValidators(), changedResources, false));
- setContext(aWorkbenchContext);
- }
-
- /**
- * IProject must exist, be open, and contain all of the resources in changedResources. If some
- * of the resources in changedResources belong to different projects, the result is undefined.
- *
- * If changedResources is null, a full validation of the project using only the incremental
- * validators is performed. If changedResources is not null, all enabled incremental validators
- * that validate resources in the changedResources array will validate those resources.
- *
- * If async is true, all thread-safe validators will run in the background validation thread,
- * and all other validators will run in the main thread. If async is false, all validators will
- * run in the main thread.
- */
- public EnabledIncrementalValidatorsOperation(IResource[] changedResources,IProject project, boolean async) {
- super(project, RegistryConstants.ATT_RULE_GROUP_DEFAULT, shouldForce(changedResources), async);
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- setEnabledValidators(InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(true)));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("EnabledIncrementalValidatorsOperation(IResource[], IProject<" + project.getName() + ">, boolean)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, exc);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- //construct an array of IFileDelta[] to wrap the Object[]; one IFileDelta for each Object in the array
- setFileDeltas(FilterUtil.getFileDeltas(getEnabledValidators(), changedResources, false));
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java
deleted file mode 100644
index a4e3cfd06..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/EnabledValidatorsOperation.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.wst.validation.internal.RegistryConstants;
-
-
-/**
- * Implemented Validators must not be called directly by anyone other than instances of
- * ValidationOperation, because some initialization of the validator, and handling of error
- * conditions, is done in the operation. The initialization is separated because some of the
- * information needed to initialize the validator (i.e., the project) isn't known until runtime.
- *
- * Instances of this operation run every enabled validator (both full and incremental) on the
- * project.
- *
- * This operation is not intended to be subclassed outside of the validation framework.
- */
-public class EnabledValidatorsOperation extends ValidatorSubsetOperation {
-
-
- /**
- * @deprecated Will be removed in Milestone 3. Use EnabledValidatorsOperation(IProject, boolean)
- */
- public EnabledValidatorsOperation(IProject project) {
- this(project, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use EnabledValidatorsOperation(IProject, int,
- * boolean, boolean)
- */
- public EnabledValidatorsOperation(IProject project, int ruleGroup) {
- this(project, ruleGroup, DEFAULT_FORCE, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use EnabledValidatorsOperation(IProject, int,
- * boolean, boolean)
- */
- public EnabledValidatorsOperation(IProject project, int ruleGroup, boolean force) {
- this(project, ruleGroup, force, DEFAULT_ASYNC);
- }
-
- /**
- * Run all enabled validators on the project.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public EnabledValidatorsOperation(IProject project, boolean async) {
- this(project, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
- }
-
- /**
- * Run all enabled validators on the project.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public EnabledValidatorsOperation(IProject project, IWorkbenchContext aWorkbenchContext, boolean async) {
- this(project, aWorkbenchContext, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
- }
-
- /**
- * Run all enabled validators on the project with the identified ruleGroup.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public EnabledValidatorsOperation(IProject project, IWorkbenchContext aWorkbenchContext, int ruleGroup, boolean force, boolean async) {
- this(project, aWorkbenchContext, ValidatorManager.getManager().getEnabledValidators(project), ruleGroup, force, async);
- }
-
-
- /**
- * Run all enabled validators on the project with the identified ruleGroup.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public EnabledValidatorsOperation(IProject project, int ruleGroup, boolean force, boolean async) {
- this(project, ValidatorManager.getManager().getEnabledValidators(project), ruleGroup, force, async);
- }
-
- /**
- * Run the identified validators on the project.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- protected EnabledValidatorsOperation(IProject project, Set enabledValidators, boolean async) {
- this(project, enabledValidators, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
- // true = force validation to run whether or not auto-validate is on
- }
-
- /**
- * Run the identified validators on the project.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- protected EnabledValidatorsOperation(IProject project,IWorkbenchContext aWorkbenchContext, Set enabledValidators, boolean async) {
- this(project,aWorkbenchContext, enabledValidators, RegistryConstants.ATT_RULE_GROUP_DEFAULT, DEFAULT_FORCE, async);
- // true = force validation to run whether or not auto-validate is on
- }
-
- /**
- * Run the identified validators on the project with the ruleGroup.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- protected EnabledValidatorsOperation(IProject project, Set enabledValidators, int ruleGroup, boolean force, boolean async) {
- super(project, force, ruleGroup, async);
- setEnabledValidators(enabledValidators);
- }
-
- /**
- * Run the identified validators on the project with the ruleGroup.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- protected EnabledValidatorsOperation(IProject project, IWorkbenchContext aWorkbenchContext, Set enabledValidators, int ruleGroup, boolean force, boolean async) {
- super(project,aWorkbenchContext,force, ruleGroup, async);
- setEnabledValidators(enabledValidators);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IResourceUtil.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IResourceUtil.java
deleted file mode 100644
index d0a34bfa7..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IResourceUtil.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-/**
- * This type is not intended to be extended by clients.
- */
-public interface IResourceUtil {
- /**
- * Return the line number where the Object is located.
- */
- public int getLineNo(Object obj);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IRuleGroup.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IRuleGroup.java
deleted file mode 100644
index dabcee8fa..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IRuleGroup.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-/**
- * This type represents a group of rules which a validator checks. For now, the only grouping is by
- * speed: if a set of rules can be checked quickly, it will be included in the PASS_FAST group,
- * otherwise, it is grouped in the PASS_FULL group.
- *
- * In future, this could be extended to include severities. To be able to group by severity helps
- * with the MessageLimitException. A validator should report errors first, and then warnings, and
- * then infos, in order to avoid the message limit being reached before the most severe problems are
- * reported.
- */
-public interface IRuleGroup {
- // The following filters are used to identify a group of validation checks.
-
- // retrieves the type of pass, from the IValidationContext, which the validator should execute
- public static final String PASS_LEVEL = "PASS_LEVEL"; //$NON-NLS-1$
-
- // On the FAST_PASS, the validator should check the rules which do not
- // take much time to check, and exclude the rules which are valid only
- // before some action (e.g. exporting or deploying).
- //
- // The severity of the messages is irrelevant.
- public static final int PASS_FAST = 0x1;
- public static final String PASS_FAST_NAME = "fast"; //$NON-NLS-1$ // In plugin.xml, identify this pass by this constant
-
- // On the FULL_PASS, the validator should check everything. This is the default.
- public static final int PASS_FULL = 0x2 | PASS_FAST;
- public static final String PASS_FULL_NAME = "full"; //$NON-NLS-1$ // In plugin.xml, identify this pass by this constant
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java
deleted file mode 100644
index 49d677f4c..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/IWorkbenchContext.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-
-
-
-/**
- * In the eclipse environment, not only does the IValidationContext need to be able to load the MOF model, it
- * also needs to load items from the eclipse workbench. This interface should be extended by
- * workbench IHelpers, so that items can be added to, and from, the task list.
- */
-public interface IWorkbenchContext extends IValidationContext {
- /**
- * When the validation is complete, this method will be called so that the IWorkbenchContext can
- * clean up any resources it allocated during the validation.
- *
- * If the cleanup is a long-running operation, subtask messages should be sent to the IReporter.
- */
- public void cleanup(WorkbenchReporter reporter);
-
- /**
- * When the IProject is closing, perform any cleanup that needs to be done. When this method is
- * called, if the helper has cached any resources from the IProject, it should release those
- * resources. If you do not allocate resources in your helper, then this method should be a
- * no-op.
- */
- public void closing();
-
- /**
- * When the IProject is being deleted, perform any cleanup that needs to be done. When this
- * method is called, if the helper has cached any resources from the IProject, it should release
- * those resources. If you do not allocate resources in your helper, then this method should be
- * a no-op.
- */
- public void deleting();
-
- /**
- * Given an Object, if the object has a corresponding IFile in the workbench, return the IFile.
- * Otherwise return null.
- *
- * This method is used by the WorkbenchReporter. In eclipse, in order to add or remove a task
- * list entry, the IResource, to which the entry applies, must be identified. The IReporter
- * interface passes in an Object in these methods:
- *
- * addValidationMessage(IValidator, IMessage) // Object is a part of IMessage
- *
- * removeAllMessages(IValidator, Object),
- *
- * Thus, the WorkbenchReporter needs to know how, given the Object, which IFile that the Object
- * represents in the workbench, in order to be able to add the task list entry.
- *
- * If this method returns null, then the WorkbenchReporter will add the message to the IProject
- * instead of an IFile.
- *
- * @deprecated Implement getResource(Object) instead.
- */
- public IFile getFile(Object object);
-
- /**
- * Given an Object, if the object has a corresponding IResource in the workbench, return the
- * IResourcee. Otherwise return null.
- *
- * This method is used by the WorkbenchReporter. In eclipse, in order to add or remove a task
- * list entry, the IResource, to which the entry applies, must be identified. The IReporter
- * interface passes in an Object in these methods:
- *
- * addValidationMessage(IValidator, IMessage) // Object is a part of IMessage
- *
- * removeAllMessages(IValidator, Object),
- *
- * Thus, the WorkbenchReporter needs to know how, given the Object, which IFile that the Object
- * represents in the workbench, in order to be able to add the task list entry.
- *
- * If this method returns null, then the WorkbenchReporter will add the message to the IProject
- * instead of an IResource.
- */
- public IResource getResource(Object object);
-
- /**
- * Given an IMessage's target object, return the line number, of the IFile, which the target
- * object represents, if possible. If the object is null, or if access to line numbers is not
- * possible, return a text description of the location.
- *
- * This method will be called whether or not the IResource is an IFile, IFolder, or IProject.
- * Line numbers are valid only for IFile types; if the resource is not an IFile, then a text
- * description of the location must be returned.
- */
- public String getLocation(Object object);
-
- /**
- * Return the name of the resource, without the project-specific information in front.
- *
- * This method is used by ValidationOperation to calculate the non-environment specific names of
- * the files. Only the IWorkbenchContext implementation knows how much information to strip off
- * of the IResource name. For example, if there is an EJB Project named "MyEJBProject", and it
- * uses the default names for the source and output folders, "source" and "ejbModule",
- * respectively, then the current implementation of EJB Helper knows how much of that structure
- * is eclipse-specific.
- *
- * Since the "source" folder contains Java source files, a portable name would be the
- * fully-qualified name of the Java class, without the eclipse-specific project and folder names
- * in front of the file name. The EJBHelper knows that everything up to the "source" folder, for
- * example, can be removed, because, according to the definition of the EJB Project, everything
- * contained in the source folder is java source code. So if there is an IResource in an EJB
- * Project named "/MyEJBProject/source/com/ibm/myclasses/MyJavaFile.java", this method would
- * make this name portable by stripping off the "/MyEJBProject/source", and returning
- * "com/ibm/myclasses/MyJavaFile.java".
- *
- * The output of this method is used by the ValidationOperation, when it is calculating the list
- * of added/changed/deleted file names for incremental validation. If getPortableName(IResource)
- * returns null, that means that the IWorkbenchContext's implementation does not support that
- * particular type of resource, and the resource should not be included in the array of
- * IFileDelta objects in the IValidator's "validate" method.
- */
- public String getPortableName(IResource resource);
-
- /**
- * Return the IProject which is about to be validated. Each IWorkbenchContext knows how to
- * traverse a certain type of IProject, for example, an EJB project or a web project.
- */
- public IProject getProject();
-
- /**
- * When an IValidator associates a target object with an IMessage, the WorkbenchReporter
- * eventually resolves that target object with an IResource. Sometimes more than one target
- * object resolves to the same IResource (usually the IProject, which is the default IResource
- * when an IFile cannot be found). This method is called, by the WorkbenchReporter, so that the
- * WorkbenchReporter can distinguish between the IMessages which are on the same IResource, but
- * refer to different target objects. This is needed for the removeAllMessages(IValidator,
- * Object) method, so that when one target object removes all of its messages, that it doesn't
- * remove another target object's messages.
- *
- * This method may return null only if object is null. Otherwise, an id which can uniquely
- * identify a particular object must be returned. The id needs to be unique only within one
- * particular IValidator.
- */
- public String getTargetObjectName(Object object);
-
- /**
- * Whether full or incremental validation is running, this method will be called, by the
- * Validation Framework, for every IResource which is filtered in by the IValidator, so that the
- * IValidationContext can receive notification that one of the resources, which validation will run on, is
- * being filtered in.
- */
- public void registerResource(IResource resource);
-
- /**
- * This method is called by the Validation Framework, to initialize the IWorkbenchContext so that
- * it can gather information from the current project.
- */
- public void setProject(IProject project);
-
- /**
- * Notifies this IWorkbenchContext that the Validation Framework is shutting down. There will be
- * calls to closing(IProject) and possibly deleting(IProject) following this call, but the
- * resources may already be closed by the time that those methods are called, so EVERYTHING
- * should be cleaned up in this method. The parameter passed in is the project which is about to
- * shut down. This method will be called once for every IProject in the workbench. The IProject
- * may, or may not, be closed.
- */
- public void shutdown();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/LocalizedMessage.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/LocalizedMessage.java
deleted file mode 100644
index 2472f7679..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/LocalizedMessage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.util.Locale;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.validation.internal.core.Message;
-
-
-/**
- * This class is provided for validators which run only in UI and whose messages, because they
- * come from another tool, are already localized. LocalizedMessage cannot be used by any validator
- * which needs to run in both WebSphere and WSAD.
- */
-public class LocalizedMessage extends Message {
- private String _message = null;
-
- public LocalizedMessage(int severity, String messageText) {
- this(severity, messageText, null);
- }
-
- public LocalizedMessage(int severity, String messageText, IResource targetObject) {
- this(severity, messageText, (Object) targetObject);
- }
-
- public LocalizedMessage(int severity, String messageText, Object targetObject) {
- super(null, severity, null);
- setLocalizedMessage(messageText);
- setTargetObject(targetObject);
- }
-
- public void setLocalizedMessage(String message) {
- _message = message;
- }
-
- public String getLocalizedMessage() {
- return _message;
- }
-
- public String getText() {
- return getLocalizedMessage();
- }
-
- public String getText(ClassLoader cl) {
- return getLocalizedMessage();
- }
-
- public String getText(Locale l) {
- return getLocalizedMessage();
- }
-
- public String getText(Locale l, ClassLoader cl) {
- return getLocalizedMessage();
- }
-} \ No newline at end of file
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
deleted file mode 100644
index c11ec1d5c..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/OneValidatorOperation.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.wst.validation.internal.RegistryConstants;
-import org.eclipse.wst.validation.internal.ValidationRegistryReader;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-
-
-/**
- * Implemented Validators must not be called directly by anyone other than instances of
- * ValidationOperation, because some initialization of the validator, and handling of error
- * conditions, is done in the operation. The initialization is separated because some of the
- * information needed to initialize the validator (i.e., the project) isn't known until runtime.
- *
- * This operation runs a single validator on a project.
- *
- * This operation is not intended to be subclassed outside of the validation framework.
- */
-public class OneValidatorOperation extends ValidatorSubsetOperation {
- /**
- * @deprecated Will be removed in Milestone 3. Use OneValidatorOperation(project, validatorId,
- * boolean, boolean)
- */
- public OneValidatorOperation(IProject project, String validatorId) throws IllegalArgumentException {
- this(project, validatorId, DEFAULT_FORCE, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use OneValidatorOperation(project, validatorId,
- * boolean, boolean)
- */
- public OneValidatorOperation(IProject project, String validatorId, boolean force) throws IllegalArgumentException {
- this(project, validatorId, force, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use OneValidatorOperation(IProject, String,
- * boolean, int, boolean)
- */
- public OneValidatorOperation(IProject project, String validatorId, boolean force, int ruleGroup) throws IllegalArgumentException {
- this(project, validatorId, force, ruleGroup, DEFAULT_ASYNC);
- }
-
- /**
- * @param validatorId
- * The plugin id of the validator which you wish to run.
- * @param force
- * If the value is "true", the validator should be run regardless of what the
- * environment settings are; if the value is "false", this operation should be run
- * only if the validation builder will not run the validator.
- *
- * IllegalArgumentException will be thrown if the named validator is not configured on the
- * project.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public OneValidatorOperation(IProject project, String validatorId, boolean force, boolean async) throws IllegalArgumentException {
- this(project, validatorId, force, RegistryConstants.ATT_RULE_GROUP_DEFAULT, async);
- }
-
- /**
- * OneValidatorOperation constructor comment.
- *
- * @param project
- * org.eclipse.core.resources.IProject
- * @param validatorId
- * The plugin id of the validator which you wish to run.
- * @param force
- * If the value is "true", the validator should be run regardless of what the
- * environment settings are; if the value is "false", this operation should be run
- * only if the validation builder will not run the validator.
- * @param ruleGroup
- * Whether a FULL or FAST pass should be invoked.
- *
- * IllegalArgumentException will be thrown if the named validator is not configured on the
- * project.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public OneValidatorOperation(IProject project, String validatorId, boolean force, int ruleGroup, boolean async) throws IllegalArgumentException {
- super(project, force, ruleGroup, async);
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorId);
- 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(validatorId);
- }
-
- if (!vmd.isConfiguredOnProject(project)) {
- // 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(validatorId);
- }
-
- Set enabled = new HashSet();
- enabled.add(vmd);
- setEnabledValidators(enabled);
- }
-} \ No newline at end of file
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
deleted file mode 100644
index a2e1fcc45..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on May 3, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.validation.internal.operations;
-
-import java.util.List;
-
-/**
- * @author vijayb
- *
- * To change the template for this generated type comment go to Window - Preferences - Java - Code
- * Generation - Code and Comments
- */
-public interface ReferencialFileValidator {
- public List getReferencedFile(List inputFiles);
-} \ No newline at end of file
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
deleted file mode 100644
index 1dbe0bd13..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ReferencialFileValidatorHelper.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on May 4, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.validation.internal.operations;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @author vijayb
- *
- * To change the template for this generated type comment go to Window - Preferences - Java - Code
- * Generation - Code and Comments
- */
-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;
- try {
- result = collectFiles(project.members(), result);
- } catch (CoreException e) {
- //Ignore
- }
- return result;
- }
-
- private static List collectFiles(IResource[] members, List 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);
- }
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ResourceHandler.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ResourceHandler.java
deleted file mode 100644
index fe47c0355..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ResourceHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-/**
- * @deprecated For use by the validation framework only. This class retrieves the Strings from the
- * .properties file appropriate for the machine's Locale.
- */
-public final class ResourceHandler extends org.eclipse.wst.validation.internal.ResourceHandler {
- //Default
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/TaskListHelper.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/TaskListHelper.java
deleted file mode 100644
index 8532dc18e..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/TaskListHelper.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.validation.internal.TaskListUtility;
-
-
-
-/**
- * @deprecated This class is intended to be used only by the validation framework. The
- * TaskListHelper class will be removed in Milestone 4.
- */
-public class TaskListHelper {
- private static TaskListHelper _taskListHelper = null;
-
- public static TaskListHelper getTaskList() {
- if (_taskListHelper == null) {
- _taskListHelper = new TaskListHelper();
- }
- return _taskListHelper;
- }
-
- /**
- * This method adds a message to a resource in the task list.
- */
- public void addTask(String pluginId, IResource resource, String location, String messageId, String message, int markerType, String targetObjectName, String groupName, int offset, int length) throws CoreException {
- TaskListUtility.addTask(pluginId, resource, location, messageId, message, markerType, targetObjectName, groupName, offset, length);
- }
-
-
- public IMarker[] getValidationTasks(int severity, IProject project) {
- return TaskListUtility.getValidationTasks(severity, project);
- }
-
- public IMarker[] getValidationTasks(IResource resource, int severity) {
- return TaskListUtility.getValidationTasks(resource, severity);
- }
-
- public IMarker[] getValidationTasks(IResource resource, String messageOwner) {
- return TaskListUtility.getValidationTasks(resource, messageOwner);
- }
-
- public IMarker[] getValidationTasks(IResource resource, String[] messageOwners) {
- return TaskListUtility.getValidationTasks(resource, messageOwners);
- }
-
- /**
- * Remove all validation messages from the resource and its children.
- */
- public void removeAllTasks(IResource resource) {
- TaskListUtility.removeAllTasks(resource);
- }
-
- /**
- * This method removes all tasks from the resource. If the resource is an IProject, all tasks
- * are also removed from the project's children.
- */
- public void removeAllTasks(IResource resource, String[] owners) throws CoreException {
- TaskListUtility.removeAllTasks(resource, owners);
- }
-
- /**
- * This method removes all messages from a resource in the task list.
- */
- public void removeAllTasks(IResource resource, String owner, String objectName) throws CoreException {
- TaskListUtility.removeAllTasks(resource, owner, objectName);
- }
-
- public void removeAllTasks(IResource resource, String[] owners, String objectName) throws CoreException {
- TaskListUtility.removeAllTasks(resource, owners, objectName);
- }
-
- /**
- * This method removes a subset of tasks from the project, including child tasks. Every task
- * which belongs to the group, identified by groupName, will be removed.
- */
- public void removeTaskSubset(IResource resource, String[] owners, String objectName, String groupName) throws CoreException {
- TaskListUtility.removeTaskSubset(resource, owners, objectName, groupName);
- }
-
- /**
- * This method changes all validator markers which are owned by "from" to make their owner "to".
- */
- public void updateOwner(String from, String to) throws CoreException {
- TaskListUtility.updateOwner(from, to);
- }
-
- /**
- * This method changes all validator markers on the IResource and its children. All markers
- * owned by "from" have their owner reassigned to "to".
- */
- public void updateOwner(String from, String to, IResource resource) throws CoreException {
- TaskListUtility.updateOwner(from, to, resource);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java
deleted file mode 100644
index cf2ea0a56..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationBuilder.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.InternalValidatorManager;
-import org.eclipse.wst.validation.internal.ProjectConfiguration;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.ResourceHandler;
-import org.eclipse.wst.validation.internal.TimeEntry;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * Validation Framework Builder.
- *
- * This builder is configured on J2EE IProjects automatically, can be added to other types of
- * projects through the Properties page, and launches validation on the project if the project has
- * build validation enabled.
- */
-public class ValidationBuilder extends IncrementalProjectBuilder {
- public static final int NO_DELTA_CHANGE = -1; // Since IResourceConstants
- protected List referencedProjects;
- protected IWorkbenchContext workbenchContext = null;
-
- // doesn't have a "no delta"
- // flag, let this constant be
- // the flag.
- 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);
- if (referencedProjects == null)
- referencedProjects = new ArrayList();
- try {
- if (project.isAccessible()) {
- IProject[] refProjArray = project.getReferencedProjects();
- collectReferecedProject(refProjArray);
- for (int i = 0; i < refProjArray.length; i++) {
- IProject refProject = refProjArray[i];
- getAllReferencedProjects(refProject, visitedProjects);
- }
- }
- return getReferencedProjects();
- } catch (CoreException core) {
- return null;
- }
- }
-
- public IWorkbenchContext getWorkbenchContext() {
- if(workbenchContext == null) {
- workbenchContext = new WorkbenchContext();
- workbenchContext.setProject(getProject());
- }
- return workbenchContext;
- }
-
-
- /**
- * @param referencedProjects2
- * @param refProjArray
- */
- private void collectReferecedProject(IProject[] refProjArray) {
- for (int i = 0; i < refProjArray.length; i++) {
- IProject project = refProjArray[i];
- if (!referencedProjects.contains(project))
- referencedProjects.add(project);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IncrementalProjectBuilder#clean(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void clean(IProgressMonitor monitor) throws CoreException {
- IProject currentProject = getProject();
- if (currentProject == null || !currentProject.isAccessible())
- return;
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(currentProject);
- ValidatorMetaData[] vmds = prjp.getValidators();
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- // For validators who aren't going to run, clear their messages from the task list.
- // Don't need to check for duplicate entries because each Validator must be unique.
- // The uniqueness of each Validator is checked by the plugin registry.
- WorkbenchReporter.removeAllMessages(currentProject, vmd.getValidatorNames(), null);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.updateTaskList(" + currentProject.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- }
-
- /**
- * @param referencedProjects
- * @return
- */
- 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;
- }
-
- public IProject[] build(int kind, Map parameters, IProgressMonitor monitor) {
- long start = System.currentTimeMillis();
- int executionMap = 0x0;
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- IResourceDelta delta = null;
- IProject project = getProject();
- IProject[] referenced = getAllReferencedProjects(project, null);
- try {
- if (ValidatorManager.getManager().isSuspended(project)) {
- // Do not perform validation on this project
- executionMap |= 0x1;
- return referenced;
- }
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- delta = getDelta(project);
- boolean doFullBuild = (kind == FULL_BUILD);
- boolean doAutoBuild = ((delta != null) && (kind == AUTO_BUILD));
- boolean doIncrementalBuild = ((delta != null) && (kind == INCREMENTAL_BUILD));
- if ((doFullBuild || doIncrementalBuild) && !prjp.isBuildValidate()) {
- // Is a build validation about to be invoked? If so, does the
- // user want build validation to run?
- executionMap |= 0x2;
- return referenced;
- }
- // It is possible for kind to == AUTO_BUILD while delta is null
- // (saw this
- // when creating a project by copying another project.)
- // However, a "Rebuild Project" will invoke this builder with
- // kind==FULL_BUILD
- // and a null delta, and validation should run in that case.
- if (!doFullBuild && delta == null) {
- if (isReferencedProjectInDelta(referenced)) {
- performFullBuildForReferencedProjectChanged(monitor, prjp);
- } else {
- String[] msgParms = new String[]{project.getName()};
- monitor.subTask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_NULL_DELTA, msgParms));
- // A null delta means that a full build must be performed,
- // but this builder was invoked with an incremental or
- // automatic
- // build kind. Return without doing anything so that the
- // user
- // doesn't have to wait forever.
- executionMap |= 0x4;
- }
- return referenced;
- }
- if (doFullBuild) {
- performFullBuild(monitor, prjp);
- } else {
- if (doAutoBuild && !prjp.isAutoValidate()) {
- executionMap |= 0x8;
- return referenced;
- }
- if (delta.getAffectedChildren().length == 0) {
- if (isReferencedProjectInDelta(referenced))
- performFullBuildForReferencedProjectChanged(monitor, prjp);
- else
- executionMap |= 0x10;
- return referenced;
- }
- EnabledIncrementalValidatorsOperation operation = new EnabledIncrementalValidatorsOperation(project, delta, prjp.runAsync());
- operation.run(monitor);
- }
- return referenced;
- } catch (InvocationTargetException exc) {
- logInvocationTargetException(logger, exc);
- executionMap |= 0x20;
- return referenced;
- } catch (Throwable exc) {
- logBuildError(logger, exc);
- executionMap |= 0x40;
- return referenced;
- } finally {
- referencedProjects = null;
- // The builder's time needs to be FINE because the builder is
- // called often.
- if (logger.isLoggingLevel(Level.FINE)) {
- logBuilderTimeEntry(start, executionMap, logger, delta);
- }
- }
- }
-
- /**
- * @param referenced
- * @return
- */
- private boolean isReferencedProjectInDelta(IProject[] referenced) {
- IProject p = null;
- for (int i = 0; i < referenced.length; i++) {
- p = referenced[i];
- IResourceDelta delta = getDelta(p);
- if (delta != null && delta.getAffectedChildren().length > 0)
- return true;
- }
- return false;
- }
-
- /**
- * @param monitor
- * @param prjp
- */
- private void performFullBuildForReferencedProjectChanged(IProgressMonitor monitor, ProjectConfiguration prjp) throws InvocationTargetException {
- performFullBuild(monitor, prjp, true);
- }
-
- private void performFullBuild(IProgressMonitor monitor, ProjectConfiguration prjp) throws InvocationTargetException {
- performFullBuild(monitor, prjp, false);
- }
-
- private void performFullBuild(IProgressMonitor monitor, ProjectConfiguration prjp, boolean onlyDependentValidators) throws InvocationTargetException {
- ValidatorMetaData[] enabledValidators = prjp.getEnabledFullBuildValidators(true, onlyDependentValidators);
- if ((enabledValidators != null) && (enabledValidators.length > 0)) {
- Set enabledValidatorsSet = InternalValidatorManager.wrapInSet(enabledValidators);
- EnabledValidatorsOperation op = new EnabledValidatorsOperation(getProject(), enabledValidatorsSet, prjp.runAsync());
- op.run(monitor);
- }
- }
-
- private void logInvocationTargetException(Logger logger, InvocationTargetException exc) {
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationBuilder::build"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- private void logBuildError(Logger logger, Throwable exc) {
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationBuilder.build(int, Map, IProgressMonitor)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
-
- private void logBuilderTimeEntry(long start, int executionMap, Logger logger, IResourceDelta delta) {
- TimeEntry entry = ValidationPlugin.getTimeEntry();
- entry.setSourceID("ValidationBuilder.build(int, Map, IProgressMonitor)"); //$NON-NLS-1$
- entry.setProjectName(getProject().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setExecutionMap(executionMap);
- entry.setElapsedTime(System.currentTimeMillis() - start);
- if (delta == null) {
- entry.setDetails("delta == null"); //$NON-NLS-1$
- }
- entry.setToolName("ValidationBuilder"); //$NON-NLS-1$
- logger.write(Level.FINE, entry);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationConstants.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationConstants.java
deleted file mode 100644
index 1e375244f..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationConstants.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-import org.eclipse.wst.validation.internal.ResourceConstants;
-
-/**
- * @deprecated For use by the validation framework only.
- *
- * Constants used to access the string resources associated with the plugin.
- *
- * See the plugin.properties file, in the plugin's directory, for the contents of the strings.
- */
-public interface ValidationConstants extends ResourceConstants {
- //Default
-} \ No newline at end of file
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
deleted file mode 100644
index 3e250be23..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationOperation.java
+++ /dev/null
@@ -1,1475 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.common.frameworks.internal.operations.IHeadlessRunnableWithProgress;
-import org.eclipse.wst.validation.internal.FilterUtil;
-import org.eclipse.wst.validation.internal.InternalValidatorManager;
-import org.eclipse.wst.validation.internal.ReferencialFileValidatorRegistryReader;
-import org.eclipse.wst.validation.internal.RegistryConstants;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.ResourceHandler;
-import org.eclipse.wst.validation.internal.TimeEntry;
-import org.eclipse.wst.validation.internal.VThreadManager;
-import org.eclipse.wst.validation.internal.ValidationRegistryReader;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.core.ValidatorLauncher;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.validation.internal.provisional.core.MessageLimitException;
-
-/**
- * Implemented Validators methods must not be called directly by anyone other than this class, since
- * some initialization of the validator is done here (via the getProject() method). The
- * initialization is separated because the IProject isn't known until runtime.
- *
- * This operation is not intended to be subclassed outside of the validation framework.
- */
-public abstract class ValidationOperation implements IWorkspaceRunnable, IHeadlessRunnableWithProgress {
- public static final int NO_DELTA_CHANGE = -1; // Since IResourceConstants
- // doesn't have a "no delta"
- // flag, let this constant be
- // the flag.
- private static final String DELTA_AS_STRING = "IFileDelta[{0}] '{'{1}'}'"; //$NON-NLS-1$
- private static final String COMMA = ", "; //$NON-NLS-1$
- protected static final boolean DEFAULT_ASYNC = false; // For the deprecated
- // constructors, by
- // default the
- // operation will not
- // fork.
- protected static final boolean DEFAULT_FORCE = true; // By default, run the
- // operation whether
- // or not it needs to
- /**
- * @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 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;
- // 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
-
- protected IWorkbenchContext context;
-
- // are enabled and were launched
- // (i.e., that have input to
- // validate). For internal
- // validation framework use only;
- // it's needed for the automatic
- // tests.
- /**
- * This method is used for FINEST logging, to report exactly what deltas were about to be
- * validated.
- */
- private static final String getDeltaAsString(IFileDelta[] delta) {
- String args = ""; //$NON-NLS-1$
- int numArgs = 0;
- if (delta != null) {
- numArgs = delta.length;
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < delta.length; i++) {
- buffer.append(COMMA);
- buffer.append(delta[i].toString());
- }
- buffer.replace(0, 1, ""); //$NON-NLS-1$ // magic numbers 0 and 1 => Remove first COMMA from the list (hence index 0); length of COMMA is 2, hence index 0, 1.
- args = buffer.toString();
- }
- return MessageFormat.format(DELTA_AS_STRING, new String[]{String.valueOf(numArgs), args});
- }
-
- protected static void checkCanceled(WorkbenchReporter reporter) throws OperationCanceledException {
- if (reporter == null) {
- return;
- } else if (reporter.getProgressMonitor().isCanceled()) {
- throw new OperationCanceledException(""); //$NON-NLS-1$
- }
- }
-
- protected static boolean shouldForce(IResourceDelta delta) {
- return ((delta == null) ? DEFAULT_FORCE : false);
- }
-
- protected static boolean shouldForce(Object[] changedResources) {
- return (((changedResources == null) || (changedResources.length == 0)) ? DEFAULT_FORCE : false);
- }
-
- /**
- * @deprecated. Will be removed in Milestone 3. Use ValidationOperation(project, boolean)
- */
- public ValidationOperation(IProject project) {
- this(project, DEFAULT_ASYNC, DEFAULT_FORCE);
- }
-
- /**
- * Internal.
- */
- public ValidationOperation(IProject project, boolean force, boolean async) {
- this(project, null, null, RegistryConstants.ATT_RULE_GROUP_DEFAULT, force, async);
- }
-
- /**
- * @deprecated. Will be removed in Milestone 3. Use ValidationOperation(project, int, boolean)
- */
- public ValidationOperation(IProject project, int ruleGroup) {
- this(project, null, null, ruleGroup, DEFAULT_FORCE, DEFAULT_ASYNC);
- }
-
- /**
- * @deprecated. Will be removed in Milestone 3. Use ValidationOperation(IProject,
- * IResourceDelta, Boolean, int, boolean, boolean)
- */
- public ValidationOperation(IProject project, IResourceDelta delta, boolean isAutoBuild, int ruleGroup, boolean force, boolean fork) {
- this(project, delta, ((isAutoBuild) ? Boolean.TRUE : Boolean.FALSE), ruleGroup, fork, force);
- }
-
- /**
- * Internal.
- */
- protected ValidationOperation(IProject project, IResourceDelta delta, Boolean isAutoBuild, int ruleGroup, boolean force, boolean fork) {
- super();
- _project = project;
- _delta = delta;
- _isAutoBuild = isAutoBuild;
- _ruleGroup = ruleGroup;
- _fork = fork;
- _force = force;
- _enabledValidators = new HashSet();
- }
-
- /**
- * Internal.
- */
- protected ValidationOperation(IProject project, IWorkbenchContext aContext, IResourceDelta delta, Boolean isAutoBuild, int ruleGroup, boolean force, boolean fork) {
- super();
- _project = project;
- _delta = delta;
- _isAutoBuild = isAutoBuild;
- _ruleGroup = ruleGroup;
- _fork = fork;
- _force = force;
- _enabledValidators = new HashSet();
- context = aContext;
- }
-
- /**
- * @deprecated Will be removed in Milestone 3.
- */
- protected void terminateCleanup(WorkbenchReporter reporter) {
- Set enabledValidators = getEnabledValidators();
- Iterator iterator = enabledValidators.iterator();
- ValidatorMetaData vmd = null;
- try {
- while (iterator.hasNext()) {
- vmd = (ValidatorMetaData) iterator.next();
- reporter.displaySubtask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_CLEANUP, new String[]{vmd.getValidatorDisplayName()}));
- try {
- reporter.removeAllMessages(vmd.getValidator());
- } catch (InstantiationException exc) {
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
- // Log the reason for the disabled validator
- final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation::terminateCleanup"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
- addCancelTask(vmd);
- reporter.displaySubtask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED, new String[]{getProject().getName(), vmd.getValidatorDisplayName()}));
- }
- } catch (MessageLimitException e) {
- ValidatorManager.getManager().addMessageLimitExceeded(getProject());
- }
- }
-
- /**
- * @param vmd
- * @param delta
- * @param logger
- * @param start
- */
-// private void logValidationInfo(ValidatorMetaData vmd, IFileDelta[] delta, Logger logger, long start) {
-// long finish = System.currentTimeMillis();
-// TimeEntry entry = ValidationPlugin.getTimeEntry();
-// entry.setSourceID("ValidationOperation.launchValidator"); //$NON-NLS-1$
-// entry.setProjectName(getProject().getName());
-// entry.setToolName(vmd.getValidatorUniqueName());
-// entry.setElapsedTime(finish - start);
-// if (logger.isLoggingLevel(Level.FINE)) {
-// StringBuffer buffer = new StringBuffer();
-// if (isFullValidate()) {
-// buffer.append("EVERYTHING"); //$NON-NLS-1$
-// } else {
-// if (delta.length == 0) {
-// buffer.append("NOTHING"); //$NON-NLS-1$
-// } else {
-// buffer.append(getDeltaAsString(delta));
-// }
-// }
-// entry.setDetails(buffer.toString());
-// }
-// logger.write(Level.INFO, entry);
-// }
-
- /**
- * @param reporter
- * @param vmd
- * @param logger
- * @param exc
- */
-// private void handleThrowables(WorkbenchReporter reporter, ValidatorMetaData vmd, Logger logger, Throwable exc) {
-// // 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.
-// if (logger.isLoggingLevel(Level.SEVERE)) {
-// LogEntry entry = ValidationPlugin.getLogEntry();
-// entry.setSourceID("ValidationOperation::launchValidator"); //$NON-NLS-1$
-// entry.setTargetException(exc);
-// logger.write(Level.SEVERE, entry);
-// }
-// String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
-// Message message = ValidationPlugin.getMessage();
-// message.setSeverity(IMessage.NORMAL_SEVERITY);
-// message.setId(ResourceConstants.VBF_EXC_RUNTIME);
-// message.setParams(msgParm);
-// try {
-// reporter.addMessage(vmd.getValidator(), message);
-// } catch (InstantiationException exc2) {
-// handleInstantiationException(vmd, logger, exc2);
-// } catch (MessageLimitException e) {
-// throw e;
-// }
-// return;
-// }
-
- /**
- * @param vmd
- * @param logger
- * @param exc2
- */
-// private void handleInstantiationException(ValidatorMetaData vmd, Logger logger, InstantiationException exc2) {
-// // Remove the vmd from the reader's list
-// ValidationRegistryReader.getReader().disableValidator(vmd);
-// // Log the reason for the disabled validator
-// if (logger.isLoggingLevel(Level.SEVERE)) {
-// LogEntry entry = ValidationPlugin.getLogEntry();
-// entry.setSourceID("ValidationOperation::launchValidator (deprecated)"); //$NON-NLS-1$
-// entry.setTargetException(exc2);
-// logger.write(Level.SEVERE, entry);
-// }
-// }
-
- /**
- * @param reporter
- * @param vmd
- * @param logger
- * @param exc
- */
-// private void handleValidationExceptions(WorkbenchReporter reporter, ValidatorMetaData vmd, Logger logger, ValidationException exc) {
-// // First, see if a validator just caught all Throwables and
-// // 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) {
-// try {
-// ValidationException vexc = (ValidationException) exc.getAssociatedException();
-// vexc.setClassLoader(vmd.getValidator().getClass().getClassLoader()); // first,
-// // set the class loader,so that the exception's getMessage() method can retrieve
-// // the resource bundle
-// } catch (InstantiationException exc2) {
-// handleInstantiationException(vmd, logger, exc2);
-// }
-// }
-// }
-// // If there is a problem with this particular validator, log the error
-// // and continue
-// // with the next validator.
-// try {
-// exc.setClassLoader(vmd.getValidator().getClass().getClassLoader()); // first,
-// // set the class loader,so that the exception's getMessage() method can retrieve the
-// // resource bundle
-// } catch (InstantiationException exc2) {
-// handleInstantiationException(vmd, logger, exc2);
-// }
-// if (logger.isLoggingLevel(Level.SEVERE)) {
-// LogEntry entry = ValidationPlugin.getLogEntry();
-// entry.setSourceID("ValidationOperation.validate(WorkbenchMonitor)"); //$NON-NLS-1$
-// entry.setTargetException(exc);
-// logger.write(Level.SEVERE, entry);
-// if (exc.getAssociatedException() != null) {
-// entry.setTargetException(exc.getAssociatedException());
-// logger.write(Level.SEVERE, entry);
-// }
-// }
-// String message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION_ABNORMALLY, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
-// reporter.displaySubtask(message);
-// if (exc.getAssociatedMessage() != null) {
-// try {
-// reporter.addMessage(vmd.getValidator(), exc.getAssociatedMessage());
-// } catch (InstantiationException exc2) {
-// handleInstantiationException(vmd, logger, exc2);
-// }
-// }
-// }
-
- /**
- * @param reporter
- * @param vmd
- * @param logger
- * @param exc
- */
-// private void handleHelperCleanupExceptions(WorkbenchReporter reporter, ValidatorMetaData vmd, Logger logger, Throwable exc) {
-// // 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.
-// if (logger.isLoggingLevel(Level.SEVERE)) {
-// LogEntry entry = ValidationPlugin.getLogEntry();
-// entry.setSourceID("ValidationOperation::launchValidator"); //$NON-NLS-1$
-// entry.setTargetException(exc);
-// logger.write(Level.SEVERE, entry);
-// }
-// String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
-// Message message = ValidationPlugin.getMessage();
-// message.setSeverity(IMessage.NORMAL_SEVERITY);
-// message.setId(ResourceConstants.VBF_EXC_RUNTIME);
-// message.setParams(msgParm);
-// try {
-// reporter.addMessage(vmd.getValidator(), message);
-// } catch (InstantiationException exc2) {
-// handleInstantiationException(vmd, logger, exc2);
-// } catch (MessageLimitException e) {
-// throw e;
-// }
-// return;
-// }
-
- public boolean isFork() {
- return _fork;
- }
-
- public boolean isForce() {
- return _force;
- }
-
- public void setForce(boolean force) {
- _force = force;
- }
-
- /**
- * If the code that invoked this operation suspended auto-build before invoking this operation,
- * the user's auto-build setting is stored in the following methods.
- */
- public boolean isAutoBuild() {
- if (_isAutoBuild == null) {
- return ValidatorManager.getManager().isGlobalAutoBuildEnabled();
- }
- return _isAutoBuild.booleanValue();
- }
-
- protected void setAutoBuild(boolean autoOn) {
- _isAutoBuild = ((autoOn) ? Boolean.TRUE : Boolean.FALSE);
- }
-
- protected boolean isFullValidate() {
- return _isFullValidate;
- }
-
- private void setFullValidate(boolean b) {
- _isFullValidate = b;
- }
-
- protected int getRuleGroup() {
- return _ruleGroup;
- }
-
- /**
- * Return true if the given validator must run (i.e., it has changes to validate, and it was not
- * 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);
- }
-
- /**
- * Return true if, given the enabled validators and file deltas, there is work for this
- * operation to do.
- */
- public boolean isNecessary(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
- Set enabledValidators = getEnabledValidators();
- if ((enabledValidators == null) || (enabledValidators.size() == 0)) {
- return false;
- }
- if (isFullValidate()) {
- return true;
- }
- Iterator iterator = enabledValidators.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- if (isValidationNecessary(vmd, getFileDeltas(monitor, vmd))) {
- return true;
- }
- }
- return false;
- }
-
- private Map 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];
- }
- IFileDelta[] temp = new IFileDelta[result.size()];
- result.toArray(temp);
- return temp;
- }
-
- /**
- * Store the file deltas (VMD <=>Set[IFileDelta]) if the file deltas haven't been loaded. If the
- * deltas have already been loaded, return without doing anything.
- */
- private void loadFileDeltas(IProgressMonitor monitor) throws CoreException {
- // Although, for a full build, we don't build up a list of changed
- // files, we do need to notify each IWorkbenchContext that an
- // IResource has been filtered in.
- // It's a full validation if the IResourceDelta is null and the
- // Object[] (or IResource[]) is also null.
- // i.e., it's a full validation if no incremental input has been set.
- setFullValidate((getDelta() == null) && (_fileDeltas == null));
- if (isFullValidate()) {
- _fileDeltas = FilterUtil.loadDeltas(monitor, getEnabledValidators(), getProject());
- } else {
- _fileDeltas = FilterUtil.loadDeltas(monitor, getEnabledValidators(), getDelta()); // traverse,
- // and process, each resource in the delta tree
- }
- }
-
- protected void setFileDeltas(Map deltas) {
- _fileDeltas = deltas;
- }
-
- protected IResourceDelta getDelta() {
- return _delta;
- }
-
- protected void setDelta(IResourceDelta delta) {
- _delta = delta;
- }
-
- protected boolean areValidatorsEnabled() {
- return (getEnabledValidators().size() != 0);
- }
-
- /**
- * 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() {
- return _enabledValidators;
- }
-
- /**
- * This is an internal method, subject to change without notice. It is provided only for the
- * automated validation framework tests.
- */
- public Set getLaunchedValidators() {
- if (_launchedValidators == null) {
- _launchedValidators = new HashSet();
- }
- return _launchedValidators;
- }
-
- protected void setEnabledValidators(Set evmds) {
- // Check that every VMD in the set is configured on this project.
- // Necessary because the user can manually choose which validators
- // to launch, and the validator may not be installed.
- _enabledValidators.clear();
- Iterator iterator = evmds.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- if (ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, getProject())) {
- _enabledValidators.add(vmd);
- }
- }
- }
-
- /**
- * This method returns the IProject that this ValidationOperation was created with.
- */
- public IProject getProject() {
- return _project;
- }
-
- protected int getUnitsOfWork() {
- /*
- * // Let one unit of work equal one resource. number of enabled validators // i.e., each
- * enabled validator must process (at most) each resource in the project; count each process
- * as one unit of work // Note that this is a ceiling number, because if we're doing an
- * incremental validation, not all resources will // be validated.
- * setNumResources(countResources(getProject())); getEnabledValidators().size();
- */
- // Until the validators can report units-of-work complete,
- // initialize the monitor with an unknown amount of work.
- // (So the user will see movement in the progress bar, even
- // if the movement doesn't indicate the amount of work done.)
- return IProgressMonitor.UNKNOWN;
- }
-
- /**
- * If the user is cancelling validation on the current project/resource, Add an information task
- * to the task list informing the user that validation has not been run on the current project.
- */
- protected void addCancelTask(ValidatorMetaData vmd) {
- InternalValidatorManager.getManager().addOperationTask(getProject(), vmd, ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- }
-
- /**
- * This method starts the validation of each configured enabled validator on the current
- * project.
- *
- * The IProgressMonitor passed in must not be null.
- */
- public void run(IProgressMonitor progressMonitor) throws OperationCanceledException {
- long start = System.currentTimeMillis();
- final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- try {
- // In order to check whether or not the monitor has been cancelled,
- // the monitor must not be null.
- if (progressMonitor == null) {
- return;
- }
- if (ValidatorManager.getManager().isSuspended(getProject())) {
- return;
- }
- if (!areValidatorsEnabled()) {
- // save some processing time...
- return;
- }
- if (ValidatorManager.getManager().getMaximumMessagesAllowed(getProject()) == 0) {
- // save some processing time
- return;
- }
- final WorkbenchReporter reporter = new WorkbenchReporter(getProject(), progressMonitor);
-
- try {
- // Periodically check if the user has cancelled the operation
- checkCanceled(reporter);
- preValidate(reporter);
- validate(reporter);
- validateReferencialFiles(reporter);
- } catch (CoreException exc) {
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation.run"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- } finally {
- if (logger.isLoggingLevel(Level.FINE)) {
- long finish = System.currentTimeMillis();
- TimeEntry entry = ValidationPlugin.getTimeEntry();
- entry.setSourceID("ValidationOperation.run(WorkbenchMonitor)"); //$NON-NLS-1$
- entry.setProjectName(getProject().getName());
- entry.setToolName("ValidationOperation"); //$NON-NLS-1$
- entry.setElapsedTime(finish - start);
- logger.write(Level.FINE, entry);
- }
- }
- }
-
- /**
- * @param reporter
- */
- private void validateReferencialFiles(WorkbenchReporter reporter) {
- ReferencialFileValidatorRegistryReader reader = ReferencialFileValidatorRegistryReader.getInstance();
- if (reader != null) {
- reader.readRegistry();
- ReferencialFileValidator refFileValidator = reader.getReferencialFileValidator();
- if (refFileValidator != null) {
- if (_delta != null) {
- refFileValidateFileDelta(reporter, refFileValidator);
- } else if (_project != null) {
- postValidateProject(reporter, refFileValidator);
- }
- }
- }
- }
-
- /**
- * @param reporter
- * @param referencialFileValidator
- */
- private void refFileValidateFileDelta(WorkbenchReporter reporter, ReferencialFileValidator refFileValidator) {
- IResourceDelta[] resourceDelta = _delta.getAffectedChildren(IResourceDelta.ADDED | IResourceDelta.CHANGED | IResourceDelta.REMOVED);
- List inputFiles = new ArrayList();
- List referencingFiles = new ArrayList();
- if (resourceDelta != null && resourceDelta.length > 0) {
- for (int i = 0; i < resourceDelta.length; i++) {
- IResource resource = resourceDelta[i].getResource();
- if (resource instanceof IFolder) {
- getFileResourceDeltaInFolder(resourceDelta[i], inputFiles);
- } else if (resource instanceof IFile)
- inputFiles.add(resource);
- }
- List rFilesToValidate = refFileValidator.getReferencedFile(inputFiles);
- if (rFilesToValidate != null && !rFilesToValidate.isEmpty())
- referencingFiles.addAll(rFilesToValidate);
- try {
- if (!referencingFiles.isEmpty())
- validateReferencingFiles(reporter, referencingFiles);
- } catch (Exception e) {
- Logger.getLogger().log(e);
- }
- }
- }
-
- /**
- * @param delta
- * @return
- */
- private void getFileResourceDeltaInFolder(IResourceDelta delta, List 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);
- }
- }
-
- /**
- * @param reporter
- * @param referencialFileValidator
- */
- private void postValidateProject(WorkbenchReporter reporter, ReferencialFileValidator refFileValidator) {
- Set set = ValidationRegistryReader.getReader().getValidatorMetaData(_project);
- Iterator it = set.iterator();
- while (it.hasNext()) {
- ValidatorMetaData data = (ValidatorMetaData) it.next();
- List filters = data.getNameFilters();
- List files = getAllFilesForFilter(filters);
- if (!files.isEmpty()) {
- List fileForValidation = refFileValidator.getReferencedFile(files);
- try {
- validateReferencingFiles(reporter, fileForValidation);
- } catch (Exception e) {
- Logger.getLogger().log(e);
- }
- }
- }
- }
-
- /**
- * @param filters
- * @return
- */
- private List getAllFilesForFilter(List filters) {
- if (!filters.isEmpty()) {
- List allProjectFiles = ReferencialFileValidatorHelper.getAllProjectFiles(_project);
- List filterFiles = new ArrayList();
- for (int i = 0; i < filters.size(); i++) {
- String fileName = (String) filters.get(i);
- if (fileName == null)
- continue;
- for (int j = 0; j < allProjectFiles.size(); j++) {
- IFile projectFile = (IFile) allProjectFiles.get(j);
- if (fileName.charAt(0) == '*') {
- String extName = fileName.substring(2, fileName.length());
- String ext = projectFile.getFileExtension();
- if (ext != null && ext.equals(extName))
- filterFiles.add(projectFile);
- } else if (fileName.equals(projectFile.getName()))
- filterFiles.add(projectFile);
- }
-
- }
- return filterFiles;
- }
- return Collections.EMPTY_LIST;
- }
-
- 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);
- if (!validatedFiles.contains(refFile)) {
- IResource resource = refFile.getParent();
- IProject project = null;
- if (resource != null && !(resource instanceof IProject))
- project = getProjectContainer(resource);
- else
- project = (IProject) resource;
- if (project != null) {
- Set set = ValidationRegistryReader.getReader().getValidatorMetaData(project);
-// IFileDelta[] changedfiles = new FileDelta[]{new WorkbenchFileDelta(refFile.getProjectRelativePath().toString(), IFileDelta.CHANGED, refFile)};
- Iterator it = set.iterator();
- while (it.hasNext()) {
- ValidatorMetaData data = (ValidatorMetaData) it.next();
- if (data.isApplicableTo(refFile)) {
- IValidator validator = data.getValidator();
- validator.validate(data.getHelper(project),reporter);
- validatedFiles.add(refFile);
- }
- }
- }
- }
- }
- }
-
- private IProject getProjectContainer(IResource resource) {
- IResource pResource = resource.getParent();
- if (!(pResource instanceof IProject))
- return getProjectContainer(pResource);
- return (IProject) pResource;
- }
-
- protected void preValidate(WorkbenchReporter reporter) throws CoreException, OperationCanceledException {
- // Load the input.
- getFileDeltas(reporter.getProgressMonitor());
- }
-
- /**
- * Iterate over all of the enabled validators and run the thread-safe validators in a background
- * thread, and the not-thread-safe validators in this thread.
- */
- protected void validate(WorkbenchReporter reporter) throws OperationCanceledException {
- if (reporter == null) {
- return;
- }
- checkCanceled(reporter);
- reporter.getProgressMonitor().beginTask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_PROGRESSMONITOR_TITLE), getUnitsOfWork());
- IValidator validator = null;
- ValidatorMetaData vmd = null;
- Iterator iterator = null;
- WorkbenchReporter nullReporter = new WorkbenchReporter(getProject(), new NullProgressMonitor());
- final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- IFileDelta[] delta = null;
- try {
- iterator = getEnabledValidators().iterator();
- // In order to allow validators to run, must first check if there's
- // space for new markers.
- // But we don't want the old markers to prevent validation from
- // running again, so delete all
- // of the old markers first, and then run validation.
- while (iterator.hasNext()) {
- vmd = (ValidatorMetaData) iterator.next();
- // Is validation about to be run on this validator?
- // Validation will run either if this operation forces
- // regardless
- // of need, or if the validator was not run automatically.
- // If validation is not about to be run, then don't activate
- // the plugin
- try {
- delta = getFileDeltas(reporter.getProgressMonitor(), vmd);
- boolean willRun = (isForce() || isValidationNecessary(vmd, delta));
- if (logger.isLoggingLevel(Level.FINEST)) {
- TimeEntry entry = ValidationPlugin.getTimeEntry();
- entry.setSourceID("ValidationOperation.validate(WorkbenchReporter)"); //$NON-NLS-1$
- entry.setProjectName(getProject().getName());
- entry.setToolName(vmd.getValidatorUniqueName());
- entry.setElapsedTime(0);
- StringBuffer buffer = new StringBuffer();
- buffer.append("will run? "); //$NON-NLS-1$
- buffer.append(willRun);
- buffer.append(" "); //$NON-NLS-1$
- buffer.append("is force? "); //$NON-NLS-1$
- buffer.append(isForce());
- buffer.append(" "); //$NON-NLS-1$
- buffer.append("isAutoBuild? "); //$NON-NLS-1$
- 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());
- buffer.append(" "); //$NON-NLS-1$
- if (isFullValidate()) {
- buffer.append("EVERYTHING"); //$NON-NLS-1$
- } else {
- if (delta.length == 0) {
- buffer.append("NOTHING"); //$NON-NLS-1$
- } else {
- buffer.append(getDeltaAsString(delta));
- }
- }
- entry.setDetails(buffer.toString());
- logger.write(Level.FINEST, entry);
- }
- if (!willRun) {
- continue;
- }
- } catch (CoreException exc) {
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation.validate(WorkbenchReporter)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- String mssg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION_ABNORMALLY, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(mssg);
- String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.NORMAL_SEVERITY);
- message.setId(ResourceConstants.VBF_EXC_RUNTIME);
- message.setParams(msgParm);
- reporter.addMessage(validator, message);
- continue;
- }
- try {
- context = vmd.getHelper(getProject());
- initValidateContext(delta);
- validator = vmd.getValidator();
- } catch (InstantiationException exc) {
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
- // Log the reason for the disabled validator
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation::validate(WorkbenchReporter)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
-
- if (isFork() && vmd.isAsync()) {
- // Don't appear to run in the foreground by sending
- // progress to the IProgressMonitor in the
- // WorkbenchMonitor. Suppress the status messages by
- // changing the IProgressMonitor to a
- // NullProgressMonitor.
- VThreadManager.getManager().queue(wrapInRunnable(nullReporter, validator, vmd,(WorkbenchContext)getContext(),delta, iterator));
- } else {
- internalValidate(reporter, validator, vmd,context,delta);
- }
- }
- } catch (OperationCanceledException exc) {
- handleOperationCancelledValidateException(reporter, validator, vmd, iterator, logger, exc);
- } finally {
- releaseCachedMaps();
- }
- }
-
- /**
- *
- */
- private void releaseCachedMaps() {
- if(ValidatorManager.messageLimitProjectMap != null) {
- ValidatorManager.messageLimitProjectMap.clear();
- ValidatorManager.messageLimitProjectMap = null;
- }
- if(ValidatorManager.messageLimitMessageProjectMap != null) {
- ValidatorManager.messageLimitMessageProjectMap.clear();
- ValidatorManager.messageLimitMessageProjectMap = null;
- }
- if (ValidationRegistryReader.getReader().projectValidationMetaData != null) {
- ValidationRegistryReader.getReader().projectValidationMetaData.clear();
- ValidationRegistryReader.getReader().projectValidationMetaData = null;
- }
- }
-
- 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];
- if(file.getDeltaType() != IFileDelta.DELETED ) {
- ((WorkbenchContext)context).getValidationFileURIs().add(file.getFileName());
- }
- }
- }
- }
-
- /**
- * @param reporter
- * @param validator
- * @param vmd
- * @param iterator
- * @param logger
- * @param exc
- */
- private void handleOperationCancelledValidateException(WorkbenchReporter reporter, IValidator validator, ValidatorMetaData vmd, Iterator iterator, final Logger logger, OperationCanceledException exc) {
- /*
- * If the user terminates validation (i.e., presses "cancel" on the progress monitor) before
- * the validation completes, perform clean up on each configured enabled validator.
- *
- * To clean up, several steps are performed: 1. call <code></code> on each configured
- * enabled validator, so that each validator can perform cleanup that it knows is necessary.
- * 2. remove all tasks that this validator has added to the task list 3. add another task to
- * the task list to say that validation, using this validator on this project, was
- * terminated.
- *
- * Steps 2 and 3 are done so that it's clear what has, and has not, been validated. If these
- * steps weren't performed, validation could be done on some items in the project, but not
- * others; and the user could mistakenly believe that those are the only problems with the
- * project. Unless the user knows that a full verification needs to be done, he/she could
- * continue to rely on automatic verification, and never know that there are problems with a
- * resource which hasn't been validated.
- */
- reporter.displaySubtask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_CLEANUP, new String[]{vmd.getValidatorDisplayName()}));
- reporter.removeAllMessages(validator);
- addCancelTask(vmd);
- reporter.displaySubtask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED, new String[]{getProject().getName(), vmd.getValidatorDisplayName()}));
- while (iterator.hasNext()) {
- vmd = (ValidatorMetaData) iterator.next();
- try {
- validator = vmd.getValidator();
- } catch (InstantiationException exc2) {
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
- // Log the reason for the disabled validator
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation::validate(WorkbenchReporter)"); //$NON-NLS-1$
- entry.setTargetException(exc2);
- logger.write(Level.SEVERE, entry);
- }
- continue;
- }
- reporter.displaySubtask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_CLEANUP, new String[]{vmd.getValidatorDisplayName()}));
- reporter.removeAllMessages(validator);
- addCancelTask(vmd);
- reporter.displaySubtask(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED, new String[]{getProject().getName(), vmd.getValidatorDisplayName()}));
- }
- throw exc; // propagate the exception up to the framework so that
- // the framework can display the correct "cancelled"
- // message in the dialog
-
- }
-
- /* package */
- void internalValidate(final WorkbenchReporter reporter, final IValidator validator, final ValidatorMetaData vmd,final IWorkbenchContext aContext, final IFileDelta[] delta) throws OperationCanceledException {
- final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- try {
- checkCanceled(reporter);
- removeOldMessages(reporter, validator, vmd, delta);
- // Do NOT check if the message limit is exceeded before launching
- // the validator.
- // Even if the limit is exceeded when the messages are removed from
- // the delta
- // files, it could be that the validator itself will remove
- // messages before
- // proceeding. Let the validator run so that it can remove messages
- // if it
- // needs to, and if it tries to add a message when the limit is
- // exceeded, let
- // the WorkbenchReporter take care of it.
- launchValidator(reporter, validator, vmd,aContext,delta);
- } catch (OperationCanceledException exc) {
- // This is handled in the validate(WorkbenchReporter) method.
- throw exc;
- } catch (MessageLimitException exc) {
- // Let the finally block handle this case.
- // handleMessageLimit();
- } catch (Throwable exc) {
- // 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.
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation.internalValidate"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- String mssg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION_ABNORMALLY, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(mssg);
- String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.NORMAL_SEVERITY);
- message.setId(ResourceConstants.VBF_EXC_RUNTIME);
- message.setParams(msgParm);
- reporter.addMessage(validator, message);
- } finally {
- // If user fixes problem, and limit exceeded, add "exceeded"
- // message, or
- // if limit not exceeded any more, remove "exceeded" message.
- ValidatorManager.getManager().checkMessageLimit(getProject(), true);
- reporter.getProgressMonitor().done();
- }
- }
-
- /**
- * In order to allow validators to run, must first check if there's space for new markers. But
- * the old markers must not prevent validation from running again (limit exceeded), so delete
- * all of the old markers first, and then run validation.
- */
- private final void removeOldMessages(WorkbenchReporter reporter, IValidator validator, ValidatorMetaData vmd, IFileDelta[] delta) {
- if (reporter == null) {
- return;
- }
- // If the validator has been enabled, remove the "cancel" task.
- // If the validator, on the last run, threw a Throwable, remove the
- // "internal error" task. (For the same reasons we remove the "cancel"
- // task.
- InternalValidatorManager.getManager().removeOperationTasks(getProject(), vmd);
- checkCanceled(reporter);
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- try {
- // Check to see if a full build must be performed, or if a delta
- // build is to be performed, if there are files to verify for that
- // validator. (If it's delta, but there are no files, calling
- // validate on that validator starts a full build, instead of just
- // returning.)
- if (isFullValidate()) {
- String message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_START_REMOVING_OLD_MESSAGES, new String[]{vmd.getValidatorDisplayName(), getProject().getName()});
- reporter.displaySubtask(message);
- reporter.removeAllMessages(validator);
- message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_FINISH_REMOVING_OLD_MESSAGES, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(message);
- } else {
- // Don't need to check that there are deltas to validate
- // because that's already checked in isValidationNecessary
- String message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_START_REMOVING_OLD_MESSAGES, new String[]{vmd.getValidatorDisplayName(), getProject().getName()});
- reporter.displaySubtask(message);
- for (int i = 0; i < delta.length; i++) {
- WorkbenchFileDelta fd = (WorkbenchFileDelta) delta[i];
- if (fd.getDeltaType() != IFileDelta.DELETED) {
- // If the file has been deleted, eclipse erases all
- // markers on the file.
- // Also, when a resource doesn't exist,
- // WorkbenchReporter's getMessageResource()
- // returns the IProject, which means that removing the
- // messages from this
- // file removes all of this validator's messages on
- // this IProject (aix defect 206157)
- IResource resource = reporter.getMessageResource(validator, fd);
- if (fd.getObject().equals(fd.getResource())) {
- WorkbenchReporter.removeAllMessages(resource, validator); // remove
- // all
- // messages
- // from
- // this
- // resource
- } else {
- reporter.removeAllMessages(validator, fd.getObject());
- }
- }
- }
- message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_FINISH_REMOVING_OLD_MESSAGES, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(message);
- }
- } catch (OperationCanceledException exc) {
- throw exc;
- } catch (Throwable exc) {
- // 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.
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation.validate(WorkbenchMonitor)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- String mssg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION_ABNORMALLY, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(mssg);
- String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.NORMAL_SEVERITY);
- message.setId(ResourceConstants.VBF_EXC_RUNTIME);
- message.setParams(msgParm);
- reporter.addMessage(validator, message);
- return;
- }
- }
-
- /**
- * Whether a full verification or a delta verification is in progress, both will call this
- * method to process the resource. This method calls the current Validator to filter the
- * resource (i.e., this method returns if the resource fails the filter test).
- * <code>process</code> also sends output to the <code>IProgressMonitor</code>, and calls
- * the current Validator to validate the resource.
- *
- * To process a resource, there are several steps: 1. check if the resource is registered for
- * this validator (i.e., the validator has either specified it in a filter, or has not filtered
- * it out explicitly) 2. call <code>isValidationSource</code> on the current validator with
- * the current resource. This method performs further filtering by the Validator itself, in
- * addition to the static filtering done by the framework, based on the information in
- * plugin.xml. 3. If the resource passes both filters, call <code>validate</code> on the
- * validator, with the resource. 4. When complete (either by failing to pass a filter, or by the
- * completion of the <code>validate</code>), increment the IProgressMonitor's status by one
- * (i.e., one resource has been processed.)
- */
- private final void launchValidator(WorkbenchReporter reporter, IValidator validator, ValidatorMetaData vmd, IWorkbenchContext helper, IFileDelta[] delta) {
- if (reporter == null) {
- return;
- }
- checkCanceled(reporter);
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- // Check to see if a full build must be performed, or if a delta
- // build is to be performed, if there are files to verify for that
- // validator. (If it's delta, but there are no files, calling
- // validate on that validator starts a full build, instead of just
- // returning.)
- try {
- // Validate the resource; this step will add errors/warnings to the
- // task list, and remove errors/warnings from the task list.
- if (helper instanceof WorkbenchContext) {
- // Initialize the "loadRuleGroup" method with the group of
- // rules
- // which the validator should validate.
- ((WorkbenchContext) helper).setRuleGroup(getRuleGroup());
- }
- long start = System.currentTimeMillis();
- 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.
- getLaunchedValidators().add(vmd);
- }
- //initValidateContext(delta);
- ValidatorLauncher.getLauncher().start(helper, validator, reporter);
- long finish = System.currentTimeMillis();
- if (logger.isLoggingLevel(Level.INFO)) {
- TimeEntry entry = ValidationPlugin.getTimeEntry();
- entry.setSourceID("ValidationOperation.launchValidator"); //$NON-NLS-1$
- entry.setProjectName(getProject().getName());
- entry.setToolName(vmd.getValidatorUniqueName());
- entry.setElapsedTime(finish - start);
- if (logger.isLoggingLevel(Level.FINE)) {
- StringBuffer buffer = new StringBuffer();
- if (isFullValidate()) {
- buffer.append("EVERYTHING"); //$NON-NLS-1$
- } else {
- if (delta.length == 0) {
- buffer.append("NOTHING"); //$NON-NLS-1$
- } else {
- buffer.append(getDeltaAsString(delta));
- }
- }
- entry.setDetails(buffer.toString());
- }
- logger.write(Level.INFO, entry);
- }
- 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) {
- // First, see if a validator just caught all Throwables and
- // 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) {
- 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
- }
- }
- // If there is a problem with this particular validator, log the
- // 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$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- if (exc.getAssociatedException() != null) {
- entry.setTargetException(exc.getAssociatedException());
- logger.write(Level.SEVERE, entry);
- }
- }
- String message = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION_ABNORMALLY, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(message);
- if (exc.getAssociatedMessage() != null) {
- reporter.addMessage(validator, exc.getAssociatedMessage());
- }
- } catch (Throwable exc) {
- // 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.
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation.validate(WorkbenchMonitor)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- String mssg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_ENDING_VALIDATION_ABNORMALLY, new String[]{getProject().getName(), vmd.getValidatorDisplayName()});
- reporter.displaySubtask(mssg);
- String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.NORMAL_SEVERITY);
- message.setId(ResourceConstants.VBF_EXC_RUNTIME);
- message.setParams(msgParm);
- reporter.addMessage(validator, message);
- } finally {
- try {
- validator.cleanup(reporter);
- } catch (MessageLimitException e) {
- throw e;
- } catch (OperationCanceledException e) {
- throw e;
- } catch (Throwable exc) {
- // 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.
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation::launchValidator"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.NORMAL_SEVERITY);
- message.setId(ResourceConstants.VBF_EXC_RUNTIME);
- message.setParams(msgParm);
- try {
- reporter.addMessage(validator, message);
- } catch (MessageLimitException e) {
- throw e;
- }
- return;
- }
- try {
- helper.cleanup(reporter);
- } catch (MessageLimitException e) {
- throw e;
- } catch (OperationCanceledException e) {
- throw e;
- } catch (Throwable exc) {
- // 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.
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationOperation::launchValidator"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- String[] msgParm = {exc.getClass().getName(), vmd.getValidatorDisplayName(), (exc.getMessage() == null ? "" : exc.getMessage())}; //$NON-NLS-1$
- Message message = ValidationPlugin.getMessage();
- message.setSeverity(IMessage.NORMAL_SEVERITY);
- message.setId(ResourceConstants.VBF_EXC_RUNTIME);
- message.setParams(msgParm);
- try {
- reporter.addMessage(validator, message);
- } catch (MessageLimitException e) {
- throw e;
- }
- return;
- } finally {
- // Now that cleanup has been called, set the project to null.
- // This project's
- // resources have been freed so this project should also be
- // cleared on the helper.
- // If it isn't set to null, then the next time that the helper
- // is retrieved from
- // the ValidatorMetaData, the resources allocated for this
- // project, in the
- // helper's initialize method, will not be reallocated if the
- // project is the same.
- helper.setProject(null);
- }
- // Tell the progress monitor that we've completed n units of work
- // (i.e., n resources validated by one validator).
- reporter.getProgressMonitor().worked(((delta == null) ? 1 : delta.length)); // One
- // unit
- // of
- // work
- // = 1
- // (i.e.,
- // 1
- // resource)
- }
- }
-
- private Runnable wrapInRunnable(final WorkbenchReporter reporter, final IValidator validator, final ValidatorMetaData vmd, final IWorkbenchContext helper, final IFileDelta[] delta, final Iterator iterator) {
- // Need to create a new Runnable each time because several Runnable
- // instances may exist at the same time.
- Runnable runnable = new ProjectRunnable(reporter, validator, vmd, helper, delta, iterator);
- return runnable;
- }
-
- /*
- * // For convenience, keep this method in the class but commented out. // When async needs to
- * be tested, this method may be needed again. private static void debug(String prefix,
- * IWorkbenchContext helper) { IProject hProject = helper.getProject(); System.err.println(prefix +
- * "Start ValidationOperation "+Thread.currentThread().getName() + "::" + hProject.getName());
- * if( Thread.currentThread().getName().equals("ValidationThread") &&
- * (hProject.getName().indexOf("noFork") > -1)) { Thread.dumpStack(); } else
- * if((!Thread.currentThread().getName().equals("ValidationThread")) &&
- * (hProject.getName().indexOf("fork") > -1)) { Thread.dumpStack(); } System.err.println(prefix +
- * "End ValidationOperation"); }
- */
- public class ProjectRunnable implements Runnable {
- private WorkbenchReporter _reporter = null;
- private IValidator _validator = null;
- private ValidatorMetaData _vmd = null;
-// private IValidationContext _helper = null;
- private IFileDelta[] __delta = null;
-
- public ProjectRunnable(WorkbenchReporter reporter, IValidator validator, ValidatorMetaData vmd, IWorkbenchContext helper, IFileDelta[] delta, Iterator iterator) {
- _reporter = reporter;
- _validator = validator;
- _vmd = vmd;
-// _helper = helper;
- __delta = delta;
- }
-
- public void run() {
- try {
- internalValidate(_reporter, _validator, _vmd, context,__delta);
- } catch (OperationCanceledException exc) {
- // User can't cancel a job in a background thread, so ignore
- // this exception.
- }
- }
-
- public IProject getProject() {
- return _reporter.getProject();
- }
- }
-
- /**
- * @return Returns the context.
- */
- public IValidationContext getContext() {
- return context;
- }
-
- /**
- * @param context The context to set.
- */
- public void setContext(IWorkbenchContext context) {
- this.context = context;
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 0a2972941..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidationUtility.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.ConfigurationConstants;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.ProjectConfiguration;
-import org.eclipse.wst.validation.internal.TaskListUtility;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-
-/**
- * This class contains utility methods that are intended to be used by validators and code outside
- * of the validation framework.
- */
-public final class ValidationUtility {
- //TODO Make the ValidationUtility constructor private in Milestone 4.
-
- /**
- * Given an IResource and one of the org.eclipse.wst.validation.internal.core.core.SevertyEnum constants,
- * return an array containing the fully-qualified class names of the validators which have
- * reported messages, of the given severity, against the resource and the resource's children.
- */
- public static String[] listValidatorClasses(IResource resource, int severity) {
- IMarker[] markers = TaskListUtility.getValidationTasks(resource, severity);
- if ((markers == null) || (markers.length == 0)) {
- return new String[0];
- }
-
- Set tempSet = new HashSet();
- for (int i = 0; i < markers.length; i++) {
- IMarker marker = markers[i];
- try {
- Object owner = marker.getAttribute(ConfigurationConstants.VALIDATION_MARKER_OWNER);
- if ((owner == null) || !(owner instanceof String)) {
- // The ValidationMigrator will remove any "unowned" validation markers.
- continue;
- }
- tempSet.add(owner);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationUtility.listValidatorClasses(" + resource.getName() + ", " + severity); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
-
- if (tempSet.size() > 0) {
- String[] result = new String[tempSet.size()];
- tempSet.toArray(result);
- tempSet.clear();
- return result;
- }
- return new String[0];
- }
-
- /**
- * @deprecated This instance method will be made static in Milestone 4.
- */
- public boolean isEnabled(IProject project, String validatorClassName) {
- return isEnabled(project, new String[]{validatorClassName});
- }
-
- /**
- * Return true if all of the validators, identified by their fully-qualified class names, are
- * enabled on the project. If a validator isn't enabled, or if there's an internal error while
- * retrieving the user's configuration, return false.
- */
- public static boolean isEnabled(IProject project, String[] validatorClassNames) {
- if ((validatorClassNames == null) || (validatorClassNames.length == 0)) {
- return false;
- }
-
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- for (int i = 0; i < validatorClassNames.length; i++) {
- if (!prjp.isEnabled(validatorClassNames[i])) {
- return false;
- }
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationUtility::isEnabled(" + project.getName() + ", String[])"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return false;
- }
-
- return true;
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 2b6ca7544..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorManager.java
+++ /dev/null
@@ -1,1363 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.InternalValidatorManager;
-import org.eclipse.wst.validation.internal.ProjectConfiguration;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.TaskListUtility;
-import org.eclipse.wst.validation.internal.ValidationConfiguration;
-import org.eclipse.wst.validation.internal.ValidationRegistryReader;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * A centralised class for accessing validation metadata.
- *
- * This class is not intended to be subclassed outside of the validation framework.
- */
-public final class ValidatorManager {
- private static ValidatorManager inst = null;
- private static IResourceUtil _resourceUtil = null; // a common utility, different whether or not
- // WSAD is running in headless or UI mode,
- // which can retrieve the line number of some
- // 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 = null;
- private boolean _suspendAllValidation = false;
- private static Class _messageLimitOwner = null;
- private String[] _internalOwners = null;
-
- public static HashMap messageLimitProjectMap = null;
- public static HashMap messageLimitMessageProjectMap = null;
-
- /**
- * ValidatorManager constructor comment.
- */
- private ValidatorManager() {
- super();
- _suspendedProjects = new HashSet();
- _internalOwners = new String[0];
-
- addInternalOwner(getMessageLimitOwner());
- }
-
- /**
- * Disable all validators for the current project, and does not touch the auto-validate setting.
- */
- public void disableAllValidators(IProject currentProject, IProgressMonitor monitor) {
- // Disable the individual validators
- setEnabledValidators(currentProject, EMPTY_SET, monitor);
- }
-
- /**
- * Given an IProject, if the IProject does not support build validation, add the validation
- * builder to the project description so that the project can support bulid validation.
- */
- public static void addProjectBuildValidationSupport(IProject project) {
- if (project == null) {
- return;
- }
-
- boolean isBuilderAdded = false;
- try {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec(); // don't need to check if description
- // is null, because it's never null
- if (commands != null) {
- for (int i = 0; i < commands.length; i++) {
- String builderName = commands[i].getBuilderName();
- if (builderName == null) {
- // builder name will be null if it has not been set
- continue;
- }
-
- if (builderName.equals(ValidationPlugin.VALIDATION_BUILDER_ID)) {
- isBuilderAdded = true;
- break;
- }
- }
- }
-
- if (!isBuilderAdded) {
- ICommand newCommand = description.newCommand();
- newCommand.setBuilderName(ValidationPlugin.VALIDATION_BUILDER_ID);
-
- ICommand[] newCommands = null;
- if (commands != null) {
- newCommands = new ICommand[commands.length + 1];
- System.arraycopy(commands, 0, newCommands, 0, commands.length);
- newCommands[commands.length] = newCommand;
- } else {
- newCommands = new ICommand[1];
- newCommands[0] = newCommand;
- }
- description.setBuildSpec(newCommands);
-
- project.setDescription(description, null);
- }
- } catch (CoreException exc) {
- // if we can't read the information, the project isn't open, so it can't run
- // auto-validate
- return;
- }
- }
-
-
- /**
- * Given an IProject, this method returns true if the project can run build validation (i.e.,
- * incremental validation), and false otherwise. The test, to find out if the project supports
- * build validation or not, is to see if the ValidationBuilder is configured on that type of
- * project.
- *
- * This is a long-running process - is there any way that I can shorten the amount of time this
- * takes?
- */
- public static boolean doesProjectSupportBuildValidation(IProject project) {
- boolean canRunAV = false;
- if (project == null) {
- return canRunAV;
- }
-
- try {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec(); // don't need to check if description
- // is null, because it's never null
- if (commands == null) {
- return canRunAV;
- }
-
- for (int i = 0; i < commands.length; i++) {
- String builderName = commands[i].getBuilderName();
- if (builderName == null) {
- // builder name will be null if it has not been set
- continue;
- }
-
- if (builderName.equals(ValidationPlugin.VALIDATION_BUILDER_ID)) {
- canRunAV = true;
- break;
- }
- }
- } catch (CoreException exc) {
- // if we can't read the information, the project isn't open, so it can't run
- // auto-validate
- return false;
- }
-
- return canRunAV;
- }
-
- /**
- * Enable all validators for the current project, and does not touch the auto-validate setting.
- */
- public void enableAllValidators(IProject project, IProgressMonitor monitor) {
- // Turn auto-validate off
- // setAutoValidate(currentProject, false);
-
- // Enable the individual validators
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- prjp.setEnabledValidators(prjp.getValidators());
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorManager::enableAllValidators(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * Return a collection of incremental ValidatorMetaData configured on a certain type of IProject
- * (e.g. EJB Project vs. Web Project).
- */
- public Set getProjectConfiguredIncrementalValidators(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return InternalValidatorManager.wrapInSet(prjp.getIncrementalValidators());
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorManager::getProjectConfiguredIncrementalValidators(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return Collections.EMPTY_SET;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * Return a collection of ValidatorMetaData configured on a certain type of IProject (e.g. EJB
- * Project vs. Web Project).
- *
- * If the collection has not been calculated before, calculate it now, and cache the result.
- */
- public Set getProjectConfiguredValidatorMetaData(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return InternalValidatorManager.wrapInSet(prjp.getValidators());
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorManager::getProjectConfiguredValidatorMetaData(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return Collections.EMPTY_SET;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * Return a collection of ValidatorMetaData enabled on a certain type of IProject (e.g. EJB
- * Project vs. Web Project). The second parameter, isIncremental, identifies whether it's the
- * incremental, or non-incremental, validators which should be returned. If the parameter is
- * true, return incremental validators. If the parameter is false, return nonincremental
- * validators.
- */
- public Set getProjectEnabledIncrementalValidators(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(true));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::getProjectEnabledIncrementalValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return Collections.EMPTY_SET;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * Return a collection of ValidatorMetaData enabled on a certain type of IProject (e.g. EJB
- * Project vs. Web Project). The second parameter, isIncremental, identifies whether it's the
- * incremental, or non-incremental, validators which should be returned. If the parameter is
- * true, return incremental validators. If the parameter is false, return nonincremental
- * validators.
- */
- public Collection getProjectEnabledNonIncrementalValidators(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return InternalValidatorManager.wrapInSet(prjp.getEnabledIncrementalValidators(false));
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::getProjectEnabledNonIncrementalValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return Collections.EMPTY_SET;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * Returns a Vector of all ValidatorMetaData who are both configured on this type of project,
- * and who are also enabled by this project. If the list of enabled validators hasn't been
- * loaded into the cache, load it now. Otherwise, just return it.
- */
- public Set getProjectEnabledValidators(IProject project) {
- return getEnabledValidators(project);
- }
-
- public static ValidatorManager getManager() {
- if (inst == null) {
- inst = new ValidatorManager();
- }
- return inst;
- }
-
- public static IResourceUtil getResourceUtil() {
- if (_resourceUtil == null) {
- if (_resourceUtilClass == null) {
- // Since the value returned from this method must never be null,
- // default the resource util to the headless resource util.
- _resourceUtilClass = RESOURCEUTIL_DEFAULTCLASS;
- }
-
- try {
- _resourceUtil = (IResourceUtil) _resourceUtilClass.newInstance();
- } catch (ClassCastException e) {
- _resourceUtil = null;
- } catch (InstantiationException e) {
- _resourceUtil = null;
- } catch (IllegalAccessException e) {
- _resourceUtil = null;
- }
- }
- return _resourceUtil;
- }
-
- /**
- * @deprecated This method is intended for use only by the validation framework. It will be
- * moved to a class in the "internal" package at some time.
- */
- public IMarker[] getValidationTasks(int severity, IProject project) {
- return getValidationTasks(project, severity);
- }
-
- /**
- * @deprecated This method is intended for use only by the validation framework. It will be
- * moved to a class in the "internal" package at some time.
- */
- public IMarker[] getValidationTasks(IResource resource, int severity) {
- return TaskListUtility.getValidationTasks(resource, severity);
- }
-
- /**
- * @deprecated This method is intended for use only by the validation framework. It will be
- * moved to a class in the "internal" package at some time.
- */
- public IMarker[] getValidationTasks(IResource resource, String[] validatorNames) {
- return TaskListUtility.getValidationTasks(resource, validatorNames);
- }
-
- public int getMaximumMessagesAllowed(IProject project) {
- try {
- return ConfigurationManager.getManager().getProjectConfiguration(project).getMaximumNumberOfMessages();
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.getMaximumMessagesAllowed(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
-
- return ValidationConfiguration.getMaximumNumberOfMessagesDefault();
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- */
- public ValidatorMetaData getValidatorMetaData(IValidator validator) {
- return ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- }
-
- /**
- * @deprecated For use by the validation framework only.
- */
- public Set getIncrementalValidators(Collection vmds) {
- if (vmds == null) {
- return Collections.EMPTY_SET;
- }
-
- Set result = new HashSet();
- Iterator iterator = vmds.iterator();
- while (iterator.hasNext()) {
- ValidatorMetaData vmd = (ValidatorMetaData) iterator.next();
- if (vmd.isIncremental()) {
- result.add(vmd);
- }
- }
- return result;
- }
-
-
- /**
- * Return true if the validator identified by validatorId will validate the given resource. If
- * either parameter is null, false is returned. If the validator is not registered with the
- * validation framework (i.e., either no validator in the activated plugins is identified by
- * that plugin id, or the given IResource's project does not run that particular validator),
- * then this method will return false.
- */
- public boolean isApplicableTo(String validatorId, IResource res) {
- if ((validatorId == null) || (res == null)) {
- return false;
- }
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorId);
- if (vmd == null) {
- // validator not registered with the framework
- return false;
- }
-
- if (!ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, res.getProject())) {
- return false;
- }
-
- return vmd.isApplicableTo(res);
- }
-
-
- public boolean isAutoValidate(IProject project) {
- return isAutoValidate(project, isGlobalAutoBuildEnabled());
- }
-
- /**
- * Keeping this API around so as not to break existing code.
- *
- * @deprecated use isAutoValidate
- */
- public boolean isAutoValidateChecked(IProject project) {
- return isAutoValidate(project);
- }
-
- /**
- * Keeping this API around so as not to break existing code.
- *
- * @deprecated use isAutoValidate
- */
- public boolean isAutoValidateChecked(IProject project, boolean isGlobalAutoBuildOn) {
- return isAutoValidate(project, isGlobalAutoBuildOn);
- }
-
- /**
- * This method returns true if validate will run when there is a resource change. The following
- * attributes are checked: 1. does this project have auto-validate on or off? 2. if this project
- * does not have an auto-validate value set, is the global auto-validate preference on? 3. if 1
- * or 2 is true, does the project support auto-validate? 4. if 1/2, & 3, is auto-build on? 5. if
- * 1/2, 3, and 4, is there at least one incremental validator enabled on the project?
- */
- public boolean isAutoValidate(IProject project, boolean isGlobalAutoBuildOn) {
- try {
- // 1. does the project have auto-validate on or off?
- boolean isAutoValidate = ConfigurationManager.getManager().getProjectConfiguration(project).isAutoValidate();
- if (!isAutoValidate) {
- return false;
- }
-
- // 3. does the project support auto-validate?
- // 4. is auto-build on?
- // 5. is there at least one incremental validator enabled on the project?
- /*
- * Auto-validation, on the properties page, can be enabled under these conditions: 1.
- * the project supports auto-validation, AND 2. fhe platform's global "automatically
- * build" is selected, AND 3. at least one of the project's validators supports
- * incremental validation. Without #1, the ValidationBuilder is never called because
- * it's not configured on the project. Without #2, the ValidationBuilder will not be
- * called because auto-building is turned off. Without #3, the ValidationBuilder will be
- * called, but there's no point because no validators can run.
- */
- return canAutoValidateButtonBeEnabled(project, isGlobalAutoBuildOn);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.canAutoValidateButtonBeEnabled(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
-
- // If the user's setting can't be retrieved, return the default
- return ValidationConfiguration.getAutoValidateDefault();
- }
- }
-
- public boolean canAutoValidateButtonBeEnabled(IProject project) {
- return canAutoValidateButtonBeEnabled(project, isGlobalAutoBuildEnabled());
- }
-
- /**
- * @deprecated For use by the validation framework only.
- */
- public Set getEnabledIncrementalValidators(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- ValidatorMetaData[] vmds = prjp.getEnabledIncrementalValidators(true);
- return InternalValidatorManager.wrapInSet(vmds);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::getEnabledIncrementalValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return Collections.EMPTY_SET;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * 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) {
- if ((project == null) || (enabledVal == null) || (enabledVal.length == 0)) {
- return Collections.EMPTY_SET;
- }
-
- Set val = new HashSet();
- for (int i = 0; i < enabledVal.length; i++) {
- ValidatorMetaData vmd = (ValidatorMetaData) enabledVal[i];
- if (!vmd.isConfiguredOnProject(project)) {
- continue;
- }
-
- if (!getIncremental || vmd.isIncremental()) {
- val.add(vmd);
- }
- }
- return val;
- }
-
- public boolean containsIncrementalValidators(Object[] enabledVal) {
- if ((enabledVal == null) || (enabledVal.length == 0)) {
- return false;
- }
-
- for (int i = 0; i < enabledVal.length; i++) {
- ValidatorMetaData vmd = (ValidatorMetaData) enabledVal[i];
-
- if (vmd.isIncremental()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * For use by the validation framework only.
- */
- protected Set getEnabledValidators(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- ValidatorMetaData[] vmds = prjp.getEnabledValidators();
- return InternalValidatorManager.wrapInSet(vmds);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::getEnabledValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return Collections.EMPTY_SET;
- }
- }
-
- /**
- * This method is for use only by the validation framework. Update the task list based on which
- * validators are enabled or disabled. This method should be called only by the validation
- * framework UI classes. Remove the messages belonging to disabled validators.
- */
- public void updateTaskList(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- ValidatorMetaData[] vmds = prjp.getDisabledValidators();
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- // For validators who aren't going to run, clear their messages from the task list.
- // Don't need to check for duplicate entries because each Validator must be unique.
- // The uniqueness of each Validator is checked by the plugin registry.
- WorkbenchReporter.removeAllMessages(project, vmd.getValidatorNames(), null);
- }
-
- if (prjp.numberOfEnabledValidators() > 0) {
- ValidatorManager.getManager().checkMessageLimit(project, false); // Do not remove
- // the exceeded
- // message; only
- // ValidationOperation
- // should do that
- // because it's
- // about to run
- // validation. If
- // the limit is
- // increased,
- // messages may
- // still be
- // missing, so
- // don't remove the
- // "messages may be
- // missing"
- // message.
- } else {
- // Can't run validation, so remove the "exceeded" message
- ValidatorManager.getManager().removeMessageLimitExceeded(project);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.updateTaskList(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
-
- public boolean canAutoValidateButtonBeEnabled(IProject project, boolean isGlobalAutoBuildOn) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- boolean incrementalValEnabled = (prjp.numberOfEnabledIncrementalValidators() > 0);
- return canAutoValidateButtonBeEnabled(project, isGlobalAutoBuildOn, incrementalValEnabled);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::canAutoValidateButtonBeEnabled" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return false;
- }
- }
-
- public boolean canAutoValidateButtonBeEnabled(IProject project, boolean isGlobalAutoBuildOn, boolean incrementalValEnabled) {
- boolean doesProjectSupportAutoValidate = doesProjectSupportBuildValidation(project);
- return (doesProjectSupportAutoValidate && isGlobalAutoBuildOn && incrementalValEnabled);
- }
-
- /**
- * Return true if the validator identified by the String is configured on the IProject and
- * enabled on the IProject. Otherwise return false;
- */
- public boolean isEnabled(IProject project, String validatorName) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return prjp.isEnabled(validatorName);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.isEnabled(" + project.getName() + ", " + validatorName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return false;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only. Return true if the ValidatorMetaData is
- * enabled for the given project
- */
- public boolean isEnabled(IProject project, ValidatorMetaData vmd) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return prjp.isEnabled(vmd);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::isEnabled" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return false;
- }
- }
-
- /**
- * @deprecated For use by the validation framework only.
- */
- public boolean isConfigured(IProject project, ValidatorMetaData vmd) {
- return ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, project);
- }
-
- /**
- * This method returns true if the global auto-build setting is turned on.
- */
- public boolean isGlobalAutoBuildEnabled() {
- return ResourcesPlugin.getWorkspace().isAutoBuilding();
- }
-
- /**
- * Returns the number of enabled validators on the given project.
- */
- public int numberProjectEnabledValidators(IProject project) {
- if (project == null) {
- return 0;
- }
-
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- return prjp.numberOfEnabledValidators();
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager::numberProjectEnabledValidators" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return 0;
- }
- }
-
- /**
- * @deprecated
- *
- * Use the suspendValidation(IProject, boolean) or suspendAllValidation(boolean) method instead.
- * This method does not guarantee that validation will be suspended. If the project is
- * overriding the preferences then validation will be suspended; otherwise validation will be
- * performed.
- *
- * Programmatically changing the value of the project's preferences may be done only by the
- * validation framework.
- */
- public void setAutoValidate(IProject project, boolean auto) {
- try {
- ConfigurationManager.getManager().getProjectConfiguration(project).setAutoValidate(auto);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.setAutoValidate(" + project.getName() + ", " + auto + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- /**
- * Suspends, or undoes the suspension of, validation on the current project. If "suspend" is
- * true then validation is suspended and if it's "false" then validation will run on the
- * project. The value of this variable is not persisted.
- *
- * Be VERY CAREFUL when you use this method! Turn validation back on in a finally block because
- * if the code which suspended validation crashes, the user has no way to unsuspend validation.
- * The user will have to shut down & restart WSAD to get validation to work again.
- *
- * If an operation is used to make changes that should not be validated, then use the technique
- * documented in the "Preventing Validation" topic of the "Validation Guide" (in the
- * 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.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.
- if (suspend) {
- _suspendedProjects.add(project);
- } else {
- _suspendedProjects.remove(project);
- }
- }
-
- /**
- * Suspends, or undoes the suspension of, validation on all projects in the workbench. If
- * "suspend" is true then validation is suspended and if it's "false" then validation will run.
- * The value of this variable is not persisted.
- *
- * Be VERY CAREFUL when you use this method! Turn validation back on in a finally block because
- * if the code which suspended validation crashes, the user has no way to unsuspend validation.
- * The user will have to shut down & restart WSAD to get validation to work again.
- *
- * If an operation is used to make changes that should not be validated, then use the technique
- * documented in the "Preventing Validation" topic of the "Validation Guide" (in the
- * org.eclipse.wst.validation.internal.provisional.core.core.prop plugin). If you don't, validation may not be suspended.
- */
- public void suspendAllValidation(boolean suspend) {
- _suspendAllValidation = suspend;
- }
-
- /**
- * Return true if "suspend all" is enabled, false otherwise.
- */
- public boolean isSuspended() {
- return _suspendAllValidation;
- }
-
- /**
- * Returns true if validation will not run on the project because it's been suspended. This
- * method checks only the suspension status; if validation cannot run for some other reason (for
- * example, there are no enabled validators), yet the IProject is not suspended, this method
- * will return true even though validation will not run.
- */
- public boolean isSuspended(IProject project) {
- if (project == null) {
- return false;
- }
-
- if (_suspendAllValidation) {
- return true;
- }
-
- return _suspendedProjects.contains(project);
- }
-
- /**
- * This method should be called by any code that is preparing to suspend validation on a
- * project. Rather than calling isSuspsend(IProject), which will return true if all validation
- * has been suspended, this method returns the state of the project itself. See the
- * ValidationMigrator::migrateProject for an example.
- *
- * @param project
- * @return boolean
- */
- public boolean isProjectSuspended(IProject project) {
- if (project == null) {
- return false;
- }
-
- return _suspendedProjects.contains(project);
- }
-
- /**
- * @deprecated For use by the validation framework only.
- *
- * 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) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- ValidatorMetaData[] vmds = null;
- if (vmdsSet == null) {
- vmds = new ValidatorMetaData[0];
- } else {
- vmds = new ValidatorMetaData[vmdsSet.size()];
- vmdsSet.toArray(vmds);
- }
-
- prjp.setEnabledValidators(vmds);
-
- updateTaskList(project);
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.setEnabledValidators(" + project.getName() + ", Set, IProgressMonitor)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- public static void setResourceUtilClass(Class clazz) {
- _resourceUtilClass = clazz;
- }
-
- public boolean isMessageLimitExceeded(IResource resource) {
- if(resource == null) {
- return false;
- }
- if(!resource.exists()) {
- return false;
- }
- IProject project = resource.getProject();
- if(isNoMessageLimit(project)) {
- return false;
- }
- try {
- //IMarker[] valTasks = getValidationTasks(project,SeverityEnum.ALL_MESSAGES);
- initializeMessageLimitProjectMap(project);
- Object messagesAddedForProject = messageLimitProjectMap.get(project);
- int valTasks = ((Integer) messagesAddedForProject).intValue();
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- int max = prjp.getMaximumNumberOfMessages();
- initializeMessageLimitMessageProjectMap();
- Object messageLimitMessageAdded = messageLimitMessageProjectMap.get(project);
- boolean isMessageLimitMessageAdded = false;
- if(messageLimitMessageAdded != null) {
- isMessageLimitMessageAdded = ((Boolean)messageLimitMessageAdded).booleanValue();
- }
- if (valTasks >= max || isMessageLimitMessageAdded) {
- IMarker[] exceededTasks = getLimitMessage(project);
- int numExceeded = (exceededTasks == null) ? 0 : exceededTasks.length;
- // Excluding the "max messages were reported" messages, do the
- // number of validation messages exceed the limit?
- int numValTasks = valTasks - numExceeded;
- if (numValTasks > max) {
- return true;
- }
- // If the "max were reported" exists, does the number of
- // messages equal the limit?
- if ((numExceeded > 0) && (numValTasks == max)) {
- return true;
- }
- }
- }
- catch(InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.setEnabledValidators(" + project.getName() + ", Set, IProgressMonitor)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if(exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- return false;
- }
-
- public static void initializeMessageLimitProjectMap(IProject project) {
- if(messageLimitProjectMap == null)
- messageLimitProjectMap = new HashMap();
- if(messageLimitProjectMap.get(project) == null)
- messageLimitProjectMap.put(project,new Integer(0));
- }
-
- public static void setMessageLimitMessageForProject(IProject project) {
- initializeMessageLimitMessageProjectMap();
- messageLimitMessageProjectMap.put(project, Boolean.TRUE);
- }
-
- private static void initializeMessageLimitMessageProjectMap() {
- if(messageLimitMessageProjectMap == null)
- messageLimitMessageProjectMap = new HashMap();
- }
-
- /**
- * This method is for use by batch EJB deploy only. Only in batch mode is an infinitie number of
- * messages allowed.
- *
- * Enable a project to have an infinite number of messages.
- */
- public void setNoMessageLimit(IProject project) {
- setMessageLimit(project, WorkbenchReporter.NO_MESSAGE_LIMIT);
- }
-
- /**
- * This method is for use by batch EJB deploy only. Only in batch mode is an infinitie number of
- * messages allowed.
- *
- * Return true if the given project is allowed an infinite number of validation messages.
- */
- public boolean isNoMessageLimit(IProject project) {
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- int max = prjp.getMaximumNumberOfMessages();
- if (max == WorkbenchReporter.NO_MESSAGE_LIMIT) {
- return true;
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.setEnabledValidators(" + project.getName() + ", Set, IProgressMonitor)"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- return false;
- }
-
- /**
- * This method is for use by the validation framework only.
- */
- public void setMessageLimit(IProject project, int limit) {
- try {
- if ((limit == WorkbenchReporter.NO_MESSAGE_LIMIT) || (limit >= 0)) {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- if (!prjp.doesProjectOverride()) {
- prjp.setDoesProjectOverride(true);
- }
- prjp.setMaximumNumberOfMessages(limit);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.setMessageLimit(" + project.getName() + ", " + limit + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- /**
- * @deprecated This method should be used only by the validation framework. If a validator
- * validates more than one project, then a try-catch block should wrap the
- * validation of each project, and the MessageLimitException should be caught. In
- * the catch(MessageLimitException) block, this method should be called so that the
- * appropriate message can be added to the task list: "validation was terminated
- * because the maximum number of messages was reported"
- */
- public boolean checkMessageLimit(IProject project) {
- return checkMessageLimit(project, true);
- }
-
- /**
- * @deprecated This method should be used only by the validation framework.
- */
- public boolean checkMessageLimit(IProject project, Iterator iterator) {
- return checkMessageLimit(project, false);
- }
-
- /**
- * This method is intended to be used only by the validation framework. This method should be
- * used by the validation operation to add/remove the "exceeded" message. Return true if the
- * project is under the limit of messages, false otherwise.
- */
- public boolean checkMessageLimit(IProject project, boolean removeExceededMessage) {
- if (project == null) {
- return true;
- }
-
- if (!isMessageLimitExceeded(project)) {
- if (removeExceededMessage) {
- // If the max was exceeded before, but isn't exceeded now,
- // remove the "exceeded" message.
- removeMessageLimitExceeded(project);
- }
- return true;
- }
-
- // This method is called under two conditions:
- // 1. The UI's message limit has changed, and some messages may need to be removed. The
- // "exceeded" message is never removed.
- // 2. The ValidationOperation has run, and the exceeded message may need to be added or
- // removed.
- boolean result = true;
- try {
- ProjectConfiguration prjp = ConfigurationManager.getManager().getProjectConfiguration(project);
- int max = prjp.getMaximumNumberOfMessages();
- IMarker[] markers = getValidationTasksWithoutLimitMessage(project);
- int numExceededMarkers = markers.length - max; // Excluding the "limit was exceeded"
- // message, this is the number of extra
- // markers.
- if (numExceededMarkers >= 0) { // Will be == max if last time val run, maximum reported.
- // Remove some markers; these markers are chosen arbitrarily.
- int index = (max >= 0) ? (max) : 0;
- IMarker[] removeMarkers = new IMarker[numExceededMarkers];
- System.arraycopy(markers, index, removeMarkers, 0, numExceededMarkers);
- try {
- ResourcesPlugin.getWorkspace().deleteMarkers(removeMarkers);
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorManager.checkMessageLimit(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- result = false;
-
- if (max > 0) {
- // If max <= 0, user doesn't want to see anything
- // If exceeded message doesn't exist, add it.
- addMessageLimitExceeded(project);
- }
- } else if (removeExceededMessage) {
- removeMessageLimitExceeded(project);
- }
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceIdentifier("ValidatorManager.checkMessageLimit(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return true;
- }
-
- return result;
- }
-
- /**
- * @deprecated This method should be used by the validation operation to add/remove the
- * "exceeded" message.
- */
- public boolean checkMessageLimit(IProject project, Iterator iterator, boolean removeExceededMessage) {
- return checkMessageLimit(project, removeExceededMessage);
- }
-
- /**
- * This message is for use only by the validation framework. If the "max messages were reported"
- * IMarker exists, return it. Otherwise return null.
- */
- private IMarker[] getLimitMessage(IProject project) {
- IMarker[] exceededMessage = TaskListUtility.getValidationTasks(project, WorkbenchReporter.getUniqueId(getMessageLimitOwner()));
- if ((exceededMessage != null) && (exceededMessage.length != 0)) {
- return exceededMessage;
- }
-
- return null;
- }
-
- /**
- * Return true if the given IMarker is a "limit was exceeded" message, false otherwise.
- */
- private boolean isLimitMessage(IMarker marker) {
- if (marker == null) {
- return false;
- }
-
- return TaskListUtility.isOwner(marker, WorkbenchReporter.getUniqueId(getMessageLimitOwner()));
- }
-
- /**
- * Return all of the IMarkers on the IProject excluding the "limit was exceeded" message. If
- * there are no markers, return null.
- */
- private IMarker[] getValidationTasksWithoutLimitMessage(IProject project) {
- IMarker[] allTasks = TaskListUtility.getValidationTasks(project, IMessage.ALL_MESSAGES);
- if ((allTasks == null) || (allTasks.length == 0)) {
- return null;
- }
-
- // Don't check if the limit message exists because
- // any interaction with markers is costly. Since the
- // interaction has to be done at least once, make that
- // single occasion in the for loop below.
- IMarker[] validatorMessages = new IMarker[allTasks.length];
- int count = 0; // how many markers have been added to the result array?
- for (int i = 0; i < allTasks.length; i++) {
- IMarker marker = allTasks[i];
- if (isLimitMessage(marker)) {
- continue;
- }
- validatorMessages[count++] = marker;
- }
-
- IMarker[] result = new IMarker[count];
- System.arraycopy(validatorMessages, 0, result, 0, count);
- return result;
- }
-
- /**
- * This method should be called only by the validation framework. Return true if the message was
- * removed, false if the message didn't exist.
- */
- public boolean removeMessageLimitExceeded(IProject project) {
- IMarker[] exceededMessage = getLimitMessage(project);
- if (exceededMessage != null) {
- try {
- ResourcesPlugin.getWorkspace().deleteMarkers(exceededMessage);
- return true;
- } catch (CoreException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidatorManager.removeMessageLimitExceeded(" + project.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- return false;
- }
-
- /**
- * Return true if the last validation operation terminated due to the maximum number of messages
- * having already been reported.
- */
- public boolean wasValidationTerminated(IProject project) {
- IMarker[] exceededMessage = getLimitMessage(project);
- return (exceededMessage != null); // Validation was terminated if the message exists.
- }
-
- private Class getMessageLimitOwner() {
- if (_messageLimitOwner == null) {
- _messageLimitOwner = getClass();
- }
- return _messageLimitOwner;
- }
-
- /**
- * Return true if owner is the name of the class which owns validation framework status
- * messages.
- *
- * ONLY the validation framework should use this method.
- */
- public boolean isInternalOwner(String owner) {
- if (owner == null) {
- return false;
- }
-
- for (int i = 0; i < _internalOwners.length; i++) {
- String internalOwner = _internalOwners[i];
- if (owner.equals(internalOwner)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Add a class to the list of owners of validation messages. ONLY by the validation framework
- * should use this method (it is used for messages owned by framework classes or classes used by
- * the TVT plugin.)
- */
- public void addInternalOwner(Class clazz) {
- if (clazz == null) {
- return;
- }
-
- String[] tempInternalOwners = new String[_internalOwners.length + 1];
- if (_internalOwners.length > 0) {
- System.arraycopy(_internalOwners, 0, tempInternalOwners, 0, _internalOwners.length);
- }
- tempInternalOwners[_internalOwners.length] = WorkbenchReporter.getUniqueId(clazz);
-
- _internalOwners = tempInternalOwners;
- }
-
-
- /**
- * @deprecated This method should be used only by the validation framework.
- */
- public void addMessageLimitExceeded(IProject project, Iterator iterator) {
- addMessageLimitExceeded(project);
- }
-
- /**
- * This method should be used only by the validation framework.
- */
- public void addMessageLimitExceeded(IProject project) {
- // if the message exists already, don't add it again.
- IMarker[] exceededMessage = getLimitMessage(project);
- if (exceededMessage == null) {
- IMessage message = new Message(ValidationPlugin.VALIDATION_PROP_FILE_NAME, IMessage.LOW_SEVERITY, ResourceConstants.VBF_TASK_WARN_MESSAGE_LIMIT_VAL);
- WorkbenchReporter.addMessage(project, getMessageLimitOwner(), message);
- }
- }
-
-} \ No newline at end of file
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
deleted file mode 100644
index f5aee2d09..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/ValidatorSubsetOperation.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.validation.internal.FilterUtil;
-import org.eclipse.wst.validation.internal.InternalValidatorManager;
-import org.eclipse.wst.validation.internal.RegistryConstants;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.ResourceHandler;
-import org.eclipse.wst.validation.internal.ValidationRegistryReader;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-
-
-/**
- * Run some validators on a given IProject. Any validators which cannot be loaded or which are not
- * registered against this type of project will be ignored.
- *
- * This operation is not intended to be subclassed outside of the validation framework.
- */
-public class ValidatorSubsetOperation extends ValidationOperation {
- protected static final String DEFAULT_DEFAULTEXTENSION = null; // By default, assume that there
-
- // is no default fallback
- // extension
-
- /**
- * Create an operation that runs a full validation on the named validators either if validation
- * needs to (@see ValidatorSubsetOperation(IProject)) or if <code>force</code> is true.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public ValidatorSubsetOperation(IProject project, boolean force, boolean async) {
- this(project, force, RegistryConstants.ATT_RULE_GROUP_DEFAULT, async);
- }
-
- /**
- * Create an operation that runs a full validation on the named validators using the
- * <code>ruleGroup</code> pass. Use this constructor only if you want to run a validator that
- * supports the two passes: FAST and FULL.
- *
- * If force is true, validation is run whether or not it needs to.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public ValidatorSubsetOperation(IProject project, IWorkbenchContext aWorkenchContext, boolean force, int ruleGroup, boolean async) {
- super(project, aWorkenchContext, null, null, ruleGroup, force, async);
- }
-
-
- /**
- * Create an operation that runs a full validation on the named validators using the
- * <code>ruleGroup</code> pass. Use this constructor only if you want to run a validator that
- * supports the two passes: FAST and FULL.
- *
- * If force is true, validation is run whether or not it needs to.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public ValidatorSubsetOperation(IProject project, boolean force, int ruleGroup, boolean async) {
- super(project, null, null, ruleGroup, force, async);
- }
-
- /**
- * The fileExtension parameter must be ".X", where X is the extension. Do not type "*.X" or "X"
- * (i.e., without the dot). The parameter could also be the file name, e.g. "foo.X".
- *
- * This constructor should be used when the invoker wishes to force validation on certain
- * resources, without waiting for the user to save their changes.
- *
- * An IllegalArgumentException is thrown if there are no validators registered for the
- * fileExtension on the given IProject.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public ValidatorSubsetOperation(IProject project, String fileExtension, Object[] changedResources, boolean async) throws IllegalArgumentException {
- this(project, fileExtension, DEFAULT_DEFAULTEXTENSION, changedResources, async);
- }
-
- /**
- * The fileExtension parameter must be ".X", where X is the extension. Do not type "*.X" or "X"
- * (i.e., without the dot). The parameter could also be the file name, e.g. "foo.X".
- *
- * This constructor should be used when the invoker wishes to force validation on certain
- * resources, without waiting for the user to save their changes.
- *
- * If there are no validators configured on files named ".X", then use the validators configured
- * on validators named ".Y", where defaultExtension identifies the fallback extension to use.
- * defaultExtension follows the same syntax as fileExtension.
- *
- * An IllegalArgumentException is thrown if there are no validators registered for the
- * fileExtension or defaultExtension on the given IProject.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public ValidatorSubsetOperation(IProject project, String fileExtension, String defaultExtension, Object[] changedResources, boolean async) throws IllegalArgumentException {
- super(project, shouldForce(changedResources), async);
-
- boolean filterIn = false; // force the resources to be filtered in even if the validator
- // doesn't normally take them?
- ValidatorMetaData[] vmds = InternalValidatorManager.getManager().getValidatorsForExtension(project, fileExtension); // return
- // a
- // list
- // of
- // validators
- // which
- // are
- // configured
- // to
- // run
- // on
- // files
- // with
- // that
- // extension.
- // A
- // validator
- // will
- // be
- // in
- // the
- // list
- // whether
- // it
- // has
- // been
- // enabled
- // or
- // disabled
- // by
- // the
- // user.
- if ((defaultExtension != null) && ((vmds == null) || (vmds.length == 0))) {
- filterIn = true;
- vmds = InternalValidatorManager.getManager().getValidatorsForExtension(project, defaultExtension);
- }
-
- if ((vmds == null) || (vmds.length == 0)) {
- throw new IllegalArgumentException();
- }
-
- setEnabledValidators(InternalValidatorManager.wrapInSet(vmds));
-
- setFileDeltas(FilterUtil.getFileDeltas(getEnabledValidators(), changedResources, filterIn)); // construct
- // an
- // array
- // of
- // IFileDelta[]
- // to
- // wrap
- // the
- // Object[];
- // one
- // IFileDelta
- // for
- // each
- // Object
- // in
- // the
- // array
- }
-
- /**
- * This constructor is provided for the validation async testing, and is not intended to be
- * called outside the validation framework.
- *
- * Run validation on the changed resources with the given validators. All resources must be from
- * the same project; if they're not, an IllegalArgumentException will be thrown. All validators
- * must be able to run on the resources' project; if not, an IllegalArgumentException will be
- * thrown. If the vmds are either empty or null, an IllegalArgumentExeption will be thrown. If
- * the project is closed or doesn't exist then an IllegalArgumentException will be thrown.
- *
- * The ifileDeltaType is one of the IFileDelta constants: ADDED, CHANGED, or DELETED.
- *
- * IProject must exist and be open.
- *
- * If async is true, the validation will run all thread-safe validators in the background
- * validation thread, and all other validators in the main thread. If async is false, all
- * validators will run in in the main thread.
- */
- public ValidatorSubsetOperation(IProject project, ValidatorMetaData[] vmds, IResource[] changedResources, int ifileDeltaType, boolean force, boolean async) throws IllegalArgumentException {
- // Have to have the IProject as a parameter because ValidationOperation needs the IProject,
- // and the super(..)
- // must be called before anything else in this constructor is called.
- super(project, force, async);
-
- if ((vmds == null) || (vmds.length == 0)) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_BADVMD));
- }
-
- if (!project.isOpen()) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_OPENPRJ, new String[]{project.getName()}));
- }
- if (!project.exists()) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_EXISTPRJ, new String[]{project.getName()}));
- }
-
- if ((changedResources != null) && (changedResources.length > 0)) {
- Set tempSet = new HashSet();
- for (int i = 0; i < changedResources.length; i++) {
- IProject p = changedResources[i].getProject();
- if (!p.isOpen()) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_OPENPRJ, new String[]{p.getName()}));
- }
- if (!p.exists()) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_EXISTPRJ, new String[]{p.getName()}));
- }
- tempSet.add(project);
- }
-
- if (!tempSet.contains(project)) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_BADPRJ, new String[]{project.getName()}));
- }
- if (tempSet.size() != 1) {
- StringBuffer buffer = new StringBuffer("\n"); //$NON-NLS-1$
- Iterator iterator = tempSet.iterator();
- while (iterator.hasNext()) {
- IProject p = (IProject) iterator.next();
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(p.getName());
- if (iterator.hasNext()) {
- buffer.append(", "); //$NON-NLS-1$
- }
- }
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_MULTIPRJ, new String[]{buffer.toString()}));
- }
- }
-
- for (int i = 0; i < vmds.length; i++) {
- ValidatorMetaData vmd = vmds[i];
- if (!ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, project)) {
- throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_BADVAL, new String[]{vmd.getValidatorDisplayName(), project.getName()}));
- }
- }
-
- 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
- }
-
- /**
- * Given an array of fully-qualified class names of validators, create the list of validators to
- * be run. The array is not checked for duplicates or for invalid validators (i.e., a validator
- * of that class type is not loaded, or the validator is loaded but cannot run against this type
- * 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]);
- 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]);
- }
- enabled.add(vmd);
- }
- setEnabledValidators(enabled);
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Use setForce(boolean)
- */
- public void setAlwaysRun(boolean force) {
- setForce(force);
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 58b281fec..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchContext.java
+++ /dev/null
@@ -1,790 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.RegistryConstants;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * Abstract base class for registration of symbolic model names, and also provides the mechanism for
- * registering the load model method which loads a specific type of MOF model, as identified by the
- * symbolic model name.
- */
-public class WorkbenchContext implements IWorkbenchContext {
- private IProject _project = null;
- private Hashtable _modelRegistry = null;
-// private static final IContainer[] NO_CONTAINERS = new IContainer[0];
- private int _ruleGroup = RegistryConstants.ATT_RULE_GROUP_DEFAULT;
- public List validationFileURIs = null;
- public static final String GET_PROJECT_FILES = "getAllFiles"; //$NON-NLS-1$
- public static final String GET_FILE = "getFile"; //$NON-NLS-1$
-// private static final IContainer[] NO_CONTAINERS = new IContainer[0];
- public static final String VALIDATION_MARKER = "com.ibm.etools.validation.problemmarker"; //$NON-NLS-1$
- public static final String VALIDATION_MARKER_OWNER = "owner"; //$NON-NLS-1$
-
- public WorkbenchContext() {
- super();
- _modelRegistry = new Hashtable();
-
- registerModel(IRuleGroup.PASS_LEVEL, "loadRuleGroup"); //$NON-NLS-1$
-
- //the following will register the helper's symbolic methods
- Class [] args = new Class[1] ;
- args[0] = String.class ; // a string argument denoting a specific JSP.
- registerModel(GET_FILE, "getFile", args);//$NON-NLS-1$
- registerModel(GET_PROJECT_FILES, "getFiles", args);//$NON-NLS-1$
- }
-
- /**
- * When the validation is complete, this method will be called so that the IWorkbenchContext can
- * clean up any resources it allocated during the validation.
- *
- * If the cleanup is a long-running operation, subtask messages should be sent to the IReporter.
- */
- public void cleanup(WorkbenchReporter reporter) {
- // Default: nothing to clean up
- }
-
- /**
- * When the IProject is closing, perform any cleanup that needs to be done. When this method is
- * called, if the helper has cached any resources from the IProject, it should release those
- * resources. If you do not allocate resources in your helper, then this method should be a
- * no-op.
- */
- public void closing() {
- closing(getProject());
- }
-
- /**
- * When the IProject is closing, perform any cleanup that needs to be done. When this method is
- * called, if the helper has cached any resources from the IProject, it should release those
- * resources. If you do not allocate resources in your helper, then this method should be a
- * no-op.
- *
- * @deprecated Override closing() instead, and use getProject()
- */
- public void closing(IProject project) {
- //do nothing
- }
-
- /**
- * When the IProject is being deleted, perform any cleanup that needs to be done. When this
- * method is called, if the helper has cached any resources from the IProject, it should release
- * those resources. If you do not allocate resources in your helper, then this method should be
- * a no-op.
- */
- public void deleting() {
- deleting(getProject());
- }
-
- /**
- * When the IProject is being deleted, perform any cleanup that needs to be done. When this
- * method is called, if the helper has cached any resources from the IProject, it should release
- * those resources. If you do not allocate resources in your helper, then this method should be
- * a no-op.
- *
- * @deprecated Override deleting() instead, and use getProject()
- */
- public void deleting(IProject project) {
- //do nothing
- }
-
- /**
- * Returns the IPath of a resource, relative to the container. If the IResource is not a member
- * of the container, return null. This method should be useful for implementors of this class;
- * specifically, in their getPortableName method.
- */
- public static String getContainerRelativePath(String fullPath, IContainer container) {
- if ((fullPath == null) || (container == null))
- return null;
- IPath relPath = getContainerRelativePath(new Path(fullPath), container);
- if (relPath != null)
- return relPath.toString();
- return null;
- }
-
- /**
- * Returns the IPath of a resource, relative to the container. If the IResource is not a member
- * of the container, return null. This method should be useful for implementors of this class;
- * specifically, in their getPortableName method.
- */
- public static IPath getContainerRelativePath(IResource resource, IContainer container) {
- if ((resource == null) || (container == null)) {
- return null;
- }
-
- IResource foundResource = null;
- IPath relPath = getContainerRelativePath(resource.getFullPath(), container);
- if (relPath != null) {
- // if relPath is null, the resource is not a direct member of the container
- try {
- if (!resource.exists()) { // findMember won't work
- if (resource instanceof IFile) {
- foundResource = container.getFile(relPath);
- } else if (resource instanceof IFolder) {
- foundResource = container.getFolder(relPath);
- }
- } else {
- foundResource = container.findMember(relPath, true); // true means include
- // phantom resources
- if ((foundResource != null) && !foundResource.exists()) {
- foundResource = null;
- }
- }
- } catch (IllegalArgumentException exc) {
- foundResource = null;
-
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext::getContainerRelativePath(IResource, IContainer)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- if (foundResource == null) {
- return null;
- }
-
- // file has been found
- int matchingFirstSegments = container.getProjectRelativePath().matchingFirstSegments(resource.getProjectRelativePath());
- return resource.getProjectRelativePath().removeFirstSegments(matchingFirstSegments);
- }
-
- /**
- * Given an IPath, if the IPath is absolute, and is a part of the IContainer, return an IPath
- * which is relative to the container. If the IPath is not part of the IContainer, return null.
- */
- public static IPath getContainerRelativePath(IPath path, IContainer container) {
- if ((path == null) || (container == null)) {
- return null;
- }
-
- if (path.isAbsolute()) {
- // Is the path part of the IContainer?
- int matchingFirstSegments = path.matchingFirstSegments(container.getFullPath());
- if ((matchingFirstSegments > 0) && (matchingFirstSegments == container.getFullPath().segmentCount())) {
- // part of the IContainer
- return path.removeFirstSegments(matchingFirstSegments);
- }
- // not part of the IContainer
- return null;
- }
- // path is relative
- // Is the path part of the IContainer?
- //TODO don't have time to implement this now, but should in future. - Ruth
- return null;
- }
-
- /**
- * Given an IMessage's target object, return a string which identifies the object, so that the
- * user can locate it.
- */
- public String getDescription(Object object) {
- if (object == null) {
- return ""; //$NON-NLS-1$
- }
-
- if (object instanceof WorkbenchFileDelta) {
- WorkbenchFileDelta wfd = (WorkbenchFileDelta) object;
- if (wfd.getResource() != null) {
- // resource will be null if WorkbenchFileDelta was constructed from an Object
- // instead of an IResource
- return wfd.getResource().getFullPath().toString();
- }
- }
-
- return object.toString();
- }
-
- /**
- * Given an Object, if the object has a corresponding IFile in the workbench, return the IFile.
- * Otherwise return null.
- *
- * This method is used by the WorkbenchReporter. In eclipse, in order to add or remove a task
- * list entry, the IResource, to which the entry applies, must be identified. The IReporter
- * interface passes in an Object in these methods:
- *
- * addValidationMessage(IValidator, IMessage) // Object is a part of IMessage
- *
- * removeAllMessages(IValidator, Object),
- *
- * Thus, the WorkbenchReporter needs to know how, given the Object, which IFile that the Object
- * represents in the workbench, in order to be able to add the task list entry.
- *
- * If this method returns null, then the WorkbenchReporter will add the message to the IProject
- * instead of an IFile.
- *
- */
- public IFile getFile(Object obj) {
- return null;
- }
-
- public IResource getResource(Object obj) {
- if (obj == null) {
- return null;
- }
-
- IResource res = null;
- if (obj instanceof WorkbenchFileDelta) {
- // resource may be null if WorkbenchFileDelta was constructed from an Object instead of
- // an IResource
- res = ((WorkbenchFileDelta) obj).getResource();
- } else if (obj instanceof IResource) {
- res = (IResource) obj;
- }
-
- if ((res == null) || (!res.exists())) {
- return getFile(obj);
- }
-
- return res;
- }
-
- /**
- * If the IProject is associated with an EJBNatureRuntime, return the IJavaProject which
- * represents it.
- */
-// public static IJavaProject getJavaProject(IProject project) {
-// if (project == null) {
-// return null;
-// }
-// return JavaCore.create(project);
-// }
-
- /**
- * Given an IMessage's target object, return the line number, of the IFile, which the target
- * object represents. If the object is null, or if access to line numbers is not possible,
- * return "0".
- */
- public int getLineNo(Object object) {
- IResourceUtil util = ValidatorManager.getResourceUtil();
- if (util == null) {
- return IMessage.LINENO_UNSET;
- }
- try {
- return util.getLineNo(object);
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext.getLineNo(Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return IMessage.LINENO_UNSET;
- }
-
- }
-
- /**
- * Given an IMessage's target object, return the line number, of the IFile, which the target
- * object represents, if possible. If the object is null, or if access to line numbers is not
- * possible, return a text description of the location.
- *
- * This method will be called whether or not the IResource is an IFile, IFolder, or IProject.
- * Line numbers are valid only for IFile types; if the resource is not an IFile, then a text
- * description of the location must be returned.
- */
- public String getLocation(Object object) {
- IResource res = getResource(object);
- if ((res == null) || !(res instanceof IFile))
- // return a text description
- return getDescription(object);
- // default to a line number, if it's available. Else, use a text description.
- int lineNumber = getLineNo(object);
- if (lineNumber == IMessage.LINENO_UNSET) {
- return getDescription(object);
- }
- // return the line number
- return String.valueOf(lineNumber);
- }
-
- /**
- * Given a name of a load method, and the types of parameters it takes (this method is always
- * called with null as the second parameter), return the java.lang.reflect.Method which
- * represents the load method.
- */
- private final Method getMethod(String methodName, Class[] parmTypes) {
- Method m = null;
- try {
- m = getClass().getMethod(methodName, parmTypes);
- } catch (NoSuchMethodException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext::getMethod(String, Class[])"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
-
- return m;
- }
-
- /**
- * @see IWorkbenchContext.getPortableName(IResource)
- */
- public String getPortableName(IResource resource) {
- return resource.getFullPath().toString();
- }
-
- /**
- * Return the IProject which is about to be validated. Each IWorkbenchContext knows how to
- * traverse a certain type of IProject, for example, an EJB project or a web project.
- */
- public final IProject getProject() {
- return _project;
- }
-
- /**
- * Get the IFile for the given filename.
- *
- * @param filename The name of the file to retrieve.
- * @return An IFile representing the file specified or null if it can't be resolved.
- */
- public IFile getFile(String filename)
- {
- // System.out.println("file name = " + filename);
- IResource res = getProject().findMember(filename, true); // true means include phantom resources
- if (res instanceof IFile)
- {
- return (IFile) res;
- }
- return null;
- }
-
- /**
- * Get the collection of files from the project that are relevant for the
- * validator with the given class name.
- *
- * @param validatorClassName The name of the validator class.
- * @return The collection of files relevant for the validator class specified.
- */
- public Collection getFiles(String validatorClassName)
- {
- IProject project = getProject();
- List files = new ArrayList();
- getFiles(files, project, validatorClassName);
- return files;
- }
-
- /**
- * Get the collection of files from the project that are relevant for the
- * validator with the given class name.
- *
- * @param files The files relevant for the class name.
- * @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)
- {
- try
- {
- IResource [] resourceArray = resource.members(false);
- for (int i=0; i<resourceArray.length; i++)
- {
- if (ValidatorManager.getManager().isApplicableTo(validatorClassName, resourceArray[i]))
- {
- if (resourceArray[i] instanceof IFile)
- files.add(resourceArray[i]);
- }
- if (resourceArray[i].getType() == IResource.FOLDER)
- getFiles(files,(IContainer)resourceArray[i], validatorClassName) ;
- }
- }
- catch (Exception e) {}
- }
-
-
-// /**
-// * Return the folders (or project) which contain the .java source files.
-// */
-// public static IContainer[] getProjectSourceContainers(IProject project) {
-// if (project == null) {
-// return NO_CONTAINERS;
-// }
-//
-// IJavaProject jp = getJavaProject(project);
-// if (jp == null) {
-// return NO_CONTAINERS;
-// }
-//
-// return getProjectSourceContainers(jp);
-// }
-
- /**
- * Return the folders (or project) which contain the .java source files.
- */
-// public static IContainer[] getProjectSourceContainers(IJavaProject javaProject) {
-// if (javaProject == null) {
-// return NO_CONTAINERS;
-// }
-// IProject project = javaProject.getProject();
-//
-// IClasspathEntry[] classpath = null;
-// try {
-// classpath = javaProject.getResolvedClasspath(true); // true means ignore unresolved
-// // (missing) variables, instead of
-// // throwing an exception
-// } catch (JavaModelException exc) {
-// Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
-// if (logger.isLoggingLevel(Level.SEVERE)) {
-// LogEntry entry = ValidationPlugin.getLogEntry();
-// entry.setSourceID("WorkbenchContext::getProjectSourceContainers(IJavaProject)"); //$NON-NLS-1$
-// entry.setTargetException(exc);
-// logger.write(Level.SEVERE, entry);
-// }
-// return NO_CONTAINERS;
-// }
-//
-// if (classpath == null) {
-// return NO_CONTAINERS;
-// }
-//
-// // Traverse the classpath, and calculate a list of just the
-// // IFolders and IProjects (i.e., IContainers) which contain source
-// IContainer[] icontainers = new IContainer[classpath.length];
-// int validCount = 0;
-// for (int i = 0; i < classpath.length; i++) {
-// IClasspathEntry entry = classpath[i];
-// if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
-// IPath entryPath = entry.getPath();
-// IPath relEntryPath = getContainerRelativePath(entryPath, project);
-// if (relEntryPath == null) {
-// // classpath entry refers to something which doesn't exist
-// continue;
-// }
-//
-// IResource outputResource = project.findMember(relEntryPath);
-// if (outputResource == null) {
-// // classpath entry refers to something which doesn't exist
-// continue;
-// }
-//
-// if (outputResource instanceof IContainer) {
-// icontainers[validCount++] = (IContainer) outputResource;
-// }
-// }
-// }
-//
-// // following line causes a ClassCastException, so construct an array of IContainers
-// // explicitly
-// // return (IContainer[])icontainers.toArray();
-// IContainer[] containers = new IContainer[validCount];
-// System.arraycopy(icontainers, 0, containers, 0, validCount);
-// return containers;
-// }
-
- public int getRuleGroup() {
- return _ruleGroup;
- }
-
- /**
- * This method can be overriden by AWorkbenchHelpers, if they wish to perform some
- * initialization once the IProject is set. Default is to do nothing.
- *
- * For example, if this IWorkbenchContext delegates to another IWorkbenchContext, then that
- * IWorkbenchContext's setProject() method should be called here.
- */
- public void initialize() {
- //do nothing
- }
-
- /**
- * Return true if the given resource is in an IJavaProject, and if it is in one of the source
- * folders in the IJavaProject. If the project's source folder happens to be the project's
- * output folder too, this method will return true. If res is null, or is not found in one of
- * the source containers, this method will return false.
- */
-// public boolean isInJavaSourcePath(IResource res) {
-// if (res == null) {
-// return false;
-// }
-//
-// IContainer[] containers = getProjectSourceContainers(res.getProject());
-// for (int c = 0; c < containers.length; c++) {
-// IPath resourcePath = getContainerRelativePath(res, containers[c]);
-// if (resourcePath != null) {
-// // file has been found
-// return true;
-// }
-// }
-//
-// return false;
-// }
-
- /**
- * Return true if the given symbolic name is registered, and can be loaded by WorkbenchContext's
- * "loadModel" method. For further information, see the comment above WorkbenchContext's
- * "registerModel" method.
- */
- public final boolean isRegistered(String symbolicName) {
- if (symbolicName == null) {
- return false;
- }
- return _modelRegistry.containsKey(symbolicName);
- }
-
- /**
- * Given a symbolic name, load the MOF model which is identified by that name.
- *
- * For support of dynamic symbolic names, such as file names, read the comment above the
- * registerModel method.
- *
- * @see registerModel
- */
- public Object loadModel(String symbolicName) {
- return loadModel(symbolicName, null);
- }
-
- /**
- * Given a symbolic name, load the MOF model which is identified by that name.
- *
- * For support of dynamic symbolic names, such as file names, read the comment above the
- * registerModel method.
- *
- * @see registerModel
- */
- public Object loadModel(String symbolicName, Object[] parms) {
- try {
- Method loader = (Method) _modelRegistry.get(symbolicName);
- if (loader == null) {
- return null;
- }
-
- return loader.invoke(this, parms);
- } catch (IllegalAccessException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext::loadModel(String, Object[])"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- } catch (InvocationTargetException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext::loadModel(String, Object[])"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
-
- if (exc.getTargetException() != null) {
- entry.setTargetException(exc.getTargetException());
- logger.write(Level.SEVERE, exc);
- }
- }
- return null;
- } catch (NullPointerException exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext::loadModel(String, Object[])"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- } catch (ExceptionInInitializerError exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchContext::loadModel(String, Object[])"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return null;
- }
- }
-
- public Object loadRuleGroup() {
- return new Integer(getRuleGroup()); // have to wrap the int in an Integer because can't cast
- // an int to an Object
- }
-
- /**
- * This method should be used only by the validation framework. This method will be called by
- * ValidationOperation, before the IValidator's validate method is called, to set the group of
- * rules which the IValidator should check.
- */
- public void setRuleGroup(int rg) {
- _ruleGroup = rg;
- }
-
- /**
- * Register a load method for a symbolic name. A load method is defined as a method which takes
- * no parameters and returns a RefObject.
- *
- * Every subclass of WorkbenchContext, for every static type of symbolic name which it supports,
- * should call registerModel. For IWorkbenchHelpers which support dynamic symbolic names, such
- * as file names, each IWorkbenchContext should override the "loadModel" method. Their
- * "loadModel" should first call this class' "isRegistered" method to see if they're dealing
- * with a static symbolic name, or a dynamic one. If the symbolic name is registered, the
- * child's "loadModel" method should just return the result of WorkbenchContext's "loadModel"
- * method. Otherwise, it should return the result based on its own processing.
- *
- * When this method is called, the load method identified by loadMethodName is located & stored
- * for future retrieval by the "loadModel" method. When the IValidator calls "loadModel" with a
- * symbolic name, the java.lang.reflect.Method which was loaded by this method is invoked, and
- * the result (RefObject) returned by that method is returned by "loadModel".
- *
- * symbolicName must not be null or the empty string. loadMethodName must not be null or the
- * empty string.
- */
- protected final void registerModel(String symbolicName, String loadMethodName) {
- registerModel(symbolicName, loadMethodName, null);
- }
-
- /**
- * Register a load method for a symbolic name. A load method is defined as a method which takes
- * no parameters and returns a RefObject.
- *
- * Every subclass of WorkbenchContext, for every static type of symbolic name which it supports,
- * should call registerModel. For IWorkbenchHelpers which support dynamic symbolic names, such
- * as file names, each IWorkbenchContext should override the "loadModel" method. Their
- * "loadModel" should first call this class' "isRegistered" method to see if they're dealing
- * with a static symbolic name, or a dynamic one. If the symbolic name is registered, the
- * child's "loadModel" method should just return the result of WorkbenchContext's "loadModel"
- * method. Otherwise, it should return the result based on its own processing.
- *
- * When this method is called, the load method identified by loadMethodName is located & stored
- * for future retrieval by the "loadModel" method. When the IValidator calls "loadModel" with a
- * symbolic name, the java.lang.reflect.Method which was loaded by this method is invoked, and
- * the result (RefObject) returned by that method is returned by "loadModel".
- *
- * symbolicName must not be null or the empty string. loadMethodName must not be null or the
- * empty string.
- */
- protected final void registerModel(String symbolicName, String loadMethodName, Class[] parms) {
- Method method = getMethod(loadMethodName, parms);
- if (method == null) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- StringBuffer buffer = new StringBuffer("Load method "); //$NON-NLS-1$
- buffer.append(loadMethodName);
- buffer.append("("); //$NON-NLS-1$
- for (int i = 0; (parms != null) && (i < parms.length); i++) {
- buffer.append(parms[i]);
- }
- buffer.append(") must exist. " + getClass().getName() + " cannot support model " + symbolicName); //$NON-NLS-1$ //$NON-NLS-2$
-
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("ValidationRegistryReader.readExtension(IExtension)"); //$NON-NLS-1$
- entry.setText(buffer.toString());
- logger.write(Level.FINE, entry);
- }
- } else {
- _modelRegistry.put(symbolicName, method);
- }
- }
-
- /**
- * Whether full or incremental validation is running, this method will be called, for every
- * IResource which is filtered in by the IValidator, so that the IValidationContext can receive
- * notification that one of the resources, which validation will run on, is being filtered in.
- */
- public void registerResource(IResource resource) {
- // default: do nothing
- }
-
- /**
- * This method is called by the Validation Framework, to initialize the IWorkbenchContext so that
- * it can gather information from the current project.
- *
- * If an IWorkbenchContext delegates some model loading to another IWorkbenchContext, this method
- * should be overriden so that the delegatee IWorkbenchContext is initialized with the IProject.
- */
- public final void setProject(IProject project) {
- _project = project;
-
- if (project != null) {
- // Project will be set back to null once the validation of the project is complete.
- initialize();
- }
- }
-
- /**
- * Notifies this IWorkbenchContext that the Validation Framework is shutting down. There will be
- * calls to closing(IProject) and possibly deleting(IProject) following this call, but the
- * resources may already be closed by the time that those methods are called, so EVERYTHING
- * should be cleaned up in this method. The parameter passed in is the project which is about to
- * shut down. This method will be called once for every IProject in the workbench. The IProject
- * may, or may not, be closed.
- */
- public void shutdown() {
- // Default is to assume that no resources were allocated; therefore,
- // no cleanup needs to be done.
- shutdown(getProject());
- }
-
- /**
- * Notifies this IWorkbenchContext that the Validation Framework is shutting down. There will be
- * calls to closing(IProject) and possibly deleting(IProject) following this call, but the
- * resources may already be closed by the time that those methods are called, so EVERYTHING
- * should be cleaned up in this method. The parameter passed in is the project which is about to
- * shut down. This method will be called once for every IProject in the workbench. The IProject
- * may, or may not, be closed.
- *
- * @deprecated Override shutdown() instead, and use getProject()
- */
- public void shutdown(IProject project) {
- // Default is to assume that no resources were allocated; therefore,
- // no cleanup needs to be done.
- }
-
- 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);
- return uris;
- }
-
- /**
- * @return Returns the validationFileURIs.
- */
- public List getValidationFileURIs() {
- return validationFileURIs;
- }
-
- /**
- * @param validationFileURIs The validationFileURIs to set.
- */
- public void setValidationFileURIs(List validationFileURIs) {
- this.validationFileURIs = validationFileURIs;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchFileDelta.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchFileDelta.java
deleted file mode 100644
index 2871aff75..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchFileDelta.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.validation.internal.core.FileDelta;
-import org.eclipse.wst.validation.internal.core.IFileDelta;
-
-
-/**
- * Eclipse-specific implementation of FileDelta which also caches the IResource which is associated
- * with the FileDelta.
- */
-public class WorkbenchFileDelta extends FileDelta {
- private IResource _resource = null;
- private Object _changedResource = null;
-
- private static final String FILE_NAME = "FILE NAME:"; //$NON-NLS-1$
- private static final String DELTA = " DELTA: "; //$NON-NLS-1$
- private static final String RESOURCE = " RESOURCE: "; //$NON-NLS-1$
- private static final String OBJECT = " OBJECT: "; //$NON-NLS-1$
-
- public WorkbenchFileDelta(String aFileName, int aFileDelta, IResource resource) {
- super(aFileName, aFileDelta);
- setResource(resource);
- setObject(resource);
- }
-
- public WorkbenchFileDelta(Object changedResource) {
- super(null, IFileDelta.CHANGED);
- setObject(changedResource);
- }
-
- public IResource getResource() {
- return _resource;
- }
-
- public void setResource(IResource resource) {
- _resource = resource;
- }
-
- /**
- * If the changed resource is not an IResource (e.g., a RefObject), then the getFileName method
- * will return null, getResource will return null, and this method will return the object. If
- * the changedResource is an IResource, then both this method and the getResource method will
- * return the resource.
- */
- public Object getObject() {
- return _changedResource;
- }
-
- /**
- * @see getObject()
- */
- public void setObject(Object o) {
- _changedResource = o;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer(FILE_NAME);
- buffer.append(String.valueOf(getFileName()));
- buffer.append(DELTA);
- buffer.append(getDeltaType());
- buffer.append(RESOURCE);
- buffer.append(String.valueOf(getResource()));
- buffer.append(OBJECT);
- buffer.append(String.valueOf(getObject()));
- return buffer.toString();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchReporter.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchReporter.java
deleted file mode 100644
index 75007c8cd..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/operations/WorkbenchReporter.java
+++ /dev/null
@@ -1,733 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.operations;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.TaskListUtility;
-import org.eclipse.wst.validation.internal.ValidationRegistryReader;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.validation.internal.provisional.core.MessageLimitException;
-import org.eclipse.wst.validation.internal.ResourceHandler;
-
-/**
- * IValidator instances will interact with an instance of this class, but should never cast that
- * IReporter instance to WorkbenchReporter. The WorkbenchReporter class will be moved in Milestone
- * 4.
- *
- * This class handles interaction between the user and the IValidator in the eclipse workbench
- * environment.
- *
- * This class must not be called outside of an IWorkspaceRunnable or IRunnableWithProgress. Many
- * resource deltas can be generated by the methods in this class.
- *
- * Only the validation framework may instantiate or alter instances of this class.
- */
-
-public final class WorkbenchReporter implements IReporter {
- public static final String DEFAULT_LOCATION = ""; //$NON-NLS-1$
- public static final int NO_MESSAGE_LIMIT = -1;
-
- private IProject _project = null;
- private IProgressMonitor _monitor = null;
-
- public static void addMessage(IResource resource, Class messageOwner, IMessage message) {
- addMessage(resource, messageOwner, null, message); // null ClassLoader = use the default
- // (clazz.getClassLoader());
- }
-
- public static void addMessage(IResource resource, Class messageOwner, ClassLoader cl, IMessage message) {
- addMessage(resource, messageOwner, cl, message, null, ""); //$NON-NLS-1$
- }
-
- public static void addMessage(IResource resource, Class clazz, IMessage message, String targetObjectName, String location) {
- addMessage(resource, clazz, null, message, targetObjectName, location); // null = use the
- // default
- // ClassLoader
- // (class.getClassLoader())
- }
-
- public static void addMessage(IResource resource, Class clazz, IMessage message, String targetObjectName, String location,String markerId) {
- addMessage(resource, clazz, null, message, targetObjectName, location,markerId); // null = use the
- // default
- // ClassLoader
- // (class.getClassLoader())
- }
-
-
-
- public static void addMessage(IResource resource, Class clazz, ClassLoader cl, IMessage message, String targetObjectName, String location) {
- if ((clazz == null) || (message == null) || (resource == null)) {
- return;
- }
-
- if (cl == null) {
- cl = clazz.getClassLoader();
- }
-
- addMessage(resource, getUniqueId(clazz), cl, message, targetObjectName, location);
- }
-
- public static void addMessage(IResource resource, Class clazz, ClassLoader cl, IMessage message, String targetObjectName, String location, String markerId) {
- if ((clazz == null) || (message == null) || (resource == null)) {
- return;
- }
-
- if (cl == null) {
- cl = clazz.getClassLoader();
- }
-
- addMessage(resource, getUniqueId(clazz), cl, message, targetObjectName, location, markerId);
- }
-
- public static void addMessage(IResource resource, String messageOwnerId, ClassLoader cl, IMessage message) {
- addMessage(resource, messageOwnerId, cl, message, null, ""); //$NON-NLS-1$
- }
-
- public static void addMessage(IResource resource, String messageOwnerId, ClassLoader cl, IMessage message, String targetObjectName, String location) {
- int severity = message.getSeverity();
- try {
- TaskListUtility.addTask(messageOwnerId, resource, location, message.getId(), message.getText(cl), severity,targetObjectName, message.getGroupName(), message.getOffset(), message.getLength());
- } catch (CoreException exc) {
- // Couldn't add the task to the task list for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.addMessage(Class,, IResource, IMessage, String, String"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- public static void addMessage(IResource resource, String messageOwnerId, ClassLoader cl, IMessage message, String targetObjectName, String location, String markerId) {
- int severity = message.getSeverity();
- try {
- TaskListUtility.addTask(messageOwnerId, resource, location, message.getId(), message.getText(cl), severity,markerId,targetObjectName, message.getGroupName(), message.getOffset(), message.getLength());
- increaseMessageCountForProject(resource.getProject());;
- } catch (CoreException exc) {
- // Couldn't add the task to the task list for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.addMessage(Class,, IResource, IMessage, String, String"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- private static void increaseMessageCountForProject(IProject project) {
- ValidatorManager.initializeMessageLimitProjectMap(project);
- Object integer = ValidatorManager.messageLimitProjectMap.get(project);
- int newVal = ((Integer) integer).intValue() + 1;
- ValidatorManager.messageLimitProjectMap.put(project,new Integer(newVal));
- }
-
- public static void removeAllMessages(IResource resource, IValidator validator) {
- if (resource == null) {
- return;
- }
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- if (vmd == null) {
- // log
- return;
- }
-
- String[] validatorNames = vmd.getValidatorNames();
- try {
- TaskListUtility.removeAllTasks(resource, validatorNames);
- } catch (CoreException exc) {
- // Couldn't remove the task from the task list for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.removeAllMessages(String[], IResource, String)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- /**
- * @deprecated Will be removed in Milestone 3. Should not be called outside of the validation
- * framework.
- */
- public static void removeAllMessages(IResource resource, IValidator validator, Object object) {
- if (resource == null) {
- return;
- }
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- if (vmd == null) {
- // log
- return;
- }
-
- String[] validatorNames = vmd.getValidatorNames();
- try {
- String targetObjectName = getTargetObjectName(vmd.getHelper(resource.getProject()), object);
- removeAllMessages(resource, validatorNames, targetObjectName);
- } catch (InstantiationException exc) {
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- final Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::removeAllMessages(IResource, IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- public static void removeAllMessages(IResource resource, String[] validatorNames, String targetObjectName) {
- try {
- TaskListUtility.removeAllTasks(resource, validatorNames, targetObjectName);
- } catch (CoreException exc) {
- // Couldn't remove the task from the task list for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.removeAllMessages(String[], IResource, String)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- public static void removeMessageSubset(IResource resource, Class messageOwner, String groupName) {
- // Since the addMessage(Class, IMessage) is defaulted to the IProject,
- // remove the message subsets from the IProject
- removeMessageSubset(resource, new String[]{getUniqueId(messageOwner)}, null, groupName);
- }
-
- public static void removeMessageSubset(IResource resource, String messageOwnerId, String groupName) {
- // Since the addMessage(Class, IMessage) is defaulted to the IProject,
- // remove the message subsets from the IProject
- removeMessageSubset(resource, new String[]{messageOwnerId}, null, groupName);
- }
-
- public static void removeMessageSubset(IResource resource, String[] ownerId, String targetObjectName, String groupName) {
- try {
- TaskListUtility.removeTaskSubset(resource, ownerId, targetObjectName, groupName);
- } catch (CoreException exc) {
- // Couldn't remove the task to the task list for some reason...
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.removeMessageSubset(String[], IResource, String, String)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
-
- /**
- * Given a Class instance, return the id that uniquely identifies this instance. (Used as the
- * value for the message owner.)
- */
- public static String getUniqueId(Class clazz) {
- if (clazz == null) {
- return ""; //$NON-NLS-1$
- }
-
- // It is safe to load this String into the constants space because
- // the Class name will not change during WSAD's session.
- return clazz.getName().intern();
- }
-
- public static String getUniqueId(IValidator validator) {
- if (validator == null) {
- return ""; //$NON-NLS-1$
- }
- return getUniqueId(validator.getClass());
- }
-
- public static Logger getMsgLogger(IValidator validator) {
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- if (vmd == null) {
- return ValidationPlugin.getPlugin().getMsgLogger();
- }
-
- return vmd.getMsgLogger();
- }
-
- public static String getLocation(IWorkbenchContext helper, IMessage message) {
- if (message == null) {
- return getLocationText(helper, null);
- }
- int lineNo = message.getLineNumber();
- if (lineNo == IMessage.LINENO_UNSET) {
- return getLocationText(helper, message.getTargetObject());
- }
- return String.valueOf(lineNo);
- }
-
- public static String getLocationText(IWorkbenchContext helper, Object targetObject) {
- String location = null;
- try {
- location = helper.getLocation(targetObject);
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.getLocationText(Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- if ((location == null) || (location.trim().equals(""))) { //$NON-NLS-1$
- location = DEFAULT_LOCATION;
- }
- return location;
- }
-
- /**
- * If the user is cancelling validation on the current project/resource, Add an information task
- * to the task list informing the user that validation has not been run on the current project.
- */
- // TODO This method was made protected for the SaberReporter. Make this method private again
- // once the framework supports IMarker.PRIORITY.
- protected static void addTerminatedTask(IProject project, IValidator validator) throws IllegalArgumentException {
- if ((project == null) || (validator == null)) {
- return;
- }
- ValidatorManager.getManager().addMessageLimitExceeded(project);
- ValidatorManager.setMessageLimitMessageForProject(project);
- }
-
- // TODO This method was made protected for the SaberReporter. Make this method private again
- // once the framework supports IMarker.PRIORITY.
- protected static String getTargetObjectName(IWorkbenchContext helper, IMessage message) {
- if (message == null) {
- return getTargetObjectName(helper, null);
- }
- return getTargetObjectName(helper, message.getTargetObject());
- }
-
- private static String getTargetObjectName(IWorkbenchContext helper, Object targetObject) {
- String targetObjectName = null;
- try {
- targetObjectName = helper.getTargetObjectName(targetObject);
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.getTargetObjectName(Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- return targetObjectName;
- }
-
- // TODO This method was made "protected" for the SaberReporter. Do not call this method! This
- // method will be made private once support for marker PRIORITY attributes is in the framework.
- protected static ValidatorMetaData getVMD(IValidator validator) throws IllegalArgumentException {
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- if (vmd == null) {
- throw new IllegalArgumentException(); // already logged in the ValidationRegistryReader
- }
- return vmd;
- }
-
- /**
- * @deprecated. The IValidationContext will be ignored.
- */
- public WorkbenchReporter(IWorkbenchContext helper, IProgressMonitor monitor, IProject project) {
- this(project, monitor);
- }
-
- /**
- * An IReporter instance must exist for each Runnable in order for the validator to report
- * status messages. IProject and IProgressMonitor must not be null.
- */
- public WorkbenchReporter(IProject project, IProgressMonitor monitor) {
- super();
- _project = project;
- _monitor = monitor;
- }
-
- // TODO This method was made protected for the SaberReporter. Make it private again once the
- // framework support IMarker.PRIORITY.
- protected IWorkbenchContext getHelper(IValidator validator) throws InstantiationException, IllegalArgumentException {
- ValidatorMetaData vmd = getVMD(validator);
- IWorkbenchContext helper = vmd.getHelper(getProject());
- return helper;
- }
-
-
- public IProject getProject() {
- return _project;
- }
-
- public IProgressMonitor getProgressMonitor() {
- return _monitor;
- }
-
- /**
- * This method will never return null.
- */
- private IResource getDefaultResource() {
- IResource prj = getProject();
- if (prj != null) {
- return prj;
- }
- // return the workspace root
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- /**
- * When an IMessage is created, the user has the option of creating it with a target object.
- * That target object is used to identify which object has the problem identified by the
- * IMessage. This method, given the target object, returns the IResource which represents that
- * object in the workbench.
- */
- public IResource getMessageResource(IValidator validator, Object object) {
- if (validator == null) {
- return null;
- }
-
- IResource resource = null;
- if (object != null) {
- if (object instanceof IResource) {
- resource = (IResource) object;
- } else if (object instanceof WorkbenchFileDelta) {
- // resource may be null if the WorkbenchFileDelta was constructed from an Object
- // instead of an IResource
- resource = ((WorkbenchFileDelta) object).getResource();
- }
-
- if (resource == null) {
- try {
- IWorkbenchContext helper = getHelper(validator);
- resource = helper.getResource(object);
- } catch (InstantiationException exc) {
- try {
- // Unlikely that an exception will be thrown, because this method is
- // invoked by the validator, and if the validator is invoked, it's likely
- // that the helper has been loaded too.
- ValidatorMetaData vmd = getVMD(validator);
-
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::getMessageResource(IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- } catch (IllegalArgumentException exc2) {
- // Even the IValidator is invalid. Unfortunately, can't disable the
- // validator because it can't be found by the registry reader.
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::getMessageResource(IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc2);
- logger.write(Level.SEVERE, entry);
- }
- }
- } catch (IllegalArgumentException exc) {
- // Even the IValidator is invalid. Unfortunately, can't disable the
- // validator because it can't be found by the registry reader.
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::getMessageResource(IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- } catch (Throwable exc) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.getMessageResource(IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- }
- }
-
- if (resource == null) {
- resource = getDefaultResource();
- }
-
- if (!resource.exists()) {
- resource = getDefaultResource();
- }
-
- return resource;
- }
-
- /**
- * Show a message to the user indicating which subtask is currently being processed. <br>
- * <br>
- * <code>message</code> may not be null or the empty string (""). <br>
- */
- public void displaySubtask(String message) {
- if ((message == null) || (message.equals(""))) { //$NON-NLS-1$
- return;
- }
-
- if (getProgressMonitor() != null) {
- getProgressMonitor().subTask(message);
- } else {
- System.out.println(message);
- }
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#getMessages()
- */
- public List getMessages() {
- return null;
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#isCancelled()
- */
- public boolean isCancelled() {
- if (getProgressMonitor() != null) {
- return getProgressMonitor().isCanceled();
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#addMessage(IValidator, IMessage)
- */
- public void addMessage(IValidator validator, IMessage message) throws MessageLimitException {
- IResource resource = getMessageResource(validator, message.getTargetObject());
- IWorkbenchContext helper = null;
- ValidatorMetaData vmd = getVMD(validator);
- try {
- helper = getHelper(validator);
- } catch (InstantiationException exc) {
- try {
- // Unlikely that an exception will be thrown, because this method is
- // invoked by the validator, and if the validator is invoked, it's likely
- // that the helper has been loaded too
-
-
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::addMessage(IValidator, IMessage)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return;
- } catch (IllegalArgumentException exc2) {
- logDisabledValidator(exc2);
- return;
- }
- } catch (IllegalArgumentException exc) {
- logDisabledValidator(exc);
- return;
- }
-
- if (resource == null) {
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter.addMessage(IValidator, Message)"); //$NON-NLS-1$
- entry.setMessageTypeIdentifier(ResourceConstants.VBF_EXC_INVALID_RESOURCE);
- String result = MessageFormat.format(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_INVALID_RESOURCE), new String[]{message.getText(), getTargetObjectName(helper, message)});
- entry.setText(result);
- //entry.setTokens(new String[]{message.getText(), getTargetObjectName(helper, message)});
- logger.write(Level.FINE, entry);
- }
- return;
- }
-
- ValidatorManager mgr = ValidatorManager.getManager();
- if (mgr.isMessageLimitExceeded(resource.getProject())) {
- validateMessageLimitExceeded(validator, resource);
- }
-
- addMessage(resource, validator.getClass(), message, getTargetObjectName(helper, message), getLocation(helper, message),vmd.getMarkerId());
- }
-
- /**
- * @param exc
- */
- private void logDisabledValidator(IllegalArgumentException exc) {
- // Even the IValidator is invalid. Unfortunately, can't disable the
- // validator because it can't be found by the registry reader.
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::addMessage(IValidator, IMessage)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- return;
- }
-
- /**
- * @param validator
- * @param resource
- */
- private void validateMessageLimitExceeded(IValidator validator, IResource resource) {
- try {
- addTerminatedTask(resource.getProject(), validator);
- } catch (IllegalArgumentException exc) {
- // Even the IValidator is invalid. Unfortunately, can't disable the
- // validator because it can't be found by the registry reader.
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::addMessage(IValidator, IMessage)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
- }
- throw new MessageLimitException();
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#displaySubtask(IValidator, IMessage)
- */
- public void displaySubtask(IValidator validator, IMessage message) {
- if ((message == null) || (message.equals(""))) { //$NON-NLS-1$
- return;
- }
-
- displaySubtask(message.getText(validator.getClass().getClassLoader()));
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#removeAllMessages(IValidator)
- */
- public void removeAllMessages(IValidator validator) {
- if (validator == null) { // getHelper could be null if the user cancelled before something
- // was fully initialized
- return;
- }
-
- removeAllMessages(validator, null);
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#removeAllMessages(IValidator, Object)
- */
- public void removeAllMessages(IValidator validator, Object object) {
- IResource resource = getMessageResource(validator, object);
- if (resource == null) {
- return;
- }
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- if (vmd == null) {
- return;
- }
-
- IWorkbenchContext helper = null;
- try {
- helper = vmd.getHelper(resource.getProject());
- } catch (InstantiationException exc) {
- // Unlikely that an exception will be thrown, because this method is
- // invoked by the validator, and if the validator is invoked, it's likely
- // that the helper has been loaded too.
-
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::removeAllMessages(IResource, IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
-
- return;
- }
-
- String[] validatorNames = vmd.getValidatorNames();
- String targetObjectName = getTargetObjectName(helper, object);
- removeAllMessages(resource, validatorNames, targetObjectName);
- }
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.IReporter#removeMessageSubset(IValidator, Object, String)
- */
- public void removeMessageSubset(IValidator validator, Object obj, String groupName) {
- IResource resource = getMessageResource(validator, obj);
- if (resource == null) {
- return;
- }
-
- ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validator);
- if (vmd == null) {
- return;
- }
-
-
- IWorkbenchContext helper = null;
- try {
- helper = vmd.getHelper(resource.getProject());
- } catch (InstantiationException exc) {
- // Unlikely that an exception will be thrown, because this method is
- // invoked by the validator, and if the validator is invoked, it's likely
- // that the helper has been loaded too.
-
- // Remove the vmd from the reader's list
- ValidationRegistryReader.getReader().disableValidator(vmd);
-
- // Log the reason for the disabled validator
- Logger logger = ValidationPlugin.getPlugin().getMsgLogger();
- if (logger.isLoggingLevel(Level.SEVERE)) {
- LogEntry entry = ValidationPlugin.getLogEntry();
- entry.setSourceID("WorkbenchReporter::removeAllMessages(IResource, IValidator, Object)"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.SEVERE, entry);
- }
-
- return;
- }
-
- String[] validatorNames = vmd.getValidatorNames();
- String targetObjectName = getTargetObjectName(helper, obj);
- removeMessageSubset(resource, validatorNames, targetObjectName, groupName);
- }
-} \ No newline at end of file
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
deleted file mode 100644
index eef9e53de..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationHelperRegistryReader.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.plugin;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.wst.validation.internal.IProjectValidationHelper;
-
-public class ValidationHelperRegistryReader extends RegistryReader {
-
- public static final String VALIDATION_HELPER = "validationHelper"; //$NON-NLS-1$
- static final String ATT_ID = "id"; //$NON-NLS-1$
- static final String ATT_HELPER_CLASS = "helperClass"; //$NON-NLS-1$
- private static ValidationHelperRegistryReader INSTANCE = null;
- private List validationHelpers = null;
-
- /**
- * Default constructor
- */
- public ValidationHelperRegistryReader() {
- super(ValidationPlugin.PLUGIN_ID, VALIDATION_HELPER);
- }
-
- public static ValidationHelperRegistryReader getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new ValidationHelperRegistryReader();
- INSTANCE.readRegistry();
- }
- return INSTANCE;
- }
-
- private List getValidationHelpers() {
- if (validationHelpers == null)
- validationHelpers = new ArrayList();
- return validationHelpers;
- }
-
- public boolean readElement(IConfigurationElement element) {
- if (!element.getName().equals(VALIDATION_HELPER))
- return false;
- IProjectValidationHelper helper = null;
- try {
- helper = (IProjectValidationHelper) element.createExecutableExtension(ATT_HELPER_CLASS);
- getValidationHelpers().add(helper);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
-
- public IProjectValidationHelper getValidationHelper() {
- if (getValidationHelpers().isEmpty())
- return null;
- return (IProjectValidationHelper) getValidationHelpers().get(0);
- }
-
-}
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationPlugin.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationPlugin.java
deleted file mode 100644
index 12170c21e..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/plugin/ValidationPlugin.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.validation.internal.plugin;
-
-import java.util.Locale;
-
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.wst.common.frameworks.internal.WTPPlugin;
-import org.eclipse.wst.validation.internal.EventManager;
-import org.eclipse.wst.validation.internal.TimeEntry;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-public class ValidationPlugin extends WTPPlugin {
- public static final String VALIDATION_PROP_FILE_NAME = "validate_base"; //$NON-NLS-1$
- public static final String PLUGIN_ID = "org.eclipse.wst.validation"; //$NON-NLS-1$
- private static ValidationPlugin _plugin = null;
- private static TimeEntry _tEntry = null;
- private static LogEntry _entry = null;
- private static Message _message = null;
- public static final String VALIDATION_BUILDER_ID = PLUGIN_ID + ".validationbuilder"; //$NON-NLS-1$// plugin id of the validation builder
- public static final String VALIDATOR_EXT_PT_ID = "validator"; //$NON-NLS-1$// extension point declaration of the validator
-
- /**
- * ValidationPlugin constructor comment.
- *
- * @param descriptor
- * org.eclipse.core.runtime.IPluginDescriptor
- */
- public ValidationPlugin() {
- super();
- if (_plugin == null) {
- _plugin = this;
- //Commenting off the following lines the Plugin is not activated and the
- //getMsgLogger tries to access the Plugin and the plugin is in a active pending state.
- //getMsgLogger();
- //logger.log(Level.CONFIG, null);
-
- }
- }
-
- public static String getBundleName() {
- return VALIDATION_PROP_FILE_NAME;
- }
-
- public static LogEntry getLogEntry() {
- if (_entry == null) {
- _entry = new LogEntry(VALIDATION_PROP_FILE_NAME);
- } else {
- _entry.reset();
- }
- // Always set the log entry's Locale before you use it
- // because the user can reset it on the fly.
- _entry.setLocaleOfOrigin(Locale.getDefault().toString());
- return _entry;
- }
-
- public static TimeEntry getTimeEntry() {
- if (_tEntry == null) {
- _tEntry = new TimeEntry();
- }
- _tEntry.reset();
- return _tEntry;
- }
-
- public static Message getMessage() {
- if (_message == null) {
- _message = new Message();
- _message.setBundleName(getBundleName());
- }
- // clear the message for reuse
- _message.setId(null);
- _message.setParams(null);
- _message.setTargetObject(null);
- _message.setGroupName(null);
- _message.setSeverity(IMessage.LOW_SEVERITY);
- return _message;
- }
-
- /**
- * Retrieves a hashtable of a logger's preferences initially from the
- * com.ibm.etools.logging.util.loggingDefaults extension point if specified in the
- * com.ibm.etools.logging.util plugin.xml file. If specified, the
- * com.ibm.etools.logging.util.loggingOptions extension point preferences in the parameter
- * plugin's plugin.xml file are returned.
- *
- * The logger's preferences are stored in the return hashtable using the static instance
- * variables in LoggerStateHashKeys as keys.
- *
- * @param plugin
- * the Plugin polled for their logger's preferences in the plugin.xml file
- * @return hashtable of a logger's preferences
- */
- /*
- * public Hashtable getMsgLoggerConfig(Plugin plugin) { return (new
- * PluginHelperImpl().getMsgLoggerConfig(plugin));
- */
- public static ValidationPlugin getPlugin() {
- return _plugin;
- }
-
- /**
- * Sets the logger's preferences based on values in the parameter hashtable.
- *
- * The logger's preferences are stored in the parameter hashtable using the static instance
- * variables in LoggerStateHashKeys as keys.
- *
- * @param msgLoggerConfig
- * hashtable of the logger's preferences
- */
- /*
- * public void setMsgLoggerConfig(Hashtable msgLoggerConfig) {
- * getMsgLogger().setMsgLoggerConfig(msgLoggerConfig); }
- */
- public static boolean isActivated() {
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- return bundle.getState() == Bundle.ACTIVE;
- return false;
- }
-
- /**
- * @see Plugin#startup()
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(EventManager.getManager(), IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_BUILD | IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_CHANGE);
- }
-
- /**
- * @see org.eclipse.core.runtime.Plugin#stop(BundleContext context)
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- EventManager.getManager().shutdown();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.WTPPlugin#getPluginID()
- */
- public String getPluginID() {
- return PLUGIN_ID;
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/provisional/ValidationFactory.java b/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/provisional/ValidationFactory.java
deleted file mode 100644
index caa461487..000000000
--- a/plugins/org.eclipse.wst.validation/validate/org/eclipse/wst/validation/internal/provisional/ValidationFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.validation.internal.provisional;
-
-import org.eclipse.wst.validation.internal.ValidationFactoryImpl;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This interface provides a way to access an instance of the ValidationFactoryImpl
- * instance, an internal implementation that provides access to some of the internal state
- * of validators.
- *
- * @plannedfor 1.0
- *
- * [issue: LM - 2 issues.
- * 1. I don't think the name 'factory' provides a good description of
- * this interface. Unless I'm mistaken the ValidationFactory doesn't
- * actually create validators but simply returns existing validators.
- * Looking at the implementation this is currently the case. I suggest
- * renaming this to ValidatorRegistry or something similar.
- * 2. I think the common way for creating a factory is to create a class
- * with a static method such as getFactory. If this is to be a factory
- * it should probably be structured as per the convention.]
- */
-public interface ValidationFactory {
-
- ValidationFactory instance = ValidationFactoryImpl.getInstance();
- /**
- * This api returns the IValidator given the validatorUniqueName id. The unique
- * id name is the class name that is defined in the class name element in the
- * plugin extension of the validator.
- * @param validatorUniqueId
- * @return IValidator
- * @plannedfor WTP 1.0
- */
- public IValidator getValidator(String validatorUniqueId) throws InstantiationException;
-
-}

Back to the top