mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 12:05:50 +00:00
Add experimental command line option --enable-comments to index comments and display them on textDocument/hover (#188)
This commit is contained in:
parent
03b50ea3cc
commit
bfccac525c
@ -5,6 +5,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
// TODO Place this global variable into config
|
||||||
|
bool g_enable_comments = false;
|
||||||
|
|
||||||
ClangType::ClangType() : cx_type() {}
|
ClangType::ClangType() : cx_type() {}
|
||||||
|
|
||||||
ClangType::ClangType(const CXType& other) : cx_type(other) {}
|
ClangType::ClangType(const CXType& other) : cx_type(other) {}
|
||||||
@ -183,14 +186,19 @@ std::string ClangCursor::get_type_description() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optional<std::string> ClangCursor::get_comments() const {
|
optional<std::string> ClangCursor::get_comments() const {
|
||||||
|
if (!g_enable_comments)
|
||||||
return nullopt;
|
return nullopt;
|
||||||
// TODO
|
|
||||||
ClangCursor referenced = get_referenced();
|
ClangCursor referenced = get_referenced();
|
||||||
if (referenced)
|
// TODO Format comments
|
||||||
|
std::string ret =
|
||||||
|
referenced
|
||||||
// Get unformatted comments. Returns multiple paragraphs.
|
// Get unformatted comments. Returns multiple paragraphs.
|
||||||
return ::ToString(clang_Cursor_getRawCommentText(referenced.cx_cursor));
|
? ::ToString(clang_Cursor_getRawCommentText(referenced.cx_cursor))
|
||||||
// Get formatted comments. Returns only the first paragraph.
|
// Get formatted comments. Returns only the first paragraph.
|
||||||
return ::ToString(clang_Cursor_getBriefCommentText(referenced.cx_cursor));
|
: ::ToString(clang_Cursor_getBriefCommentText(referenced.cx_cursor));
|
||||||
|
if (ret.empty())
|
||||||
|
return nullopt;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ClangCursor::ToString() const {
|
std::string ClangCursor::ToString() const {
|
||||||
|
@ -439,6 +439,12 @@ int main(int argc, char** argv) {
|
|||||||
RunIndexTests(options["--test-index"]);
|
RunIndexTests(options["--test-index"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HasOption(options, "--enable-comments")) {
|
||||||
|
// TODO Place this global variable into config
|
||||||
|
extern bool g_enable_comments;
|
||||||
|
g_enable_comments = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (HasOption(options, "--language-server")) {
|
if (HasOption(options, "--language-server")) {
|
||||||
print_help = false;
|
print_help = false;
|
||||||
// std::cerr << "Running language server" << std::endl;
|
// std::cerr << "Running language server" << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user