summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd')
-rw-r--r--clang-tools-extra/clangd/CodeCompletionStrings.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
index 8cdaa3380b8..c3066939a5a 100644
--- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -151,6 +151,16 @@ bool canRequestComment(const ASTContext &Ctx, const NamedDecl &D,
const ObjCPropertyDecl *PDecl = M ? M->findPropertyDecl() : nullptr;
return !PDecl || canRequestForDecl(*PDecl);
}
+
+bool LooksLikeDocComment(llvm::StringRef CommentText) {
+ // We don't report comments that only contain "special" chars.
+ // This avoids reporting various delimiters, like:
+ // =================
+ // -----------------
+ // *****************
+ return CommentText.find_first_not_of("/*-= \t\r\n") != llvm::StringRef::npos;
+}
+
} // namespace
std::string getDocComment(const ASTContext &Ctx,
@@ -167,7 +177,10 @@ std::string getDocComment(const ASTContext &Ctx,
const RawComment *RC = getCompletionComment(Ctx, Decl);
if (!RC)
return "";
- return RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+ std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+ if (!LooksLikeDocComment(Doc))
+ return "";
+ return Doc;
}
std::string
@@ -180,7 +193,10 @@ getParameterDocComment(const ASTContext &Ctx,
const RawComment *RC = getParameterComment(Ctx, Result, ArgIndex);
if (!RC)
return "";
- return RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+ std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+ if (!LooksLikeDocComment(Doc))
+ return "";
+ return Doc;
}
void getLabelAndInsertText(const CodeCompletionString &CCS, std::string *Label,
OpenPOWER on IntegriCloud