aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java35
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java3
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java3
3 files changed, 11 insertions, 30 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java b/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java
index de751bc..77d0dad 100644
--- a/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java
+++ b/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java
@@ -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);
diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java
index 0074ebe..9154193 100644
--- a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java
+++ b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java
@@ -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);
}
diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java
index f646a1c..2878ec6 100644
--- a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java
+++ b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java
@@ -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);
}