Commit Graph

302 Commits

Author SHA1 Message Date
Alex Hoppen
195d3af74e Move LocalConnection to LSPTestSupport
We weren’t logging requests sent to a `TestSourceKitLSPClient` because we were assuming that `JSONRPCConnection` logs those requests in `SourceKitLSPServer`. But no logging happens in `LocalConnection`, which `TestSourceKitLSPClient` uses.

Since `LangaugeServerProtcol` can’t depend on `LSPLogging`, move the type to `LSPTestsSupport`.
2024-05-17 11:59:40 -07:00
Alex Hoppen
7e7df04b48 Make the SourceKitLSP module build in Swift 6 mode
Swift 6 mode didn’t find any notable data races. But it’s good to know Swift 6 will prevent future ones.
2024-05-13 21:28:42 -07:00
Alex Hoppen
0685ee7773 Enhance syntactic test discovery with information from the semantic index
When the semantic index is out-of-date, we currently purely rely on the syntactic index to discover tests and completely ignore data from the semantic index. This may lead to confusing behavior. For example if you have

```
class MightInheritFromXCTestCaseOrNot {}

class MyClass: MightInheritFromXCTestCaseOrNot {
  func testStuff() {}
}
```

Then we don’t return any tests when the semantic index is up-to-date. But once the file is modified (either on disk or in-memory), we purely rely on the syntactic index, which reports `testStuff` as a test method. After a build / background indexing finishes, the test method disappears again.

We can mitigate this problem as follows: If we have stale semantic index data for the test file, for every test method found by the syntactic index, check if we have an entry for this method in the semantic index. If we do, but that entry is not marked as a test class/method, we know that the semantic index knows about this method but decided that it’s not a test method for some reason. So we should ignore it.

rdar://126492948
2024-05-02 21:10:46 -07:00
Doug Gregor
0830a95a72 Address code review and add "Add product to export this target" action 2024-04-24 21:25:55 -07:00
Doug Gregor
d11230cc24 Fix JSON encoding for TextDocumentEdit and VersionedTextDocumentIdentifier 2024-04-24 21:25:53 -07:00
Alex Hoppen
771d2a7c23 Merge pull request #1185 from ahoppen/ahoppen/jump-to-system-interface
Fix jump-to-definition to methods in swift interfaces that are in synthesized extensions
2024-04-22 22:59:51 -07:00
Alex Hoppen
440dc62e58 Fix jump-to-definition to methods in swift interfaces that are in synthesized extensions
For example when trying to go-to-definition to `filter` on `Array`, we get a USR `s:s14_ArrayProtocolPsE6filterySay7ElementQzGSbAEKXEKF::SYNTHESIZED::s:Sa`. We were trying to look it up in the index, which failed because synthesized extension methods are not indexed.

Instead, consult the `module` and `groupName` that `sourcekitd` returns in the cursor info request to decide which module to jump to.

rdar://126240558
2024-04-18 10:30:18 -07:00
Alex Hoppen
1770204e5d Implement test discovery for swift-testing tests for the textDocument/tests request
This allows us to return swift-testing tests within a single document. It does not look for swift-testing tests workspace-wide (the `workspace/tests` request), which will be a follow-up PR.
2024-04-15 21:50:16 -07:00
Alex Hoppen
67a73f47c1 Return document tests in a hierarchical format
Same as for workspace tests, instead of returning a flat list of symbols, return a hierarchical structure.
2024-04-05 20:18:46 -07:00
Alex Hoppen
65b9505081 Return workspace tests in a hierarchical format
This ways the client doesn’t need to create a hierarchical structure using the container names. It is also more flexible and allows nesting of test suites + the addition of labels and tags for swift-testing.

The data structure for `TestItem` has been heavily inspired by VS Code’s `TestItem` for the test explorer, which should make it fairly straightforward to integrate these results into the VS Code test explorer.
2024-04-05 20:16:06 -07:00
Alex Hoppen
8e9c19ac61 Don’t fatalError when constructing DocumentURI from an invalid URL 2024-04-04 11:05:49 -07:00
Max Desiatov
747c39b3b6 Remove unused import Dispatch from Message.swift (#1156)
This import is unused and is redundant in that file
2024-03-31 09:04:39 -07:00
Alex Hoppen
d1b527e14c Make the LanguageServerProtocolJSONRPC module build with strict concurrency enabled 2024-03-20 08:37:39 +01:00
Alex Hoppen
3007d9f392 Naming improvements, added comments and typo fixes in connection related code
This should make the code easier to understand. No functionality change.
2024-03-20 08:30:16 +01:00
Alex Hoppen
7c46df3abe Remove clientID from request handling
The client ID was needed when a `MessageHandler` could handle messages from multiple connections. We don’t support this anymore (because it wasn’t needed) and so the client ID doesn’t need to get passed through as well.
2024-03-20 08:28:26 +01:00
Alex Hoppen
a6fdd1d0d8 Merge pull request #1117 from ahoppen/ahoppen/sendability
Add Sendable annotations to LanguageServerProtocol, LSPLogging and SKSupport
2024-03-07 18:27:26 -08:00
Alex Hoppen
5e2fc40b8c Report whether sourcekit-lsp supports the workspace/tests and textDocument/tests requests
Fixes #1098
rdar://123771703
2024-03-04 23:16:20 -08:00
Alex Hoppen
8ea9c534f3 Add Sendable annotations to SKSupport 2024-03-03 21:50:38 -08:00
Alex Hoppen
fa54ef1748 Add Sendable annotations to LanguageServerProtocol 2024-03-03 21:50:38 -08:00
Alex Hoppen
fef3cb8f64 Sort results returned by the index
rdar://123487052
2024-02-29 13:07:28 -08:00
Alex Hoppen
1877d470a3 Use pull diagnostics by default in tests
Currently, all tests send publish diagnostics notifications, which is noise in the logs for most tests. Change the tests to use the pull diagnostics model by default and make the push diagnostic model opt-in.

rdar://123241539
2024-02-27 19:06:20 -08:00
Alex Hoppen
bfb9040fbf Support cross-file rename for clang languages
This uses the indexed rename request I added to clangd to perform global rename in clang’s language using SourceKit-LSP’s index: SourceKit-LSP’s index is used to find the locations to rename and the indexed rename request to clangd is used to translate the rename locations to edits.

rdar://118996369
2024-01-23 21:56:09 -08:00
Alex Hoppen
e8e4fb2106 Merge pull request #1011 from krzyzanowskim/marcin/fix-array-decoding
Fix decoding Array of LSPAnyCodable
2024-01-09 18:13:26 -08:00
Alex Hoppen
e0fe9d6aa1 Merge pull request #1012 from krzyzanowskim/marcin/semantictokentypes
Refactor SemanticTokenTypes, SemanticTokenModifiers
2024-01-08 18:14:28 -08:00
Marcin Krzyzanowski
72e28b1a6a Indicate failure if array element can't get decoded 2024-01-08 23:59:07 +01:00
Marcin Krzyzanowski
1e799a8cd3 Document deprecated property 2024-01-08 23:44:11 +01:00
Marcin Krzyzanowski
c7b0a68b4f add deprecated serverSideFiltering for backward compatibility 2023-12-28 00:10:27 +01:00
Marcin Krzyzanowski
0797a361d8 Add files to CMake files 2023-12-27 20:23:44 +01:00
Marcin Krzyzanowski
2c616f7838 Refactor SemanticTokenTypes, SemanticTokenModifiers 2023-12-26 22:55:12 +01:00
Marcin Krzyzanowski
6a369f5754 Fix decoding Array of LSPAnyCodable 2023-12-26 00:51:23 +01:00
Alex Hoppen
e4c2a3fe32 Merge pull request #1002 from krzyzanowskim/marcin/missing-initializers-2
More public initializers
2023-12-20 14:13:54 -08:00
Marcin Krzyzanowski
11d6e55f49 Update formatting 2023-12-16 16:18:11 +01:00
Alex Hoppen
4f5186e1d2 Merge pull request #997 from krzyzanowskim/marcin/missing-initializer-worskapce-folders 2023-12-14 17:16:23 -08:00
Marcin Krzyzanowski
a8cd9bfe05 More public initializers 2023-12-14 21:08:45 +01:00
Marcin Krzyzanowski
8eeec74904 Add public initializer 2023-12-13 21:46:45 +01:00
Alex Hoppen
5a7a91027a Merge pull request #995 from krzyzanowskim/marcin/missing-initializer
WillSaveTextDocumentNotification public initializer
2023-12-13 12:44:21 -08:00
Marcin Krzyzanowski
c614d6bd56 Public initializer 2023-12-13 15:31:13 +01: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
Alex Hoppen
ce9fdf9258 Merge pull request #990 from ahoppen/ahoppen/rename
Implement local rename within the current file
2023-12-11 19:39:35 -08:00
Alex Hoppen
8acc5bd999 Factor related identifiers request into a separate file
This allows use to re-use related identifiers when implementing rename
2023-12-09 08:34:40 -08:00
Jeremy Day
c006421667 Switch to more descriptive case names 2023-12-08 15:23:03 -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
446f9280da Add a request to list all the tests within the current workspace
Fixes #611
rdar://98710526
2023-12-06 17:40:21 -08:00
Alex Hoppen
ed410e6503 Merge pull request #977 from ahoppen/ahoppen/jump-to-override
Show overriden functions when performing jump-to-definition on a dynamic call
2023-12-05 16:18:46 -08:00
Marcin Krzyzanowski
b7cc49bcfa Decode RegistrationOptions (#980) 2023-11-30 00:46:03 -08:00
Alex Hoppen
84fdea9e05 Filter overrides in DefinitionRequest by receiver types 2023-11-29 09:03:36 -08:00
Alex Hoppen
4052465905 Show overriden functions when performing jump-to-definition on a dynamic call
Fixes #809
rdar://114864256
2023-11-29 09:02:02 -08:00
Alex Hoppen
33f4612243 Add support for different arguments per workspace
Fixes #663
rdar://101815704
2023-11-28 11:19:09 -08:00
Max Desiatov
d5831963cd Fix typo in LanguageServerProtocol/Error.swift (#970) 2023-11-27 10:08:02 +05:30