diff options
author | zaaarf <zaaarf@proton.me> | 2023-08-26 23:20:06 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-08-26 23:20:06 +0200 |
commit | 6ec42321a36bb44f71ca27a52c774a8dee21ef08 (patch) | |
tree | 88a10ae36e82be9b75e865026c4bdb8d9440f7d7 /src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java | |
parent | 27ff8340f3435459ee21babaceef22f59b7a84f6 (diff) |
feat: heavily reworked api to provide data instead of names
Diffstat (limited to 'src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java')
-rw-r--r-- | src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java b/src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java index 442c204..e47ca38 100644 --- a/src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java +++ b/src/main/java/ftbsc/lll/mapper/impl/SRGMapper.java @@ -6,18 +6,24 @@ import ftbsc.lll.mapper.AbstractMapper; import ftbsc.lll.mapper.IMapper; import ftbsc.lll.mapper.tools.data.ClassData; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * A {@link IMapper} capable of parsing SRG mappings. */ @AutoService(IMapper.class) public class SRGMapper extends AbstractMapper { + /** - * Checks whether this mapper can process the given lines. - * @param lines the lines to read - * @return whether this type of mapper can process these lines + * A {@link Map} tying each obfuscated name to its class data. + * Done this way because SRG files provide mapped descriptors in advance, + * so we can populate this right a way in a less expensive way. */ + private final Map<String, ClassData> mappingsInverted = new HashMap<>(); + + @Override public boolean claim(List<String> lines) { String[] firstLineTokens = lines.get(0).trim().split(" "); @@ -27,13 +33,6 @@ public class SRGMapper extends AbstractMapper { || firstLineTokens[0].equals("FD:")); } - /** - * Populates the {@link IMapper} given the lines, ignoring errors depending on the - * given ignoreErrors flag. - * @param lines the lines to read - * @param ignoreErrors try to ignore errors and keep going - * @throws MalformedMappingsException if an error is encountered and ignoreErrors is false - */ @Override public void populate(List<String> lines, boolean ignoreErrors) throws MalformedMappingsException { for(int i = 0; i < lines.size(); i++) { @@ -85,14 +84,6 @@ public class SRGMapper extends AbstractMapper { } /** - * This does nothing as it is never called for this type of mapper. - * @param lines the lines to read - * @param ignoreErrors try to ignore errors and keep going - */ - @Override - protected void processLines(List<String> lines, boolean ignoreErrors) {} - - /** * Registers a class in the mapper, if it isn't already. * @param name the name * @param nameMapped the mapped name @@ -128,4 +119,17 @@ public class SRGMapper extends AbstractMapper { dataReverse.addMethod(nameMapped, name, descriptorMapped); } } + + @Override + public IMapper getInverted() { + SRGMapper inverted = new SRGMapper(); + inverted.mappings.putAll(this.mappingsInverted); + inverted.mappingsInverted.putAll(this.mappings); //in case some weirdo calls getInverted() twice + return inverted; + } + + @Override + protected AbstractMapper newInstance() { //not really used but whatever + return new SRGMapper(); + } }
\ No newline at end of file |