apple / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes to a header in a `.systemLibrary` target's sources are not detected

GeorgeLyon opened this issue · comments

I have a package with a .systemLibrary target, and in Sources/MySystemLibraryTarget there is a MySystemLibrary.h header and a module.modulemap (which references the header via header "MySystemLibrary.h"). If I change MySystemLibrary.h, sourcekit-lsp will not pick up the changes until I both clean the build folder and restart sourcekit-lsp (restarting alone is not enough). An easy way to test this is to add an inline function to the header file, then try to call it from Swift. swift build will succeed without any additional effort (same for building/running the tests via VSCode's UI) , but sourcekit-lsp will report "no such function" until the build folder is cleaned and sourcekit-lsp is restarted.

Expected behavior:
Changes are detected by sourcekit-lsp as they occur.

Notes:
While this may sound like a weird use case, I find it very helpful for making a system library I work on work better with Swift. If I can test some functionality just by changing this header, that is preferable to having to change the system library and re-install. Also, in these situations it is often the case that you need to add #include statements as you build out the Swift wrapper for a system library.

Tracked in Apple’s issue tracker as rdar://118263993

Thanks for filing the issue @GeorgeLyon. However, I can’t reproduce it using the following steps:

  1. echo "void systemTest() {}" > /tmp/systemlib/MyLib.h
  2. Unzip package.zip
  3. Open the package in VS Code and build
  4. Open /tmp/systemlib/MyLib.h and add void test2() {} at the end
  5. Call test2 from main.swift
  6. I don’t see any diagnostics about test2 not existing

Could you check if these steps reproduce the issue for you? If not, could you amend them with the steps that I need to take to reproduce the issue?

Hmm just tried on your small project and it does indeed work, though it still fails on my larger project. My guess is that because I'm importing a significant amount of headers it is just really slow to update the index, making it seem like it never updates and resetting the LSP server makes it update quicker. I'll do some more testing and see if I can find the exact issue, but can close this for now.

If you can reproduce this in a project you can share, I would be very interested to hear about it and figure out what’s going on.