use of org.eclipse.wst.validation.ValidationResult in project liferay-ide by liferay.
the class WorkflowDefinitionValidator method validate.
@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE) {
return null;
}
ValidationResult result = new ValidationResult();
IFile workflowDefinitionXml = (IFile) resource;
if (workflowDefinitionXml.isAccessible() && CoreUtil.isLiferayProject(resource.getProject())) {
IScopeContext[] scopes = { new InstanceScope(), new DefaultScope() };
ProjectScope projectScope = new ProjectScope(workflowDefinitionXml.getProject());
boolean useProjectSettings = projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(ProjectCore.USE_PROJECT_SETTINGS, false);
if (useProjectSettings) {
scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
try {
Map<String, Object>[] problems = detectProblems(workflowDefinitionXml, scopes);
for (int i = 0; i < problems.length; i++) {
Object messageValue = problems[i].get(IMarker.MESSAGE);
ValidatorMessage message = ValidatorMessage.create(messageValue.toString(), resource);
message.setType(MARKER_TYPE);
message.setAttributes(problems[i]);
result.add(message);
}
if (ListUtil.isNotEmpty(problems)) {
IResource[] resources = { workflowDefinitionXml };
result.setDependsOn(resources);
}
} catch (Exception e) {
KaleoCore.logError(e);
}
}
return result;
}
use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.
the class JsValidator method validate.
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE || !shouldValidate((IFile) resource))
return null;
ValidationResult result = new ValidationResult();
IReporter reporter = result.getReporter(monitor);
IFile file = (IFile) resource;
validateFile(file, reporter);
result.setDependsOn(createDependencies(file));
return result;
}
use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.
the class JSPBatchValidatorTest method testFragmentValidationPreferenceOnProject.
public void testFragmentValidationPreferenceOnProject() throws Exception {
JSPBatchValidator validator1 = new JSPBatchValidator();
JSPContentValidator validator2 = new JSPContentValidator();
String filePath = "/" + PROJECT_NAME + "/WebContent/header.jspf";
ValidationResult result = null;
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
// enable workspace-wide but disable in project, no problem markers
// expected
workspaceScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
projectScope.putBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, true);
projectScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, false);
result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
assertEquals("Problems found while fragment validation was disabled in project but enabled on workspace", 0, (((ReporterHelper) result.getReporter(null)).getMessages().size()));
/*
* disable workspace-wide but enable in project, some problem markers
* expected
*/
workspaceScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, false);
projectScope.putBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, true);
projectScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
JSPFContentProperties.setProperty(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, file, Boolean.toString(true));
result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
assertTrue("Problems not found while fragment validation was enabled for project but disabled on workspace", 0 < (((ReporterHelper) result.getReporter(null)).getMessages().size()));
}
use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.
the class JSONSyntaxValidator method validate.
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;
}
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();
IReporter reporter = result.getReporter(monitor);
validateV1File((IFile) resource, reporter);
return result;
}
Aggregations