Repository navigation
Resolve a tag field's namespace from a direct link to the namespace - #103
raul-marquez-csa wants to merge 1 commit into
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
|
|
||
| // isNamespaceAnchor reports whether referenceID names an anchor in a namespace document, such as | ||
| // ref_CommonLandmarkNamespace. | ||
| func (library *Library) isNamespaceAnchor(referenceID string) bool { |
There was a problem hiding this comment.
This is a little weird, since it makes any anchor in a namespace doc into an anchor to a namespace.
Might be better to change the source element for namespaces to be the section that defines them, rather than the table; this would be on line 37 in matter/spec/namespace.go. Then anchors would just resolve to the correct element, and the namespace would automatically be associated by entity finder. This would mean you don't need the special case up above.
The other benefit to this is that in #98 we start validating these references to make sure they point to a valid element, adding a spec error if it doesn't.
With this code, if I had a description of a tag field that first linked to a specific tag, and then linked to the name space, it would silently fail; the first link would match isNamespaceAnchor, the ref would get assigned to the source, but getTagNamespace would fail on the cast to namespace.
A
tagfield takes its namespace from a<<ref_StandardNamespaces, X Namespace>>link in its description. The spec now links the namespace itself instead (<<ref_CommonLandmarkNamespace>>), so Alchemy finds no namespace and writesenum8for Service Area'sLandmarkTagandRelativePositionTagand forLocationDescriptorStruct.AreaType. The spec errata works aroundAreaTypewithoverride-type: AreaTypeTag;LandmarkInfoStructhas no workaround, and anoverride-typenaming a tag enum is an unknown custom type, which stops generation for an input document.Changes (
matter/spec)ref_StandardNamespaceslabel and the name match still work as before.Testing
go test ./..., includingTestTagFieldNamespaceFromNamespaceReference, which fails when any of the three parts is removed.zaprun into the SDK, with and without this change, over spec master with theAreaTypeoverride removed from the errata: the only difference across the 144 generated files is the three fields above, which getAreaTypeTag,LandmarkTagandRelativePositionTag(the SDK's current types) instead ofenum8.Related
AreaTypeoverride, so it needs this change released first.