Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Validator2 won't run on build?(Why won't my validator run on build.)
Validator2 won't run on build? [message #976187] Thu, 08 November 2012 11:34 Go to next message
William Bath is currently offline William BathFriend
Messages: 3
Registered: July 2009
Junior Member
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 11:36]

Report message to a moderator

Re: Validator2 won't run on build? [message #976457 is a reply to message #976187] Thu, 08 November 2012 15:45 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Looks like the Validation Builder itself is not set on the project. The project's Validation property page can do that for you. It should add this to your .project file, before the natures tag:

<buildSpec>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Validator2 won't run on build? [message #976828 is a reply to message #976457] Thu, 08 November 2012 22:03 Go to previous message
William Bath is currently offline William BathFriend
Messages: 3
Registered: July 2009
Junior Member
Bang on Nitin; as soon as I put it in my .project validation came to life! Thanks!
Cheers,
Will.
Previous Topic:Failed while installing Axis2 Web Services Core 1.1
Next Topic:Adding JavaScript Library to a JavaScriptProject programatically
Goto Forum:
  


Current Time: Tue Apr 16 18:49:19 GMT 2024

Powered by FUDForum. Page generated in 0.53115 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top