Skip to content

Commit

Permalink
Merge all properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Nov 16, 2023
1 parent d4e3433 commit 84827df
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,23 @@ private fun AvkBuilder.Companion.from(
parseDocs: Element.() -> String?
): AvkBuilder {

// Merge the set of all properties with setters and builders
val allProperties = builderContext.setters().keys + builderContext.propertyBuilders().keys

// Setters
val props =
builderContext.setters().entries.map { (prop, setters) ->
allProperties.map { prop ->
val setters = builderContext.setters()[prop] ?: emptyList()
val propertyBuilder =
builderContext.propertyBuilders()[prop]?.let { propertyBuilder ->
FunSpec.copyOf(propertyBuilder).withDocsFrom(propertyBuilder, parseDocs).build()
}
val type = propertyTypes.getValue(prop)
BuilderProperty(
prop,
type,
setters.mapTo(LinkedHashSet()) { FunSpec.copyOf(it).withDocsFrom(it, parseDocs).build() },
builderContext.propertyBuilders()[prop]?.let { propertyBuilder ->
FunSpec.copyOf(propertyBuilder).withDocsFrom(propertyBuilder, parseDocs).build()
}
propertyBuilder
)
}

Expand Down

0 comments on commit 84827df

Please sign in to comment.