This topic is a continuation of a discussion that I believe may be interesting for everyone (original discussion: https://github.com/apple/sourcekit-lsp/pull/69)
We have ideas about making it possible to use index data for more things, but I don't foresee this completely replacing live ASTs.
mind to share the ideas?
the fact that we trigger dependency resolution right now is a bug. When I first implemented this, there was no way to opt-out of that resolution, but @Aciid said he'd be fine with us adding a way to opt out. Just haven't got to this yet.
Let's assume dependency resolution is disabled as requested... what left? everything depends on it. Is "opt-out" still a way to go? please elaborate.
To summarize discussion:
- SPM has to resolve dependencies to generate a llbuild manifest (it's up to SPM, not up to a server to initiate this task)
- server wants to reuse llbuild manifest (
sourcekitdand index generation.
- llbuild manifest could be generated by SPM, without triggering an actual build afterward (requires SPM modification(?)) - SPM build manifest generation is not part of libSwiftPM, hence either spawn spm binary with e.g.
--disable-build, or expose this part in SwiftPM and use it - (requires SPM modification). In theory, there is
LLBuildManifestGeneratorthat should be able to generate manifest, but there seems to be more logic in SPM.
- Indexer job continuously updates the index as files are modified (bear in mind that an LSP is aware of the changes that are not yet saved to the underlying storage - I'd say most of the time changes are not yet saved, but it is expected to have modification already in the index)
Now interaction with manual calls (initiated by the user) to SPM is more tricky:
- Does SPM have any mechanism to prevent simultaneous builds? I see
llbuilddoes have some:
don't see anything obvious in spm though. Checking for "build.db" lock feels a bit hacky.
<unknown>:0: error: unable to attach DB: error: accessing build database "/Users/marcinkrzyzanowski/Devel/swift-source/sourcekit-lsp/.build/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location. error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/marcinkrzyzanowski/Devel/swift-source/sourcekit-lsp/.build/debug.yaml main output:
- SPM may use a custom build directory that won't be shared with the server.
- Server indexer should update on each llbuild manifest change - custom build parameters may appear as a result of manual build command.
- A toolchain version used to generate dependencies (swiftmodules) and an indexer toolchain has to be aligned, otherwise, it won't work (will it?)
did I miss anything? thoughts?