@@ -335,65 +335,15 @@ final class DocumentationCacheBasedLinkResolver {
335
335
let moduleName : String
336
336
var languages : Set < SourceLanguage >
337
337
}
338
- var pathCollisionInfo = [ [ String] : [ PathCollisionInfo] ] ( )
338
+ var pathCollisionInfo = [ String: [ PathCollisionInfo] ] ( )
339
339
pathCollisionInfo. reserveCapacity ( totalSymbolCount)
340
340
341
341
// Group symbols by path from all of the available symbol graphs
342
342
for (moduleName, symbolGraph) in unifiedGraphs {
343
343
let symbols = Array ( symbolGraph. symbols. values)
344
-
345
- let referenceMap = symbols. concurrentMap { symbol in
346
- ( symbol, referencesWithoutDisambiguationFor ( symbol, moduleName: moduleName, bundle: bundle, context: context) )
347
- } . reduce ( into: [ String: [ SourceLanguage: ResolvedTopicReference] ] ( ) , { result, next in
348
- let ( symbol, references) = next
349
- for reference in references {
350
- result [ symbol. uniqueIdentifier, default: [ : ] ] [ reference. sourceLanguage] = reference
351
- }
352
- } )
353
-
354
- let parentMap = symbolGraph. relationshipsByLanguage. reduce ( into: [ String: [ SourceLanguage: String] ] ( ) , { parentMap, next in
355
- let ( selector, relationships) = next
356
- guard let language = SourceLanguage ( knownLanguageIdentifier: selector. interfaceLanguage) else {
357
- return
358
- }
359
-
360
- for relationship in relationships {
361
- switch relationship. kind {
362
- case . memberOf, . requirementOf, . declaredIn:
363
- parentMap [ relationship. source, default: [ : ] ] [ language] = relationship. target
364
- default :
365
- break
366
- }
367
- }
368
- } )
369
-
370
- let pathsAndLanguages : [ [ ( [ String ] , SourceLanguage ) ] ] = symbols. concurrentMap { symbol in
371
- guard let references = referenceMap [ symbol. uniqueIdentifier] else {
372
- return [ ]
373
- }
374
-
375
- return references. map { language, reference in
376
- var prefixLength : Int
377
- if let parentId = parentMap [ symbol. uniqueIdentifier] ? [ language] ,
378
- let parentReference = referenceMap [ parentId] ? [ language] ?? referenceMap [ parentId] ? . values. first {
379
- // This is a child of some other symbol
380
- prefixLength = parentReference. pathComponents. count
381
- } else {
382
- // This is a top-level symbol or another symbol without parent (e.g. default implementation)
383
- prefixLength = reference. pathComponents. count- 1
384
- }
385
-
386
- // PathComponents can have prefixes which are not known locally. In that case,
387
- // the "empty" segments will be cut out later on. We follow the same logic here, as otherwise
388
- // some collisions would not be detected.
389
- // E.g. consider an extension to an external nested type `SomeModule.SomeStruct.SomeStruct`. The
390
- // parent of this extended type symbol is `SomeModule`, however, the path for the extended type symbol
391
- // is `SomeModule/SomeStruct/SomeStruct`, later on, this will change to `SomeModule/SomeStruct`. Now, if
392
- // we also extend `SomeModule.SomeStruct`, the paths for both extensions could collide. To recognize (and resolve)
393
- // the collision here, we work with the same, shortened paths.
394
- return ( ( reference. pathComponents [ 0 ..< prefixLength] + [ reference. pathComponents. last!] ) . map { $0. lowercased ( ) } , reference. sourceLanguage)
395
- }
396
- }
344
+ let pathsAndLanguages : [ [ ( String , SourceLanguage ) ] ] = symbols. concurrentMap { referencesWithoutDisambiguationFor ( $0, moduleName: moduleName, bundle: bundle, context: context) . map {
345
+ ( $0. path. lowercased ( ) , $0. sourceLanguage)
346
+ } }
397
347
398
348
for (symbol, symbolPathsAndLanguages) in zip ( symbols, pathsAndLanguages) {
399
349
for (path, language) in symbolPathsAndLanguages {
0 commit comments