-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
feat(SpoonifierVisitor): a visitor that generate the spoon code to recreate a spoon model #3105
Conversation
…red to recreate a spoon model
There are still some issues. |
Really cool. What about adding an assertEquals(code, spoonify(elem)) so that we have a feeling of
the generated code?
|
@monperrus Do you mean an assertion on the element itself like in src/test/java/spoon/test/spoonifier/SpoonifierTest.java:81 ? or do you mean an assertion on the code pretty printed? |
I mean an assertion on the code pretty printed. |
I was about to say that assertEquals on elements should be stronger then on the prettyprinted code, and that obviously two elements that are equal should be printed identically by construction. But of course I have tried... |
Ok it does not necessarily leads to the same pretty printing. If I understand correctly, one of the issue is containers that are map. Some elements contained might not be in the same order. (But the order does not carry semantic in this case.) @spoon.test.annotation.testclasses.AnnotParamTypes(
integer = 42,
integers = { 42 },
string = "Hello World!",
strings = { "Hello", "World" },
clazz = java.lang.Integer.class,
classes = { java.lang.Integer.class, java.lang.String.class },
b = true,
byt = 42,
c = 'c',
s = ((short) (42)),
l = 42,
f = 3.14F,
d = 3.14159,
e = AnnotParamTypeEnum.G,
ia = @InnerAnnot("dd")
) becomes: @spoon.test.annotation.testclasses.AnnotParamTypes(
strings = { "Hello", "World" },
string = "Hello World!",
s = ((short) (42)),
l = 42,
integers = { 42 },
integer = 42,
ia = @InnerAnnot("dd"),
f = 3.14F,
e = AnnotParamTypeEnum.G,
d = 3.14159,
clazz = java.lang.Integer.class,
classes = { java.lang.Integer.class, java.lang.String.class },
c = 'c', byt = 42,
b = true
) I am not sure if we want to fix this, as I am not sure it is a problem. WDYT? |
yes, But I meant the generated code sorry! |
Ok I have added one. (I am not completely sure that the order is deterministic though. I just obtained different result by running it inside and outside of my debugger. (The issue was on the order of modifiers ( |
LGTM, will merge. |
@monperrus CI is finally happy! |
Cool, thanks! |
…red to recreate a spoon model