Merge "Do not use StringPiece in ExtractJavaIdentifier"
am: 20ecc6397b
Change-Id: I3c70a4b9db43d9590f52cdb6972cf9fba3501787
This commit is contained in:
committed by
android-build-merger
commit
206ccf1f61
@@ -26,21 +26,20 @@
|
|||||||
#include "util/Maybe.h"
|
#include "util/Maybe.h"
|
||||||
#include "xml/XmlDom.h"
|
#include "xml/XmlDom.h"
|
||||||
|
|
||||||
using ::android::StringPiece;
|
|
||||||
using ::aapt::text::IsJavaIdentifier;
|
using ::aapt::text::IsJavaIdentifier;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
static Maybe<StringPiece> ExtractJavaIdentifier(IDiagnostics* diag, const Source& source,
|
static Maybe<std::string> ExtractJavaIdentifier(IDiagnostics* diag, const Source& source,
|
||||||
const std::string& value) {
|
const std::string& value) {
|
||||||
StringPiece result = value;
|
std::string result = value;
|
||||||
size_t pos = value.rfind('.');
|
size_t pos = value.rfind('.');
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
result = result.substr(pos + 1);
|
result = result.substr(pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize only the java identifier, leave the original value unchanged.
|
// Normalize only the java identifier, leave the original value unchanged.
|
||||||
if (result.contains("-")) {
|
if (result.find("-") != std::string::npos) {
|
||||||
result = JavaClassGenerator::TransformToFieldName(result);
|
result = JavaClassGenerator::TransformToFieldName(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ static bool WriteSymbol(const Source& source, IDiagnostics* diag, xml::Element*
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<StringPiece> result =
|
Maybe<std::string> result =
|
||||||
ExtractJavaIdentifier(diag, source.WithLine(el->line_number), attr->value);
|
ExtractJavaIdentifier(diag, source.WithLine(el->line_number), attr->value);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user