-
-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Spoon metamodel #1183
Comments
To some extent, creating the Spoon of model of
Correct Moving this information elsewhere make it more explicit but is one more level of indirection to understand and maintain. |
I understand what you mean and I agree. I am thinking, how to minimize amount of manually written code and replace it by generated code. May be the spoon sources (even one file) might contain both manually written and generated code. The generated code would be marked (e.g by some comment) and the generator would be allowed to update only such sections. For example the sources file below contains both manually written and generated code: public class CtBreakImpl extends CtStatementImpl implements CtBreak {
private static final long serialVersionUID = 1L;
//begin of code genereated by: ModelGeneratorTemplate#primitiveProperty
String targetLabel;
//end of genereated code
//begin of code genereated by: ModelGeneratorTemplate#visitorPattern_accept
@Override
public void accept(CtVisitor visitor) {
visitor.visitCtBreak(this);
}
//end of genereated code
//begin of code genereated by: ModelGeneratorTemplate#primitiveGetter
@Override
public String getTargetLabel() {
return targetLabel;
}
//end of genereated code
//begin of code genereated by: ModelGeneratorTemplate#primitiveSetter
@Override
public <T extends CtBreak> T setTargetLabel(String targetLabel) {
this.targetLabel = targetLabel;
return (T) this;
}
//end of genereated code
//begin of code genereated by: ModelGeneratorTemplate#clone
@Override
public CtBreak clone() {
return (CtBreak) super.clone();
}
//end of genereated code
} Such sources would allow mixing of manually written code and generated code. The generator must of course assure that manually written code is not lost during update of generated code. |
I am thinking, how to minimize amount of manually written code and replace it by generated code.
Interesting. This is already what we have in Spoon for replacement and equality code.
May be the spoon sources (even one file) might contain both manually written and generated code
This is possible, but I need a longer answer to explain. More on this later.
|
Considered closed per the recent work on annotations for roles. |
Requirements:
Some code in spoon library is generated by generators. Do we have in spoon an metamodel, which can be used as good input for future generators?
Idea: if we would have a good and complete metamodel of spoon model, then this metamodel might be used to generate more sources and to implement issues like #741, #1168 faster.
If I understood it well current spoon generators are using
CtScanner
and annotations on spoon model interfaces as source metamodel. May be we might write a code which scans current spoon sources, mainlyand to automatically build a real - easy to use :-) ... metamodel, which might be then used as input of next generation generators and may be might be even used to update spoon model itself.
... I know, it is quite big task, but may be once ...
The text was updated successfully, but these errors were encountered: