Lines Matching refs:parser
245 xml::XmlPullParser* parser, std::string* out_raw_string, android::StyleString* out_style_string, in FlattenXmlSubtree() argument
262 while (depth > 0 && xml::XmlPullParser::IsGoodEvent(parser->Next())) { in FlattenXmlSubtree()
263 const xml::XmlPullParser::Event event = parser->event(); in FlattenXmlSubtree()
282 current_text += parser->text(); in FlattenXmlSubtree()
283 raw_string += parser->text(); in FlattenXmlSubtree()
287 if (parser->element_namespace().empty()) { in FlattenXmlSubtree()
290 span_node->name = parser->element_name(); in FlattenXmlSubtree()
291 const auto end_attr_iter = parser->end_attributes(); in FlattenXmlSubtree()
292 for (auto attr_iter = parser->begin_attributes(); attr_iter != end_attr_iter; in FlattenXmlSubtree()
302 } else if (parser->element_namespace() == sXliffNamespaceUri) { in FlattenXmlSubtree()
304 if (parser->element_name() == "g") { in FlattenXmlSubtree()
308 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in FlattenXmlSubtree()
323 diag_->Warn(android::DiagMessage(source_.WithLine(parser->line_number())) in FlattenXmlSubtree()
324 << "ignoring element '" << parser->element_name() in FlattenXmlSubtree()
325 << "' with unknown namespace '" << parser->element_namespace() << "'"); in FlattenXmlSubtree()
383 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in FlattenXmlSubtree()
396 bool ResourceParser::Parse(xml::XmlPullParser* parser) { in Parse() argument
398 const size_t depth = parser->depth(); in Parse()
399 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in Parse()
400 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in Parse()
405 if (!parser->element_namespace().empty() || parser->element_name() != "resources") { in Parse()
406 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in Parse()
411 error |= !ParseResources(parser); in Parse()
415 if (parser->event() == xml::XmlPullParser::Event::kBadDocument) { in Parse()
416 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in Parse()
417 << "xml parser error: " << parser->error()); in Parse()
423 bool ResourceParser::ParseResources(xml::XmlPullParser* parser) { in ParseResources() argument
428 const size_t depth = parser->depth(); in ParseResources()
429 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseResources()
430 const xml::XmlPullParser::Event event = parser->event(); in ParseResources()
432 comment = parser->comment(); in ParseResources()
437 if (!util::TrimWhitespace(parser->text()).empty()) { in ParseResources()
438 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseResources()
447 if (!parser->element_namespace().empty()) { in ParseResources()
452 std::string element_name = parser->element_name(); in ParseResources()
460 parsed_resource.source = source_.WithLine(parser->line_number()); in ParseResources()
468 if (std::optional<StringPiece> maybe_product = xml::FindNonEmptyAttribute(parser, "product")) { in ParseResources()
473 if (!ParseResource(parser, &parsed_resource)) { in ParseResources()
497 bool ResourceParser::ParseResource(xml::XmlPullParser* parser, in ParseResource() argument
546 std::string resource_type = parser->element_name(); in ParseResource()
561 if (std::optional<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type")) { in ParseResource()
564 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseResource()
569 if (std::optional<StringPiece> maybe_format = xml::FindNonEmptyAttribute(parser, "format")) { in ParseResource()
584 if (std::optional<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type")) { in ParseResource()
587 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseResource()
595 std::optional<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseResource()
600 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
609 auto item = ParseItem(parser, out_resource, resource_format); in ParseResource()
627 << "<" << parser->element_name() in ParseResource()
637 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
644 return ParseMacro(parser, out_resource); in ParseResource()
654 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
667 if (!ParseItem(parser, out_resource, resource_format)) { in ParseResource()
683 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
692 if (!bag_iter->second(this, parser, out_resource)) { in ParseResource()
706 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
712 out_resource->value = ParseXml(parser, android::ResTable_map::TYPE_REFERENCE, kNoRawString); in ParseResource()
728 bool ResourceParser::ParseItem(xml::XmlPullParser* parser, in ParseItem() argument
732 return ParseString(parser, out_resource); in ParseItem()
735 out_resource->value = ParseXml(parser, format, kNoRawString); in ParseItem()
745 xml::XmlPullParser* parser) { in CreateFlattenSubTree() argument
746 const size_t begin_xml_line = parser->line_number(); in CreateFlattenSubTree()
751 if (!FlattenXmlSubtree(parser, &raw_value, &style_string, &untranslatable_sections)) { in CreateFlattenSubTree()
758 .namespace_resolver = parser, in CreateFlattenSubTree()
769 std::unique_ptr<Item> ResourceParser::ParseXml(xml::XmlPullParser* parser, const uint32_t type_mask, in ParseXml() argument
771 auto sub_tree = CreateFlattenSubTree(parser); in ParseXml()
833 bool ResourceParser::ParseString(xml::XmlPullParser* parser, in ParseString() argument
836 if (std::optional<StringPiece> formatted_attr = xml::FindAttribute(parser, "formatted")) { in ParseString()
847 if (std::optional<StringPiece> translatable_attr = xml::FindAttribute(parser, "translatable")) { in ParseString()
858 ParseXml(parser, android::ResTable_map::TYPE_STRING, kNoRawString); in ParseString()
887 bool ResourceParser::ParseMacro(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseMacro() argument
888 auto sub_tree = CreateFlattenSubTree(parser); in ParseMacro()
905 for (const auto& decl : parser->package_decls()) { in ParseMacro()
916 bool ResourceParser::ParsePublic(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParsePublic() argument
928 std::optional<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type"); in ParsePublic()
944 if (std::optional<StringPiece> maybe_id_str = xml::FindNonEmptyAttribute(parser, "id")) { in ParsePublic()
964 bool static ParseGroupImpl(xml::XmlPullParser* parser, ParsedResource* out_resource, in ParseGroupImpl() argument
972 std::optional<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type"); in ParseGroupImpl()
988 std::optional<StringPiece> maybe_id_str = xml::FindNonEmptyAttribute(parser, "first-id"); in ParseGroupImpl()
1005 const size_t depth = parser->depth(); in ParseGroupImpl()
1006 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseGroupImpl()
1007 if (parser->event() == xml::XmlPullParser::Event::kComment) { in ParseGroupImpl()
1008 comment = std::string(util::TrimWhitespace(parser->comment())); in ParseGroupImpl()
1010 } else if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseGroupImpl()
1015 const android::Source item_source = out_resource->source.WithLine(parser->line_number()); in ParseGroupImpl()
1016 const std::string& element_namespace = parser->element_namespace(); in ParseGroupImpl()
1017 const std::string& element_name = parser->element_name(); in ParseGroupImpl()
1019 auto maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseGroupImpl()
1026 if (xml::FindNonEmptyAttribute(parser, "id")) { in ParseGroupImpl()
1033 if (xml::FindNonEmptyAttribute(parser, "type")) { in ParseGroupImpl()
1066 bool ResourceParser::ParseStagingPublicGroup(xml::XmlPullParser* parser, in ParseStagingPublicGroup() argument
1068 return ParseGroupImpl(parser, out_resource, kStagingPublicGroupTag, diag_, in ParseStagingPublicGroup()
1076 bool ResourceParser::ParseStagingPublicGroupFinal(xml::XmlPullParser* parser, in ParseStagingPublicGroupFinal() argument
1078 return ParseGroupImpl(parser, out_resource, kStagingPublicGroupFinalTag, diag_, in ParseStagingPublicGroupFinal()
1084 bool ResourceParser::ParsePublicGroup(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParsePublicGroup() argument
1091 return ParseGroupImpl(parser, out_resource, kPublicGroupTag, diag_, in ParsePublicGroup()
1098 bool ResourceParser::ParseSymbolImpl(xml::XmlPullParser* parser, in ParseSymbolImpl() argument
1100 std::optional<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type"); in ParseSymbolImpl()
1103 << "<" << parser->element_name() << "> must have a 'type' attribute"); in ParseSymbolImpl()
1111 << parser->element_name() << ">"); in ParseSymbolImpl()
1119 bool ResourceParser::ParseSymbol(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseSymbol() argument
1128 << parser->element_name() << "> tag"); in ParseSymbol()
1131 if (!ParseSymbolImpl(parser, out_resource)) { in ParseSymbol()
1139 bool ResourceParser::ParseOverlayable(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseOverlayable() argument
1145 std::optional<StringPiece> overlayable_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseOverlayable()
1154 std::optional<StringPiece> overlayable_actor = xml::FindNonEmptyAttribute(parser, "actor"); in ParseOverlayable()
1170 const size_t start_depth = parser->depth(); in ParseOverlayable()
1171 while (xml::XmlPullParser::IsGoodEvent(parser->Next())) { in ParseOverlayable()
1172 xml::XmlPullParser::Event event = parser->event(); in ParseOverlayable()
1173 if (event == xml::XmlPullParser::Event::kEndElement && parser->depth() == start_depth) { in ParseOverlayable()
1177 && parser->depth() == start_depth + 1) { in ParseOverlayable()
1183 comment = parser->comment(); in ParseOverlayable()
1190 const android::Source element_source = source_.WithLine(parser->line_number()); in ParseOverlayable()
1191 const std::string& element_name = parser->element_name(); in ParseOverlayable()
1192 const std::string& element_namespace = parser->element_namespace(); in ParseOverlayable()
1202 std::optional<StringPiece> item_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseOverlayable()
1210 std::optional<StringPiece> item_type = xml::FindNonEmptyAttribute(parser, "type"); in ParseOverlayable()
1246 xml::FindNonEmptyAttribute(parser, "type")) { in ParseOverlayable()
1285 bool ResourceParser::ParseAddResource(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseAddResource() argument
1286 if (ParseSymbolImpl(parser, out_resource)) { in ParseAddResource()
1294 bool ResourceParser::ParseAttr(xml::XmlPullParser* parser, in ParseAttr() argument
1296 return ParseAttrImpl(parser, out_resource, false); in ParseAttr()
1299 bool ResourceParser::ParseAttrImpl(xml::XmlPullParser* parser, in ParseAttrImpl() argument
1314 std::optional<StringPiece> maybe_format = xml::FindAttribute(parser, "format"); in ParseAttrImpl()
1318 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1326 if (std::optional<StringPiece> maybe_min_str = xml::FindAttribute(parser, "min")) { in ParseAttrImpl()
1337 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1343 if (std::optional<StringPiece> maybe_max_str = xml::FindAttribute(parser, "max")) { in ParseAttrImpl()
1354 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1362 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1377 const size_t depth = parser->depth(); in ParseAttrImpl()
1378 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseAttrImpl()
1379 if (parser->event() == xml::XmlPullParser::Event::kComment) { in ParseAttrImpl()
1380 comment = std::string(util::TrimWhitespace(parser->comment())); in ParseAttrImpl()
1382 } else if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseAttrImpl()
1387 const android::Source item_source = source_.WithLine(parser->line_number()); in ParseAttrImpl()
1388 const std::string& element_namespace = parser->element_namespace(); in ParseAttrImpl()
1389 const std::string& element_name = parser->element_name(); in ParseAttrImpl()
1410 if (std::optional<Attribute::Symbol> s = ParseEnumOrFlagItem(parser, element_name)) { in ParseAttrImpl()
1459 std::optional<Attribute::Symbol> ResourceParser::ParseEnumOrFlagItem(xml::XmlPullParser* parser, in ParseEnumOrFlagItem() argument
1461 const android::Source source = source_.WithLine(parser->line_number()); in ParseEnumOrFlagItem()
1463 std::optional<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseEnumOrFlagItem()
1470 std::optional<StringPiece> maybe_value = xml::FindNonEmptyAttribute(parser, "value"); in ParseEnumOrFlagItem()
1491 bool ResourceParser::ParseStyleItem(xml::XmlPullParser* parser, Style* style) { in ParseStyleItem() argument
1492 const android::Source source = source_.WithLine(parser->line_number()); in ParseStyleItem()
1494 std::optional<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseStyleItem()
1507 ResolvePackage(parser, &maybe_key.value()); in ParseStyleItem()
1510 std::unique_ptr<Item> value = ParseXml(parser, 0, kAllowRawString); in ParseStyleItem()
1520 bool ResourceParser::ParseStyle(const ResourceType type, xml::XmlPullParser* parser, in ParseStyle() argument
1526 std::optional<StringPiece> maybe_parent = xml::FindAttribute(parser, "parent"); in ParseStyle()
1539 ResolvePackage(parser, &style->parent.value()); in ParseStyle()
1554 const size_t depth = parser->depth(); in ParseStyle()
1555 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseStyle()
1556 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseStyle()
1561 const std::string& element_namespace = parser->element_namespace(); in ParseStyle()
1562 const std::string& element_name = parser->element_name(); in ParseStyle()
1564 error |= !ParseStyleItem(parser, style.get()); in ParseStyle()
1567 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseStyle()
1581 bool ResourceParser::ParseArray(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseArray() argument
1583 if (std::optional<StringPiece> format_attr = xml::FindNonEmptyAttribute(parser, "format")) { in ParseArray()
1586 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseArray()
1591 return ParseArrayImpl(parser, out_resource, resource_format); in ParseArray()
1594 bool ResourceParser::ParseIntegerArray(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseIntegerArray() argument
1595 return ParseArrayImpl(parser, out_resource, android::ResTable_map::TYPE_INTEGER); in ParseIntegerArray()
1598 bool ResourceParser::ParseStringArray(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseStringArray() argument
1599 return ParseArrayImpl(parser, out_resource, android::ResTable_map::TYPE_STRING); in ParseStringArray()
1602 bool ResourceParser::ParseArrayImpl(xml::XmlPullParser* parser, in ParseArrayImpl() argument
1611 if (std::optional<StringPiece> translatable_attr = xml::FindAttribute(parser, "translatable")) { in ParseArrayImpl()
1623 const size_t depth = parser->depth(); in ParseArrayImpl()
1624 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseArrayImpl()
1625 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseArrayImpl()
1630 const android::Source item_source = source_.WithLine(parser->line_number()); in ParseArrayImpl()
1631 const std::string& element_namespace = parser->element_namespace(); in ParseArrayImpl()
1632 const std::string& element_name = parser->element_name(); in ParseArrayImpl()
1634 std::unique_ptr<Item> item = ParseXml(parser, typeMask, kNoRawString); in ParseArrayImpl()
1644 diag_->Error(android::DiagMessage(source_.WithLine(parser->line_number())) in ParseArrayImpl()
1658 bool ResourceParser::ParsePlural(xml::XmlPullParser* parser, in ParsePlural() argument
1666 const size_t depth = parser->depth(); in ParsePlural()
1667 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParsePlural()
1668 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParsePlural()
1673 const android::Source item_source = source_.WithLine(parser->line_number()); in ParsePlural()
1674 const std::string& element_namespace = parser->element_namespace(); in ParsePlural()
1675 const std::string& element_name = parser->element_name(); in ParsePlural()
1677 std::optional<StringPiece> maybe_quantity = xml::FindNonEmptyAttribute(parser, "quantity"); in ParsePlural()
1716 parser, android::ResTable_map::TYPE_STRING, kNoRawString))) { in ParsePlural()
1738 bool ResourceParser::ParseDeclareStyleable(xml::XmlPullParser* parser, in ParseDeclareStyleable() argument
1764 const size_t depth = parser->depth(); in ParseDeclareStyleable()
1765 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseDeclareStyleable()
1766 if (parser->event() == xml::XmlPullParser::Event::kComment) { in ParseDeclareStyleable()
1767 comment = std::string(util::TrimWhitespace(parser->comment())); in ParseDeclareStyleable()
1769 } else if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseDeclareStyleable()
1774 const android::Source item_source = source_.WithLine(parser->line_number()); in ParseDeclareStyleable()
1775 const std::string& element_namespace = parser->element_namespace(); in ParseDeclareStyleable()
1776 const std::string& element_name = parser->element_name(); in ParseDeclareStyleable()
1778 std::optional<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseDeclareStyleable()
1798 xml::ResolvePackage(parser, &child_ref); in ParseDeclareStyleable()
1810 if (!ParseAttrImpl(parser, &child_resource, true)) { in ParseDeclareStyleable()