Skip to content

Commit 87f4305

Browse files
interpolation now expands correctly for more syntax
1 parent b1d41f4 commit 87f4305

File tree

9 files changed

+491
-142
lines changed

9 files changed

+491
-142
lines changed

Sources/HTMLKitUtilities/interpolation/ParseLiteral.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ extension HTMLKitUtilities {
132132
break
133133
}
134134
}
135-
return .interpolation(to_single_line(function))
135+
return .interpolation(function.singleLineDescription)
136136
}
137137
if expression.memberAccess != nil || expression.is(ForceUnwrapExprSyntax.self) {
138-
return .interpolation(to_single_line(expression))
138+
return .interpolation(expression.singleLineDescription)
139139
}
140140
if let array:ArrayExprSyntax = expression.array {
141141
let separator:String

Sources/HTMLKitUtilities/interpolation/ToSingleLine.swift

Lines changed: 0 additions & 139 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// DeclSLD.swift
3+
//
4+
//
5+
// Created by Evan Anderson on 11/29/24.
6+
//
7+
8+
import SwiftSyntax
9+
10+
public extension DeclSyntaxProtocol {
11+
var singleLineDescription : String {
12+
var string:String
13+
if let variable:VariableDeclSyntax = self.as(VariableDeclSyntax.self) {
14+
string = variable.singleLineDescription
15+
} else {
16+
string = "\(self)"
17+
//print("DeclSLD;DeclSyntax;singleLineDescription;self=" + self.debugDescription)
18+
return ""
19+
}
20+
string.stripLeadingAndTrailingWhitespace()
21+
return string
22+
}
23+
}
24+
25+
// MARK: VariableDecl
26+
public extension VariableDeclSyntax {
27+
var singleLineDescription : String {
28+
var string:String = bindingSpecifier.text + " "
29+
for binding in bindings {
30+
string += binding.singleLineDescription
31+
}
32+
return string
33+
}
34+
}

0 commit comments

Comments
 (0)