ResolveCandidateNames returns the candidates name of namespaced identifiers in C++ resolution order. Names which shadow other names are returned first. If a name includes a leading dot ('.'), the name is treated as an absolute identifier which cannot be shadowed. Given a container name a.b.c.M.N a
(name string)
| 109 | // If aliases or abbreviations are configured for the container, then alias names will take |
| 110 | // precedence over containerized names. |
| 111 | func (c *Container) ResolveCandidateNames(name string) []string { |
| 112 | if strings.HasPrefix(name, ".") { |
| 113 | qn := name[1:] |
| 114 | alias, isAlias := c.findAlias(qn) |
| 115 | if isAlias { |
| 116 | return []string{alias} |
| 117 | } |
| 118 | return []string{qn} |
| 119 | } |
| 120 | alias, isAlias := c.findAlias(name) |
| 121 | if isAlias { |
| 122 | return []string{alias} |
| 123 | } |
| 124 | if c.Name() == "" { |
| 125 | return []string{name} |
| 126 | } |
| 127 | nextCont := c.Name() |
| 128 | candidates := []string{nextCont + "." + name} |
| 129 | for i := strings.LastIndex(nextCont, "."); i >= 0; i = strings.LastIndex(nextCont, ".") { |
| 130 | nextCont = nextCont[:i] |
| 131 | candidates = append(candidates, nextCont+"."+name) |
| 132 | } |
| 133 | return append(candidates, name) |
| 134 | } |
| 135 | |
| 136 | // AliasSet returns the alias to fully-qualified name mapping stored in the container. |
| 137 | func (c *Container) AliasSet() map[string]string { |