Source Validation

org.eclipse.wst.sse.ui.sourcevalidation

This extension point is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

This extension point is provided to allow clients to contribute a validator (org.eclipse.wst.validation.internal.provisional.core.IValidator) for as-you-type (source) validation.
If your validator can handle "partial document" validation, it should also implement ISourceValidator. The validate call on ISourceValidator gets passed an IRegion representation of the part of the document that's dirty.
This should be much more efficient than validating the entire file each time someone types.
The validator is enabled for specific content type/partition combinations.
Required plugins are:
org.eclipse.wst.sse.ui
org.eclipse.wst.validation

<!ELEMENT extension (validator)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED>


<!ELEMENT validator (contentTypeIdentifier+)>

<!ATTLIST validator

id    CDATA #IMPLIED

class CDATA #IMPLIED

scope CDATA #IMPLIED>


<!ELEMENT partitionType EMPTY>

<!ATTLIST partitionType

id CDATA #IMPLIED>


<!ELEMENT contentTypeIdentifier (partitionType*)>

<!ATTLIST contentTypeIdentifier

id CDATA #IMPLIED>


Example demonstrating how HTMLValidator contributes to as-you-type validation in the source editor.
   

<extension point=

"org.eclipse.wst.sse.ui.extensions.sourcevalidation"

>

<validator scope=

"total"

class=

"org.eclipse.wst.validation.html.HTMLValidator"

id=

"org.eclipse.wst.validation.htmlsourcevalidator"

>

<contentTypeIdentifier id=

"org.eclipse.wst.html.core.htmlsource"

>

<partitionType id=

"org.eclipse.wst.html.HTML_DEFAULT"

/>

</contentTypeIdentifier>

<contentTypeIdentifier id=

"org.eclipse.jst.jsp.core.jspsource"

>

<partitionType id=

"org.eclipse.wst.html.HTML_DEFAULT"

/>

</contentTypeIdentifier>

</validator>

</extension>

Using ISourceValidator

If your validator can handle "partial document" validation, it should implement ISourceValidator.

The validate call on ISourceValidator gets passed an IRegion of the document which represents just the part that's dirty. This should be much more efficient than validating the entire file each time someone types.

ISourceValidator has its "connect(IDocument doc)" method called when it's hooked up to the document (when the editor is opened), and "disconnect(IDocument doc)" called when the editor is closed, where any "unhooking" should take place.

Currently there is no supplied implementation for IValidator.