aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-08-26 22:37:47 +0200
committer zaaarf <zaaarf@proton.me>2023-08-26 22:37:47 +0200
commit8e3284a904633b5434104668936be5251e520241 (patch)
tree3963d6787a0f4c4b9d0351b7cd62faed76d184bb
parent3f730c69d3360ae7af030e9e5a4ebd065f8bb05a (diff)
feat: updated to use mapper 0.1
-rw-r--r--build.gradle2
-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
4 files changed, 12 insertions, 31 deletions
diff --git a/build.gradle b/build.gradle
index 5109f86..74794ea 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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 {
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);
}