Class TypeHierarchy
java.lang.Object
io.helidon.codegen.TypeHierarchy
Utilities for type hierarchy.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<List<Annotation>> hierarchyAnnotationCandidates(CodegenContext ctx, TypeInfo type, TypedElementInfo method, Set<TypeName> annotationTypes) Find all distinct effective occurrences of any of the annotation types on matching methods in a method's type hierarchy, grouped by the declaring method.static 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 TypeNamemergeTypeNameAnnotations(TypeName typeName, TypeName sourceTypeName) Merge type-use annotations from a source type name into a target type name.static ElementSignaturemethodSignature(TypedElementInfo method) Create a method signature that treats method type-variable names as declaration-local aliases.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
-
methodSignature
Create a method signature that treats method type-variable names as declaration-local aliases.- Parameters:
method- method element- Returns:
- normalized method signature
-
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
-
hierarchyAnnotationCandidates
public static List<List<Annotation>> hierarchyAnnotationCandidates(CodegenContext ctx, TypeInfo type, TypedElementInfo method, Set<TypeName> annotationTypes) Find all distinct effective occurrences of any of the annotation types on matching methods in a method's type hierarchy, grouped by the declaring method. Meta-annotations are included. UnlikehierarchyAnnotations(CodegenContext, TypeInfo, TypedElementInfo), this method does not apply annotation-type precedence between declarations. A candidate-bearing declaration excludes candidates on declarations it overrides. A declaration without matching candidates does not exclude candidates inherited from its ancestors. Candidates on unrelated hierarchy branches are retained. The provided method itself is excluded. The outer list contains distinct declaration multisets; each inner list preserves candidate order and multiplicity.- Parameters:
ctx- codegen contexttype- type info owning the methodmethod- method elementannotationTypes- annotation types to find- Returns:
- distinct annotation candidates grouped by declaring method
-
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
-
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
-