java.lang.Object
io.helidon.codegen.TypeHierarchy
Utilities for type hierarchy.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type) Find all annotations on the whole type hierarchy.static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type, TypedElementInfo element) Find all annotations on the whole type hierarchy.static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type, TypedElementInfo executable, TypedElementInfo parameter, int parameterIndex) Annotations of a parameter, taken from the full inheritance hierarchy (super type(s), interface(s).static TypedElementInfomergeHierarchyAnnotations(TypeInfo type, TypedElementInfo element) Merge method and parameter annotations, and return and parameter type-use annotations, from overridden methods and interface methods into the provided method element.static TypeNamemergeTypeNameAnnotations(TypeName typeName, TypeName sourceTypeName) Merge type-use annotations from a source type name into a target type name.nestedAnnotations(CodegenContext ctx, TypeInfo typeInfo) Annotations on thetypeInfo, its methods, method parameters, and the type-use positions nested in theirTypeNames.static List<Annotation> typeNameAnnotations(TypeName typeName) Annotation instances nested inside a type name.
-
Method Details
-
hierarchyAnnotations
Find all annotations on the whole type hierarchy. Adds all annotations on the provided type, and allInheritedannotations on supertype(s) and/or interface(s).- Parameters:
ctx- codegen contexttype- type info to process- Returns:
- all annotations on the type and in its hierarchy
-
hierarchyAnnotations
public static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type, TypedElementInfo element) Find all annotations on the whole type hierarchy. Adds all annotations on the provided element, and allInheritedannotations on the same element from supertype(s), and/or interfaces, and/or annotations.Based on element type:
- Constructor: only uses annotations from the current element
- Constructor parameter: ditto
- Method: uses annotations from the current element, and from the overridden method/interface method
- Method parameter: use
hierarchyAnnotations(CodegenContext, io.helidon.common.types.TypeInfo, io.helidon.common.types.TypedElementInfo, io.helidon.common.types.TypedElementInfo, int)instead - Field: only uses annotations from the current element
- Parameters:
ctx- codegen contexttype- type info owning the executableelement- executable (method or constructor) element info- Returns:
- all annotations on the type and in its hierarchy
-
hierarchyAnnotations
public static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type, TypedElementInfo executable, TypedElementInfo parameter, int parameterIndex) Annotations of a parameter, taken from the full inheritance hierarchy (super type(s), interface(s).- Parameters:
ctx- codegen context to obtainTypeInfoof typestype- type info of the processed typeexecutable- owner of the parameter (constructor or method)parameter- parameter info itselfparameterIndex- index of the parameter within the method (as names may be wrong at runtime)- Returns:
- list of annotations on this parameter on this type, super type(s), and interface methods it implements
-
nestedAnnotations
Annotations on thetypeInfo, its methods, method parameters, and the type-use positions nested in theirTypeNames.Type-use positions include type arguments, wildcard bounds, and array component types of the type itself, element return or field types, and parameter types.
- Parameters:
ctx- contexttypeInfo- type info to check- Returns:
- a set of all annotation types on any of the elements, including inherited annotations
-
mergeHierarchyAnnotations
Merge method and parameter annotations, and return and parameter type-use annotations, from overridden methods and interface methods into the provided method element. Non-method elements are returned unchanged.When the same annotation type exists on both the target method and an inherited method, the target method annotation is preserved. Type-use annotations are merged using
mergeTypeNameAnnotations(TypeName, TypeName).- Parameters:
type- type declaring the elementelement- element to merge- Returns:
- element with matching hierarchy annotations merged in
-
typeNameAnnotations
Annotation instances nested inside a type name. This includes annotations declared directly on the provided type name and annotations declared on nested type arguments, wildcard bounds, and array component types.- Parameters:
typeName- type name to scan- Returns:
- nested annotation instances
-
mergeTypeNameAnnotations
Merge type-use annotations from a source type name into a target type name. If the type names do not have the same structure, the target type name is returned unchanged.Matching type names merge direct and inherited annotations on the root type, type arguments, wildcard bounds, and array component types. When both type names contain the same annotation type at a matching position, the target annotation is preserved. Formal type parameter names do not block merging.
- Parameters:
typeName- target type namesourceTypeName- source type name- Returns:
- type name with annotations merged from the source
-