Skip to content

Commit 040054f

Browse files
authored
Merge pull request #515 from swiftwasm/pr-f43735e0b9dfd04f7168e573bfa2ac569dce3906
BridgeJS: Merge small core files into single Misc.swift
2 parents 19b5504 + a2b9900 commit 040054f

File tree

4 files changed

+60
-49
lines changed

4 files changed

+60
-49
lines changed

Plugins/BridgeJS/Sources/BridgeJSCore/BridgeJSCoreError.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

Plugins/BridgeJS/Sources/BridgeJSCore/DiagnosticError.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

Plugins/BridgeJS/Sources/BridgeJSCore/BridgeJSConfig.swift renamed to Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
// MARK: - ProgressReporting
2+
3+
public struct ProgressReporting {
4+
let print: (String) -> Void
5+
6+
public init(verbose: Bool) {
7+
self.init(print: verbose ? { Swift.print($0) } : { _ in })
8+
}
9+
10+
private init(print: @escaping (String) -> Void) {
11+
self.print = print
12+
}
13+
14+
public static var silent: ProgressReporting {
15+
return ProgressReporting(print: { _ in })
16+
}
17+
18+
public func print(_ message: String) {
19+
self.print(message)
20+
}
21+
}
22+
23+
// MARK: - DiagnosticError
24+
25+
import SwiftSyntax
26+
27+
struct DiagnosticError: Error {
28+
let node: Syntax
29+
let message: String
30+
let hint: String?
31+
32+
init(node: some SyntaxProtocol, message: String, hint: String? = nil) {
33+
self.node = Syntax(node)
34+
self.message = message
35+
self.hint = hint
36+
}
37+
38+
func formattedDescription(fileName: String) -> String {
39+
let locationConverter = SourceLocationConverter(fileName: fileName, tree: node.root)
40+
let location = locationConverter.location(for: node.position)
41+
var description = "\(fileName):\(location.line):\(location.column): error: \(message)"
42+
if let hint {
43+
description += "\nHint: \(hint)"
44+
}
45+
return description
46+
}
47+
}
48+
49+
// MARK: - BridgeJSCoreError
50+
51+
public struct BridgeJSCoreError: Swift.Error, CustomStringConvertible {
52+
public let description: String
53+
54+
public init(_ message: String) {
55+
self.description = message
56+
}
57+
}
58+
59+
// MARK: - BridgeJSConfig
60+
161
import struct Foundation.URL
262
import struct Foundation.Data
363
import class Foundation.FileManager

Plugins/BridgeJS/Sources/BridgeJSCore/ProgressReporting.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)