Skip to content

Merge main into release/6.0 #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Apr 24, 2024

Conversation

ahoppen and others added 30 commits April 4, 2024 10:08
…ent:)`

This initializer was only introduced very recently since `IncrementalEdit` stores the replacement bytes instead of just the replacement length. We are now changing `IncrementalEdit` store the range it’s replacing as `Range<AbsolutePosition>` instead of `ByteSourceRange`.

Companion of swiftlang/swift-syntax#2588
…t/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.
Otherwise, the date formatters always output the time in GMT, which has confused me multiple times. Setting the user’s local time zone will emit the date in the user’s local time zone and include the time zone offset to GMT in the date as well.
…kit-lsp should return `nil`

Eg. when requesting type hierarchy of a class when the project hasn’t been built, sourcekit-lsp returns an empty array. That causes VS Code to fail with very ambiguous error messages
- MISSING provider
- Cannot read properties of null (reading 'kind')

To work around this, instead of returning an empty array, return `nil` instead.

rdar://126228814
This change includes a number of new refactoring code actions that
build on the syntax refactorings for the SwiftRefactor module of swift-syntax:

  * Add digit separators to an integer literal, e.g., `1000000` ->
    `1_000_000`.
  * Remove digit separators from an integer literal, e.g., 1_000_000 ->
    1000000.
  * Format a raw string literal, e.g., `"Hello \#(world)"` ->
    `##"Hello\#(world)"##`
  * Migrate to new if let syntax, e.g., `if let x = x { ... }` ->
    `if let x { ... }`
  * Replace opaque parameters with generic parameters, e.g.,
    `func f(p: some P)` --> `func f<T1: P>(p: T1)`.

This is generally easy to do, requiring one conformance to provide a name for the refactoring:

    extension AddSeparatorsToIntegerLiteral: SyntaxRefactoringCodeActionProvider {
      public static var title: String { "Add digit separators" }
    }
…refactorings

Introduce new refactoring code actions based on the Swift syntax tree.
…type-hierarchy

Instead of returning an empty array in `prepareTypeHierarchy`, sourcekit-lsp should return `nil`
See comment in `workspaceForDocument` that explains the race.
…thesized 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
…discovery

Implement test discovery for swift-testing tests for the `textDocument/tests` request
…-race-condition

Fix a race condition during the computation of `uriToWorkspaceCache`
…-range

Adjustment for the removal of `IncrementalEdit(offset:length:replacement:)` 🤝 swift-syntax#2588
…tests

Otherwise we can get into race conditions where we run a request before the index has actually been updated.

While at it, also add logging when IndexStoreDB has been updated.

rdar://126635046
Truncate log message after 10.000 characters to avoid flooding the log with huge log messages (eg. from a sourcekitd response). 10.000 characters wasn't chosen because it seems to fit the result of most sourcekitd responses that are not generated interface or global completion results (which are a lot bigger).
With swiftlang/swift#72930 we can use the `containedBy` instead of `calledBy` relation for the call hierarchy, which allows us to show unapplied function references in the call hierarchy as well.

rdar://123769825
…og-message

Truncate log message in `NonDarwinLogger` at 10.000 characters
…tion-refs-in-call-hierarchy

Show unapplied function references in call hierarchy
Set time zone to the user's local time zone when using date formatters
…-interface

Fix jump-to-definition to methods in swift interfaces that are in synthesized extensions
…-in-tests

Wait for indexstore-db to update after building a SwiftPM project in tests
…ovements

Slightly simplify code completion logic
This workspace-wide syntactic test index is used for two purposes:
- It is used for XCTests instead of the semantic index for files that have on-disk or in-memory modifications to files
- It is uses for swift-testing tests, which are only discovered syntactically.

rdar://119191037
…ule` file has been changed

When the client sends us `workspace/didChangeWatchedFiles` notification of an updated `.swift` file, we should refresh the other open files in that module since they might be referencing functions from that updated file.

If a `.swiftmodule` file has been updated, we refresh all the files within the package since they might import that module. Technically, we would only need to refresh files that are in module that are downstream of the updated module but we don’t currently have that information easily available from SwiftPM. Also, usually, if the client has a file from a low-level module open, he’ll be working on that module which means that such an optimization won’t help. The real solution here is to wait for us to finish preparation (which we would exactly know when it finishes since sourcekit-lsp would schedule it) but for that we need to implement background preparation.

Fixes swiftlang#620
Fixes swiftlang#1116
rdar://99329579
rdar://123971779
- Change name of request in reproducer bundle from `request.json` to `request.yml` because it’s a YAML file, not a JSON file
- Change names of diagnose components to use dashes instead of camel case
@ahoppen ahoppen requested a review from benlangmuir as a code owner April 23, 2024 18:21
@ahoppen ahoppen requested a review from bnbarham April 23, 2024 18:21
@ahoppen
Copy link
Member Author

ahoppen commented Apr 23, 2024

@swift-ci Please test

… in cursor info

The formatting of these hover responses contains a newline if we don’t have a raw documentation response. Skip these tests if sourcekitd doesn’t return the raw documentation in cursor info, like we do with other tests in this file.

This ensures that all tests are passing in Xcode 15.4 again.
@ahoppen
Copy link
Member Author

ahoppen commented Apr 24, 2024

@swift-ci Please test

ahoppen and others added 6 commits April 23, 2024 20:34
Minor improvements to the diagnose subcommand
…d-toolchains

Skip a few hover tests if sourcekitd doesn’t return raw documentation in cursor info
…d-dependencies

Reload a file when other files within the same module or a `.swiftmodule` file has been changed
@ahoppen
Copy link
Member Author

ahoppen commented Apr 24, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 24, 2024

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Apr 24, 2024

@swift-ci Please test

@ahoppen ahoppen merged commit d14ddcf into swiftlang:release/6.0 Apr 24, 2024
3 checks passed
@ahoppen ahoppen deleted the 6.0/merge-main-2024-04-23 branch April 24, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants