From 96e3e58ccb86d5456225774a333d689a1dbfec37 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 17 Dec 2024 15:24:33 +0000 Subject: [PATCH] Remove unused Foundation imports Motivation: A few files unnecesarily import Foundation Modifications: Remove unused imports Result: Fewer dependencies --- Sources/GRPCCodeGen/CodeGenerationRequest.swift | 4 +--- .../GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift | 1 - Sources/GRPCCodeGen/Internal/Translator/Docs.swift | 6 +++--- Sources/GRPCCodeGen/Internal/TypeName.swift | 1 - 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Sources/GRPCCodeGen/CodeGenerationRequest.swift b/Sources/GRPCCodeGen/CodeGenerationRequest.swift index fbe545dbe..d6d0f73d1 100644 --- a/Sources/GRPCCodeGen/CodeGenerationRequest.swift +++ b/Sources/GRPCCodeGen/CodeGenerationRequest.swift @@ -14,8 +14,6 @@ * limitations under the License. */ -import Foundation - /// Describes the services, dependencies and trivia from an IDL file, /// and the IDL itself through its specific serializer and deserializer. public struct CodeGenerationRequest { @@ -334,7 +332,7 @@ extension Name { /// /// For example, if `base` is "Foo.Bar", then `normalizedBase` is "Foo_Bar". public var normalizedBase: String { - return self.base.replacingOccurrences(of: ".", with: "_") + return self.base.replacing(".", with: "_") } } diff --git a/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift b/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift index c7c6f3850..0900169c0 100644 --- a/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift +++ b/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift @@ -26,7 +26,6 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// -import Foundation /// An object for building up a generated file line-by-line. /// diff --git a/Sources/GRPCCodeGen/Internal/Translator/Docs.swift b/Sources/GRPCCodeGen/Internal/Translator/Docs.swift index c0017e293..f8c6def00 100644 --- a/Sources/GRPCCodeGen/Internal/Translator/Docs.swift +++ b/Sources/GRPCCodeGen/Internal/Translator/Docs.swift @@ -14,8 +14,6 @@ * limitations under the License. */ -import Foundation - package enum Docs { package static func suffix(_ header: String, withDocs footer: String) -> String { if footer.isEmpty { @@ -58,7 +56,9 @@ package enum Docs { """ let body = docs.split(separator: "\n").map { line in - "/// > " + line.dropFirst(4).trimmingCharacters(in: .whitespaces) + var line = "/// > " + line.dropFirst(4) + line.trimPrefix(while: { $0.isWhitespace }) + return String(line.drop(while: { $0.isWhitespace })) }.joined(separator: "\n") return header + "\n" + body diff --git a/Sources/GRPCCodeGen/Internal/TypeName.swift b/Sources/GRPCCodeGen/Internal/TypeName.swift index 0152de6a0..35d5eb77a 100644 --- a/Sources/GRPCCodeGen/Internal/TypeName.swift +++ b/Sources/GRPCCodeGen/Internal/TypeName.swift @@ -26,7 +26,6 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// -import Foundation /// A fully-qualified type name that contains the components of the Swift /// type name.