aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-27 00:20:29 +0800
committerchriseth <c@ethdev.com>2015-10-27 02:47:25 +0800
commit8fb49d85f9464bfa0d17ac77d2e19b3ba371c53c (patch)
treecbe785c7e483fb83d9ed5148273f3cc93d602914 /libsolidity/analysis
parente77deccfb3373f5cc7208a0d2579a76f31379952 (diff)
downloaddexon-solidity-8fb49d85f9464bfa0d17ac77d2e19b3ba371c53c.tar.gz
dexon-solidity-8fb49d85f9464bfa0d17ac77d2e19b3ba371c53c.tar.zst
dexon-solidity-8fb49d85f9464bfa0d17ac77d2e19b3ba371c53c.zip
Allow docstrings for statements.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/DocStringAnalyser.cpp33
-rw-r--r--libsolidity/analysis/DocStringAnalyser.h9
2 files changed, 30 insertions, 12 deletions
diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp
index 41bff87e..4f75f03d 100644
--- a/libsolidity/analysis/DocStringAnalyser.cpp
+++ b/libsolidity/analysis/DocStringAnalyser.cpp
@@ -39,12 +39,8 @@ bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)
bool DocStringAnalyser::visit(ContractDefinition const& _node)
{
- parseDocStrings(_node, _node.annotation());
-
- static const set<string> validTags = set<string>{"author", "title", "dev", "notice"};
- for (auto const& docTag: _node.annotation().docTags)
- if (!validTags.count(docTag.first))
- appendError("Doc tag @" + docTag.first + " not valid for contracts.");
+ static const set<string> validTags = set<string>{"author", "title", "dev", "notice", "why3"};
+ parseDocStrings(_node, _node.annotation(), validTags, "contracts");
return true;
}
@@ -69,17 +65,24 @@ bool DocStringAnalyser::visit(EventDefinition const& _node)
return true;
}
+bool DocStringAnalyser::visitNode(ASTNode const& _node)
+{
+ if (auto node = dynamic_cast<Statement const*>(&_node))
+ {
+ static const set<string> validTags = {"why3"};
+ parseDocStrings(*node, node->annotation(), validTags, "statements");
+ }
+ return true;
+}
+
void DocStringAnalyser::handleCallable(
CallableDeclaration const& _callable,
Documented const& _node,
DocumentedAnnotation& _annotation
)
{
- parseDocStrings(_node, _annotation);
static const set<string> validTags = set<string>{"author", "dev", "notice", "return", "param", "why3"};
- for (auto const& docTag: _annotation.docTags)
- if (!validTags.count(docTag.first))
- appendError("Doc tag @" + docTag.first + " not valid for functions.");
+ parseDocStrings(_node, _annotation, validTags, "functions");
set<string> validParams;
for (auto const& p: _callable.parameters())
@@ -97,7 +100,12 @@ void DocStringAnalyser::handleCallable(
);
}
-void DocStringAnalyser::parseDocStrings(Documented const& _node, DocumentedAnnotation& _annotation)
+void DocStringAnalyser::parseDocStrings(
+ Documented const& _node,
+ DocumentedAnnotation& _annotation,
+ set<string> const& _validTags,
+ string const& _nodeName
+)
{
DocStringParser parser;
if (_node.documentation() && !_node.documentation()->empty())
@@ -106,6 +114,9 @@ void DocStringAnalyser::parseDocStrings(Documented const& _node, DocumentedAnnot
m_errorOccured = true;
_annotation.docTags = parser.tags();
}
+ for (auto const& docTag: _annotation.docTags)
+ if (!_validTags.count(docTag.first))
+ appendError("Doc tag @" + docTag.first + " not valid for " + _nodeName + ".");
}
void DocStringAnalyser::appendError(string const& _description)
diff --git a/libsolidity/analysis/DocStringAnalyser.h b/libsolidity/analysis/DocStringAnalyser.h
index 06384c8d..cdf297e3 100644
--- a/libsolidity/analysis/DocStringAnalyser.h
+++ b/libsolidity/analysis/DocStringAnalyser.h
@@ -46,13 +46,20 @@ private:
virtual bool visit(ModifierDefinition const& _modifier) override;
virtual bool visit(EventDefinition const& _event) override;
+ virtual bool visitNode(ASTNode const&) override;
+
void handleCallable(
CallableDeclaration const& _callable,
Documented const& _node,
DocumentedAnnotation& _annotation
);
- void parseDocStrings(Documented const& _node, DocumentedAnnotation& _annotation);
+ void parseDocStrings(
+ Documented const& _node,
+ DocumentedAnnotation& _annotation,
+ std::set<std::string> const& _validTags,
+ std::string const& _nodeName
+ );
void appendError(std::string const& _description);