use of com.redhat.qute.commons.datamodel.QuteDataModelProjectParams in project quarkus-ls by redhat-developer.
the class QuteSupportForTemplateDelegateCommandHandler method getProjectDataModel.
private static DataModelProject<DataModelTemplate<DataModelParameter>> getProjectDataModel(List<Object> arguments, String commandId, IProgressMonitor monitor) throws Exception {
QuteDataModelProjectParams params = createQuteProjectDataModelParams(arguments, commandId);
// Execute the getProjectDataModel in a Job to benefit with progress
// monitor
final AtomicReference<DataModelProject<DataModelTemplate<DataModelParameter>>> dataModelRef = new AtomicReference<DataModelProject<DataModelTemplate<DataModelParameter>>>(null);
Job job = Job.create("Qute data model collector", progress -> {
DataModelProject<DataModelTemplate<DataModelParameter>> project = QuteSupportForTemplate.getInstance().getDataModelProject(params, JDTUtilsLSImpl.getInstance(), progress);
dataModelRef.set(project);
});
job.schedule();
try {
job.join();
} catch (InterruptedException e) {
LOGGER.log(Level.WARNING, "Error while joining Qute data model collector job", e);
}
Exception jobException = (Exception) job.getResult().getException();
if (jobException != null) {
if (jobException.getCause() != null) {
throw (Exception) jobException.getCause();
}
throw jobException;
}
return dataModelRef.get();
}
use of com.redhat.qute.commons.datamodel.QuteDataModelProjectParams in project quarkus-ls by redhat-developer.
the class TemplateGetDataModelProjectTest method quteQuickStart.
@Test
public void quteQuickStart() throws Exception {
loadMavenProject(QuteMavenProjectName.qute_quickstart);
QuteDataModelProjectParams params = new QuteDataModelProjectParams(QuteMavenProjectName.qute_quickstart);
DataModelProject<DataModelTemplate<DataModelParameter>> project = QuteSupportForTemplate.getInstance().getDataModelProject(params, getJDTUtils(), new NullProgressMonitor());
Assert.assertNotNull(project);
// Test templates
testTemplates(project);
// Test value resolvers
List<ValueResolverInfo> resolvers = project.getValueResolvers();
Assert.assertNotNull(resolvers);
Assert.assertFalse(resolvers.isEmpty());
testValueResolversFomTemplateExtension(resolvers);
testValueResolversFomInject(resolvers);
}
use of com.redhat.qute.commons.datamodel.QuteDataModelProjectParams in project quarkus-ls by redhat-developer.
the class QuteSupportForTemplateDelegateCommandHandler method createQuteProjectDataModelParams.
private static QuteDataModelProjectParams createQuteProjectDataModelParams(List<Object> arguments, String commandId) {
Map<String, Object> obj = getFirst(arguments);
if (obj == null) {
throw new UnsupportedOperationException(String.format("Command '%s' must be called with one QuteProjectDataModelParams argument!", commandId));
}
// Get project name from the java file URI
String projectUri = getString(obj, PROJECT_URI_ATTR);
if (projectUri == null) {
throw new UnsupportedOperationException(String.format("Command '%s' must be called with required QuteProjectDataModelParams.projectUri!", commandId));
}
return new QuteDataModelProjectParams(projectUri);
}
use of com.redhat.qute.commons.datamodel.QuteDataModelProjectParams in project quarkus-ls by redhat-developer.
the class QuteProject method loadDataModelProject.
protected synchronized CompletableFuture<ExtendedDataModelProject> loadDataModelProject() {
if (dataModelProjectFuture != null) {
return dataModelProjectFuture;
}
QuteDataModelProjectParams params = new QuteDataModelProjectParams();
params.setProjectUri(getUri());
return //
getDataModelProject(params).thenApply(project -> {
if (project == null) {
return null;
}
return new ExtendedDataModelProject(project);
});
}
Aggregations