eclipse / Xpect

This repository has been rewritten to move to the Eclipse Foundation. Find the old history here: https://github.com/TypeFox/Xpect
http://www.xpect-tests.org/
Eclipse Public License 2.0
32 stars 28 forks source link

Support parameter provider taking offset AND length into account #129

Open JensN4 opened 10 years ago

JensN4 commented 10 years ago

In some cases I want to write an Xpect test for a AST element identified by an OFFSET parameter. E.g.,

// XPECT mytest at 'location in my code' --> ... location in my code

However, the current implementation of the OFFSET parameter (provider) only takes the offset into account. That is, in the example above, the two tests

// XPECT mytest at 'location in my code' --> ... and // XPECT mytest at 'location' --> ...

will test the same object. It would be useful to take the length of the offset parameter into account as well, in order to be able to distinguish between these two cases. This would makes these tests much more useable, e.g., in case of expressions.

JensN4 commented 10 years ago

Actually, I have written a full solution to that problem and I could provide the code.Unfortunately I cannot attach anything here.

It consists of an XtextOffsetAdapter subclass, adapting a "EObjectCoveringRegionProvider", which almost works like a MatchingOffsetProvider except that it takes the region into account (and thus traverses the node tree upwards in order to find a node which covers the whole region.

Moritz, if you're interested in that, just sent me an email.

meysholdt commented 10 years ago

Hi Jens,

sure, can you email me the files? moritz at eysholdt dot de