Address two TODOs

This commit is contained in:
Cory Slep 2019-01-08 20:37:04 +01:00
parent f2c70191ab
commit a4f90ff8e0
4 changed files with 10 additions and 15 deletions

View file

@ -216,6 +216,7 @@ func (m *ManagerGenerator) createDeserializationMethod(deserName string, pubPkg,
jen.Error(),
).Block(
jen.List(
// Note: this "i" must be the same as the "i" in the deserialization definition.
jen.Id("i"),
jen.Err(),
).Op(":=").Qual(privPkg.Path(), deserName).Call(jen.Id("m")),

View file

@ -77,21 +77,9 @@ func (p *NonFunctionalPropertyGenerator) Definitions() (*codegen.Struct, *codege
return p.cachedStruct, p.cachedTypedef
}
// iteratorTypeName determines the identifier to use for the iterator type.
func (p *NonFunctionalPropertyGenerator) iteratorTypeName() Identifier {
return Identifier{
LowerName: p.Name.LowerName,
CamelName: fmt.Sprintf("%sPropertyIterator", p.Name.CamelName),
}
}
// iteratorInterfaceName gets the interface name for the iterator.
//
// TODO: Fix this kluge, which must be kept in sync with
// PropertyGenerator.InterfaceName().
func (p *NonFunctionalPropertyGenerator) iteratorInterfaceName() string {
id := p.iteratorTypeName()
return fmt.Sprintf("%sInterface", id.CamelName)
return fmt.Sprintf("%sInterface", p.iteratorTypeName().CamelName)
}
// elementTypeGenerator produces a FunctionalPropertyGenerator for the iterator

View file

@ -192,6 +192,14 @@ func (p *PropertyGenerator) StructName() string {
return fmt.Sprintf("%sProperty", p.Name.CamelName)
}
// iteratorTypeName determines the identifier to use for the iterator type.
func (p *PropertyGenerator) iteratorTypeName() Identifier {
return Identifier{
LowerName: p.Name.LowerName,
CamelName: fmt.Sprintf("%sPropertyIterator", p.Name.CamelName),
}
}
// InterfaceName returns the interface name of the property type.
func (p *PropertyGenerator) InterfaceName() string {
return fmt.Sprintf("%sInterface", p.StructName())

View file

@ -130,8 +130,6 @@ func NewTypeGenerator(vocabName string, pm *PackageManager, typeName, comment st
func (t *TypeGenerator) apply(m *ManagerGenerator) error {
t.m = m
// Set up Kind functions
// Note: this "i" must be the same as the "i" in the deserialization definition.
// TODO: Remove this kluge. (2nd todo: figure out wtf this todo means)
deser := m.getDeserializationMethodForType(t)
kind := jen.Qual(t.PublicPackage().Path(), t.InterfaceName())
for _, p := range t.rangeProperties {