use of org.eclipse.xtext.ui.editor.validation.ValidationJob in project xtext-eclipse by eclipse.
the class XtextDocumentProvider method registerAnnotationInfoProcessor.
/**
* @since 2.4
*/
protected void registerAnnotationInfoProcessor(ElementInfo info) {
XtextDocument doc = (XtextDocument) info.fDocument;
if (info.fModel != null) {
AnnotationIssueProcessor annotationIssueProcessor = new AnnotationIssueProcessor(doc, info.fModel, issueResolutionProvider);
ValidationJob job = new ValidationJob(resourceValidator, doc, annotationIssueProcessor, CheckMode.FAST_ONLY);
doc.setValidationJob(job);
}
}
use of org.eclipse.xtext.ui.editor.validation.ValidationJob in project xtext-eclipse by eclipse.
the class XtextDocumentProvider method disposeElementInfo.
@Override
protected void disposeElementInfo(Object element, ElementInfo info) {
if (info.fDocument instanceof XtextDocument) {
XtextDocument document = (XtextDocument) info.fDocument;
ValidationJob job = (ValidationJob) document.getValidationJob();
if (job != null) {
job.cancel();
}
document.disposeInput();
}
super.disposeElementInfo(element, info);
}
use of org.eclipse.xtext.ui.editor.validation.ValidationJob in project xtext-eclipse by eclipse.
the class ValidateActionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null) {
IValidationIssueProcessor issueProcessor;
IXtextDocument xtextDocument = xtextEditor.getDocument();
IResource resource = xtextEditor.getResource();
if (resource != null)
issueProcessor = new MarkerIssueProcessor(resource, xtextEditor.getInternalSourceViewer().getAnnotationModel(), markerCreator, markerTypeProvider);
else
issueProcessor = new AnnotationIssueProcessor(xtextDocument, xtextEditor.getInternalSourceViewer().getAnnotationModel(), issueResolutionProvider);
ValidationJob validationJob = new ValidationJob(resourceValidator, xtextDocument, issueProcessor, CheckMode.ALL);
validationJob.schedule();
}
return this;
}
use of org.eclipse.xtext.ui.editor.validation.ValidationJob in project xtext-eclipse by eclipse.
the class XtextGrammarQuickfixProviderTest method validateInEditor.
private void validateInEditor(IXtextDocument document) {
Job validationJob = ((XtextDocument) document).getValidationJob();
validationJob.schedule();
boolean wasInterrupted = false;
do {
try {
Job.getJobManager().join(ValidationJob.XTEXT_VALIDATION_FAMILY, new NullProgressMonitor());
wasInterrupted = false;
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (InterruptedException e) {
wasInterrupted = true;
}
} while (wasInterrupted);
}
use of org.eclipse.xtext.ui.editor.validation.ValidationJob in project n4js by eclipse.
the class OwnResourceValidatorAwareValidatingEditorCallback method newValidationJob.
private ValidationJob newValidationJob(final XtextEditor editor) {
final IXtextDocument document = editor.getDocument();
final IAnnotationModel annotationModel = editor.getInternalSourceViewer().getAnnotationModel();
final IssueResolutionProvider issueResolutionProvider = getService(editor, IssueResolutionProvider.class);
final MarkerTypeProvider markerTypeProvider = getService(editor, MarkerTypeProvider.class);
final MarkerCreator markerCreator = getService(editor, MarkerCreator.class);
final IValidationIssueProcessor issueProcessor = new CompositeValidationIssueProcessor(new AnnotationIssueProcessor(document, annotationModel, issueResolutionProvider), new MarkerIssueProcessor(editor.getResource(), markerCreator, markerTypeProvider));
return editor.getDocument().modify(resource -> {
final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
return new ValidationJob(resourceValidator, editor.getDocument(), issueProcessor, ALL);
});
}
Aggregations