Search in sources :

Example 1 with NamespaceResolverInfo

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

the class AbstractDataModelProvider method endSearch.

@Override
public void endSearch(SearchContext context, IProgressMonitor monitor) {
    NamespaceResolverInfo info = getNamespaceResolverInfo();
    if (info != null) {
        // Register namespace information
        String namespacekey = info.getNamespaces().get(0);
        Map<String, NamespaceResolverInfo> infos = context.getDataModelProject().getNamespaceResolverInfos();
        infos.put(namespacekey, info);
    }
}
Also used : NamespaceResolverInfo(com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo)

Example 2 with NamespaceResolverInfo

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

the class DataModelProviderRegistry method createProvider.

@Override
protected IDataModelProvider createProvider(IConfigurationElement ce) throws CoreException {
    IDataModelProvider provider = super.createProvider(ce);
    String namespaces = ce.getAttribute(NAMESPACES_ATTR);
    if (StringUtils.isNotEmpty(namespaces)) {
        String description = ce.getAttribute(DESCRIPTION_ATTR);
        String url = ce.getAttribute(URL_ATTR);
        NamespaceResolverInfo info = new NamespaceResolverInfo();
        info.setNamespaces(Arrays.asList(namespaces.split(",")));
        info.setDescription(description);
        info.setUrl(url);
        provider.setNamespaceResolverInfo(info);
    }
    return provider;
}
Also used : NamespaceResolverInfo(com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo) IDataModelProvider(com.redhat.qute.jdt.template.datamodel.IDataModelProvider)

Example 3 with NamespaceResolverInfo

use of com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo 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)

Example 4 with NamespaceResolverInfo

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

the class QuteQuickStartProject method createNamespaceResolverInfos.

@Override
protected Map<String, NamespaceResolverInfo> createNamespaceResolverInfos() {
    Map<String, NamespaceResolverInfo> infos = new HashMap<>();
    NamespaceResolverInfo inject = new NamespaceResolverInfo();
    inject.setNamespaces(Arrays.asList("inject", "cdi"));
    inject.setDescription("A CDI bean annotated with `@Named` can be referenced in any template through `cdi` and/or `inject` namespaces.");
    inject.setUrl("https://quarkus.io/guides/qute-reference#injecting-beans-directly-in-templates");
    infos.put("inject", inject);
    return infos;
}
Also used : NamespaceResolverInfo(com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo) HashMap(java.util.HashMap)

Aggregations

NamespaceResolverInfo (com.redhat.qute.commons.datamodel.resolvers.NamespaceResolverInfo)4 HashMap (java.util.HashMap)2 JavaElementKind (com.redhat.qute.commons.JavaElementKind)1 DataModelParameter (com.redhat.qute.commons.datamodel.DataModelParameter)1 DataModelProject (com.redhat.qute.commons.datamodel.DataModelProject)1 DataModelTemplate (com.redhat.qute.commons.datamodel.DataModelTemplate)1 IDataModelProvider (com.redhat.qute.jdt.template.datamodel.IDataModelProvider)1 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)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 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1