Commit Graph

158 Commits

Author SHA1 Message Date
Kabir Oberai
d6ae675663 Forward cross-compilation args when indexing 2025-01-21 12:02:33 -05:00
Alex Hoppen
d8a8e3c312 Merge remote-tracking branch 'swiftlang/main' into release/6.1 2024-12-17 16:32:09 +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
c3f97b9080 Revert "Merge pull request #1854 from matthewbastien/documentation-language-service"
This reverts commit 9bbb8f3287, reversing
changes made to 21dfaf0f9c.
2024-12-10 10:33:28 -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
Alex Hoppen
8d13afa73d Merge pull request #1824 from kateinoigakukun/katei/interpret-relative-scratch-dir
Allow `scratchPath` to be a relative path
2024-11-19 11:14:40 -08:00
Yuta Saito
184fa12389 Allow scratchPath to be relative paths
Interpret it as relative to the project root directory if it's a
relative path.
2024-11-19 11:19:54 +09:00
Alex Hoppen
be546308ca Use URL in many cases where we used AbsolutePath
We made quite a few fixes recently to make sure that path handling works correctly using `URL` on Windows. Use `URL` in most places to have a single type that represents file paths instead of sometimes using `AbsolutePath`.

While doing so, also remove usages of `TSCBasic.FileSystem` an `InMemoryFileSystem`. The pattern of using `InMemoryFileSystem` for tests was never consistently used and it was a little confusing that some types took a `FileSystem` parameter while other always assumed to work on the local file system.
2024-11-18 18:19:48 -08:00
Alex Hoppen
b01ae2adb6 Add Task{Start|Progress|Finish}Notification to BuildSystemMessageDependencyTracker 2024-11-15 17:02:53 -08:00
Alex Hoppen
c23b4ff776 Merge pull request #1803 from ahoppen/indexbuild-subfolder
Make `.index-build` a subdirectory of `.build`
2024-11-14 12:54:20 -08:00
Alex Hoppen
9c84a344c8 Merge pull request #1817 from ahoppen/bsp-review 2024-11-14 08:10:02 -08:00
Alex Hoppen
8c2def8ef9 Rename SKSupport to LanguageServerProtocolExtensions 2024-11-13 16:53:58 -08:00
Alex Hoppen
1f33ed484d Split SKUtilities from SKSupport 2024-11-13 16:53:54 -08:00
Alex Hoppen
47f3cd506b Split TSCExtensions into a separate module 2024-11-13 13:58:36 -08:00
Alex Hoppen
0fbb6466e7 Make BuildSystemKind a struct and rename to BuildSystemSpec 2024-11-13 10:23:43 -08:00
Alex Hoppen
c1e090ef33 Address minor review comments 2024-11-13 10:09:31 -08:00
Alex Hoppen
41a773f89a Merge pull request #1804 from ahoppen/remove-unnecessary-fault
Don’t log “Did not compute dependents for target”
2024-11-07 15:38:17 -08:00
Alex Hoppen
5c7d495ebd Merge pull request #1808 from ahoppen/member-import-visibility
Adopt `MemberImportVisibility`
2024-11-07 15:38:05 -08:00
Alex Hoppen
06f58db5c8 Use build/taskStart, build/taskProgress and build/taskFinish to communicate progress from a BSP server to the client
Instead of defining BSP extensions for `window/workDoneProgress/create` and `$/progress`, we should be able to use the standard `build/taskStart`, `build/taskProgress` and `build/taskFinish` messages to the same effect, as suggested by https://forums.swift.org/t/extending-functionality-of-build-server-protocol-with-sourcekit-lsp/74400/9.

Fixes #1783
rdar://138653131
2024-11-06 09:39:09 -08:00
Alex Hoppen
1d7c27bc4b Adopt MemberImportVisibility 2024-11-05 21:04:01 -08:00
Alex Hoppen
69e9a5cf54 Don’t log “Did not compute dependents for target”
Leaf targets don’t have dependents and that’s expected. We shouldn’t log a fault for them.
2024-11-04 15:58:57 -08:00
Alex Hoppen
ec0a7c4ef3 Make .index-build a subdirectory of .build
This means that users of SourceKit-LSP’s background indexing don’t need to add another directory to their `.gitignore`.
2024-11-04 15:34:59 -08:00
Alex Hoppen
5d47358236 Merge pull request #1762 from ahoppen/build-settings-timeout 2024-10-23 23:50:58 -07:00
Alex Hoppen
951e923245 Use withUnsafeFileSystemRepresentation to get the path of a URL on disk
`URL.path` returns forward slashes in the path on Windows (https://github.com/swiftlang/swift-foundation/issues/973) where we expect backslashes. Work around that by defining our own `filePath` property that is backed by `withUnsafeFileSystemRepresentation`, which produces backslashes.

rdar://137963660
2024-10-21 11:12:30 -07:00
Alex Hoppen
5bae73fca8 Use fallback build settings if build system doesn’t provide build settings within a timeout
When we receive build settings after hitting the timeout, we call `fileBuildSettingsChanged` on the delegate, which should cause the document to get re-opened in sourcekitd and diagnostics to get refreshed.

rdar://136332685
Fixes #1693
2024-10-16 10:55:29 -07:00