Java Code Examples for org.jboss.jandex.ClassInfo#interfaceTypes()
The following examples show how to use
org.jboss.jandex.ClassInfo#interfaceTypes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueResolverGenerator.java From quarkus with Apache License 2.0 | 6 votes |
static boolean hasCompletionStageInTypeClosure(ClassInfo classInfo, IndexView index) { if (classInfo == null) { // TODO cannot perform analysis return false; } if (classInfo.name().equals(COMPLETION_STAGE)) { return true; } // Interfaces for (Type interfaceType : classInfo.interfaceTypes()) { ClassInfo interfaceClassInfo = index.getClassByName(interfaceType.name()); if (interfaceClassInfo != null && hasCompletionStageInTypeClosure(interfaceClassInfo, index)) { return true; } } // Superclass if (classInfo.superClassType() != null) { ClassInfo superClassInfo = index.getClassByName(classInfo.superName()); if (superClassInfo != null && hasCompletionStageInTypeClosure(superClassInfo, index)) { return true; } } return false; }
Example 2
Source File: SmallRyeMetricsProcessor.java From quarkus with Apache License 2.0 | 6 votes |
private void findNonOverriddenDefaultMethods(ClassInfo interfaceInfo, Set<String> alreadyRegisteredNames, SmallRyeMetricsRecorder recorder, BeanArchiveIndexBuildItem beanArchiveIndex, JandexMemberInfoAdapter memberInfoAdapter, BeanInfo beanInfo) { // Check for default methods which are NOT overridden by the bean that we are registering metrics for // or any of its superclasses. Register a metric for each of them. for (MethodInfo method : interfaceInfo.methods()) { if (!Modifier.isAbstract(method.flags())) { // only take default methods if (!alreadyRegisteredNames.contains(method.name())) { recorder.registerMetrics(beanInfo, memberInfoAdapter.convert(method)); alreadyRegisteredNames.add(method.name()); } } } // recursively repeat the same for interfaces which this interface extends for (Type extendedInterface : interfaceInfo.interfaceTypes()) { ClassInfo extendedInterfaceInfo = beanArchiveIndex.getIndex().getClassByName(extendedInterface.name()); if (extendedInterfaceInfo != null) { findNonOverriddenDefaultMethods(extendedInterfaceInfo, alreadyRegisteredNames, recorder, beanArchiveIndex, memberInfoAdapter, beanInfo); } } }
Example 3
Source File: RESTEasyExtension.java From quarkus with Apache License 2.0 | 6 votes |
private void scanAsyncResponseProviders(IndexView index) { for (ClassInfo providerClass : index.getAllKnownImplementors(DOTNAME_ASYNC_RESPONSE_PROVIDER)) { for (AnnotationInstance annotation : providerClass.classAnnotations()) { if (annotation.name().equals(DOTNAME_PROVIDER)) { for (Type interf : providerClass.interfaceTypes()) { if (interf.kind() == Type.Kind.PARAMETERIZED_TYPE && interf.name().equals(DOTNAME_ASYNC_RESPONSE_PROVIDER)) { ParameterizedType pType = interf.asParameterizedType(); if (pType.arguments().size() == 1) { Type asyncType = pType.arguments().get(0); asyncTypes.add(asyncType.name()); } } } } } } }
Example 4
Source File: Methods.java From quarkus with Apache License 2.0 | 5 votes |
static void addDelegatingMethods(IndexView index, ClassInfo classInfo, Map<Methods.MethodKey, MethodInfo> methods) { // TODO support interfaces default methods if (classInfo != null) { for (MethodInfo method : classInfo.methods()) { if (skipForClientProxy(method)) { continue; } methods.computeIfAbsent(new Methods.MethodKey(method), key -> { // If parameterized try to resolve the type variables Type returnType = key.method.returnType(); Type[] params = new Type[key.method.parameters().size()]; for (int i = 0; i < params.length; i++) { params[i] = key.method.parameters().get(i); } List<TypeVariable> typeVariables = key.method.typeParameters(); return MethodInfo.create(classInfo, key.method.name(), params, returnType, key.method.flags(), typeVariables.toArray(new TypeVariable[] {}), key.method.exceptions().toArray(Type.EMPTY_ARRAY)); }); } // Interfaces for (Type interfaceType : classInfo.interfaceTypes()) { ClassInfo interfaceClassInfo = getClassByName(index, interfaceType.name()); if (interfaceClassInfo != null) { addDelegatingMethods(index, interfaceClassInfo, methods); } } if (classInfo.superClassType() != null) { ClassInfo superClassInfo = getClassByName(index, classInfo.superName()); if (superClassInfo != null) { addDelegatingMethods(index, superClassInfo, methods); } } } }
Example 5
Source File: RestClientProcessor.java From quarkus with Apache License 2.0 | 5 votes |
private void findInterfaces(IndexView index, Map<DotName, ClassInfo> interfaces, Set<Type> returnTypes, DotName annotationToFind) { for (AnnotationInstance annotation : index.getAnnotations(annotationToFind)) { AnnotationTarget target = annotation.target(); ClassInfo theInfo; if (target.kind() == AnnotationTarget.Kind.CLASS) { theInfo = target.asClass(); } else if (target.kind() == AnnotationTarget.Kind.METHOD) { theInfo = target.asMethod().declaringClass(); } else { continue; } if (!isRestClientInterface(index, theInfo)) { continue; } interfaces.put(theInfo.name(), theInfo); // Find Return types processInterfaceReturnTypes(theInfo, returnTypes); for (Type interfaceType : theInfo.interfaceTypes()) { ClassInfo interfaceClassInfo = index.getClassByName(interfaceType.name()); if (interfaceClassInfo != null) { processInterfaceReturnTypes(interfaceClassInfo, returnTypes); } } } }
Example 6
Source File: JandexUtil.java From quarkus with Apache License 2.0 | 4 votes |
/** * Finds the type arguments passed from the starting type to the given target type, mapping * generics when found, on the way down. Returns null if not found. */ private static List<Type> findParametersRecursively(Type type, DotName target, Set<DotName> visitedTypes, IndexView index) { DotName name = type.name(); // cache results first if (!visitedTypes.add(name)) { return null; } // always end at Object if (DOTNAME_OBJECT.equals(name)) { return null; } final ClassInfo inputClassInfo = fetchFromIndex(name, index); // look at the current type if (target.equals(name)) { Type thisType = getType(inputClassInfo, index); if (thisType.kind() == Kind.CLASS) return Collections.emptyList(); else return thisType.asParameterizedType().arguments(); } // superclasses first Type superClassType = inputClassInfo.superClassType(); List<Type> superResult = findParametersRecursively(superClassType, target, visitedTypes, index); if (superResult != null) { // map any returned type parameters to our type arguments on the way down return mapTypeArguments(superClassType, superResult, index); } // interfaces second for (Type interfaceType : inputClassInfo.interfaceTypes()) { List<Type> ret = findParametersRecursively(interfaceType, target, visitedTypes, index); if (ret != null) { // map any returned type parameters to our type arguments on the way down return mapTypeArguments(interfaceType, ret, index); } } // not found return null; }