Skip to content

Commit 7abf33e

Browse files
authored
Adopt the upcoming feature SE-0274 (concise magic file name) (#1180)
* Enable SE-0274 (concise magic file name) upcoming feature * Use absolute file paths in generate-symbol-graph tool
1 parent e1f56f1 commit 7abf33e

File tree

41 files changed

+67
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+67
-66
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import class Foundation.ProcessInfo
1515
let swiftSettings: [SwiftSetting] = [
1616
.unsafeFlags(["-Xfrontend", "-warn-long-expression-type-checking=1000"], .when(configuration: .debug)),
1717

18+
.enableUpcomingFeature("ConciseMagicFile"), // SE-0274: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0274-magic-file.md
1819
.enableUpcomingFeature("ExistentialAny"), // SE-0335: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0335-existential-any.md
1920
]
2021

Sources/generate-symbol-graph/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ let supportedDirectives: [Directive] = [
199199
}
200200

201201
func generateSwiftDocCFrameworkSymbolGraph() throws -> SymbolGraph {
202-
let packagePath = URL(fileURLWithPath: #file)
202+
let packagePath = URL(fileURLWithPath: #filePath) // Absolute path to this file
203203
.deletingLastPathComponent() // generate-symbol-graph
204204
.deletingLastPathComponent() // Sources
205205
.deletingLastPathComponent() // swift-docc
@@ -680,7 +680,7 @@ private struct SortedSymbolGraph: Codable {
680680
}
681681
}
682682

683-
let output = URL(fileURLWithPath: #file)
683+
let output = URL(fileURLWithPath: #filePath) // Absolute path to this file
684684
.deletingLastPathComponent()
685685
.deletingLastPathComponent()
686686
.appendingPathComponent("docc/DocCDocumentation.docc/docc.symbols.json")

Tests/SwiftDocCTests/DocumentationService/ConvertService/ConvertServiceTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ class ConvertServiceTests: XCTestCase {
23962396
source: URL,
23972397
title: String?,
23982398
isDocumentationExtensionContent: Bool,
2399-
file: StaticString = #file,
2399+
file: StaticString = #filePath,
24002400
line: UInt = #line
24012401
) throws {
24022402
let topicContentKey = try XCTUnwrap(referenceStore.topics.keys.first { $0.path == topicPath })

Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ fileprivate func validateTree(node: NavigatorTree.Node, validator: (NavigatorTre
20522052
return true
20532053
}
20542054

2055-
fileprivate func assertUniqueIDs(node: NavigatorTree.Node, message: String = "The tree has duplicated IDs.", file: StaticString = #file, line: UInt = #line) {
2055+
fileprivate func assertUniqueIDs(node: NavigatorTree.Node, message: String = "The tree has duplicated IDs.", file: StaticString = #filePath, line: UInt = #line) {
20562056
var collector = Set<UInt32>()
20572057
var brokenItemTitle = ""
20582058

Tests/SwiftDocCTests/Infrastructure/AutomaticCurationTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class AutomaticCurationTests: XCTestCase {
9595
containsAutomaticTopicSectionFor kind: SymbolGraph.Symbol.KindIdentifier,
9696
context: DocumentationContext,
9797
bundle: DocumentationBundle,
98-
file: StaticString = #file,
98+
file: StaticString = #filePath,
9999
line: UInt = #line
100100
) throws {
101101
let node = try context.entity(with: ResolvedTopicReference(bundleID: bundle.id, path: path, sourceLanguage: .swift))
@@ -771,7 +771,7 @@ class AutomaticCurationTests: XCTestCase {
771771

772772
func assertAutomaticCuration(
773773
variants: Set<DocumentationDataVariantsTrait>,
774-
file: StaticString = #file,
774+
file: StaticString = #filePath,
775775
line: UInt = #line
776776
) throws {
777777
let topics = try AutomaticCuration.topics(

Tests/SwiftDocCTests/Infrastructure/BundleDiscoveryTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ class BundleDiscoveryTests: XCTestCase {
136136

137137
let expectedBundle = try parsedBundle(from: CopyOfFolder(original: testBundleLocation))
138138

139-
func checkExpectedFilesFoundIn(_ folder: any File, file: StaticString = #file, line: UInt = #line) throws {
139+
func checkExpectedFilesFoundIn(_ folder: any File, file: StaticString = #filePath, line: UInt = #line) throws {
140140
let bundle = try parsedBundle(from: folder)
141141

142142
XCTAssertEqual(bundle.id, expectedBundle.id)
143143
XCTAssertEqual(bundle.displayName, expectedBundle.displayName)
144144

145-
func assertEqualFiles(_ got: [URL], _ expected: [URL], file: StaticString = #file, line: UInt = #line) {
145+
func assertEqualFiles(_ got: [URL], _ expected: [URL], file: StaticString = #filePath, line: UInt = #line) {
146146
let gotFileNames = Set(got.map { $0.lastPathComponent })
147147
let expectedFileNames = Set(expected.map { $0.lastPathComponent })
148148

Tests/SwiftDocCTests/Infrastructure/DataAssetManagerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import XCTest
1414

1515
class DataAssetManagerTests: XCTestCase {
1616

17-
func assertIsRegistered(named name: String, trait: DataTraitCollection, expectedURL: URL, manager: DataAssetManager, file: StaticString = #file, line: UInt = #line) {
17+
func assertIsRegistered(named name: String, trait: DataTraitCollection, expectedURL: URL, manager: DataAssetManager, file: StaticString = #filePath, line: UInt = #line) {
1818
let data = manager.data(named: name, bestMatching: trait)!
1919
XCTAssertEqual(data.url, expectedURL)
2020
XCTAssertEqual(data.traitCollection, trait)

Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageLinkResolutionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DocumentationContext_MixedLanguageLinkResolutionTests: XCTestCase {
2424
func assertCanResolveSymbolLinks(
2525
symbolPaths: String...,
2626
parentPath: String,
27-
file: StaticString = #file,
27+
file: StaticString = #filePath,
2828
line: UInt = #line
2929
) {
3030
for symbolPath in symbolPaths {

Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContext+MixedLanguageSourceLanguagesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DocumentationContext_MixedLanguageSourceLanguagesTests: XCTestCase {
3636
func assertArticleAvailableSourceLanguages(
3737
moduleAvailableLanguages: Set<SourceLanguage>,
3838
expectedArticleDefaultLanguage: SourceLanguage,
39-
file: StaticString = #file,
39+
file: StaticString = #filePath,
4040
line: UInt = #line
4141
) throws {
4242
precondition(

Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5568,7 +5568,7 @@ let expected = """
55685568

55695569
}
55705570

5571-
func assertEqualDumps(_ lhs: String, _ rhs: String, file: StaticString = #file, line: UInt = #line) {
5571+
func assertEqualDumps(_ lhs: String, _ rhs: String, file: StaticString = #filePath, line: UInt = #line) {
55725572
// The default message by XCTAssertEqual isn't helpful in this case as it dumps both values in the console
55735573
// and is difficult to track any changes
55745574
guard lhs.removingLeadingSpaces == rhs.removingLeadingSpaces else {

0 commit comments

Comments
 (0)