Commit Graph

178 Commits

Author SHA1 Message Date
Alex Hoppen
6746f30ba3 Allow non-file URLs when injecting a build system
There is no reason why we should only support file URLs here.
2025-01-28 10:42:53 -08:00
Alex Hoppen
fc100d24bf Cache the mapping from compiler to toolchain
While at it, also make `Toolchain.path` non-optional and clean up `ToolchainRegistry.init` slightly.
2025-01-25 21:32:44 -08:00
Alex Hoppen
ed098f58cb Merge pull request #1934 from ahoppen/multi-toolchain-support
Support opening documents within the same workspace with sourcekitd/clangd from different toolchains
2025-01-25 08:52:52 -08:00
Alex Hoppen
c67c06e7b1 Merge pull request #1950 from ahoppen/gardening
Gardening
2025-01-24 22:33:51 -08:00
Alex Hoppen
98b1294ad9 Support opening documents within the same workspace with sourcekitd/clangd from different toolchains
rdar://142909783
2025-01-24 22:32:05 -08:00
Alex Hoppen
e9ea204ac2 Merge pull request #1930 from ahoppen/inject-indexstoredb
Add a hook to inject an `IndexStoreDB` instance into `SourceKitLSPServer`
2025-01-24 13:16:19 -08:00
Alex Hoppen
a1716e29ea Merge pull request #1940 from ahoppen/log-module-graph-loading-finish
Add a signposter for SwiftPM package loading
2025-01-24 12:54:09 -08:00
Alex Hoppen
73bf53a953 Merge pull request #1933 from ahoppen/split-compile-commands-build-systems
Split build systems for JSON compilation database and fixed compilation database
2025-01-23 21:25:12 -08:00
Alex Hoppen
64f2aef446 Fix build warnings
Quite a few of these were reminders to clean things up once we no longer need to support testing using compilers and sourcekitd from older toolchains.
2025-01-23 21:11:08 -08:00
Alex Hoppen
6620faed02 Add a signposter for SwiftPM package loading
I saw `testBackgroundIndexingHappensWithLowPriority` hang once. This should help us determine where we are hanging if we see the hang again.

rdar://143303256
2025-01-21 11:48:31 -08:00
Alex Hoppen
e39321fc27 Merge pull request #1923 from kabiroberai/kabir/cross-index
Support background indexing when cross-compiling
2025-01-21 02:23:31 -08:00
Alex Hoppen
15b9670888 Split build systems for JSON compilation database and fixed compilation database
I feel like the implementations are actually simpler if we split them. This will also allow us to add more advanced logic to the JSON compilation database build system in the future, such as inferring the toolchain from the compile command.
2025-01-17 14:38:37 -08:00
Alex Hoppen
44bd97babe Fix Windows test failures 2025-01-17 09:49:52 -08:00
Ben Barham
0c896696c9 Allow workspace options to affect build system search
There were a few places that options only took place *after* determining
a build system, even though we have multiple that impact the search (eg.
`defaultBuildSystem` and `searchPaths`).

Additionally track project root and configuration paths separately, so
that when searching for implicit workspaces we can make sure to skip
creating duplicates.
2025-01-17 08:36:36 -08:00
Alex Hoppen
8cfc4b67f4 Add a hook to inject an IndexStoreDB instance into SourceKitLSPServer
rdar://142907558
2025-01-16 16:34:47 -08:00
Alex Hoppen
b7907b4c5a Merge pull request #1922 from ahoppen/inject-build-system
Allow injection of build systems into `SourceKitLSP`
2025-01-16 14:01:19 -08:00
Alex Hoppen
8d28ed1373 Merge pull request #1919 from ahoppen/output-redirection-sendable
Mark all closures in the `.stream` outputRedirection of TSC as `@Sendable`
2025-01-16 13:35:48 -08:00
Kabir Oberai
b5a97695b6 Forward cross-compilation args when indexing 2025-01-15 21:40:26 -05:00
Alex Hoppen
31b1909ce1 Allow injection of build systems into SourceKitLSP
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
2025-01-15 15:57:21 -08:00
Alex Hoppen
8617b8bbcc Do not realpath the project root of a SwiftPMBuildSystem
If you have a package located at `/pkg` and a symlink at `/symlink` and you open `/symlink` as a workspace, the SwiftPMBuildSystem’s project root would be `/pkg`. This would mean that it also only knew about build settings for files in `/pkg`, not in `/symlink`. Thus, whenever we were opening a file in `/symlink` we would create an implicit workspace to handle it (but which ended up having a project root at `/symlink` again) – or something close to this.

We shouldn’t need to realpath here. If you open `/symlink`, we should view `/symlink` as the project root of your workspace.
2025-01-15 09:54:20 -08:00
Alex Hoppen
7fffc04e50 Mark all closures in the .stream outputRedirection of TSC as @Sendable
The closures aren’t guaranteed to be called on the same thread as the process was launched, which can cause assertion failure by the concurrency runtime.

rdar://142813605
2025-01-15 08:25:25 -08:00
Alex Hoppen
5326852ea8 Support building SourceKit-LSP without a dependency on SwiftPM 2025-01-08 13:13:31 +01:00
Alex Hoppen
718c0ee809 Remove imports of SwiftPM modules that are not strictly necessary 2025-01-08 12:43:43 +01:00
Alex Hoppen
b07044d25d Interpret the -index-store-path relative to the command’s directory
Fixes #1856
rdar://141004197
2024-12-13 18:35:13 +01:00
Alex Hoppen
559f23957e Improve performance of sourceFilesAndDirectories
`SourceFilesAndDirectoriesKey` contained all source files in the project and computing its hash value was pretty expensive. The key didn’t really provide any value here because the only way it changes is if the build targets change and if that’s the case, we already clear `cachedSourceFilesAndDirectories`, so we can just avoid the hash value computation.
2024-12-10 16:26:22 -08:00
Alex Hoppen
7a06eb0ddf Merge pull request #1858 from ahoppen/symlink-target
Fix background indexing behavior if a source file is included in two targets via a symlink
2024-12-10 15:00:46 -08:00
Alex Hoppen
a087692725 Return compiler arguments for invalid package manifests
Currently, when there‘s a syntax error in a package manifest, we don’t get any build settings from it in SourceKit-LSP and thus loose almost all semantic functionality. If we can’t parse the package manifest, fall back to providing build settings by assuming it has the current Swift tools version.

Currently, when there‘s a syntax error in a package manifest, we don’t get any build settings from it in SourceKit-LSP and thus loose almost all semantic functionality. If we can’t parse the package manifest, fall back to providing build settings by assuming it has the current Swift tools version.

Fixes #1704
rdar://136423767
2024-12-09 15:25:38 -08:00
Alex Hoppen
5eb460f148 Fix background indexing behavior if a source file is included in two targets via a symlink
Consider the following scenario: A project has target A containing A.swift an target B containing B.swift. B.swift is a symlink to A.swift. When A.swift is modified, both the dependencies of A and B need to be marked as having an out-of-date preparation status, not just A.
2024-12-09 15:06:39 -08:00
Alex Hoppen
247acf6ae7 Merge pull request #1874 from ahoppen/allow-dependency-updates
Allow dependency updates in the `index-build` folder
2024-12-09 14:31:38 -08:00
Alex Hoppen
881f0f55fa Merge pull request #1873 from ahoppen/swiftpm-child-scopes
Create child scopes for SwiftPM operations
2024-12-09 12:17:02 -08:00
Alex Hoppen
fad3c10033 Merge pull request #1867 from ahoppen/cache-transformed
Cached transformed results in `Cache`
2024-12-06 17:15:12 -08:00
Alex Hoppen
1c1a1cf5f6 Cached transformed results in Cache
The transform to get the transformed result might be expensive, so we should cache its result.
2024-12-06 11:59:25 -08:00
Alex Hoppen
a61bbffdb4 Cache path components for directories returned from build system
We frequently compute if a file is descendent of the directory and `URL.pathComponents` is an expensive computation.
2024-12-06 11:55:00 -08:00
Alex Hoppen
ddbd6543c4 Allow dependency updates in the index-build folder
When we have background indexing enabled, SourceKit-LSP manages the dependencies. We should thus allow it to update them, eg. after `Package.resolved` was updated.
2024-12-06 11:30:02 -08:00
Alex Hoppen
388789472c Create child scopes for SwiftPM operations
Some SwiftPM functions check whether their observability scope has errors. If we use the same observability scope for all SwiftPM operations during SourceKit-LSP’s lifetime, a single SwiftPM error will set the `hasError` bit in that observability scope for the entirety of SourceKit-LSP’s lifetime, impacting all upcoming SwiftPM operations.

Creating a separate child scope for every operation fixes
2024-12-06 11:26:13 -08:00
Alex Hoppen
b42e62f42d Merge pull request #1862 from ahoppen/log-package-reload-trigger
Log which file caused the package to be reloaded
2024-12-06 09:02:36 -08:00
Alex Hoppen
7cc63f58b4 Merge pull request #1861 from ahoppen/log-package-loading
Log package loading messages to the index log
2024-12-06 09:02:27 -08:00
Alex Hoppen
e038c790db Merge pull request #1860 from ahoppen/bsp-server-language
Only load BSP servers that support one of the language we are interested in
2024-12-06 09:02:19 -08:00
Alex Hoppen
9bbb8f3287 Merge pull request #1854 from matthewbastien/documentation-language-service
Handle `*.md` and `*.tutorial` files from Swift DocC
2024-12-05 20:35:23 -08:00
Alex Hoppen
1c9a15eeb0 Log which file caused the package to be reloaded 2024-12-05 20:27:32 -08:00
Alex Hoppen
5914efd9b4 Log package loading messages to the index log 2024-12-05 20:26:50 -08:00
Alex Hoppen
8ea381d7be Only load BSP servers that support one of the language we are interested in
Instead of unconditionally loading any BSP server from one of the search locations, only load those that support, C, C++, Obj-C, Obj-C++ or Swift.
2024-12-05 16:59:07 -08:00
Matthew Bastien
f900b4ef2c Merge pull request #1853 from matthewbastien/include-all-build-target-resources
Include all resources in a build target's sources list
2024-12-05 16:49:06 -05:00
Matthew Bastien
8fd30908e7 handle *.md and *.tutorial files for Swift DocC 2024-12-05 11:18:49 -05:00
Matthew Bastien
f2fed7afa5 reduce code duplication
Co-authored-by: Alex Hoppen <alex@alexhoppen.de>
2024-12-05 10:48:56 -05:00
Matthew Bastien
3ea9a65d77 include all resources in a build target's sources list 2024-12-05 09:53:42 -05:00
Alex Hoppen
3131ca3c81 Merge pull request #1845 from ahoppen/version-specific-manifest
Provide build settings for version-specific package manifests
2024-12-03 14:43:06 -08:00
Alex Hoppen
cddd810455 Provide build settings for version-specific package manifests
Fixes #1670
rdar://136014520
2024-11-22 22:04:20 +01:00
Alex Hoppen
eb982d5b1e Fix quadratic performance issue in AsyncQueue<Serial>
Adding an item to `AsyncQueue` was linear in the number of pending queue items, thus adding n items to an `AsyncQueue` before any can execute is in O(n^2). This decision was made intentionally because the primary use case for `AsyncQueue` was to track pending LSP requests, of which we don’t expect to have too many pending requests at any given time.

While we can't fix the quadratic performance issue in general, we can resolve the quadratic issue of `AsyncQueue<Serial>` by making a new task only depend on the last item in the queue, which then transitively depends on all the previous items. `AsyncQueue<Serial>` are the queues that are most likely to contain many items.

Fixes #1725
rdar://137886469
2024-11-22 15:33:57 +01:00
Alex Hoppen
76304db5e2 Fix merge conflict
https://github.com/swiftlang/sourcekit-lsp/pull/1824 and https://github.com/swiftlang/sourcekit-lsp/pull/1832 raced.
2024-11-19 15:47:52 -08:00