Automated rollback of commit e9c9970eb4.

PiperOrigin-RevId: 629405086
pull/16677/head
Éamonn McManus 9 months ago committed by Copybara-Service
parent 959903d199
commit c24e7529eb
  1. 28
      java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt
  2. 14
      java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt
  3. 9
      java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto
  4. 6
      java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto
  5. 1
      src/google/protobuf/compiler/java/BUILD.bazel
  6. 56
      src/google/protobuf/compiler/java/field_common.cc
  7. 10
      src/google/protobuf/compiler/java/immutable/enum_field.cc
  8. 2
      src/google/protobuf/compiler/java/immutable/map_field.cc
  9. 6
      src/google/protobuf/compiler/java/immutable/message_field.cc
  10. 31
      src/google/protobuf/compiler/java/immutable/primitive_field.cc
  11. 6
      src/google/protobuf/compiler/java/immutable/string_field.cc
  12. 10
      src/google/protobuf/compiler/java/lite/enum_field.cc
  13. 2
      src/google/protobuf/compiler/java/lite/map_field.cc
  14. 6
      src/google/protobuf/compiler/java/lite/message_field.cc
  15. 38
      src/google/protobuf/compiler/java/lite/primitive_field.cc
  16. 6
      src/google/protobuf/compiler/java/lite/string_field.cc

@ -225,7 +225,7 @@ class Proto2Test {
TestAllTypesKt.repeatedGroup { a = 1 },
TestAllTypesKt.repeatedGroup { a = 2 },
TestAllTypesKt.repeatedGroup { a = 3 },
TestAllTypesKt.repeatedGroup { a = 4 },
TestAllTypesKt.repeatedGroup { a = 4 }
)
)
repeatedGroup[0] = TestAllTypesKt.repeatedGroup { a = 5 }
@ -235,7 +235,7 @@ class Proto2Test {
TestAllTypesKt.repeatedGroup { a = 5 },
TestAllTypesKt.repeatedGroup { a = 2 },
TestAllTypesKt.repeatedGroup { a = 3 },
TestAllTypesKt.repeatedGroup { a = 4 },
TestAllTypesKt.repeatedGroup { a = 4 }
)
)
@ -249,7 +249,7 @@ class Proto2Test {
nestedMessage { bb = 1 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 },
nestedMessage { bb = 4 }
)
)
repeatedNestedMessage[0] = nestedMessage { bb = 5 }
@ -259,7 +259,7 @@ class Proto2Test {
nestedMessage { bb = 5 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 },
nestedMessage { bb = 4 }
)
)
@ -548,7 +548,7 @@ class Proto2Test {
repeatedGroupExtension { a = 1 },
repeatedGroupExtension { a = 2 },
repeatedGroupExtension { a = 3 },
repeatedGroupExtension { a = 4 },
repeatedGroupExtension { a = 4 }
)
)
this[UnittestProto.repeatedGroupExtension][0] = repeatedGroupExtension { a = 5 }
@ -558,7 +558,7 @@ class Proto2Test {
repeatedGroupExtension { a = 5 },
repeatedGroupExtension { a = 2 },
repeatedGroupExtension { a = 3 },
repeatedGroupExtension { a = 4 },
repeatedGroupExtension { a = 4 }
)
)
@ -575,7 +575,7 @@ class Proto2Test {
nestedMessage { bb = 1 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 },
nestedMessage { bb = 4 }
)
)
this[UnittestProto.repeatedNestedMessageExtension][0] = nestedMessage { bb = 5 }
@ -585,7 +585,7 @@ class Proto2Test {
nestedMessage { bb = 5 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 },
nestedMessage { bb = 4 }
)
)
@ -757,7 +757,7 @@ class Proto2Test {
1 to Proto2MapEnum.PROTO2_MAP_ENUM_FOO,
2 to Proto2MapEnum.PROTO2_MAP_ENUM_BAR,
3 to Proto2MapEnum.PROTO2_MAP_ENUM_BAZ,
4 to Proto2MapEnum.PROTO2_MAP_ENUM_FOO,
4 to Proto2MapEnum.PROTO2_MAP_ENUM_FOO
)
)
}
@ -844,11 +844,6 @@ class Proto2Test {
cachedSize_ = "foo"
serializedSize_ = true
by = "foo"
dEPRECATEDFoo = "foo"
DEPRECATEDBar = "foo"
iD = "foo"
aBNotification = "foo"
notDEPRECATEDFoo = "foo"
}
)
.isEqualTo(
@ -874,11 +869,6 @@ class Proto2Test {
.setCachedSize_("foo")
.setSerializedSize_(true)
.setBy("foo")
.setDEPRECATEDFoo("foo")
.setDEPRECATEDBar("foo")
.setID("foo")
.setABNotification("foo")
.setNotDEPRECATEDFoo("foo")
.build()
)

@ -81,7 +81,7 @@ class Proto3Test {
nestedMessage { bb = 1 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 },
nestedMessage { bb = 4 }
)
)
repeatedNestedMessage[0] = nestedMessage { bb = 5 }
@ -91,7 +91,7 @@ class Proto3Test {
nestedMessage { bb = 5 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 },
nestedMessage { bb = 4 }
)
)
@ -200,11 +200,6 @@ class Proto3Test {
pairs["foo"] = 1
LeadingUnderscore = "foo"
option = 1
dEPRECATEDFoo = "foo"
iD = "foo"
aBNotification = "foo"
DEPRECATEDBar = "foo"
notDEPRECATEDFoo = "foo"
}
)
.isEqualTo(
@ -242,11 +237,6 @@ class Proto3Test {
.putPairs("foo", 1)
.setLeadingUnderscore("foo")
.setOption(1)
.setDEPRECATEDFoo("foo")
.setID("foo")
.setABNotification("foo")
.setDEPRECATEDBar("foo")
.setNotDEPRECATEDFoo("foo")
.build()
)

@ -43,15 +43,6 @@ message EvilNamesProto2 {
optional string cached_size = 23;
optional bool serialized_size = 24;
optional string by = 25;
optional string DEPRECATED_foo = 26;
optional group DEPRECATED_NavigationImageRequested = 27 {
optional int32 DEPRECATED_FooBar = 28;
}
optional string __DEPRECATED_Bar = 29;
optional string ID = 30;
optional string a_b_notification = 31;
optional string not_DEPRECATED_foo = 32;
}
message List {}

@ -56,12 +56,6 @@ message EvilNamesProto3 {
oneof _leading_underscore_oneof {
int32 option = 34;
}
optional string DEPRECATED_foo = 35;
optional string ID = 36;
optional string a_b_notification = 37;
optional string __DEPRECATED_Bar = 38;
optional string not_DEPRECATED_foo = 39;
}
message HardKeywordsAllTypesProto3 {

@ -144,7 +144,6 @@ cc_library(
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
],
)

@ -1,11 +1,8 @@
#include "google/protobuf/compiler/java/field_common.h"
#include <cstddef>
#include <string>
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/java/helpers.h"
#include "google/protobuf/compiler/java/names.h"
#include "google/protobuf/descriptor.h"
namespace google {
@ -13,8 +10,6 @@ namespace protobuf {
namespace compiler {
namespace java {
std::string GetKotlinPropertyName(const FieldDescriptor* descriptor);
void SetCommonFieldVariables(
const FieldDescriptor* descriptor, const FieldGeneratorInfo* info,
absl::flat_hash_map<absl::string_view, std::string>* variables) {
@ -35,11 +30,6 @@ void SetCommonFieldVariables(
(*variables)["kt_name"] = IsForbiddenKotlin(info->name)
? absl::StrCat(info->name, "_")
: info->name;
auto kt_property_name = GetKotlinPropertyName(descriptor);
(*variables)["kt_property_name"] = kt_property_name;
(*variables)["kt_safe_name"] = IsForbiddenKotlin(kt_property_name)
? absl::StrCat("`", kt_property_name, "`")
: kt_property_name;
(*variables)["kt_capitalized_name"] =
IsForbiddenKotlin(info->name) ? absl::StrCat(info->capitalized_name, "_")
: info->capitalized_name;
@ -61,52 +51,6 @@ void SetCommonFieldVariables(
}
}
// Locale-independent ASCII upper and lower case munging.
static bool IsUpper(char c) {
return static_cast<unsigned int>(c - 'A') <= 'Z' - 'A';
}
static char ToLower(char c) { return IsUpper(c) ? c - 'A' + 'a' : c; }
// Returns the name by which the generated Java getters and setters should be
// referenced from Kotlin as properties. In the simplest case, the original name
// is something like `foo_bar`, which gets translated into `getFooBar()` etc,
// and that in turn can be referenced from Kotlin as `fooBar`.
//
// The algorithm for translating proto names into Java getters and setters is
// straightforward. The first letter of each underscore-separated word gets
// uppercased and the underscores are deleted. There are no other changes, so in
// particular if the proto name has a string of capitals then those remain
// as-is.
//
// The algorithm that the Kotlin compiler uses to derive the property name is
// slightly more complicated. If the first character after `get` (etc) is a
// capital and the second isn't, then the property name is just that string with
// its first letter lowercased. So `getFoo` becomes `foo` and `getX` becomes
// `x`. But if there is more than one capital, then all but the last get
// lowercased. So `getHTMLPage` becomes `htmlPage`. If there are only capitals
// then they all get lowercased, so `getID` becomes `id`.
// TODO: move this to a Kotlin-specific location
std::string GetKotlinPropertyName(const FieldDescriptor* descriptor) {
// Find the first non-capital. If it is the second character, then we just
// need to lowercase the first one. Otherwise we need to lowercase everything
// up to but not including the last capital, except that if everything is
// capitals then everything must be lowercased.
std::string capitalized_name = CapitalizedFieldName(descriptor);
std::string kt_property_name = capitalized_name;
size_t first_non_capital;
for (first_non_capital = 0; first_non_capital < capitalized_name.length() &&
IsUpper(capitalized_name[first_non_capital]);
first_non_capital++) {
}
size_t stop = first_non_capital;
if (stop > 1 && stop < capitalized_name.length()) stop--;
for (size_t i = 0; i < stop; i++) {
kt_property_name[i] = ToLower(kt_property_name[i]);
}
return kt_property_name;
}
void SetCommonOneofVariables(
const FieldDescriptor* descriptor, const OneofGeneratorInfo* info,
absl::flat_hash_map<absl::string_view, std::string>* variables) {

@ -273,10 +273,10 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
if (SupportUnknownEnumValue(descriptor_)) {
@ -284,10 +284,10 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
variables_,
"$kt_deprecation$public var $kt_name$Value: kotlin.Int\n"
" @JvmName(\"${$get$kt_capitalized_name$Value$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_property_name$Value$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$Value$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$Value$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_property_name$Value$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$Value$}$(value)\n"
" }\n");
}
@ -1100,7 +1100,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,

@ -981,7 +981,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
" @kotlin.jvm.JvmSynthetic\n"
" @JvmName(\"get$kt_capitalized_name$Map\")\n"
" get() = com.google.protobuf.kotlin.DslMap(\n"
" $kt_dsl_builder$.${$$kt_property_name$Map$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
" )\n");
WriteFieldDocComment(printer, descriptor_, context_->options(),

@ -378,10 +378,10 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
@ -1376,7 +1376,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,

@ -291,27 +291,14 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_, context_->options(),
/* kdoc */ true);
if (descriptor_->name() == "is_initialized") {
printer->Print(
variables_,
"// TODO: remove this hack; we should access properties\n"
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$kt_capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$set$kt_capitalized_name$$}$(value)\n"
" }\n");
} else {
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" }\n");
}
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
context_->options(),
@ -861,7 +848,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,

@ -372,10 +372,10 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: kotlin.String\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
@ -992,7 +992,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
// List<String>.add(String)

@ -308,10 +308,10 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
if (SupportUnknownEnumValue(descriptor_)) {
@ -319,10 +319,10 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"$kt_deprecation$public var $kt_name$Value: kotlin.Int\n"
" @JvmName(\"${$get$kt_capitalized_name$Value$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_property_name$Value$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$Value$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$Value$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_property_name$Value$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$Value$}$(value)\n"
" }\n");
}
@ -914,7 +914,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,

@ -857,7 +857,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
" @kotlin.jvm.JvmSynthetic\n"
" @JvmName(\"get$kt_capitalized_name$Map\")\n"
" get() = com.google.protobuf.kotlin.DslMap(\n"
" $kt_dsl_builder$.${$$kt_property_name$Map$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
" )\n");
WriteFieldDocComment(printer, descriptor_, context_->options(),

@ -283,10 +283,10 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
@ -818,7 +818,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,

@ -217,9 +217,10 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
"private static final $field_type$ $bytes_default$ = $default$;\n");
}
if (!context_->options().opensource_runtime) {
printer->Print(variables_,
"@com.google.protobuf.ProtoField(\n"
" isRequired=$required$)\n");
printer->Print(
variables_,
"@com.google.protobuf.ProtoField(\n"
" isRequired=$required$)\n");
if (HasHasbit(descriptor_)) {
printer->Print(variables_,
"@com.google.protobuf.ProtoPresenceCheckedField(\n"
@ -328,27 +329,14 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_, context_->options());
if (descriptor_->name() == "is_initialized") {
printer->Print(
variables_,
"// TODO: b/336400327 - remove this hack; we should access properties\n"
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.get${$$kt_capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$set$kt_capitalized_name$$}$(value)\n"
" }\n");
} else {
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" }\n");
}
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: $kt_type$\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
context_->options(),
@ -730,7 +718,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,

@ -336,10 +336,10 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"$kt_deprecation$public var $kt_name$: kotlin.String\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
" set(value) {\n"
" $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
" }\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
@ -825,7 +825,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$$kt_property_name$List$}$\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
// List<String>.add(String)

Loading…
Cancel
Save