-
Notifications
You must be signed in to change notification settings - Fork 91
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
Could CloseTagCodeAction offer option to close and result with an empty element. #1544
Comments
The basic idea of close tag action like you have debuged it is to insert the end tag according the fault tolerant parser which set following elements of an element which is not closed as children. You can see that in the outline:
If I understand, you would like to have a new code action which inserts end tag just after the start tag. Are you interested to implement this kind of code action?
Indeed close code action doesn't take care of XSD (in lemminx we call that CMDocument which is an abstract of XSD, DTD, RNG, etc), it could be nice to takes care of XSD. In conclusion I think it could be nice to have:
@scottkurz are you interested to work on it? |
Thank you for your comment and reply. As a start, it's a big help just to hear you confirm I'm understanding this correctly and Lemminx isn't already (supposedly) doing this. I am interested in working on this though I'm not sure exactly when, so I guess we can leave this issue open for now.
Yeah, the last one sounds like to me like a whole other level of complexity, so I would try to start just with 'strategy 2' here. Thx again for your explanation. |
Don't hesitate to ask me if you need some assistance. We have a lot of test with code action, it can be a good start to play with them and write some tests with your future feature. |
Environment
Example Data
With XML (server.xml) like this:
I get a quick fix / code action option to close the webApplication element
</webApplication>
like this:Problem Result
If I click to apply the quick fix the
</webApplication>
gets inserted "at the end", i.e. before the close tag of the parent element (<server>
) containing<webApplication>
.Desired Behavior
In this case, I want to simply close out the start tag and produce an empty element:
<webApplication ... <attrs>.../>
.I don't want to include the other elements as content.
Now, one could argue, if I see the red X and know this is what the problem is, it'd be almost as quick to click the cursor and insert the
/
char myself instead of relying on the tool.But..imagine it's scrolled off the screen. Or, maybe I didn't know what the problem was until I hovered over the quick fix suggestion, and at this point I expect now to be able to resolve the issue with this action (even though I could do it myself with a single char now).
Note on Code
Stepping through in the debugger, it seems like this behavior is controlled by the
CloseTagCodeAction#doCodeActionsForStartTagClosed
method. I don't see that it has logic to perform the behavior I'm describing, but I could be missing something.Note on Extension
The Liberty Tools Lemminx extension works with server.xml, which is governed by an XSD (similar to this. I don't see this CloseTagCodeAction impl taking this into account either, but I mention this fact in case this is somehow relevant but I'm not aware.
The text was updated successfully, but these errors were encountered: