[Spoon-discuss] Field assignments in class constructors (changes in Spoon API)

Gerard Paligot gerard.paligot at inria.fr
Fri Feb 27 15:25:02 CET 2015


Hi Camilla, 

For your first problem about CtFieldAcces and CtThisAccess, it isn't a bug but an recent improvement in the AST to retrieve all this access in a project. Sorry for your previous works, but Spoon 1.4.2 is out 8 years ago and during this old version and the newest version (3.1), there are a lot of changes. So you should update your previous works. 

For your second problem about stubs of Spoon classes, there isn't a solution for that now. Currently, in tests of Spoon, we build metamodel from snippets too before assertions. But we think about a new project based on annotations to merge test classes and assertions. This project is in the roadmap of spoon here . 

Best regards, 
-- Gérard 

----- Mail original -----

> De: "Camilla" <camillamon at gmail.com>
> À: "This mailing list is used to discuss around Spoon."
> <spoon-discuss at lists.gforge.inria.fr>
> Envoyé: Jeudi 26 Février 2015 19:07:37
> Objet: Re: [Spoon-discuss] Field assignments in class constructors (changes
> in Spoon API)

> Hi Gérard!

> Thank you so much for responding!
> I would also like to unit test my custom classes which use Spoon, but I am
> having some trouble
> creating stubs of Spoon classes, primarily because I am not always sure which
> elements in the source
> code map to which node in the Spoon metamodel.
> Do you have tips on creating test stubs from Spoon interfaces?

> I suppose I could create a repository of code snippets and build the
> metamodel before each test suite, but
> I would rather unit test in isolation.
> Any tips are really appreciated.

> Kind regards,
> Camilla

> 2015-02-25 15:01 GMT+00:00 Gerard Paligot < gerard.paligot at inria.fr > :

> > Hello Camilla,
> 

> > Indeed, there is something strange with Spoon in your problem.
> 

> > I'll develop some tests to confirm it and create an issue if there is
> > really
> > a bug or give you the solution if there is none.
> 

> > I come back to you soon!
> 

> > -- Gérard
> 

> > > De: "Camilla" < camillamon at gmail.com >
> > 
> 
> > > À: "This mailing list is used to discuss around Spoon." <
> > > spoon-discuss at lists.gforge.inria.fr >
> > 
> 
> > > Envoyé: Vendredi 20 Février 2015 17:33:33
> > 
> 
> > > Objet: [Spoon-discuss] Field assignments in class constructors (changes
> > > in
> > > Spoon API)
> > 
> 

> > > Hello Spoon developers!
> > 
> 

> > > I am studying how two different versions of the spoon API deal
> > 
> 
> > > with field assignments in class constructors using the this. keyword.
> > 
> 

> > > For example, I have the following class
> > 
> 

> > > public class ConstructorExample{
> > 
> 

> > > private int i;
> > 
> 
> > > private String hello;
> > 
> 

> > > public ConstructorExample(int i, String hello){
> > 
> 

> > > this.i=i;
> > 
> 
> > > this.hello=hello;
> > 
> 
> > > }
> > 
> 
> > > }
> > 
> 

> > > In spoon 1.4.2, this.i becomes an instance of CtFieldAccessImpl<T> and
> > > calling getTarget() yields another instance of CtFieldAccessImpl<T>.
> > 
> 

> > > In spoon 3.1, however, calling getTarget() on the element of type
> > > CtFieldAccessImpl<T> (representing this.i), returns an instance of
> > > CtThisAccessImpl<T>, instead of CtFieldAccessImpl<T>.
> > 
> 

> > > This breaks some things in a program using Spoon and I am currently
> > > working
> > > on a fix for this.
> > 
> 
> > > I am really curious to know why this change in the API was implemented. I
> > > tried browsing the previous release notes, but could not find information
> > > related to this.
> > 
> 

> > > Kind regards,
> > 
> 
> > > Camilla
> > 
> 

> > > _______________________________________________
> > 
> 
> > > Spoon-discuss mailing list
> > 
> 
> > > Spoon-discuss at lists.gforge.inria.fr
> > 
> 
> > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/spoon-discuss
> > 
> 
> > _______________________________________________
> 
> > Spoon-discuss mailing list
> 
> > Spoon-discuss at lists.gforge.inria.fr
> 
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/spoon-discuss
> 

> _______________________________________________
> Spoon-discuss mailing list
> Spoon-discuss at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/spoon-discuss
-------------- section suivante --------------
Une pi?ce jointe HTML a ?t? nettoy?e...
URL: <http://lists.gforge.inria.fr/pipermail/spoon-discuss/attachments/20150227/961ce5d6/attachment.html>


More information about the Spoon-discuss mailing list