specs-feup / lara-framework

Tools and APIs to develop weavers for the LARA language (LARA Compiler, LARA Interpreter, Weaver Generator, etc...)
Apache License 2.0
13 stars 2 forks source link

Update Query API to accept wrapper classes as filters #63

Closed lm-sousa closed 4 months ago

lm-sousa commented 6 months ago

Both Query and Selector APIs now accept wrapper classes as filters instead of strings. Method variants that use strings to filter by joinpoint type have been tagged as deprecated and will be removed in the future. Both APIs now report correct type information about their results.

joaobispo commented 5 months ago

If someone wants to do a Query in a programmatic way, where a functions accepts an array of join point types that will be used in consecutive searches, this API will work, as it would currently with the strings?

The question relates to if removing support for strings (which this PR deprecates) reduces current functionality or not.

lm-sousa commented 5 months ago

Short answer? Yes. Searching with the old string API is still supported (but tagged as deprecated and for removal).

In that context, using the new API would be a matter of modifying that function to receive an array of Joinpoint constructors instead of strings. Then, on each iteration of a loop, a constructor would be used. Type inference (and supported filtering) will be limited to things only supported by the base class of the array (in the worst case, only the base Joinpoint). What I mean by this is that, a type error will be thrown if you try to filter by the content of a attribute not shared by all joinpoint types defined in the function arguments.