Search in sources :

Example 6 with ValidationResult

use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.

the class StreamingMarkupValidator method validate.

/* (non-Javadoc)
	 * @see org.eclipse.wst.validation.AbstractValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
	 */
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE)
        return null;
    ValidationResult result = new ValidationResult();
    fReporter = result.getReporter(monitor);
    validateFile((IFile) resource, fReporter);
    return result;
}
Also used : ValidationResult(org.eclipse.wst.validation.ValidationResult)

Example 7 with ValidationResult

use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.

the class AbstractNestedValidator method validate.

/**
 * Perform the validation using version 2 of the validation framework.
 */
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    ValidationResult result = new ValidationResult();
    IFile file = null;
    if (resource instanceof IFile)
        file = (IFile) resource;
    if (file != null && shouldValidate(file)) {
        IReporter reporter = result.getReporter(monitor);
        NestedValidatorContext nestedcontext = getNestedContext(state, false);
        boolean teardownRequired = false;
        if (nestedcontext == null) {
            // validationstart was not called, so manually setup and tear down
            nestedcontext = getNestedContext(state, true);
            nestedcontext.setProject(file.getProject());
            setupValidation(nestedcontext);
            teardownRequired = true;
        } else {
            nestedcontext.setProject(file.getProject());
        }
        validate(file, null, result, reporter, nestedcontext);
        if (teardownRequired)
            teardownValidation(nestedcontext);
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) ValidationResult(org.eclipse.wst.validation.ValidationResult)

Example 8 with ValidationResult

use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.

the class Validator method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    ValidationResult res = super.validate(resource, kind, state, monitor);
    if (resource.getType() == IResource.FILE) {
        StylesheetModel stylesheet = XSLCore.getInstance().getStylesheet((IFile) resource);
        IFile[] dependencies = stylesheet.getFileDependencies().toArray(new IFile[0]);
        res.setDependsOn(dependencies);
    }
    return res;
}
Also used : IFile(org.eclipse.core.resources.IFile) ValidationResult(org.eclipse.wst.validation.ValidationResult) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel)

Example 9 with ValidationResult

use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.

the class MarkupValidator method validate.

/* (non-Javadoc)
	 * @see org.eclipse.wst.validation.AbstractValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
	 */
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE)
        return null;
    ValidationResult result = new ValidationResult();
    fReporter = result.getReporter(monitor);
    validateV1File((IFile) resource, fReporter);
    return result;
}
Also used : ValidationResult(org.eclipse.wst.validation.ValidationResult)

Example 10 with ValidationResult

use of org.eclipse.wst.validation.ValidationResult in project sling by apache.

the class ContentProjectValidator method validate.

@Override
public ValidationResult validate(ValidationEvent event, ValidationState state, IProgressMonitor monitor) {
    ValidationResult res = new ValidationResult();
    if (!okToValidate) {
        return res;
    }
    okToValidate = false;
    IResource resource = event.getResource();
    IProject project = resource.getProject();
    IPath syncDir = ProjectUtil.getSyncDirectoryValue(project);
    IResource member = project.findMember(syncDir);
    try {
        // we assume this is the only validator putting validation markers with that id on the project itself
        deleteValidationMarkers(project);
        if (member == null) {
            addValidatorMessage(res, project, "Configured sync dir " + syncDir + " does not exist");
        } else if (member.getType() != IResource.FOLDER) {
            addValidatorMessage(res, project, "Configured sync dir " + syncDir + " is not a directory");
        }
    } catch (CoreException e) {
        getLogger().warn("Failed validating content project " + resource.getFullPath(), e);
    }
    return res;
}
Also used : IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ValidationResult(org.eclipse.wst.validation.ValidationResult) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Aggregations

ValidationResult (org.eclipse.wst.validation.ValidationResult)21 IFile (org.eclipse.core.resources.IFile)14 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)9 CoreException (org.eclipse.core.runtime.CoreException)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IResource (org.eclipse.core.resources.IResource)4 IOException (java.io.IOException)3 IPath (org.eclipse.core.runtime.IPath)3 Path (org.eclipse.core.runtime.Path)3 ValidationState (org.eclipse.wst.validation.ValidationState)3 ValidatorMessage (org.eclipse.wst.validation.ValidatorMessage)3 List (java.util.List)2 Map (java.util.Map)2 IProject (org.eclipse.core.resources.IProject)2 ProjectScope (org.eclipse.core.resources.ProjectScope)2 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)2 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)2 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)2 JSPBatchValidator (org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator)2 JSPContentValidator (org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)2