Cleanup
This commit is contained in:
parent
73fdafdfd4
commit
631913cbf9
|
|
@ -53,11 +53,9 @@ public class MixinProcessor extends AbstractProcessor {
|
|||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
if(roundEnv.processingOver()){
|
||||
// set difference of mixins and client
|
||||
List<String> commonSet = mixinConfigList.get("mixins");
|
||||
commonSet.removeAll(mixinConfigList.get("client"));
|
||||
filterMixinSets();
|
||||
// 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();
|
||||
generateMixinConfig(
|
||||
new MixinConfig(packageName,
|
||||
|
|
@ -71,6 +69,34 @@ public class MixinProcessor extends AbstractProcessor {
|
|||
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) {
|
||||
try (Writer mixinConfigWriter = processingEnv.getFiler()
|
||||
.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() {
|
||||
// relativize class names
|
||||
for(var list : mixinConfigList.values()) {
|
||||
list.replaceAll(className -> className.split("(?<=mixin.)")[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user