Validate open .xml files when bounded .xsd files are externally saved #509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: David Kwon [email protected]
Fixes vscode-xml #132.
This PR was tested with this
xml
document:With this
xsd
schema:In the
xsd
file, I simply change themaxOccurs
value from2
to3
and back to2
in a separate editor to test this fix.This PR will register all
xsd
files as watched files, therefore when thexsd
files are saved externally, the client would send thedidChangeWatchedFiles
notification. The server will check through every open xml document and validate if it is bound to the recently savedxsd
file.This check was needed because
document
is null if the document representingdocumentURI
is not opened on the client side. In our case,document
is null when anxsd
that is not currently open in the client, has been modified and saved externally.Note that this PR works whether or not the
xsd
file is currently open in the client. I have only written the unit test for the unopened case. I am more than willing to write one for the opened case if desired.For the unit test, I created this new file. One thing I am not sure about are the two sleep calls here. I added them because it seems like validation for the xml file is being done in a separate thread, and I wanted to wait until the validation was over, so I could read the resulting diagnostics/errors.
Validation for the
xml
document takes place when I calldidOpen()
with the xml document here which returnsvoid
.I did not test this on Windows yet, however a fix for Windows overlaps with #506 .