Skip to content

Commit cfcef76

Browse files
authored
resolves issue (helidon-io#6883)
1 parent a38b51e commit cfcef76

5 files changed

Lines changed: 2 additions & 57 deletions

File tree

nima/http/processor/src/main/java/io/helidon/nima/http/processor/HttpMethodCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private Map<String, Object> addProperties(CustomAnnotationTemplateRequest reques
121121

122122
// http.params (full string)
123123
List<HeaderDef> headerList = new LinkedList<>();
124-
List<TypedElementInfo> elementArgs = request.targetElementArgs();
124+
List<TypedElementInfo> elementArgs = request.targetElement().parameterArguments();
125125
LinkedList<String> parameters = new LinkedList<>();
126126
int headerCount = 1;
127127
for (TypedElementInfo elementArg : elementArgs) {

pico/processor/src/main/java/io/helidon/pico/processor/CustomAnnotationProcessor.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.helidon.pico.processor;
1818

19-
import java.util.ArrayList;
2019
import java.util.Collection;
2120
import java.util.Collections;
2221
import java.util.LinkedHashSet;
@@ -31,15 +30,13 @@
3130
import javax.annotation.processing.ProcessingEnvironment;
3231
import javax.annotation.processing.RoundEnvironment;
3332
import javax.lang.model.element.Element;
34-
import javax.lang.model.element.ExecutableElement;
3533
import javax.lang.model.element.TypeElement;
3634
import javax.lang.model.util.Elements;
3735

3836
import io.helidon.common.HelidonServiceLoader;
3937
import io.helidon.common.types.TypeInfo;
4038
import io.helidon.common.types.TypeName;
4139
import io.helidon.common.types.TypeNameDefault;
42-
import io.helidon.common.types.TypedElementInfo;
4340
import io.helidon.pico.api.ServiceInfoBasics;
4441
import io.helidon.pico.tools.AbstractFilerMessager;
4542
import io.helidon.pico.tools.CodeGenFiler;
@@ -55,8 +52,6 @@
5552
import static io.helidon.pico.processor.GeneralProcessorUtils.rootStackTraceElementOf;
5653
import static io.helidon.pico.tools.TypeTools.createTypeNameFromElement;
5754
import static io.helidon.pico.tools.TypeTools.createTypedElementInfoFromElement;
58-
import static io.helidon.pico.tools.TypeTools.isStatic;
59-
import static io.helidon.pico.tools.TypeTools.toAccess;
6055
import static io.helidon.pico.tools.TypeTools.toFilePath;
6156

6257
/**
@@ -239,25 +234,7 @@ CustomAnnotationTemplateRequestDefault.Builder toRequestBuilder(TypeName annoTyp
239234
.annoTypeName(annoTypeName)
240235
.serviceInfo(siInfo)
241236
.targetElement(createTypedElementInfoFromElement(typeToProcess, elements).orElseThrow())
242-
.enclosingTypeInfo(enclosingClassTypeInfo)
243-
// the following are duplicates that should be removed - get them from the enclosingTypeInfo instead
244-
// see https://github.com/helidon-io/helidon/issues/6773
245-
.targetElementArgs(toArgs(typeToProcess))
246-
.targetElementAccess(toAccess(typeToProcess))
247-
.elementStatic(isStatic(typeToProcess));
248-
}
249-
250-
List<TypedElementInfo> toArgs(Element typeToProcess) {
251-
if (!(typeToProcess instanceof ExecutableElement)) {
252-
return List.of();
253-
}
254-
255-
Elements elements = processingEnv.getElementUtils();
256-
List<TypedElementInfo> result = new ArrayList<>();
257-
ExecutableElement executableElement = (ExecutableElement) typeToProcess;
258-
executableElement.getParameters().forEach(v -> result.add(
259-
createTypedElementInfoFromElement(v, elements).orElseThrow()));
260-
return result;
237+
.enclosingTypeInfo(enclosingClassTypeInfo);
261238
}
262239

263240
private static TypeElement toEnclosingClassTypeElement(Element typeToProcess) {

pico/processor/src/main/java/io/helidon/pico/processor/GenericTemplateCreatorDefault.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,10 @@ Map<String, Object> gatherSubstitutions(GenericTemplateCreatorRequest genericReq
114114
substitutions.put("basicServiceInfo", req.serviceInfo());
115115
substitutions.put("weight", req.serviceInfo().realizedWeight());
116116
substitutions.put("runLevel", req.serviceInfo().realizedRunLevel());
117-
substitutions.put("elementAccess", req.targetElementAccess());
118-
substitutions.put("elementIsStatic", req.isElementStatic());
119117
substitutions.put("elementKind", req.targetElement().elementTypeKind());
120118
substitutions.put("elementName", req.targetElement().elementName());
121119
substitutions.put("elementAnnotations", req.targetElement().annotations());
122120
substitutions.put("elementEnclosingTypeName", req.targetElement().typeName());
123-
substitutions.put("elementArgs", req.targetElementArgs());
124-
substitutions.put("elementArgs-declaration", GeneralProcessorUtils.toString(req.targetElementArgs()));
125121
substitutions.putAll(genericRequest.overrideProperties());
126122
return substitutions;
127123
}

pico/processor/src/test/java/io/helidon/pico/processor/CustomAnnotationProcessorTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import io.helidon.common.types.TypeName;
2828
import io.helidon.common.types.TypedElementInfo;
2929
import io.helidon.common.types.TypedElementInfoDefault;
30-
import io.helidon.pico.api.ElementInfo;
3130
import io.helidon.pico.api.ServiceInfoBasics;
3231
import io.helidon.pico.api.ServiceInfoDefault;
3332
import io.helidon.pico.processor.testsubjects.BasicEndpoint;
@@ -84,8 +83,6 @@ void extensibleGET() {
8483
.annoTypeName(create(ExtensibleGET.class))
8584
.serviceInfo(serviceInfo)
8685
.targetElement(target)
87-
.targetElementArgs(List.of(arg1))
88-
.targetElementAccess(ElementInfo.Access.PUBLIC)
8986
.enclosingTypeInfo(enclosingTypeInfo)
9087
.genericTemplateCreator(genericTemplateCreator)
9188
.build();

pico/tools/src/main/java/io/helidon/pico/tools/CustomAnnotationTemplateRequest.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616

1717
package io.helidon.pico.tools;
1818

19-
import java.util.List;
20-
2119
import io.helidon.builder.Builder;
2220
import io.helidon.common.types.TypeInfo;
2321
import io.helidon.common.types.TypeName;
2422
import io.helidon.common.types.TypedElementInfo;
2523
import io.helidon.config.metadata.ConfiguredOption;
26-
import io.helidon.pico.api.InjectionPointInfo;
2724
import io.helidon.pico.api.ServiceInfoBasics;
2825

2926
/**
@@ -47,28 +44,6 @@ public interface CustomAnnotationTemplateRequest {
4744
*/
4845
TypedElementInfo targetElement();
4946

50-
/**
51-
* The access modifier of the element.
52-
*
53-
* @return the access modifier of the element
54-
*/
55-
InjectionPointInfo.Access targetElementAccess();
56-
57-
/**
58-
* Only applicable for {@link javax.lang.model.element.ElementKind#METHOD} or
59-
* {@link javax.lang.model.element.ElementKind#CONSTRUCTOR}.
60-
*
61-
* @return the list of typed arguments for this method or constructor
62-
*/
63-
List<TypedElementInfo> targetElementArgs();
64-
65-
/**
66-
* Returns true if the element is declared to be static.
67-
*
68-
* @return returns true if the element is declared to be private
69-
*/
70-
boolean isElementStatic();
71-
7247
/**
7348
* Projects the {@link #enclosingTypeInfo()} as a {@link ServiceInfoBasics} type.
7449
*

0 commit comments

Comments
 (0)