I'm new to Eclipse plugin development, but I've been able to cobble together a plugin that defines a content type and a corresponding editor. I've gotten custom content assist going, so I know the editor is coming up okay.
My problem is that I need to create some custom validation for files of this content type, and I've found scant information. The only example I could find that has java code is here: http://www.eclipse.org/webtools/wst/components/sse/tutorials/source-validation.html . Unfortunately, copying this technique yields no results. My validator class is never even invoked.
Here are the relevant parts of my plugin.xml:
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type base-type="org.eclipse.core.runtime.xml"
file-extensions="xml"
id="com.palantir.eclipse.kite.contenttype.kite"
name="Kite File"
priority="normal">
<describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber">
<parameter name="element" value="kite"></parameter>
</describer>
</content-type>
</extension>
<extension point="org.eclipse.ui.editors">
<editor name="Kite XML Editor"
icon="icons/smalllogo.gif"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
class="com.palantir.eclipse.kite.plugin.editor.KiteXmlEditor"
id="com.palantir.eclipse.kite.plugin.editor.KiteXmlEditor">
<contentTypeBinding contentTypeId="com.palantir.eclipse.kite.contenttype.kite">
</contentTypeBinding>
</editor>
</extension>
<extension point="org.eclipse.wst.sse.ui.sourcevalidation">
<validator scope="total"
class="com.palantir.eclipse.kite.plugin.validator.KiteValidator"
id="com.palantir.eclipse.kite.plugin.validator.KiteValidator">
<contentTypeIdentifier id="com.palantir.eclipse.kite.contenttype.kite">
<partitionType id="org.eclipse.wst.sse.ST_DEFAULT" />
</contentTypeIdentifier>
</validator>
</extension>
And the validator file:
package com.palantir.eclipse.kite.plugin.validator;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator;
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;
public class KiteValidator implements ISourceValidator, IValidator {
public KiteValidator() {
System.out.println("Initialized KiteValidator");
}
public void cleanup(IReporter reporter) {
System.out.println("Inside KiteValidator");
}
public void validate(IValidationContext context, IReporter reporter) {
System.out.println("Inside KiteValidator");
}
public void connect(IDocument document) {
System.out.println("Inside KiteValidator");
}
public void disconnect(IDocument document) {
System.out.println("Inside KiteValidator");
}
public void validate(IRegion region, IValidationContext context, IReporter reporter) {
System.out.println("Inside KiteValidator");
}
}