File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,3 +130,4 @@ disabled_rules:
130130 - closure_parameter_position
131131 - trailing_comma
132132 - opening_brace
133+ - optional_data_string_conversion
Original file line number Diff line number Diff line change 33
44import PackageDescription
55
6+ // swiftlint:disable:next explicit_top_level_acl explicit_acl
67let package = Package (
78 name: " SyntaxKit " ,
89 platforms: [
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ public enum Literal: CodeBlock {
5151 /// A boolean literal.
5252 case boolean( Bool )
5353
54+ /// The SwiftSyntax representation of this literal.
5455 public var syntax : SyntaxProtocol {
5556 switch self {
5657 case . string( let value) :
@@ -77,8 +78,10 @@ public enum Literal: CodeBlock {
7778// MARK: - LiteralValue Implementations
7879
7980extension Array : LiteralValue where Element == String {
81+ /// The Swift type name for an array of strings.
8082 public var typeName : String { " [String] " }
8183
84+ /// Renders this array as a Swift literal string with proper escaping.
8285 public var literalString : String {
8386 let elements = self . map { element in
8487 // Escape quotes and newlines
@@ -96,8 +99,10 @@ extension Array: LiteralValue where Element == String {
9699}
97100
98101extension Dictionary : LiteralValue where Key == Int , Value == String {
102+ /// The Swift type name for a dictionary mapping integers to strings.
99103 public var typeName : String { " [Int: String] " }
100104
105+ /// Renders this dictionary as a Swift literal string with proper escaping.
101106 public var literalString : String {
102107 let elements = self . map { key, value in
103108 // Escape quotes and newlines
Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ package enum SyntaxParser {
5151
5252 let tree = visitor. tree
5353 let encoder = JSONEncoder ( )
54- let json = String ( decoding: try encoder. encode ( tree) , as: UTF8 . self)
54+ let data = try encoder. encode ( tree)
55+ let json = String ( decoding: data, as: UTF8 . self)
5556
5657 return SyntaxResponse ( syntaxJSON: json)
5758 }
You can’t perform that action at this time.
0 commit comments