Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Code completion using LSP and clangd

<< < (60/85) > >>

ollydbg:

--- Quote from: Pecan on January 14, 2023, 10:28:10 pm ---
--- Quote from: ollydbg on December 28, 2022, 09:43:03 am ---Hi, I see one issue today.

In the latest clangd_client (0.61), I see that "find declaration" and "find implementation" context menu item just do the same thing.

Here, I can see when I click on either item, it just jump between the function declaration and implementation.

--- End quote ---

This "bounce" behavior is how clangd is currently working.
If the user asks for a declaration while positioned on it, clangd will respond with the implementation location and vise versa.
 
They seem to think that's how a "smart editor" should act.
i.e., "Do what I meant to do" behavior. Read my mind, not my mouse.
https://github.com/clangd/clangd/issues/713

I've spent 25 hours trying to get this to behave how the old CodeCompletion behaved.
Alas, I've failed, since it would require parsing the file text of the "GoTo/Find"response. That would get us back to the problem we're trying to get away from, namely parsing c++ code.

I'm leaving it as is until (maybe) clangd gives us an option to circumvent this behavior.

Suggestions welcomed.

--- End quote ---

Thanks, especially for your time and effort to try to fix the issue. I just add one comment on that clangd github issue.

Here are my guess:

To distinguish the definition and declaration. If we have to two locations: one in header file and the other in implementation file. This means the former is the declaration and the later is the definition.

If we can't distinguish by the file extension, then I guess the declaration have the ";" at the end of the statement, and the definition usually don't. Maybe a function definition may have a "{" at the beginning. (I think this is the way our build-in C++ parser parses the file, maybe ctags universal-ctags/ctags: A maintained ctags implementation, the one used in CodeLite for its native C++ parser also did that similar things.)

BlueHazzard:
Just some error reporting. During editing the ProjectLoader.cpp from codeblocks i get a lot of this error message dialogs:

I can not find steps to reproduce them, they come on opening file, or editing it, quite random... Sometimes it works...

Would it be possible to not use message boxes for this? Simply logging would be enough i think, message boxes interrupt the user work...

Pecan:

--- Quote from: BlueHazzard on February 26, 2023, 12:38:47 am ---Just some error reporting. During editing the ProjectLoader.cpp from codeblocks i get a lot of this error message dialogs:

I can not find steps to reproduce them, they come on opening file, or editing it, quite random... Sometimes it works...

Would it be possible to not use message boxes for this? Simply logging would be enough i think, message boxes interrupt the user work...

--- End quote ---

For me this happens after running the debugger.
Clangd_client is paused when running the debugger, but it didn't solve the problem. I'll keep working on it.
 
You can right-click in the editor and select "Reparse this file" or right-click on the project in the workspace tree and select "Reparse this project" to solve the problem.

I'll move the messages to the log as you suggest.

Thanks for the report.
It tells me that it's not just my machine that's having this problem.

Pecan:

--- Quote from: BlueHazzard on February 26, 2023, 12:38:47 am ---Just some error reporting. During editing the ProjectLoader.cpp from codeblocks i get a lot of this error message dialogs:

I can not find steps to reproduce them, they come on opening file, or editing it, quite random... Sometimes it works...

Would it be possible to not use message boxes for this? Simply logging would be enough i think, message boxes interrupt the user work...

--- End quote ---

This should be fixed in Head 13230.
Clangd_client now puts a msg in the log and issues an Info msg that the file is being reparse.
I cannot find a way to re-create the problem. So if it happens, let me know if the fix is working ok.

Thanks

killerbot:
since I build and installed clang16, the plug-in keep asking to specify the path to clangd, though it is in the same location as before, and even explicitly specifying the path does not help.


> which clangd
/opt/llvm/bin/clangd

> clangd --version
clangd version 16.0.0 (https://github.com/llvm/llvm-project.git 08d094a0e457360ad8b94b017d2dc277e697ca76)
Features: linux
Platform: x86_64-unknown-linux-gnu

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version