Introduce types for looking up and receiving notifications about changes
to main file mappings (e.g. header.h -> foo.cpp) in terms of documents.
For now this is only exercised in the test, but the goal is to use this
to correctly lookup main files for headers during build system queries.
Request types should always have the suffix Request and notifications
should end with Notification.
Also moved all request and notification types into separate folders to
reduce the number of files in the LanguageServerProtocol folder.
If the client is well-behaved and sends a shutdown request, we close the
index in order to flush it to disk. This should speed up reopening the
same project when it is already indexed.
URL can in fact store URIs, it just doesn't have a very nice API to
interact with them. As long as we only operate on absoluteString, we
should be fine though. So instead of implementing the logic for
detecting file URLs ourselves, we can just use a URL as storage for
DocumentURI.
According to the LSP specification, arbitrary URIs can be used as
document identifiers. Instead of internally assuming that all URIs are
URLs, use a DocumentURI enum to represent URIs. These can either be file
URLs or other URIs whose value as treated as an opaque string.
We will be able to split the LSP modules off later. These LSP modules
will provide the ability to write custom LSP servers and clients in
Swift. The sourcekit-lsp repository will build on top of this new
package to provide an LSP implementation that creates a language server
for Swift and C-based-languages.
This goes through the work of building a swiftpm package, loading the
index, and performing requests against sourcekit-lsp using that package.
This gives us a canary test for our swiftpm support to make sure the
whole thing works together. We don't anticipate adding many tests like
this, since they are relatively slow.
This builds on the indexer changes to support test projects using the
tibs build system. See the commit message from IndexStoreDB for more
information.
This commit adds a couple of simple tests using test fixtures in the
INPUTS directory. It is a fairly minimal change for using the indexer's
test support code to prove the model works. One missing piece here is
support for mutable sources and updating the index, which is supported
on the IndexStoreDB side, but needs a bit more work here. This also
doesn't include any tests using swiftpm's build system.
On macOS since there is an override, both `measure` methods funnel
through one entry point, but on other platforms they are not `open`, so
we need to shadow all of them.
While specifying the build path relative to something might be a useful
idea in principle, we would need a clearer story for how it is specified
and resolved. When passing a path to a command-line argument, it should
be resolved relative to the CWD, not to the package root by default.
Incidentally, it doesn't really make sense to have a global default,
since different build systems are likely to want different defaults. For
now, simplify this configuration to an optional absolute path (passing a
relative path on the command line will resolve relative to the CWD).
Each build system can interpret `nil` as its preferred default.
When running in debug, or in continuous integration that is not setup
for performance testing, default to not collecting performance metrics
to avoid failures due to slow or high-variability tests (default
max_stddev = 10% in xctest). Instead, run the measured block once and
skip the timing code. This has the nice side effect of speeding up test
runs in debug builds.