Skip to content

Fixes Aspects not working for Certain Types #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void writeMethod(Append writer) {
if (i > 0) {
writer.append(", ");
}
params.get(i).writeMethodParam(writer);
params.get(i).writeMethodParamAspect(writer);
}
writer.append(")");
writeThrowsClause(writer);
Expand Down Expand Up @@ -118,7 +118,7 @@ void writeSetupForMethods(Append writer, String shortName) {
writer.append(" %s = %s.class.getDeclaredMethod(\"%s\"", localName, shortName, simpleName);
for (MethodReader.MethodParam param : params) {
writer.append(", ");
param.writeMethodParamType(writer);
param.writeMethodParamTypeAspect(writer);
writer.append(".class");
}
writer.append(");").eol();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -392,11 +393,11 @@ Dependency getDependsOn() {
}

void addImports(Set<String> importTypes) {

importTypes.addAll(Arrays.asList(utilType.full().split("[<|>|,]")));

if (genericType.isGenericType()) {
importTypes.add(Constants.PROVIDER);
genericType.addImports(importTypes);
} else {
genericType.addImports(importTypes);
}
}

Expand Down Expand Up @@ -434,6 +435,21 @@ void writeMethodParamType(Append writer) {
writer.append(Util.shortName(genericType.topType()));
}

void writeMethodParamAspect(Append writer) {
final var type = GenericType.parse(utilType.full());
if (type.isGenericType()) {
type.writeShort(writer);
} else {
writer.append(Util.shortName(type.topType()));
}
writer.append(" ").append(simpleName);
}

void writeMethodParamTypeAspect(Append writer) {
final var type = GenericType.parse(utilType.full());
writer.append(Util.shortName(type.topType()));
}

void writeConstructorInit(Append writer) {
writer.append(simpleName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ String getMethod(boolean nullable) {
return nullable ? "getNullable(" : "get(";
}

public String full() {
return rawType;
}
}