File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
Sources/SwiftDocC/DocumentationService/Convert/Symbol Link Resolution
Tests/SwiftDocCTests/Infrastructure/Symbol Link Resolution Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -131,8 +131,8 @@ public enum LinkCompletionTools {
131131 node,
132132 kind: symbol. kind,
133133 hash: symbol. symbolIDHash,
134- parameterTypes: symbol. parameterTypes,
135- returnTypes: symbol. returnTypes
134+ parameterTypes: symbol. parameterTypes? . map { $0 . withoutWhitespace ( ) } ,
135+ returnTypes: symbol. returnTypes? . map { $0 . withoutWhitespace ( ) }
136136 )
137137 }
138138
@@ -236,3 +236,9 @@ private extension PathHierarchy.PathComponent.Disambiguation {
236236 }
237237 }
238238}
239+
240+ private extension String {
241+ func withoutWhitespace( ) -> String {
242+ filter { !$0. isWhitespace }
243+ }
244+ }
Original file line number Diff line number Diff line change @@ -237,4 +237,25 @@ class LinkCompletionToolsTests: XCTestCase {
237237 " ->_ " , // The only overload that returns something
238238 ] )
239239 }
240+
241+ func testRemovesWhitespaceFromTypeSignatureDisambiguation( ) {
242+ let overloads = [
243+ // The caller included whitespace in these closure type spellings but the DocC disambiguation won't include this whitespace.
244+ ( parameters: [ " (Int) -> Int " ] , returns: [ ] ) , // ((Int) -> Int) -> Void
245+ ( parameters: [ " (Bool) -> () " ] , returns: [ ] ) , // ((Bool) -> () ) -> Void
246+ ] . map {
247+ LinkCompletionTools . SymbolInformation (
248+ kind: " func " ,
249+ symbolIDHash: " \( $0) " . stableHashString,
250+ parameterTypes: $0. parameters,
251+ returnTypes: $0. returns
252+ )
253+ }
254+
255+ XCTAssertEqual ( LinkCompletionTools . suggestedDisambiguation ( forCollidingSymbols: overloads) , [
256+ // Both parameters require the only parameter type as disambiguation. The suggested disambiguation shouldn't contain extra whitespace.
257+ " -((Int)->Int) " ,
258+ " -((Bool)->()) " ,
259+ ] )
260+ }
240261}
You can’t perform that action at this time.
0 commit comments