use of com.redhat.qute.project.datamodel.resolvers.TypeValueResolver 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;
}
use of com.redhat.qute.project.datamodel.resolvers.TypeValueResolver in project quarkus-ls by redhat-developer.
the class QuteProjectRegistry method findJavaElementWithNamespace.
public CompletableFuture<JavaElementInfo> findJavaElementWithNamespace(String namespace, String partName, String projectUri) {
if (StringUtils.isEmpty(projectUri)) {
return JAVA_ELEMENT_INFO_NULL_FUTURE;
}
QuteProject project = getProject(projectUri);
if (project == null) {
return JAVA_ELEMENT_INFO_NULL_FUTURE;
}
return //
project.getDataModelProject().thenApply(dataModel -> {
if (dataModel == null) {
return null;
}
// Search in types resolvers
List<TypeValueResolver> typeResolvers = dataModel.getTypeValueResolvers();
for (TypeValueResolver resolver : typeResolvers) {
if (isMatchNamespaceResolver(namespace, partName, resolver, dataModel)) {
return resolver;
}
}
// Search in methods resolvers
List<MethodValueResolver> methodResolvers = dataModel.getMethodValueResolvers();
for (MethodValueResolver resolver : methodResolvers) {
if (isMatchNamespaceResolver(namespace, partName, resolver, dataModel)) {
return resolver;
}
}
// Search in field resolvers
List<FieldValueResolver> fieldResolvers = dataModel.getFieldValueResolvers();
for (FieldValueResolver resolver : fieldResolvers) {
if (isMatchNamespaceResolver(namespace, partName, resolver, dataModel)) {
return resolver;
}
}
return null;
});
}
use of com.redhat.qute.project.datamodel.resolvers.TypeValueResolver in project quarkus-ls by redhat-developer.
the class ExtendedDataModelProject method updateValueResolvers.
private static void updateValueResolvers(List<TypeValueResolver> typeValueResolvers, List<FieldValueResolver> fieldValueResolvers, List<MethodValueResolver> methodValueResolvers, DataModelProject<DataModelTemplate<DataModelParameter>> project) {
project.getValueResolvers().forEach(resolver -> {
JavaElementKind kind = resolver.getJavaElementKind();
switch(kind) {
case TYPE:
TypeValueResolver typeValueResolver = new TypeValueResolver();
typeValueResolver.setNamed(resolver.getNamed());
typeValueResolver.setNamespace(resolver.getNamespace());
typeValueResolver.setSignature(resolver.getSignature());
typeValueResolver.setSourceType(resolver.getSourceType());
typeValueResolvers.add(typeValueResolver);
break;
case FIELD:
FieldValueResolver fieldValueResolver = new FieldValueResolver();
fieldValueResolver.setNamed(resolver.getNamed());
fieldValueResolver.setNamespace(resolver.getNamespace());
fieldValueResolver.setSignature(resolver.getSignature());
fieldValueResolver.setSourceType(resolver.getSourceType());
fieldValueResolvers.add(fieldValueResolver);
break;
case METHOD:
MethodValueResolver methodValueResolver = new MethodValueResolver();
methodValueResolver.setNamed(resolver.getNamed());
methodValueResolver.setNamespace(resolver.getNamespace());
methodValueResolver.setMatchName(resolver.getMatchName());
methodValueResolver.setSignature(resolver.getSignature());
methodValueResolver.setSourceType(resolver.getSourceType());
methodValueResolvers.add(methodValueResolver);
break;
default:
break;
}
});
}
Aggregations