Skip to content

Commit 46a05ce

Browse files
committed
Java2SwiftPlugin: Drop the ability to infer Swift type names
The configuration file should be explicit. If we want to infer Swift type names, we should do it when generating the configuration file.
1 parent 4b3387d commit 46a05ce

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

Plugins/Java2SwiftPlugin/Configuration.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct Configuration: Codable {
2020

2121
/// The Java classes that should be translated to Swift. The keys are
2222
/// canonical Java class names (e.g., java.util.Vector) and the values are
23-
/// the corresponding Swift names (e.g., JavaVector). If the value is `nil`,
24-
/// then the Java class name will be used for the Swift name, too.
25-
var classes: [String: String?] = [:]
23+
/// the corresponding Swift names (e.g., JavaVector).
24+
var classes: [String: String] = [:]
2625
}

Plugins/Java2SwiftPlugin/Java2SwiftPlugin.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ struct Java2SwiftBuildToolPlugin: BuildToolPlugin {
7575
/// Determine the list of Java classes that will be translated into Swift,
7676
/// along with the names of the corresponding Swift types. This will be
7777
/// passed along to the Java2Swift tool.
78-
let classes = config.classes.map { (javaClassName, swiftName) in
79-
(javaClassName, swiftName ?? javaClassName.defaultSwiftNameForJavaClass)
80-
}.sorted { (lhs, rhs) in
78+
let classes = config.classes.sorted { (lhs, rhs) in
8179
lhs.0 < rhs.0
8280
}
8381

@@ -139,16 +137,3 @@ func findJavaHome() -> String {
139137

140138
fatalError("Please set the JAVA_HOME environment variable to point to where Java is installed.")
141139
}
142-
143-
extension String {
144-
/// For a String that's of the form java.util.Vector, return the "Vector"
145-
/// part.
146-
fileprivate var defaultSwiftNameForJavaClass: String {
147-
if let dotLoc = lastIndex(of: ".") {
148-
let afterDot = index(after: dotLoc)
149-
return String(self[afterDot...])
150-
}
151-
152-
return self
153-
}
154-
}

0 commit comments

Comments
 (0)