blob: 87823d674d943cf2f2fee8b994c90019dbb1f6b2 [file] [log] [blame]
<title>Validation Framework</title>
<p>A framework for calling validators that are build based.</p>
There are two main types of validation, <b>build based</b> and
<b>as you type</b>. This framework supports build based
validation. If auto build is turned on then the validators are called
when the user saves their file. If auto build is not turned on then
the validators are called when the user starts a build.</p>
<p>This framework was added to WTP in version 3.4.</p>
<h3>Dependency Support</h3>
<p>Sometimes resources depend on other resources, to determine whether they are
valid or not. An example would be that an XML resource could depend on a DTD. If at some
point in the future the DTD changes, then the dependent XML resource should be
revalidated to ensure that it still meets the requirements of the changed DTD
file. In order to do this efficiently, there needs to be an association between
the DTD and all the resources that depend on it.<p>To be as efficient as possible, the validation framework allows
this dependency information to be returned as part of a
<a href="AbstractValidator.html#validate(org.eclipse.core.resources.IResource, int, ValidationState, org.eclipse.core.runtime.IProgressMonitor)">
validate operation</a>. Since the validator needed to figure this out anyways,
why not pass this information back to the framework, so that it can be saved.
This saves the cost of having to parse the file at some later point in time
(when the file is probably sitting cold on disk). The fewer times that we need
to open, read and/or parse the same file, will improve the performance of the
<p>In particular when the validate method returns, a
<a href="ValidationResult.html">ValidationResult</a> must be returned, inside of
this result, all your dependencies need to be specified with the&nbsp;
<a href="ValidationResult.html#setDependsOn(org.eclipse.core.resources.IResource[])">
setDependsOn</a> method.<p>In addition to keeping the dependency information
up-to-date through the normal course of validation, direct access is also
provided to the dependency support through the
<a href="ValidationFramework.html#getDependencyIndex()">getDependencyIndex</a>
method. The <a href="IDependencyIndex.html">IDependencyIndex</a> allows you to
directly manipulate the dependency information for a validator.