Commit Graph

2272 Commits

Author SHA1 Message Date
Alex Hoppen
72812498d0 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-04-29 20:35:32 +02:00
Alex Hoppen
471841ce7c Only show the Scheduling Indexing progress if no indexing tasks are currently happening
- **Issue**: Since https://github.com/swiftlang/sourcekit-lsp/pull/1973, we are watching for all changes in SourceKit-LSP. This means that we get notified every time the index database is changed. Each of these modifications triggers a new task that waits for build system updates to determine if the modified file needs to be re-indexed. While this task finishes very quickly, it still causes `Scheduling indexing` to replace the `Indexing x / y` in the index status during initial indexing, which looks very noisy.
- **Explanation**: To avoid this flickering, only show `Scheduling indexing` in the index status if we aren’t already indexing any files
- **Scope**: Index progress status
- **Original PR**: This is a significantly reduced version of https://github.com/swiftlang/sourcekit-lsp/pull/2051
- **Risk**: Low, this only changes the precedence of status messages in the indexing status
- **Testing**: Manually verified that we don’t see `Scheduling indexing` appear during initial indexing of a package
- **Reviewer**: @bnbarham
2025-03-10 20:31:25 -07:00
Alex Hoppen
faa2232f2c Retry loading the build description if it fails to write output-file-map.json on Windows
Loading the build description sometimes fails non-deterministically on Windows because it's unable to write `output-file-map.json`, probably due to https://github.com/swiftlang/swift-package-manager/issues/8038.

If this happens, retry loading the build description up to 5 times.
2025-02-25 16:24:09 -08:00
Ben Barham
c065093b5c Add option to skip building and running plugins
This *shouldn't* be needed, but allows running plugins to be skipped if
there's any unexpected interactions with background indexing.

(cherry picked from commit a5343852c6)
2025-02-17 19:17:38 -08:00
Alex Hoppen
655da45347 Hide internal options from SourceKit-LSP configuration file documentation
(cherry picked from commit 4ec669f834)
2025-02-17 19:17:16 -08:00
Ben Barham
7191e16d5c Add a couple missing SwiftPM options
(cherry picked from commit 751eb6181e29b3264a45edb9f2fd143c35b07d4d)
2025-02-17 09:46:13 -08:00
Ben Barham
57d8c45e6e Use the new SwiftPM API to load the build plan
We previously skipped building/running tool plugins here, which meant
that the compiler arguments for a target also missed any generated
sources. Use the new `BuildDescription.load` API from SwiftPM to address
this.

Resolves rdar://102242345.

(cherry picked from commit f525da52529bcc8c3e51985d99f72ae44725de70)
2025-02-17 09:46:13 -08:00
Ben Barham
786f8077d2 Update the compiler arguments used for background AST builds
This fixes two issues:
1. The SwiftPM build system was setup without passing through whether it
   should prepare or not. This meant that we lost eg. the argument to
   allow compiler errors when building the AST (even though it was set
   when building the modules)
2. The compiler argument adjustment to remove harmful and unnecessary
   flags only applied to indexing arguments, not those passed to the AST
   builds

Resolves rdar://141508656.

(cherry picked from commit ab12429651)
2025-02-07 16:31:07 -08:00
Alex Hoppen
c670558138 Fix Windows test failures
(cherry picked from commit 44bd97babe)
2025-01-23 19:59:00 -08:00
Ben Barham
333e950df2 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.

(cherry picked from commit 0c896696c9)
2025-01-23 15:17:48 -08:00
Alex Hoppen
b7fbb47b65 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.

(cherry picked from commit 8617b8bbcc)
2025-01-23 15:17:26 -08:00
Alex Hoppen
351a7814c6 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
(cherry picked from commit 31b1909ce1)
2025-01-23 15:17:14 -08:00
Ben Barham
95f7fc9946 Partially cherry-pick MultiFileTestProject changes
This was a small refactoring in a much larger PR.
2025-01-23 11:43:46 -08:00
Alex Hoppen
9e10ece2eb Remove imports of SwiftPM modules that are not strictly necessary
(cherry picked from commit 718c0ee809)
2025-01-23 11:43:18 -08:00
Alex Hoppen
f8002f72fd Support building SourceKit-LSP without a dependency on SwiftPM
(cherry picked from commit 5326852ea8)
2025-01-23 11:43:10 -08:00
Alex Hoppen
c8f8c1e53d Avoid logging options for a workspace twice
We are already logging the options below.

(cherry picked from commit 760be317bc)
2025-01-23 11:42:59 -08:00
Kabir Oberai
af08a4868e Add cross-compilation regression test
Feedback

More cleanup

Allow skipping canSwiftPMCompileForIOS on CI

Format
2025-01-21 12:02:36 -05:00
Kabir Oberai
d6ae675663 Forward cross-compilation args when indexing 2025-01-21 12:02:33 -05:00
Alex Hoppen
2122cd36eb Revert "Merge pull request #1907 from ahoppen/remove-unused-method"
This reverts commit 991b8933bc, reversing
changes made to c214a5fdb1.
2025-01-08 09:43:54 +01:00
Alex Hoppen
c63ccc24d2 Revert "Merge pull request #1887 from ahoppen/generated-interface-reference-document"
This reverts commit f653ef3255, reversing
changes made to 233f2e6f37.
2025-01-08 09:43:07 +01:00
Alex Hoppen
115068d4f4 Revert "Merge pull request #1901 from rintaro/macros-link-cshims"
This reverts commit 233f2e6f37, reversing
changes made to 320177ff85.
2025-01-08 09:42:31 +01:00
Alex Hoppen
929531e983 Merge remote-tracking branch 'swiftlang/main' into release/6.1 2025-01-08 09:38:42 +01:00
Alex Hoppen
17e2db073c Merge pull request #1909 from ahoppen/cache-container-names
Cache container names in `CheckedIndex`
2025-01-08 09:37:30 +01:00
Alex Hoppen
5b9b53104d Use forEachSymbolOccurrence to find parent container symbol
This improves performance when searching for `only` in SourceKit-LSP by ~30%.
2025-01-06 13:07:35 +01:00
Alex Hoppen
970c5a564f Correctly compute container names for extensions 2025-01-06 12:26:55 +01:00
Alex Hoppen
991b8933bc Merge pull request #1907 from ahoppen/remove-unused-method
Remove `SourceKitLSPServer.openGeneratedInterface`
2025-01-04 09:23:40 +01:00
Alex Hoppen
2a0902bb20 Cache container names in CheckedIndex
It is important that we cache this because we might find a lot of symbols in the same container for eg. workspace symbols (eg. consider many symbols in the same C++ namespace). If we didn't cache this value, then we would need to perform a `primaryDefinitionOrDeclarationOccurrence` lookup for all of these containers, which is expensive.

For example, searching for `only` in SourceKit-LSP’s codebase used to not return results in more than 20s (after which I gave up) and now returns >8000 results in <2s.

rdar://141412138
2025-01-03 16:00:22 +01:00
Alex Hoppen
c214a5fdb1 Merge pull request #1905 from ahoppen/output-mirror
Add option to generate an output mirror file that contains the exact data sent from SourceKit-LSP to the client
2025-01-03 15:11:52 +01:00
Alex Hoppen
2f53e7cf16 Remove SourceKitLSPServer.openGeneratedInterface
The method was never called.
2025-01-03 15:09:40 +01:00
Alex Hoppen
f653ef3255 Merge pull request #1887 from ahoppen/generated-interface-reference-document
Support semantic functionality in generated interfaces if the client supports `getReferenceDocument`
2025-01-03 14:35:01 +01:00
Rintaro Ishizaki
233f2e6f37 Merge pull request #1901 from rintaro/macros-link-cshims
[Test] Link macro binaries to _SwiftSyntaxCShims objects
2025-01-02 15:28:00 -08:00
Alex Hoppen
8d73731bcb Support semantic functionality in generated interfaces if the client supports getReferenceDocument
This allows us to provide semantic functionality inside the generated interfaces, such as hover or jump-to-definition.

rdar://125663597
2025-01-02 20:29:36 +01:00
Alex Hoppen
5330795404 Add option to generate an output mirror file that contains the exact data sent from SourceKit-LSP to the client
This could help us debug low-level issues of SourceKit-LSP to client communication such as https://github.com/swiftlang/sourcekit-lsp/issues/1890.
2025-01-02 19:12:50 +01:00
Alex Hoppen
320177ff85 Merge pull request #1902 from ahoppen/clear-in-progress-on-queue
Clear `inProgressTextDocumentRequests` on `textDocumentTrackingQueue`
2025-01-02 18:40:11 +01:00
Alex Hoppen
3f085600ef Merge pull request #1903 from ahoppen/macro-highlighting
Add semantic highlighting for macros
2025-01-02 18:40:01 +01:00
Alex Hoppen
a30385afa5 Merge pull request #1904 from ahoppen/log-cancellation
Emit a log message when we receive a cancel request notification
2025-01-02 18:39:53 +01:00
Alex Hoppen
7b43383260 Emit a log message when we receive a cancel request notification 2025-01-02 14:17:23 +01:00
Alex Hoppen
4303e44fcb Add semantic highlighting for macros 2025-01-02 13:25:58 +01:00
Alex Hoppen
e59df13bb0 Clear inProgressTextDocumentRequests on textDocumentTrackingQueue
`inProgressTextDocumentRequests` is supposed to only be accessed on `textDocumentTrackingQueue` but we were accessing it outside of that queue. Because of this, we might try to remove requests from `inProgressTextDocumentRequests` before adding them, which would cause them to stay in the list indefinitely.
2025-01-02 13:23:18 +01:00
Alex Hoppen
ede40883f5 Merge pull request #1898 from Kila2/feature/config-build-settings-timeout
feature support override buildSettingsTimeout by workspace config.json
2025-01-02 09:40:20 +01:00
Alex Hoppen
50793f682f Merge pull request #1895 from Kila2/main
fix ASTBuild command exec failed
2025-01-02 09:39:45 +01:00
Rintaro Ishizaki
6e23a8f0df [Test] Link macro binaries to _SwiftSyntaxCShims objects
`_SwiftSyntaxCShims` objects weren't linked because it was a header-only
library. But since actual code is being added, we need to link it.
2025-01-01 10:07:40 -08:00
lijunliang.9819
cf58f14215 feature support override buildSettingsTimeout by workspace config.json 2024-12-23 11:30:18 +08:00
Alex Hoppen
e93b7ed6bf Merge pull request #1849 from kateinoigakukun/katei/json-schema 2024-12-20 10:01:06 +01:00
lijunliang.9819
4987a40359 fix ASTBuild command exec failed 2024-12-20 16:55:18 +08:00
Alex Hoppen
61c3d0c727 Revert "Merge pull request #1886 from ahoppen/sourcekitd-request-diagnostics"
This reverts commit 97711388d0, reversing
changes made to 9a1c75e883.
2024-12-17 16:33:24 +01:00
Alex Hoppen
d8a8e3c312 Merge remote-tracking branch 'swiftlang/main' into release/6.1 2024-12-17 16:32:09 +01:00
Alex Hoppen
1cd010db98 Merge pull request #1888 from ahoppen/indexstore-relative-compdb
Interpret the `-index-store-path` relative to the command’s directory
2024-12-13 23:47:50 +01:00
Alex Hoppen
97711388d0 Merge pull request #1886 from ahoppen/sourcekitd-request-diagnostics
When a sourcekitd diagnostics request fails, show the request error as a diagnostic on the source file
2024-12-13 19:42:05 +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