Commit Graph

1827 Commits

Author SHA1 Message Date
Finagolfin
1cf6c76897 Import new Bionic module from Android overlay instead where possible 2024-07-08 19:08:07 +05:30
Alex Hoppen
158bed8d85 Merge pull request #1550 from finagolfin/droid
Import new Android overlay
2024-07-04 14:57:16 +02:00
Alex Hoppen
8695c0ccf5 Merge pull request #1549 from plemarquand/fix-module-name-precedence
Respect module name argument order precedence
2024-07-04 14:56:53 +02:00
Louis Qian
3be034233b fix: SwiftLanguageService instead of ClangLanguageService
fix!: remove `documentManager` property

fix!: remove `documentManager` in constructor

fix: added documentManager as a computed Property

fix: remove old documentmanager resetting step

fix!: get throws instead of crashing server

fix: throw ResponseError instead of NSError

fix: adding try & orLog where necesary

fix: refined orLog usage

style: ran swift-format

fix: document being opened twice

fix(DocumentManager): remove unwanted comments

lint: ran swift format
2024-07-03 23:48:49 -05:00
Finagolfin
7c20015331 Import new Android overlay 2024-07-04 02:20:23 +05:30
Paul LeMarquand
c753169434 Respect module name argument order precedence
When the same flag is specified multiple times the last one found is
used.
2024-07-03 10:06:31 -04:00
Lokesh T R
0221475b70 Implement PeekDocumentsRequest and update ShowDocumentRequest.
-------------------------------------------------------------------------------

This implements an LSP Extension `PeekDocumentsRequest` to let `ExpandMacroCommand` to open the macro expansions in a "peeked" editor window.
For this to work, the client has to pass "workspace/peekDocuments" enabled to `ClientCapabilities.experimental` and the client should handle the `PeekDocumentsRequest` and show the expansions in a "peeked" editor window.

PR to support the above capability in the "Swift for VS Code" Extension: https://github.com/swiftlang/vscode-swift/pull/945
The "Swift for VS Code" extension cannot send the client capability, so it instead passes the same through `initializationOptions` in the `InitializeRequest`.

For editors which doesn't support this capability, `sourcekit-lsp` sends a `ShowDocumentRequest`.
The `ShowDocumentRequest` is updated to show all the macro expansions in a single generated file. Moreover, its folder structure is updated to use hex string of MD5 hash of concatenation of buffer names of expansions.

Fixes https://github.com/swiftlang/vscode-swift/issues/564
Fixes https://github.com/swiftlang/sourcekit-lsp/issues/1498 ( rdar://130207754 )
2024-07-03 15:32:40 +05:30
Lokesh T R
9fb3d0e417 Add LSP support for showing @attached Macro Expansions 2024-07-03 15:32:40 +05:30
Alex Hoppen
ef2dc17806 Merge pull request #1543 from ahoppen/time-out-sourcekitd
Add a maximum duration for sourcekitd requests
2024-07-03 01:48:37 +02:00
Alex Hoppen
191d366a2c Add a maximum duration for sourcekitd requests
VS Code does not cancel semantic tokens requests. If a source file gets into a state where an AST build takes very long, this can cause us to wait for the semantic tokens from sourcekitd for a few minutes, effectively blocking all other semantic functionality in that file.

To circumvent this problem (or any other problem where an editor might not be cancelling requests they are no longer interested in) add a maximum request duration for SourceKitD requests, defaulting to 2 minutes.

rdar://130948453
2024-07-02 22:47:27 +02:00
Alex Hoppen
83cb1625f4 Merge pull request #1544 from ahoppen/function-output-together
Set `prioritizeKeepingFunctionOutputTogether` in `.swift-format`
2024-07-02 22:46:24 +02:00
Alex Hoppen
91c55f9fcb Merge pull request #1532 from AppAppWorks/remove-OpenGeneratedInterfaceRequest
removed OpenGeneratedInterfaceRequest
2024-07-02 13:31:40 +02:00
Alex Hoppen
f4ea614be6 Set prioritizeKeepingFunctionOutputTogether in .swift-format 2024-07-02 11:06:35 +02:00
Alex Hoppen
5784bf87e5 Merge pull request #1538 from ahoppen/skip-wasm-test
Skip `testWasm` if the host toolchain can’t build for WASM
2024-07-02 06:57:43 +02:00
Kai Lau
eb6f919b5e removed OpenGeneratedInterfaceRequest
deleted OpenInterfaceRequest.swift and moved GeneratedInterfaceDetails to LanguageService.swift
replaced usages by passing its members as parameters directly, refactored usage of TextDocumentIdentifier to DocumentURI
removed from Messages.builtinRequests
removed from SwiftInterfaceTests
removed from Documentation/`LSP Extensions.md`
removed from Sources/LanguageServerProtocol/CMakeLists.txt
2024-07-01 15:14:44 -07:00
Alex Hoppen
1efb2677ea Merge pull request #1530 from plemarquand/prefix-module-name-to-test-id
Prepend module name to TestItem IDs
2024-07-01 21:31:47 +02:00
Paul LeMarquand
c49d6a997c Revert TestStyle enum changes 2024-07-01 09:31:00 -04:00
Alex Hoppen
ab67a7e8ca Skip testWasm if the host toolchain can’t build for WASM
This fixes a test failure when running tests using Xcode 15.4.
2024-06-28 23:25:41 +02:00
Alex Hoppen
c6b82a7556 Fix a compilation issue caused by #1533 and #1524 racing 2024-06-28 22:54:52 +02:00
Alex Hoppen
16e4f83ec3 Merge pull request #1534 from ahoppen/configuration-improvements
Allow specification of SourceKitLSPOptions in the initialize request and look for SourceKit-LSP options in `$XDG_CONFIG_HOME/sourcekit-lsp`
2024-06-28 22:18:45 +02:00
Alex Hoppen
6b88cfe294 Merge pull request #1533 from ahoppen/background-indexing-configuration-option
Make background indexing a proper option in `SourceKitLSPOptions`
2024-06-28 22:14:19 +02:00
Paul LeMarquand
14b81cfe6c Fixup DocumentTestDiscoveryTests, make TestStyle an enum 2024-06-28 14:42:00 -04:00
Paul LeMarquand
bc86ff8e6a Address comments 2024-06-28 12:45:14 -04:00
Paul LeMarquand
f7a831ba36 Parse module name for obj-c targets
Parse the obj-c module name for targets by looking at the `-fmodule-name`
flag.
2024-06-28 09:38:59 -04:00
Alex Hoppen
bfe1a24110 Support using SourceKit-LSP for projects that are cross-compiled
We previously always assumed that the project was being built for the host.

Fixes #786
Fixes #1475
rdar://129662080
rdar://113099964
2024-06-28 10:28:46 +02:00
Alex Hoppen
2c21284ff8 Look for SourceKit-LSP options in $XDG_CONFIG_HOME/sourcekit-lsp
The reverse-DNS notation is macOS style and doesn’t feel at home on Linux.
2024-06-28 10:25:37 +02:00
Alex Hoppen
ddbad85c28 Allow specification of SourceKitLSPOptions in the initialize request
This allows editors to provide UI elements to toggle SourceKit-LSP options.
2024-06-28 10:25:37 +02:00
Alex Hoppen
d8e0fff6da Make background indexing a proper option in SourceKitLSPOptions
This allows us to flip the default in the future more easily. It also allows users to disable background indexing when it’s enabled by default.

rdar://130280855
2024-06-28 10:23:29 +02:00
Alex Hoppen
abfe5e9432 Merge pull request #1524 from ahoppen/configuration
Allow configuring of SourceKit-LSP’s options using configuration files
2024-06-28 10:14:20 +02:00
Paul LeMarquand
281c3e0e2e Prepend module name to TestItem IDs
It is possible to have two identically named suites in two different
test targets. These were being erroniously rolled up in to the same
parent TestItem.

Disambiguate these TestItems by prepending the module name. This has the
added benefit of making the TestItem IDs a fully qualified name that can
be passed to `swift test`.

The module name is pulled from the compiler arguments for the target. If
no module name can be found we fall back to the `targetID` for the
`ConfiguredTarget`.
2024-06-27 11:49:00 -04:00
Alex Hoppen
d1cddb8c41 Allow configuring of SourceKit-LSP’s options using .sourcekit-lsp configuration files
The idea here is to unify the different ways in which we can currently set options on SourceKit-LSP in a scalable way: Environment variables, command line arguments to `sourcekit-lsp` and initialization options.

The idea is that a user can define a `~/.sourcekit-lsp/.sourcekit-lsp` file (we store logs in `~/.sourcekit-lsp/logs` on non-Darwin platforms), which will be used as the default configuration for all SourceKit-LSP instances. They can also place a `.sourcekit-lsp` file in the root of a workspace to configure SourceKit-LSP for that project specifically, eg. setting arguments that need to be passed to `swift build` for that project and which thus also need to be set on SourceKit-LSP.

For compatibility reasons, I’m mapping the existing command line options into the new options structure for now. I hope to delete the command line arguments in the future and solely rely on `.sourcekit-lsp` configuration files.

Environment variable will be migrated to `.sourcekit-lsp` in a follow-up commit.
2024-06-27 17:36:16 +02:00
Alex Hoppen
617cdccc57 Handle diagnostics in secondary files correctly
rdar://130503535
2024-06-27 12:40:44 +02:00
Alex Hoppen
12142c024c Remove configuration options from WorkspaceFolder
This extension was added for VS Code but never used. Let’s remove it in favor of workspace-specific configuration files.
2024-06-27 07:01:24 +02:00
Alex Hoppen
9c6a91da4e Merge pull request #1517 from ahoppen/document-module-purpose
Add documentation about each module's purpose and move some files between modules
2024-06-27 05:09:10 +02:00
Alex Hoppen
d324d71a6c Merge pull request #1500 from ahoppen/fix-index-cancellation
Send `SIGKILL` to `swift-frontend` indexing processes
2024-06-26 22:25:23 +02:00
Alex Hoppen
2ba180b192 Send SIGKILL to swift-frontend indexing processes
We were sending `SIGINT` to `swift-frontend` processes if they didn’t terminate after 2 minutes. However, `swift-frontend` doesn’t listen to `SIGINT`.

If a task running `waitUntilExitStoppingProcessOnTaskCancellation` is cancelled and the process doesn’t terminate on a `SIGINT` after 2 seconds, kill it.

rdar://130103147
2024-06-26 09:43:05 +02:00
Alex Hoppen
80a35aabe8 Translate the semantic token legend used by clangd to the semantic token legend used by SourceKit-LSP
clangd uses a completely different semantic token legend than SourceKit-LSP (it doesn’t even adhere to the ordering of the pre-defined token types) but we were passing index offsets from clangd through assuming that clangd uses the same legend, which was incorrect.

When retrieving semantic tokens from clangd, translate the semantic tokens from clangd’s legend to SourceKit-LSP’s legend.

rdar://129895062
2024-06-26 09:30:16 +02:00
Alex Hoppen
fec5dd17f3 Merge pull request #1507 from ahoppen/re-index
Add a request to re-index all files in SourceKit-LSP
2024-06-26 00:07:46 -07:00
Alex Hoppen
46456107f7 Merge pull request #1502 from ahoppen/log-toolchain-path
Log path of the toolchain used to opening a document
2024-06-25 21:35:31 -07:00
Alex Hoppen
e23e300f7c Add a request to re-index all files in SourceKit-LSP
Users should not need to rely on this request. The index should always be updated automatically in the background. Having to invoke this request manes there is a bug in SourceKit-LSP's automatic re-indexing. It does, however, offer a workaround to re-index files when such a bug occurs where otherwise there would be no workaround.

rdar://127476221
Resolves #1263
2024-06-26 06:33:32 +02:00
Alex Hoppen
96f6e69dd8 Merge pull request #1513 from ahoppen/swiftlang-migration
Update links for repositories moved to the swiftlang org on GitHub
2024-06-25 21:09:10 -07:00
Alex Hoppen
48223851ae Merge pull request #1518 from ahoppen/sort-handle-impl
Sort cases in `handleImpl`
2024-06-25 21:05:37 -07:00
Alex Hoppen
df06ffb23b Merge pull request #1519 from ahoppen/discard-void-response
Add a variant of `send` to `TestSourceKitLSPClient` that allows implicit discarding of `VoidResponse`
2024-06-25 21:05:29 -07:00
Alex Hoppen
9618df80a0 Add documentation about each module's purpose and move some files between modules
The purpose of the different modules wasn’t clearly defined, which lead to inconsistent responsibilities between the different modules. Define each module’s purpose and move a few files between modules to satisfy these definitions.

There are a few more larger changes that will need to be made for a fully consistent module structure. These are FIXMEs in the new Modules.md document and I’ll address them in follow-up PRs.
2024-06-25 07:47:45 -07:00
Alex Hoppen
da1f6dae80 Update links for repositories moved to the swiftlang org on GitHub 2024-06-25 04:34:28 -07:00
Alex Hoppen
5d42fcde17 Add a variant of send to TestSourceKitLSPClient that allows implicit discarding of VoidResponse
Cleans up tests slightly.
2024-06-25 03:41:07 -07:00
Alex Hoppen
66ec0014d3 Sort cases in handleImpl 2024-06-25 03:32:48 -07:00
Alex Hoppen
89bd9b0372 Add test case that we don't reload the package if a .swift file get added in a folder that doesn't affect compilation
rdar://128573306
2024-06-22 09:06:40 -07:00
Alex Hoppen
652cd00b91 Log path of the toolchain used to opening a document
I don’t know why we logged the toolchain’s identifier twice. That didn’t make much sense.
2024-06-22 06:20:52 -07:00
Alex Hoppen
6aba969da7 Merge pull request #1501 from ahoppen/watch-package-resolved
Watch for changes to `Package.resolved`
2024-06-21 12:46:12 -07:00