From 24152cb8970d99f81f1d3426b9a4da86e73d6e48 Mon Sep 17 00:00:00 2001 From: Tien Nguyen Date: Fri, 1 Mar 2019 03:06:48 +0700 Subject: [PATCH] Generate initializer in case multiple variable defined in a line. --- SourceEditorExtension/SIG.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SourceEditorExtension/SIG.swift b/SourceEditorExtension/SIG.swift index 1a52ffb..7c2259a 100644 --- a/SourceEditorExtension/SIG.swift +++ b/SourceEditorExtension/SIG.swift @@ -46,7 +46,12 @@ func generate(selection: [String], indentation: String, leadingIndent: String) t let variableType = scanner.scanUpTo("\n") else { throw SIGError.parseError } - variables.append((variableName, variableType)) + + // In case multiple variables defined in a line. + let variableNames = variableName.components(separatedBy: ",") + for vname in variableNames { + variables.append((vname.trimmingCharacters(in: .whitespaces), variableType)) + } } let arguments = variables.map { "\($0.0): \(addEscapingAttributeIfNeeded(to: $0.1))" }.joined(separator: ", ")