diff options
Diffstat (limited to 'tools/aapt2/compile/InlineXmlFormatParser.cpp')
-rw-r--r-- | tools/aapt2/compile/InlineXmlFormatParser.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/aapt2/compile/InlineXmlFormatParser.cpp b/tools/aapt2/compile/InlineXmlFormatParser.cpp index 73a90da6baf0..238e339c05af 100644 --- a/tools/aapt2/compile/InlineXmlFormatParser.cpp +++ b/tools/aapt2/compile/InlineXmlFormatParser.cpp @@ -69,10 +69,10 @@ class Visitor : public xml::PackageAwareVisitor { // Use an empty string for the compilation package because we don't want to default to // the local package if the user specified name="style" or something. This should just // be the default namespace. - Maybe<xml::ExtractedPackage> maybe_pkg = TransformPackageAlias(name.package, {}); + Maybe<xml::ExtractedPackage> maybe_pkg = TransformPackageAlias(name.package); if (!maybe_pkg) { - context_->GetDiagnostics()->Error(DiagMessage(src) << "invalid namespace prefix '" - << name.package << "'"); + context_->GetDiagnostics()->Error(DiagMessage(src) + << "invalid namespace prefix '" << name.package << "'"); error_ = true; return; } @@ -118,10 +118,11 @@ bool InlineXmlFormatParser::Consume(IAaptContext* context, xml::XmlResource* doc size_t name_suffix_counter = 0; for (const InlineDeclaration& decl : visitor.GetInlineDeclarations()) { - auto new_doc = util::make_unique<xml::XmlResource>(); - new_doc->file.config = doc->file.config; - new_doc->file.source = doc->file.source.WithLine(decl.el->line_number); - new_doc->file.name = doc->file.name; + // Create a new XmlResource with the same ResourceFile as the base XmlResource. + auto new_doc = util::make_unique<xml::XmlResource>(doc->file); + + // Attach the line number. + new_doc->file.source.line = decl.el->line_number; // Modify the new entry name. We need to suffix the entry with a number to // avoid local collisions, then mangle it with the empty package, such that it won't show up @@ -163,7 +164,7 @@ bool InlineXmlFormatParser::Consume(IAaptContext* context, xml::XmlResource* doc // Add the inline attribute to the parent. parent_el->attributes.push_back(xml::Attribute{decl.attr_namespace_uri, decl.attr_name, - "@" + new_doc->file.name.ToString()}); + "@" + new_doc->file.name.to_string()}); // Delete the subtree. for (auto iter = parent_el->children.begin(); iter != parent_el->children.end(); ++iter) { |