diff --git a/Sources/SwiftCompilerPluginMessageHandling/PluginMacroExpansionContext.swift b/Sources/SwiftCompilerPluginMessageHandling/PluginMacroExpansionContext.swift index ee61d2d27f7..5efa8121845 100644 --- a/Sources/SwiftCompilerPluginMessageHandling/PluginMacroExpansionContext.swift +++ b/Sources/SwiftCompilerPluginMessageHandling/PluginMacroExpansionContext.swift @@ -43,7 +43,7 @@ class SourceManager { /// Location converter to get line/column in the node. lazy var locationConverter: SourceLocationConverter = .init( - file: self.location.fileName, + fileName: self.location.fileName, tree: self.node ) } diff --git a/Sources/SwiftDiagnostics/Diagnostic.swift b/Sources/SwiftDiagnostics/Diagnostic.swift index 35e091ad5f0..249d59c55e7 100644 --- a/Sources/SwiftDiagnostics/Diagnostic.swift +++ b/Sources/SwiftDiagnostics/Diagnostic.swift @@ -68,7 +68,7 @@ public struct Diagnostic: CustomDebugStringConvertible { } public var debugDescription: String { - let locationConverter = SourceLocationConverter(file: "", tree: node.root) + let locationConverter = SourceLocationConverter(fileName: "", tree: node.root) let location = location(converter: locationConverter) return "\(location.line):\(location.column): \(message)" } diff --git a/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift b/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift index db758a2ab81..39b8f18c0b3 100644 --- a/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift +++ b/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift @@ -189,7 +189,7 @@ public struct DiagnosticsFormatter { suffixTexts: [AbsolutePosition: String], sourceLocationConverter: SourceLocationConverter? = nil ) -> String { - let slc = sourceLocationConverter ?? SourceLocationConverter(file: fileName ?? "", tree: tree) + let slc = sourceLocationConverter ?? SourceLocationConverter(fileName: fileName ?? "", tree: tree) // First, we need to put each line and its diagnostics together var annotatedSourceLines = [AnnotatedSourceLine]() diff --git a/Sources/SwiftDiagnostics/GroupedDiagnostics.swift b/Sources/SwiftDiagnostics/GroupedDiagnostics.swift index d2fdd2d6876..afd36e26d9a 100644 --- a/Sources/SwiftDiagnostics/GroupedDiagnostics.swift +++ b/Sources/SwiftDiagnostics/GroupedDiagnostics.swift @@ -142,7 +142,7 @@ extension GroupedDiagnostics { ) -> String { let sourceFile = sourceFiles[sourceFileID.id] let slc = SourceLocationConverter( - file: sourceFile.displayName, + fileName: sourceFile.displayName, tree: sourceFile.tree ) diff --git a/Sources/SwiftDiagnostics/Note.swift b/Sources/SwiftDiagnostics/Note.swift index e4c8b962a5e..fecbe1a056a 100644 --- a/Sources/SwiftDiagnostics/Note.swift +++ b/Sources/SwiftDiagnostics/Note.swift @@ -57,7 +57,7 @@ public struct Note: CustomDebugStringConvertible { public var debugDescription: String { if let root = node.root.as(SourceFileSyntax.self) { - let locationConverter = SourceLocationConverter(file: "", tree: root) + let locationConverter = SourceLocationConverter(fileName: "", tree: root) let location = location(converter: locationConverter) return "\(location): \(message)" } else { diff --git a/Sources/SwiftSyntaxMacroExpansion/BasicMacroExpansionContext.swift b/Sources/SwiftSyntaxMacroExpansion/BasicMacroExpansionContext.swift index fa21a40703f..2618aa79b4d 100644 --- a/Sources/SwiftSyntaxMacroExpansion/BasicMacroExpansionContext.swift +++ b/Sources/SwiftSyntaxMacroExpansion/BasicMacroExpansionContext.swift @@ -139,10 +139,10 @@ extension BasicMacroExpansionContext: MacroExpansionContext { fileName: String ) -> SourceLocation { guard let nodeInOriginalTree = detachedNodes[node.root] else { - return SourceLocationConverter(file: fileName, tree: node.root).location(for: position) + return SourceLocationConverter(fileName: fileName, tree: node.root).location(for: position) } let adjustedPosition = position + SourceLength(utf8Length: nodeInOriginalTree.position.utf8Offset) - return SourceLocationConverter(file: fileName, tree: nodeInOriginalTree.root).location(for: adjustedPosition) + return SourceLocationConverter(fileName: fileName, tree: nodeInOriginalTree.root).location(for: adjustedPosition) } public func location( @@ -197,7 +197,7 @@ extension BasicMacroExpansionContext: MacroExpansionContext { } // Do the location lookup. - let converter = SourceLocationConverter(file: fileName, tree: rootSourceFile) + let converter = SourceLocationConverter(fileName: fileName, tree: rootSourceFile) return AbstractSourceLocation(converter.location(for: rawPosition + offsetAdjustment)) } } diff --git a/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift b/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift index d24ba39c053..83489b1a8a0 100644 --- a/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift +++ b/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift @@ -43,8 +43,8 @@ extension TreeDifference: CustomDebugStringConvertible { public var debugDescription: String { let includeTrivia = reason == .trivia - let expectedConverter = SourceLocationConverter(file: "Baseline.swift", tree: baseline.root) - let actualConverter = SourceLocationConverter(file: "Actual.swift", tree: node.root) + let expectedConverter = SourceLocationConverter(fileName: "Baseline.swift", tree: baseline.root) + let actualConverter = SourceLocationConverter(fileName: "Actual.swift", tree: node.root) let expectedDesc = baseline.debugDescription(includeTrivia: includeTrivia, converter: expectedConverter) let actualDesc = node.debugDescription(includeTrivia: includeTrivia, converter: actualConverter) diff --git a/Tests/SwiftParserTest/Assertions.swift b/Tests/SwiftParserTest/Assertions.swift index f33b37d9035..28156d24500 100644 --- a/Tests/SwiftParserTest/Assertions.swift +++ b/Tests/SwiftParserTest/Assertions.swift @@ -338,7 +338,7 @@ func assertLocation( line: UInt = #line ) { if let markerLoc = markerLocations[locationMarker] { - let locationConverter = SourceLocationConverter(file: "", tree: tree) + let locationConverter = SourceLocationConverter(fileName: "", tree: tree) let actualLocation = location let expectedLocation = locationConverter.location(for: AbsolutePosition(utf8Offset: markerLoc)) if actualLocation.line != expectedLocation.line || actualLocation.column != expectedLocation.column { @@ -362,7 +362,7 @@ func assertNote( expected spec: NoteSpec ) { XCTAssertEqual(note.message, spec.message, file: spec.file, line: spec.line) - let locationConverter = SourceLocationConverter(file: "", tree: tree) + let locationConverter = SourceLocationConverter(fileName: "", tree: tree) assertLocation( note.location(converter: locationConverter), in: tree, @@ -381,7 +381,7 @@ func assertDiagnostic( markerLocations: [String: Int], expected spec: DiagnosticSpec ) { - let locationConverter = SourceLocationConverter(file: "", tree: tree) + let locationConverter = SourceLocationConverter(fileName: "", tree: tree) assertLocation( diag.location(converter: locationConverter), in: tree, diff --git a/Tests/SwiftParserTest/ParserTests.swift b/Tests/SwiftParserTest/ParserTests.swift index 87a91163393..6b23678e285 100644 --- a/Tests/SwiftParserTest/ParserTests.swift +++ b/Tests/SwiftParserTest/ParserTests.swift @@ -39,7 +39,7 @@ public class ParserTests: XCTestCase { let diagnostics = ParseDiagnosticsGenerator.diagnostics(for: parsed) if !diagnostics.isEmpty { var locationAndDiagnostics: [String] = [] - let locationConverter = SourceLocationConverter(file: fileURL.lastPathComponent, tree: parsed) + let locationConverter = SourceLocationConverter(fileName: fileURL.lastPathComponent, tree: parsed) for diag in diagnostics { let location = diag.location(converter: locationConverter) let message = diag.message diff --git a/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift b/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift index 52d692825e2..ecdfa865033 100644 --- a/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift +++ b/Tests/SwiftParserTest/StringLiteralRepresentedLiteralValueTests.swift @@ -302,7 +302,7 @@ public class StringLiteralRepresentedLiteralValueTests: XCTestCase { super.init(viewMode: .sourceAccurate) - self.locationConverter = SourceLocationConverter(file: "", tree: syntax) + self.locationConverter = SourceLocationConverter(fileName: "", tree: syntax) self.walk(syntax) self.locationConverter = nil }