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

Camilla camillamon at gmail.com
Thu Feb 26 19:07:37 CET 2015


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/spoon-discuss/attachments/20150226/b6ff1e9a/attachment.html>


More information about the Spoon-discuss mailing list