use of org.eclipse.wst.sse.core.internal.validate.ValidationAdapter in project webtools.sourceediting by eclipse.
the class AbstractPropagatingValidator method propagateToChildElements.
private void propagateToChildElements(ValidationComponent validator, Node parent) {
if (parent == null)
return;
Class clazz = validator.getClass();
Node child = parent.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
INodeNotifier notifier = (INodeNotifier) child;
ValidationAdapter va = (ValidationAdapter) notifier.getExistingAdapter(clazz);
if (va == null) {
notifier.addAdapter(validator);
va = validator;
}
// bug 143213 - Can't batch validate open HTML files when
// as-you-type validation is enabled
va.setReporter(validator.getReporter());
va.validate((IndexedRegion) child);
}
child = child.getNextSibling();
}
}
use of org.eclipse.wst.sse.core.internal.validate.ValidationAdapter in project webtools.sourceediting by eclipse.
the class Propagator method propagateToChildElements.
public static void propagateToChildElements(ValidationComponent validator, Node parent) {
if (parent == null)
return;
Class clazz = validator.getClass();
NodeList children = parent.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child == null || child.getNodeType() != Node.ELEMENT_NODE)
continue;
INodeNotifier notifier = (INodeNotifier) child;
ValidationAdapter va = (ValidationAdapter) notifier.getExistingAdapter(clazz);
if (va == null) {
notifier.addAdapter(validator);
va = validator;
}
va.validate((IndexedRegion) child);
}
}
use of org.eclipse.wst.sse.core.internal.validate.ValidationAdapter in project webtools.sourceediting by eclipse.
the class HTMLSourceValidator method validate.
/**
* This validate call is for the ISourceValidator partial document validation approach
*
* @param dirtyRegion
* @param helper
* @param reporter
* @see org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator
*/
public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) {
if (helper == null || fDocument == null)
return;
if ((reporter != null) && (reporter.isCancelled() == true)) {
throw new OperationCanceledException();
}
IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
if (model == null)
// error
return;
try {
IDOMDocument document = null;
if (model instanceof IDOMModel) {
document = ((IDOMModel) model).getDocument();
}
if (document == null || !hasHTMLFeature(document)) {
// ignore
return;
}
IPath filePath = null;
IFile file = null;
ITextFileBuffer fb = FileBufferModelManager.getInstance().getBuffer(fDocument);
if (fb != null) {
filePath = fb.getLocation();
if (filePath.segmentCount() > 1) {
file = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
if (!file.isAccessible()) {
file = null;
}
}
} else {
filePath = new Path(model.getId());
}
// this will be the wrong region if it's Text (instead of Element)
// we don't know how to validate Text
// model.getIndexedRegion(dirtyRegion.getOffset());
IndexedRegion ir = getCoveringNode(dirtyRegion);
if (ir instanceof Text) {
while (ir != null && ir instanceof Text) {
// it's assumed that this gets the IndexedRegion to
// the right of the end offset
ir = model.getIndexedRegion(ir.getEndOffset());
}
}
if (ir instanceof INodeNotifier) {
INodeAdapterFactory factory = HTMLValidationAdapterFactory.getInstance();
ValidationAdapter adapter = (ValidationAdapter) factory.adapt((INodeNotifier) ir);
if (adapter == null)
// error
return;
if (reporter != null) {
HTMLValidationReporter rep = null;
rep = getReporter(reporter, file, (IDOMModel) model);
rep.clear();
adapter.setReporter(rep);
Message mess = new LocalizedMessage(IMessage.LOW_SEVERITY, filePath.toString().substring(1));
reporter.displaySubtask(this, mess);
}
adapter.validate(ir);
}
} finally {
releaseModel(model);
}
}
Aggregations