Fix value qualified statements in interfaces.
Also fix the qualified interface name for non-functional properties in the LessThan method.
このコミットが含まれているのは:
コミット
8b8cc2af27
|
@ -446,8 +446,8 @@ func (c Converter) convertValue(v rdf.VocabularyValue) (k *props.Kind) {
|
|||
k = &props.Kind{
|
||||
Name: c.toIdentifier(v),
|
||||
// TODO: Add Qualifier
|
||||
ConcreteKind: jen.Id(v.DefinitionType),
|
||||
Nilable: c.isNilable(v.DefinitionType),
|
||||
ConcreteKind: v.DefinitionType,
|
||||
Nilable: v.IsNilable,
|
||||
SerializeFn: s.QualifiedName(),
|
||||
DeserializeFn: d.QualifiedName(),
|
||||
LessFn: l.QualifiedName(),
|
||||
|
@ -643,10 +643,6 @@ func (c Converter) toIdentifier(n rdf.NameGetter) props.Identifier {
|
|||
}
|
||||
}
|
||||
|
||||
func (c Converter) isNilable(goType string) bool {
|
||||
return goType[0] == '*'
|
||||
}
|
||||
|
||||
func allExtendsAreIn(t rdf.VocabularyType, v map[string]*props.TypeGenerator) bool {
|
||||
for _, e := range t.Extends {
|
||||
if len(e.Vocab) != 0 {
|
||||
|
|
|
@ -277,7 +277,7 @@ func (p *NonFunctionalPropertyGenerator) funcs() []*codegen.Method {
|
|||
p.GetPrivatePackage().Path(),
|
||||
compareLessMethod,
|
||||
p.StructName(),
|
||||
[]jen.Code{jen.Id("o").Id(p.InterfaceName())},
|
||||
[]jen.Code{jen.Id("o").Qual(p.GetPublicPackage().Path(), p.InterfaceName())},
|
||||
[]jen.Code{jen.Bool()},
|
||||
[]jen.Code{
|
||||
lessCode,
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"github.com/cjslep/activity/tools/exp/codegen"
|
||||
"github.com/dave/jennifer/jen"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
|
@ -104,8 +105,9 @@ func (v *Vocabulary) SetValue(name string, a *VocabularyValue) error {
|
|||
type VocabularyValue struct {
|
||||
Name string
|
||||
URI *url.URL
|
||||
DefinitionType string
|
||||
DefinitionType *jen.Statement
|
||||
Zero string
|
||||
IsNilable bool
|
||||
SerializeFn *codegen.Function
|
||||
DeserializeFn *codegen.Function
|
||||
LessFn *codegen.Function
|
||||
|
|
|
@ -155,8 +155,9 @@ func (l *langstring) Apply(key string, value interface{}, ctx *ParsingContext) (
|
|||
e = ctx.Result.GetReference(rdfSpec).SetValue(langstringSpec, &VocabularyValue{
|
||||
Name: langstringSpec,
|
||||
URI: u,
|
||||
DefinitionType: "map[string]string",
|
||||
Zero: "nil",
|
||||
DefinitionType: jen.Map(jen.String()).String(),
|
||||
Zero: "make(map[string]string)",
|
||||
IsNilable: true,
|
||||
SerializeFn: SerializeValueFunction(
|
||||
l.pkg,
|
||||
langstringSpec,
|
||||
|
|
|
@ -197,8 +197,9 @@ func (a *anyURI) Apply(key string, value interface{}, ctx *rdf.ParsingContext) (
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: anyURISpec,
|
||||
URI: u,
|
||||
DefinitionType: "*url.URL",
|
||||
DefinitionType: jen.Op("*").Qual("net/url", "URL"),
|
||||
Zero: "&url.URL{}",
|
||||
IsNilable: true,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
a.pkg,
|
||||
anyURISpec,
|
||||
|
@ -288,8 +289,9 @@ func (d *dateTime) Apply(key string, value interface{}, ctx *rdf.ParsingContext)
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: dateTimeSpec,
|
||||
URI: u,
|
||||
DefinitionType: "time.Time",
|
||||
DefinitionType: jen.Qual("time", "Time"),
|
||||
Zero: "&time.Time{}",
|
||||
IsNilable: false,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
d.pkg,
|
||||
dateTimeSpec,
|
||||
|
@ -390,8 +392,9 @@ func (f *float) Apply(key string, value interface{}, ctx *rdf.ParsingContext) (b
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: floatSpec,
|
||||
URI: u,
|
||||
DefinitionType: "float32",
|
||||
DefinitionType: jen.Float32(),
|
||||
Zero: "0.0",
|
||||
IsNilable: false,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
f.pkg,
|
||||
floatSpec,
|
||||
|
@ -469,8 +472,9 @@ func (s *xmlString) Apply(key string, value interface{}, ctx *rdf.ParsingContext
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: stringSpec,
|
||||
URI: u,
|
||||
DefinitionType: "string",
|
||||
DefinitionType: jen.String(),
|
||||
Zero: "\"\"",
|
||||
IsNilable: false,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
s.pkg,
|
||||
stringSpec,
|
||||
|
@ -548,8 +552,9 @@ func (b *boolean) Apply(key string, value interface{}, ctx *rdf.ParsingContext)
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: booleanSpec,
|
||||
URI: u,
|
||||
DefinitionType: "bool",
|
||||
DefinitionType: jen.Bool(),
|
||||
Zero: "false",
|
||||
IsNilable: false,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
b.pkg,
|
||||
booleanSpec,
|
||||
|
@ -658,8 +663,9 @@ func (n *nonNegativeInteger) Apply(key string, value interface{}, ctx *rdf.Parsi
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: nonNegativeIntegerSpec,
|
||||
URI: u,
|
||||
DefinitionType: "int",
|
||||
DefinitionType: jen.Int(),
|
||||
Zero: "0",
|
||||
IsNilable: false,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
n.pkg,
|
||||
nonNegativeIntegerSpec,
|
||||
|
@ -750,8 +756,9 @@ func (d *duration) Apply(key string, value interface{}, ctx *rdf.ParsingContext)
|
|||
val := &rdf.VocabularyValue{
|
||||
Name: durationSpec,
|
||||
URI: u,
|
||||
DefinitionType: "time.Duration",
|
||||
DefinitionType: jen.Qual("time", "Duration"),
|
||||
Zero: "time.Duration(0)",
|
||||
IsNilable: false,
|
||||
SerializeFn: rdf.SerializeValueFunction(
|
||||
d.pkg,
|
||||
durationSpec,
|
||||
|
|
読み込み中…
新しいイシューから参照