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); }); }
@Override public void processIssues(final List<Issue> issues, final IProgressMonitor monitor) { for (final IValidationIssueProcessor processor : processors) { if (null != processor) { processor.processIssues(issues, monitor); } } }
public Builder processIssuesBy(IValidationIssueProcessor issueProcessor) { if (this.issueProcessor != null) throw new IllegalStateException(); if (issueProcessor == null) throw new IllegalArgumentException(); this.issueProcessor = issueProcessor; return this; }
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); }
protected SourceViewer createViewer(final Composite parent) { Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider); editorBuilder.processIssuesBy(new IValidationIssueProcessor() { @Override public void processIssues(final List<Issue> issues, final 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(), data.getTemplate().getPattern(), "", true); return handle.getViewer(); }
public void setValidationIssueProcessor(IValidationIssueProcessor validationIssueProcessor) { this.validationIssueProcessor = validationIssueProcessor; }
public void setValidationIssueProcessor(IValidationIssueProcessor validationIssueProcessor) { validationJob.setValidationIssueProcessor(validationIssueProcessor); }
/** * 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); }