Skip to content
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

Merge main into release/6.0 #1236

Merged
merged 44 commits into from
May 8, 2024

Conversation

ahoppen and others added 30 commits May 3, 2024 13:32
…o `sourcekit-lsp-diagnose`

The name still dated back to when `sourcekit-lsp diagnose` would only reduce sourcekitd crashes. Now it does quite a bit more.
This way we’ll be able to use it from the semantic indexer.
This will allow us to conditionally enable background indexing in tests
This allows us to enable background indexing for a workspace based on a value in `SourceKitLSPServer.Options`.
…erver` to `BuildSystemManager`

This allows us to determine the toolchain to use during background indexing. It also moves toolchain selection closer to the build system, which is good because when we support multiple toolchains for a single workspace, the build system is what decides which toolchain to use for which document.
The build system has potentially  more information about a document's language than we do based on the file’s extension.
This allows us to get rid of the lock.
Rename diagnose bundle created on disk from `sourcekitd-reproducer` to `sourcekit-lsp-diagnose`
Add '-Xswiftc -plugin-path -Xswiftc ${toolchain}/lib/swift/host/plugins'
to swiftpm invocations.
[build-script-helper] Prefer just-built plugins to SDK plugins
…toringProvider

Rather than only adapt refactoring actions that conform to
SyntaxRefactoringProvider, which takes a syntax node and produces a
syntax node, adapt to the less-constraining EditRefactoringProvider,
which takes a syntax node and produces edits. We can map edits over
just as effectively.
…unction

This code action takes an undocumented function declaration like

    func refactor(syntax: DeclSyntax, in context: Void) -> DeclSyntax?

and adds stub documentation for the parameters / result / etc., like this:

    /// A description
    /// - Parameters:
    ///   - syntax:
    ///   - context:
    ///
    /// - Returns:
…action

Add "Add documentation" code action to stub out documentation for a function
Miscellaneous commits in preparation for background indexing
Most importantly, the bug report template is now asking for the user’s OS, Swift version and logging.
Since we now have a `.github` folder for issue templates, we can move `CODEOWNERS` to it.
There were two issues with Objective-C XCTest discovery:
1. We were relying on syntactic test discovery after a document is edited. But since we don't have syntactic test discovery for Objective-C tests, this meant that all tests would disappear as a document got edited. Until we get syntactic test discovery for Objective-C, use the semantic index to discover tests, even if they are out-of-date.
2. We were assuming that the `DocumentSymbols` request returned `[DocumentSymbol]` to find the ranges of tests. But clangd returns the alternative `[SymbolInformation]`, which meant that we were only returning the position of a test function’s name instead of the test function’s range.

rdar://126810202
Use `TokenSyntax.indentationOfLine` from SwiftBasicFormat instead of duplicating indentation inferring logic
DougGregor and others added 13 commits May 6, 2024 13:53
Add a syntactic action that takes JSON pasted into a Swift file or
placed in a string literal, then turns it into a set of Codable
structs that can represent the JSON. Our typical example starts like
this:

```
{
    "name": "Produce",
    "shelves": [
        {
            "name": "Discount Produce",
            "product": {
                "name": "Banana",
                "points": 200,
                "description": "A banana that's perfectly ripe."
            }
        }
    ]
}
```

and turns into this:

```swift
struct JSONValue: Codable {
    var name: String
    var shelves: [Shelves]

    struct Shelves: Codable {
        var name: String
        var product: Product

        struct Product: Codable {
            var description: String
            var name: String
            var points: Double
        }
    }
}
```

When converting to JSON, we attempt to reason about multiple JSON
objects on the same level to detect when there are optional fields,
due to either an explicit null or due to the absence of fields in some
of the JSON objects that are conceptually stored together.

The refactoring itself would live down in the swift-syntax package if
not for its dependency on Foundation. We'll move it when appropriate.
Renaming an enum case currently caused invalid code to be generated because we would rename eg. `myCase(String)` to `myNewCase(_ String)`.

Fixing the underlying issue requires changes to `sourcekitd`, that are out-of-scope at the moment. For now, just suppress argument label rename for enum cases in SourceKit-LSP and avoid generating invalid code even if just the base name is modified.

rdar://127248157
Useful for correlating request IDs with cancellation notifications.
Add a syntactic "Add Codable structs from JSON" code action
Prevent rename of argument labels for enum cases
When renaming `func test(foo: Int) {}` to `test2(foo:)`, rename used to report an edit from `foo` to `foo`, which clutters the refactor preview view. We shouldn’t report edits if no text is actually changed.

rdar://127291815
Fix test discovery for Objective-C XCTests
Log request ID of received requests
@ahoppen ahoppen requested a review from bnbarham May 7, 2024 16:00
@ahoppen ahoppen requested a review from benlangmuir as a code owner May 7, 2024 16:00
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 7, 2024

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 7, 2024

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 7, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit aa0ed90 into apple:release/6.0 May 8, 2024
3 checks passed
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.

None yet

4 participants