Dieser Commit ist enthalten in:
Ursprung
567187ea88
Commit
4f4caac67f
@ -173,18 +173,15 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
|
|
||||||
Map<String, MethodBuilder> methods = new HashMap<>();
|
Map<String, MethodBuilder> methods = new HashMap<>();
|
||||||
for (Map.Entry<Set<String>, List<TypeElement>> entry : groupedByChecks.entrySet()) {
|
for (Map.Entry<Set<String>, List<TypeElement>> entry : groupedByChecks.entrySet()) {
|
||||||
Map<String, Map<LinkageType, List<TypeElement>>> groupedByMethod = new HashMap<>();
|
Map<String, Map<TypeElement, List<LinkageType>>> groupedByMethod = new HashMap<>();
|
||||||
for (TypeElement typeElement : entry.getValue()) {
|
for (TypeElement typeElement : entry.getValue()) {
|
||||||
for (Map.Entry<String, List<LinkageType>> linkages : getLinkagesOfType(typeElement).entrySet()) {
|
for (Map.Entry<String, List<LinkageType>> linkages : getLinkagesOfType(typeElement).entrySet()) {
|
||||||
Map<LinkageType, List<TypeElement>> internalGroup = groupedByMethod.computeIfAbsent(linkages.getKey(), s -> new HashMap<>());
|
groupedByMethod.computeIfAbsent(linkages.getKey(), ignored -> new HashMap<>())
|
||||||
for (LinkageType linkageType : linkages.getValue()) {
|
.put(typeElement, linkages.getValue());
|
||||||
List<TypeElement> list = internalGroup.computeIfAbsent(linkageType, s -> new ArrayList<>());
|
|
||||||
list.add(typeElement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, Map<LinkageType, List<TypeElement>>> group : groupedByMethod.entrySet()) {
|
for (Map.Entry<String, Map<TypeElement, List<LinkageType>>> group : groupedByMethod.entrySet()) {
|
||||||
MethodBuilder method = methods.computeIfAbsent(group.getKey(), s -> {
|
MethodBuilder method = methods.computeIfAbsent(group.getKey(), s -> {
|
||||||
MethodBuilder methodBuilder = new MethodBuilder(s, "void");
|
MethodBuilder methodBuilder = new MethodBuilder(s, "void");
|
||||||
buildPlan.addMethod(methodBuilder);
|
buildPlan.addMethod(methodBuilder);
|
||||||
@ -192,10 +189,17 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!entry.getKey().isEmpty()) method.addLine("if (" + String.join(" && ", entry.getKey()) + ") {");
|
if (!entry.getKey().isEmpty()) method.addLine("if (" + String.join(" && ", entry.getKey()) + ") {");
|
||||||
for (Map.Entry<LinkageType, List<TypeElement>> toGenerate : group.getValue().entrySet()) {
|
for (Map.Entry<TypeElement, List<LinkageType>> toGenerate : group.getValue().entrySet()) {
|
||||||
toGenerate.getValue().forEach(typeElement -> {
|
TypeElement typeElement = toGenerate.getKey();
|
||||||
|
String instance = getElement(typeElement, neededFields);
|
||||||
|
if (toGenerate.getValue().size() > 1 && instance.startsWith("new ")) {
|
||||||
|
method.addLine(typeElement.getSimpleName() + " local" + typeElement.getSimpleName().toString() + " = " + instance + ";");
|
||||||
|
instance = "local" + typeElement.getSimpleName().toString();
|
||||||
|
}
|
||||||
|
String finalInstance = instance;
|
||||||
|
toGenerate.getValue().forEach(linkageType -> {
|
||||||
buildPlan.addImport(typeElement.getQualifiedName().toString());
|
buildPlan.addImport(typeElement.getQualifiedName().toString());
|
||||||
toGenerate.getKey().generateCode(buildPlan, method, getElement(typeElement, neededFields), typeElement);
|
linkageType.generateCode(buildPlan, method, finalInstance, typeElement);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!entry.getKey().isEmpty()) method.addLine("}");
|
if (!entry.getKey().isEmpty()) method.addLine("}");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren