News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Code completion using LSP and clangd

Started by Pecan, February 20, 2021, 09:13:50 PM

Previous topic - Next topic

kakas

I should be the one thanking you for this amazing plugin ;D

Quote from: Pecan on April 10, 2024, 05:43:01 PM
In the coming Nightly, you will also be able to Alt-LeftMouseClick on the red/green warning/error box in the margin to apply any suggested fix.
Hmmm... I might have to keep an eye out for nightly build after this.

MaxGaspa

Hi,

I'm writing to submit a (passible) bug report of the Code Completion plugin (LSP and Clangd).

When I load a project the plugin starts to parse all the project's files. I observe the log of parsing in the Code::Blocks  panel of the Logs window. In the meantime  I open a file, Application.cpp for example,  and  I select "Application:" to use the plugin (see image attached)...but...as soon as a new file is parsed the selection disappears....so I can't use the code completion till the full parsing of the projects. As soon as a new file parsing is completed the selection becomes blank.

Is this behavior expected?

Windows 10 , latest nightly , latest Mys2 clang 18.1.3-1

Pecan

Quote from: MaxGaspa on April 16, 2024, 12:02:56 PM
Hi,

I'm writing to submit a (passible) bug report of the Code Completion plugin (LSP and Clangd).

When I load a project the plugin starts to parse all the project's files. I observe the log of parsing in the Code::Blocks  panel of the Logs window. In the meantime  I open a file, Application.cpp for example,  and  I select "Application:" to use the plugin (see image attached)...but...as soon as a new file is parsed the selection disappears....so I can't use the code completion till the full parsing of the projects. As soon as a new file parsing is completed the selection becomes blank.

Is this behavior expected?

Windows 10 , latest nightly , latest Mys2 clang 18.1.3-1

Would you please give steps to re-create and trace the problem, i.e.,
1) do this
2) now do that

MaxGaspa

Quote from: Pecan on April 16, 2024, 06:37:58 PM

Would you please give steps to re-create and trace the problem, i.e.,
1) do this
2) now do that

1) open a project with multiple source file, so the whole parsing process takes time (more than few seconds)
2) During the parsing process open a source file
3) Select in the box (shown in the attached e-mail) a choice
4) When the parsing of a file is completed the box is cleared (made empty).

In case I can make a video....

Max


Pecan

#410
Quote from: MaxGaspa on April 16, 2024, 12:02:56 PM
Hi,

I'm writing to submit a (passible) bug report of the Code Completion plugin (LSP and Clangd).

When I load a project the plugin starts to parse all the project's files. I observe the log of parsing in the Code::Blocks  panel of the Logs window. In the meantime  I open a file, Application.cpp for example,  and  I select "Application:" to use the plugin (see image attached)...but...as soon as a new file is parsed the selection disappears....so I can't use the code completion till the full parsing of the projects. As soon as a new file parsing is completed the selection becomes blank.

Is this behavior expected?

Windows 10 , latest nightly , latest Mys2 clang 18.1.3-1

Thanks for the video. It cleared up (in my head) what box you were trying to point out.

That box is called the Clangd_client (or CodeCompletion) toolbar.

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

The left hand side (the one you were clicking in) displays the classes in an active editor file, and the right hand choice box shows all functions within the class.

You can cause the editor to position on a class/function by clicking in the left hand choice box to choose the class, then click in the right choice box and choosing what function to position to.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.

Regards


MaxGaspa

Quote from: Pecan on April 17, 2024, 07:09:19 PM

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.


Thank you for your answer but....

...it seems that the issue is still the same even if I'm clicking the editor.

Hereafter another video in which it should be very clear that I'm activating (clicking) the editor but the "left choice" still disapperar.

If I'm so quick (very quick) to select something in the "right choice" before the "left choice" is blanked .... then the "left choice" is no longer disappearing. But it's difficult...I need to be very quick. Basically I need to wait for the parsing completion before using the plugin.

https://drive.google.com/file/d/1ntVkrxRg9YccNJBByNuHaBKE-SgX3Xwn/view?usp=sharing

Pecan

Quote from: MaxGaspa on April 17, 2024, 11:28:29 PM
Quote from: Pecan on April 17, 2024, 07:09:19 PM

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.


Thank you for your answer but....

...it seems that the issue is still the same even if I'm clicking the editor.

Hereafter another video in which it should be very clear that I'm activating (clicking) the editor but the "left choice" still disapperar.

If I'm so quick (very quick) to select something in the "right choice" before the "left choice" is blanked .... then the "left choice" is no longer disappearing. But it's difficult...I need to be very quick. Basically I need to wait for the parsing completion before using the plugin.

https://drive.google.com/file/d/1ntVkrxRg9YccNJBByNuHaBKE-SgX3Xwn/view?usp=sharing

I cannot reproduce this. So would you start CB with the -d or /d parameter so that the Code::Blocks Debug log is produced.

Before you load your project be sure that the "CodeBlocks Debut" log tab is focused.

Do as you have done to cause the bug, then right-click the Code::Blocks Debug tab and choose copy "contents to clipboard", Paste it into a message here between code tags (the # icon above a forum reply box).

Thanks for your patience with this.
It's really peculiar.

BTW: after the new file is parsed and clicked into, can you even perform a Mainmenu/Search/goto function, (Ctrl-Shift-G for me.)
It tells me if if the bug is in the plugin interface to the editor code or the toobar code.

Pecan

#413
Quote from: MaxGaspa on April 17, 2024, 11:28:29 PM
Quote from: Pecan on April 17, 2024, 07:09:19 PM

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.


Thank you for your answer but....

...it seems that the issue is still the same even if I'm clicking the editor.

Hereafter another video in which it should be very clear that I'm activating (clicking) the editor but the "left choice" still disapperar.

If I'm so quick (very quick) to select something in the "right choice" before the "left choice" is blanked .... then the "left choice" is no longer disappearing. But it's difficult...I need to be very quick. Basically I need to wait for the parsing completion before using the plugin.

https://drive.google.com/file/d/1ntVkrxRg9YccNJBByNuHaBKE-SgX3Xwn/view?usp=sharing

I just watched the video again.
I see that you're not clicking either inside a class or a function.
Do this, after the clicked file has parsed, click inside a function, not at the top of an editor file.
Tell me if you still get the bug.

If you get the bug, send me the Code::Blocks Debug log as specified in the previous messgage.

Thanks

kakas

hey @Pecan
sorry to bother you again but I have encounter an unusual behavior.
I was trying to use a large single file libraryhttps://github.com/mackron/miniaudio.
It has a single headerfile: miniaudio.h <--- 62k lines

when I try to open the header file or search for declaration through the main.c, whole code blocks freezes for solid 1-2 mins, weanwhile the mouse gradually becomes unresponsive until it's completely frozen and the screen turns black. Throws an error that Clangd_Cliet has stopped at the end.

I not sure if it's because my laptop isn't powerful enough. because the plugin usually worked smooth with other large libraries.

Apart from this single instance the plugin works fine and it has been very helpful.

Pecan

#415
Quote from: kakas on April 18, 2024, 08:17:02 AM
hey @Pecan
sorry to bother you again but I have encounter an unusual behavior.
I was trying to use a large single file libraryhttps://github.com/mackron/miniaudio.
It has a single headerfile: miniaudio.h <--- 62k lines

when I try to open the header file or search for declaration through the main.c, whole code blocks freezes for solid 1-2 mins, weanwhile the mouse gradually becomes unresponsive until it's completely frozen and the screen turns black. Throws an error that Clangd_Cliet has stopped at the end.

I not sure if it's because my laptop isn't powerful enough. because the plugin usually worked smooth with other large libraries.

Apart from this single instance the plugin works fine and it has been very helpful.

I'll have a look at it.
Please attach your .cbp file for the project and your main.c  to a forum reply, so I can mirror what's happening.
Thanks for the report.


Pecan

#416
Quote from: Pecan on April 18, 2024, 06:21:12 PM
Quote from: kakas on April 18, 2024, 08:17:02 AM
hey @Pecan
sorry to bother you again but I have encounter an unusual behavior.
I was trying to use a large single file libraryhttps://github.com/mackron/miniaudio.
It has a single headerfile: miniaudio.h <--- 62k lines

when I try to open the header file or search for declaration through the main.c, whole code blocks freezes for solid 1-2 mins, weanwhile the mouse gradually becomes unresponsive until it's completely frozen and the screen turns black. Throws an error that Clangd_Cliet has stopped at the end.

I not sure if it's because my laptop isn't powerful enough. because the plugin usually worked smooth with other large libraries.

Apart from this single instance the plugin works fine and it has been very helpful.

I'll have a look at it.
Please attach your .cbp file for the project and your main.c  to a forum reply, so I can mirror what's happening.
Thanks for the report.

After testing and tracing clangd_client and the miniAudio source I believe it will not be possible to pass that 4meg miniAudio.h file to clangd.

I have a relatively fast system, but clangd never finished parsing the header file before it crashed attempting to create a response file which would have been many times the size of the source file (about 24meg or more) after it formatted a response containing line/col/symbol/diagnostics/fix suggestions, etc.
If it didn't give out of memory, it sure would have caused Clangd_client to.

That header file will have to be broken up into multiple headers in order for clangd to handle it.

Note from opinionated self: I really do not consider creating a 4meg header file as acceptable software design. It's just going to create grief for anyone using it. If not now, certainly in the future.

MaxGaspa

Quote from: Pecan on April 18, 2024, 01:18:54 AM
I see that you're not clicking either inside a class or a function.
Do this, after the clicked file has parsed, click inside a function, not at the top of an editor file.

Yes, clicking inside a function or class works. Thanks

kakas

Quote from: Pecan on April 18, 2024, 06:21:12 PM
I'll have a look at it.
Please attach your .cbp file for the project and your main.c  to a forum reply, so I can mirror what's happening.
Thanks for the report.
(sorry for the late reply, I lost track of time)
I had to change the file extension since the anything other than image and txt file isn't accepted. Miniaudio.txt is cbp and main.txt is main.c

kakas

Quote from: Pecan on April 18, 2024, 11:16:15 PM
After testing and tracing clangd_client and the miniAudio source I believe it will not be possible to pass that 4meg miniAudio.h file to clangd.

I have a relatively fast system, but clangd never finished parsing the header file before it crashed attempting to create a response file which would have been many times the size of the source file (about 24meg or more) after it formatted a response containing line/col/symbol/diagnostics/fix suggestions, etc.
If it didn't give out of memory, it sure would have caused Clangd_client to.

That header file will have to be broken up into multiple headers in order for clangd to handle it.

Note from opinionated self: I really do not consider creating a 4meg header file as acceptable software design. It's just going to create grief for anyone using it. If not now, certainly in the future.
yea that makes sense I guess. I think I'll have to break the miniaudio.h in like miniaudio1.h miniaudio2.h miniaudio3.h... no?