diff options
Diffstat (limited to 'src/main/java/ftbsc/lll/mapper/impl/TSRGMapper.java')
-rw-r--r-- | src/main/java/ftbsc/lll/mapper/impl/TSRGMapper.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/main/java/ftbsc/lll/mapper/impl/TSRGMapper.java b/src/main/java/ftbsc/lll/mapper/impl/TSRGMapper.java index 838a84d..222fafc 100644 --- a/src/main/java/ftbsc/lll/mapper/impl/TSRGMapper.java +++ b/src/main/java/ftbsc/lll/mapper/impl/TSRGMapper.java @@ -2,20 +2,20 @@ package ftbsc.lll.mapper.impl; import com.google.auto.service.AutoService; import ftbsc.lll.exceptions.MalformedMappingsException; -import ftbsc.lll.mapper.AbstractMapper; -import ftbsc.lll.mapper.IMapper; +import ftbsc.lll.mapper.IMappingFormat; +import ftbsc.lll.mapper.tools.Mapper; import ftbsc.lll.mapper.tools.data.ClassData; import java.util.List; import java.util.regex.Pattern; /** - * A {@link IMapper} capable of parsing TSRG (an intermediary + * A {@link IMappingFormat} capable of parsing TSRG (an intermediary * format used by Forge) files. */ -@AutoService(IMapper.class) -public class TSRGMapper extends AbstractMapper { +@AutoService(IMappingFormat.class) +public class TSRGMapper implements IMappingFormat { @Override public boolean claim(List<String> lines) { @@ -24,7 +24,8 @@ public class TSRGMapper extends AbstractMapper { } @Override - public void populate(List<String> lines, boolean ignoreErrors) throws MalformedMappingsException { + public Mapper getMapper(List<String> lines, boolean ignoreErrors) throws MalformedMappingsException { + Mapper result = new Mapper(); String currentClass = ""; for(int i = 1; i < lines.size(); i++) { //start from 1 to skip header String currentLine = lines.get(i); @@ -32,22 +33,18 @@ public class TSRGMapper extends AbstractMapper { String[] tokens = currentLine.trim().split(" "); if(isMember) { if(tokens.length == 2) //field - this.mappings.get(currentClass).addField(tokens[0], tokens[1]); + result.getClassData(currentClass).addField(tokens[0], tokens[1]); else if(tokens.length == 3)//method - this.mappings.get(currentClass).addMethod(tokens[0], tokens[2], tokens[1]); //add child + result.getClassData(currentClass).addMethod(tokens[0], tokens[2], tokens[1]); //add child else if(!ignoreErrors) throw new MalformedMappingsException(i, "wrong number of space-separated tokens"); } else { if(tokens.length == 2) { ClassData s = new ClassData(tokens[0], tokens[1]); currentClass = s.name; - this.mappings.put(s.name, s); + result.getRawMappings().put(s.name, s); } else if(!ignoreErrors) throw new MalformedMappingsException(i, "wrong number of space-separated tokens"); } } - } - - @Override - protected AbstractMapper newInstance() { - return new TSRGMapper(); + return result; } } |