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

The following examples show how to use org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor. 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();

}
 
Example #3
Source File: CompositeValidationIssueProcessor.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void processIssues(final List<Issue> issues, final IProgressMonitor monitor) {
	for (final IValidationIssueProcessor processor : processors) {
		if (null != processor) {
			processor.processIssues(issues, monitor);
		}
	}
}
 
Example #4
Source File: EditTemplateDialog.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected SourceViewer createViewer(Composite parent) {
	Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider);
	editorBuilder.processIssuesBy(new IValidationIssueProcessor() {
		@Override
		public void processIssues(List<Issue> issues, IProgressMonitor monitor) {
			IStatus result = Status.OK_STATUS;
			StringBuilder messages = new StringBuilder();
			for(Issue issue: issues) {
				if (issue.getSeverity() == Severity.ERROR) {
					if (messages.length() != 0)
						messages.append('\n');
					messages.append(issue.getMessage());
				}
			}
			if (messages.length() != 0) {
				result = createErrorStatus(messages.toString(), null);
			}
			final IStatus toBeUpdated = result;
			getShell().getDisplay().asyncExec(new Runnable() {
				@Override
				public void run() {
					updateStatus(toBeUpdated);
				}
			});
		}
	});
	EmbeddedEditor handle = editorBuilder.withParent(parent);
	partialModelEditor = handle.createPartialEditor(getPrefix(), fTemplate.getPattern(), "", true);
	return handle.getViewer();
}
 
Example #5
Source File: EmbeddedEditorFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public Builder processIssuesBy(IValidationIssueProcessor issueProcessor) {
	if (this.issueProcessor != null)
		throw new IllegalStateException();
	if (issueProcessor == null)
		throw new IllegalArgumentException();
	this.issueProcessor = issueProcessor;
	return this;
}
 
Example #6
Source File: GenericEditorModule.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void configure(Binder binder) {
	super.configure(binder);
	Multibinder<IEditProposalProvider> proposalProviderBinder = Multibinder.newSetBinder(binder,
			IEditProposalProvider.class);
	proposalProviderBinder.addBinding().to(SmartEditProposalProvider.class);
	proposalProviderBinder.addBinding().to(RefactoringProposalProvider.class);
	binder.bind(IResourceValidator.class).to(SCTResourceValidatorImpl.class);
	binder.bind(IValidationIssueProcessor.class).to(DefaultValidationIssueStore.class);
}
 
Example #7
Source File: ValidationJob.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public void setValidationIssueProcessor(IValidationIssueProcessor validationIssueProcessor) {
	this.validationIssueProcessor = validationIssueProcessor;
}
 
Example #8
Source File: LiveValidationListener.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public void setValidationIssueProcessor(IValidationIssueProcessor validationIssueProcessor) {
	validationJob.setValidationIssueProcessor(validationIssueProcessor);
}
 
Example #9
Source File: CompositeValidationIssueProcessor.java    From n4js with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new composite issue processor with the given sub processor arguments.
 *
 * @param first
 *            the first sub processor.
 * @param others
 *            the other processor;
 */
public CompositeValidationIssueProcessor(final IValidationIssueProcessor first,
		final IValidationIssueProcessor... others) {
	processors = Lists.asList(first, others);
}