A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/protocolbuffers/protobuf/commit/527b2ab41e785149a6189dba3052a210959b1372 below:

Add Kotlin class name helpers to names.h · protocolbuffers/protobuf@527b2ab · GitHub

File tree Expand file treeCollapse file tree 5 files changed

+65

-0

lines changed

Filter options

Expand file treeCollapse file tree 5 files changed

+65

-0

lines changed Original file line number Diff line number Diff line change

@@ -354,6 +354,19 @@ std::string ClassNameResolver::GetKotlinFactoryName(

354 354

return IsForbiddenKotlin(name) ? absl::StrCat(name, "_") : name;

355 355

}

356 356 357 +

std::string ClassNameResolver::GetFullyQualifiedKotlinFactoryName(

358 +

const Descriptor* descriptor) {

359 +

if (descriptor->containing_type() != nullptr) {

360 +

return absl::StrCat(

361 +

GetKotlinExtensionsClassName(descriptor->containing_type()), ".",

362 +

GetKotlinFactoryName(descriptor));

363 +

} else {

364 +

return absl::StrCat(

365 +

GetFileJavaPackage(descriptor->file(), /*immutable=*/true), ".",

366 +

GetKotlinFactoryName(descriptor));

367 +

}

368 +

}

369 + 357 370

std::string ClassNameResolver::GetJavaImmutableClassName(

358 371

const Descriptor* descriptor) {

359 372

return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, true),

Original file line number Diff line number Diff line change

@@ -99,6 +99,7 @@ class PROTOC_EXPORT ClassNameResolver {

99 99

std::string GetJavaImmutableClassName(const EnumDescriptor* descriptor);

100 100

std::string GetJavaImmutableClassName(const ServiceDescriptor* descriptor);

101 101

std::string GetKotlinFactoryName(const Descriptor* descriptor);

102 +

std::string GetFullyQualifiedKotlinFactoryName(const Descriptor* descriptor);

102 103

std::string GetKotlinExtensionsClassName(const Descriptor* descriptor);

103 104

std::string GetKotlinExtensionsClassNameEscaped(const Descriptor* descriptor);

104 105

std::string GetFileJavaPackage(const FileDescriptor* file, bool immutable);

Original file line number Diff line number Diff line change

@@ -242,6 +242,8 @@ TEST_F(NameResolverTest, MultipleFilesMessageEdition2023) {

242 242

PACKAGE_PREFIX "proto2_unittest.FooMessage");

243 243

EXPECT_EQ(resolver.GetJavaImmutableClassName(message_descriptor),

244 244

PACKAGE_PREFIX "proto2_unittest.FooMessage");

245 +

EXPECT_EQ(resolver.GetFullyQualifiedKotlinFactoryName(message_descriptor),

246 +

PACKAGE_PREFIX "proto2_unittest.fooMessage");

245 247

}

246 248 247 249

TEST_F(NameResolverTest, SingleFileMessageEdition2023) {

@@ -262,6 +264,8 @@ TEST_F(NameResolverTest, SingleFileMessageEdition2023) {

262 264

PACKAGE_PREFIX "proto2_unittest.Foo.FooMessage");

263 265

EXPECT_EQ(resolver.GetJavaImmutableClassName(message_descriptor),

264 266

PACKAGE_PREFIX "proto2_unittest.Foo$FooMessage");

267 +

EXPECT_EQ(resolver.GetFullyQualifiedKotlinFactoryName(message_descriptor),

268 +

PACKAGE_PREFIX "proto2_unittest.fooMessage");

265 269

}

266 270 267 271

TEST_F(NameResolverTest, NestInFileClassMessageEdition2024) {

@@ -307,6 +311,14 @@ TEST_F(NameResolverTest, NestInFileClassMessageEdition2024) {

307 311

EXPECT_EQ(resolver.GetJavaImmutableClassName(nested_in_unnested_message),

308 312

PACKAGE_PREFIX

309 313

"proto2_unittest.UnnestedMessage$NestedInUnnestedMessage");

314 +

EXPECT_EQ(resolver.GetFullyQualifiedKotlinFactoryName(unnested_message),

315 +

PACKAGE_PREFIX "proto2_unittest.unnestedMessage");

316 +

EXPECT_EQ(resolver.GetFullyQualifiedKotlinFactoryName(nested_in_file_message),

317 +

PACKAGE_PREFIX "proto2_unittest.nestedInFileClassMessage");

318 +

EXPECT_EQ(

319 +

resolver.GetFullyQualifiedKotlinFactoryName(nested_in_unnested_message),

320 +

PACKAGE_PREFIX

321 +

"proto2_unittest.UnnestedMessageKt.nestedInUnnestedMessage");

310 322

}

311 323 312 324

TEST_F(NameResolverTest, MultipleFilesEnumEdition2023) {

Original file line number Diff line number Diff line change

@@ -160,6 +160,23 @@ std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {

160 160

return name;

161 161

}

162 162 163 +

PROTOC_EXPORT std::string KotlinFactoryName(const Descriptor* descriptor) {

164 +

ClassNameResolver name_resolver;

165 +

return name_resolver.GetKotlinFactoryName(descriptor);

166 +

}

167 + 168 +

PROTOC_EXPORT std::string FullyQualifiedKotlinFactoryName(

169 +

const Descriptor* descriptor) {

170 +

ClassNameResolver name_resolver;

171 +

return name_resolver.GetFullyQualifiedKotlinFactoryName(descriptor);

172 +

}

173 + 174 +

PROTOC_EXPORT std::string KotlinExtensionsClassName(

175 +

const Descriptor* descriptor) {

176 +

ClassNameResolver name_resolver;

177 +

return name_resolver.GetKotlinExtensionsClassName(descriptor);

178 +

}

179 + 163 180 164 181

} // namespace java

165 182

} // namespace compiler

Original file line number Diff line number Diff line change

@@ -132,6 +132,28 @@ PROTOC_EXPORT std::string UnderscoresToCamelCaseCheckReserved(

132 132

PROTOC_EXPORT std::string UnderscoresToCapitalizedCamelCase(

133 133

const FieldDescriptor* field);

134 134 135 +

// Requires:

136 +

// descriptor != NULL

137 +

// Returns:

138 +

// The unqualified Kotlin factory name.

139 +

PROTOC_EXPORT std::string KotlinFactoryName(const Descriptor* descriptor);

140 + 141 +

// Requires:

142 +

// descriptor != NULL

143 +

// Returns:

144 +

// The fully qualified Kotlin factory name.

145 +

PROTOC_EXPORT std::string FullyQualifiedKotlinFactoryName(

146 +

const Descriptor* descriptor);

147 + 148 +

// Requires:

149 +

// descriptor != NULL

150 +

// Returns:

151 +

// The fully qualified Kotlin extensions class name. "Extensions" in this case

152 +

// refers to "Extensions" the Kotlin concept, not "Extensions" the Protobuf

153 +

// concept

154 +

PROTOC_EXPORT std::string KotlinExtensionsClassName(

155 +

const Descriptor* descriptor);

156 + 135 157 136 158

} // namespace java

137 159

} // namespace compiler

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4