Skip to content

Commit 0ed78d2

Browse files
author
yzhou
committed
hook up imports from plugins in generator
1 parent af8dc02 commit 0ed78d2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Sources/ImmutableSwift/generating/Generator.swift

+19
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ class Generator {
88
output = output + Generator.ImportsToString(datamodel.imports!) + "\n"
99
}
1010

11+
if pluginList != nil {
12+
let importsFromPlugins = Generator.GenerateImportsWithPluginList(pluginList!)
13+
if importsFromPlugins.count > 0{
14+
output = output + importsFromPlugins + "\n"
15+
}
16+
}
17+
1118
// optional accesscontrol
1219
if datamodel.accessControlLevel != nil {
1320
output = output + Generator.AccessControlLevelToString(datamodel.accessControlLevel!) + " "
@@ -76,6 +83,18 @@ class Generator {
7683
return output
7784
}
7885

86+
static func GenerateImportsWithPluginList(_ pluginList: PluginList) -> String {
87+
var imports: Set<String> = []
88+
for pluginName in pluginList.plugins {
89+
if Plugins.PLUGIN_MAP[pluginName] != nil {
90+
for importFromPlugin in Plugins.PLUGIN_MAP[pluginName]!.imports() {
91+
imports.insert("import "+importFromPlugin)
92+
}
93+
}
94+
}
95+
return imports.joined(separator: "\n") + "\n"
96+
}
97+
7998
static func AccessControlLevelToString(_ accessControl: AccessControl) -> String {
8099
switch accessControl {
81100
case AccessControl.levelPublic:

0 commit comments

Comments
 (0)