Skip to content

DSLDs: Wrong ordering on enclosingCallName/enclosingCallDeclaringType pointcut binding #1451

@andvazqu

Description

@andvazqu

Hi! We're using DSLDs to add editor support to a Groovy Builder, which looks like this:

image

Using the following contribution block:

contribute(bind(enclosingCalls:enclosingCallName())) {log "enclosingCallName returns: " + enclosingCalls}

According to the documentation, the enclosingCallName/enclosingCallDeclaringType pointcuts "return all enclosing method name/declaring types as an ordered set. The ordering is from the lexically closest call to the furthest."

However, when invoking code assist at "|" (line 6), we obtain:
enclosingCallName returns: [ApplicationRecordData, elements, smt, ARPackage]
The expected behavior would be:
enclosingCallName returns: [elements, ApplicationRecordData, elements, ARPackage, smt]

The ArrayList in


has the correct ordering.

The problem comes when binding the return value to a named argument (e.g. to pass it to a locally defined pointcut) since on


the ArrayList is put in a HashSet so duplicates disappear and the ordering gets messed up.

Then again on

public BindingSet addToBinding(String name, Collection<?> value) {

this is put in a HashSet, messing the ordering.

Changing those two HashSets to LinkedHashSets fixes the ordering (although the duplicates issue remains). Changing to ArrayLists fixes the issue (although the ordering is from furthest to closest).

All the same applies to enclosingCallDeclaringType.

In our use-case, the contributions depend not only on the name/declaring type of the currentNode (e.g. "elements") but also its direct parent (e.g. "ApplicationRecordData), that's why we use the return value of enclosingCallName and the duplicates and correct ordering are important. Is there maybe some alternative way to obtain the name/declaring type of the direct parent? Thanks! :)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions