fix linter warnings.
このコミットが含まれているのは:
コミット
3ff5423014
|
@ -195,7 +195,7 @@ func (m Method) Definition() jen.Code {
|
||||||
if len(m.function.comment) > 0 {
|
if len(m.function.comment) > 0 {
|
||||||
comment = jen.Commentf(insertNewlines(m.function.comment)).Line()
|
comment = jen.Commentf(insertNewlines(m.function.comment)).Line()
|
||||||
}
|
}
|
||||||
funcDef := jen.Empty()
|
var funcDef *jen.Statement
|
||||||
switch m.member {
|
switch m.member {
|
||||||
case pointerMember:
|
case pointerMember:
|
||||||
funcDef = jen.Func().Params(
|
funcDef = jen.Func().Params(
|
||||||
|
|
|
@ -69,8 +69,8 @@ func (s *Struct) Definition() jen.Code {
|
||||||
for _, m := range s.methods {
|
for _, m := range s.methods {
|
||||||
ms = append(ms, m.Name())
|
ms = append(ms, m.Name())
|
||||||
}
|
}
|
||||||
sort.Sort(sort.StringSlice(fs))
|
sort.Strings(fs)
|
||||||
sort.Sort(sort.StringSlice(ms))
|
sort.Strings(ms)
|
||||||
// Add the functions and methods in order.
|
// Add the functions and methods in order.
|
||||||
for _, c := range fs {
|
for _, c := range fs {
|
||||||
def = def.Line().Line().Add(s.constructors[c].Definition())
|
def = def.Line().Line().Add(s.constructors[c].Definition())
|
||||||
|
|
|
@ -59,8 +59,8 @@ func (t *Typedef) Definition() jen.Code {
|
||||||
for _, m := range t.methods {
|
for _, m := range t.methods {
|
||||||
ms = append(ms, m.Name())
|
ms = append(ms, m.Name())
|
||||||
}
|
}
|
||||||
sort.Sort(sort.StringSlice(fs))
|
sort.Strings(fs)
|
||||||
sort.Sort(sort.StringSlice(ms))
|
sort.Strings(ms)
|
||||||
// Add the functions and methods in order
|
// Add the functions and methods in order
|
||||||
for _, c := range fs {
|
for _, c := range fs {
|
||||||
def = def.Line().Line().Add(t.constructors[c].Definition())
|
def = def.Line().Line().Add(t.constructors[c].Definition())
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
interfacePkg = "vocab"
|
interfacePkg = "vocab"
|
||||||
resolverPkg = "resolver"
|
|
||||||
typePropertyName = "type"
|
typePropertyName = "type"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -43,11 +42,11 @@ type vocabulary struct {
|
||||||
// newVocabulary creates a vocabulary with maps already made.
|
// newVocabulary creates a vocabulary with maps already made.
|
||||||
func newVocabulary() vocabulary {
|
func newVocabulary() vocabulary {
|
||||||
return vocabulary{
|
return vocabulary{
|
||||||
Values: make(map[string]*gen.Kind, 0),
|
Values: make(map[string]*gen.Kind),
|
||||||
FProps: make(map[string]*gen.FunctionalPropertyGenerator, 0),
|
FProps: make(map[string]*gen.FunctionalPropertyGenerator),
|
||||||
NFProps: make(map[string]*gen.NonFunctionalPropertyGenerator, 0),
|
NFProps: make(map[string]*gen.NonFunctionalPropertyGenerator),
|
||||||
Types: make(map[string]*gen.TypeGenerator, 0),
|
Types: make(map[string]*gen.TypeGenerator),
|
||||||
References: make(map[string]*vocabulary, 0),
|
References: make(map[string]*vocabulary),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +273,7 @@ func (c *Converter) Convert(p *rdf.ParsedVocabulary) (f []*File, e error) {
|
||||||
// all vocabularies and results in a flattened converted map.
|
// all vocabularies and results in a flattened converted map.
|
||||||
func (c *Converter) convertReferenceVocabularyRecursively(skip map[string]bool, p *rdf.ParsedVocabulary, refs map[string]*vocabulary) (v map[string]*vocabulary, e error) {
|
func (c *Converter) convertReferenceVocabularyRecursively(skip map[string]bool, p *rdf.ParsedVocabulary, refs map[string]*vocabulary) (v map[string]*vocabulary, e error) {
|
||||||
v = make(map[string]*vocabulary)
|
v = make(map[string]*vocabulary)
|
||||||
for k, _ := range p.References {
|
for k := range p.References {
|
||||||
if skip[k] {
|
if skip[k] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ func (p *FunctionalPropertyGenerator) multiTypeClearNonLanguageMapMembers() []je
|
||||||
// funcs produces the methods needed for the functional property.
|
// funcs produces the methods needed for the functional property.
|
||||||
func (p *FunctionalPropertyGenerator) funcs() []*codegen.Method {
|
func (p *FunctionalPropertyGenerator) funcs() []*codegen.Method {
|
||||||
kindIndexFns := make([]jen.Code, 0, len(p.kinds)+1)
|
kindIndexFns := make([]jen.Code, 0, len(p.kinds)+1)
|
||||||
for i, _ := range p.kinds {
|
for i := range p.kinds {
|
||||||
kindIndexFns = append(kindIndexFns, jen.If(
|
kindIndexFns = append(kindIndexFns, jen.If(
|
||||||
jen.Id(codegen.This()).Dot(p.isMethodName(i)).Call(),
|
jen.Id(codegen.This()).Dot(p.isMethodName(i)).Call(),
|
||||||
).Block(
|
).Block(
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dave/jennifer/jen"
|
"github.com/dave/jennifer/jen"
|
||||||
"github.com/go-fed/activity/astool/codegen"
|
"github.com/go-fed/activity/astool/codegen"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -52,9 +51,6 @@ type ManagerGenerator struct {
|
||||||
tgManagedMethods map[*TypeGenerator]*managedMethods
|
tgManagedMethods map[*TypeGenerator]*managedMethods
|
||||||
fpManagedMethods map[*FunctionalPropertyGenerator]*managedMethods
|
fpManagedMethods map[*FunctionalPropertyGenerator]*managedMethods
|
||||||
nfpManagedMethods map[*NonFunctionalPropertyGenerator]*managedMethods
|
nfpManagedMethods map[*NonFunctionalPropertyGenerator]*managedMethods
|
||||||
// Cached during manager code generation.
|
|
||||||
cacheOnce sync.Once
|
|
||||||
cachedStruct *codegen.Struct
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// managedMethods caches the specific methods and interfaces mapped to specific
|
// managedMethods caches the specific methods and interfaces mapped to specific
|
||||||
|
|
|
@ -105,7 +105,7 @@ func (p *NonFunctionalPropertyGenerator) Definitions() (*codegen.Struct, *codege
|
||||||
|
|
||||||
// iteratorInterfaceName gets the interface name for the iterator.
|
// iteratorInterfaceName gets the interface name for the iterator.
|
||||||
func (p *NonFunctionalPropertyGenerator) iteratorInterfaceName() string {
|
func (p *NonFunctionalPropertyGenerator) iteratorInterfaceName() string {
|
||||||
return fmt.Sprintf("%s", strings.Title(p.iteratorTypeName().CamelName))
|
return strings.Title(p.iteratorTypeName().CamelName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// elementTypeGenerator produces a FunctionalPropertyGenerator for the iterator
|
// elementTypeGenerator produces a FunctionalPropertyGenerator for the iterator
|
||||||
|
|
|
@ -447,7 +447,7 @@ func genInit(pkg Package,
|
||||||
)
|
)
|
||||||
callInitsSlice = append(callInitsSlice, key)
|
callInitsSlice = append(callInitsSlice, key)
|
||||||
}
|
}
|
||||||
sort.Sort(sort.StringSlice(callInitsSlice))
|
sort.Strings(callInitsSlice)
|
||||||
callInits := make([]jen.Code, 0, len(callInitsSlice))
|
callInits := make([]jen.Code, 0, len(callInitsSlice))
|
||||||
for _, c := range callInitsSlice {
|
for _, c := range callInitsSlice {
|
||||||
callInits = append(callInits, callInitsMap[c])
|
callInits = append(callInits, callInitsMap[c])
|
||||||
|
@ -464,7 +464,7 @@ func genInit(pkg Package,
|
||||||
)
|
)
|
||||||
callInitsSlice = append(callInitsSlice, key)
|
callInitsSlice = append(callInitsSlice, key)
|
||||||
}
|
}
|
||||||
sort.Sort(sort.StringSlice(callInitsSlice))
|
sort.Strings(callInitsSlice)
|
||||||
for _, c := range callInitsSlice {
|
for _, c := range callInitsSlice {
|
||||||
callInits = append(callInits, callInitsMap[c])
|
callInits = append(callInits, callInitsMap[c])
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,13 +290,13 @@ func (p *PropertyGenerator) iteratorTypeName() Identifier {
|
||||||
|
|
||||||
// InterfaceName returns the interface name of the property type.
|
// InterfaceName returns the interface name of the property type.
|
||||||
func (p *PropertyGenerator) InterfaceName() string {
|
func (p *PropertyGenerator) InterfaceName() string {
|
||||||
return fmt.Sprintf("%s", p.StructName())
|
return p.StructName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// parentTypeInterfaceName is useful for iterators that need the base property
|
// parentTypeInterfaceName is useful for iterators that need the base property
|
||||||
// type's interface name.
|
// type's interface name.
|
||||||
func (p *PropertyGenerator) parentTypeInterfaceName() string {
|
func (p *PropertyGenerator) parentTypeInterfaceName() string {
|
||||||
return fmt.Sprintf("%s", strings.TrimSuffix(p.StructName(), "Iterator"))
|
return strings.TrimSuffix(p.StructName(), "Iterator")
|
||||||
}
|
}
|
||||||
|
|
||||||
// PropertyName returns the name of this property, as defined in
|
// PropertyName returns the name of this property, as defined in
|
||||||
|
|
|
@ -24,7 +24,6 @@ const (
|
||||||
errorUnhandled = "ErrUnhandledType"
|
errorUnhandled = "ErrUnhandledType"
|
||||||
errorPredicateUnmatched = "ErrPredicateUnmatched"
|
errorPredicateUnmatched = "ErrPredicateUnmatched"
|
||||||
errorCannotTypeAssert = "errCannotTypeAssertType"
|
errorCannotTypeAssert = "errCannotTypeAssertType"
|
||||||
errorCannotTypeAssertPredicate = "errCannotTypeAssertPredicate"
|
|
||||||
isUnFnName = "IsUnmatchedErr"
|
isUnFnName = "IsUnmatchedErr"
|
||||||
toAliasMapFnName = "toAliasMap"
|
toAliasMapFnName = "toAliasMap"
|
||||||
)
|
)
|
||||||
|
@ -32,21 +31,20 @@ const (
|
||||||
// ResolverGenerator generates the code required for the TypeResolver and the
|
// ResolverGenerator generates the code required for the TypeResolver and the
|
||||||
// PredicateTypeResolver.
|
// PredicateTypeResolver.
|
||||||
type ResolverGenerator struct {
|
type ResolverGenerator struct {
|
||||||
pkg Package
|
pkg Package
|
||||||
types []*TypeGenerator
|
types []*TypeGenerator
|
||||||
manGen *ManagerGenerator
|
manGen *ManagerGenerator
|
||||||
cacheOnce sync.Once
|
cacheOnce sync.Once
|
||||||
cachedJSON *codegen.Struct
|
cachedJSON *codegen.Struct
|
||||||
cachedTypePredicate *codegen.Struct
|
cachedTypePredicate *codegen.Struct
|
||||||
cachedType *codegen.Struct
|
cachedType *codegen.Struct
|
||||||
cachedErrNoMatch jen.Code
|
cachedErrNoMatch jen.Code
|
||||||
cachedErrUnhandled jen.Code
|
cachedErrUnhandled jen.Code
|
||||||
cachedErrPredicateUnmatched jen.Code
|
cachedErrPredicateUnmatched jen.Code
|
||||||
cachedErrCannotTypeAssert jen.Code
|
cachedErrCannotTypeAssert jen.Code
|
||||||
cachedErrCannotTypeAssertPredicate jen.Code
|
cachedFns []*codegen.Function
|
||||||
cachedFns []*codegen.Function
|
cachedASInterface *codegen.Interface
|
||||||
cachedASInterface *codegen.Interface
|
cachedResolverInterface *codegen.Interface
|
||||||
cachedResolverInterface *codegen.Interface
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new ResolverGenerator for generating all the methods, functions,
|
// Creates a new ResolverGenerator for generating all the methods, functions,
|
||||||
|
@ -138,7 +136,6 @@ func (r *ResolverGenerator) Definition() (jsonRes, typeRes, typePredRes *codegen
|
||||||
r.cachedErrUnhandled = r.errorUnhandled()
|
r.cachedErrUnhandled = r.errorUnhandled()
|
||||||
r.cachedErrPredicateUnmatched = r.errorPredicateUnmatched()
|
r.cachedErrPredicateUnmatched = r.errorPredicateUnmatched()
|
||||||
r.cachedErrCannotTypeAssert = r.errorCannotTypeAssert()
|
r.cachedErrCannotTypeAssert = r.errorCannotTypeAssert()
|
||||||
r.cachedErrCannotTypeAssertPredicate = r.errorCannotTypeAssertPredicate()
|
|
||||||
r.cachedFns = r.fns()
|
r.cachedFns = r.fns()
|
||||||
r.cachedASInterface = r.asInterface()
|
r.cachedASInterface = r.asInterface()
|
||||||
r.cachedResolverInterface = r.resolverInterface()
|
r.cachedResolverInterface = r.resolverInterface()
|
||||||
|
@ -148,7 +145,6 @@ func (r *ResolverGenerator) Definition() (jsonRes, typeRes, typePredRes *codegen
|
||||||
r.cachedErrUnhandled,
|
r.cachedErrUnhandled,
|
||||||
r.cachedErrPredicateUnmatched,
|
r.cachedErrPredicateUnmatched,
|
||||||
r.cachedErrCannotTypeAssert,
|
r.cachedErrCannotTypeAssert,
|
||||||
r.cachedErrCannotTypeAssertPredicate,
|
|
||||||
}, r.cachedFns, []*codegen.Interface{
|
}, r.cachedFns, []*codegen.Interface{
|
||||||
r.cachedASInterface,
|
r.cachedASInterface,
|
||||||
r.cachedResolverInterface,
|
r.cachedResolverInterface,
|
||||||
|
@ -184,16 +180,6 @@ func (r *ResolverGenerator) errorCannotTypeAssert() jen.Code {
|
||||||
).Line().Var().Id(errorCannotTypeAssert).Error().Op("=").Qual("errors", "New").Call(jen.Lit("activity stream type cannot be asserted to its interface"))
|
).Line().Var().Id(errorCannotTypeAssert).Error().Op("=").Qual("errors", "New").Call(jen.Lit("activity stream type cannot be asserted to its interface"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// errorCannotTypeAssertPredicate returns the declaration for the
|
|
||||||
// errCannotTypeAssert global value.
|
|
||||||
func (r *ResolverGenerator) errorCannotTypeAssertPredicate() jen.Code {
|
|
||||||
return jen.Commentf(
|
|
||||||
"%s indicates that a predicate cannot be type-casted to an "+
|
|
||||||
"expected function signature.",
|
|
||||||
errorCannotTypeAssertPredicate,
|
|
||||||
).Line().Var().Id(errorCannotTypeAssertPredicate).Error().Op("=").Qual("errors", "New").Call(jen.Lit("predicate cannot be type asserted to a known function type"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// errorPredicateUnmatched returns the declaration for the ErrPredicateUnmatched
|
// errorPredicateUnmatched returns the declaration for the ErrPredicateUnmatched
|
||||||
// global value.
|
// global value.
|
||||||
func (r *ResolverGenerator) errorPredicateUnmatched() jen.Code {
|
func (r *ResolverGenerator) errorPredicateUnmatched() jen.Code {
|
||||||
|
@ -307,10 +293,7 @@ func (r *ResolverGenerator) jsonResolverMethods() (m []*codegen.Method) {
|
||||||
jen.If(
|
jen.If(
|
||||||
jen.Op("!").Id("ok"),
|
jen.Op("!").Id("ok"),
|
||||||
).Block(
|
).Block(
|
||||||
jen.List(
|
jen.Id(vocabId).Op("=").Id("aliasMap").Index(
|
||||||
jen.Id(vocabId),
|
|
||||||
jen.Id("_"),
|
|
||||||
).Op("=").Id("aliasMap").Index(
|
|
||||||
jen.Lit(vocabHttp.String()),
|
jen.Lit(vocabHttp.String()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -304,7 +304,7 @@ func (t *TypeGenerator) StructName() string {
|
||||||
|
|
||||||
// InterfaceName returns the interface name for this type.
|
// InterfaceName returns the interface name for this type.
|
||||||
func (t *TypeGenerator) InterfaceName() string {
|
func (t *TypeGenerator) InterfaceName() string {
|
||||||
return fmt.Sprintf("%s", t.StructName())
|
return t.StructName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extends returns the generators of types that this ActivityStreams type
|
// Extends returns the generators of types that this ActivityStreams type
|
||||||
|
@ -450,11 +450,11 @@ func (t *TypeGenerator) allProperties() []Property {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ext := range extends {
|
for ext := range extends {
|
||||||
for k, _ := range ext.WithoutProperties() {
|
for k := range ext.WithoutProperties() {
|
||||||
delete(p, k)
|
delete(p, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for k, _ := range t.WithoutProperties() {
|
for k := range t.WithoutProperties() {
|
||||||
delete(p, k)
|
delete(p, k)
|
||||||
}
|
}
|
||||||
// Sort the properties into a stable order -- this is important for
|
// Sort the properties into a stable order -- this is important for
|
||||||
|
@ -546,7 +546,7 @@ func (t *TypeGenerator) extendsDefinition() (*codegen.Function, *codegen.Method)
|
||||||
for _, name := range extends {
|
for _, name := range extends {
|
||||||
extendsStr = append(extendsStr, name)
|
extendsStr = append(extendsStr, name)
|
||||||
}
|
}
|
||||||
sort.Sort(sort.StringSlice(extendsStr))
|
sort.Strings(extendsStr)
|
||||||
extensions := make([]jen.Code, 0, len(extendsStr))
|
extensions := make([]jen.Code, 0, len(extendsStr))
|
||||||
for _, name := range extendsStr {
|
for _, name := range extendsStr {
|
||||||
extensions = append(extensions, jen.Lit(name))
|
extensions = append(extensions, jen.Lit(name))
|
||||||
|
@ -595,7 +595,7 @@ func (t *TypeGenerator) getAllChildrenExtendedBy(s []string, tg *TypeGenerator)
|
||||||
s = append(s, e.TypeName())
|
s = append(s, e.TypeName())
|
||||||
s = t.getAllChildrenExtendedBy(s, e)
|
s = t.getAllChildrenExtendedBy(s, e)
|
||||||
}
|
}
|
||||||
sort.Sort(sort.StringSlice(s))
|
sort.Strings(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ func (t *TypeGenerator) constructorFn() *codegen.Function {
|
||||||
jen.Op("&").Qual(t.PrivatePackage().Path(), t.StructName()).Values(
|
jen.Op("&").Qual(t.PrivatePackage().Path(), t.StructName()).Values(
|
||||||
jen.Dict{
|
jen.Dict{
|
||||||
jen.Id(aliasMember): jen.Lit(t.vocabAlias),
|
jen.Id(aliasMember): jen.Lit(t.vocabAlias),
|
||||||
jen.Id(unknownMember): jen.Make(jen.Map(jen.String()).Interface(), jen.Lit(0)),
|
jen.Id(unknownMember): jen.Make(jen.Map(jen.String()).Interface()),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1132,7 +1132,7 @@ func (t *TypeGenerator) constructorFn() *codegen.Function {
|
||||||
jen.Op("&").Qual(t.PrivatePackage().Path(), t.StructName()).Values(
|
jen.Op("&").Qual(t.PrivatePackage().Path(), t.StructName()).Values(
|
||||||
jen.Dict{
|
jen.Dict{
|
||||||
jen.Id(aliasMember): jen.Lit(t.vocabAlias),
|
jen.Id(aliasMember): jen.Lit(t.vocabAlias),
|
||||||
jen.Id(unknownMember): jen.Make(jen.Map(jen.String()).Interface(), jen.Lit(0)),
|
jen.Id(unknownMember): jen.Make(jen.Map(jen.String()).Interface()),
|
||||||
jen.Id(typeMember): jen.Id("typeProp"),
|
jen.Id(typeMember): jen.Id("typeProp"),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/go-fed/activity/astool/rdf/rfc"
|
"github.com/go-fed/activity/astool/rdf/rfc"
|
||||||
"github.com/go-fed/activity/astool/rdf/schema"
|
"github.com/go-fed/activity/astool/rdf/schema"
|
||||||
"github.com/go-fed/activity/astool/rdf/xsd"
|
"github.com/go-fed/activity/astool/rdf/xsd"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -166,9 +167,7 @@ func mustAddOntology(o rdf.Ontology) {
|
||||||
// into the registry, before main executes.
|
// into the registry, before main executes.
|
||||||
func init() {
|
func init() {
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Fprintf(
|
_, _ = io.WriteString(flag.CommandLine.Output(), helpText)
|
||||||
flag.CommandLine.Output(),
|
|
||||||
helpText)
|
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
mustAddOntology(&xsd.XMLOntology{Package: "xml"})
|
mustAddOntology(&xsd.XMLOntology{Package: "xml"})
|
||||||
|
@ -278,8 +277,7 @@ func (c *CommandLineFlags) detectPath() error {
|
||||||
}
|
}
|
||||||
c.pathAutoDetected = true
|
c.pathAutoDetected = true
|
||||||
gopath = strings.Join([]string{gopath, "src", ""}, "/")
|
gopath = strings.Join([]string{gopath, "src", ""}, "/")
|
||||||
c.path.Set(strings.TrimPrefix(pwd, gopath))
|
return c.path.Set(strings.TrimPrefix(pwd, gopath))
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate applies custom validation logic to flags and returns an error if any
|
// Validate applies custom validation logic to flags and returns an error if any
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (p *ParsedVocabulary) GetReference(uri string) (*Vocabulary, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if p.References == nil {
|
if p.References == nil {
|
||||||
p.References = make(map[string]*Vocabulary, 0)
|
p.References = make(map[string]*Vocabulary)
|
||||||
}
|
}
|
||||||
if v, ok := p.References[httpSpec]; ok {
|
if v, ok := p.References[httpSpec]; ok {
|
||||||
return v, nil
|
return v, nil
|
||||||
|
|
|
@ -270,12 +270,8 @@ func (l *langstring) Apply(key string, value interface{}, ctx *ParsingContext) (
|
||||||
jen.Id("k"),
|
jen.Id("k"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
jen.Qual("sort", "Sort").Call(
|
jen.Qual("sort", "Strings").Call(jen.Id("lk")),
|
||||||
jen.Qual("sort", "StringSlice").Call(jen.Id("lk")),
|
jen.Qual("sort", "Strings").Call(jen.Id("rk")),
|
||||||
),
|
|
||||||
jen.Qual("sort", "Sort").Call(
|
|
||||||
jen.Qual("sort", "StringSlice").Call(jen.Id("rk")),
|
|
||||||
),
|
|
||||||
jen.For(
|
jen.For(
|
||||||
jen.Id("i").Op(":=").Lit(0),
|
jen.Id("i").Op(":=").Lit(0),
|
||||||
jen.Id("i").Op("<").Len(jen.Id("lk")).Op("&&").Id("i").Op("<").Len(jen.Id("rk")),
|
jen.Id("i").Op("<").Len(jen.Id("lk")).Op("&&").Id("i").Op("<").Len(jen.Id("rk")),
|
||||||
|
|
|
@ -611,6 +611,7 @@ func parseJSONLDContext(registry *RDFRegistry, input JSONLD) (nodes []RDFNode, e
|
||||||
s, ok := i.(string)
|
s, ok := i.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
err = fmt.Errorf("single @context value is not a string")
|
err = fmt.Errorf("single @context value is not a string")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return registry.getFor(s)
|
return registry.getFor(s)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1008,7 +1008,8 @@ func (d *duration) Apply(key string, value interface{}, ctx *rdf.ParsingContext)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
jen.Id("re").Op(":=").Qual("regexp", "MustCompile").Call(
|
jen.Id("re").Op(":=").Qual("regexp", "MustCompile").Call(
|
||||||
jen.Lit("P(\\d*Y)?(\\d*M)?(\\d*D)?(T(\\d*H)?(\\d*M)?(\\d*S)?)?"),
|
// raw string, recommended by https://github.com/dave/jennifer/issues/50
|
||||||
|
jen.Op("`P(\\d*Y)?(\\d*M)?(\\d*D)?(T(\\d*H)?(\\d*M)?(\\d*S)?)?`"),
|
||||||
),
|
),
|
||||||
jen.Id("res").Op(":=").Id("re").Dot("FindStringSubmatch").Call(jen.Id("s")),
|
jen.Id("res").Op(":=").Id("re").Dot("FindStringSubmatch").Call(jen.Id("s")),
|
||||||
jen.Var().Id("dur").Qual("time", "Duration"),
|
jen.Var().Id("dur").Qual("time", "Duration"),
|
||||||
|
|
|
@ -187,7 +187,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
|
||||||
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
||||||
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
||||||
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
||||||
activity = withNewId(activity)
|
withNewId(activity)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().PostOutbox(
|
delegate.EXPECT().PostOutbox(
|
||||||
|
@ -217,7 +217,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
|
||||||
return wrappedInCreate(t), nil
|
return wrappedInCreate(t), nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().AddNewIds(ctx, wrappedInCreate(toDeserializedForm(testMyNote))).DoAndReturn(func(c context.Context, activity Activity) error {
|
delegate.EXPECT().AddNewIds(ctx, wrappedInCreate(toDeserializedForm(testMyNote))).DoAndReturn(func(c context.Context, activity Activity) error {
|
||||||
activity = withNewId(activity)
|
withNewId(activity)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().PostOutbox(
|
delegate.EXPECT().PostOutbox(
|
||||||
|
@ -242,7 +242,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
|
||||||
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
||||||
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
||||||
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
||||||
activity = withNewId(activity)
|
withNewId(activity)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().PostOutbox(
|
delegate.EXPECT().PostOutbox(
|
||||||
|
@ -267,7 +267,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
|
||||||
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
||||||
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
||||||
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
||||||
activity = withNewId(activity)
|
withNewId(activity)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().PostOutbox(
|
delegate.EXPECT().PostOutbox(
|
||||||
|
@ -696,7 +696,7 @@ func TestBaseActor(t *testing.T) {
|
||||||
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
||||||
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
||||||
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
||||||
activity = withNewId(activity)
|
withNewId(activity)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().PostOutbox(
|
delegate.EXPECT().PostOutbox(
|
||||||
|
@ -723,7 +723,7 @@ func TestBaseActor(t *testing.T) {
|
||||||
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
|
||||||
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
|
||||||
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
|
||||||
activity = withNewId(activity)
|
withNewId(activity)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
delegate.EXPECT().PostOutbox(
|
delegate.EXPECT().PostOutbox(
|
||||||
|
|
|
@ -185,7 +185,7 @@ func (w SocialWrappedCallbacks) create(c context.Context, a vocab.ActivityStream
|
||||||
}
|
}
|
||||||
// Obtain all actor IRIs.
|
// Obtain all actor IRIs.
|
||||||
actors := a.GetActivityStreamsActor()
|
actors := a.GetActivityStreamsActor()
|
||||||
createActorIds := make(map[string]*url.URL, 0)
|
createActorIds := make(map[string]*url.URL)
|
||||||
if actors != nil {
|
if actors != nil {
|
||||||
createActorIds = make(map[string]*url.URL, actors.Len())
|
createActorIds = make(map[string]*url.URL, actors.Len())
|
||||||
for iter := actors.Begin(); iter != actors.End(); iter = iter.Next() {
|
for iter := actors.Begin(); iter != actors.End(); iter = iter.Next() {
|
||||||
|
|
|
@ -113,7 +113,7 @@ func (h HttpSigTransport) Dereference(c context.Context, iri *url.URL) ([]byte,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req.WithContext(c)
|
req = req.WithContext(c)
|
||||||
req.Header.Add(acceptHeader, acceptHeaderValue)
|
req.Header.Add(acceptHeader, acceptHeaderValue)
|
||||||
req.Header.Add("Accept-Charset", "utf-8")
|
req.Header.Add("Accept-Charset", "utf-8")
|
||||||
req.Header.Add("Date", h.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
|
req.Header.Add("Date", h.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
|
||||||
|
@ -144,7 +144,7 @@ func (h HttpSigTransport) Deliver(c context.Context, b []byte, to *url.URL) erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.WithContext(c)
|
req = req.WithContext(c)
|
||||||
req.Header.Add(contentTypeHeader, contentTypeHeaderValue)
|
req.Header.Add(contentTypeHeader, contentTypeHeaderValue)
|
||||||
req.Header.Add("Accept-Charset", "utf-8")
|
req.Header.Add("Accept-Charset", "utf-8")
|
||||||
req.Header.Add("Date", h.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
|
req.Header.Add("Date", h.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")+" GMT")
|
||||||
|
|
読み込み中…
新しいイシューから参照