We were blocking the initialization response on `self.buildSystemManager.testFiles`, which requires the list of test files to be determined. Make that operation asynchronous so that a slow build server can’t take down all of SourceKit-LSP.
Otherwise, we return the failed diagnostic report even after sourcekitd has been restored.
Also, make sure that we don't show the `semantic editor is disabled` error to users.
Otherwise, the close does not get handled by the SourceKit plugin. In practice, it doesn’t matter too much because the SourceKit plugin will implicitly close the last completion session when a new one is opened but we should fix this.
SourceKit-LSP prepares the currently active file for editor functionality and currently infers the currently active document from whichever received the last `TextDocumentRequest`.
If an editor is capable of doing so, it should be able to report the document that the user currently has focused so that SourceKit-LSP does not have to infer this information from other requests.
Also clean up some handling code for experimental capabilities.
If the build system is sending us with `buildTarget/didChange`, we would always create processor count * 4 new entries in the `indexingQueue` to rescan those files, if they are up-to-date. This can be quite wasteful if the underlying files didn’t actually change. Do a quick scan up-front to check if the files actually need to be re-scanned up-front.
This allows us to clean up the creation of `TestBuildSystem` a little bit because the tests can create `TestBuildSystem` instead of retrieving it from the `BuildSystemManager`.
rdar://142906050
If you have a SwiftPM project at `/projects/myProject` and a symlink pointing from `/myProject` to `/projects/myProject`, we would correctly get build settings etc for the files. But, when getting diagnostics, sourcekitd would return these diagnostics for the full `/projects/myProject` path. We would then decide that those diagnostics didn’t matched the file you opened (inside `/myProject`) and thus suppress them.
Show diagnostics diagnostics if the originated from a file with the same realpath as the file you opened.
Fixes#1910
rdar://142386278
When `\{` is included inside an LSP placeholder, in VS Code will insert `\{` verbatim. At least in VS Code, we only need to escape the closing brace.
While at it, also escape `$` and `\` inside placeholders, according to the LSP spec.
This is more performant. In particular adding a new task to `indexingQueue` for each file to rescan can hit the quadratic issue in `AsyncQueue` if many files were changed.
This resolves <https://github.com/swiftlang/sourcekit-lsp/issues/1788>,
following the discussion of alternatives on
<https://github.com/swiftlang/sourcekit-lsp/pulls/1789>. The bulk of the
change updates the translation from SourceKit placeholders to LSP
placeholders to handle nesting. The `CodeCompletionSession` also passes
a new custom formatter to the swift-syntax expansion routine, which
disables the transformation to trailing closures.