Switch ResourceName to use ResourceNamedType instead of ResourceType.
DD: go/custom-resource-types-in-aapt2
Bug: b/215108200
Test: Resource_test.cpp
Change-Id: I0b97fc0024523700e01adce788bb934d388da288
diff --git a/tools/aapt2/compile/IdAssigner.cpp b/tools/aapt2/compile/IdAssigner.cpp
index 339b8af..fa816be 100644
--- a/tools/aapt2/compile/IdAssigner.cpp
+++ b/tools/aapt2/compile/IdAssigner.cpp
@@ -275,7 +275,7 @@
return false;
}
- auto key = ResourceTypeKey{name.type, id.type_id()};
+ auto key = ResourceTypeKey{name.type.type, id.type_id()};
auto type = types_.find(key);
if (type == types_.end()) {
// The type has not been assigned an id yet. Ensure that the specified id is not being used by
@@ -291,7 +291,7 @@
if (!visibility.staged_api) {
// Ensure that non-staged resources can only exist in one type ID.
- auto non_staged_type = non_staged_type_ids_.emplace(name.type, id.type_id());
+ auto non_staged_type = non_staged_type_ids_.emplace(name.type.type, id.type_id());
if (!non_staged_type.second && non_staged_type.first->second != id.type_id()) {
diag->Error(DiagMessage() << "can't assign ID " << id << " to resource " << name
<< " because type already has ID " << std::hex
@@ -316,14 +316,14 @@
CHECK(name.package.empty() || name.package == package_name_);
// Find the type id for non-staged resources of this type.
- auto non_staged_type = non_staged_type_ids_.find(name.type);
+ auto non_staged_type = non_staged_type_ids_.find(name.type.type);
if (non_staged_type == non_staged_type_ids_.end()) {
auto next_type_id = type_id_finder_.NextId();
CHECK(next_type_id.has_value()) << "resource type IDs allocated have exceeded maximum (256)";
- non_staged_type = non_staged_type_ids_.emplace(name.type, *next_type_id).first;
+ non_staged_type = non_staged_type_ids_.emplace(name.type.type, *next_type_id).first;
}
- ResourceTypeKey key{name.type, non_staged_type->second};
+ ResourceTypeKey key{name.type.type, non_staged_type->second};
auto type = types_.find(key);
if (type == types_.end()) {
type = types_.emplace(key, TypeGroup(package_id_, key.id)).first;
diff --git a/tools/aapt2/compile/XmlIdCollector.cpp b/tools/aapt2/compile/XmlIdCollector.cpp
index 5054115..bb72159 100644
--- a/tools/aapt2/compile/XmlIdCollector.cpp
+++ b/tools/aapt2/compile/XmlIdCollector.cpp
@@ -46,7 +46,7 @@
ResourceNameRef name;
bool create = false;
if (ResourceUtils::ParseReference(attr.value, &name, &create, nullptr)) {
- if (create && name.type == ResourceType::kId) {
+ if (create && name.type.type == ResourceType::kId) {
if (!text::IsValidResourceEntryName(name.entry)) {
source_diag_->Error(DiagMessage(element->line_number)
<< "id '" << name << "' has an invalid entry name");