Review: refactor: move SpoonMetaModel from src/test to src/main#2016
Review: refactor: move SpoonMetaModel from src/test to src/main#2016monperrus merged 18 commits intoINRIA:masterfrom
Conversation
Yes.
I'm not sure to understand. Which ones?
A static singleton seems fine to me. |
|
@monperrus I need your feedback concerning design. There are several ways how to do it |
|
ping @monperrus |
|
I suggest to move |
3558168 to
ce0ccf9
Compare
OK for me. |
|
Just passed over the PR and pushed my changes (mostly documentation, several renamings, some refactorings). This is super meta, I like it! Two questions:
|
thank you. Me too. It opens new ways how to implement new powerful features in Spoon.
For example: So I would prefer getOwnMethods or getDeclaredMethods. Because getRelatedMethods sounds more like (all) related method, not only these which are delcared directly in current concept and are not inherited from super type |
Just renamed it to getDeclaredMethods. I'm still not sure it should be in this class. Would |
yes, it would be conceptually equivalent. So API can be changed like this, but the data should be stored same - so we assure that it behaves same |
|
By working on getDeclaredMethods, I finally got a solution where all tests pass with method getDeclaredMethods / field ownMethods. Is there something I don't understand? Is there a missing test? |
Probably yes. I don't understand your changes - it cannot work. You changed the meaning of members - there is different values now so it fails.
sure. I did not developed that using "Test driven development" rules, so there was a code needed by other tests, which was not directly tested by MetamodelTest. I will need some time to remember the purpose of own methods, but they are definitely need. I suggest to rollback the changes related to own methods |
|
I suggest to rollback your last commit. We can then discuss the state before that commit and I can explain your questions. But your latest changes are too deep and changed a lot. |
CtScannerTest#testScannerCallsAllProperties is not only a test of scanner but also a test of metamodel. I think you agree that CtScanner contains some unique information about spoon model. So "comparing" the CtScanner and Metamodel types and properties is the only test which can check whether all concepts and properties are as expected. |
|
You're right. I'll rollback. |
ac3c98c to
5cb8998
Compare
|
Worked on it. The goal was to:
This has worked well, but for For handling this, this was the opportunity to simplify two things:
Now all tests pass! OK with this? |
| } | ||
|
|
||
| MMMethod getter = mmField.getMethod(MMMethodKind.GET); | ||
| System.err.println("---"+getter.getSignature()); |
There was a problem hiding this comment.
is it intentional?
|
|
||
| if(getter.getName().equals("getComments") && leafConcept.getModelInterface().isSubtypeOf(ctRefRef)) { | ||
| if(getter.getName().equals("getComments") && leafConcept.getMetamodelInterface().isSubtypeOf(ctRefRef) | ||
| ) { |
There was a problem hiding this comment.
is the new line before that line intentional?
| // contract: CtScanner only calls methods that have a role and the associated getter | ||
| if (calledMethods.size() > 0) { | ||
| problems.add("CtScanner " + visitMethod.getPosition() + " calls unexpected methods: "+calledMethods); | ||
| fail("CtScanner " + visitMethod.getPosition() + " calls unexpected methods: "+calledMethods); |
There was a problem hiding this comment.
why that? A) change all to fail or keep all as problems.add(). WDYT?
| mmConcept.getRoleToProperty().forEach((role, mmField) -> { | ||
| if (mmField.isUnsettable()) { | ||
| //contract: all unsettable fields are derived too | ||
| assertTrue("Unsettable field " + mmField + " must be derived too", mmField.isDerived()); |
There was a problem hiding this comment.
Why did you removed that contract? Is it no more true?
There was a problem hiding this comment.
it was hard to understand and debug.
now the contract is much easier: if the method or one of its ancestor contains the Derived annotation (resp Unsettable) it is derived (resp unsettable)
the test has been adapted accordingly
There was a problem hiding this comment.
These lines was the test you required here #1904
I guess the contract "unsettable implies derived" should be still assert by a test. So I suggest to keep these lines
|
|
||
| RoleHandler rh = RoleHandlerHelper.getRoleHandler(o.getClass(), mmField.getRole()); | ||
| if (mmField.getName().equals("interface")) { | ||
| System.out.println(""); |
There was a problem hiding this comment.
Is it intentional?
There was a problem hiding this comment.
forgot the breakpoint, sorry, removed!
Yes, I like these simplifications. Thank You Martin 👍 |
|
Then, I'll merge after Travis, and you can proceed with rebasing the Pattern branch afterwards. |
3687f91 to
48fe277
Compare
|
The Travis failed on timeout (downloading some dependencies), so I rebased to trigger next build |
|
@surli the travis failed on timeout second time. Any idea? |
|
API changes: 1 (Detected by Revapi) Old API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-20180608.225255-128 / New API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-SNAPSHOT
|
|
@monperrus CI finally passed. It is ready for merge |
The metamodel in runtime is needed by Pattern matcher.
@monperrus I have some questions:
spoon.Metamodel?spoon.metamodel?spoon.Metamodelor ?