mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-13 02:29:22 +01:00
doc: improved javadoc
This commit is contained in:
parent
64fa73a583
commit
211142cd59
1 changed files with 20 additions and 10 deletions
|
@ -5,6 +5,7 @@ import ftbsc.lll.IInjector;
|
||||||
import ftbsc.lll.processor.annotations.Injector;
|
import ftbsc.lll.processor.annotations.Injector;
|
||||||
import ftbsc.lll.processor.annotations.Patch;
|
import ftbsc.lll.processor.annotations.Patch;
|
||||||
import ftbsc.lll.tools.DescriptorBuilder;
|
import ftbsc.lll.tools.DescriptorBuilder;
|
||||||
|
import ftbsc.lll.tools.SrgMapper;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
@ -15,14 +16,14 @@ import javax.lang.model.element.Modifier;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.type.ExecutableType;
|
import javax.lang.model.type.ExecutableType;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.util.Elements;
|
|
||||||
import javax.lang.model.util.Types;
|
|
||||||
import javax.tools.Diagnostic;
|
import javax.tools.Diagnostic;
|
||||||
import javax.tools.JavaFileObject;
|
import javax.tools.JavaFileObject;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -31,8 +32,17 @@ import java.util.Set;
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||||
public class LilleroProcessor extends AbstractProcessor {
|
public class LilleroProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
Types types = processingEnv.getTypeUtils();
|
private SrgMapper mapper;
|
||||||
Elements elements = processingEnv.getElementUtils();
|
|
||||||
|
@Override
|
||||||
|
public void init(ProcessingEnvironment processingEnv) {
|
||||||
|
try {
|
||||||
|
mapper = new SrgMapper(Files.lines(Paths.get("build/createMcpToSrg/output.tsrg")));
|
||||||
|
} catch(IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
super.init(processingEnv);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
@ -54,12 +64,12 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO: fancy class object ref in javadoc
|
/**
|
||||||
* This checks whether a given class contains the requirements to be parsed into a Lillero injector.
|
* This checks whether a given class contains the requirements to be parsed into a Lillero injector.
|
||||||
* It must have at least one method annotated with @Target, and one method annotated with @Injector
|
* It must have at least one method annotated with {@link Target}, and one method annotated with {@link Injector}
|
||||||
* that must be public, static and take in a ClassNode and a MethodNode.
|
* that must be public, static and take in a {@link ClassNode} and a {@link MethodNode}.
|
||||||
* @param elem the element to check.
|
* @param elem the element to check.
|
||||||
* @return whether it can be converted into a valid IInjector.
|
* @return whether it can be converted into a valid {@link IInjector}.
|
||||||
*/
|
*/
|
||||||
private boolean isValidInjector(TypeElement elem) {
|
private boolean isValidInjector(TypeElement elem) {
|
||||||
TypeMirror classNodeType = processingEnv.getElementUtils().getTypeElement("org.objectweb.asm.tree.ClassNode").asType();
|
TypeMirror classNodeType = processingEnv.getElementUtils().getTypeElement("org.objectweb.asm.tree.ClassNode").asType();
|
||||||
|
@ -99,7 +109,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSrgName(MethodSpec m) {
|
private String getSrgElementName(MethodSpec m) {
|
||||||
return m.name; //TODO;
|
return m.name; //TODO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +147,7 @@ public class LilleroProcessor extends AbstractProcessor {
|
||||||
MethodSpec methodName = MethodSpec.methodBuilder("methodName")
|
MethodSpec methodName = MethodSpec.methodBuilder("methodName")
|
||||||
.addModifiers(Modifier.PUBLIC)
|
.addModifiers(Modifier.PUBLIC)
|
||||||
.returns(String.class)
|
.returns(String.class)
|
||||||
.addStatement("return $S", getSrgName(targetMethod))
|
.addStatement("return $S", getSrgElementName(targetMethod))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MethodSpec methodDesc = MethodSpec.methodBuilder("methodDesc")
|
MethodSpec methodDesc = MethodSpec.methodBuilder("methodDesc")
|
||||||
|
|
Loading…
Reference in a new issue