Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-07

Lazarus Codetools

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Дмитрий Курашкин

Hi to all!

I am using Lazarus 2 years. Now I want to try develop some features for Lazarus.
I want make something like Eclipse (java IDE) feature. When user move mouse cursor over class property or method, my patch mast show hint window, which allow make some changes in class definition: change type, scope, set and get methods, etc. It will works as powerful refactoring tool. I think it will be very nice feature!

I have seen some source files, but they hasn't comments, so I can't understand how it works or must waste a lot of time for understanding. I would be very much obliged to you if you can ask me where source codes contains following:

- hint window in code editor: it's showning condition, content (variable description, for example), etc.
- getting information about variables, classes, types, functions, for example:

user writes:
*
uses *AncectorClass;

*type *
TMyChild = *class *(TMyAncector)

  *end*;

How can I recieve code of *TMyAncector *class as string or string list?

Please, ask me which units of IDE sources can help me?

P. S. I found modules *FindDeclarationTool, CodeTree, CodeCache* In $LazarusDir$/components/examples/codetools. Is it units what I need? -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100728/b97c3b3f/attachment.html>

Reply by email

Mattias Gaertner
to Дмитрий Курашкин
Hi to all! I am using Lazarus 2 years. Now I want to try develop some features for Lazarus.

Great!

Show quoted text 8 lines
I want make something like Eclipse (java IDE) feature. When user move mouse cursor over class property or method, my patch mast show hint window, which allow make some changes in class definition: change type, scope, set and get methods, etc. It will works as powerful refactoring tool. I think it will be very nice feature! I have seen some source files, but they hasn't comments, so I can't understand how it works or must waste a lot of time for understanding.

The above functions are probably not simple extensions, so I have to explain some more:

The codetools do all the parsing and refactoring. The IDE just adds menu items, setup dialogs, short cuts. Because the codetools are a normal package you can write command line programs to test functions. This greatly help debugging. There are already many such utilities in components/codetools/examples.

See here
http://wiki.lazarus.freepascal.org/Codetools

Maybe I can use this opportunity to add an extensive example.

Refactoring tools are put into the popup menu of the source editor (like eclipse) and in the main menu (there is already a feature request for that). Your tools should be put there too.

And when that works you can extend the hint window.

Show quoted text 5 lines
I would be very much obliged to you if you can ask me where source codes contains following: - hint window in code editor: it's showning condition, content (variable description, for example), etc.

The source editor has a timer and some flags to show the hint window.

See ide/sourceeditor.pp
TSourceNotebook.ShowSynEditHint

Your refactoring tools should not run when the completion box is open. So this needs to be checked somewhere.

It then calls Manager.OnShowHintForSource which calls in ide/main.pp TMainIDE.OnSrcNotebookShowHintForSource

This checks the current state. For example while debugging it evaluates the identifier under the cursor.
Then it asks the codetools for declaration and comments. Then it asks the help system, which normally searches the fpdoc files. Then it has a hint as html.
This is passed to source editor to show its hint window.

See ide/sourceeditor.pp
TSourceNotebook.ActivateHint

It calls LazarusHelp.CreateHint which calls ide/helpmanager.pas TIDEHelpManager.CreateHint.

I guess, you want to add some buttons to the hint window as eclipse does.

Show quoted text 6 lines
- getting information about variables, classes, types, functions, for example: user writes: * uses *AncectorClass;

Do you mean
uses UnitOfAncectorClass;
?

Show quoted text 7 lines
*type * TMyChild = *class *(TMyAncector) *end*; How can I recieve code of *TMyAncector *class as string or string list?

The codetools can search for its nodes, file, clean position and source position. Then you can parse it token by token, or iterate all its child nodes or as extract it as string or whatever fits.

Please, ask me which units of IDE sources can help me? P. S. I found modules *FindDeclarationTool, CodeTree, CodeCache* In $LazarusDir$/components/examples/codetools. Is it units what I need?

Yes.

Can you explain what each of your functions should do exactly? Then I can write some docs how to do that.

Mattias

Reply by email