Skip to content

Commit

Permalink
THRIFT-4355 Fix javascript indentation of default values
Browse files Browse the repository at this point in the history
Client: js

This closes apache#1388
  • Loading branch information
bforbis authored and jeking3 committed Oct 10, 2017
1 parent b628736 commit 8b8a8ef
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/cpp/src/thrift/generate/t_js_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) {
} else if (type->is_enum()) {
out << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
out << "new " << js_type_namespace(type->get_program()) << type->get_name() << "({" << endl;
out << "new " << js_type_namespace(type->get_program()) << type->get_name() << "({";
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
Expand All @@ -576,12 +576,12 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) {
}
if (v_iter != val.begin())
out << ",";
out << render_const_value(g_type_string, v_iter->first);
out << endl << indent() << render_const_value(g_type_string, v_iter->first);
out << " : ";
out << render_const_value(field_type, v_iter->second);
}

out << "})";
indent_down();
out << endl << indent() << "})";
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();

Expand All @@ -600,9 +600,8 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) {
out << " : ";
out << render_const_value(vtype, v_iter->second);
}

indent_down();
out << endl << "}";
out << endl << indent() << "}";
} else if (type->is_list() || type->is_set()) {
t_type* etype;
if (type->is_list()) {
Expand Down

0 comments on commit 8b8a8ef

Please sign in to comment.