/** * @since 2.4 */ protected void validate(Resource resource, final CheckMode mode, final CancelIndicator monitor, IAcceptor<Issue> acceptor) { for (EObject ele : resource.getContents()) { if (monitor.isCanceled()) return; validate(resource, ele, mode, monitor, acceptor); } }
/** * @since 2.4 */ protected void validate(Resource resource, EObject element, final CheckMode mode, final CancelIndicator monitor, IAcceptor<Issue> acceptor) { try { Map<Object, Object> options = Maps.newHashMap(); options.put(CheckMode.KEY, mode); options.put(CancelableDiagnostician.CANCEL_INDICATOR, monitor); // disable concrete syntax validation, since a semantic model that has been parsed // from the concrete syntax always complies with it - otherwise there are parse errors. options.put(ConcreteSyntaxEValidator.DISABLE_CONCRETE_SYNTAX_EVALIDATOR, Boolean.TRUE); // see EObjectValidator.getRootEValidator(Map<Object, Object>) options.put(EValidator.class, diagnostician); if (resource instanceof XtextResource) { options.put(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME, ((XtextResource) resource).getLanguageName()); } Diagnostic diagnostic = diagnostician.validate(element, options); if (!diagnostic.getChildren().isEmpty()) { for (Diagnostic childDiagnostic : diagnostic.getChildren()) { issueFromEValidatorDiagnostic(childDiagnostic, acceptor); } } else { issueFromEValidatorDiagnostic(diagnostic, acceptor); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } }
task.start(); final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon; resolveProxies(resource, monitor); if (monitor.isCanceled()) return Collections.emptyList(); + resource.getWarnings().size()); try { IAcceptor<Issue> acceptor = createAcceptor(result); if (monitor.isCanceled()) return Collections.emptyList(); issueFromXtextResourceDiagnostic(resource.getErrors().get(i), Severity.ERROR, acceptor); if (monitor.isCanceled()) return Collections.emptyList(); issueFromXtextResourceDiagnostic(resource.getWarnings().get(i), Severity.WARNING, acceptor); return Collections.emptyList(); boolean syntaxDiagFail = !result.isEmpty(); logCheckStatus(resource, syntaxDiagFail, "Syntax"); validate(resource, mode, monitor, acceptor); if (monitor.isCanceled()) return Collections.emptyList();
protected void checkNoErrorsInValidator(final String model, XtextResource resource) { ResourceValidatorImpl validator = resourceValidatorProvider.get(); Assert.assertNotSame(validator, resource.getResourceServiceProvider().getResourceValidator()); validator.setDiagnosticConverter(new IDiagnosticConverter() { @Override public void convertValidatorDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic, IAcceptor<Issue> acceptor) { validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
@Override protected void validate(Resource resource, CheckMode mode, CancelIndicator monitor, IAcceptor<Issue> acceptor) { getOperationCanceledManager().checkCanceled(monitor); if (resource instanceof DerivedStateAwareResource) { List<EObject> contents = resource.getContents(); if (!contents.isEmpty()) { validate(resource, contents.get(0), mode, monitor, acceptor); } } else { super.validate(resource, mode, monitor, acceptor); } }