Issue
Currently I have source validator(org.eclipse.wst.sse.ui.sourcevalidation) to check the html source:
<extension point="org.eclipse.wst.sse.ui.sourcevalidation">
<validator
scope="total"
class="com.test.HtmlValidator"
id="com.test.HtmlValidator.total">
<contentTypeIdentifier
id="org.eclipse.wst.html.core.htmlsource">
<partitionType id="org.eclipse.wst.html.HTML_DEFAULT"/>
<partitionType id="org.eclipse.wst.html.HTML_DECLARATION"/>
<partitionType id="org.eclipse.wst.html.HTML_COMMENT"/>
</contentTypeIdentifier>
</validator>
The source validator works as expected with the default html editor (org.eclipse.wst.html.core.htmlsource.source) but if I open the same files with the Eclipse Generic Editor (org.eclipse.ui.genericeditor.GenericEditor, Eclipse Wild Web Developer uses it to open all the web development files) the source validator does not work.
Until I know the source validator works directly with the content type not with the editor, my question here is what should I do to make the validator work with both editors?
Solution
To solve this problem I have found a workaround using the org.eclipse.core.filebuffers.documentSetup extension point, this extension point executes the method IDocumentSetupParticipant.setup(IDocument document), the advantage of this extension point is that it is independent of the editor. org.eclipse.core.filebuffers.documentSetup executes when a file with certain content type is open using any editor.
<extension
point="org.eclipse.core.filebuffers.documentSetup">
<participant
class="setup.HTMLDocumentSetup"
contentTypeId="org.eclipse.wst.html.core.htmlsource">
</participant>
</extension>
In IDocumentSetupParticipant.setup we can register a IDocumentListener, this interface defines 2 methods:
- documentAboutToBeChanged
- documentChanged
If we use documentChanged, every time that the user types something in the editor the method will executed.
Answered By - Jaime Villaseñor