use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class XMLValidator method executeMarkupValidator.
private IReporter executeMarkupValidator(String uri) {
Path path = new Path(uri);
// $NON-NLS-1$
String fileProtocol = "file://";
int index = uri.indexOf(fileProtocol);
IFile resource = null;
if (index == 0) {
String transformedUri = uri.substring(fileProtocol.length());
Path transformedPath = new Path(transformedUri);
resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(transformedPath);
} else {
resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
}
IReporter reporter = null;
if (resource != null) {
reporter = val.validate(resource, 0, new ValOperation().getState());
}
return reporter;
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project sling by apache.
the class IgnoreMissingGrammarXmlValidator method validate.
/** Perform the validation using version 2 of the validation framework. Copied from {@link AbstractNestedValidator#validate(IResource,
* int, ValidationState, IProgressMonitor). Cannot use original one as that skips resources starting with "." */
@Override
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());
}
doValidate(file, null, result, reporter, nestedcontext);
if (teardownRequired)
teardownValidation(nestedcontext);
}
return result;
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPContentValidator method validate.
public ValidationResult validate(final IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
if (!shouldValidate(resource))
return null;
ValidationResult result = new ValidationResult();
final IReporter reporter = result.getReporter(monitor);
if (fragmentCheck((IFile) resource)) {
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager().getModelForRead((IFile) resource);
if (!reporter.isCancelled() && model instanceof IDOMModel) {
reporter.removeAllMessages(this, resource);
validate((IFile) resource, kind, state, monitor, (IDOMModel) model, reporter);
}
} catch (IOException e) {
Logger.logException(e);
} catch (CoreException e) {
Logger.logException(e);
} finally {
if (model != null)
model.releaseFromRead();
}
}
return result;
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPValidator method validate.
public ValidationResult validate(final IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
final IReporter reporter = result.getReporter(monitor);
validateFile((IFile) resource, reporter);
return result;
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPBatchValidator method validate.
public ValidationResult validate(final IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
if (!shouldValidate((IFile) resource))
return null;
final ValidationResult result = new ValidationResult();
final IReporter reporter = result.getReporter(monitor);
if (result.getDependsOn() != null) {
fDependsOn = new HashSet(Arrays.asList(result.getDependsOn()));
} else {
fDependsOn = new HashSet();
}
// add web.xml as a dependency
addDependsOn(DeploymentDescriptorPropertyCache.getInstance().getWebXML(resource.getFullPath()));
// List relevant JSP 2.0 preludes/codas as dependencies
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
PropertyGroup[] propertyGroups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(resource.getFullPath());
for (int j = 0; j < propertyGroups.length; j++) {
IPath[] preludes = propertyGroups[j].getIncludePrelude();
for (int i = 0; i < preludes.length; i++) {
addDependsOn(workspaceRoot.getFile(preludes[i]));
}
IPath[] codas = propertyGroups[j].getIncludeCoda();
for (int i = 0; i < codas.length; i++) {
addDependsOn(workspaceRoot.getFile(codas[i]));
}
}
IWorkspaceRunnable validationRunnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
if (fragmentCheck((IFile) resource)) {
validateFile((IFile) resource, reporter);
}
IResource[] resources = (IResource[]) fDependsOn.toArray(new IResource[fDependsOn.size()]);
result.setDependsOn(resources);
fDependsOn.clear();
}
};
Job currentJob = Job.getJobManager().currentJob();
ISchedulingRule rule = null;
if (currentJob != null) {
rule = currentJob.getRule();
}
try {
JavaCore.run(validationRunnable, rule, new NullProgressMonitor());
} catch (CoreException e) {
Logger.logException(e);
}
return result;
}
Aggregations