aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/csharp/csharp_helpers.cc
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-07-29 20:15:03 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-07-30 14:54:09 -0700
commit43a2dee7085f91d7a7a55f21f0d6c474b7a83c7c (patch)
tree7be44c737bf985b2c9f2a56acb48a1a8069d16e4 /src/google/protobuf/compiler/csharp/csharp_helpers.cc
parent12febd0a7611858eb026fab7eaf8a4d14c4eba80 (diff)
refactor umbrella class helpers
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_helpers.cc')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.cc32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
index 1c7a24a9..07305a93 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
@@ -117,21 +117,18 @@ std::string GetFileNamespace(const FileDescriptor* descriptor) {
return UnderscoresToCamelCase(descriptor->package(), true, true);
}
-std::string GetUmbrellaClassNameInternal(const std::string& proto_file) {
+std::string GetUmbrellaClassUnqualifiedName(const FileDescriptor* descriptor) {
+ // umbrella_classname can no longer be set using message option.
+ std::string proto_file = descriptor->name();
int lastslash = proto_file.find_last_of("/");
std::string base = proto_file.substr(lastslash + 1);
return UnderscoresToPascalCase(StripDotProto(base));
}
-std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor) {
- // umbrella_classname can no longer be set using message option.
- return GetUmbrellaClassNameInternal(descriptor->name());
-}
-
-std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) {
+std::string GetUmbrellaClassNestedNamespace(const FileDescriptor* descriptor) {
// TODO(jtattermusch): reintroduce csharp_umbrella_namespace option
bool collision = false;
- std::string umbrella_classname = GetFileUmbrellaClassname(descriptor);
+ std::string umbrella_classname = GetUmbrellaClassUnqualifiedName(descriptor);
for(int i = 0; i < descriptor->message_type_count(); i++) {
if (descriptor->message_type(i)->name() == umbrella_classname) {
collision = true;
@@ -215,26 +212,17 @@ std::string ToCSharpName(const std::string& name, const FileDescriptor* file) {
return "global::" + result;
}
-
-
-std::string GetFullUmbrellaClassName(const FileDescriptor* descriptor) {
+std::string GetUmbrellaClassName(const FileDescriptor* descriptor) {
std::string result = GetFileNamespace(descriptor);
if (!result.empty()) {
result += '.';
}
- result += GetQualifiedUmbrellaClassName(descriptor);
- return "global::" + result;
-}
-
-std::string GetQualifiedUmbrellaClassName(const FileDescriptor* descriptor) {
- std::string umbrellaNamespace = GetFileUmbrellaNamespace(descriptor);
- std::string umbrellaClassname = GetFileUmbrellaClassname(descriptor);
-
- std::string fullName = umbrellaClassname;
+ std::string umbrellaNamespace = GetUmbrellaClassNestedNamespace(descriptor);
if (!umbrellaNamespace.empty()) {
- fullName = umbrellaNamespace + "." + umbrellaClassname;
+ result += umbrellaNamespace + ".";
}
- return fullName;
+ result += GetUmbrellaClassUnqualifiedName(descriptor);
+ return "global::" + result;
}
std::string GetClassName(const Descriptor* descriptor) {