-
Notifications
You must be signed in to change notification settings - Fork 89
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
Support xsiSchemaLocationSplit setting with experimental formatter #1252
Conversation
...eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/format/DOMAttributeFormatter.java
Outdated
Show resolved
Hide resolved
I believe some of the tests require this setting to get the correct result: Line 175 in 043e5e1
This will prevent the empty content from getting deleted like here: Line 165 in 043e5e1
I can either work on the other setting first or change the test so that it's not dependent on the other setting? |
@JessicaJHee for this kind of formatting you need to do that with an implementation of IformmatingParticipant. I suggest that you see how old formatter uses this participant. You woll need to add or update the signature of the participant to support edits |
@JessicaJHee if you think it is better to work on another settings before doing this pr dont hesîtate to do that |
I didn't use this because I thought for the new formatter, the idea is to avoid using XMLBuilder by adding/removing spaces instead of rewriting the xml content? But if my understanding is wrong, I will try again and use XSIFormatterParticipant/IFormatterParticipant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that formatting as onElement
and then back to onPair
doesn't work.
...eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/format/DOMAttributeFormatter.java
Outdated
Show resolved
Hide resolved
...lipse.lemminx/src/main/java/org/eclipse/lemminx/services/format/XMLFormatterDocumentNew.java
Outdated
Show resolved
Hide resolved
Whoops, just saw Angelo's other comments. My guess is you need to go into With that in place the task just becomes implementing the new method in @angelozerr feel free to correct me if any of this is wrong. |
Indeed @rgrunber it was my idea. the formatter participant could have à New method with edits as parameter. Once experimental formatter will replace the old formatter we will able to remove the method with xmlbuilder. |
Still fixing up a few things before this commit is ready for review! |
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMDocument.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMAttr.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMAttr.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMAttr.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMAttr.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMAttr.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...minx/src/main/java/org/eclipse/lemminx/services/extensions/format/IFormatterParticipant.java
Outdated
Show resolved
Hide resolved
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Show resolved
Hide resolved
5f8f594
to
d574533
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, Jessica!
Wait actually, some of the tests fail on my computer. Can you take a look again and see if anything odd is happening for you? |
Well, it works well for me now. No idea what changed |
...lipse.lemminx/src/main/java/org/eclipse/lemminx/services/format/XMLFormatterDocumentNew.java
Show resolved
Hide resolved
...e.lemminx/src/test/java/org/eclipse/lemminx/extensions/xsi/XSIFormatterExperimentalTest.java
Show resolved
Hide resolved
It seems that the PR requires that splitAttributes is set to true https://github.com/eclipse/lemminx/pull/1252/files#diff-c0186ecdc200d591a9caa3dadf037073d77443cee30423e92600647efbf3fddbR337 You should remove this seetings and it should work without splitAttributes. With the current PR if you remove the line code https://github.com/eclipse/lemminx/pull/1252/files#diff-c0186ecdc200d591a9caa3dadf037073d77443cee30423e92600647efbf3fddbR337 tests fail. |
...e.lemminx/src/test/java/org/eclipse/lemminx/extensions/xsi/XSIFormatterExperimentalTest.java
Outdated
Show resolved
Hide resolved
I already have these three tests for the case where split attribute is set to false:
Is the idea to force split attribute to true when schema location split is set to either onPair or onElement? |
I think you should not have specific test with split attributes to true. The xsi settings (which format the attribute value of xsi:schemaLocation) should be totally independant from splitAttribute (which format attribute name location).
Even if looks like the same behavior, we should distinguish them. SplitAttribute format the attribute name location, although xsi settings is for attribute value of xsi:schemaLocation. |
Why not? If I understand correctly, the behaviour should be different, since you need to indent the schemaLocation entries a different amount. eg. <?xml version="1.0" encoding="UTF-8"?>
<aaa xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://google.ca my-file.xsd
https://stackoverflow.yaml my-other-schema.xsd
https://github.com my-github-schema.xsd">
<bbb> Hello</bbb>
<ccc />
</aaa> If you were to indent to the same level as you would do with splitAttributes: "true", then the entries don't line up. |
Good catch @datho7561. Lets keep tests with Split attributes. But the main tests should be done with no Split attributes. |
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Outdated
Show resolved
Hide resolved
d466a48
to
774ef58
Compare
After playing with the PR, I noticed that it is important to support too https://github.com/redhat-developer/vscode-xml/blob/main/docs/Formatting.md#xmlformatpreserveattributelinebreaks If I think we should have a test with
|
...x/src/main/java/org/eclipse/lemminx/extensions/xsi/participants/XSIFormatterParticipant.java
Show resolved
Hide resolved
...lipse.lemminx/src/main/java/org/eclipse/lemminx/services/format/XMLFormatterDocumentNew.java
Outdated
Show resolved
Hide resolved
...e.lemminx/src/test/java/org/eclipse/lemminx/extensions/xsi/XSIFormatterExperimentalTest.java
Show resolved
Hide resolved
...e.lemminx/src/test/java/org/eclipse/lemminx/extensions/xsi/XSIFormatterExperimentalTest.java
Show resolved
Hide resolved
Signed-off-by: Jessica He <jhe@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works really well. Thanks, Jessica!
Fixes #1246
Signed-off-by: Jessica He jhe@redhat.com