From 16b203164dcf4cf9ae3ff79b61634dc5d80fbc7e Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 6 Mar 2024 18:01:26 +0100 Subject: Add constructor status --- .../java/moe/nea/zwirn/EnrichSeargeWithMCP.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/main/java/moe/nea/zwirn/EnrichSeargeWithMCP.java') diff --git a/src/main/java/moe/nea/zwirn/EnrichSeargeWithMCP.java b/src/main/java/moe/nea/zwirn/EnrichSeargeWithMCP.java index d91e424..8631e6a 100644 --- a/src/main/java/moe/nea/zwirn/EnrichSeargeWithMCP.java +++ b/src/main/java/moe/nea/zwirn/EnrichSeargeWithMCP.java @@ -6,7 +6,10 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.nio.file.Path; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -19,6 +22,7 @@ public class EnrichSeargeWithMCP { private final Map fieldMap; private final Map> paramMap; private final Map methodMap; + private final Map constructorParamMap; // TODO: parse joined.exc for constructor indexes parameters public EnrichSeargeWithMCP(@NotNull TinyFile searge, Path fields, Path methods, Path params) throws IOException { @@ -29,6 +33,7 @@ public class EnrichSeargeWithMCP { this.fieldMap = this.fields.stream().collect(Collectors.toMap(MCPField::searge, Function.identity())); this.methodMap = this.methods.stream().collect(Collectors.toMap(MCPMethod::searge, Function.identity())); this.paramMap = this.params.stream().filter(it -> it.methodId() != null).collect(Collectors.groupingBy(MCPParam::methodId, Collectors.toList())); + this.constructorParamMap = this.params.stream().collect(Collectors.toMap(MCPParam::searge, Function.identity())); } record MCPParam( @@ -135,21 +140,30 @@ public class EnrichSeargeWithMCP { private TinyMethod mergeMethod(TinyMethod tinyMethod) { var srg = tinyMethod.getMethodNames().get(1); var mcpMethod = methodMap.get(srg); - List params = new ArrayList<>(); + Map params = new HashMap<>(); if (mcpMethod != null) { var mcpParams = paramMap.get(mcpMethod.methodId()); if (mcpParams != null) for (var param : mcpParams) { - params.add(new TinyMethodParameter( + params.put(param.lvIndexHeuristic(), new TinyMethodParameter( param.lvIndexHeuristic(), Arrays.asList("p" + param.lvIndexHeuristic(), param.searge(), param.name()), Arrays.asList() )); } } + for (TinyMethodParameter parameter : tinyMethod.getParameters()) { + MCPParam mcpParam = constructorParamMap.get(parameter.getParameterNames().get(1)); + if (mcpParam != null) + params.put(parameter.getLvIndex(), new TinyMethodParameter( + parameter.getLvIndex(), + Arrays.asList(parameter.getParameterNames().get(0), parameter.getParameterNames().get(1), mcpParam.name()), + parameter.getComments() + )); + } return new TinyMethod( tinyMethod.getMethodDescriptorInFirstNamespace(), Arrays.asList(tinyMethod.getMethodNames().get(0), srg, mcpMethod == null ? srg : mcpMethod.name()), - params, + params.values(), Arrays.asList(), mcpMethod == null ? Arrays.asList() : Arrays.asList(mcpMethod.desc) // TODO: handle empty comment ); -- cgit