Skip to content

Commit 43a88d4

Browse files
committed
BridgeJS: fix: run swiftformat
1 parent 1bf6c12 commit 43a88d4

File tree

4 files changed

+156
-142
lines changed

4 files changed

+156
-142
lines changed

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ class ExportSwift {
126126
guard let jsAttribute = node.attributes.firstJSAttribute else {
127127
return nil
128128
}
129-
129+
130130
let name = node.name.text
131131
let namespace = extractNamespace(from: jsAttribute)
132-
132+
133133
if namespace != nil, case .classBody = state {
134134
diagnose(
135135
node: jsAttribute,
136136
message: "Namespace is only needed in top-level declaration",
137137
hint: "Remove the namespace from @JS attribute or move this function to top-level"
138138
)
139139
}
140-
140+
141141
var parameters: [Parameter] = []
142142
for param in node.signature.parameterClause.parameters {
143143
guard let type = self.parent.lookupType(for: param.type) else {
@@ -204,14 +204,15 @@ class ExportSwift {
204204
}
205205
return Effects(isAsync: isAsync, isThrows: isThrows)
206206
}
207-
207+
208208
private func extractNamespace(
209209
from jsAttribute: AttributeSyntax
210210
) -> [String]? {
211211
guard let arguments = jsAttribute.arguments?.as(LabeledExprListSyntax.self),
212-
let firstArg = arguments.first?.expression.as(StringLiteralExprSyntax.self),
213-
let namespaceString = firstArg.segments.first?.as(StringSegmentSyntax.self)?.content.text else {
214-
return nil
212+
let firstArg = arguments.first?.expression.as(StringLiteralExprSyntax.self),
213+
let namespaceString = firstArg.segments.first?.as(StringSegmentSyntax.self)?.content.text
214+
else {
215+
return nil
215216
}
216217
return namespaceString.split(separator: ".").map(String.init)
217218
}
@@ -222,17 +223,18 @@ class ExportSwift {
222223
diagnose(node: node, message: "@JS init must be inside a @JS class")
223224
return .skipChildren
224225
}
225-
226+
226227
if let jsAttribute = node.attributes.firstJSAttribute,
227-
let namespace = extractNamespace(from: jsAttribute),
228-
namespace != nil {
228+
let namespace = extractNamespace(from: jsAttribute),
229+
namespace != nil
230+
{
229231
diagnose(
230232
node: jsAttribute,
231233
message: "Namespace is not supported for initializer declarations",
232234
hint: "Remove the namespace from @JS attribute"
233235
)
234236
}
235-
237+
236238
var parameters: [Parameter] = []
237239
for param in node.signature.parameterClause.parameters {
238240
guard let type = self.parent.lookupType(for: param.type) else {
@@ -259,7 +261,7 @@ class ExportSwift {
259261

260262
override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind {
261263
let name = node.name.text
262-
264+
263265
stateStack.push(state: .classBody(name: name))
264266

265267
guard let jsAttribute = node.attributes.firstJSAttribute else { return .skipChildren }
@@ -675,7 +677,7 @@ extension AttributeListSyntax {
675677
fileprivate func hasJSAttribute() -> Bool {
676678
firstJSAttribute != nil
677679
}
678-
680+
679681
fileprivate var firstJSAttribute: AttributeSyntax? {
680682
first(where: {
681683
$0.as(AttributeSyntax.self)?.attributeName.trimmedDescription == "JS"

0 commit comments

Comments
 (0)