Search in sources :

Example 1 with QuteDataModelProjectParams

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();
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) QuteDataModelProjectParams(com.redhat.qute.commons.datamodel.QuteDataModelProjectParams) DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) AtomicReference(java.util.concurrent.atomic.AtomicReference) Job(org.eclipse.core.runtime.jobs.Job) DataModelProject(com.redhat.qute.commons.datamodel.DataModelProject) JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with QuteDataModelProjectParams

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QuteDataModelProjectParams(com.redhat.qute.commons.datamodel.QuteDataModelProjectParams) ValueResolverInfo(com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo) DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) Test(org.junit.Test)

Example 3 with QuteDataModelProjectParams

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);
}
Also used : QuteDataModelProjectParams(com.redhat.qute.commons.datamodel.QuteDataModelProjectParams) ArgumentUtils.getString(com.redhat.qute.jdt.internal.ls.ArgumentUtils.getString)

Example 4 with QuteDataModelProjectParams

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);
    });
}
Also used : QuteDataModelProjectParams(com.redhat.qute.commons.datamodel.QuteDataModelProjectParams) ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject)

Aggregations

QuteDataModelProjectParams (com.redhat.qute.commons.datamodel.QuteDataModelProjectParams)4 DataModelTemplate (com.redhat.qute.commons.datamodel.DataModelTemplate)2 DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)1 DataModelProject (com.redhat.qute.commons.datamodel.DataModelProject)1 ValueResolverInfo (com.redhat.qute.commons.datamodel.resolvers.ValueResolverInfo)1 ArgumentUtils.getString (com.redhat.qute.jdt.internal.ls.ArgumentUtils.getString)1 ExtendedDataModelProject (com.redhat.qute.project.datamodel.ExtendedDataModelProject)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 Test (org.junit.Test)1