Skip to content

Commit d2c8907

Browse files
committed
#97 - Followup tidy remove unused code
1 parent 30f5615 commit d2c8907

File tree

3 files changed

+2
-39
lines changed

3 files changed

+2
-39
lines changed

inject-generator/src/main/java/io/avaje/inject/generator/MethodReader.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.avaje.inject.generator;
22

33
import io.avaje.inject.Bean;
4-
54
import jakarta.inject.Named;
65

76
import javax.lang.model.element.*;
@@ -15,12 +14,9 @@ class MethodReader {
1514
private static final String CODE_COMMENT_LIFECYCLE = " /**\n * Lifecycle wrapper for %s.\n */";
1615
private static final String CODE_COMMENT_BUILD_FACTORYBEAN = " /**\n * Create and register %s via factory bean method %s#%s().\n */";
1716

18-
private final ProcessingContext context;
1917
private final ExecutableElement element;
2018
private final String factoryType;
2119
private final String methodName;
22-
private final TypeMirror returnType;
23-
private final TypeElement returnElement;
2420
private final String returnTypeRaw;
2521
private final String shortName;
2622
private final boolean isVoid;
@@ -39,10 +35,9 @@ class MethodReader {
3935

4036
MethodReader(ProcessingContext context, ExecutableElement element, TypeElement beanType, Bean bean, Named named) {
4137
this.isFactory = bean != null;
42-
this.context = context;
4338
this.element = element;
4439
this.methodName = element.getSimpleName().toString();
45-
this.returnType = element.getReturnType();
40+
TypeMirror returnType = element.getReturnType();
4641
this.returnTypeRaw = returnType.toString();
4742
this.shortName = Util.shortName(returnTypeRaw);
4843
this.factoryType = beanType.getQualifiedName().toString();
@@ -51,7 +46,7 @@ class MethodReader {
5146
this.initMethod = (bean == null) ? null : bean.initMethod();
5247
this.destroyMethod = (bean == null) ? null : bean.destroyMethod();
5348
this.name = (named == null) ? null : named.value();
54-
this.returnElement = baseTypeElement(context.asElement(returnType));
49+
TypeElement returnElement = baseTypeElement(context.asElement(returnType));
5550
if (returnElement == null) {
5651
this.typeReader = null;
5752
} else {

inject-generator/src/main/java/io/avaje/inject/generator/TypeInterfaceReader.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class TypeInterfaceReader {
1515
private final ProcessingContext context;
1616
private final List<String> interfaceTypes = new ArrayList<>();
1717
private boolean beanLifeCycle;
18-
private String ifaceForType;
1918

2019
/**
2120
* Create for bean type.
@@ -33,10 +32,6 @@ boolean isBeanLifeCycle() {
3332
return beanLifeCycle;
3433
}
3534

36-
String getIfaceForType() {
37-
return ifaceForType;
38-
}
39-
4035
void process() {
4136
if (beanType == null) {
4237
return;
@@ -54,12 +49,5 @@ void process() {
5449
interfaceTypes.add(type);
5550
}
5651
}
57-
if (interfaceTypes.size() == 1) {
58-
String ifaceType = interfaceTypes.get(0);
59-
if (!GenericType.isGeneric(ifaceType)) {
60-
// only register for non-generic interfaces for the moment
61-
ifaceForType = Util.addForInterface(ifaceType);
62-
}
63-
}
6452
}
6553
}

inject-generator/src/main/java/io/avaje/inject/generator/TypeReader.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class TypeReader {
1616
private final TypeInterfaceReader interfaceReader;
1717
private final TypeAnnotationReader annotationReader;
1818
private boolean beanLifeCycle;
19-
private String ifaceForType;
20-
private String typesAddFor;
2119
private String typesRegister;
2220

2321
TypeReader(TypeElement beanType, ProcessingContext context, Set<String> importTypes) {
@@ -41,10 +39,6 @@ boolean isBeanLifeCycle() {
4139
return beanLifeCycle;
4240
}
4341

44-
String getTypesAddFor() {
45-
return typesAddFor;
46-
}
47-
4842
String getTypesRegister() {
4943
return typesRegister;
5044
}
@@ -57,7 +51,6 @@ void process() {
5751
extendsReader.process();
5852
interfaceReader.process();
5953
beanLifeCycle = interfaceReader.isBeanLifeCycle();
60-
ifaceForType = interfaceReader.getIfaceForType();
6154
if (forBean) {
6255
annotationReader.process();
6356
}
@@ -86,19 +79,6 @@ private void initRegistrationTypes() {
8679
appender.add(annotationReader.getAnnotationTypes());
8780
}
8881
this.typesRegister = appender.asString();
89-
this.typesAddFor = initTypesFor();
90-
}
91-
92-
private String initTypesFor() {
93-
StringBuilder buffer = new StringBuilder();
94-
if (ifaceForType != null) {
95-
buffer.append(", ").append(ifaceForType).append(".class");
96-
} else {
97-
for (String type : extendsReader.getExtendsTypes()) {
98-
buffer.append(", ").append(Util.shortName(type)).append(".class");
99-
}
100-
}
101-
return buffer.toString();
10282
}
10383

10484
void addImports(Set<String> importTypes) {

0 commit comments

Comments
 (0)