mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
added helper function that joins vectors of strings, refactored suggestions formattingi function to use it
This commit is contained in:
1 parent
009a55c82d
commit
3705bcc9bc
3 files changed
+61
-10
No files matched your search
@@ -85,17 +85,11 @@ size_t dev::stringDistance(string const& _str1, string const& _str2)
|
||||
|
||||
string dev::quotedAlternativesList(vector<string> const& suggestions)
|
||||
{
|
||||
if (suggestions.empty())
|
||||
return "";
|
||||
if (suggestions.size() == 1)
|
||||
return "\"" + suggestions.front() + "\"";
|
||||
vector<string> quotedSuggestions;
|
||||
|
||||
string choices = "\"" + suggestions.front() + "\"";
|
||||
for (size_t i = 1; i + 1 < suggestions.size(); ++i)
|
||||
choices += ", \"" + suggestions[i] + "\"";
|
||||
for (auto& suggestion: suggestions)
|
||||
quotedSuggestions.push_back("\"" + suggestion + "\"");
|
||||
|
||||
choices += " or \"" + suggestions.back() + "\"";
|
||||
|
||||
return choices;
|
||||
return joinHumanReadable(quotedSuggestions, ", ", " or ");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user