Skip to content

Commit 08fa08e

Browse files
committed
Move the Diagnostic-related types back to the SwiftSyntax module
Moving `Diagnostic` etc. to the `SwiftSyntaxParser` module required `swift-format` to import `SwiftSyntaxParser` in a bunch of places where it shouldn’t be needed. Move the types back to the `SwiftSyntax` module for now until we completely refactor the parser to just return `Diagnostics` and not require a `DiagnsoticEngine` (tracked by SR-15280).
1 parent ac7bcbe commit 08fa08e

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

Sources/SwiftSyntaxParser/Diagnostic.swift renamed to Sources/SwiftSyntax/Diagnostic.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// This file provides the Diagnostic, Note, and FixIt types.
1313
//===----------------------------------------------------------------------===//
1414

15-
import SwiftSyntax
16-
1715
/// A FixIt represents a change to source code in order to "correct" a
1816
/// diagnostic.
1917
public enum FixIt: Codable, CustomDebugStringConvertible {
@@ -108,7 +106,7 @@ public struct Note: Codable {
108106
public let fixIts: [FixIt]
109107

110108
/// Constructs a new Note from the constituent parts.
111-
internal init(message: Diagnostic.Message, location: SourceLocation?,
109+
public init(message: Diagnostic.Message, location: SourceLocation?,
112110
highlights: [SourceRange], fixIts: [FixIt]) {
113111
precondition(message.severity == .note,
114112
"notes can only have the `note` severity")

Sources/SwiftSyntaxParser/DiagnosticEngine.swift renamed to Sources/SwiftSyntax/DiagnosticEngine.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
import Foundation
17-
import SwiftSyntax
1817

1918
/// The DiagnosticEngine allows Swift tools to emit diagnostics.
2019
public class DiagnosticEngine {
@@ -56,7 +55,7 @@ public class DiagnosticEngine {
5655
}
5756
}
5857

59-
internal var needsLineColumn: Bool {
58+
public var needsLineColumn: Bool {
6059
// Check if any consumer is interested in line and column.
6160
return consumers.first { $0.needsLineColumn } != nil
6261
}
@@ -71,7 +70,7 @@ public class DiagnosticEngine {
7170
}
7271
}
7372

74-
internal func diagnose(_ diagnostic: Diagnostic) {
73+
public func diagnose(_ diagnostic: Diagnostic) {
7574
diagnostics.append(diagnostic)
7675
for consumer in consumers {
7776
consumer.handle(diagnostic)

Sources/SwiftSyntaxParser/JSONDiagnosticConsumer.swift renamed to Sources/SwiftSyntax/JSONDiagnosticConsumer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
import Foundation
17-
import SwiftSyntax
1817

1918
public final class JSONDiagnosticConsumer: DiagnosticConsumer {
2019
/// Enumerates the possible places this consumer might output diagnostics.

utils/group.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
],
4141
"Parse": [
4242
"IncrementalParseTransition.swift",
43+
"Diagnostic.swift",
44+
"DiagnosticEngine.swift",
45+
"DiagnosticConsumer.swift",
46+
"JSONDiagnosticConsumer.swift",
47+
"PrintingDiagnosticConsumer.swift"
4348
],
4449
"Internal": [
4550
"_SyntaxParserInterop.swift",

0 commit comments

Comments
 (0)