use of org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorMetaData in project webtools.sourceediting by eclipse.
the class DocumentRegionProcessor method getValidatorStrategy.
/**
* @return Returns the ValidatorStrategy.
*/
protected ValidatorStrategy getValidatorStrategy() {
ValidatorStrategy validatorStrategy = null;
if (fValidatorStrategy == null && fValidationEnabled) {
if (getTextViewer() instanceof ISourceViewer) {
ISourceViewer viewer = (ISourceViewer) getTextViewer();
String contentTypeId = null;
IDocument doc = viewer.getDocument();
contentTypeId = getContentType(doc);
if (contentTypeId != null) {
validatorStrategy = new ValidatorStrategy(viewer, contentTypeId);
ValidatorBuilder vBuilder = new ValidatorBuilder();
ValidatorMetaData[] vmds = vBuilder.getValidatorMetaData(SSE_UI_ID);
List enabledValidators = new ArrayList(1);
/* if any "must" handle this content type, just add them */
boolean foundSpecificContentTypeValidators = false;
for (int i = 0; i < vmds.length; i++) {
if (vmds[i].mustHandleContentType(contentTypeId)) {
if (DEBUG_VALIDATORS)
// $NON-NLS-1$
Logger.log(Logger.INFO, contentTypeId + " using specific validator " + vmds[i].getValidatorId());
foundSpecificContentTypeValidators = true;
enabledValidators.add(vmds[i]);
}
}
if (!foundSpecificContentTypeValidators) {
for (int i = 0; i < vmds.length; i++) {
if (vmds[i].canHandleContentType(contentTypeId)) {
if (DEBUG_VALIDATORS)
// $NON-NLS-1$
Logger.log(Logger.INFO, contentTypeId + " using inherited(?) validator " + vmds[i].getValidatorId());
enabledValidators.add(vmds[i]);
}
}
}
for (int i = 0; i < enabledValidators.size(); i++) {
validatorStrategy.addValidatorMetaData((ValidatorMetaData) enabledValidators.get(i));
}
}
}
fValidatorStrategy = validatorStrategy;
} else if (fValidatorStrategy != null && fValidationEnabled) {
validatorStrategy = fValidatorStrategy;
}
return validatorStrategy;
}
use of org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorMetaData in project webtools.sourceediting by eclipse.
the class JavascriptValidationStrategy method getValidatorStrategy.
/**
* @return Returns the ValidatorStrategy.
*/
protected ValidatorStrategy getValidatorStrategy() {
ValidatorStrategy validatorStrategy = null;
if (fValidatorStrategy == null && fValidationEnabled) {
if (getTextViewer() instanceof ISourceViewer) {
ISourceViewer viewer = (ISourceViewer) getTextViewer();
String contentTypeId = getContentType();
if (contentTypeId != null) {
validatorStrategy = new ValidatorStrategy(viewer, contentTypeId);
ValidatorBuilder vBuilder = new ValidatorBuilder();
ValidatorMetaData[] vmds = vBuilder.getValidatorMetaData(SSE_UI_ID);
List enabledValidators = new ArrayList(1);
/* if any "must" handle this content type, just add them */
boolean foundSpecificContentTypeValidators = false;
for (int i = 0; i < vmds.length; i++) {
if (vmds[i].mustHandleContentType(contentTypeId)) {
if (DEBUG_VALIDATORS) {
// $NON-NLS-1$
String info = contentTypeId + " using specific validator " + vmds[i].getValidatorId();
IStatus status = new Status(IStatus.INFO, JavaScriptUI.ID_PLUGIN, info);
JavaScriptPlugin.getDefault().getLog().log(status);
}
foundSpecificContentTypeValidators = true;
enabledValidators.add(vmds[i]);
}
}
if (!foundSpecificContentTypeValidators) {
for (int i = 0; i < vmds.length; i++) {
if (vmds[i].canHandleContentType(contentTypeId)) {
if (DEBUG_VALIDATORS) {
// $NON-NLS-1$
String info = contentTypeId + " using inherited(?) validator " + vmds[i].getValidatorId();
IStatus status = new Status(IStatus.INFO, JavaScriptUI.ID_PLUGIN, info);
JavaScriptPlugin.getDefault().getLog().log(status);
}
enabledValidators.add(vmds[i]);
}
}
}
for (int i = 0; i < enabledValidators.size(); i++) {
validatorStrategy.addValidatorMetaData((ValidatorMetaData) enabledValidators.get(i));
}
}
}
fValidatorStrategy = validatorStrategy;
} else if (fValidatorStrategy != null && fValidationEnabled) {
validatorStrategy = fValidatorStrategy;
}
return validatorStrategy;
}
Aggregations