vineflower
vineflower copied to clipboard
Allow plugins to modify default QF output (Adding annotations, lombok support)
The original title of this issue was Auto Lombok, which is why the description may not match.
The generated code could potentially look quite a lot cleaner if Lombok annotations were used where possible.
Since this could obviously lead to issues, and not everyone will want this, a flag would be needed.
Example:
public class Animal {
private int age;
public Animal(int age) {
this.age = age;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
Could be decompiled as:
@AllArgsConstructor
public class Animal {
@Getter
@Setter
private int age;
}
This could also make longer classes more readable. Another useful feature would be annotating methods with illegal throws with @SneakyThrows, assuming that is what the original developer used, therefore removing some compilation errors, and making the code (possibly) more accurate.
Of course, you don't want to get too generous. AllArgsConstructor should only be used when the constructor only sets all of the applicable fields in the class, and annotations should generally only be used when the behaviour and access modifiers are completely unchanged.
This relates to #122 - external framework support and non-pure-java would be better as plugins (ideally including IntelliJ @NotNull support)
I agree. This will not be a first party feature, but we want to make code simplification and such like this possible through plugins, once that system matures.
I feel like the new issue title makes it sound too similar to #122 - maybe Annotation Processor Plugins or something?
Also, sorry for the email that you will have received now, SneakyThrows (when will I learn).
Since annotation processing is a subset of modifying the default code output, it still works here- the issues mainly help organize what we prioritize working on, so it still works 😛
Okay, sure
Still, I feel like maybe this issue should have something in the title about annotations, since I feel like output is the main part of plugins, but it's whatever helps development most, I guess.