use of org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy in project webtools.sourceediting by eclipse.
the class DocumentRegionProcessor method endProcessing.
protected void endProcessing() {
super.endProcessing();
ValidatorStrategy validatorStrategy = getValidatorStrategy();
if (validatorStrategy != null) {
validatorStrategy.endProcessing();
}
/* single spell-check for everything to ensure that SpellingProblem offsets are correct */
IReconcilingStrategy spellingStrategy = getSpellcheckStrategy();
IDocument document = getDocument();
if (spellingStrategy != null && document != null) {
spellingStrategy.reconcile(new Region(0, document.getLength()));
}
IReconcilingStrategy semanticHighlightingStrategy = getSemanticHighlightingStrategy();
if (semanticHighlightingStrategy != null && document != null) {
semanticHighlightingStrategy.reconcile(new Region(0, document.getLength()));
}
if ((getTextViewer() instanceof ISourceViewer)) {
ISourceViewer sourceViewer = (ISourceViewer) getTextViewer();
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
for (int i = 0; i < fReconcileListeners.length; i++) {
fReconcileListeners[i].reconciled(document, annotationModel, false, new NullProgressMonitor());
}
}
}
use of org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy 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.ValidatorStrategy 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;
}
use of org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy in project webtools.sourceediting by eclipse.
the class TestSourceValidationFramework method getSourceValidatorIDs.
private List getSourceValidatorIDs(String fileName) throws Exception {
List validatorIds = new ArrayList(1);
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IFile file = ensureFileIsAccessible(PROJECT_NAME + SEPARATOR + fileName, null);
IEditorPart editor = IDE.openEditor(page, file, TestStructuredTextEditor.class.getName(), true);
ITextEditor textEditor = editor.getAdapter(ITextEditor.class);
TestStructuredTextEditor testTextEditor = (TestStructuredTextEditor) textEditor;
IReconciler reconciler = testTextEditor.textViewerConfiguration.getReconciler(testTextEditor.getTextViewer());
assertNotNull(reconciler);
assertTrue("unexpected IReconciler implementation: " + reconciler.getClass(), reconciler instanceof DocumentRegionProcessor);
Class reconcilerClass = reconciler.getClass();
Method method = null;
while (reconcilerClass != Object.class && method == null) {
Method[] methods = reconcilerClass.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals("getValidatorStrategy")) {
method = methods[i];
}
}
reconcilerClass = reconcilerClass.getSuperclass();
}
assertNotNull("no getValidatorStrategy method found on " + reconciler.getClass(), method);
method.setAccessible(true);
ValidatorStrategy strategy = (ValidatorStrategy) method.invoke(reconciler, new Object[0]);
assertNotNull(strategy);
Field fMetaData = strategy.getClass().getDeclaredField("fMetaData");
assertNotNull("validator metadata field \"fMetaData\" not found on strategy " + strategy.getClass(), fMetaData);
fMetaData.setAccessible(true);
List metadata = (List) fMetaData.get(strategy);
assertNotNull(metadata);
for (int i = 0; i < metadata.size(); i++) {
validatorIds.add(((ValidatorMetaData) metadata.get(i)).getValidatorId());
}
page.closeEditor(editor, false);
return validatorIds;
}
use of org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy in project webtools.sourceediting by eclipse.
the class DocumentRegionProcessor method beginProcessing.
protected void beginProcessing() {
super.beginProcessing();
ValidatorStrategy validatorStrategy = getValidatorStrategy();
if (validatorStrategy != null) {
validatorStrategy.beginProcessing();
}
if ((getTextViewer() instanceof ISourceViewer)) {
for (int i = 0; i < fReconcileListeners.length; i++) {
fReconcileListeners[i].aboutToBeReconciled();
}
}
}
Aggregations