org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OwnResourceValidatorAwareValidatingEditorCallback.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
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(), annotationModel, 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);
		});
	}
 
Example #2
Source File: GamlEditor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private void scheduleValidationJob() {
	if (!isEditable()) { return; }
	final IValidationIssueProcessor processor = new MarkerIssueProcessor(getResource(),
			getInternalSourceViewer().getAnnotationModel(), markerCreator, markerTypeProvider);
	final ValidationJob validate = new ValidationJob(validator, getDocument(), processor, CheckMode.FAST_ONLY) {
		@Override
		protected IStatus run(final IProgressMonitor monitor) {
			final List<Issue> issues = getDocument().readOnly(resource -> {
				if (resource.isValidationDisabled()) { return Collections.emptyList(); }
				return validator.validate(resource, getCheckMode(), null);
			});
			processor.processIssues(issues, monitor);
			return Status.OK_STATUS;
		}

	};
	validate.schedule();

}