NameIndex

class NameIndex

Description

A name -> elements lookup over a model, built once by build_name_index().

Two maps are held:

  • by_qualified_name maps the rendered qualified name (e.g. "Pkg::Sub::Name") to one element bearing it. Within one document a qualified name is unique (a duplicate is a namespace-distinguishability error), but two documents may each declare package Dup, and then both packages render Dup: the first in document order is kept under "Dup" and the later same-named packages are not, here and in find_by_qualified_name() alike, so the two paths agree. Only the package objects are shadowed: their members keep distinct qualified names (Dup::AA from one document, Dup::BB from the other) and each is indexed. Use by_simple_name to see every element of a name. Memberships are left out: the only memberships carrying a qualified name are alias memberships, whose name is a name for their target, and handing one back from a lookup by name would answer with the membership rather than the element asked for. An alias name therefore resolves to nothing here, exactly as it does in find_by_qualified_name(); to follow an alias to its target use get_by_path(). Every other named element is indexed, relationships included: a dependency dep from A to B; is found as "P::dep" here and by the walk alike.

  • by_simple_name maps an element’s simple name to every element bearing that name anywhere in the model (names are not unique), so its values are lists in first-seen (scan) order.

Which library elements are indexed is set by the LibraryElements value the index was built with. An element that value excludes is skipped during the scan, so it also cannot claim a name (in either map) ahead of an indexed element.

Members defined in NameIndex (2 members)

Attributes

by_qualified_name: dict[str, syside.Element] = None
by_simple_name: dict[str, list[syside.Element]] = None

Used by