| 105 | } |
| 106 | |
| 107 | void NamespaceGenerator::GenerateCandidates( |
| 108 | absl::string_view simple_name, |
| 109 | absl::FunctionRef<bool(absl::string_view)> callback) const { |
| 110 | // Special case for root-relative names. Aliases still apply first. |
| 111 | bool is_root_relative = absl::StartsWith(simple_name, "."); |
| 112 | if (is_root_relative) { |
| 113 | simple_name = simple_name.substr(1); |
| 114 | } |
| 115 | |
| 116 | // The name is unqualified, but may include a namespace (struct creation). |
| 117 | // This is just a quirk of the parser. |
| 118 | if (auto dot_pos = simple_name.find('.'); |
| 119 | dot_pos != absl::string_view::npos) { |
| 120 | absl::string_view first_segment = simple_name.substr(0, dot_pos); |
| 121 | absl::string_view rest = simple_name.substr(dot_pos + 1); |
| 122 | if (auto resolved_alias = expression_container_->FindAlias(first_segment); |
| 123 | !resolved_alias.empty()) { |
| 124 | callback(absl::StrCat(resolved_alias, ".", rest)); |
| 125 | return; |
| 126 | } |
| 127 | } else { |
| 128 | if (auto resolved_alias = expression_container_->FindAlias(simple_name); |
| 129 | !resolved_alias.empty()) { |
| 130 | callback(resolved_alias); |
| 131 | return; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | if (is_root_relative) { |
| 136 | callback(simple_name); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | for (const auto& prefix : candidates_) { |
| 141 | std::string candidate = absl::StrCat(prefix, ".", simple_name); |
| 142 | if (!callback(candidate)) { |
| 143 | return; |
| 144 | } |
| 145 | } |
| 146 | callback(simple_name); |
| 147 | } |
| 148 | |
| 149 | void NamespaceGenerator::GenerateCandidates( |
| 150 | absl::Span<const std::string> partly_qualified_name, |