Search in sources :

Example 1 with ValidationJob

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);
    }
}
Also used : AnnotationIssueProcessor(org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor) ValidationJob(org.eclipse.xtext.ui.editor.validation.ValidationJob)

Example 2 with ValidationJob

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);
}
Also used : ValidationJob(org.eclipse.xtext.ui.editor.validation.ValidationJob)

Example 3 with ValidationJob

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;
}
Also used : IValidationIssueProcessor(org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) IResource(org.eclipse.core.resources.IResource) MarkerIssueProcessor(org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) AnnotationIssueProcessor(org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor) ValidationJob(org.eclipse.xtext.ui.editor.validation.ValidationJob)

Example 4 with ValidationJob

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) ValidationJob(org.eclipse.xtext.ui.editor.validation.ValidationJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 5 with ValidationJob

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);
    });
}
Also used : IValidationIssueProcessor(org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor) MarkerTypeProvider(org.eclipse.xtext.ui.validation.MarkerTypeProvider) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IssueResolutionProvider(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider) IResourceValidator(org.eclipse.xtext.validation.IResourceValidator) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) MarkerCreator(org.eclipse.xtext.ui.editor.validation.MarkerCreator) MarkerIssueProcessor(org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) AnnotationIssueProcessor(org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor) ValidationJob(org.eclipse.xtext.ui.editor.validation.ValidationJob)

Aggregations

ValidationJob (org.eclipse.xtext.ui.editor.validation.ValidationJob)5 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)3 AnnotationIssueProcessor (org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor)3 IValidationIssueProcessor (org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor)2 MarkerIssueProcessor (org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor)2 IResource (org.eclipse.core.resources.IResource)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Job (org.eclipse.core.runtime.jobs.Job)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)1 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)1 IssueResolutionProvider (org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider)1 MarkerCreator (org.eclipse.xtext.ui.editor.validation.MarkerCreator)1 MarkerTypeProvider (org.eclipse.xtext.ui.validation.MarkerTypeProvider)1 IResourceValidator (org.eclipse.xtext.validation.IResourceValidator)1