I did some extra test of how to show the comments.
Here is the log file from CBclangd_client-xxxxx.log:
{"id":"textDocument/hover","jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":4,"line":3},"textDocument":{"uri":"file:///F:/code/test_clangd_client_tipwin/main.cpp"}}}
15:06:48.772 >>> readJson() len:220:
{"id":"textDocument/hover","jsonrpc":"2.0","result":{"contents":{"kind":"plaintext","value":"variable m_AAA\n\nType: int\nABCDEFG\n\nint m_AAA"},"range":{"end":{"character":9,"line":3},"start":{"character":4,"line":3}}}}
15:07:41.294 <<< Hover:
file:///F:/code/test_clangd_client_tipwin/main.cpp,line[1], char[4]
15:07:41.294 <<< Content-Length: 196
{"id":"textDocument/hover","jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":4,"line":1},"textDocument":{"uri":"file:///F:/code/test_clangd_client_tipwin/main.cpp"}}}
15:07:41.524 >>> readJson() len:240:
{"id":"textDocument/hover","jsonrpc":"2.0","result":{"contents":{"kind":"plaintext","value":"variable m_TcpFile\n\nType: int\nTCP鎺ユ敹鐨勬暟鎹甛n\nint m_TcpFile"},"range":{"end":{"character":13,"line":1},"start":{"character":4,"line":1}}}}
and here is the test code:
int m_TcpFile; ///< TCP接收的数据
int m_AAA; ///< ABCDEFG
int main()
{
return 0;
}
You can see, when I hover on the variable "m_TcpFile", the received json contains some wrong contents, I'm not sure why it is not shown in Chinese.
While, for the variable "m_AAA", it shows the "ABCDEFG" correctly.
EDITIt looks like we just drop the text returned from clangd, after the second \n
Here is the screen shot(in attachment)
The source code looks like in parser.cpp line 2553
// Example Hover contents: L"instance-method HelloWxWorldFrame::OnAbout\n\nType: void\nParameters:\n- wxCommandEvent & event\n\n// In HelloWxWorldFrame\nprivate: void HelloWxWorldFrame::OnAbout(wxCommandEvent &event)"
// get string array of hover info separated at /n chars.
wxString hoverString = contentsValue;
hoverString.Replace("\n\n", "\n"); //remove double newline chars
wxArrayString vHoverInfo = GetArrayFromString(hoverString, "\n");
// **Debugging**
// LogManager* pLogMgr = Manager::Get()->GetLogManager();
// for (size_t ii=0; ii<vHoverInfo.size(); ++ii)
// pLogMgr->DebugLog(wxString::Format("vHoverInfo[%d]:%s", int(ii), vHoverInfo[ii]));
// Find items from hover data and cut the chaff
wxString hoverText;
for (size_t ii=0, foundIn=false; ii<vHoverInfo.size(); ++ii)
{
if (ii < 2) hoverText += vHoverInfo[ii] + "\n"; //type and return value
if (vHoverInfo[ii].StartsWith("// In ")) //parent
{
hoverText += vHoverInfo[ii] += "\n";
foundIn = true; continue;
}
if (foundIn) hoverText += vHoverInfo[ii] + "\n";;
}//endfor vHoverInfo
v_HoverTokens.push_back(ClgdCCToken(0, hoverText, hoverText));