Remove redundant 'get_has_field_bit_message' versus 'is_field_present_message'

PiperOrigin-RevId: 696936553
pull/19277/head
Protobuf Team Bot 4 weeks ago committed by Copybara-Service
parent 8718872ce8
commit 9fdf3f89cf
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 3
      src/google/protobuf/compiler/java/full/enum_field.cc
  3. 32
      src/google/protobuf/compiler/java/full/message_field.cc
  4. 3
      src/google/protobuf/compiler/java/full/primitive_field.cc
  5. 4
      src/google/protobuf/compiler/java/full/string_field.cc
  6. 4
      src/google/protobuf/compiler/java/lite/enum_field.cc
  7. 52
      src/google/protobuf/compiler/java/lite/message_field.cc
  8. 4
      src/google/protobuf/compiler/java/lite/primitive_field.cc
  9. 4
      src/google/protobuf/compiler/java/lite/string_field.cc

@ -1,17 +0,0 @@
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#endregion
namespace Google.Protobuf.Reflection;
internal sealed partial class FeatureSetDescriptor
{
// Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
private const string DefaultsBase64 =
"ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
}

@ -63,7 +63,6 @@ void SetEnumVariables(
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
absl::StrCat(GenerateSetBit(messageBitIndex), ";");
@ -162,7 +161,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const {
printer->Print(variables_,
"@java.lang.Override $deprecation$public boolean "
"${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}

@ -57,8 +57,6 @@ void SetMessageVariables(
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_to_local"] =
GenerateSetBitToLocal(messageBitIndex);
@ -141,27 +139,15 @@ void ImmutableMessageFieldGenerator::GenerateMembers(
printer->Print(variables_, "private $type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHasbit(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
} else {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $name$_ != null;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER,
context_->options());
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, GETTER,
context_->options());
printer->Print(

@ -128,7 +128,6 @@ void SetPrimitiveVariables(
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_to_local"] =
absl::StrCat(GenerateSetBitToLocal(messageBitIndex), ";");
@ -243,7 +242,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}

@ -75,7 +75,6 @@ void SetPrimitiveVariables(
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
(*variables)["set_has_field_bit_to_local"] =
GenerateSetBitToLocal(messageBitIndex);
@ -85,7 +84,6 @@ void SetPrimitiveVariables(
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
} else {
(*variables)["get_has_field_bit_message"] = "";
(*variables)["set_has_field_bit_to_local"] = "";
(*variables)["set_has_field_bit_message"] = "";
@ -200,7 +198,7 @@ void ImmutableStringFieldGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}

@ -77,8 +77,6 @@ void SetEnumVariables(
absl::StrCat(1 << (messageBitIndex % 32));
}
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
absl::StrCat(GenerateSetBit(messageBitIndex), ";");
@ -173,7 +171,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}

@ -57,8 +57,6 @@ void SetMessageVariables(
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
absl::StrCat(GenerateSetBit(messageBitIndex), ";");
@ -129,41 +127,21 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
printer->Print(variables_, "private $type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
if (HasHasbit(descriptor_)) {
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
} else {
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $name$_ != null;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(
variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
// Field.Builder setField(Field value)
WriteFieldDocComment(printer, descriptor_, context_->options());

@ -127,8 +127,6 @@ void SetPrimitiveVariables(
if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
absl::StrCat(GenerateSetBit(messageBitIndex), ";");
@ -231,7 +229,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}

@ -75,8 +75,6 @@ void SetPrimitiveVariables(
absl::StrCat(1 << (messageBitIndex % 32));
}
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
// Note that these have a trailing ";".
(*variables)["set_has_field_bit_message"] =
absl::StrCat(GenerateSetBit(messageBitIndex), ";");
@ -190,7 +188,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers(
variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
" return $is_field_present_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
}

Loading…
Cancel
Save