mirror of
https://gitea.com/gitea/go-fed-activity.git
synced 2024-06-01 09:46:47 +05:30
Fix astool bug to properly alias properties and types
This commit is contained in:
parent
bf196748f9
commit
b5a6786f9e
|
@ -1202,8 +1202,16 @@ func (p *FunctionalPropertyGenerator) hasValueKind() bool {
|
|||
|
||||
// nameMethod returns the Name method for this functional property.
|
||||
func (p *FunctionalPropertyGenerator) nameMethod() *codegen.Method {
|
||||
nameImpl := jen.Return(
|
||||
jen.Lit(p.PropertyName()),
|
||||
nameImpl := jen.If(
|
||||
jen.Len(jen.Id(codegen.This()).Dot(aliasMember)).Op(">").Lit(0),
|
||||
).Block(
|
||||
jen.Return(
|
||||
jen.Id(codegen.This()).Dot(aliasMember).Op("+").Lit(":").Op("+").Lit(p.PropertyName()),
|
||||
),
|
||||
).Else().Block(
|
||||
jen.Return(
|
||||
jen.Lit(p.PropertyName()),
|
||||
),
|
||||
)
|
||||
if p.hasNaturalLanguageMap {
|
||||
nameImpl = jen.If(
|
||||
|
|
|
@ -1029,8 +1029,16 @@ func (p *NonFunctionalPropertyGenerator) thisIRI() *jen.Statement {
|
|||
|
||||
// nameMethod returns the Name method for this non-functional property.
|
||||
func (p *NonFunctionalPropertyGenerator) nameMethod() *codegen.Method {
|
||||
nameImpl := jen.Return(
|
||||
jen.Lit(p.PropertyName()),
|
||||
nameImpl := jen.If(
|
||||
jen.Len(jen.Id(codegen.This()).Dot(aliasMember)).Op(">").Lit(0),
|
||||
).Block(
|
||||
jen.Return(
|
||||
jen.Id(codegen.This()).Dot(aliasMember).Op("+").Lit(":").Op("+").Lit(p.PropertyName()),
|
||||
),
|
||||
).Else().Block(
|
||||
jen.Return(
|
||||
jen.Lit(p.PropertyName()),
|
||||
),
|
||||
)
|
||||
if p.hasNaturalLanguageMap {
|
||||
nameImpl = jen.If(
|
||||
|
@ -1056,6 +1064,6 @@ func (p *NonFunctionalPropertyGenerator) nameMethod() *codegen.Method {
|
|||
[]jen.Code{
|
||||
nameImpl,
|
||||
},
|
||||
fmt.Sprintf("%s returns the name of this property: %q.", nameMethod, p.PropertyName()),
|
||||
fmt.Sprintf("%s returns the name of this property (%q) with any alias.", nameMethod, p.PropertyName()),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1072,6 +1072,10 @@ func (t *TypeGenerator) getAllManagerMethods() (m []*codegen.Method) {
|
|||
|
||||
// constructorFn creates a constructor for this type.
|
||||
func (t *TypeGenerator) constructorFn() *codegen.Function {
|
||||
typeName := jen.Lit(t.TypeName())
|
||||
if len(t.vocabAlias) > 0 {
|
||||
typeName = jen.Lit(t.vocabAlias).Op("+").Lit(":").Op("+").Lit(t.TypeName())
|
||||
}
|
||||
return codegen.NewCommentedFunction(
|
||||
t.PrivatePackage().Path(),
|
||||
fmt.Sprintf("%s%s", constructorName, t.StructName()),
|
||||
|
@ -1081,7 +1085,7 @@ func (t *TypeGenerator) constructorFn() *codegen.Function {
|
|||
},
|
||||
[]jen.Code{
|
||||
jen.Id("typeProp").Op(":=").Id(typePropertyConstructorName()).Call(),
|
||||
jen.Id("typeProp").Dot("AppendXMLSchemaString").Call(jen.Lit(t.TypeName())),
|
||||
jen.Id("typeProp").Dot("AppendXMLSchemaString").Call(typeName),
|
||||
jen.Return(
|
||||
jen.Op("&").Qual(t.PrivatePackage().Path(), t.StructName()).Values(
|
||||
jen.Dict{
|
||||
|
|
Loading…
Reference in a new issue