Lines Matching refs:parser
233 xml::XmlPullParser* parser, std::string* out_raw_string, StyleString* out_style_string, in FlattenXmlSubtree() argument
250 while (depth > 0 && xml::XmlPullParser::IsGoodEvent(parser->Next())) { in FlattenXmlSubtree()
251 const xml::XmlPullParser::Event event = parser->event(); in FlattenXmlSubtree()
270 current_text += parser->text(); in FlattenXmlSubtree()
271 raw_string += parser->text(); in FlattenXmlSubtree()
275 if (parser->element_namespace().empty()) { in FlattenXmlSubtree()
278 span_node->name = parser->element_name(); in FlattenXmlSubtree()
279 const auto end_attr_iter = parser->end_attributes(); in FlattenXmlSubtree()
280 for (auto attr_iter = parser->begin_attributes(); attr_iter != end_attr_iter; in FlattenXmlSubtree()
290 } else if (parser->element_namespace() == sXliffNamespaceUri) { in FlattenXmlSubtree()
292 if (parser->element_name() == "g") { in FlattenXmlSubtree()
296 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in FlattenXmlSubtree()
311 diag_->Warn(DiagMessage(source_.WithLine(parser->line_number())) in FlattenXmlSubtree()
312 << "ignoring element '" << parser->element_name() in FlattenXmlSubtree()
313 << "' with unknown namespace '" << parser->element_namespace() << "'"); in FlattenXmlSubtree()
371 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) << builder.GetError()); in FlattenXmlSubtree()
383 bool ResourceParser::Parse(xml::XmlPullParser* parser) { in Parse() argument
385 const size_t depth = parser->depth(); in Parse()
386 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in Parse()
387 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in Parse()
392 if (!parser->element_namespace().empty() || parser->element_name() != "resources") { in Parse()
393 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in Parse()
398 error |= !ParseResources(parser); in Parse()
402 if (parser->event() == xml::XmlPullParser::Event::kBadDocument) { in Parse()
403 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in Parse()
404 << "xml parser error: " << parser->error()); in Parse()
410 bool ResourceParser::ParseResources(xml::XmlPullParser* parser) { in ParseResources() argument
415 const size_t depth = parser->depth(); in ParseResources()
416 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseResources()
417 const xml::XmlPullParser::Event event = parser->event(); in ParseResources()
419 comment = parser->comment(); in ParseResources()
424 if (!util::TrimWhitespace(parser->text()).empty()) { in ParseResources()
425 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseResources()
434 if (!parser->element_namespace().empty()) { in ParseResources()
439 std::string element_name = parser->element_name(); in ParseResources()
447 parsed_resource.source = source_.WithLine(parser->line_number()); in ParseResources()
455 if (Maybe<StringPiece> maybe_product = xml::FindNonEmptyAttribute(parser, "product")) { in ParseResources()
460 if (!ParseResource(parser, &parsed_resource)) { in ParseResources()
483 bool ResourceParser::ParseResource(xml::XmlPullParser* parser, in ParseResource() argument
530 std::string resource_type = parser->element_name(); in ParseResource()
545 if (Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type")) { in ParseResource()
548 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseResource()
553 if (Maybe<StringPiece> maybe_format = xml::FindNonEmptyAttribute(parser, "format")) { in ParseResource()
569 if (Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type")) { in ParseResource()
572 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseResource()
580 Maybe<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseResource()
585 << "<" << parser->element_name() in ParseResource()
594 auto item = ParseItem(parser, out_resource, resource_format); in ParseResource()
612 << "<" << parser->element_name() in ParseResource()
628 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
640 if (!ParseItem(parser, out_resource, resource_format)) { in ParseResource()
655 << "<" << parser->element_name() << "> missing 'name' attribute"); in ParseResource()
664 if (!bag_iter->second(this, parser, out_resource)) { in ParseResource()
678 << "<" << parser->element_name() in ParseResource()
685 out_resource->value = ParseXml(parser, android::ResTable_map::TYPE_REFERENCE, kNoRawString); in ParseResource()
701 bool ResourceParser::ParseItem(xml::XmlPullParser* parser, in ParseItem() argument
705 return ParseString(parser, out_resource); in ParseItem()
708 out_resource->value = ParseXml(parser, format, kNoRawString); in ParseItem()
724 std::unique_ptr<Item> ResourceParser::ParseXml(xml::XmlPullParser* parser, in ParseXml() argument
727 const size_t begin_xml_line = parser->line_number(); in ParseXml()
732 if (!FlattenXmlSubtree(parser, &raw_value, &style_string, &untranslatable_sections)) { in ParseXml()
759 ResolvePackage(parser, ref); in ParseXml()
787 bool ResourceParser::ParseString(xml::XmlPullParser* parser, in ParseString() argument
791 xml::FindAttribute(parser, "formatted")) { in ParseString()
803 if (Maybe<StringPiece> translatable_attr = xml::FindAttribute(parser, "translatable")) { in ParseString()
814 ParseXml(parser, android::ResTable_map::TYPE_STRING, kNoRawString); in ParseString()
843 bool ResourceParser::ParsePublic(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParsePublic() argument
855 Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type"); in ParsePublic()
872 if (Maybe<StringPiece> maybe_id_str = xml::FindNonEmptyAttribute(parser, "id")) { in ParsePublic()
891 bool ResourceParser::ParsePublicGroup(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParsePublicGroup() argument
904 Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type"); in ParsePublicGroup()
920 xml::FindNonEmptyAttribute(parser, "first-id"); in ParsePublicGroup()
940 const size_t depth = parser->depth(); in ParsePublicGroup()
941 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParsePublicGroup()
942 if (parser->event() == xml::XmlPullParser::Event::kComment) { in ParsePublicGroup()
943 comment = util::TrimWhitespace(parser->comment()).to_string(); in ParsePublicGroup()
945 } else if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParsePublicGroup()
950 const Source item_source = source_.WithLine(parser->line_number()); in ParsePublicGroup()
951 const std::string& element_namespace = parser->element_namespace(); in ParsePublicGroup()
952 const std::string& element_name = parser->element_name(); in ParsePublicGroup()
955 xml::FindNonEmptyAttribute(parser, "name"); in ParsePublicGroup()
963 if (xml::FindNonEmptyAttribute(parser, "id")) { in ParsePublicGroup()
970 if (xml::FindNonEmptyAttribute(parser, "type")) { in ParsePublicGroup()
997 bool ResourceParser::ParseSymbolImpl(xml::XmlPullParser* parser, in ParseSymbolImpl() argument
999 Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type"); in ParseSymbolImpl()
1002 << "<" << parser->element_name() in ParseSymbolImpl()
1011 << parser->element_name() << ">"); in ParseSymbolImpl()
1019 bool ResourceParser::ParseSymbol(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseSymbol() argument
1028 << parser->element_name() << "> tag"); in ParseSymbol()
1031 if (!ParseSymbolImpl(parser, out_resource)) { in ParseSymbol()
1039 bool ResourceParser::ParseOverlayable(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseOverlayable() argument
1046 Maybe<StringPiece> overlayable_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseOverlayable()
1055 Maybe<StringPiece> overlayable_actor = xml::FindNonEmptyAttribute(parser, "actor"); in ParseOverlayable()
1071 const size_t start_depth = parser->depth(); in ParseOverlayable()
1072 while (xml::XmlPullParser::IsGoodEvent(parser->Next())) { in ParseOverlayable()
1073 xml::XmlPullParser::Event event = parser->event(); in ParseOverlayable()
1074 if (event == xml::XmlPullParser::Event::kEndElement && parser->depth() == start_depth) { in ParseOverlayable()
1078 && parser->depth() == start_depth + 1) { in ParseOverlayable()
1084 comment = parser->comment(); in ParseOverlayable()
1091 const Source element_source = source_.WithLine(parser->line_number()); in ParseOverlayable()
1092 const std::string& element_name = parser->element_name(); in ParseOverlayable()
1093 const std::string& element_namespace = parser->element_namespace(); in ParseOverlayable()
1103 Maybe<StringPiece> item_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseOverlayable()
1111 Maybe<StringPiece> item_type = xml::FindNonEmptyAttribute(parser, "type"); in ParseOverlayable()
1145 } else if (Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type")) { in ParseOverlayable()
1190 bool ResourceParser::ParseAddResource(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseAddResource() argument
1191 if (ParseSymbolImpl(parser, out_resource)) { in ParseAddResource()
1199 bool ResourceParser::ParseAttr(xml::XmlPullParser* parser, in ParseAttr() argument
1201 return ParseAttrImpl(parser, out_resource, false); in ParseAttr()
1204 bool ResourceParser::ParseAttrImpl(xml::XmlPullParser* parser, in ParseAttrImpl() argument
1218 Maybe<StringPiece> maybe_format = xml::FindAttribute(parser, "format"); in ParseAttrImpl()
1222 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1230 if (Maybe<StringPiece> maybe_min_str = xml::FindAttribute(parser, "min")) { in ParseAttrImpl()
1241 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1247 if (Maybe<StringPiece> maybe_max_str = xml::FindAttribute(parser, "max")) { in ParseAttrImpl()
1258 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1266 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseAttrImpl()
1281 const size_t depth = parser->depth(); in ParseAttrImpl()
1282 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseAttrImpl()
1283 if (parser->event() == xml::XmlPullParser::Event::kComment) { in ParseAttrImpl()
1284 comment = util::TrimWhitespace(parser->comment()).to_string(); in ParseAttrImpl()
1286 } else if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseAttrImpl()
1291 const Source item_source = source_.WithLine(parser->line_number()); in ParseAttrImpl()
1292 const std::string& element_namespace = parser->element_namespace(); in ParseAttrImpl()
1293 const std::string& element_name = parser->element_name(); in ParseAttrImpl()
1315 ParseEnumOrFlagItem(parser, element_name)) { in ParseAttrImpl()
1366 xml::XmlPullParser* parser, const StringPiece& tag) { in ParseEnumOrFlagItem() argument
1367 const Source source = source_.WithLine(parser->line_number()); in ParseEnumOrFlagItem()
1369 Maybe<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseEnumOrFlagItem()
1376 Maybe<StringPiece> maybe_value = xml::FindNonEmptyAttribute(parser, "value"); in ParseEnumOrFlagItem()
1397 bool ResourceParser::ParseStyleItem(xml::XmlPullParser* parser, Style* style) { in ParseStyleItem() argument
1398 const Source source = source_.WithLine(parser->line_number()); in ParseStyleItem()
1400 Maybe<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseStyleItem()
1412 ResolvePackage(parser, &maybe_key.value()); in ParseStyleItem()
1415 std::unique_ptr<Item> value = ParseXml(parser, 0, kAllowRawString); in ParseStyleItem()
1425 bool ResourceParser::ParseStyle(const ResourceType type, xml::XmlPullParser* parser, in ParseStyle() argument
1431 Maybe<StringPiece> maybe_parent = xml::FindAttribute(parser, "parent"); in ParseStyle()
1444 ResolvePackage(parser, &style->parent.value()); in ParseStyle()
1458 const size_t depth = parser->depth(); in ParseStyle()
1459 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseStyle()
1460 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseStyle()
1465 const std::string& element_namespace = parser->element_namespace(); in ParseStyle()
1466 const std::string& element_name = parser->element_name(); in ParseStyle()
1468 error |= !ParseStyleItem(parser, style.get()); in ParseStyle()
1471 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseStyle()
1485 bool ResourceParser::ParseArray(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseArray() argument
1487 if (Maybe<StringPiece> format_attr = xml::FindNonEmptyAttribute(parser, "format")) { in ParseArray()
1490 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseArray()
1495 return ParseArrayImpl(parser, out_resource, resource_format); in ParseArray()
1498 bool ResourceParser::ParseIntegerArray(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseIntegerArray() argument
1499 return ParseArrayImpl(parser, out_resource, android::ResTable_map::TYPE_INTEGER); in ParseIntegerArray()
1502 bool ResourceParser::ParseStringArray(xml::XmlPullParser* parser, ParsedResource* out_resource) { in ParseStringArray() argument
1503 return ParseArrayImpl(parser, out_resource, android::ResTable_map::TYPE_STRING); in ParseStringArray()
1506 bool ResourceParser::ParseArrayImpl(xml::XmlPullParser* parser, in ParseArrayImpl() argument
1514 if (Maybe<StringPiece> translatable_attr = xml::FindAttribute(parser, "translatable")) { in ParseArrayImpl()
1526 const size_t depth = parser->depth(); in ParseArrayImpl()
1527 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseArrayImpl()
1528 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseArrayImpl()
1533 const Source item_source = source_.WithLine(parser->line_number()); in ParseArrayImpl()
1534 const std::string& element_namespace = parser->element_namespace(); in ParseArrayImpl()
1535 const std::string& element_name = parser->element_name(); in ParseArrayImpl()
1537 std::unique_ptr<Item> item = ParseXml(parser, typeMask, kNoRawString); in ParseArrayImpl()
1547 diag_->Error(DiagMessage(source_.WithLine(parser->line_number())) in ParseArrayImpl()
1562 bool ResourceParser::ParsePlural(xml::XmlPullParser* parser, in ParsePlural() argument
1569 const size_t depth = parser->depth(); in ParsePlural()
1570 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParsePlural()
1571 if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParsePlural()
1576 const Source item_source = source_.WithLine(parser->line_number()); in ParsePlural()
1577 const std::string& element_namespace = parser->element_namespace(); in ParsePlural()
1578 const std::string& element_name = parser->element_name(); in ParsePlural()
1581 xml::FindNonEmptyAttribute(parser, "quantity"); in ParsePlural()
1621 parser, android::ResTable_map::TYPE_STRING, kNoRawString))) { in ParsePlural()
1644 bool ResourceParser::ParseDeclareStyleable(xml::XmlPullParser* parser, in ParseDeclareStyleable() argument
1669 const size_t depth = parser->depth(); in ParseDeclareStyleable()
1670 while (xml::XmlPullParser::NextChildNode(parser, depth)) { in ParseDeclareStyleable()
1671 if (parser->event() == xml::XmlPullParser::Event::kComment) { in ParseDeclareStyleable()
1672 comment = util::TrimWhitespace(parser->comment()).to_string(); in ParseDeclareStyleable()
1674 } else if (parser->event() != xml::XmlPullParser::Event::kStartElement) { in ParseDeclareStyleable()
1679 const Source item_source = source_.WithLine(parser->line_number()); in ParseDeclareStyleable()
1680 const std::string& element_namespace = parser->element_namespace(); in ParseDeclareStyleable()
1681 const std::string& element_name = parser->element_name(); in ParseDeclareStyleable()
1683 Maybe<StringPiece> maybe_name = xml::FindNonEmptyAttribute(parser, "name"); in ParseDeclareStyleable()
1702 xml::ResolvePackage(parser, &child_ref); in ParseDeclareStyleable()
1714 if (!ParseAttrImpl(parser, &child_resource, true)) { in ParseDeclareStyleable()