Recent

Author Topic: IDE/ New Plugin  (Read 1350 times)

anderbelluno

  • New Member
  • *
  • Posts: 44
IDE/ New Plugin
« on: June 02, 2025, 02:58:16 pm »
Hello, I recently developed a plugin to use in the source code toolbar, the sources are available on Github https://github.com/anderbelluno/LazarusCodeExplorerPlugin, if you are interested, the plugin can be integrated into the new versions of Lazarus.

wp

  • Hero Member
  • *****
  • Posts: 12926
Re: IDE/ New Plugin
« Reply #1 on: June 03, 2025, 12:35:22 am »
I played with it a bit and noticed that the combobox does appear only for the blank form when Lazarus has just been opened. Any other project that I load does not show it any more. In your error log, I see a message "Error in OnEditorActivated: Access violation" after loading such a projct. Maybe this is the reason for it?

Ah error messages: you introduce your own error logging system in this package (DebugLog). This is not necessary because the IDE has its own, based on LazLogger, and the standard call is DebugLn(...).

I don't like that the label "Methods" is not centered vertically - this looks strange... I know, adding non-toolbutton controls to a Toolbar can have many surprises, add them to a panel first, where they can be positioned more freely - I'll prepare a pull request fixing this.

When a new toolbutton is added to the editor toolbar the combobox jumps to the left side after the "Jump to implementation" button. Maybe it's better to place it there from the beginning?

anderbelluno

  • New Member
  • *
  • Posts: 44
Re: IDE/ New Plugin
« Reply #2 on: June 03, 2025, 12:45:31 am »
Great, are welcome your fixes.
Thank you a lot.

wp

  • Hero Member
  • *****
  • Posts: 12926
Re: IDE/ New Plugin
« Reply #3 on: June 03, 2025, 03:28:34 pm »
I began debugging the unit to find out why the method combobox is not longer visible for projects loaded later. I added some more DebugLn instructions and got the following message log between loading the project and appearance of the mentioned exception:

Code: [Select]
Hint: (lazarus) [TMainIDE.DoOpenProjectFile] "D:\Prog_Lazarus\wp-git\jpmMath\fpc\_unittests\jpmTestsGUI.lpi"
*** ENTER OnEditorDestroy ***
[TCodeAnalyzerPlugin] OnEditorDestroy called
*** EXIT OnEditorDestroy ***
******** Highlighter.NeedScan ************
*** ENTER OnEditorActivated ***
*** D:\Prog_Lazarus\wp-git\jpmMath\fpc\_shared\jpmintegration.pas ***
[TCodeAnalyzerPlugin] OnEditorActivated: jpmintegration.pas
*** ENTER UpdateMethods ***
[TCodeAnalyzerPlugin] Updating methods for: jpmintegration.pas
*** ENTER UpdateComboSelection ***
   *** CurrentMethodIndex = 2 ***
   *** Combobox = $2DBD1F50 ***
   *** FCombobox.ClassName = TComboBox ***
   *** FCombobox.Items.ClassName = TWin32ComboBoxStringList ***
   *** Combobox.Items.Count = 10 ***
[TCodeAnalyzerPlugin] Auto-selected method: GaussIntegral
*** EXIT UpdateComboSelection ***
[TCodeAnalyzerPlugin] UpdateMethods completed. Found 9 methods
*** EXIT UpdateMethods ***
[TCodeAnalyzerPlugin] Cursor change event configured for editor
*** EXIT OnEditorActivated ***
 ####### ENTER TCombobox.Destroy #######
 ####### EXIT TCombobox.Destroy #######
*** ENTER OnCursorPosChanged ***
  ***  FCurrentEditor = 2C8754C0 ***
  *** IsValidEditor ***
*** ENTER UpdateComboSelection ***
   *** CurrentMethodIndex = 2 ***
   *** Combobox = $2DBD1F50 ***
   ******* FCOMBOBOX IS NOT A CLASS ANY MORE ******
[TCodeAnalyzerPlugin] Error in UpdateComboSelection: Access violation
The issue happens in UpdateComboSelection. It is called two times after loading the project. During the first time, everything is correct, but during the second time the Combobox still has the same address but cannot be detected as a TCustomCombobox class any more. And after adding debuglns also in TCustomCombobox.Create and .Destroy I saw that the combobox is destroyed before the second UpdateComboboxSelection is executed, but not created any more.

The question now is: Why is the combobox destroyed? In your code, it is destroyed only in the DestroyCombo method, but his is not called in this context.
found that the FCombobox class is not longer valid when UpdateComboboxSelection is entered after loading the project. Maybe an external command destroys the editor toolbar, when a new file is loaded, and since the combobox is owned by the toolbar, the toolbar would be destroyed here. Is your plugin notified of such an event?

CM630

  • Hero Member
  • *****
  • Posts: 1451
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: IDE/ New Plugin
« Reply #4 on: June 04, 2025, 08:48:56 am »
There is already a code explorer in the IDE, I wonder what the advantages of yours are.
In the screenshot, I saw no area for typing; if there is not one, the usefulness of the plugin seems very limited.
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: IDE/ New Plugin
« Reply #5 on: June 04, 2025, 09:40:45 pm »
There is already a code explorer in the IDE, I wonder what the advantages of yours are.
In the screenshot, I saw no area for typing; if there is not one, the usefulness of the plugin seems very limited.
Yes, you can dock Code Explorer window that has similar functionality. Dock is the keyword here, otherwise the window is gonna be floating. This package instead integrates with the source editor toolbar, provides the listing and filtering mechanism via combobox (from which you can type) instead of treeview, and specifically lists only methods. Indeed it might be less featureful than Code Explorer, though.

n7800

  • Sr. Member
  • ****
  • Posts: 402
Re: IDE/ New Plugin
« Reply #6 on: June 04, 2025, 10:39:56 pm »
In fact, this package reminded me of the old days when I wrote macros in Visual Basic for MS Office. In the editor (called via the menu or [Alt+F11]) there are two combo boxes at the top. I found screenshot examples on this and this pages.

I almost never use MS Visual Studio, but as far as I can see from the screenshots, it has this too.

And these combo boxes are not labeled anywhere, and I think the "Methods:" label is unnecessary and takes up space. I think everything will be intuitive without it.

n7800

  • Sr. Member
  • ****
  • Posts: 402
Re: IDE/ New Plugin
« Reply #7 on: June 05, 2025, 12:14:35 am »
As for duplicating the functionality, this is a complete analogue of the "Main Menu > Search > Procedure List" dialog [Alt+G], only not modal, and for mouse lovers.

The advantage over this dialog is that it shows the current procedure. However, this is already done by "sticky scrolling", which shows the first line of the function "header" in the editor itself...

In any case, the presence of such a combobox in popular IDEs indicates that it is in demand.

anderbelluno

  • New Member
  • *
  • Posts: 44
Re: IDE/ New Plugin
« Reply #8 on: June 13, 2025, 12:19:10 am »
The intention would be to have a filter and a list of methods faster, I like this model, if you think it's useless, just ignore it, don't install it, and if you want to help improve it, feel free.
In my work environment it's working the way I need it, if it doesn't work for other environments, you can adjust it and send a pull request on my Github.
I appreciate everyone's collaboration.

 

TinyPortal © 2005-2018