use of com.redhat.qute.commons.JavaMemberInfo in project quarkus-ls by redhat-developer.
the class QuteProjectRegistry method findMember.
/**
* Returns the Java member (field or method) from the given Java base type with
* the given property and null otherwise.
*
* @param baseType the Java base type.
* @param property the member property (field name or getter method name).
* @param projectUri the project Uri used to search in the extended Java type.
* @return the Java member (field or method) from the given Java base type with
* the given property and null otherwise.
*/
public JavaMemberInfo findMember(ResolvedJavaTypeInfo baseType, String property, String projectUri) {
if (baseType == null) {
return null;
}
if (baseType.isIterable() && !baseType.isArray()) {
// Expression uses iterable type
// {@java.util.List<org.acme.Item items>
// {items.size()}
// Property, method to validate must be done for iterable type (ex :
// java.util.List
String iterableType = baseType.getIterableType();
baseType = resolveJavaType(iterableType, projectUri).getNow(null);
if (baseType == null) {
// The java type doesn't exists or it is resolving, stop the validation
return null;
}
}
// Search in the java root type
JavaMemberInfo memberInfo = findMember(baseType, property);
if (memberInfo != null) {
return memberInfo;
}
if (baseType.getExtendedTypes() != null) {
// Search in extended types
for (String superType : baseType.getExtendedTypes()) {
ResolvedJavaTypeInfo resolvedSuperType = resolveJavaType(superType, projectUri).getNow(null);
if (resolvedSuperType != null) {
JavaMemberInfo superMemberInfo = findMember(resolvedSuperType, property, projectUri);
if (superMemberInfo != null) {
return superMemberInfo;
}
}
}
}
// Search in value resolver
String literalType = LiteralSupport.getLiteralJavaType(property);
if (literalType != null) {
// ex : @java.lang.Integer(base : T[]) : T (see qute-resolvers.jsonc)
property = "@" + literalType;
}
return findValueResolver(property, baseType, projectUri);
}
Aggregations