Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Code completion using LSP and clangd
ollydbg:
Hi, Pecan, my guess is correct. ;)
--- Code: ----------------------- clangd_client/src/LSPclient/client.cpp --------------------
index e92c789..5c56b26 100644
@@ -626,7 +626,7 @@ void ProcessLanguageClient::writeClientLog(const std::string& logmsg)
std::string logcr = "";
if (not StdString_EndsWith(logmsg, "\n"))
logcr = "\n";
- lspClientLogFile.Write("\n" + GetTime_in_HH_MM_SS_MMM() + " " + logmsg + logcr);
+ lspClientLogFile.Write("\n" + GetTime_in_HH_MM_SS_MMM() + " " + GetwxUTF8Str(logmsg) + logcr);
lspClientLogFile.Flush();
}
// ----------------------------------------------------------------------------
@@ -634,7 +634,7 @@ void ProcessLanguageClient::writeServerLog(const std::string& logmsg)
// ----------------------------------------------------------------------------
{
if (not lspServerLogFile.IsOpened()) return;
- lspServerLogFile.Write(logmsg);
+ lspServerLogFile.Write(GetwxUTF8Str(logmsg));
lspServerLogFile.Flush();
//(ph 2022/02/16)
--- End code ---
With this patch, the log file is correctly showing the non-ascii characters.
Pecan:
--- Quote from: ollydbg on October 11, 2022, 04:17:36 am ---Hi, Pecan, my guess is correct. ;)
--- Code: ----------------------- clangd_client/src/LSPclient/client.cpp --------------------
index e92c789..5c56b26 100644
@@ -626,7 +626,7 @@ void ProcessLanguageClient::writeClientLog(const std::string& logmsg)
std::string logcr = "";
if (not StdString_EndsWith(logmsg, "\n"))
logcr = "\n";
- lspClientLogFile.Write("\n" + GetTime_in_HH_MM_SS_MMM() + " " + logmsg + logcr);
+ lspClientLogFile.Write("\n" + GetTime_in_HH_MM_SS_MMM() + " " + GetwxUTF8Str(logmsg) + logcr);
lspClientLogFile.Flush();
}
// ----------------------------------------------------------------------------
@@ -634,7 +634,7 @@ void ProcessLanguageClient::writeServerLog(const std::string& logmsg)
// ----------------------------------------------------------------------------
{
if (not lspServerLogFile.IsOpened()) return;
- lspServerLogFile.Write(logmsg);
+ lspServerLogFile.Write(GetwxUTF8Str(logmsg));
lspServerLogFile.Flush();
//(ph 2022/02/16)
--- End code ---
With this patch, the log file is correctly showing the non-ascii characters.
--- End quote ---
There is no need for the logs to show only ascii chars.
I hex dumped that section of the log. Those non ascii chars are each legal utf8 3byte hex representations of one char.
At the point we need to use/display them, we do the GetwxUTF8String() to convert them to wxStrings.
That works just fine.
Please do not convert the logs. I need them to look just the same as clangd sent to us. Especially when trying to document possible bugs.
Thanks for the work you do. I'm grateful.
ollydbg:
--- Quote from: Pecan on October 11, 2022, 06:36:51 am ---There is no need for the logs to show only ascii chars.
I hex dumped that section of the log. Those non ascii chars are each legal utf8 3byte hex representations of one char.
At the point we need to use/display them, we do the GetwxUTF8String() to convert them to wxStrings.
That works just fine.
Please do not convert the logs. I need them to look just the same as clangd sent to us. Especially when trying to document possible bugs.
Thanks for the work you do. I'm grateful.
--- End quote ---
Hi, Pecan, I think the using of member function Write from wxWidgets: wxFFile Class Reference:
--- Code: ---bool Write (const wxString &str, const wxMBConv &conv=wxConvAuto())
--- End code ---
which is wrong here.
If you look at the source code, you will see:
--- Code: ---// ----------------------------------------------------------------------------
void ProcessLanguageClient::writeClientLog(const std::string& logmsg)
// ----------------------------------------------------------------------------
{
if (not lspClientLogFile.IsOpened()) return;
std::string logcr = "";
if (not StdString_EndsWith(logmsg, "\n"))
logcr = "\n";
lspClientLogFile.Write("\n" + GetTime_in_HH_MM_SS_MMM() + " " + logmsg + logcr);
lspClientLogFile.Flush();
}
--- End code ---
In this code, you first construct a std::string arg0:
--- Code: ---arg0 = "\n" + GetTime_in_HH_MM_SS_MMM() + " " + logmsg + logcr
--- End code ---
Then, the lspClientLogFile.Write() function need a wxString, so the arg0 is convert to wxString(arg0), and the bad thing is it will use the "Locale encodings", in my PC, it could be GB2312. The wrong thing is: logmsg is returned from clangd, which is encoded in UTF8, and the implicit conversion from arg0 to wxString is using Locale encodings(GB2312).
I think if you just need a byte stream, then we need another member function:
--- Code: ---size_t Write (const void *buffer, size_t count)
--- End code ---
This just Writes the specified number of bytes from a buffer.
I hope you can understand my explanation.
Pecan:
--- Quote from: MaxGaspa on October 10, 2022, 11:17:39 am ---
...Partial quote....
Yes you fixed the issue related to my message #205 but the bugs in #203 is still present (latest nightly and plugin, Win7 and Win10).
I'm observing the plugin in "sleep state" in several way but the one in #203 seems the simpler test case. The most surprising thing is that I need to close CB to force a reparse...
If you need a test project to replicate the issue let me know.
Thank you anyway for your plugin...is usable and good (IMHO)
MAx
--- End quote ---
@ MaxGaspa
Try the "-2" version below to see if it fixes the "sleep state" error.
It seems you've run across a CB bug where the "compiler finished" event was not being issued and clangd_client got stuck waiting for the compiler to end.
I've made a temporary fix (until the next Nightly) that circumvents the missing event.
Be careful though, the circumvention allows clangd to parse files while the "Run" command is active. You might want to right-click on the project name and "Pause parsing(toggle)" before running your program from the menu run command.
After the "Run" finishes, you can "Pause parsing(toggle)" again to continue parsing where it left off.
Try:
https://sourceforge.net/projects/cb-clangd-client/files/Plugin_Install_Package/Windows_x64/ClangdClientForCBNightly_221008_rev12969_win64-2.zip/download
Pecan:
@ olldbg RE: Reply #218 on: October 11, 2022, 02:44:26
Thanks, it works for me.
Will be in rev 85.
--- Code: ---// ----------------------------------------------------------------------------
void ProcessLanguageClient::writeClientLog(const std::string& logmsg)
// ----------------------------------------------------------------------------
{
if (not lspClientLogFile.IsOpened()) return;
std::string logcr = "";
if (not StdString_EndsWith(logmsg, "\n"))
logcr = "\n";
std::string out = "\n" + GetTime_in_HH_MM_SS_MMM() + " " + logmsg + logcr;
lspClientLogFile.Write(out.c_str(), out.size());
lspClientLogFile.Flush();
}
// ----------------------------------------------------------------------------
void ProcessLanguageClient::writeServerLog(const std::string& logmsg)
// ----------------------------------------------------------------------------
{
if (not lspServerLogFile.IsOpened()) return;
lspServerLogFile.Write(logmsg.c_str(), logmsg.size());
lspServerLogFile.Flush();
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version