feat: added support for field type descriptor

This commit is contained in:
zaaarf 2023-08-27 09:49:12 +02:00
parent 8f122b540e
commit e07a0ac423
No known key found for this signature in database
GPG key ID: 6445A5CD15E5B40C
3 changed files with 34 additions and 2 deletions

View file

@ -53,7 +53,7 @@ public class TinyV2Mapper extends AbstractMapper {
case 'f': //fields
if(tokens.length == 4)
break;
this.mappings.get(currentClass).addField(tokens[2], tokens[3]);
this.mappings.get(currentClass).addField(tokens[2], tokens[3], tokens[1]);
continue;
}
break;

View file

@ -68,6 +68,16 @@ public class ClassData {
this.fields.put(plain, new FieldData(this, plain, mapped));
}
/**
* Adds a field to the target class.
* @param plain the name of the field
* @param mapped the mapped name of the field
* @param descriptor the plain type descriptor of the field
*/
public void addField(String plain, String mapped, String descriptor) {
this.fields.put(plain, new FieldData(this, plain, mapped, descriptor));
}
/**
* Generates the reverse mappings for this class.
* Should always be called only after the given mapper has finished

View file

@ -21,7 +21,14 @@ public class FieldData {
public final String nameMapped;
/**
* Constructs a new {@link FieldData}.
* The field's type descriptor.
* Some formats may not specify it; if this was created in one such format,
* this is going to be null.
*/
public final String descriptor;
/**
* Constructs a new {@link FieldData} with unspecified descriptor.
* @param parentClass the {@link ClassData} representation of the parent class
* @param name the field name
* @param nameMapped the mapped field name
@ -30,5 +37,20 @@ public class FieldData {
this.parentClass = parentClass;
this.name = name;
this.nameMapped = nameMapped;
this.descriptor = null;
}
/**
* Constructs a new {@link FieldData} with descriptor.
* @param parentClass the {@link ClassData} representation of the parent class
* @param name the field name
* @param nameMapped the mapped field name
* @param descriptor the field's type descriptor
*/
public FieldData(ClassData parentClass, String name, String nameMapped, String descriptor) {
this.parentClass = parentClass;
this.name = name;
this.nameMapped = nameMapped;
this.descriptor = descriptor;
}
}