Search in sources :

Example 1 with MarkerIssueProcessor

use of org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor 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 2 with MarkerIssueProcessor

use of org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor 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

IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)2 AnnotationIssueProcessor (org.eclipse.xtext.ui.editor.validation.AnnotationIssueProcessor)2 IValidationIssueProcessor (org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor)2 MarkerIssueProcessor (org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor)2 ValidationJob (org.eclipse.xtext.ui.editor.validation.ValidationJob)2 IResource (org.eclipse.core.resources.IResource)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)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