Skip to content

Commit 37f3622

Browse files
committed
Restore Swift-only index store occurrence filtering.
Filter non-Swift symbols before building the source graph so mixed Swift/Objective-C projects don't ingest raw extension metadata that triggers extension resolution failures and duplicate USR conflicts.
1 parent dcd5646 commit 37f3622

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var dependencies: [Package.Dependency] = [
77
.package(url: "https://github.com/tadija/AEXML", from: "4.0.0"),
88
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
99
// Use tag once https://github.com/MobileNativeFoundation/swift-index-store/issues/27 is resolved.
10-
.package(url: "https://github.com/ileitch/swift-index-store", revision: "ad6f20532864a2cf3b1e1ee7a084267e94eb68b9"),
10+
.package(url: "https://github.com/MobileNativeFoundation/swift-index-store", revision: "7edb9a64e084ed64f83b84fb9269d3d1a20c0687"),
1111
.package(url: "https://github.com/apple/swift-syntax", from: "603.0.0"),
1212
.package(url: "https://github.com/ileitch/swift-filename-matcher", from: "2.0.0"),
1313
]

Sources/Indexer/SwiftIndexer.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ final class SwiftIndexer: Indexer {
8585
logger.debug("\(sourceFile.path.string) (\(modules)) (\(elapsed)s)")
8686
}
8787

88+
static func shouldProcessSymbolLanguage(_ language: SymbolLanguage) -> Bool {
89+
language == .swift
90+
}
91+
8892
private final class Job {
8993
let sourceFile: SourceFile
9094

@@ -162,7 +166,8 @@ final class SwiftIndexer: Indexer {
162166

163167
record.forEach(occurrence: { occurrence in
164168
let usr = occurrence.symbol.usr
165-
guard let location = self.transformLocation(occurrence.location)
169+
guard Self.shouldProcessOccurrence(occurrence),
170+
let location = self.transformLocation(occurrence.location)
166171
else { return }
167172

168173
var relations: [RawRelation] = []
@@ -701,6 +706,10 @@ final class SwiftIndexer: Indexer {
701706
Location(file: sourceFile, line: input.line, column: input.column)
702707
}
703708

709+
static func shouldProcessOccurrence(_ occurrence: SymbolOccurrence) -> Bool {
710+
SwiftIndexer.shouldProcessSymbolLanguage(occurrence.symbol.language)
711+
}
712+
704713
private func transformDeclarationKind(_ kind: SymbolKind, _ subKind: SymbolSubkind) -> Declaration.Kind? {
705714
switch subKind {
706715
case .accessorGetter: return .functionAccessorGetter

Tests/PeripheryTests/DeterminismRegressionTest.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Configuration
2+
@testable import Indexer
23
import Logger
34
import Shared
45
@testable import SourceGraph
@@ -54,6 +55,13 @@ final class DeterminismRegressionTest: XCTestCase {
5455
return reference
5556
}
5657

58+
func testSwiftIndexerFiltersNonSwiftSymbolLanguages() {
59+
XCTAssertTrue(SwiftIndexer.shouldProcessSymbolLanguage(.swift))
60+
XCTAssertFalse(SwiftIndexer.shouldProcessSymbolLanguage(.objc))
61+
XCTAssertFalse(SwiftIndexer.shouldProcessSymbolLanguage(.c))
62+
XCTAssertFalse(SwiftIndexer.shouldProcessSymbolLanguage(.cxx))
63+
}
64+
5765
func testExtendedDeclarationReferenceUsesDeterministicSelection() throws {
5866
let graph = makeGraph()
5967

0 commit comments

Comments
 (0)