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
Improved parsing of completions with InsertTextFormat.Snippet #844
Improved parsing of completions with InsertTextFormat.Snippet #844
Conversation
I did a similar work for IJ and I created a snippet parser at https://github.com/redhat-developer/intellij-quarkus/blob/main/src/main/java/com/redhat/devtools/intellij/lsp4ij/operations/completion/snippet/LspSnippetParser.java This parser parse characters by characters the snippet syntax and don't use some string substring. IMHO I think this parser should belong to LSP4J. See my comments at eclipse-lsp4j/lsp4j#149 (comment) |
@ChristophKaser Can you please check whether you can reproduce the test failure exposed by https://ci.eclipse.org/lsp4e/job/lsp4e-github/job/PR-844/1/display/redirect locally? |
Yes, I can reproduce it locally. I had missed that test class and only tested against CompleteCompletionTest to save time, sorry. |
c953636
to
f4ef874
Compare
I don't see any test failures any more (the build failure is due to some issue with the version number that I don't really understand). BTW, it seems the test testVariableReplacement is duplicated in CompleteCompletionTest and VariableReplacementTest. |
I wish I had seen that before I implemented the parser from scratch ;) |
This message shows up because this is the 1st change in the bundle since last release, so we can't use 0.15.6 any longer. Can you please bump the version to 0.15.7 in the MANIFEST.MF and pom.xml for the test bundle as part of this PR? |
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.
The version bump do touch the wrong bundles. According to the former build error, only org.eclipse.lsp4e.tests needs to be upversioned.
@@ -2,7 +2,7 @@ Manifest-Version: 1.0 | |||
Bundle-ManifestVersion: 2 | |||
Bundle-Name: Debug Adapter client for Eclipse IDE (Incubation) | |||
Bundle-SymbolicName: org.eclipse.lsp4e.debug;singleton:=true | |||
Bundle-Version: 0.15.4.qualifier |
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.
This one doesn't need to be changed as you didn't modify it. Only the bundles you change needs to be upversioned (if it wasn't already done since last release)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0 | |||
Bundle-ManifestVersion: 2 | |||
Bundle-Name: Language Server Protocol client for Eclipse IDE (Incubation) | |||
Bundle-SymbolicName: org.eclipse.lsp4e;singleton:=true | |||
Bundle-Version: 0.17.3.qualifier |
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.
This one doesn't have to be changed because it was already upversions since last release.
8ababa1
to
10f9173
Compare
Fixes - variables with default values - escaping of special characters like dollar
10f9173
to
8bb79f8
Compare
Sorry, I got mixed up in my changes and the rebase... |
Thanks, it's all good now! |
Hello everyone,
we are making extensive use of completions with InsertTextFormat.Snippet and had some problems with completions that try to insert keys with $ in them, because
\$
was inserted as is.So I tried to improve the parsing of snippets to be closer to the spec (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) and/or closer to what VSCode does.
Since the snippet format is fairly complex, I extracted the parser into its own class, so I could keep the current parser offset in a field.
This PR fixes
${TM_SELECTED_TEXT:defaultval}
}special\$key
)The following complicated parts of the snippet format are not yet implemented:
${TM_FILENAME/(.*)\..+$/$1/}
)${1:Place${2:holder}}
)${TM_SELECTED_TEXT:Place${1:holder}}
)