Cleanup
This commit is contained in:
parent
73fdafdfd4
commit
631913cbf9
|
|
@ -53,11 +53,9 @@ public class MixinProcessor extends AbstractProcessor {
|
||||||
@Override
|
@Override
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
if(roundEnv.processingOver()){
|
if(roundEnv.processingOver()){
|
||||||
// set difference of mixins and client
|
filterMixinSets();
|
||||||
List<String> commonSet = mixinConfigList.get("mixins");
|
|
||||||
commonSet.removeAll(mixinConfigList.get("client"));
|
|
||||||
// create record for serialization, compute package name
|
// create record for serialization, compute package name
|
||||||
String packageName = commonSet.get(0).split("(?<=mixin)")[0];
|
String packageName = mixinConfigList.get("mixins").get(0).split("(?<=mixin)")[0];
|
||||||
finalizeMixinConfig();
|
finalizeMixinConfig();
|
||||||
generateMixinConfig(
|
generateMixinConfig(
|
||||||
new MixinConfig(packageName,
|
new MixinConfig(packageName,
|
||||||
|
|
@ -71,6 +69,34 @@ public class MixinProcessor extends AbstractProcessor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processMixins(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
for (TypeElement annotation : annotations) {
|
||||||
|
Set<? extends Element> annotatedMixins = roundEnv.getElementsAnnotatedWith(annotation);
|
||||||
|
|
||||||
|
List<String> mixins = annotatedMixins.stream()
|
||||||
|
.filter(TypeElement.class::isInstance)
|
||||||
|
.map(TypeElement.class::cast)
|
||||||
|
.map(TypeElement::toString)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
mixinConfigList.putIfAbsent(aliases.get(annotation.getSimpleName().toString()), mixins);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filterMixinSets() {
|
||||||
|
// set difference of mixins and client
|
||||||
|
List<String> commonSet = mixinConfigList.get("mixins");
|
||||||
|
commonSet.removeAll(mixinConfigList.get("client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String computeMixinConfigPath() {
|
||||||
|
var projectName = processingEnv.getOptions().get("project.name");
|
||||||
|
return "resources/" +
|
||||||
|
rootProjectName +
|
||||||
|
(projectName != null ? "-" + projectName : "") +
|
||||||
|
".mixins.json";
|
||||||
|
}
|
||||||
|
|
||||||
private void generateMixinConfig(Object config) {
|
private void generateMixinConfig(Object config) {
|
||||||
try (Writer mixinConfigWriter = processingEnv.getFiler()
|
try (Writer mixinConfigWriter = processingEnv.getFiler()
|
||||||
.createResource(StandardLocation.SOURCE_OUTPUT, "", computeMixinConfigPath())
|
.createResource(StandardLocation.SOURCE_OUTPUT, "", computeMixinConfigPath())
|
||||||
|
|
@ -88,32 +114,10 @@ public class MixinProcessor extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String computeMixinConfigPath() {
|
|
||||||
var projectName = processingEnv.getOptions().get("project.name");
|
|
||||||
return "resources/" +
|
|
||||||
rootProjectName +
|
|
||||||
(projectName != null ? "-" + projectName : "") +
|
|
||||||
".mixins.json";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processMixins(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
|
||||||
for (TypeElement annotation : annotations) {
|
|
||||||
Set<? extends Element> annotatedMixins = roundEnv.getElementsAnnotatedWith(annotation);
|
|
||||||
|
|
||||||
List<String> mixins = annotatedMixins.stream()
|
|
||||||
.filter(TypeElement.class::isInstance)
|
|
||||||
.map(TypeElement.class::cast)
|
|
||||||
.map(TypeElement::toString)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
mixinConfigList.putIfAbsent(aliases.get(annotation.getSimpleName().toString()), mixins);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finalizeMixinConfig() {
|
private void finalizeMixinConfig() {
|
||||||
// relativize class names
|
// relativize class names
|
||||||
for(var list : mixinConfigList.values()) {
|
for(var list : mixinConfigList.values()) {
|
||||||
list.replaceAll(className -> className.split("(?<=mixin.)")[1]);
|
list.replaceAll(className -> className.split("(?<=mixin.)")[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user