-
Notifications
You must be signed in to change notification settings - Fork 74
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
File association pattern validation #586
Comments
@rgrunber here a demo with the current work: As you can see in the demo, user can fill the pattern (**/foo2.xml) and if it changes to **/bar.xml, the pattern doesn't match the XML file to bind. This idea of this issue is to validate this file with a custom command on LemMinx side:
|
- Fixes redhat-developer#586 - Declare command "xml.check.file.pattern" to be used on the server side to determine if a given pattern will match any files Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
I just have one general question about this approach. Initially I thought the reason for validation is to confirm that some file in the workspace folder(s) would match the file association pattern when the user is typing it in the wizard, so they don't waste time creating a pattern that matches nothing. Now I see that the language server can only know about files that are opened, since we're not going to be sending every file Uri over for the validation. In fact our language server doesn't make use of the workspace folder setting from initialize and I think it would even break protocol to have it checking the filesystem. So @angelozerr, you suggested to just send over the pattern & uri, and confirm that the pattern would match. Is there any reason we want to force this check to happen on the language server ? Even if other clients would be able to use it, it's a simple pattern check, that they could just as easily implement in their own client's wizard validation logic. If it were a more complicated validation, I would completely agree it should be on the language server side to save time, but I'm just curious about whether we draw any distinction on ease of implementation in deciding whether something gets done on the client, or server side. |
Sorry with my bad explanation. The idea is to write file association for the current file which is bound. We provide a default pattern which works but user can change it (to use * for instance inside file name to check another files that the current). When user change this pattern, the match should continue to work for the current file which is bound.
Yes I think.
The main reason why I would like to this check on server side is that association with xsd/dtd with file association pattern is done on server side. So the check on wizard should be done on server side to share the same checking behavior (TypeScript glob pattern could have a different behavior from Java glob pattern for instance). |
Ok, makes sense. I will make the necessary changes. |
- Fixes redhat-developer#586 - Declare command "xml.check.file.pattern" to be used on the server side to determine if a given pattern will match the given file Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
- Fixes redhat-developer#586 - Declare command "xml.check.file.pattern" to be used on the server side to determine if a given pattern will match the given file Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
- Fixes #586 - Declare command "xml.check.file.pattern" to be used on the server side to determine if a given pattern will match the given file Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
@angelozerr Just curious, why did I need to specify |
It should work without it, no? |
When I tried it, I kept getting |
Related to #573.
When a grammar file is associated with an XML document using
xml.fileAssociations
, we should ensure that the pattern of the XML document file(s) (pattern
field) is valid.For example, when the file association pattern input is accepted:
And the text entry is an invalid pattern, no file association similar to the example below should be entered:
and instead there should be an error thrown with no file association.
The text was updated successfully, but these errors were encountered: