Suggest alternatives when identifier not found.

This commit is contained in:
Balajiganapathi S
2018-02-13 14:54:36 +00:00
committed by Alex Beregszaszi
parent 8f8ad3840e
commit 2859834e58
7 changed files with 183 additions and 2 deletions
@@ -425,6 +425,23 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list<list<_T const*>>& _toMer
return result;
}
string NameAndTypeResolver::similarNameSuggestions(ASTString const& _name) const
{
vector<ASTString> suggestions = m_currentScope->similarNames(_name);
if (suggestions.empty())
return "";
if (suggestions.size() == 1)
return suggestions.front();
string choices = suggestions.front();
for (size_t i = 1; i + 1 < suggestions.size(); ++i)
choices += ", " + suggestions[i];
choices += " or " + suggestions.back();
return choices;
}
DeclarationRegistrationHelper::DeclarationRegistrationHelper(
map<ASTNode const*, shared_ptr<DeclarationContainer>>& _scopes,
ASTNode& _astRoot,