| 958 | // ---------------------------------------------------------------------------------------- |
| 959 | |
| 960 | string pretty_print_declaration ( |
| 961 | const std::vector<std::pair<int,string> >& decl |
| 962 | ) |
| 963 | { |
| 964 | string temp; |
| 965 | long angle_count = 0; |
| 966 | long paren_count = 0; |
| 967 | |
| 968 | if (decl.size() == 0) |
| 969 | return temp; |
| 970 | |
| 971 | temp = decl[0].second; |
| 972 | |
| 973 | |
| 974 | bool just_closed_template = false; |
| 975 | bool in_template = false; |
| 976 | bool last_was_scope_res = false; |
| 977 | bool seen_operator = false; |
| 978 | |
| 979 | if (temp == "operator") |
| 980 | seen_operator = true; |
| 981 | |
| 982 | for (unsigned long i = 1; i < decl.size(); ++i) |
| 983 | { |
| 984 | bool last_was_less_than = false; |
| 985 | if (decl[i-1].first == tok_type::OTHER && decl[i-1].second == "<") |
| 986 | last_was_less_than = true; |
| 987 | |
| 988 | |
| 989 | if (decl[i].first == tok_type::OTHER && decl[i].second == "<" && |
| 990 | (decl[i-1].second != "operator" && ((i>1 && decl[i-2].second != "operator") || decl[i-1].second != "<") )) |
| 991 | ++angle_count; |
| 992 | |
| 993 | if (decl[i-1].first == tok_type::KEYWORD && decl[i-1].second == "template" && |
| 994 | decl[i].first == tok_type::OTHER && decl[i].second == "<") |
| 995 | { |
| 996 | in_template = true; |
| 997 | temp += " <\n "; |
| 998 | } |
| 999 | else if (decl[i].first == tok_type::OTHER && decl[i].second == ">") |
| 1000 | { |
| 1001 | // don't count angle brackets when they are part of an operator |
| 1002 | if (decl[i-1].second != "operator" && ((i>1 && decl[i-2].second != "operator") || decl[i-1].second != ">")) |
| 1003 | --angle_count; |
| 1004 | |
| 1005 | if (angle_count == 0 && in_template) |
| 1006 | { |
| 1007 | temp += "\n >\n"; |
| 1008 | just_closed_template = true; |
| 1009 | in_template = false; |
| 1010 | } |
| 1011 | else |
| 1012 | { |
| 1013 | temp += ">"; |
| 1014 | } |
| 1015 | } |
| 1016 | else if (decl[i].first == tok_type::OTHER && decl[i].second == "<") |
| 1017 | { |
no test coverage detected