Skip to content
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

Merged
merged 14 commits into from
Sep 22, 2019

Conversation

nharrand
Copy link
Collaborator

…red to recreate a spoon model

@nharrand
Copy link
Collaborator Author

There are still some issues.
Works on src/test/java/spoon/test/spoonifier/testclasses/ArrayRealVector.java but not on src/test/java/spoon/test/prettyprinter/testclasses/ArrayRealVector.java

@monperrus
Copy link
Collaborator

monperrus commented Sep 17, 2019 via email

@nharrand
Copy link
Collaborator Author

@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?

@monperrus
Copy link
Collaborator

I mean an assertion on the code pretty printed.

@nharrand
Copy link
Collaborator Author

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...

@nharrand nharrand changed the title WiP: feat(SpoonifierVisitor): a visitor that generate the spoon code requi… feat(SpoonifierVisitor): a visitor that generate the spoon code requi… Sep 17, 2019
@nharrand
Copy link
Collaborator Author

nharrand commented Sep 17, 2019

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.)
Example:

@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?

@monperrus
Copy link
Collaborator

Some elements contained might not be in the same order.

yes,

But I meant the generated code sorry!

@nharrand
Copy link
Collaborator Author

nharrand commented Sep 18, 2019

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 (PUBLIC and STATIC) addition))

@monperrus monperrus changed the title feat(SpoonifierVisitor): a visitor that generate the spoon code requi… feat(SpoonifierVisitor): a visitor that generate the spoon code to recreate a spoon model Sep 18, 2019
@monperrus
Copy link
Collaborator

LGTM, will merge.

@nharrand
Copy link
Collaborator Author

@monperrus CI is finally happy!

@monperrus monperrus merged commit 58fdcf8 into INRIA:master Sep 22, 2019
@monperrus
Copy link
Collaborator

Cool, thanks!

@nharrand
Copy link
Collaborator Author

@arnobl Here is the feature we discussed in #3107 . It does not generate super concise code yet, but it is a start!

@monperrus monperrus mentioned this pull request Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants