Skip to content

Commit d0a4481

Browse files
praihanfacebook-github-bot
authored andcommitted
Move t_type::get_scoped_name to t_named
Summary: Should've been in base class instead. Reviewed By: sadroeck Differential Revision: D76773055 fbshipit-source-id: d308dd9763f4c159a64dbcc3e68b43f674723f03
1 parent 59f5cb4 commit d0a4481

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

third-party/thrift/src/thrift/compiler/ast/t_named.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <thrift/compiler/ast/t_type.h>
2222
#include <thrift/compiler/ast/uri.h>
2323

24+
#include <fmt/core.h>
25+
2426
namespace apache::thrift::compiler {
2527

2628
t_named::t_named(const t_program* program, std::string name)
@@ -41,6 +43,10 @@ t_named::t_named(const t_named& named)
4143
// NOTE: Must be defined here for t_const's destructor defintion.
4244
t_named::~t_named() = default;
4345

46+
std::string t_named::get_scoped_name() const {
47+
return program_ ? fmt::format("{}.{}", program_->name(), name_) : name_;
48+
}
49+
4450
void t_named::add_structured_annotation(std::unique_ptr<t_const> annot) {
4551
assert(annot->type() != nullptr);
4652
structured_annotations_.emplace_back(std::move(annot));

third-party/thrift/src/thrift/compiler/ast/t_named.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class t_named : public t_node {
4242
const std::string& name() const noexcept { return name_; }
4343
void set_name(const std::string& name) { name_ = name; }
4444

45+
// Returns a string in the format "program_name.type_name"
46+
std::string get_scoped_name() const;
47+
4548
node_list_view<const t_const> structured_annotations() const {
4649
return structured_annotations_;
4750
}

third-party/thrift/src/thrift/compiler/ast/t_type.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,6 @@ uint64_t t_type::get_type_id() const {
6565
return (hash & ~t_type::kTypeMask) | static_cast<int>(get_type_value());
6666
}
6767

68-
std::string t_type::get_scoped_name() const {
69-
std::ostringstream os;
70-
if (program_) {
71-
os << program_->name() << ".";
72-
}
73-
os << name_;
74-
return os.str();
75-
}
76-
7768
const t_type* t_type::get_true_type() const {
7869
return t_typedef::find_type_if(
7970
this, [](const t_type* type) { return !type->is_typedef(); });

third-party/thrift/src/thrift/compiler/ast/t_type.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ extern decltype(auto) visit_type(const t_type& ty, Visitors&&... visitors);
4747
*/
4848
class t_type : public t_named {
4949
public:
50-
// Returns a string in the format "program_name.type_name"
51-
std::string get_scoped_name() const;
52-
5350
// Returns the full name for the given type. For example:
5451
// `list<string, string>`
5552
virtual std::string get_full_name() const { return get_scoped_name(); }

0 commit comments

Comments
 (0)