aboutsummaryrefslogtreecommitdiffstats
path: root/InterfaceHandler.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-18 21:43:35 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-18 22:03:45 +0800
commita6b0fba22748ffa8a73d505f31bec8630f434f39 (patch)
tree8969a0dd76fd6a49377b6750daa8a8bd4fd91bb4 /InterfaceHandler.cpp
parentf73278c8b2373e4cd27408618ef4a65001ff1437 (diff)
downloaddexon-solidity-a6b0fba22748ffa8a73d505f31bec8630f434f39.tar.gz
dexon-solidity-a6b0fba22748ffa8a73d505f31bec8630f434f39.tar.zst
dexon-solidity-a6b0fba22748ffa8a73d505f31bec8630f434f39.zip
Changes in InterfaceHandler to deal with multiline natspec
- Also now Solidity scanner considers Carriage Return as whitespace - Tests for Natspec generation with the new multiline comments
Diffstat (limited to 'InterfaceHandler.cpp')
-rw-r--r--InterfaceHandler.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp
index c734fa38..9ae284b4 100644
--- a/InterfaceHandler.cpp
+++ b/InterfaceHandler.cpp
@@ -166,9 +166,12 @@ static inline std::string::const_iterator skipLineOrEOS(std::string::const_itera
std::string::const_iterator InterfaceHandler::parseDocTagLine(std::string::const_iterator _pos,
std::string::const_iterator _end,
std::string& _tagString,
- DocTagType _tagType)
+ DocTagType _tagType,
+ bool _appending)
{
auto nlPos = std::find(_pos, _end, '\n');
+ if (_appending && *_pos != ' ')
+ _tagString += " ";
std::copy(_pos, nlPos, back_inserter(_tagString));
m_lastTag = _tagType;
return skipLineOrEOS(nlPos, _end);
@@ -201,7 +204,8 @@ std::string::const_iterator InterfaceHandler::appendDocTagParam(std::string::con
solAssert(!m_params.empty(), "Internal: Tried to append to empty parameter");
auto pair = m_params.back();
- pair.second += " ";
+ if (*_pos != ' ')
+ pair.second += " ";
auto nlPos = std::find(_pos, _end, '\n');
std::copy(_pos, nlPos, back_inserter(pair.second));
@@ -221,17 +225,17 @@ std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_ite
if (m_lastTag == DocTagType::NONE || _tag != "")
{
if (_tag == "dev")
- return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV);
+ return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV, false);
else if (_tag == "notice")
- return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE);
+ return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE, false);
else if (_tag == "return")
- return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN);
+ return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN, false);
else if (_tag == "author")
{
if (_owner == CommentOwner::CONTRACT)
- return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR);
+ return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR, false);
else if (_owner == CommentOwner::FUNCTION)
- return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR);
+ return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR, false);
else
// LTODO: for now this else makes no sense but later comments will go to more language constructs
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@author tag is legal only for contracts"));
@@ -239,7 +243,7 @@ std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_ite
else if (_tag == "title")
{
if (_owner == CommentOwner::CONTRACT)
- return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE);
+ return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE, false);
else
// LTODO: Unknown tag, throw some form of warning and not just an exception
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@title tag is legal only for contracts"));
@@ -261,34 +265,22 @@ std::string::const_iterator InterfaceHandler::appendDocTag(std::string::const_it
switch (m_lastTag)
{
case DocTagType::DEV:
- m_dev += " ";
- return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV);
+ return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV, true);
case DocTagType::NOTICE:
- m_notice += " ";
- return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE);
+ return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE, true);
case DocTagType::RETURN:
- m_return += " ";
- return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN);
+ return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN, true);
case DocTagType::AUTHOR:
if (_owner == CommentOwner::CONTRACT)
- {
- m_contractAuthor += " ";
- return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR);
- }
+ return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR, true);
else if (_owner == CommentOwner::FUNCTION)
- {
- m_author += " ";
- return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR);
- }
+ return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR, true);
else
// LTODO: Unknown tag, throw some form of warning and not just an exception
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@author tag in illegal comment"));
case DocTagType::TITLE:
if (_owner == CommentOwner::CONTRACT)
- {
- m_title += " ";
- return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE);
- }
+ return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE, true);
else
// LTODO: Unknown tag, throw some form of warning and not just an exception
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@title tag in illegal comment"));
@@ -329,7 +321,7 @@ void InterfaceHandler::parseDocString(std::string const& _string, CommentOwner _
currPos = parseDocTag(tagNameEndPos + 1, end, std::string(tagPos + 1, tagNameEndPos), _owner);
}
else if (m_lastTag != DocTagType::NONE) // continuation of the previous tag
- currPos = appendDocTag(currPos + 1, end, _owner);
+ currPos = appendDocTag(currPos, end, _owner);
else if (currPos != end) // skip the line if a newline was found
currPos = nlPos + 1;
}