diff --git a/builder/builder-config-processor/src/main/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreator.java b/builder/builder-config-processor/src/main/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreator.java index 85b2ffe1f94..38e2976d9db 100644 --- a/builder/builder-config-processor/src/main/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreator.java +++ b/builder/builder-config-processor/src/main/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreator.java @@ -50,7 +50,7 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.config.metadata.ConfiguredOption; import static io.helidon.builder.config.spi.ConfigBeanInfo.LevelType; @@ -124,7 +124,7 @@ protected void preValidate(TypeName implTypeName, * Generic/simple map types are not supported on config beans, only <String, <Known ConfigBean types>>. */ private void assertNoGenericMaps(TypeInfo typeInfo) { - List list = typeInfo.elementInfo().stream() + List list = typeInfo.interestingElementInfo().stream() .filter(it -> it.typeName().isMap()) .filter(it -> { TypeName typeName = it.typeName(); @@ -292,7 +292,7 @@ protected void appendExtraBuilderMethods(StringBuilder builder, int i = 0; for (String attrName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); String configKey = toConfigKey(attrName, method, ctx.builderTriggerAnnotation()); // resolver.of(config, "port", int.class).ifPresent(this::port); @@ -449,7 +449,7 @@ private void javaDocAcceptResolveConfigCtx(StringBuilder builder, } private String toConfigKey(String attrName, - TypedElementName method, + TypedElementInfo method, AnnotationAndValue ignoredBuilderAnnotation) { String configKey = null; Optional configuredOptions = AnnotationAndValueDefault @@ -473,7 +473,7 @@ private static void assertNoAnnotation(String annoTypeName, + " on " + typeInfo.typeName()); } - for (TypedElementName elem : typeInfo.elementInfo()) { + for (TypedElementInfo elem : typeInfo.interestingElementInfo()) { anno = AnnotationAndValueDefault.findFirst(annoTypeName, elem.annotations()); if (anno.isEmpty()) { anno = AnnotationAndValueDefault.findFirst(annoTypeName, elem.elementTypeAnnotations()); diff --git a/builder/builder-config-processor/src/test/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreatorTest.java b/builder/builder-config-processor/src/test/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreatorTest.java index c2bef78c0d6..19b231ece3f 100644 --- a/builder/builder-config-processor/src/test/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreatorTest.java +++ b/builder/builder-config-processor/src/test/java/io/helidon/builder/config/processor/ConfigBeanBuilderCreatorTest.java @@ -29,8 +29,8 @@ import io.helidon.common.types.TypeInfoDefault; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfo; +import io.helidon.common.types.TypedElementInfoDefault; import org.junit.jupiter.api.Test; @@ -111,11 +111,11 @@ void preValidateConfigBeansMustBeRootToHaveDefaults() { @Test void preValidateConfigBeansMustNotHaveDuplicateSingularNames() { - TypedElementName method1 = TypedElementNameDefault.builder() + TypedElementInfo method1 = TypedElementInfoDefault.builder() .elementName("socket") .typeName(String.class) .build(); - TypedElementName method2 = TypedElementNameDefault.builder() + TypedElementInfo method2 = TypedElementInfoDefault.builder() .elementName("socketSet") .typeName(String.class) .addAnnotation(AnnotationAndValueDefault.create(Singular.class, "socket")) @@ -124,7 +124,7 @@ void preValidateConfigBeansMustNotHaveDuplicateSingularNames() { TypeInfo typeInfo = TypeInfoDefault.builder() .typeKind(TypeInfo.KIND_INTERFACE) .typeName(TypeNameDefault.create(getClass())) - .elementInfo(Set.of(method1, method2)) + .interestingElementInfo(Set.of(method1, method2)) .build(); AnnotationAndValueDefault configBeanAnno = AnnotationAndValueDefault.builder() .typeName(TypeNameDefault.create(ConfigBean.class)) @@ -141,7 +141,7 @@ void preValidateConfigBeansMustNotHaveDuplicateSingularNames() { @Test void preValidateConfigBeansMustHaveMapTypesWithNestedConfigBeans() { - TypedElementName method1 = TypedElementNameDefault.builder() + TypedElementInfo method1 = TypedElementInfoDefault.builder() .elementName("socket") .typeName(TypeNameDefault.builder() .type(Map.class) @@ -154,7 +154,7 @@ void preValidateConfigBeansMustHaveMapTypesWithNestedConfigBeans() { TypeInfo typeInfo = TypeInfoDefault.builder() .typeKind(TypeInfo.KIND_INTERFACE) .typeName(TypeNameDefault.create(getClass())) - .elementInfo(Set.of(method1)) + .interestingElementInfo(Set.of(method1)) .build(); AnnotationAndValueDefault configBeanAnno = AnnotationAndValueDefault.builder() .typeName(TypeNameDefault.create(ConfigBean.class)) @@ -172,7 +172,7 @@ void preValidateConfigBeansMustHaveMapTypesWithNestedConfigBeans() { creator.preValidate(implTypeName, typeInfo, configBeanAnno); // now we will validate the exceptions when ConfigBeans are attempted to be embedded - TypedElementName method2 = TypedElementNameDefault.builder() + TypedElementInfo method2 = TypedElementInfoDefault.builder() .elementName("unsupported1") .typeName(TypeNameDefault.builder() .type(Map.class) @@ -182,7 +182,7 @@ void preValidateConfigBeansMustHaveMapTypesWithNestedConfigBeans() { TypeNameDefault.create(getClass()))) .build()) .build(); - TypedElementName method3 = TypedElementNameDefault.builder() + TypedElementInfo method3 = TypedElementInfoDefault.builder() .elementName("unsupported2") .typeName(TypeNameDefault.builder() .type(Map.class) @@ -195,7 +195,7 @@ void preValidateConfigBeansMustHaveMapTypesWithNestedConfigBeans() { TypeInfo typeInfo2 = TypeInfoDefault.builder() .typeKind(TypeInfo.KIND_INTERFACE) .typeName(TypeNameDefault.create(getClass())) - .elementInfo(List.of(method2, method3)) + .interestingElementInfo(List.of(method2, method3)) .referencedTypeNamesToAnnotations(Map.of(TypeNameDefault.create(getClass()), List.of(AnnotationAndValueDefault.create(Builder.class)))) .build(); diff --git a/builder/processor-spi/src/main/java/io/helidon/builder/processor/spi/TypeInfoCreatorProvider.java b/builder/processor-spi/src/main/java/io/helidon/builder/processor/spi/TypeInfoCreatorProvider.java index b18db69c59c..1b7bb01b295 100644 --- a/builder/processor-spi/src/main/java/io/helidon/builder/processor/spi/TypeInfoCreatorProvider.java +++ b/builder/processor-spi/src/main/java/io/helidon/builder/processor/spi/TypeInfoCreatorProvider.java @@ -25,7 +25,7 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; /** * Java {@link java.util.ServiceLoader} provider interface used to discover type info creators. @@ -58,13 +58,13 @@ Optional createBuilderTypeInfo(TypeName annoTypeName, * @param mirror the type mirror for the element being processed * @param processingEnv the processing environment * @param elementOfInterest the predicate filter to determine whether the element is of interest, and therefore should be - * included in {@link TypeInfo#elementInfo()}. Otherwise, if the predicate indicates it is not of + * included in {@link TypeInfo#interestingElementInfo()}. Otherwise, if the predicate indicates it is not of * interest then the method will be placed under {@link TypeInfo#otherElementInfo()} instead * @return the type info associated with the arguments being processed, or empty if not able to process the type */ Optional createTypeInfo(TypeElement element, TypeMirror mirror, ProcessingEnvironment processingEnv, - Predicate elementOfInterest); + Predicate elementOfInterest); } diff --git a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BodyContext.java b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BodyContext.java index d22ec9a84ef..a6885130a5c 100644 --- a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BodyContext.java +++ b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BodyContext.java @@ -30,7 +30,7 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import static io.helidon.builder.processor.tools.BeanUtils.isBooleanType; import static io.helidon.builder.processor.tools.BeanUtils.isReservedWord; @@ -54,8 +54,8 @@ public class BodyContext { private final TypeName implTypeName; private final TypeInfo typeInfo; private final AnnotationAndValue builderTriggerAnnotation; - private final Map map = new LinkedHashMap<>(); - private final List allTypeInfos = new ArrayList<>(); + private final Map map = new LinkedHashMap<>(); + private final List allTypeInfos = new ArrayList<>(); private final List allAttributeNames = new ArrayList<>(); private final boolean hasStreamSupportOnImpl; private final boolean hasStreamSupportOnBuilder; @@ -180,7 +180,7 @@ public AnnotationAndValue builderTriggerAnnotation() { * * @return the map of elements by name */ - protected Map map() { + protected Map map() { return map; } @@ -189,7 +189,7 @@ protected Map map() { * * @return the list of type elements */ - public List allTypeInfos() { + public List allTypeInfos() { return allTypeInfos; } @@ -428,7 +428,7 @@ public Optional interceptorCreateMethod() { */ public boolean hasOtherMethod(String name, TypeInfo typeInfo) { - for (TypedElementName elem : typeInfo.otherElementInfo()) { + for (TypedElementInfo elem : typeInfo.otherElementInfo()) { if (elem.elementName().equals(name)) { return true; } @@ -448,7 +448,7 @@ public boolean hasOtherMethod(String name, * @param isBeanStyleRequired is bean style required * @return the bean attribute name */ - protected static String toBeanAttributeName(TypedElementName method, + protected static String toBeanAttributeName(TypedElementInfo method, boolean isBeanStyleRequired) { AtomicReference>> refAttrNames = new AtomicReference<>(); validateAndParseMethodName(method.elementName(), method.typeName().name(), isBeanStyleRequired, refAttrNames); @@ -585,9 +585,9 @@ private void gatherAllAttributeNames(TypeInfo typeInfo) { } } - for (TypedElementName method : typeInfo.elementInfo()) { + for (TypedElementInfo method : typeInfo.interestingElementInfo()) { String beanAttributeName = toBeanAttributeName(method, beanStyleRequired); - TypedElementName existing = map.get(beanAttributeName); + TypedElementInfo existing = map.get(beanAttributeName); if (existing != null && isBooleanType(method.typeName().name()) && method.elementName().startsWith("is")) { @@ -630,16 +630,16 @@ && isBooleanType(method.typeName().name()) } } - private static void populateMap(Map map, + private static void populateMap(Map map, TypeInfo typeInfo, boolean isBeanStyleRequired) { if (typeInfo.superTypeInfo().isPresent()) { populateMap(map, typeInfo.superTypeInfo().get(), isBeanStyleRequired); } - for (TypedElementName method : typeInfo.elementInfo()) { + for (TypedElementInfo method : typeInfo.interestingElementInfo()) { String beanAttributeName = toBeanAttributeName(method, isBeanStyleRequired); - TypedElementName existing = map.get(beanAttributeName); + TypedElementInfo existing = map.get(beanAttributeName); if (existing != null) { if (!existing.typeName().equals(method.typeName())) { throw new IllegalStateException(method + " cannot redefine types from super for " + beanAttributeName); @@ -684,7 +684,7 @@ private static TypeName toCtorBuilderAcceptTypeName(TypeInfo typeInfo, return typeInfo.typeName(); } - return (parentAnnotationTypeName != null && typeInfo.elementInfo().isEmpty() + return (parentAnnotationTypeName != null && typeInfo.interestingElementInfo().isEmpty() ? typeInfo.superTypeInfo().orElseThrow().typeName() : typeInfo.typeName()); } diff --git a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BuilderTypeTools.java b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BuilderTypeTools.java index 59a5d0c2265..35521795c00 100644 --- a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BuilderTypeTools.java +++ b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/BuilderTypeTools.java @@ -58,8 +58,8 @@ import io.helidon.common.types.TypeInfoDefault; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfo; +import io.helidon.common.types.TypedElementInfoDefault; // this is really ok! import com.sun.source.util.TreePath; @@ -109,15 +109,15 @@ public Optional createBuilderTypeInfo(TypeName annotationTypeName, throw new IllegalStateException(msg); } - Collection elementInfo = toElementInfo(element, processingEnv, true, wantDefaultMethods); - Collection otherElementInfo = toElementInfo(element, processingEnv, false, wantDefaultMethods); + Collection elementInfo = toElementInfo(element, processingEnv, true, wantDefaultMethods); + Collection otherElementInfo = toElementInfo(element, processingEnv, false, wantDefaultMethods); Set modifierNames = toModifierNames(element.getModifiers()); return Optional.of(TypeInfoDefault.builder() .typeName(typeName) .typeKind(String.valueOf(element.getKind())) .annotations( createAnnotationAndValueListFromElement(element, processingEnv.getElementUtils())) - .elementInfo(elementInfo) + .interestingElementInfo(elementInfo) .otherElementInfo(otherElementInfo) .referencedTypeNamesToAnnotations( toReferencedTypeNamesAndAnnotations( @@ -132,7 +132,7 @@ public Optional createBuilderTypeInfo(TypeName annotationTypeName, public Optional createTypeInfo(TypeElement element, TypeMirror mirror, ProcessingEnvironment processingEnv, - Predicate isOneWeCareAbout) { + Predicate isOneWeCareAbout) { return toTypeInfo(element, mirror, processingEnv, isOneWeCareAbout); } @@ -176,12 +176,12 @@ static Map> toMetaAnnotations(Collection> toReferencedTypeNamesAndAnnotations(ProcessingEnvironment processingEnv, TypeName typeName, - Collection... refs) { + Collection... refs) { Map> result = new LinkedHashMap<>(); - for (Collection ref : refs) { - for (TypedElementName typedElementName : ref) { - collectReferencedTypeNames(result, processingEnv, typeName, List.of(typedElementName.typeName())); - collectReferencedTypeNames(result, processingEnv, typeName, typedElementName.typeName().typeArguments()); + for (Collection ref : refs) { + for (TypedElementInfo typedElementInfo : ref) { + collectReferencedTypeNames(result, processingEnv, typeName, List.of(typedElementInfo.typeName())); + collectReferencedTypeNames(result, processingEnv, typeName, typedElementInfo.typeName().typeArguments()); } } return result; @@ -206,7 +206,7 @@ private void collectReferencedTypeNames(Map> } /** - * Translation the arguments to a collection of {@link io.helidon.common.types.TypedElementName}'s. + * Translation the arguments to a collection of {@link TypedElementInfo}'s. * * @param element the typed element (i.e., class) * @param processingEnv the processing env @@ -214,7 +214,7 @@ private void collectReferencedTypeNames(Map> * @param wantDefaultMethods true to process {@code default} methods * @return the collection of typed elements */ - private Collection toElementInfo(TypeElement element, + private Collection toElementInfo(TypeElement element, ProcessingEnvironment processingEnv, boolean wantWhatWeCanAccept, boolean wantDefaultMethods) { @@ -222,7 +222,7 @@ private Collection toElementInfo(TypeElement element, .filter(it -> it.getKind() == ElementKind.METHOD) .map(ExecutableElement.class::cast) .filter(it -> (wantWhatWeCanAccept == canAccept(it, wantDefaultMethods))) - .map(it -> createTypedElementNameFromElement(it, processingEnv.getElementUtils())) + .map(it -> createTypedElementInfoFromElement(it, processingEnv.getElementUtils())) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); @@ -286,14 +286,14 @@ private Optional toBuilderTypeInfo(TypeName annotationTypeName, * @param mirror the type mirror for the element being processed * @param processingEnv the processing environment * @param isOneWeCareAbout the predicate filter to determine whether the element is of interest, and therefore should be - * included in {@link TypeInfo#elementInfo()}. Otherwise, if the predicate indicates it is not of + * included in {@link TypeInfo#interestingElementInfo()}. Otherwise, if the predicate indicates it is not of * interest then the method will be placed under {@link TypeInfo#otherElementInfo()} instead * @return the type info associated with the arguments being processed, or empty if not able to process the type */ static Optional toTypeInfo(TypeElement element, TypeMirror mirror, ProcessingEnvironment processingEnv, - Predicate isOneWeCareAbout) { + Predicate isOneWeCareAbout) { TypeName fqTypeName = createTypeNameFromMirror(mirror).orElseThrow(); if (fqTypeName.name().equals(Object.class.getName())) { return Optional.empty(); @@ -315,10 +315,10 @@ static Optional toTypeInfo(TypeElement element, createAnnotationAndValueSet(elementUtils.getTypeElement(genericTypeName.name())); Map> referencedAnnotations = new LinkedHashMap<>(toMetaAnnotations(annotations, processingEnv)); - List elementsWeCareAbout = new ArrayList<>(); - List otherElements = new ArrayList<>(); + List elementsWeCareAbout = new ArrayList<>(); + List otherElements = new ArrayList<>(); element.getEnclosedElements().stream() - .map(it -> createTypedElementNameFromElement(it, elementUtils)) + .map(it -> createTypedElementInfoFromElement(it, elementUtils)) .filter(Optional::isPresent) .map(Optional::get) .forEach(it -> { @@ -337,7 +337,7 @@ static Optional toTypeInfo(TypeElement element, .annotations(annotations) .referencedTypeNamesToAnnotations(referencedAnnotations) .modifierNames(toModifierNames(element.getModifiers())) - .elementInfo(elementsWeCareAbout) + .interestingElementInfo(elementsWeCareAbout) .otherElementInfo(otherElements); // add all of the element's and parameters to the references annotation set @@ -354,7 +354,7 @@ static Optional toTypeInfo(TypeElement element, .filter(t -> !t.generic()) .forEach(allInterestingTypeNames::add); it.parameterArguments().stream() - .map(TypedElementName::typeName) + .map(TypedElementInfo::typeName) .map(TypeName::genericTypeName) .filter(t -> !isBuiltInJavaType(t)) .filter(t -> !t.generic()) @@ -704,19 +704,7 @@ public static Map extractValues(Map createTypedElementNameFromElement(Element v, + public static Optional createTypedElementInfoFromElement(Element v, Elements elements) { TypeName type = createTypeNameFromElement(v).orElse(null); TypeMirror typeMirror = null; String defaultValue = null; - List params = List.of(); - List componentTypeNames = List.of(); + List params = List.of(); List elementTypeAnnotations = List.of(); Set modifierNames = v.getModifiers().stream() .map(Modifier::toString) @@ -740,7 +727,7 @@ public static Optional createTypedElementNameFromElement(Eleme ExecutableElement ee = (ExecutableElement) v; typeMirror = Objects.requireNonNull(ee.getReturnType()); params = ee.getParameters().stream() - .map(it -> createTypedElementNameFromElement(it, elements).orElseThrow()) + .map(it -> createTypedElementInfoFromElement(it, elements).orElseThrow()) .collect(Collectors.toList()); AnnotationValue annotationValue = ee.getDefaultValue(); defaultValue = (annotationValue == null) ? null @@ -760,20 +747,13 @@ public static Optional createTypedElementNameFromElement(Eleme type = createTypeNameFromMirror(typeMirror).orElse(createFromGenericDeclaration(typeMirror.toString())); } if (typeMirror instanceof DeclaredType) { - List args = ((DeclaredType) typeMirror).getTypeArguments(); - componentTypeNames = args.stream() - .map(BuilderTypeTools::createTypeNameFromMirror) - .filter(Optional::isPresent) - .map(Optional::orElseThrow) - .collect(Collectors.toList()); elementTypeAnnotations = createAnnotationAndValueListFromElement(((DeclaredType) typeMirror).asElement(), elements); } } - TypedElementNameDefault.Builder builder = TypedElementNameDefault.builder() + TypedElementInfoDefault.Builder builder = TypedElementInfoDefault.builder() .typeName(type) - .componentTypeNames(componentTypeNames) .elementName(v.getSimpleName().toString()) .elementKind(v.getKind().name()) .annotations(createAnnotationAndValueListFromElement(v, elements)) diff --git a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/DefaultBuilderCreatorProvider.java b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/DefaultBuilderCreatorProvider.java index d97a4a1cdec..33d45efda7b 100644 --- a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/DefaultBuilderCreatorProvider.java +++ b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/DefaultBuilderCreatorProvider.java @@ -47,7 +47,7 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.config.metadata.ConfiguredOption; import static io.helidon.builder.processor.tools.BodyContext.TAG_META_PROPS; @@ -127,7 +127,7 @@ private void assertNoDuplicateSingularNames(TypeInfo typeInfo) { Set names = new LinkedHashSet<>(); Set duplicateNames = new LinkedHashSet<>(); - typeInfo.elementInfo().stream() + typeInfo.interestingElementInfo().stream() .map(DefaultBuilderCreatorProvider::nameOf) .forEach(name -> { if (!names.add(name)) { @@ -342,7 +342,7 @@ protected void appendFields(StringBuilder builder, } for (int i = 0; i < ctx.allTypeInfos().size(); i++) { - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); String beanAttributeName = ctx.allAttributeNames().get(i); appendAnnotations(builder, method.annotations(), "\t"); builder.append("\tprivate "); @@ -621,7 +621,7 @@ protected void appendVisitAttributes(StringBuilder builder, // void visit(String key, Object value, Object userDefinedCtx, Class type, Class... typeArgument); int i = 0; for (String attrName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); TypeName typeName = method.typeName(); List typeArgs = method.typeName().typeArguments().stream() .map(this::normalize) @@ -810,7 +810,7 @@ protected String toConfigKey(String name, */ protected void maybeAppendSingularSetter(StringBuilder builder, BodyContext ctx, - TypedElementName method, + TypedElementInfo method, String beanAttributeName, boolean isList, boolean isMap, boolean isSet) { String singularVal = toValue(Singular.class, method, false, false).orElse(null); @@ -843,7 +843,7 @@ protected static String maybeSingularFormOf(String beanAttributeName) { * @param elem the element * @return the (singular) name of the element */ - protected static String nameOf(TypedElementName elem) { + protected static String nameOf(TypedElementInfo elem) { return AnnotationAndValueDefault.findFirst(Singular.class, elem.annotations()) .flatMap(AnnotationAndValue::value) .filter(BuilderTypeTools::hasNonBlankValue) @@ -863,7 +863,7 @@ protected void appendSetter(StringBuilder mainBuilder, BodyContext ctx, String beanAttributeName, String methodName, - TypedElementName method) { + TypedElementInfo method) { appendSetter(mainBuilder, ctx, beanAttributeName, methodName, method, true, ""); } @@ -871,7 +871,7 @@ private void appendSetter(StringBuilder mainBuilder, BodyContext ctx, String beanAttributeName, String methodName, - TypedElementName method, + TypedElementInfo method, boolean doClear, String prefixName) { TypeName typeName = method.typeName(); @@ -954,7 +954,7 @@ private void appendSetter(StringBuilder mainBuilder, protected void appendDirectNonOptionalSetter(StringBuilder builder, BodyContext ctx, String beanAttributeName, - TypedElementName method, + TypedElementInfo method, String methodName, TypeName genericType) { GenerateMethod.nonOptionalSetter(builder, ctx, beanAttributeName, method, methodName, genericType); @@ -991,7 +991,7 @@ protected void appendAnnotations(StringBuilder builder, * @param upLevelToCollection true if the generics should be "up leveled" * @return the generic decl */ - protected static String toGenerics(TypedElementName method, + protected static String toGenerics(TypedElementInfo method, boolean upLevelToCollection) { return toGenerics(method.typeName(), upLevelToCollection); } @@ -1043,7 +1043,7 @@ protected static String toString(Collection coll, * @param avoidBlanks flag indicating whether blank values should be ignored * @return the default value, or empty if there is no default value applicable for the given arguments */ - protected static Optional toConfiguredOptionValue(TypedElementName method, + protected static Optional toConfiguredOptionValue(TypedElementInfo method, boolean wantTypeElementDefaults, boolean avoidBlanks) { String val = toValue(ConfiguredOption.class, method, wantTypeElementDefaults, avoidBlanks).orElse(null); @@ -1060,7 +1060,7 @@ protected static Optional toConfiguredOptionValue(TypedElementName metho * @return the default value, or empty if there is no default value applicable for the given arguments */ protected static Optional toValue(Class annoType, - TypedElementName method, + TypedElementInfo method, boolean wantTypeElementDefaults, boolean avoidBlanks) { if (wantTypeElementDefaults && method.defaultValue().isPresent()) { @@ -1187,7 +1187,7 @@ private void appendBuilder(StringBuilder builder, } else { int i = 0; for (String beanAttributeName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); TypeName typeName = method.typeName(); boolean isList = typeName.isList(); boolean isMap = !isList && typeName.isMap(); @@ -1268,7 +1268,7 @@ private void appendBuilder(StringBuilder builder, } i = 0; for (String beanAttributeName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i++); + TypedElementInfo method = ctx.allTypeInfos().get(i++); TypeName typeName = method.typeName(); String getterName = method.elementName(); builder.append("\t\t\t").append(beanAttributeName).append("("); @@ -1301,7 +1301,7 @@ private void appendBuilderBody(StringBuilder builder, boolean hasFinal = false; for (int i = 0; i < ctx.allAttributeNames().size(); i++) { String beanAttributeName = ctx.allAttributeNames().get(i); - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); TypeName typeName = method.typeName(); if (typeName.isList() || typeName.isMap() || typeName.isSet()) { hasFinal = true; @@ -1315,7 +1315,7 @@ private void appendBuilderBody(StringBuilder builder, // then any other field for (int i = 0; i < ctx.allAttributeNames().size(); i++) { String beanAttributeName = ctx.allAttributeNames().get(i); - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); TypeName typeName = method.typeName(); if (typeName.isList() || typeName.isMap() || typeName.isSet()) { continue; @@ -1341,7 +1341,7 @@ private void appendBuilderBody(StringBuilder builder, private void addBuilderField(StringBuilder builder, BodyContext ctx, - TypedElementName method, + TypedElementInfo method, TypeName type, String beanAttributeName) { GenerateJavadoc.builderField(builder, method); @@ -1362,7 +1362,7 @@ private void addBuilderField(StringBuilder builder, private void addCollectionField(StringBuilder builder, BodyContext ctx, - TypedElementName method, + TypedElementInfo method, TypeName typeName, String beanAttributeName) { GenerateJavadoc.builderField(builder, method); @@ -1474,7 +1474,7 @@ private void appendInterfaceBasedGetters(StringBuilder builder, int i = 0; for (String beanAttributeName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i); + TypedElementInfo method = ctx.allTypeInfos().get(i); String extraPrefix = prefix + "\t"; appendAnnotations(builder, method.annotations(), extraPrefix); builder.append(extraPrefix) @@ -1537,7 +1537,7 @@ protected void appendCtorCodeBody(StringBuilder builder, } int i = 0; for (String beanAttributeName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i++); + TypedElementInfo method = ctx.allTypeInfos().get(i++); builder.append("\t\tthis.").append(beanAttributeName).append(" = "); if (method.typeName().isList()) { @@ -1573,7 +1573,7 @@ private void appendHashCodeAndEquals(StringBuilder builder, builder.append("\t\tint hashCode = 1;\n"); } List methods = new ArrayList<>(); - for (TypedElementName method : ctx.allTypeInfos()) { + for (TypedElementInfo method : ctx.allTypeInfos()) { methods.add(method.elementName() + "()"); } builder.append("\t\thashCode = 31 * hashCode + Objects.hash(").append(String.join(", ", methods)).append(");\n"); @@ -1595,7 +1595,7 @@ private void appendHashCodeAndEquals(StringBuilder builder, } else { builder.append("\t\tboolean equals = true;\n"); } - for (TypedElementName method : ctx.allTypeInfos()) { + for (TypedElementInfo method : ctx.allTypeInfos()) { String equalsClass = method.typeName().array() ? Arrays.class.getName() : "Objects"; builder.append("\t\tequals &= ").append(equalsClass).append(".equals(") .append(method.elementName()).append("(), other.") @@ -1630,7 +1630,7 @@ private void appendInnerToStringMethod(StringBuilder builder, int i = 0; for (String beanAttributeName : ctx.allAttributeNames()) { - TypedElementName method = ctx.allTypeInfos().get(i++); + TypedElementInfo method = ctx.allTypeInfos().get(i++); TypeName typeName = method.typeName(); builder.append("\t\tresult += \"").append(beanAttributeName).append("=\" + "); @@ -1674,7 +1674,7 @@ private void appendInnerToStringMethod(StringBuilder builder, } private void appendDefaultValueAssignment(StringBuilder builder, - TypedElementName method, + TypedElementInfo method, String defaultVal) { TypeName type = method.typeName(); boolean isOptional = type.isOptional(); @@ -1714,7 +1714,7 @@ private void appendDefaultValueAssignment(StringBuilder builder, private void appendOverridesOfDefaultValues(StringBuilder builder, BodyContext ctx) { - for (TypedElementName method : ctx.typeInfo().elementInfo()) { + for (TypedElementInfo method : ctx.typeInfo().interestingElementInfo()) { String beanAttributeName = toBeanAttributeName(method, ctx.beanStyleRequired()); if (!ctx.allAttributeNames().contains(beanAttributeName)) { // candidate for override... @@ -1734,7 +1734,7 @@ private String superValue(Optional optSuperTypeInfo, return null; } TypeInfo superTypeInfo = optSuperTypeInfo.get(); - Optional method = superTypeInfo.elementInfo().stream() + Optional method = superTypeInfo.interestingElementInfo().stream() .filter(it -> toBeanAttributeName(it, isBeanStyleRequired).equals(elemName)) .findFirst(); if (method.isPresent()) { @@ -1751,7 +1751,7 @@ private String superValue(Optional optSuperTypeInfo, private void appendDefaultOverride(StringBuilder builder, String attrName, - TypedElementName method, + TypedElementInfo method, String override) { builder.append("\t\t\t").append(attrName).append("("); appendDefaultValueAssignment(builder, method, override); @@ -1771,7 +1771,7 @@ private void appendCustomMapOf(StringBuilder builder) { } private String mapOf(String attrName, - TypedElementName method, + TypedElementInfo method, AtomicBoolean needsCustomMapOf) { Optional configuredOptions = AnnotationAndValueDefault .findFirst(ConfiguredOption.class, method.annotations()); diff --git a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateJavadoc.java b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateJavadoc.java index a1ad7a40b49..b3f45b2ef28 100644 --- a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateJavadoc.java +++ b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateJavadoc.java @@ -17,7 +17,7 @@ package io.helidon.builder.processor.tools; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; final class GenerateJavadoc { private GenerateJavadoc() { @@ -106,7 +106,7 @@ static void updateConsumer(StringBuilder builder) { } static void builderField(StringBuilder builder, - TypedElementName method) { + TypedElementInfo method) { builder.append("\t\t/**\n" + "\t\t * Field value for {@code ") .append(method) .append("()}.\n\t\t */\n"); diff --git a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateMethod.java b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateMethod.java index 911c13d0254..99d6774910d 100644 --- a/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateMethod.java +++ b/builder/processor-tools/src/main/java/io/helidon/builder/processor/tools/GenerateMethod.java @@ -21,7 +21,7 @@ import java.util.Optional; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; final class GenerateMethod { static final String SINGULAR_PREFIX = "add"; @@ -50,7 +50,7 @@ static String builderMethods(StringBuilder builder, static void stringToCharSetter(StringBuilder builder, BodyContext ctx, String beanAttributeName, - TypedElementName method, + TypedElementInfo method, String methodName) { GenerateJavadoc.setter(builder, beanAttributeName); builder.append("\t\tpublic ").append(ctx.genericBuilderAliasDecl()).append(" ").append(methodName) @@ -76,7 +76,7 @@ static void internalMetaAttributes(StringBuilder builder) { static void nonOptionalSetter(StringBuilder builder, BodyContext ctx, String beanAttributeName, - TypedElementName method, + TypedElementInfo method, String methodName, TypeName genericType) { GenerateJavadoc.setter(builder, beanAttributeName); @@ -102,7 +102,7 @@ static void nonOptionalSetter(StringBuilder builder, static void singularSetter(StringBuilder builder, BodyContext ctx, - TypedElementName method, + TypedElementInfo method, String beanAttributeName, char[] methodName) { TypeName typeName = method.typeName(); @@ -209,7 +209,7 @@ private static TypeName mapValueTypeNameOf(TypeName typeName) { return (typeName.isMap() && typeName.typeArguments().size() > 1) ? typeName.typeArguments().get(1) : null; } - private static String toGenericsDecl(TypedElementName method, + private static String toGenericsDecl(TypedElementInfo method, boolean useSingluarMapValues, TypeName mapValueType) { List compTypeNames = method.typeName().typeArguments(); diff --git a/common/types/src/main/java/io/helidon/common/types/AnnotationAndValueDefault.java b/common/types/src/main/java/io/helidon/common/types/AnnotationAndValueDefault.java index cc772071ac5..059655480fd 100644 --- a/common/types/src/main/java/io/helidon/common/types/AnnotationAndValueDefault.java +++ b/common/types/src/main/java/io/helidon/common/types/AnnotationAndValueDefault.java @@ -31,7 +31,7 @@ public class AnnotationAndValueDefault implements AnnotationAndValue, Comparable private final Map values; /** - * Ctor. + * Constructor taking the result of the fluent builder. * * @param b the builder * @see #builder() @@ -230,12 +230,11 @@ public int compareTo(AnnotationAndValue other) { */ public static class Builder implements io.helidon.common.Builder { private final Map values = new LinkedHashMap<>(); - private TypeName typeName; private String value; /** - * Default ctor. + * Default fluent builder constructor. */ protected Builder() { } diff --git a/common/types/src/main/java/io/helidon/common/types/TypeInfo.java b/common/types/src/main/java/io/helidon/common/types/TypeInfo.java index 0d104d948e8..93cd8017d10 100644 --- a/common/types/src/main/java/io/helidon/common/types/TypeInfo.java +++ b/common/types/src/main/java/io/helidon/common/types/TypeInfo.java @@ -16,6 +16,8 @@ package io.helidon.common.types; +import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -146,7 +148,7 @@ public interface TypeInfo { * * @return the elements that make up the type that are relevant for processing */ - List elementInfo(); + List interestingElementInfo(); /** * The elements that make up this type that are considered "other", or being skipped because they are irrelevant to @@ -154,7 +156,28 @@ public interface TypeInfo { * * @return the elements that still make up the type, but are otherwise deemed irrelevant for processing */ - List otherElementInfo(); + List otherElementInfo(); + + /** + * Combines {@link #interestingElementInfo()} and {@link #otherElementInfo()} to form all typed element info belonging to this + * instance. + * + * @return all element info + */ + default List allElementInfo() { + List interestingElementInfo = interestingElementInfo(); + List otherElementInfo = otherElementInfo(); + + if (interestingElementInfo.isEmpty()) { + return otherElementInfo; + } else if (otherElementInfo.isEmpty()) { + return interestingElementInfo; + } + + LinkedHashSet all = new LinkedHashSet<>(interestingElementInfo); + all.addAll(otherElementInfo); + return new ArrayList<>(all); + } /** * Any Map, List, Set, or method that has {@link TypeName#typeArguments()} will be analyzed and any type arguments will have diff --git a/common/types/src/main/java/io/helidon/common/types/TypeInfoDefault.java b/common/types/src/main/java/io/helidon/common/types/TypeInfoDefault.java index c3c46d4def3..10c714e6640 100644 --- a/common/types/src/main/java/io/helidon/common/types/TypeInfoDefault.java +++ b/common/types/src/main/java/io/helidon/common/types/TypeInfoDefault.java @@ -33,8 +33,8 @@ public class TypeInfoDefault implements TypeInfo { private final TypeName typeName; private final String typeKind; private final List annotations; - private final List elementInfo; - private final List otherElementInfo; + private final List elementInfo; + private final List otherElementInfo; private final Map referencedModuleNames; private final Map> referencedTypeNamesToAnnotations; private final TypeInfo superTypeInfo; @@ -85,12 +85,12 @@ public List annotations() { } @Override - public List elementInfo() { + public List interestingElementInfo() { return elementInfo; } @Override - public List otherElementInfo() { + public List otherElementInfo() { return otherElementInfo; } @@ -131,7 +131,7 @@ public String toString() { */ protected String toStringInner() { return "typeName=" + typeName() - + ", elementInfo=" + elementInfo() + + ", elementInfo=" + allElementInfo() + ", annotations=" + annotations() + ", superTypeInfo=" + superTypeInfo() + ", modifierNames=" + modifierNames(); @@ -142,15 +142,14 @@ protected String toStringInner() { */ public static class Builder implements io.helidon.common.Builder { private final List annotations = new ArrayList<>(); - private final List elementInfo = new ArrayList<>(); - private final List otherElementInfo = new ArrayList<>(); + private final List elementInfo = new ArrayList<>(); + private final List otherElementInfo = new ArrayList<>(); private final Map referencedModuleNames = new LinkedHashMap<>(); private final Map> referencedTypeNamesToAnnotations = new LinkedHashMap<>(); private final List interfaceTypeInfo = new ArrayList<>(); private final Set modifierNames = new LinkedHashSet<>(); private TypeName typeName; private String typeKind; - private TypeInfo superTypeInfo; /** @@ -217,12 +216,12 @@ public Builder addAnnotation(AnnotationAndValue val) { } /** - * Sets the elementInfo to val. + * Sets the interestingElementInfo to val. * * @param val the value * @return this fluent builder */ - public Builder elementInfo(Collection val) { + public Builder interestingElementInfo(Collection val) { Objects.requireNonNull(val); this.elementInfo.clear(); this.elementInfo.addAll(val); @@ -230,12 +229,12 @@ public Builder elementInfo(Collection val) { } /** - * Adds a single elementInfo val. + * Adds a single interestingElementInfo val. * * @param val the value * @return this fluent builder */ - public Builder addElementInfo(TypedElementName val) { + public Builder addInterestingElementInfo(TypedElementInfo val) { Objects.requireNonNull(val); elementInfo.add(val); return identity(); @@ -247,7 +246,7 @@ public Builder addElementInfo(TypedElementName val) { * @param val the value * @return this fluent builder */ - public Builder otherElementInfo(Collection val) { + public Builder otherElementInfo(Collection val) { Objects.requireNonNull(val); this.otherElementInfo.clear(); this.otherElementInfo.addAll(val); @@ -260,7 +259,7 @@ public Builder otherElementInfo(Collection val) { * @param val the value * @return this fluent builder */ - public Builder addOtherElementInfo(TypedElementName val) { + public Builder addOtherElementInfo(TypedElementInfo val) { Objects.requireNonNull(val); otherElementInfo.add(val); return identity(); diff --git a/common/types/src/main/java/io/helidon/common/types/TypedElementName.java b/common/types/src/main/java/io/helidon/common/types/TypedElementInfo.java similarity index 91% rename from common/types/src/main/java/io/helidon/common/types/TypedElementName.java rename to common/types/src/main/java/io/helidon/common/types/TypedElementInfo.java index 298c17b4361..e78903faf8f 100644 --- a/common/types/src/main/java/io/helidon/common/types/TypedElementName.java +++ b/common/types/src/main/java/io/helidon/common/types/TypedElementInfo.java @@ -24,7 +24,7 @@ * Provides a way to describe a {@link TypeInfo#KIND_FIELD}, {@link TypeInfo#KIND_METHOD}, or {@link TypeInfo#KIND_PARAMETER} * of a method. */ -public interface TypedElementName { +public interface TypedElementInfo { /** * The type name for the element (e.g., java.util.List). If the element is a method, then this is the return type of * the method. @@ -70,13 +70,6 @@ public interface TypedElementName { */ List elementTypeAnnotations(); - /** - * Returns the component type names describing the element. - * - * @return the component type names of the element - */ - List componentTypeNames(); - /** * Element modifiers. * @@ -99,6 +92,6 @@ public interface TypedElementName { * * @return the list of parameters belonging to this method if applicable */ - List parameterArguments(); + List parameterArguments(); } diff --git a/common/types/src/main/java/io/helidon/common/types/TypedElementNameDefault.java b/common/types/src/main/java/io/helidon/common/types/TypedElementInfoDefault.java similarity index 87% rename from common/types/src/main/java/io/helidon/common/types/TypedElementNameDefault.java rename to common/types/src/main/java/io/helidon/common/types/TypedElementInfoDefault.java index 0e69011daba..1bee6929ded 100644 --- a/common/types/src/main/java/io/helidon/common/types/TypedElementNameDefault.java +++ b/common/types/src/main/java/io/helidon/common/types/TypedElementInfoDefault.java @@ -28,12 +28,11 @@ import static io.helidon.common.types.TypeNameDefault.create; /** - * Default implementation for {@link io.helidon.common.types.TypedElementName}. + * Default implementation for {@link TypedElementInfo}. */ @SuppressWarnings("unused") -public class TypedElementNameDefault implements TypedElementName { +public class TypedElementInfoDefault implements TypedElementInfo { private final TypeName typeName; - private final List componentTypeNames; private final String elementName; private final String elementKind; private final String defaultValue; @@ -41,7 +40,7 @@ public class TypedElementNameDefault implements TypedElementName { private final List elementTypeAnnotations; private final Set modifierNames; private final TypeName enclosingTypeName; - private final List parameters; + private final List parameters; /** * Constructor taking the fluent builder. @@ -49,9 +48,8 @@ public class TypedElementNameDefault implements TypedElementName { * @param b the builder * @see #builder() */ - protected TypedElementNameDefault(Builder b) { + protected TypedElementInfoDefault(Builder b) { this.typeName = b.typeName; - this.componentTypeNames = List.copyOf(b.componentTypeNames); this.elementName = b.elementName; this.elementKind = b.elementKind; this.defaultValue = b.defaultValue; @@ -92,11 +90,6 @@ public List elementTypeAnnotations() { return elementTypeAnnotations; } - @Override - public List componentTypeNames() { - return componentTypeNames; - } - @Override public Set modifierNames() { return modifierNames; @@ -108,7 +101,7 @@ public Optional enclosingTypeName() { } @Override - public List parameterArguments() { + public List parameterArguments() { return parameters; } @@ -119,11 +112,11 @@ public int hashCode() { @Override public boolean equals(Object another) { - if (!(another instanceof TypedElementName)) { + if (!(another instanceof TypedElementInfo)) { return false; } - TypedElementName other = (TypedElementName) another; + TypedElementInfo other = (TypedElementInfo) another; return Objects.equals(typeName(), other.typeName()) && Objects.equals(elementName(), other.elementName()) && Objects.equals(elementTypeKind(), other.elementTypeKind()) @@ -163,7 +156,7 @@ public String toDeclaration() { } /** - * Creates a builder for {@link io.helidon.common.types.TypedElementName}. + * Creates a builder for {@link TypedElementInfo}. * * @return a fluent builder */ @@ -176,11 +169,10 @@ public static Builder builder() { * The fluent builder. */ public static class Builder { - private final List componentTypeNames = new ArrayList<>(); private final List annotations = new ArrayList<>(); private final List elementTypeAnnotations = new ArrayList<>(); private final Set modifierNames = new LinkedHashSet<>(); - private final List parameters = new ArrayList<>(); + private final List parameters = new ArrayList<>(); private TypeName typeName; private String elementName; @@ -216,19 +208,6 @@ public Builder typeName(Class type) { return typeName(create(type)); } - /** - * Set the component type names. - * - * @param val the component type values - * @return this fluent builder - */ - public Builder componentTypeNames(List val) { - Objects.requireNonNull(val); - this.componentTypeNames.clear(); - this.componentTypeNames.addAll(val); - return this; - } - /** * Set the element name. * @@ -356,7 +335,7 @@ public Builder enclosingTypeName(Class val) { * @param val the parameter values * @return this fluent builder */ - public Builder parameterArguments(List val) { + public Builder parameterArguments(List val) { Objects.requireNonNull(val); this.parameters.clear(); this.parameters.addAll(val); @@ -369,7 +348,7 @@ public Builder parameterArguments(List val) { * @param val the parameter value * @return the fluent builder */ - public Builder addParameterArgument(TypedElementName val) { + public Builder addParameterArgument(TypedElementInfo val) { Objects.requireNonNull(val); this.parameters.add(val); return this; @@ -380,9 +359,9 @@ public Builder addParameterArgument(TypedElementName val) { * * @return the built instance */ - public TypedElementNameDefault build() { + public TypedElementInfoDefault build() { Objects.requireNonNull(typeName); - return new TypedElementNameDefault(this); + return new TypedElementInfoDefault(this); } } diff --git a/common/types/src/test/java/io/helidon/common/types/TypedElementNameDefaultTest.java b/common/types/src/test/java/io/helidon/common/types/TypedElementInfoDefaultTest.java similarity index 64% rename from common/types/src/test/java/io/helidon/common/types/TypedElementNameDefaultTest.java rename to common/types/src/test/java/io/helidon/common/types/TypedElementInfoDefaultTest.java index 68e7c3ec1e8..4d179297f50 100644 --- a/common/types/src/test/java/io/helidon/common/types/TypedElementNameDefaultTest.java +++ b/common/types/src/test/java/io/helidon/common/types/TypedElementInfoDefaultTest.java @@ -16,74 +16,78 @@ package io.helidon.common.types; +import java.util.List; + import org.junit.jupiter.api.Test; import static io.helidon.common.types.TypeNameDefault.create; import static io.helidon.common.types.TypeNameDefault.createFromTypeName; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.sameInstance; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; -class TypedElementNameDefaultTest { +class TypedElementInfoDefaultTest { @Test void declarations() { - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(boolean.class)) .build().toString(), is("boolean arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(byte.class)) .build().toString(), is("byte arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(short.class)) .build().toString(), is("short arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(int.class)) .build().toString(), is("int arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(long.class)) .build().toString(), is("long arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(char.class)) .build().toString(), is("char arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(float.class)) .build().toString(), is("float arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(double.class)) .build().toString(), is("double arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .elementName("arg") .typeName(create(void.class)) .build().toString(), is("void arg")); - assertThat(TypedElementNameDefault.builder() + assertThat(TypedElementInfoDefault.builder() .enclosingTypeName(createFromTypeName("MyClass")) .elementName("hello") .typeName(create(void.class)) .elementKind(TypeInfo.KIND_METHOD) - .addParameterArgument(TypedElementNameDefault.builder() + .addParameterArgument(TypedElementInfoDefault.builder() .elementName("arg1") .typeName(create(String.class)) .elementKind(TypeInfo.KIND_PARAMETER) .build()) - .addParameterArgument(TypedElementNameDefault.builder() + .addParameterArgument(TypedElementInfoDefault.builder() .elementName("arg2") .typeName(create(int.class)) .elementKind(TypeInfo.KIND_PARAMETER) @@ -92,4 +96,37 @@ void declarations() { is("MyClass::void hello(java.lang.String arg1, int arg2)")); } + @Test + void allElementInfo() { + TypedElementInfo m1 = TypedElementInfoDefault.builder() + .typeName(getClass()) + .elementKind(TypeInfo.KIND_METHOD) + .elementName("m1") + .build(); + TypedElementInfo m2 = TypedElementInfoDefault.builder() + .typeName(getClass()) + .elementKind(TypeInfo.KIND_METHOD) + .elementName("m2") + .build(); + + TypeInfo typeInfo = TypeInfoDefault.builder() + .addInterestingElementInfo(m1) + .build(); + assertThat(typeInfo.allElementInfo(), + sameInstance(typeInfo.interestingElementInfo())); + + typeInfo = TypeInfoDefault.builder() + .addOtherElementInfo(m1) + .build(); + assertThat(typeInfo.allElementInfo(), + sameInstance(typeInfo.otherElementInfo())); + + typeInfo = TypeInfoDefault.builder() + .addInterestingElementInfo(m1) + .otherElementInfo(List.of(m2, m1)) + .build(); + assertThat(typeInfo.allElementInfo(), + contains(m1, m2)); + } + } diff --git a/nima/http/processor/src/main/java/io/helidon/nima/http/processor/HttpMethodCreator.java b/nima/http/processor/src/main/java/io/helidon/nima/http/processor/HttpMethodCreator.java index 3fd8ccfde88..85484db48ff 100644 --- a/nima/http/processor/src/main/java/io/helidon/nima/http/processor/HttpMethodCreator.java +++ b/nima/http/processor/src/main/java/io/helidon/nima/http/processor/HttpMethodCreator.java @@ -29,7 +29,7 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.tools.CustomAnnotationTemplateRequest; import io.helidon.pico.tools.CustomAnnotationTemplateResponse; import io.helidon.pico.tools.GenericTemplateCreator; @@ -100,7 +100,7 @@ public Optional create(CustomAnnotationTemplat } private Map addProperties(CustomAnnotationTemplateRequest request) { - TypedElementName targetElement = request.targetElement(); + TypedElementInfo targetElement = request.targetElement(); Map response = new HashMap<>(); HttpDef http = new HttpDef(); @@ -121,10 +121,10 @@ private Map addProperties(CustomAnnotationTemplateRequest reques // http.params (full string) List headerList = new LinkedList<>(); - List elementArgs = request.targetElementArgs(); + List elementArgs = request.targetElementArgs(); LinkedList parameters = new LinkedList<>(); int headerCount = 1; - for (TypedElementName elementArg : elementArgs) { + for (TypedElementInfo elementArg : elementArgs) { String type = elementArg.typeName().name(); switch (type) { @@ -171,7 +171,7 @@ private void processParameter(HttpDef httpDef, LinkedList parameters, List headerList, String type, - TypedElementName elementArg) { + TypedElementInfo elementArg) { // depending on annotations List annotations = elementArg.annotations(); if (annotations.size() == 0) { diff --git a/pico/api/src/main/java/io/helidon/pico/api/InvocationContext.java b/pico/api/src/main/java/io/helidon/pico/api/InvocationContext.java index ac868e43058..5a37a2537a1 100644 --- a/pico/api/src/main/java/io/helidon/pico/api/InvocationContext.java +++ b/pico/api/src/main/java/io/helidon/pico/api/InvocationContext.java @@ -23,7 +23,7 @@ import io.helidon.builder.Builder; import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import jakarta.inject.Provider; @@ -59,14 +59,14 @@ public interface InvocationContext { * * @return the element info represents the method (or the constructor) being invoked */ - TypedElementName elementInfo(); + TypedElementInfo elementInfo(); /** * The method/element argument info. * * @return the method/element argument info */ - Optional elementArgInfo(); + Optional elementArgInfo(); /** * The interceptor chain. diff --git a/pico/configdriven/processor/src/main/java/io/helidon/pico/configdriven/processor/ConfiguredByAnnotationProcessor.java b/pico/configdriven/processor/src/main/java/io/helidon/pico/configdriven/processor/ConfiguredByAnnotationProcessor.java index 9918283c47e..8af3e69bc3b 100644 --- a/pico/configdriven/processor/src/main/java/io/helidon/pico/configdriven/processor/ConfiguredByAnnotationProcessor.java +++ b/pico/configdriven/processor/src/main/java/io/helidon/pico/configdriven/processor/ConfiguredByAnnotationProcessor.java @@ -26,7 +26,7 @@ import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.processor.PicoAnnotationProcessor; import io.helidon.pico.tools.ActivatorCreatorProvider; import io.helidon.pico.tools.ServicesToProcess; @@ -65,7 +65,7 @@ protected Set supportedServiceClassTargetAnnotations() { protected void processExtensions(ServicesToProcess services, TypeInfo service, Set serviceTypeNamesToCodeGenerate, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { Optional configuredByAnno = findFirst(PICO_CONFIGURED_BY, service.annotations()); if (configuredByAnno.isEmpty()) { return; diff --git a/pico/processor/src/main/java/io/helidon/pico/processor/ActiveProcessorUtils.java b/pico/processor/src/main/java/io/helidon/pico/processor/ActiveProcessorUtils.java index f6572b8ae23..d066cd3e666 100644 --- a/pico/processor/src/main/java/io/helidon/pico/processor/ActiveProcessorUtils.java +++ b/pico/processor/src/main/java/io/helidon/pico/processor/ActiveProcessorUtils.java @@ -38,7 +38,7 @@ import io.helidon.builder.processor.spi.TypeInfoCreatorProvider; import io.helidon.common.HelidonServiceLoader; import io.helidon.common.types.TypeInfo; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.tools.Messager; import io.helidon.pico.tools.ModuleInfoDescriptor; import io.helidon.pico.tools.Options; @@ -187,7 +187,7 @@ void relayModuleInfoToServicesToProcess(ServicesToProcess servicesToProcess) { */ Optional toTypeInfo(TypeElement element, TypeMirror mirror, - Predicate isOneWeCareAbout) { + Predicate isOneWeCareAbout) { return typeInfoCreatorProvider.createTypeInfo(element, mirror, processingEnv, isOneWeCareAbout); } diff --git a/pico/processor/src/main/java/io/helidon/pico/processor/CustomAnnotationProcessor.java b/pico/processor/src/main/java/io/helidon/pico/processor/CustomAnnotationProcessor.java index 065c353e1e9..3ba0a81953e 100644 --- a/pico/processor/src/main/java/io/helidon/pico/processor/CustomAnnotationProcessor.java +++ b/pico/processor/src/main/java/io/helidon/pico/processor/CustomAnnotationProcessor.java @@ -39,7 +39,7 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.ServiceInfoBasics; import io.helidon.pico.tools.AbstractFilerMessager; import io.helidon.pico.tools.CodeGenFiler; @@ -54,7 +54,7 @@ import static io.helidon.pico.processor.GeneralProcessorUtils.hasValue; import static io.helidon.pico.processor.GeneralProcessorUtils.rootStackTraceElementOf; import static io.helidon.pico.tools.TypeTools.createTypeNameFromElement; -import static io.helidon.pico.tools.TypeTools.createTypedElementNameFromElement; +import static io.helidon.pico.tools.TypeTools.createTypedElementInfoFromElement; import static io.helidon.pico.tools.TypeTools.isStatic; import static io.helidon.pico.tools.TypeTools.toAccess; import static io.helidon.pico.tools.TypeTools.toFilePath; @@ -186,12 +186,12 @@ void doFiler(CustomAnnotationTemplateResponse response) { AbstractFilerMessager filer = AbstractFilerMessager.createAnnotationBasedFiler(processingEnv, utils()); CodeGenFiler codegen = CodeGenFiler.create(filer); response.generatedSourceCode().forEach(codegen::codegenJavaFilerOut); - response.generatedResources().forEach((typedElementName, resourceBody) -> { - String fileType = typedElementName.elementName(); + response.generatedResources().forEach((TypedElementInfo, resourceBody) -> { + String fileType = TypedElementInfo.elementName(); if (!hasValue(fileType)) { fileType = ".generated"; } - codegen.codegenResourceFilerOut(toFilePath(typedElementName.typeName(), fileType), resourceBody); + codegen.codegenResourceFilerOut(toFilePath(TypedElementInfo.typeName(), fileType), resourceBody); }); } @@ -238,7 +238,7 @@ CustomAnnotationTemplateRequestDefault.Builder toRequestBuilder(TypeName annoTyp .filerEnabled(true) .annoTypeName(annoTypeName) .serviceInfo(siInfo) - .targetElement(createTypedElementNameFromElement(typeToProcess, elements).orElseThrow()) + .targetElement(createTypedElementInfoFromElement(typeToProcess, elements).orElseThrow()) .enclosingTypeInfo(enclosingClassTypeInfo) // the following are duplicates that should be removed - get them from the enclosingTypeInfo instead // see https://github.com/helidon-io/helidon/issues/6773 @@ -247,16 +247,16 @@ CustomAnnotationTemplateRequestDefault.Builder toRequestBuilder(TypeName annoTyp .elementStatic(isStatic(typeToProcess)); } - List toArgs(Element typeToProcess) { + List toArgs(Element typeToProcess) { if (!(typeToProcess instanceof ExecutableElement)) { return List.of(); } Elements elements = processingEnv.getElementUtils(); - List result = new ArrayList<>(); + List result = new ArrayList<>(); ExecutableElement executableElement = (ExecutableElement) typeToProcess; executableElement.getParameters().forEach(v -> result.add( - createTypedElementNameFromElement(v, elements).orElseThrow())); + createTypedElementInfoFromElement(v, elements).orElseThrow())); return result; } diff --git a/pico/processor/src/main/java/io/helidon/pico/processor/GeneralProcessorUtils.java b/pico/processor/src/main/java/io/helidon/pico/processor/GeneralProcessorUtils.java index cbcd4b77600..eb738aa260a 100644 --- a/pico/processor/src/main/java/io/helidon/pico/processor/GeneralProcessorUtils.java +++ b/pico/processor/src/main/java/io/helidon/pico/processor/GeneralProcessorUtils.java @@ -35,7 +35,7 @@ import io.helidon.common.types.AnnotationAndValueDefault; import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.QualifierAndValue; import io.helidon.pico.api.QualifierAndValueDefault; import io.helidon.pico.api.RunLevel; @@ -185,12 +185,12 @@ static Optional toWeight(TypeInfo service) { * @return the post construct method if available */ static Optional toPostConstructMethod(TypeInfo service) { - List postConstructs = service.elementInfo().stream() + List postConstructs = service.interestingElementInfo().stream() .filter(it -> { AnnotationAndValue anno = findFirst(PostConstruct.class, it.annotations()).orElse(null); return (anno != null); }) - .map(TypedElementName::elementName) + .map(TypedElementInfo::elementName) .toList(); if (postConstructs.size() == 1) { return Optional.of(postConstructs.get(0)); @@ -215,12 +215,12 @@ static Optional toPostConstructMethod(TypeInfo service) { * @return the pre destroy method if available */ static Optional toPreDestroyMethod(TypeInfo service) { - List preDestroys = service.elementInfo().stream() + List preDestroys = service.interestingElementInfo().stream() .filter(it -> { AnnotationAndValue anno = findFirst(PreDestroy.class, it.annotations()).orElse(null); return (anno != null); }) - .map(TypedElementName::elementName) + .map(TypedElementInfo::elementName) .toList(); if (preDestroys.size() == 1) { return Optional.of(preDestroys.get(0)); @@ -311,7 +311,7 @@ static Set toQualifiers(TypeInfo service) { * @param service the service for which the typed element belongs * @return the qualifiers associated with the provided element */ - static Set toQualifiers(TypedElementName element, + static Set toQualifiers(TypedElementInfo element, TypeInfo service) { Set result = new LinkedHashSet<>(); diff --git a/pico/processor/src/main/java/io/helidon/pico/processor/PicoAnnotationProcessor.java b/pico/processor/src/main/java/io/helidon/pico/processor/PicoAnnotationProcessor.java index 4192999548b..b5bcb30c554 100644 --- a/pico/processor/src/main/java/io/helidon/pico/processor/PicoAnnotationProcessor.java +++ b/pico/processor/src/main/java/io/helidon/pico/processor/PicoAnnotationProcessor.java @@ -40,7 +40,7 @@ import io.helidon.common.types.AnnotationAndValueDefault; import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.Activator; import io.helidon.pico.api.Contract; import io.helidon.pico.api.DependenciesInfo; @@ -81,7 +81,7 @@ import static io.helidon.pico.processor.GeneralProcessorUtils.toScopeNames; import static io.helidon.pico.processor.GeneralProcessorUtils.toServiceTypeHierarchy; import static io.helidon.pico.processor.GeneralProcessorUtils.toWeight; -import static io.helidon.pico.tools.TypeTools.createTypedElementNameFromElement; +import static io.helidon.pico.tools.TypeTools.createTypedElementInfoFromElement; import static io.helidon.pico.tools.TypeTools.toAccess; import static java.util.Objects.requireNonNull; @@ -110,7 +110,7 @@ public class PicoAnnotationProcessor extends BaseAnnotationProcessor { TypeNames.JAVAX_PRE_DESTROY, TypeNames.JAVAX_POST_CONSTRUCT); - private final Set allElementsOfInterestInThisModule = new LinkedHashSet<>(); + private final Set allElementsOfInterestInThisModule = new LinkedHashSet<>(); private final Map typeInfoToCreateActivatorsForInThisModule = new LinkedHashMap<>(); private CreatorHandler creator; private boolean autoAddInterfaces; @@ -169,7 +169,7 @@ public boolean process(Set annotations, try { // build the model - Set elementsOfInterestInThisRound = gatherElementsOfInterestInThisModule(); + Set elementsOfInterestInThisRound = gatherElementsOfInterestInThisModule(); validate(elementsOfInterestInThisRound); allElementsOfInterestInThisModule.addAll(elementsOfInterestInThisRound); @@ -271,7 +271,7 @@ protected void doFiler(ServicesToProcess services) { * * @param elementsOfInterest the elements that are eligible for some form of Pico processing */ - protected void validate(Collection elementsOfInterest) { + protected void validate(Collection elementsOfInterest) { validatePerClass( elementsOfInterest, "There can be max of one injectable constructor per class", @@ -298,11 +298,11 @@ protected void validate(Collection elementsOfInterest) { || toModifierNames(it.modifierNames()).stream().anyMatch(TypeInfo.MODIFIER_STATIC::equalsIgnoreCase)); } - private void validatePerClass(Collection elementsOfInterest, + private void validatePerClass(Collection elementsOfInterest, String msg, int maxAllowed, - Predicate matcher) { - Map> allTypeNamesToMatchingElements = new LinkedHashMap<>(); + Predicate matcher) { + Map> allTypeNamesToMatchingElements = new LinkedHashMap<>(); elementsOfInterest.stream() .filter(matcher) .forEach(it -> allTypeNamesToMatchingElements @@ -336,7 +336,7 @@ protected Set interceptorAndValidate(Collection typesToCreat protected void process(ServicesToProcess services, TypeInfo service, Set serviceTypeNamesToCodeGenerate, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { utils().debug("Code generating" + Activator.class.getSimpleName() + " for: " + service.typeName()); processBasics(services, service, serviceTypeNamesToCodeGenerate, allElementsOfInterest); processInterceptors(services, service, serviceTypeNamesToCodeGenerate, allElementsOfInterest); @@ -355,7 +355,7 @@ protected void process(ServicesToProcess services, protected void processBasics(ServicesToProcess services, TypeInfo service, Set serviceTypeNamesToCodeGenerate, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { TypeName serviceTypeName = service.typeName(); TypeInfo superTypeInfo = service.superTypeInfo().orElse(null); if (superTypeInfo != null) { @@ -393,7 +393,7 @@ protected void processBasics(ServicesToProcess services, private void processInterceptors(ServicesToProcess services, TypeInfo service, Set serviceTypeNamesToCodeGenerate, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { TypeName serviceTypeName = service.typeName(); InterceptorCreator interceptorCreator = InterceptorCreatorProvider.instance(); ServiceInfoBasics interceptedServiceInfo = toBasicServiceInfo(service); @@ -426,7 +426,7 @@ private void processInterceptors(ServicesToProcess services, protected void processExtensions(ServicesToProcess services, TypeInfo service, Set serviceTypeNamesToCodeGenerate, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { // NOP; expected that derived classes will implement this } @@ -443,7 +443,7 @@ protected Optional findFirst(String jakartaAnnoNam } private ServicesToProcess toServicesToProcess(Set typesToCodeGenerate, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { ServicesToProcess services = ServicesToProcess.create(); utils().relayModuleInfoToServicesToProcess(services); @@ -583,7 +583,7 @@ private Optional filterModuleName(Optional moduleName) { } private Optional toInjectionDependencies(TypeInfo service, - Collection allElementsOfInterest) { + Collection allElementsOfInterest) { Dependencies.BuilderContinuation builder = Dependencies.builder(service.typeName().name()); gatherInjectionPoints(builder, service, allElementsOfInterest); DependenciesInfo deps = builder.build(); @@ -592,8 +592,8 @@ private Optional toInjectionDependencies(TypeInfo service, private void gatherInjectionPoints(Dependencies.BuilderContinuation builder, TypeInfo service, - Collection allElementsOfInterest) { - List injectableElementsForThisService = allElementsOfInterest.stream() + Collection allElementsOfInterest) { + List injectableElementsForThisService = allElementsOfInterest.stream() .filter(it -> GeneralProcessorUtils.findFirst(Inject.class, it.annotations()).isPresent()) .filter(it -> service.typeName().equals(it.enclosingTypeName().orElseThrow())) .toList(); @@ -613,7 +613,7 @@ private void gatherInjectionPoints(Dependencies.BuilderContinuation builder, * @param service the type info of the backing service */ private static void gatherInjectionPoints(Dependencies.BuilderContinuation builder, - TypedElementName typedElement, + TypedElementInfo typedElement, TypeInfo service, Set modifierNames) { String elemName = typedElement.elementName(); @@ -670,8 +670,8 @@ private static void gatherInjectionPoints(Dependencies.BuilderContinuation build } } - private Set gatherElementsOfInterestInThisModule() { - Set result = new LinkedHashSet<>(); + private Set gatherElementsOfInterestInThisModule() { + Set result = new LinkedHashSet<>(); Elements elementUtils = processingEnv.getElementUtils(); for (String annoType : supportedElementTargetAnnotations()) { @@ -679,7 +679,7 @@ private Set gatherElementsOfInterestInThisModule() { TypeElement annoTypeElement = elementUtils.getTypeElement(annoType); if (annoTypeElement != null) { Set typesToProcess = utils().roundEnv().getElementsAnnotatedWith(annoTypeElement); - typesToProcess.forEach(it -> result.add(createTypedElementNameFromElement(it, elementUtils).orElseThrow())); + typesToProcess.forEach(it -> result.add(createTypedElementInfoFromElement(it, elementUtils).orElseThrow())); } } @@ -687,7 +687,7 @@ private Set gatherElementsOfInterestInThisModule() { } private void gatherTypeInfosToProcessInThisModule(Map result, - Collection elementsOfInterest) { + Collection elementsOfInterest) { // this section gathers based upon the class-level annotations in order to discover what to process for (String annoType : supportedServiceClassTargetAnnotations()) { // annotation may not be on the classpath, in such a case just ignore it @@ -710,7 +710,7 @@ private void gatherTypeInfosToProcessInThisModule(Map result // this section gathers based upon the element-level annotations in order to discover what to process Set enclosingElementsOfInterest = elementsOfInterest.stream() - .map(TypedElementName::enclosingTypeName) + .map(TypedElementInfo::enclosingTypeName) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toSet()); diff --git a/pico/processor/src/test/java/io/helidon/pico/processor/CustomAnnotationProcessorTest.java b/pico/processor/src/test/java/io/helidon/pico/processor/CustomAnnotationProcessorTest.java index e8e61db4413..3c993f2c2fc 100644 --- a/pico/processor/src/test/java/io/helidon/pico/processor/CustomAnnotationProcessorTest.java +++ b/pico/processor/src/test/java/io/helidon/pico/processor/CustomAnnotationProcessorTest.java @@ -25,8 +25,8 @@ import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeInfoDefault; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfo; +import io.helidon.common.types.TypedElementInfoDefault; import io.helidon.pico.api.ElementInfo; import io.helidon.pico.api.ServiceInfoBasics; import io.helidon.pico.api.ServiceInfoDefault; @@ -68,12 +68,12 @@ void extensibleGET() { .typeName(create(BasicEndpoint.class)) .annotations(annotations) .build(); - TypedElementName target = TypedElementNameDefault.builder() + TypedElementInfo target = TypedElementInfoDefault.builder() .typeName(create(String.class)) .elementKind(ElementKind.METHOD.name()) .elementName("itWorks") .build(); - TypedElementName arg1 = TypedElementNameDefault.builder() + TypedElementInfo arg1 = TypedElementInfoDefault.builder() .typeName(create(String.class)) .elementName("header") .build(); diff --git a/pico/runtime/src/main/java/io/helidon/pico/runtime/InterceptedMethod.java b/pico/runtime/src/main/java/io/helidon/pico/runtime/InterceptedMethod.java index adbdcc17ce1..f26a23ef102 100644 --- a/pico/runtime/src/main/java/io/helidon/pico/runtime/InterceptedMethod.java +++ b/pico/runtime/src/main/java/io/helidon/pico/runtime/InterceptedMethod.java @@ -22,7 +22,7 @@ import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.Interceptor; import io.helidon.pico.api.InvocationContext; import io.helidon.pico.api.InvocationContextDefault; @@ -58,8 +58,8 @@ protected InterceptedMethod(I interceptedImpl, TypeName serviceTypeName, Collection serviceLevelAnnotations, Collection> interceptors, - TypedElementName methodInfo, - TypedElementName[] methodArgInfo) { + TypedElementInfo methodInfo, + TypedElementInfo[] methodArgInfo) { this.impl = Objects.requireNonNull(interceptedImpl); this.ctx = InvocationContextDefault.builder() .serviceProvider(serviceProvider) @@ -86,7 +86,7 @@ protected InterceptedMethod(I interceptedImpl, TypeName serviceTypeName, Collection serviceLevelAnnotations, Collection> interceptors, - TypedElementName methodInfo) { + TypedElementInfo methodInfo) { this.impl = Objects.requireNonNull(interceptedImpl); this.ctx = InvocationContextDefault.builder() .serviceProvider(serviceProvider) diff --git a/pico/runtime/src/test/java/io/helidon/pico/runtime/InvocationTest.java b/pico/runtime/src/test/java/io/helidon/pico/runtime/InvocationTest.java index 15d82ac3642..4fb047ebb79 100644 --- a/pico/runtime/src/test/java/io/helidon/pico/runtime/InvocationTest.java +++ b/pico/runtime/src/test/java/io/helidon/pico/runtime/InvocationTest.java @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfoDefault; import io.helidon.pico.api.Interceptor; import io.helidon.pico.api.InvocationContext; import io.helidon.pico.api.InvocationContextDefault; @@ -42,7 +42,7 @@ class InvocationTest { TestInterceptor first = new TestInterceptor("first"); TestInterceptor second = new TestInterceptor("second"); InvocationContext dummyCtx = InvocationContextDefault.builder() - .elementInfo(TypedElementNameDefault.builder().elementName("test").typeName(InvocationTest.class).build()) + .elementInfo(TypedElementInfoDefault.builder().elementName("test").typeName(InvocationTest.class).build()) .interceptors(List.of(first.provider, second.provider)); ArrayList calls = new ArrayList<>(); @@ -63,7 +63,7 @@ void normalCaseWithInterceptors() { @Test void normalCaseWithNoInterceptors() { InvocationContext dummyCtx = InvocationContextDefault.builder() - .elementInfo(TypedElementNameDefault.builder().elementName("test").typeName(InvocationTest.class).build()) + .elementInfo(TypedElementInfoDefault.builder().elementName("test").typeName(InvocationTest.class).build()) .interceptors(List.of()); Object[] args = new Object[] {}; diff --git a/pico/tests/resources-pico/src/test/resources/expected/ximpl-interceptor._java_ b/pico/tests/resources-pico/src/test/resources/expected/ximpl-interceptor._java_ index 6cf4ce06cda..cb04c127469 100644 --- a/pico/tests/resources-pico/src/test/resources/expected/ximpl-interceptor._java_ +++ b/pico/tests/resources-pico/src/test/resources/expected/ximpl-interceptor._java_ @@ -10,9 +10,9 @@ import java.util.function.Function; import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.AnnotationAndValueDefault; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfoDefault; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.ClassNamed; import io.helidon.pico.api.InvocationContextDefault; import io.helidon.pico.api.Interceptor; @@ -46,7 +46,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce AnnotationAndValueDefault.create(io.helidon.pico.api.ExternalContracts.class, Map.of("moduleNames", "test1, test2", "value", "java.io.Closeable")), AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))); - private static final TypedElementName __ctor = TypedElementNameDefault.builder() + private static final TypedElementInfo __ctor = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName(io.helidon.pico.api.ElementInfo.CONSTRUCTOR) .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -56,7 +56,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Singleton.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIA1 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIA1 = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("methodIA1") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -66,7 +66,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIA2 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIA2 = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("methodIA2") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -77,7 +77,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIB = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("methodIB") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -89,12 +89,12 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIB__p1 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB__p1 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("p1") .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Named.class, Map.of("value", "arg1"))) .build(); - private static final TypedElementName __methodIB2 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB2 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("methodIB2") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -106,12 +106,12 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIB2__p1 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB2__p1 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("p1") .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Named.class, Map.of("value", "arg1"))) .build(); - private static final TypedElementName __close = TypedElementNameDefault.builder() + private static final TypedElementInfo __close = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("close") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -122,7 +122,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodX = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodX = TypedElementInfoDefault.builder() .typeName(create(long.class)) .elementName("methodX") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -131,19 +131,19 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Singleton.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodX__p1 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodX__p1 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("p1") .build(); - private static final TypedElementName __methodX__p2 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodX__p2 = TypedElementInfoDefault.builder() .typeName(create(int.class)) .elementName("p2") .build(); - private static final TypedElementName __methodX__p3 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodX__p3 = TypedElementInfoDefault.builder() .typeName(create(boolean.class)) .elementName("p3") .build(); - private static final TypedElementName __methodY = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodY = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("methodY") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -152,7 +152,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Singleton.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodZ = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodZ = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("methodZ") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -161,7 +161,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Singleton.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __throwRuntimeException = TypedElementNameDefault.builder() + private static final TypedElementInfo __throwRuntimeException = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("throwRuntimeException") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ClassNamed.class, Map.of("value", "io.helidon.pico.tests.pico.ClassNamedX"))) @@ -247,7 +247,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce this.__methodIB__call = new InterceptedMethod( __impl, __sp, __serviceTypeName, __serviceLevelAnnotations, __methodIB__interceptors, __methodIB, - new TypedElementName[] {__methodIB__p1}) { + new TypedElementInfo[] {__methodIB__p1}) { @Override public java.lang.Void invoke(Object... args) throws Throwable { impl().methodIB((java.lang.String) args[0]); @@ -257,7 +257,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce this.__methodIB2__call = new InterceptedMethod( __impl, __sp, __serviceTypeName, __serviceLevelAnnotations, __methodIB2__interceptors, __methodIB2, - new TypedElementName[] {__methodIB2__p1}) { + new TypedElementInfo[] {__methodIB2__p1}) { @Override public java.lang.String invoke(Object... args) throws Throwable { return impl().methodIB2((java.lang.String) args[0]); @@ -275,7 +275,7 @@ public class XImpl$$Pico$$Interceptor extends io.helidon.pico.tests.pico.interce this.__methodX__call = new InterceptedMethod( __impl, __sp, __serviceTypeName, __serviceLevelAnnotations, __methodX__interceptors, __methodX, - new TypedElementName[] {__methodX__p1, __methodX__p2, __methodX__p3}) { + new TypedElementInfo[] {__methodX__p1, __methodX__p2, __methodX__p3}) { @Override public java.lang.Long invoke(Object... args) throws Throwable { return impl().methodX((java.lang.String) args[0], (java.lang.Integer) args[1], (java.lang.Boolean) args[2]); diff --git a/pico/tests/resources-pico/src/test/resources/expected/yimpl-interceptor._java_ b/pico/tests/resources-pico/src/test/resources/expected/yimpl-interceptor._java_ index 3dfcb9a065e..679ecab1eda 100644 --- a/pico/tests/resources-pico/src/test/resources/expected/yimpl-interceptor._java_ +++ b/pico/tests/resources-pico/src/test/resources/expected/yimpl-interceptor._java_ @@ -10,9 +10,9 @@ import java.util.function.Function; import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.AnnotationAndValueDefault; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfoDefault; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.InvocationContextDefault; import io.helidon.pico.api.Interceptor; import io.helidon.pico.api.InvocationException; @@ -44,7 +44,7 @@ public class YImpl$$Pico$$Interceptor /* extends io.helidon.pico.tests.pico.inte AnnotationAndValueDefault.create(io.helidon.pico.api.ExternalContracts.class, Map.of("moduleNames", "test1, test2", "value", "java.io.Closeable")), AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))); - private static final TypedElementName __ctor = TypedElementNameDefault.builder() + private static final TypedElementInfo __ctor = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName(io.helidon.pico.api.ElementInfo.CONSTRUCTOR) .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ExternalContracts.class, Map.of("moduleNames", "test1, test2", "value", "java.io.Closeable"))) @@ -53,7 +53,7 @@ public class YImpl$$Pico$$Interceptor /* extends io.helidon.pico.tests.pico.inte .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Singleton.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIB = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("methodIB") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ExternalContracts.class, Map.of("moduleNames", "test1, test2", "value", "java.io.Closeable"))) @@ -63,12 +63,12 @@ public class YImpl$$Pico$$Interceptor /* extends io.helidon.pico.tests.pico.inte .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIB__p1 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB__p1 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("p1") .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Named.class, Map.of("value", "arg1"))) .build(); - private static final TypedElementName __methodIB2 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB2 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class)) .elementName("methodIB2") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ExternalContracts.class, Map.of("moduleNames", "test1, test2", "value", "java.io.Closeable"))) @@ -78,12 +78,12 @@ public class YImpl$$Pico$$Interceptor /* extends io.helidon.pico.tests.pico.inte .addAnnotation(AnnotationAndValueDefault.create(java.lang.Override.class)) .addAnnotation(AnnotationAndValueDefault.create(java.lang.SuppressWarnings.class, Map.of("value", "unused"))) .build(); - private static final TypedElementName __methodIB2__p1 = TypedElementNameDefault.builder() + private static final TypedElementInfo __methodIB2__p1 = TypedElementInfoDefault.builder() .typeName(create(java.lang.String.class) ) .elementName("p1") .addAnnotation(AnnotationAndValueDefault.create(jakarta.inject.Named.class, Map.of("value", "arg1"))) .build(); - private static final TypedElementName __close = TypedElementNameDefault.builder() + private static final TypedElementInfo __close = TypedElementInfoDefault.builder() .typeName(create(void.class)) .elementName("close") .addAnnotation(AnnotationAndValueDefault.create(io.helidon.pico.api.ExternalContracts.class, Map.of("moduleNames", "test1, test2", "value", "java.io.Closeable"))) @@ -133,7 +133,7 @@ public class YImpl$$Pico$$Interceptor /* extends io.helidon.pico.tests.pico.inte this.__methodIB__call = new InterceptedMethod( __impl, __sp, __serviceTypeName, __serviceLevelAnnotations, __methodIB__interceptors, __methodIB, - new TypedElementName[] {__methodIB__p1}) { + new TypedElementInfo[] {__methodIB__p1}) { @Override public java.lang.Void invoke(Object... args) throws Throwable { impl().methodIB((java.lang.String) args[0]); @@ -143,7 +143,7 @@ public class YImpl$$Pico$$Interceptor /* extends io.helidon.pico.tests.pico.inte this.__methodIB2__call = new InterceptedMethod( __impl, __sp, __serviceTypeName, __serviceLevelAnnotations, __methodIB2__interceptors, __methodIB2, - new TypedElementName[] {__methodIB2__p1}) { + new TypedElementInfo[] {__methodIB2__p1}) { @Override public java.lang.String invoke(Object... args) throws Throwable { return impl().methodIB2((java.lang.String) args[0]); diff --git a/pico/tests/resources-plain/src/main/java/io/helidon/pico/tests/plain/interceptor/TestNamedInterceptor.java b/pico/tests/resources-plain/src/main/java/io/helidon/pico/tests/plain/interceptor/TestNamedInterceptor.java index bc38aaf5179..303c9cfd181 100644 --- a/pico/tests/resources-plain/src/main/java/io/helidon/pico/tests/plain/interceptor/TestNamedInterceptor.java +++ b/pico/tests/resources-plain/src/main/java/io/helidon/pico/tests/plain/interceptor/TestNamedInterceptor.java @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.Interceptor; import io.helidon.pico.api.InvocationContext; @@ -37,7 +37,7 @@ public V proceed(InvocationContext ctx, Object... args) { assert (ctx != null); - TypedElementName methodInfo = ctx.elementInfo(); + TypedElementInfo methodInfo = ctx.elementInfo(); if (methodInfo != null && methodInfo.typeName().equals(TypeNameDefault.create(long.class))) { V result = chain.proceed(args); long longResult = (Long) result; diff --git a/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateRequest.java b/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateRequest.java index 493691c544c..2371f93a6a4 100644 --- a/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateRequest.java +++ b/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateRequest.java @@ -21,7 +21,7 @@ import io.helidon.builder.Builder; import io.helidon.common.types.TypeInfo; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.config.metadata.ConfiguredOption; import io.helidon.pico.api.InjectionPointInfo; import io.helidon.pico.api.ServiceInfoBasics; @@ -45,7 +45,7 @@ public interface CustomAnnotationTemplateRequest { * * @return the target element being processed */ - TypedElementName targetElement(); + TypedElementInfo targetElement(); /** * The access modifier of the element. @@ -60,7 +60,7 @@ public interface CustomAnnotationTemplateRequest { * * @return the list of typed arguments for this method or constructor */ - List targetElementArgs(); + List targetElementArgs(); /** * Returns true if the element is declared to be static. diff --git a/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateResponse.java b/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateResponse.java index 41d2eea5e76..8e94cd5e697 100644 --- a/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateResponse.java +++ b/pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateResponse.java @@ -21,7 +21,7 @@ import io.helidon.builder.Builder; import io.helidon.builder.Singular; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; /** * The response from {@link io.helidon.pico.tools.spi.CustomAnnotationTemplateCreator#create(CustomAnnotationTemplateRequest)}. @@ -50,7 +50,7 @@ public interface CustomAnnotationTemplateResponse { * @return map of generated type name (which is really just a directory path under resources) to the resource to be generated */ @Singular - Map generatedResources(); + Map generatedResources(); /** * Aggregates the responses given to one response. diff --git a/pico/tools/src/main/java/io/helidon/pico/tools/InterceptorCreatorDefault.java b/pico/tools/src/main/java/io/helidon/pico/tools/InterceptorCreatorDefault.java index c1d40e5f496..421c1003304 100644 --- a/pico/tools/src/main/java/io/helidon/pico/tools/InterceptorCreatorDefault.java +++ b/pico/tools/src/main/java/io/helidon/pico/tools/InterceptorCreatorDefault.java @@ -1057,7 +1057,7 @@ private static InterceptedMethodCodeGen toBody(InterceptedElement method) { String elementArgInfo = ""; if (hasArgs) { - elementArgInfo = ",\n\t\t\t\tnew TypedElementName[] {" + typedElementArgs + "}"; + elementArgInfo = ",\n\t\t\t\tnew TypedElementInfo[] {" + typedElementArgs + "}"; } return new InterceptedMethodCodeGen(name, methodDecl, true, hasReturn, supplierType, elementArgInfo, args, objArrayArgs, untypedElementArgs, diff --git a/pico/tools/src/main/resources/templates/pico/default/interface-based-interceptor.hbs b/pico/tools/src/main/resources/templates/pico/default/interface-based-interceptor.hbs index 0640aeadc35..15ee366b4b7 100644 --- a/pico/tools/src/main/resources/templates/pico/default/interface-based-interceptor.hbs +++ b/pico/tools/src/main/resources/templates/pico/default/interface-based-interceptor.hbs @@ -24,9 +24,9 @@ import java.util.function.Function; import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.AnnotationAndValueDefault; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfoDefault; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.ClassNamed; import io.helidon.pico.api.InvocationContextDefault; import io.helidon.pico.api.Interceptor; @@ -56,7 +56,7 @@ public class {{className}} /* extends {{parent}} */ implements {{interfaces}} { private static final List __serviceLevelAnnotations = List.of({{#servicelevelannotations}} {{{.}}}{{#unless @last}},{{/unless}}{{/servicelevelannotations}}); {{#interceptedmethoddecls}} - private static final TypedElementName __{{id}} = TypedElementNameDefault.builder() + private static final TypedElementInfo __{{id}} = TypedElementInfoDefault.builder() {{{.}}} .build();{{/interceptedmethoddecls}} diff --git a/pico/tools/src/main/resources/templates/pico/default/no-arg-based-interceptor.hbs b/pico/tools/src/main/resources/templates/pico/default/no-arg-based-interceptor.hbs index 074c2c51f44..b118502f96c 100644 --- a/pico/tools/src/main/resources/templates/pico/default/no-arg-based-interceptor.hbs +++ b/pico/tools/src/main/resources/templates/pico/default/no-arg-based-interceptor.hbs @@ -24,9 +24,9 @@ import java.util.function.Function; import io.helidon.common.types.AnnotationAndValue; import io.helidon.common.types.AnnotationAndValueDefault; import io.helidon.common.types.TypeNameDefault; -import io.helidon.common.types.TypedElementNameDefault; +import io.helidon.common.types.TypedElementInfoDefault; import io.helidon.common.types.TypeName; -import io.helidon.common.types.TypedElementName; +import io.helidon.common.types.TypedElementInfo; import io.helidon.pico.api.ClassNamed; import io.helidon.pico.api.InvocationContextDefault; import io.helidon.pico.api.Interceptor; @@ -56,7 +56,7 @@ public class {{className}} extends {{parent}} { private static final List __serviceLevelAnnotations = List.of({{#servicelevelannotations}} {{{.}}}{{#unless @last}},{{/unless}}{{/servicelevelannotations}}); {{#interceptedmethoddecls}} - private static final TypedElementName __{{id}} = TypedElementNameDefault.builder() + private static final TypedElementInfo __{{id}} = TypedElementInfoDefault.builder() {{{.}}} .build();{{/interceptedmethoddecls}}