aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/CommentBriefParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/CommentBriefParser.cpp')
-rw-r--r--lib/AST/CommentBriefParser.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/AST/CommentBriefParser.cpp b/lib/AST/CommentBriefParser.cpp
index 22209c097f..0aebc1e4e3 100644
--- a/lib/AST/CommentBriefParser.cpp
+++ b/lib/AST/CommentBriefParser.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/CommentBriefParser.h"
+#include "clang/AST/CommentCommandTraits.h"
#include "llvm/ADT/StringSwitch.h"
namespace clang {
@@ -39,19 +40,13 @@ void cleanupBrief(std::string &S) {
S.resize(O - S.begin());
}
+} // unnamed namespace
-bool isBlockCommand(StringRef Name) {
- return llvm::StringSwitch<bool>(Name)
- .Cases("brief", "short", true)
- .Cases("result", "return", "returns", true)
- .Cases("author", "authors", true)
- .Case("pre", true)
- .Case("post", true)
- .Cases("param", "arg", true)
- .Case("tparam", true)
- .Default(false);
+BriefParser::BriefParser(Lexer &L, const CommandTraits &Traits) :
+ L(L), Traits(Traits) {
+ // Get lookahead token.
+ ConsumeToken();
}
-} // unnamed namespace
std::string BriefParser::Parse() {
std::string FirstParagraphOrBrief;
@@ -72,18 +67,18 @@ std::string BriefParser::Parse() {
if (Tok.is(tok::command)) {
StringRef Name = Tok.getCommandName();
- if (Name == "brief" || Name == "short") {
+ if (Traits.isBriefCommand(Name)) {
FirstParagraphOrBrief.clear();
InBrief = true;
ConsumeToken();
continue;
}
- if (Name == "result" || Name == "return" || Name == "returns") {
+ if (Traits.isReturnsCommand(Name)) {
InReturns = true;
ReturnsParagraph += "Returns ";
}
// Block commands implicitly start a new paragraph.
- if (isBlockCommand(Name)) {
+ if (Traits.isBlockCommand(Name)) {
// We found an implicit paragraph end.
InFirstParagraph = false;
if (InBrief)
@@ -121,11 +116,6 @@ std::string BriefParser::Parse() {
return ReturnsParagraph;
}
-BriefParser::BriefParser(Lexer &L) : L(L) {
- // Get lookahead token.
- ConsumeToken();
-}
-
} // end namespace comments
} // end namespace clang