Search in sources :

Example 1 with DataModelProject

use of com.redhat.qute.commons.datamodel.DataModelProject in project quarkus-ls by redhat-developer.

the class MockQuteProject method loadDataModelProject.

@Override
protected synchronized CompletableFuture<ExtendedDataModelProject> loadDataModelProject() {
    DataModelProject<DataModelTemplate<DataModelParameter>> project = new DataModelProject<DataModelTemplate<DataModelParameter>>();
    project.setTemplates(templates);
    project.setValueResolvers(valueResolvers);
    project.setNamespaceResolverInfos(namespaceResolverInfos);
    return CompletableFuture.completedFuture(new ExtendedDataModelProject(project));
}
Also used : DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject) DataModelProject(com.redhat.qute.commons.datamodel.DataModelProject) ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject)

Example 2 with DataModelProject

use of com.redhat.qute.commons.datamodel.DataModelProject 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 3 with DataModelProject

use of com.redhat.qute.commons.datamodel.DataModelProject in project quarkus-ls by redhat-developer.

the class ExtendedDataModelProject method getAllNamespaces.

private static Set<String> getAllNamespaces(DataModelProject<DataModelTemplate<DataModelParameter>> project) {
    Set<String> allNamespaces = // 
    project.getValueResolvers().stream().filter(// 
    resolver -> resolver.getNamespace() != null).map(// 
    resolver -> resolver.getNamespace()).distinct().collect(Collectors.toSet());
    allNamespaces.add(NamespacePart.DATA_NAMESPACE);
    for (NamespaceResolverInfo info : project.getNamespaceResolverInfos().values()) {
        info.getNamespaces().forEach(namespace -> {
            allNamespaces.add(namespace);
        });
    }
    return allNamespaces;
}
Also used : DataModelTemplate(com.redhat.qute.commons.datamodel.DataModelTemplate) MethodValueResolver(com.redhat.qute.project.datamodel.resolvers.MethodValueResolver) DataModelProject(com.redhat.qute.commons.datamodel.DataModelProject) NamespacePart(com.redhat.qute.parser.expression.NamespacePart) TypeValueResolver(com.redhat.qute.project.datamodel.resolvers.TypeValueResolver) Set(java.util.Set) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) DataModelParameter(com.redhat.qute.commons.datamodel.DataModelParameter) Map(java.util.Map) Entry(java.util.Map.Entry) JavaElementKind(com.redhat.qute.commons.JavaElementKind) MATCH_NAME_ANY(com.redhat.qute.project.datamodel.resolvers.ValueResolver.MATCH_NAME_ANY) FieldValueResolver(com.redhat.qute.project.datamodel.resolvers.FieldValueResolver) Collections(java.util.Collections) NamespaceResolverInfo(com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo) NamespaceResolverInfo(com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo)

Aggregations

DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)3 DataModelProject (com.redhat.qute.commons.datamodel.DataModelProject)3 DataModelTemplate (com.redhat.qute.commons.datamodel.DataModelTemplate)3 JavaElementKind (com.redhat.qute.commons.JavaElementKind)1 QuteDataModelProjectParams (com.redhat.qute.commons.datamodel.QuteDataModelProjectParams)1 NamespaceResolverInfo (com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo)1 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)1 ExtendedDataModelProject (com.redhat.qute.project.datamodel.ExtendedDataModelProject)1 FieldValueResolver (com.redhat.qute.project.datamodel.resolvers.FieldValueResolver)1 MethodValueResolver (com.redhat.qute.project.datamodel.resolvers.MethodValueResolver)1 TypeValueResolver (com.redhat.qute.project.datamodel.resolvers.TypeValueResolver)1 MATCH_NAME_ANY (com.redhat.qute.project.datamodel.resolvers.ValueResolver.MATCH_NAME_ANY)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1