-
Notifications
You must be signed in to change notification settings - Fork 321
Fix module definition jumping in Swift interface files #2233
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
Changes from all commits
12135d0
a86ed02
717f011
e396421
a2a3388
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,6 +319,65 @@ final class SwiftInterfaceTests: XCTestCase { | |
) | ||
XCTAssertEqual(diagnostics.fullReport?.items, []) | ||
} | ||
|
||
func testFoundationImportNavigation() async throws { | ||
ahoppen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let testClient = try await TestSourceKitLSPClient( | ||
capabilities: ClientCapabilities(experimental: [ | ||
GetReferenceDocumentRequest.method: .dictionary(["supported": .bool(true)]) | ||
]) | ||
) | ||
let uri = DocumentURI(for: .swift) | ||
|
||
let positions = testClient.openDocument( | ||
""" | ||
import 1️⃣Foundation | ||
""", | ||
uri: uri, | ||
language: .swift | ||
) | ||
|
||
// Test navigation to Foundation module | ||
let foundationDefinition = try await testClient.send( | ||
DefinitionRequest(textDocument: TextDocumentIdentifier(uri), position: positions["1️⃣"]) | ||
) | ||
let foundationLocation = try XCTUnwrap(foundationDefinition?.locations?.only) | ||
XCTAssertEqual(foundationLocation.uri.scheme, "sourcekit-lsp") | ||
assertContains(foundationLocation.uri.pseudoPath, "Foundation.swiftinterface") | ||
} | ||
|
||
func testFoundationSubmoduleNavigation() async throws { | ||
try SkipUnless.platformIsDarwin("Non-Darwin platforms don't have Foundation submodules") | ||
|
||
let testClient = try await TestSourceKitLSPClient( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like Foundation only has submodules on Darwin platforms (macOS, iOS, etc.). Let’s skip this test on Linux and Windows by adding the following at the start of the test. try SkipUnless.platformIsDarwin("Non-Darwin platforms don't have Foundation submodules") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for very detailed code every time 😄 |
||
capabilities: ClientCapabilities(experimental: [ | ||
GetReferenceDocumentRequest.method: .dictionary(["supported": .bool(true)]) | ||
]) | ||
) | ||
let uri = DocumentURI(for: .swift) | ||
|
||
let positions = testClient.openDocument( | ||
""" | ||
import 1️⃣Foundation.2️⃣NSAffineTransform | ||
""", | ||
uri: uri | ||
) | ||
|
||
let foundationDefinition = try await testClient.send( | ||
DefinitionRequest(textDocument: TextDocumentIdentifier(uri), position: positions["1️⃣"]) | ||
) | ||
let foundationLocation = try XCTUnwrap(foundationDefinition?.locations?.only) | ||
XCTAssertEqual(foundationLocation.uri.scheme, "sourcekit-lsp") | ||
assertContains(foundationLocation.uri.pseudoPath, "Foundation.swiftinterface") | ||
|
||
// Test navigation to NSAffineTransform | ||
let transformDefinition = try await testClient.send( | ||
DefinitionRequest(textDocument: TextDocumentIdentifier(uri), position: positions["2️⃣"]) | ||
) | ||
let transformLocation = try XCTUnwrap(transformDefinition?.locations?.only) | ||
// Verify we can identify this as a swiftinterface file | ||
XCTAssertEqual(transformLocation.uri.scheme, "sourcekit-lsp") | ||
assertContains(transformLocation.uri.pseudoPath, "Foundation.NSAffineTransform.swiftinterface") | ||
} | ||
} | ||
|
||
private func assertSystemSwiftInterface( | ||
|
Uh oh!
There was an error while loading. Please reload this page.