-
-
Notifications
You must be signed in to change notification settings - Fork 196
Description
Hi! We're using DSLDs to add editor support to a Groovy Builder, which looks like this:
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
Line 39 in eef468a
| public Collection<?> matches(GroovyDSLDContext pattern, Object toMatch) { |
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
Line 141 in eef468a
| protected Collection<?> matchOnPointcutArgumentReturnInner( |
the ArrayList is put in a HashSet so duplicates disappear and the ordering gets messed up.
Then again on
Line 52 in eef468a
| 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! :)
