@@ -28,7 +28,7 @@ public struct GroupedDiagnostics {
2828 let id : SourceFileID
2929
3030 /// The syntax tree for the source file.
31- let tree : SourceFileSyntax
31+ let tree : Syntax
3232
3333 /// The source location converter for this source file.
3434 let sourceLocationConverter : SourceLocationConverter
@@ -55,7 +55,7 @@ public struct GroupedDiagnostics {
5555
5656 /// Mapping from the root source file syntax nodes to the corresponding
5757 /// source file IDs.
58- var rootIndexes : [ SourceFileSyntax : SourceFileID ] = [ : ]
58+ var rootIndexes : [ Syntax : SourceFileID ] = [ : ]
5959
6060 public init ( ) { }
6161
@@ -71,12 +71,13 @@ public struct GroupedDiagnostics {
7171 /// - Returns: The unique ID for this source file.
7272 @discardableResult
7373 public mutating func addSourceFile(
74- tree: SourceFileSyntax ,
74+ tree: some SyntaxProtocol ,
7575 sourceLocationConverter: SourceLocationConverter ? = nil ,
7676 displayName: String ,
7777 parent: ( SourceFileID , AbsolutePosition ) ? = nil ,
7878 diagnostics: [ Diagnostic ] = [ ]
7979 ) -> SourceFileID {
80+ let tree = Syntax ( tree)
8081 // Determine the ID this source file will have.
8182 let id = SourceFileID ( id: sourceFiles. count)
8283 let slc =
@@ -108,11 +109,7 @@ public struct GroupedDiagnostics {
108109
109110 /// Find the ID of the source file containing this syntax node.
110111 func findSourceFileContaining( _ node: Syntax ) -> SourceFileID ? {
111- guard let rootSourceFile = node. root. as ( SourceFileSyntax . self) else {
112- return nil
113- }
114-
115- return rootIndexes [ rootSourceFile]
112+ return rootIndexes [ node. root]
116113 }
117114
118115 /// Add a diagnostic to the set of grouped diagnostics.
0 commit comments