getNamespacesToSearchForModule to use blueprint.Namespace

Allow for nil argument.

Test: m all

Change-Id: I03e3afe00d72905f259ce1af5085387b796ebc3d
This commit is contained in:
Bob Badour 2020-12-17 16:30:00 -08:00
parent 4eb5048585
commit 38620edca1
1 changed files with 5 additions and 4 deletions

View File

@ -232,13 +232,14 @@ func (r *NameResolver) parseFullyQualifiedName(name string) (namespaceName strin
} }
func (r *NameResolver) getNamespacesToSearchForModule(sourceNamespace *Namespace) (searchOrder []*Namespace) { func (r *NameResolver) getNamespacesToSearchForModule(sourceNamespace blueprint.Namespace) (searchOrder []*Namespace) {
if sourceNamespace.visibleNamespaces == nil { ns, ok := sourceNamespace.(*Namespace)
if !ok || ns.visibleNamespaces == nil {
// When handling dependencies before namespaceMutator, assume they are non-Soong Blueprint modules and give // When handling dependencies before namespaceMutator, assume they are non-Soong Blueprint modules and give
// access to all namespaces. // access to all namespaces.
return r.sortedNamespaces.sortedItems() return r.sortedNamespaces.sortedItems()
} }
return sourceNamespace.visibleNamespaces return ns.visibleNamespaces
} }
func (r *NameResolver) ModuleFromName(name string, namespace blueprint.Namespace) (group blueprint.ModuleGroup, found bool) { func (r *NameResolver) ModuleFromName(name string, namespace blueprint.Namespace) (group blueprint.ModuleGroup, found bool) {
@ -252,7 +253,7 @@ func (r *NameResolver) ModuleFromName(name string, namespace blueprint.Namespace
container := namespace.moduleContainer container := namespace.moduleContainer
return container.ModuleFromName(moduleName, nil) return container.ModuleFromName(moduleName, nil)
} }
for _, candidate := range r.getNamespacesToSearchForModule(namespace.(*Namespace)) { for _, candidate := range r.getNamespacesToSearchForModule(namespace) {
group, found = candidate.moduleContainer.ModuleFromName(name, nil) group, found = candidate.moduleContainer.ModuleFromName(name, nil)
if found { if found {
return group, true return group, true