Validator2 won't run on build? [message #976187] |
Thu, 08 November 2012 06:34  |
Eclipse User |
|
|
|
Hi All,
I'm new to the validation framework and I am building a custom validator for some Javascript that is hosted on a remote server. I can get it to validate manually; but nothing happens on a build.
I used the validator extension point:
<extension
id="com.orchestrap.ops.opsValidator"
name="OPS Validator"
point="org.eclipse.wst.validation.validatorV2">
<validator
build="true"
class="com.orchestral.ops.tools.validation.OPSValidator"
manual="true">
<include>
<rules>
<fileext
caseSensitive="false"
ext="op">
</fileext>
</rules>
</include>
<group
id="com.orchestral.tops.group">
</group>
<messageCategory
id="com.orchestral.tops.errorMessageCategory"
label="OPS Errors"
severity="error">
</messageCategory>
</validator>
</extension>
and implemented it:
public class OPSValidator extends AbstractValidator {
public OPSValidator() {
System.err.println("OPSVAl is here!");
}
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
System.err.println("OPSVAl validating: "+resource.getName());
List<ScriptValidationProblem> probs = getValidationProblems(resource);
ValidationResult vr = new ValidationResult();
for (ScriptValidationProblem p : probs){
ValidatorMessage message = ValidatorMessage.create(p.getMessage(), resource);
message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
message.setAttribute(IMarker.LINE_NUMBER, p.getLineNumber());
vr.add(message);
vr.incrementError(1);
}
return vr;
}
@Override
public ValidationResult validate(ValidationEvent event,
ValidationState state, IProgressMonitor monitor) {
return validate(event.getResource(), event.getKind(), state, monitor);
}
private List<ScriptValidationProblem> getValidationProblems(IResource resource){
try {
if (resource.getLocationURI().getScheme().equals(OpsCmsFileSystem.OPS_SCHEME)){
OpsCmsFileStore store = (OpsCmsFileStore)EFS.getStore(resource.getLocationURI());
return store.getValidationProblems();
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return Collections.EMPTY_LIST;
}
}
and it all works for manual validation (i.e. if I right click and select validate in the context menu; but nothing happens off a build (I've tried automatic building; cleaning and building manually; nothing happens).
I've checked the preferences to ensure my validator shows up and has the manual and build options checked; all good.
So what else do I need to do to get my validator to validate my resources on build?
Do I need specific natures; do I need a specific builder in my .project file? For completeness; here is my .project file:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OPS</name>
<comment></comment>
<projects>
</projects>
<natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.orchestral.opsNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
Any and all help much appreciated!
[Updated on: Thu, 08 November 2012 06:36] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08415 seconds