Skip to content

Commit e1ad6f7

Browse files
committed
linting fixes
1 parent c68750f commit e1ad6f7

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ disabled_rules:
130130
- closure_parameter_position
131131
- trailing_comma
132132
- opening_brace
133+
- optional_data_string_conversion

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import PackageDescription
55

6+
// swiftlint:disable:next explicit_top_level_acl explicit_acl
67
let package = Package(
78
name: "SyntaxKit",
89
platforms: [

Sources/SyntaxKit/Literal.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

7980
extension 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

98101
extension 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

Sources/SyntaxKit/parser/SyntaxParser.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)