-
Notifications
You must be signed in to change notification settings - Fork 72
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
[XML+HTML] Support for autoCloseTags #865
[XML+HTML] Support for autoCloseTags #865
Conversation
I created quickly this PR but my code is very uggly but I would like to know some feedback if it is in the right direction. Here a demo with this PR: I need to sleep the Thread which consumes the custom LSP request closeTag to be sure that didOpen does the update of the document in language server side with the '>'. Please note that HTML have too a custom LSP request which closes tag. Once this PR will be merged I could manage it in the same way. I created NoThreadReconciler which avoid creating a new Thread. |
8ef3c0b
to
5dd8b4e
Compare
...per.xml/src/org/eclipse/wildwebdeveloper/xml/internal/lsp/ClosingTagReconcilingStrategy.java
Outdated
Show resolved
Hide resolved
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.
Please add copyright headers.
If possible, please add a test.
Maybe consider dropping the NoThreadReciler and stick to IReconciler+IDocumentListener?
import org.eclipse.lsp4j.services.LanguageServer; | ||
import org.eclipse.wildwebdeveloper.xml.internal.lsp.AutoCloseTagResponse; | ||
|
||
public interface XMLLanguageServerAPI extends LanguageServer { |
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.
You may call it just LemminxServer
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 keep this name because I use the similar name for HTML. Is it OK for you?
...wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServerAPI.java
Show resolved
Hide resolved
import org.eclipse.jface.text.DocumentEvent; | ||
import org.eclipse.jface.text.ITextViewer; | ||
|
||
public class ClosingTagReconciler extends NoThreadReconciler { |
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.
why not a IReconciler?
...per.xml/src/org/eclipse/wildwebdeveloper/xml/internal/lsp/ClosingTagReconcilingStrategy.java
Outdated
Show resolved
Hide resolved
...per.xml/src/org/eclipse/wildwebdeveloper/xml/internal/lsp/ClosingTagReconcilingStrategy.java
Outdated
Show resolved
Hide resolved
// we receive a text like | ||
// $0</foo> | ||
// $0 should be used for set the cursor. | ||
String text = r.snippet.replace("$0", ""); |
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.
One days, when snippets are usable more widely in LSP, we'll extract the LSCompletionProposal stuff that supports snippets as an API so such extension will be able to support it.
Or maybe the snippets will be generalized in LSP first and we'll be able to get rid of this custom operation before we have need for an API in LSP4E!
CompletableFuture.supplyAsync(() -> { | ||
try { | ||
// Wait for textDocument/didChange | ||
Thread.sleep(100); |
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.
@mickaelistria do you know how I could fix this problem of wait for textDocument/didChange?
5dd8b4e
to
bc11965
Compare
9ef3d59
to
0fbbd1d
Compare
0fbbd1d
to
217c218
Compare
A lot of changes are caused by the renaming of the Messages class and hide that actual changes. Would you mind creating separate commits to isolate the refactoring so we can more easily focus review on what's changed? |
I have not updated this class, perhaps you mean XMLPreferenceConstants -> XMLPreferenceServerConstants ? If it that I could rename to XMLPreferenceConstants again? |
217c218
to
55c7612
Compare
Yes sorry. |
55c7612
to
7e24d6b
Compare
Fixes eclipse-wildwebdeveloper#143 Signed-off-by: azerr <azerr@redhat.com>
Signed-off-by: azerr <azerr@redhat.com>
done with a new commit. |
Please bump versions and add note to RELEASE_NOTES about this addition. |
done |
Including features that were not touched since release need to be bumped as well, and I suspect the version in .product as well. |
Signed-off-by: azerr <azerr@redhat.com>
a7f4ff5
to
d073edf
Compare
It should be fixed. |
Thanks! |
Fixes #143
This PR provides auto close tags for XML and HTML both with UI preferences to enable/disable it.
here a demo with XML:
here a demo with HTML which supports auto close tags and auto insert quote (see in the demo with div/@id attribute, when
=
is typped, the quote are inserted):