Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fusion path intentions #325

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

PRGfx
Copy link
Contributor

@PRGfx PRGfx commented Sep 14, 2024

Adds intentions to work with fusion paths.

Split path at delimiter at caret

foo.<caret>.bar.baz = 'value'

###

foo {
  bar.baz = 'value'
}

Motivation: start with a first deep override and notice that an additional expression in that block is necessary. Breaking the path and wrapping it in braces is somehow super buggy..

Only one block will be created at a time. I was thinking about having some option or multiple intentions to break up either the current or all path segments. Could be improved, if someone has an idea how this should behave.

Merge path up into surrounding block

foo {
  b<caret>ar.baz = 'value'
  qux = 12
}

###

foo {
  qux = 12
}
foo.bar.baz = 'value'

Pretty much the reverse to splitting the path. If the block contains multiple paths, the path at the cursor will be pulled out and added after the block. An empty block will be removed.

Group common fusion paths

renderer.@process<caret>.foo = ${...}
[email protected] = ${...}

###

renderer.@process {
  foo = ${...}
  bar = ${...}
}

Creates a new block for the common prefix (= the path before the caret at a path separator).

Unfortunately still a bit buggy with the amount of whitespace created. Also currently conflicts pretty hard with prototype instanciation (e.g. merge array.key = ... into array = Neos.Fusion:DataStructure) as a new block is created and the original block is removed.
Might be a relatively easy fix to look for a prefix-candidate that already is block candidate.
However in this case I currently create the PSI tree from a string because I couldn't get the newlines to be created at the correct positions.

There could be an argument whether this is the correct trigger for an action like this though: it affects more lines than the current one and I could imagine use-cases where I only want to merge this specific line into an existing block.
It could be possible to "collect" all other paths into a prefix block, however that might not exist.
Also, merging into a block might be a desired behavior of the normal split path intention. But it might be surprising, if it just does that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant