mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-21 21:44:49 +01:00
feat: updated to use mapper 0.1
This commit is contained in:
parent
3f730c69d3
commit
8e3284a904
4 changed files with 12 additions and 31 deletions
|
@ -22,7 +22,7 @@ dependencies {
|
|||
implementation 'com.squareup:javapoet:1.13.0'
|
||||
implementation 'org.ow2.asm:asm-commons:9.5'
|
||||
implementation 'ftbsc:lll:0.4.2'
|
||||
implementation 'ftbsc.lll:mapper:0.0.2'
|
||||
implementation 'ftbsc.lll:mapper:0.1.0'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
package ftbsc.lll.processor.tools;
|
||||
|
||||
import ftbsc.lll.IInjector;
|
||||
import ftbsc.lll.exceptions.InvalidResourceException;
|
||||
import ftbsc.lll.mapper.IMapper;
|
||||
import ftbsc.lll.mapper.MapperProvider;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Class in charge of containing, parsing and processing all processor options,
|
||||
|
@ -63,28 +59,11 @@ public class ProcessorOptions {
|
|||
public ProcessorOptions(ProcessingEnvironment env) {
|
||||
this.env = env;
|
||||
String location = env.getOptions().get("mappingsFile");
|
||||
if(location == null)
|
||||
this.mapper = null;
|
||||
else {
|
||||
InputStream targetStream;
|
||||
try {
|
||||
URI target = new URI(location);
|
||||
targetStream = target.toURL().openStream();
|
||||
} catch(URISyntaxException | IOException e) {
|
||||
//may be a local file path
|
||||
File f = new File(location);
|
||||
if(!f.exists())
|
||||
throw new InvalidResourceException(location);
|
||||
try {
|
||||
targetStream = new FileInputStream(f);
|
||||
} catch(FileNotFoundException ex) {
|
||||
throw new InvalidResourceException(location);
|
||||
}
|
||||
}
|
||||
this.mapper = IMapper.getMappers(new BufferedReader(
|
||||
new InputStreamReader(targetStream, StandardCharsets.UTF_8)).lines().collect(Collectors.toList())
|
||||
).iterator().next(); //TODO: add logic for choosing a specific one
|
||||
}
|
||||
if(location != null) {
|
||||
List<String> lines = MapperProvider.fetchFromLocalOrRemote(location);
|
||||
this.mapper = MapperProvider.getMapper(lines);
|
||||
this.mapper.populate(lines, true);
|
||||
} else this.mapper = null;
|
||||
this.anonymousClassWarning = parseBooleanArg(env.getOptions().get("anonymousClassWarning"), true);
|
||||
this.obfuscateInjectorMetadata = parseBooleanArg(env.getOptions().get("obfuscateInjectorMetadata"), true);
|
||||
this.noServiceProvider = parseBooleanArg(env.getOptions().get("noServiceProvider"), false);
|
||||
|
|
|
@ -74,7 +74,8 @@ public class FieldContainer {
|
|||
this.name = this.elem.getSimpleName().toString();
|
||||
this.descriptor = descriptorFromType(this.elem.asType(), options.env);
|
||||
}
|
||||
this.descriptorObf = options.mapper == null ? this.descriptor : MappingUtils.obfuscateType(Type.getType(this.descriptor), options.mapper).getDescriptor();
|
||||
this.descriptorObf = options.mapper == null ? this.descriptor
|
||||
: MappingUtils.mapType(Type.getType(this.descriptor), options.mapper, false).getDescriptor();
|
||||
this.nameObf = findMemberName(parent.fqn, this.name, null, options.mapper);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ public class MethodContainer {
|
|||
this.name = this.elem.getSimpleName().toString();
|
||||
this.descriptor = descriptorFromExecutableElement(this.elem, options.env);
|
||||
}
|
||||
this.descriptorObf = options.mapper == null ? this.descriptor : MappingUtils.obfuscateMethodDescriptor(this.descriptor, options.mapper);
|
||||
this.descriptorObf = options.mapper == null ? this.descriptor
|
||||
: MappingUtils.mapMethodDescriptor(this.descriptor, options.mapper, false);
|
||||
this.nameObf = findMemberName(parent.fqn, this.name, this.descriptor, options.mapper);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue