Skip to content

Commit faec856

Browse files
committed
Drop Diagnostic prefix from types moved to the Diagnostics module
1 parent 39473d8 commit faec856

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

Sources/Diagnostics/Diagnostic.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public struct Diagnostic {
3030
}
3131

3232
/// An ID that identifies the diagnostic's message.
33-
/// See ``DiagnosticMessageID``.
34-
public var diagnosticID: DiagnosticMessageID {
33+
/// See ``MessageID``.
34+
public var diagnosticID: MessageID {
3535
return diagMessage.diagnosticID
3636
}
3737

Sources/Diagnostics/DiagnosticMessage.swift renamed to Sources/Diagnostics/Message.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- DiagnosticMessage.swift ------------------------------------------===//
1+
//===--- Message.swift ----------------------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -17,7 +17,7 @@
1717
/// Two diagnostics with the same ID don’t need to necessarily have the exact
1818
/// same wording. Eg. it’s possible that the message contains more context when
1919
/// available.
20-
public struct DiagnosticMessageID: Hashable {
20+
public struct MessageID: Hashable {
2121
private let value: String
2222

2323
public init(_ value: String) {
@@ -31,6 +31,6 @@ public protocol DiagnosticMessage {
3131
/// The diagnostic message that should be displayed in the client.
3232
var message: String { get }
3333

34-
/// See ``DiagnosticMessageID``.
35-
var diagnosticID: DiagnosticMessageID { get }
34+
/// See ``MessageID``.
35+
var diagnosticID: MessageID { get }
3636
}

Sources/SwiftParser/Diagnostics/ParserDiagnosticMessages.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,28 @@ extension Syntax {
3636
}
3737
}
3838

39-
40-
/// A diagnostic how's ID is determined by the diagnostic's type.
41-
public protocol TypedDiagnosticMessage: DiagnosticMessage {
42-
var diagnosticID: DiagnosticMessageID { get }
39+
/// A diagnostic whose ID is determined by the diagnostic's type.
40+
public protocol DiagnosticMessageType: DiagnosticMessage {
41+
var diagnosticID: MessageID { get }
4342
}
4443

45-
public extension TypedDiagnosticMessage {
46-
static var diagnosticID: DiagnosticMessageID {
47-
return DiagnosticMessageID("\(self)")
44+
public extension DiagnosticMessageType {
45+
static var diagnosticID: MessageID {
46+
return MessageID("\(self)")
4847
}
4948

50-
var diagnosticID: DiagnosticMessageID {
49+
var diagnosticID: MessageID {
5150
return Self.diagnosticID
5251
}
5352
}
5453

55-
5654
// MARK: - Diagnostics (please sort alphabetically)
5755

58-
public struct CStyleForLoopDiagnostic: TypedDiagnosticMessage {
56+
public struct CStyleForLoopDiagnostic: DiagnosticMessageType {
5957
public var message = "C-style for statement has been removed in Swift 3"
6058
}
6159

62-
public struct MissingTokenDiagnostic: TypedDiagnosticMessage {
60+
public struct MissingTokenDiagnostic: DiagnosticMessageType {
6361
public let missingToken: TokenSyntax
6462

6563
public var message: String {
@@ -82,11 +80,11 @@ public struct MissingTokenDiagnostic: TypedDiagnosticMessage {
8280
}
8381
}
8482

85-
public struct ThrowsInReturnPositionDiagnostic: TypedDiagnosticMessage {
83+
public struct ThrowsInReturnPositionDiagnostic: DiagnosticMessageType {
8684
public let message = "'throws' may only occur before '->'"
8785
}
8886

89-
public struct UnexpectedNodesDiagnostic: TypedDiagnosticMessage {
87+
public struct UnexpectedNodesDiagnostic: DiagnosticMessageType {
9088
public let unexpectedNodes: UnexpectedNodesSyntax
9189

9290
public var message: String {

Tests/SwiftParserTest/DiagnosticAssertions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func XCTAssertDiagnostic<T: SyntaxProtocol>(
1313
in tree: T,
1414
line: Int,
1515
column: Int,
16-
id: DiagnosticMessageID? = nil,
16+
id: MessageID? = nil,
1717
message: String? = nil,
1818
testFile: StaticString = #filePath,
1919
testLine: UInt = #line
@@ -38,7 +38,7 @@ func XCTAssertSingleDiagnostic<T: SyntaxProtocol>(
3838
in tree: T,
3939
line: Int,
4040
column: Int,
41-
id: DiagnosticMessageID? = nil,
41+
id: MessageID? = nil,
4242
message: String? = nil,
4343
testFile: StaticString = #filePath,
4444
testLine: UInt = #line

Tests/SwiftParserTest/DiagnosticInfrastructureTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import SwiftParser
44

55
public class DiagnosticInfrastructureTests: XCTestCase {
66
public func testDiagnosticID() throws {
7-
struct TestDiagnostic: TypedDiagnosticMessage {
7+
struct TestDiagnostic: DiagnosticMessageType {
88
let message: String = "My test diagnostic"
99
}
1010

1111
let diag = TestDiagnostic()
12-
XCTAssertEqual(diag.diagnosticID, DiagnosticMessageID("TestDiagnostic"))
12+
XCTAssertEqual(diag.diagnosticID, MessageID("TestDiagnostic"))
1313
XCTAssertEqual(diag.message, "My test diagnostic")
1414
}
1515
}

0 commit comments

Comments
 (0)