Commit Graph

212 Commits

Author SHA1 Message Date
Alex Hoppen
a6fe4848b6 Merge pull request #994 from ahoppen/ahoppen/log-clangd-build-server
Log messages from the build server and clangd
2024-01-08 21:38:28 -08:00
Alex Hoppen
757a029664 Log messages from the build server and clangd
Log messages sent to clangd and the build server in a similar way that we log requests to sourcekitd.

Fixes #886
rdar://116705677
2023-12-12 14:05:25 -08:00
Alex Hoppen
d931806c69 Merge pull request #988 from z2oh/configure-workspace-type
Allow configuring workspace type via flag
2023-12-12 10:50:52 -08:00
Jeremy Day
c31417ac92 Fix formatting 2023-12-11 14:05:04 -08:00
Jeremy Day
3278ff0612 Enable per-workspace configuration of default workspace type 2023-12-08 11:06:11 -08:00
Alex Hoppen
96905aaf16 Add a request to get all tests within a file 2023-12-06 17:40:21 -08:00
Alex Hoppen
33f4612243 Add support for different arguments per workspace
Fixes #663
rdar://101815704
2023-11-28 11:19:09 -08:00
Saleem Abdulrasool
8f53d08b50 build: correct dependencies
The changes in #945 changed the dependencies but did not correct them in
the CMakeLists.txt resulting in a broken build.  Resynchronise the
dependencies across Package.swift and CMake.
2023-11-01 11:12:08 -07:00
Alex Hoppen
ac3eb32e65 Format sources with swift-format 2023-10-31 19:30:31 -07:00
Alex Hoppen
1a23153fd5 When sourcekitd crashes, log the file contents with which it crashed and the request
This should make it a lot easier to reproduce sourcekitd crashes.
2023-10-31 08:30:54 -07:00
Alex Hoppen
6cff70a4b8 Merge pull request #950 from ahoppen/ahoppen/no-main-file-provider-swift
Don't call into the `MainFileProvider` for Swift files
2023-10-30 17:27:36 -07:00
Alex Hoppen
2a51479dea Remove language parameter from BuildSystem.registerForChangeNotifications
The language wasn’t used anywhere.
2023-10-30 13:57:11 -07:00
Alex Hoppen
3c83777dda Merge pull request #948 from ahoppen/ahoppen/cleanup
Two minor improvements
2023-10-30 13:54:43 -07:00
Alex Hoppen
1e32709333 Don't call into the MainFileProvider for Swift files
Swift doesn’t have header and main files. A Swift file is always its own main file. Skip the call into the main file provider.
2023-10-27 14:11:02 -07:00
Alex Hoppen
8d71b317a4 Merge pull request #946 from ahoppen/ahoppen/remove-connection-sendsync
Remove `Connection.sendSync`
2023-10-27 14:04:00 -07:00
Alex Hoppen
57fc1614b8 Merge pull request #942 from ahoppen/ahoppen/log-less-noisy
Make logs less noisy
2023-10-27 14:03:43 -07:00
Alex Hoppen
cd57429a8b Reduce the scope of one task 2023-10-27 13:04:51 -07:00
Alex Hoppen
baa450a602 Remove Connection.sendSync
All callers should call the async version `Connection.send`.
2023-10-27 10:42:00 -07:00
Alex Hoppen
182deb75bb Merge pull request #932 from ahoppen/ahoppen/log-build-settings-once
Only log build settings once unless they change
2023-10-27 09:48:51 -07:00
Alex Hoppen
8286113fef Set the build system to nil if no compilation database can be loaded
When we couldn’t start a build server or find a SwiftPM package, we currently always create a `CompilationDatabaseBuildSystem`, even if no `compile_commands.json` or `compile_flags.txt` exits. Every request for build settings would then log an error that the compilation database can’t be opened, which was very spammy. Instead, if the compilation database can’t be loaded, just set the build system to `nil` and log a single error message.
2023-10-27 09:45:34 -07:00
Alex Hoppen
9abcd2a3a3 Remove the Notification type
`Notification` is just a wrapper around `NotificationType` and there’s no reason for it to exist anymore.

Resolves #880
rdar://116705670
2023-10-26 18:28:10 -07:00
Alex Hoppen
4e0e12c14c Only log build settings once unless they change
This makes the logs a lot less spammy.
2023-10-26 14:10:57 -07:00
Alex Hoppen
83519eae21 Merge pull request #917 from joehsieh/migrate-queue-to-actor 2023-10-24 17:18:01 -07:00
joehsieh
ea445cb9e2 Convert ManualMainFilesProvider to be an actor
Refactor the code

Remove unused code

Refine the code
2023-10-25 01:30:27 +09:00
Alex Hoppen
645b5110e9 Merge pull request #915 from GeorgeLyon/dev/george/compilation-db-search-paths 2023-10-23 21:03:59 -07:00
George
170b44bb05 Add support for compile databases not at the root of the workspace 2023-10-21 05:17:01 +00:00
joehsieh
98ba3ee7d8 Remove isFallback from func buildSettings for FallbackBuildSystem 2023-10-20 10:04:18 +09:00
Alex Hoppen
f7735bd276 Log the request handling duration 2023-10-18 21:46:55 -07:00
Alex Hoppen
a503e1b61f Log build settings over multiple log messages 2023-10-18 21:46:55 -07:00
Alex Hoppen
1458d06937 Add more fine grained dependency tracking to AsyncQueue
Instead of just having barriers and non-barriers, this allows `AsyncQueue` to track dependencies between tasks at a more fine-grained level.

For example, we can now specify that requests that affect one document only depend on edits to that same document and are not blocked by edits to any other document. As a consequence, a busy `sourcekitd` will not block requests from `clangd` to be executed and vice versa.

Resolves #875
rdar://116705652
2023-10-16 17:36:53 -07:00
Alex Hoppen
f960d7ed9b Change logging to use OSLog
OSLog is the suggesting logging solution on Apple platforms and we should be using it there, taking advantage of the different log levels and privacy masking.

Switch sourcekit-lsp to use OSLog on Apple platforms and implement a logger that is API-compatible with OSLog for all uses in sourcekit-lsp and which can be used on non-Darwin platforms.

The goal of this commit is to introduce the new logging API. There are still improvements about what we log and we can display more privacy-insensitive information after masking. Those changes will be in follow-up commits.
2023-10-13 13:46:32 -07:00
Alex Hoppen
d0fc00ce98 Format using swift-format
Add `.swift-format` to the repo and format the repo with `swift-format`.

This commit does not add any automation to enforce formatting of sourcekit-lsp in CI. The goal of this commit is to get the majority of source changes out of the way so that the diff of actually enforcing formatting will have fewer changes or conflicts.
2023-10-10 13:44:47 -07:00
Alex Hoppen
32acbf52fd Remove FileBuildSettingsChange
This type wasn’t used anymore.
2023-10-06 18:07:20 -07:00
Alex Hoppen
16c3ae17c2 Remove functions that were never called 2023-10-06 18:07:20 -07:00
Alex Hoppen
d9da113ca7 Remove BuildServerBuildSystem.requestQueue
The queue isn’t used anymore.
2023-10-06 18:07:20 -07:00
Alex Hoppen
4495256b35 Remove the queue parameter from Connection.send
We don’t actually care about the queue that we receive the reply on anymore since we migrated everything™ to actors/async/await.
2023-10-06 18:07:20 -07:00
Alex Hoppen
0cccd3b443 Refactor the computation of main files
The motivating change for this was to deterministically pick a main file for a header file instead of picking the first element in a set, which is not deterministic.

While doing this, I also changed the main file computation to not carry any state about previous main files around. If a header file is associated with a main file b.cpp and a new a.cpp gets added that imports the header as well, we should be using a.cpp for the build settings. That way we will get the same build settings if we close and re-open the project.

And this was a good opportunity to refactor some of the main file handling into smaller, more dedicated functions.
2023-10-03 08:06:08 -07:00
Alex Hoppen
453ebfb2b3 Make FallbackBuildSystem not conform to BuildSystem and remove no-op functions from it 2023-10-03 08:02:56 -07:00
Alex Hoppen
d6101a1c56 Merge pull request #848 from ahoppen/ahoppen/minor-cleanups
Fix a couple `FIXME: (async)`
2023-10-03 07:59:50 -07:00
Alex Hoppen
1f02b95e55 Shift responsibility for in-order message handling from Connection to SourceKitServer
This generally seems like the cleaner design because `SourceKitServer` is actually able to semantically inspect the message and decide whether it can be handled concurrently with other requests.
2023-10-03 07:56:49 -07:00
Alex Hoppen
7f4e10e6d2 Asyncify MainFilesDelegate 2023-10-02 17:00:04 -07:00
Alex Hoppen
eb597fd0a7 Remove a couple of async wrapper functions
These are no longer needed as all callers are async now.
2023-10-02 17:00:04 -07:00
Alex Hoppen
c642b37a96 Remove tracking of file build settings status in SourceKitServer and BuildSystemManager
The core idea here is that the toolchain language servers always call into `BuildSystemManager` and `BuildSystemManager` will always reply with build settings. If it hasn’t computed them yet, it will reply with fallback settings.

With that assumption, we can remove the `documentToPendingQueue` from `SourceKitServer` since there are no longer any documents that are pending – everything has a build settings immediately.

Similarly, `BuildSystemManager.mainFileStatuses` also isn’t needed anymore.

And lastly, since we know that `BuildSystemManager.buildSettings` will always return a value `registerForChangeNotifications` is changed not call `fileBuildSettingsChanged` immediately. Instead, it will only cause `fileBuildSettingsChanged` to be called when the file’s build settings change after the `registerForChangeNotifications` call.
2023-10-02 09:53:25 -07:00
Alex Hoppen
dffcc939f7 Change the build system to only notify delegate about changed files, not about new build settings
This defines away an entire class of data races if delegate callbacks are delivered out-of-order. If we aren’t providing the new build settings in the delegate callback, then it doesn’t matter if two `fileBuildSettingsChanged` calls change order since they don’t carry any state.
2023-10-02 09:53:25 -07:00
Alex Hoppen
93dfc3dfbf Get the build settings of the main file for a given header in BuildSystemManager 2023-10-02 09:53:25 -07:00
Alex Hoppen
bf867eced6 Call into the BuildSystemManager from BSMDelegate in BuildSystemManagerTests to get build settings 2023-10-02 09:53:25 -07:00
Alex Hoppen
5335acaae7 Migrate BuildServerBuildSystem to an actor and make methods in BuildSystemDelegate async
This concludes the migration of the build systems to async.
2023-10-02 09:47:33 -07:00
Alex Hoppen
2c76561085 Migrate CompilationDatabaseBuildSystem to be an actor 2023-10-02 09:47:28 -07:00
Alex Hoppen
54e6d958d6 Make all methods on BuildSystem async
This is the prerequisite for making the build systems actors.
2023-10-02 09:47:21 -07:00
Alex Hoppen
443fc7a776 Make BuildSystemManager an actor
Again, fairly straightforward.
2023-10-02 09:47:17 -07:00