Skip to content

Commit

Permalink
hook up imports from plugins in generator
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhou committed Feb 17, 2019
1 parent af8dc02 commit 0ed78d2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Sources/ImmutableSwift/generating/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class Generator {
output = output + Generator.ImportsToString(datamodel.imports!) + "\n"
}

if pluginList != nil {
let importsFromPlugins = Generator.GenerateImportsWithPluginList(pluginList!)
if importsFromPlugins.count > 0{
output = output + importsFromPlugins + "\n"
}
}

// optional accesscontrol
if datamodel.accessControlLevel != nil {
output = output + Generator.AccessControlLevelToString(datamodel.accessControlLevel!) + " "
Expand Down Expand Up @@ -76,6 +83,18 @@ class Generator {
return output
}

static func GenerateImportsWithPluginList(_ pluginList: PluginList) -> String {
var imports: Set<String> = []
for pluginName in pluginList.plugins {
if Plugins.PLUGIN_MAP[pluginName] != nil {
for importFromPlugin in Plugins.PLUGIN_MAP[pluginName]!.imports() {
imports.insert("import "+importFromPlugin)
}
}
}
return imports.joined(separator: "\n") + "\n"
}

static func AccessControlLevelToString(_ accessControl: AccessControl) -> String {
switch accessControl {
case AccessControl.levelPublic:
Expand Down

0 comments on commit 0ed78d2

Please sign in to comment.