Author Topic: Code completion using LSP and clangd  (Read 124519 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2659
Re: Code completion using LSP and clangd
« Reply #345 on: November 16, 2023, 08:05:15 pm »
The  TU information is available to the user, for each activated (referenced) TU, about as fast as your cpu can run the Clangd parser. My Win10 system (an Intel i7/8 core) parses most TUs in 2 seconds or less. Giving Clangd more than 1 core makes for a speedy throughput since that allows Clangd to parse multiple TUs in parallel. I seldom have to wait for info.
clangd use local network? If that's the case, then clang can't run faster than the native way.
Google gave a result in the search, to what extent do you agree with what is described there about the negative facts of clang use.
https://www.eclipsecon.org/sites/default/files/slides/EclipseCon2018-cpp-lsp_0.pdf

Depends on what you mean by a local network.
Clangd_client and Clangd LSP server are all in the same machine communicating with pipes.

I'm not interested in arguments about clang use.
Clangd uses the parser, not the compiler.
CodeBlocks needs a modern parser for C++11 and beyond.
You don't have to use it.
« Last Edit: November 16, 2023, 08:16:27 pm by Pecan »

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 100
Re: Code completion using LSP and clangd
« Reply #346 on: November 16, 2023, 08:27:07 pm »
Now it will be necessary to monitor what and how clang transmits over the network  :)
Wireshark now officially support msys2 to compile in Windows https://www.wireshark.org/news/20231115b.html
https://omlk.itch.io
from: Ukraine, Ivano-Frankivs`k  https://w.wiki/7vBe

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5853
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion using LSP and clangd
« Reply #347 on: November 18, 2023, 08:56:50 am »
Hi, Pecan, thanks. I appreciate your work on the clangd_client plugin.
I'm using the rev 13397 for about 6 hours, and I haven't see a crash here till now. :)
I came across the post, and I wonder if you were able to implement what you wrote about?
https://forums.codeblocks.org/index.php?topic=17543.0

And I also wonder how much faster the clang_client works compared to the standard codecompletion (because my codecompletion in some cases does not see the classes, I changed the order of the included header files and disabled others, but there are still problems)?

ollydbg will have to answer your question about COW strings.
It applies to legacy CodeCompletion but not so much to Clangd_Cllient.


@omlk

The COW strings issue. If I member correctly, recent GCC's std::string and wxString do not use the COW(copy on write). So, I think this issue is gone. Because the COW has many issue on multiple thread environment.

About the old legecy CodeCompletion plugin, the parser in this plugin has all hand written. But the modern C++'s grammar is very complex to parse, the parser failed to parse the source files if those files have many advanced C++ code.

Clangd is a compiler level parser, so it parse the source file correctly.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 100
Re: Code completion using LSP and clangd
« Reply #348 on: November 18, 2023, 01:38:12 pm »
@ollydbg
Thanks for the answer. Then, if you know where to find information that will help improve code completion to a modern level, please let me know. Previously, someone wrote a code completion, but now - no one is capable of it?
The problem here is not to write the code, but to understand how it works, you can say the algorithm of actions.
« Last Edit: November 18, 2023, 01:44:06 pm by omlk »
https://omlk.itch.io
from: Ukraine, Ivano-Frankivs`k  https://w.wiki/7vBe

Offline blauzahn

  • Almost regular
  • **
  • Posts: 151
Re: Code completion using LSP and clangd
« Reply #349 on: November 19, 2023, 10:36:58 am »
I second the remark by @ollydbg. Modern C++ has gotten extremely complex to parse. Even before C++11 it was complex. Recent standards like C++20 have added a ton of additional complexity and are continuing to do so.

Have you ever met a C++-compiler or -library programmer? It is a humbling experience.

It would be a lot more useful to help solving problems already reported in the bugtracker. Thank you for offering help.