From 35dfcdb753b454a419ce83c30d00c48f84713d91 Mon Sep 17 00:00:00 2001 From: Ian Leitch Date: Tue, 20 Aug 2024 11:27:10 +0200 Subject: [PATCH] Remove workaround for unsupported Swift versions causing performance issues (#796) --- .../Mutators/ExtensionReferenceBuilder.swift | 18 ------------------ .../SourceGraphDebugger.swift | 1 - 2 files changed, 19 deletions(-) rename Sources/{Indexer => SourceGraph}/SourceGraphDebugger.swift (98%) diff --git a/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift b/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift index 47363b36a..1402763d4 100644 --- a/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift @@ -23,12 +23,9 @@ final class ExtensionReferenceBuilder: SourceGraphMutator { guard let extendedDeclaration = graph.explicitDeclaration(withUsr: extendedTypeReference.usr) else { // This is an extension on an external type and cannot be folded. graph.markRetained(extensionDeclaration) - referenceExtendedTypeAliases(of: extendedTypeReference, from: extensionDeclaration) continue } - referenceExtendedTypeAliases(of: extendedTypeReference, from: extendedDeclaration) - // Don't fold protocol extensions as they must be treated differently. guard kind != .extensionProtocol else { continue } @@ -48,19 +45,4 @@ final class ExtensionReferenceBuilder: SourceGraphMutator { graph.remove(extensionDeclaration) } } - - private func referenceExtendedTypeAliases(of extendedTypeReference: Reference, from extensionDeclaration: Declaration) { - // Extensions on type aliases reference the existing type, not the alias. - // We need to find the typealias and build a reference to it. - let extendedTypeReferences = graph.allReferencesByUsr[extendedTypeReference.usr, default: []] - - for reference in extendedTypeReferences { - guard let aliasDecl = reference.parent, aliasDecl.kind == .typealias else { continue } - for usr in aliasDecl.usrs { - let aliasReference = Reference(kind: .typealias, usr: usr, location: extensionDeclaration.location) - aliasReference.name = aliasDecl.name - graph.add(aliasReference, from: extensionDeclaration) - } - } - } } diff --git a/Sources/Indexer/SourceGraphDebugger.swift b/Sources/SourceGraph/SourceGraphDebugger.swift similarity index 98% rename from Sources/Indexer/SourceGraphDebugger.swift rename to Sources/SourceGraph/SourceGraphDebugger.swift index 9bc69788c..1cf817d21 100644 --- a/Sources/Indexer/SourceGraphDebugger.swift +++ b/Sources/SourceGraph/SourceGraphDebugger.swift @@ -1,7 +1,6 @@ // periphery:ignore:all import Foundation -import SourceGraph final class SourceGraphDebugger { private let graph: SourceGraph