Search in sources :

Example 1 with ExtendedDataModelProject

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

the class QuteProjectRegistry method getNamespaceResolvers.

/**
 * Returns namespace resolvers from the given Qute project Uri.
 *
 * @param projectUri the Qute project Uri
 *
 * @return namespace resolvers from the given Qute project Uri.
 */
public List<ValueResolver> getNamespaceResolvers(String namespace, String projectUri) {
    if (StringUtils.isEmpty(projectUri)) {
        return Collections.emptyList();
    }
    QuteProject project = getProject(projectUri);
    if (project == null) {
        return Collections.emptyList();
    }
    ExtendedDataModelProject dataModel = project.getDataModelProject().getNow(null);
    if (dataModel == null) {
        return Collections.emptyList();
    }
    List<ValueResolver> namespaceResolvers = new ArrayList<>();
    List<TypeValueResolver> allTypeResolvers = dataModel.getTypeValueResolvers();
    if (allTypeResolvers != null) {
        for (ValueResolver resolver : allTypeResolvers) {
            if (isMatchNamespace(resolver, namespace, dataModel)) {
                namespaceResolvers.add(resolver);
            }
        }
    }
    List<MethodValueResolver> allMethodResolvers = dataModel.getMethodValueResolvers();
    if (allMethodResolvers != null) {
        for (ValueResolver resolver : allMethodResolvers) {
            if (isMatchNamespace(resolver, namespace, dataModel)) {
                namespaceResolvers.add(resolver);
            }
        }
    }
    List<FieldValueResolver> allFieldResolvers = dataModel.getFieldValueResolvers();
    if (allFieldResolvers != null) {
        for (ValueResolver resolver : allFieldResolvers) {
            if (isMatchNamespace(resolver, namespace, dataModel)) {
                namespaceResolvers.add(resolver);
            }
        }
    }
    return namespaceResolvers;
}
Also used : TypeValueResolver(com.redhat.qute.project.datamodel.resolvers.TypeValueResolver) ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject) MethodValueResolver(com.redhat.qute.project.datamodel.resolvers.MethodValueResolver) FieldValueResolver(com.redhat.qute.project.datamodel.resolvers.FieldValueResolver) ValueResolver(com.redhat.qute.project.datamodel.resolvers.ValueResolver) TypeValueResolver(com.redhat.qute.project.datamodel.resolvers.TypeValueResolver) MethodValueResolver(com.redhat.qute.project.datamodel.resolvers.MethodValueResolver) ArrayList(java.util.ArrayList) FieldValueResolver(com.redhat.qute.project.datamodel.resolvers.FieldValueResolver)

Example 2 with ExtendedDataModelProject

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

use of com.redhat.qute.project.datamodel.ExtendedDataModelProject 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)

Example 4 with ExtendedDataModelProject

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

the class QuteProjectRegistry method getAllNamespaces.

private Set<String> getAllNamespaces(String projectUri) {
    if (StringUtils.isEmpty(projectUri)) {
        return Collections.emptySet();
    }
    QuteProject project = getProject(projectUri);
    if (project == null) {
        return Collections.emptySet();
    }
    ExtendedDataModelProject dataModel = project.getDataModelProject().getNow(null);
    return dataModel != null ? dataModel.getAllNamespaces() : Collections.emptySet();
}
Also used : ExtendedDataModelProject(com.redhat.qute.project.datamodel.ExtendedDataModelProject)

Aggregations

ExtendedDataModelProject (com.redhat.qute.project.datamodel.ExtendedDataModelProject)4 DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)1 DataModelProject (com.redhat.qute.commons.datamodel.DataModelProject)1 DataModelTemplate (com.redhat.qute.commons.datamodel.DataModelTemplate)1 QuteDataModelProjectParams (com.redhat.qute.commons.datamodel.QuteDataModelProjectParams)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 ValueResolver (com.redhat.qute.project.datamodel.resolvers.ValueResolver)1 ArrayList (java.util.ArrayList)1