Support for restricting commutativity #33

Merged
wetneb merged 3 commits from wetneb/mergiraf:5-restrict-commutativity into main 2024-11-19 15:24:36 +01:00
Owner

This is one attempt to add support for restricting which types of children are able to commute inside a commutative parent (#5).
For each commutative parent, one can define any number of "children groups", which are lists of children types allowed to commute together.
If no children groups are provided, the current behaviour of letting all children commute remains.

I don't know if this is the right way to specify this. As the failing example demonstrates, this also forbids reordering as soon as there is a comment involved (unless comments are explicitly added in the children groups), which is perhaps a good thing given that we're not able to handle them reliably yet (#26).

@zanbaldwin @keirlawson does this go in the right direction?

This is one attempt to add support for restricting which types of children are able to commute inside a commutative parent (#5). For each commutative parent, one can define any number of "children groups", which are lists of children types allowed to commute together. If no children groups are provided, the current behaviour of letting all children commute remains. I don't know if this is the right way to specify this. As the failing example demonstrates, this also forbids reordering as soon as there is a comment involved (unless comments are explicitly added in the children groups), which is perhaps a good thing given that we're not able to handle them reliably yet (#26). @zanbaldwin @keirlawson does this go in the right direction?
wetneb force-pushed 5-restrict-commutativity from 4c438aae9a to f7cd837693 2024-11-14 22:12:11 +01:00 Compare
@ -213,0 +220,4 @@
ChildrenGroup::new(&["field_declaration"]),
ChildrenGroup::new(&["function_definition"])
],
}
Author
Owner

Here is an example of how it can be used in a language profile.

Here is an example of how it can be used in a language profile.
Contributor

If I'm understanding the examples correctly these groups members have to all be adjacent to each other, this fits the Scala use case well as we might have imports defined lower down in our program that change behavior that we wouldn't want to commute with the traditional imports at the top of the file.

If I'm understanding the examples correctly these groups members have to all be adjacent to each other, this fits the Scala use case well as we might have imports defined lower down in our program that change behavior that we wouldn't want to commute with the traditional imports at the top of the file.
wetneb force-pushed 5-restrict-commutativity from 7c7a9536f7 to 3b85eac4cb 2024-11-19 15:11:28 +01:00 Compare
wetneb changed title from WIP: Support for restricting commutativity to Support for restricting commutativity 2024-11-19 15:22:47 +01:00
Author
Owner

Let's merge this already, for the sake of enabling the feature for other languages. I intend to go through existing languages and review if they would benefit from the feature.

Let's merge this already, for the sake of enabling the feature for other languages. I intend to go through existing languages and review if they would benefit from the feature.
wetneb merged commit 13ad29591b into main 2024-11-19 15:24:36 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#33
No description provided.