aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp9
-rw-r--r--libsolidity/analysis/DeclarationContainer.h1
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.cpp15
3 files changed, 6 insertions, 19 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index f9a52dc6..7508ad9e 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -119,20 +119,19 @@ vector<Declaration const*> DeclarationContainer::resolveName(ASTString const& _n
vector<ASTString> DeclarationContainer::similarNames(ASTString const& _name) const
{
+ static size_t const MAXIMUM_EDIT_DISTANCE = 2;
+
vector<ASTString> similar;
for (auto const& declaration: m_declarations)
{
string const& declarationName = declaration.first;
- if (stringWithinDistance(_name, declarationName, MAXIMUM_DISTANCE))
+ if (stringWithinDistance(_name, declarationName, MAXIMUM_EDIT_DISTANCE))
similar.push_back(declarationName);
}
if (m_enclosingContainer)
- {
- vector<ASTString> enclosingSimilar = m_enclosingContainer->similarNames(_name);
- similar.insert(similar.end(), enclosingSimilar.begin(), enclosingSimilar.end());
- }
+ similar += m_enclosingContainer->similarNames(_name);
return similar;
}
diff --git a/libsolidity/analysis/DeclarationContainer.h b/libsolidity/analysis/DeclarationContainer.h
index 6c1459c7..94bbe129 100644
--- a/libsolidity/analysis/DeclarationContainer.h
+++ b/libsolidity/analysis/DeclarationContainer.h
@@ -68,7 +68,6 @@ private:
std::map<ASTString, std::vector<Declaration const*>> m_declarations;
std::map<ASTString, std::vector<Declaration const*>> m_invisibleDeclarations;
- static size_t const MAXIMUM_DISTANCE = 2;
};
}
diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp
index 21f2af5f..5e4d414b 100644
--- a/libsolidity/analysis/NameAndTypeResolver.cpp
+++ b/libsolidity/analysis/NameAndTypeResolver.cpp
@@ -25,6 +25,7 @@
#include <libsolidity/ast/AST.h>
#include <libsolidity/analysis/TypeChecker.h>
#include <libsolidity/interface/ErrorReporter.h>
+#include <libdevcore/StringUtils.h>
#include <boost/algorithm/string.hpp>
@@ -427,19 +428,7 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list<list<_T const*>>& _toMer
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;
+ return quotedAlternativesList(m_currentScope->similarNames(_name));
}
DeclarationRegistrationHelper::DeclarationRegistrationHelper(