From 38e65a909ac86d0e2cea7d4c48dfe1a98f4f020a Mon Sep 17 00:00:00 2001 From: a3d4 Date: Thu, 21 May 2020 00:26:14 +0200 Subject: [PATCH] Remove DocStringAnalyzer and DocStringParser class-specific error reporting functions --- libsolidity/analysis/DocStringAnalyser.cpp | 27 +++++++++++----------- libsolidity/analysis/DocStringAnalyser.h | 2 -- libsolidity/parsing/DocStringParser.cpp | 11 +++------ libsolidity/parsing/DocStringParser.h | 2 -- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index a04c9314e..1d2d8f54a 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -68,13 +68,13 @@ bool DocStringAnalyser::visit(VariableDeclaration const& _variable) parseDocStrings(_variable, _variable.annotation(), validPublicTags, "non-public state variables"); if (_variable.annotation().docTags.count("notice") > 0) m_errorReporter.warning( - 9098_error, _variable.documentation()->location(), + 7816_error, _variable.documentation()->location(), "Documentation tag on non-public state variables will be disallowed in 0.7.0. You will need to use the @dev tag explicitly." ); } if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0) m_errorReporter.warning( - 4822_error, _variable.documentation()->location(), + 8532_error, _variable.documentation()->location(), "Documentation tag @title and @author is only allowed on contract definitions. It will be disallowed in 0.7.0." ); } @@ -110,7 +110,8 @@ void DocStringAnalyser::checkParameters( auto paramRange = _annotation.docTags.equal_range("param"); for (auto i = paramRange.first; i != paramRange.second; ++i) if (!validParams.count(i->second.paramName)) - appendError( + m_errorReporter.docstringParsingError( + 3881_error, _node.documentation()->location(), "Documented parameter \"" + i->second.paramName + @@ -159,7 +160,8 @@ void DocStringAnalyser::parseDocStrings( for (auto const& docTag: _annotation.docTags) { if (!_validTags.count(docTag.first)) - appendError( + m_errorReporter.docstringParsingError( + 6546_error, _node.documentation()->location(), "Documentation tag @" + docTag.first + " not valid for " + _nodeName + "." ); @@ -170,12 +172,14 @@ void DocStringAnalyser::parseDocStrings( if (auto* varDecl = dynamic_cast(&_node)) { if (!varDecl->isPublic()) - appendError( + m_errorReporter.docstringParsingError( + 9440_error, _node.documentation()->location(), "Documentation tag \"@" + docTag.first + "\" is only allowed on public state-variables." ); if (returnTagsVisited > 1) - appendError( + m_errorReporter.docstringParsingError( + 5256_error, _node.documentation()->location(), "Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables." ); @@ -186,7 +190,8 @@ void DocStringAnalyser::parseDocStrings( string firstWord = content.substr(0, content.find_first_of(" \t")); if (returnTagsVisited > function->returnParameters().size()) - appendError( + m_errorReporter.docstringParsingError( + 2604_error, _node.documentation()->location(), "Documentation tag \"@" + docTag.first + " " + docTag.second.content + "\"" + " exceeds the number of return parameters." @@ -195,7 +200,8 @@ void DocStringAnalyser::parseDocStrings( { auto parameter = function->returnParameters().at(returnTagsVisited - 1); if (!parameter->name().empty() && parameter->name() != firstWord) - appendError( + m_errorReporter.docstringParsingError( + 5856_error, _node.documentation()->location(), "Documentation tag \"@" + docTag.first + " " + docTag.second.content + "\"" + " does not contain the name of its return parameter." @@ -205,8 +211,3 @@ void DocStringAnalyser::parseDocStrings( } } } - -void DocStringAnalyser::appendError(SourceLocation const& _location, string const& _description) -{ - m_errorReporter.docstringParsingError(7816_error, _location, _description); -} diff --git a/libsolidity/analysis/DocStringAnalyser.h b/libsolidity/analysis/DocStringAnalyser.h index cddfc2f1d..9bc8ec578 100644 --- a/libsolidity/analysis/DocStringAnalyser.h +++ b/libsolidity/analysis/DocStringAnalyser.h @@ -81,8 +81,6 @@ private: std::string const& _nodeName ); - void appendError(langutil::SourceLocation const& _location, std::string const& _description); - langutil::ErrorReporter& m_errorReporter; }; diff --git a/libsolidity/parsing/DocStringParser.cpp b/libsolidity/parsing/DocStringParser.cpp index 3ce67a430..755eb0b50 100644 --- a/libsolidity/parsing/DocStringParser.cpp +++ b/libsolidity/parsing/DocStringParser.cpp @@ -96,7 +96,7 @@ void DocStringParser::parse(string const& _docString, ErrorReporter& _errorRepor auto tagNameEndPos = firstWhitespaceOrNewline(tagPos, end); if (tagNameEndPos == end) { - appendError("End of tag " + string(tagPos, tagNameEndPos) + " not found"); + m_errorReporter->docstringParsingError(9222_error, "End of tag " + string(tagPos, tagNameEndPos) + " not found"); break; } @@ -138,7 +138,7 @@ DocStringParser::iter DocStringParser::parseDocTagParam(iter _pos, iter _end) auto nameStartPos = skipWhitespace(_pos, _end); if (nameStartPos == _end) { - appendError("No param name given"); + m_errorReporter->docstringParsingError(3335_error, "No param name given"); return _end; } auto nameEndPos = firstNonIdentifier(nameStartPos, _end); @@ -149,7 +149,7 @@ DocStringParser::iter DocStringParser::parseDocTagParam(iter _pos, iter _end) if (descStartPos == nlPos) { - appendError("No description given for param " + paramName); + m_errorReporter->docstringParsingError(9942_error, "No description given for param " + paramName); return _end; } @@ -189,8 +189,3 @@ void DocStringParser::newTag(string const& _tagName) { m_lastTag = &m_docTags.insert(make_pair(_tagName, DocTag()))->second; } - -void DocStringParser::appendError(string const& _description) -{ - m_errorReporter->docstringParsingError(9440_error, _description); -} diff --git a/libsolidity/parsing/DocStringParser.h b/libsolidity/parsing/DocStringParser.h index b4c9186a7..eaf18503b 100644 --- a/libsolidity/parsing/DocStringParser.h +++ b/libsolidity/parsing/DocStringParser.h @@ -58,8 +58,6 @@ private: /// Creates and inserts a new tag and adjusts m_lastTag. void newTag(std::string const& _tagName); - void appendError(std::string const& _description); - /// Mapping tag name -> content. std::multimap m_docTags; DocTag* m_lastTag = nullptr;