Fixing more kokoro tests

pull/8272/head
Deanna Garcia 4 years ago
parent 887462a435
commit 8399bb81b1
  1. 34
      src/google/protobuf/compiler/java/java_helpers.cc
  2. 7
      src/google/protobuf/compiler/java/java_helpers.h

@ -166,6 +166,38 @@ void PrintEnumVerifierLogic(io::Printer* printer,
StrCat(enum_verifier_string, terminating_string).c_str());
}
std::string ToCamelCase(const std::string& input, bool lower_first) {
bool capitalize_next = !lower_first;
std::string result;
result.reserve(input.size());
for (char i : input) {
if (i == '_') {
capitalize_next = true;
} else if (capitalize_next) {
result.push_back(ToUpperCh(i));
capitalize_next = false;
} else {
result.push_back(i);
}
}
// Lower-case the first letter.
if (lower_first && !result.empty()) {
result[0] = ToLowerCh(result[0]);
}
return result;
}
char ToUpperCh(char ch) {
return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
}
char ToLowerCh(char ch) {
return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
}
std::string UnderscoresToCamelCase(const std::string& input,
bool cap_next_letter) {
GOOGLE_CHECK(!input.empty());
@ -462,7 +494,7 @@ const char* KotlinTypeName(JavaType type) {
// JavaTypes are added.
}
LOG(FATAL) << "Can't get here.";
GOOGLE_LOG(FATAL) << "Can't get here.";
return NULL;
}

@ -72,6 +72,13 @@ void PrintEnumVerifierLogic(io::Printer* printer,
const char* var_name,
const char* terminating_string, bool enforce_lite);
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
std::string ToCamelCase(const std::string& input, bool lower_first);
char ToUpperCh(char ch);
char ToLowerCh(char ch);
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
std::string UnderscoresToCamelCase(const std::string& name,

Loading…
Cancel
Save