use of com.redhat.qute.services.diagnostics.ResolvingJavaTypeContext in project quarkus-ls by redhat-developer.
the class TemplateFileTextDocumentService method triggerValidationFor.
private void triggerValidationFor(QuteTextDocument document) {
//
document.getModel().thenApply((template) -> {
// The template is parsed, check if the document has changed since the
// parsing
template.checkCanceled();
// Collect diagnostics
ResolvingJavaTypeContext resolvingJavaTypeContext = new ResolvingJavaTypeContext(template);
List<Diagnostic> diagnostics = getQuteLanguageService().doDiagnostics(template, getSharedSettings().getValidationSettings(template.getUri()), resolvingJavaTypeContext, () -> template.checkCanceled());
// Diagnostics has been collected, before diagnostics publishing, check if the
// document has changed since diagnostics collect.
template.checkCanceled();
// Publish diagnostics
quteLanguageServer.getLanguageClient().publishDiagnostics(new PublishDiagnosticsParams(template.getUri(), diagnostics));
if (!resolvingJavaTypeContext.isEmpty()) {
// Some Java types was not loaded, wait for that all Java types are resolved to
// retrigger the validation.
CompletableFuture<Void> allFutures = CompletableFuture.allOf(resolvingJavaTypeContext.toArray(new CompletableFuture[resolvingJavaTypeContext.size()]));
allFutures.thenAccept(Void -> {
triggerValidationFor(document);
});
}
return null;
});
}
use of com.redhat.qute.services.diagnostics.ResolvingJavaTypeContext in project quarkus-ls by redhat-developer.
the class QuteAssert method testDiagnosticsFor.
public static void testDiagnosticsFor(String value, String fileUri, String templateId, String projectUri, String templateBaseDir, boolean filter, QuteValidationSettings validationSettings, Diagnostic... expected) {
QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
template.setTemplateId(templateId);
QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
List<Diagnostic> actual = languageService.doDiagnostics(template, validationSettings, new ResolvingJavaTypeContext(template), () -> {
});
if (expected == null) {
assertTrue(actual.isEmpty());
return;
}
assertDiagnostics(actual, Arrays.asList(expected), filter);
}
Aggregations