Difference between revisions of "Codetools"

From Lazarus wiki
Jump to navigationJump to search
Line 8: Line 8:
 
   <lazarusdir>/components/codetools/methodjumping.lpi
 
   <lazarusdir>/components/codetools/methodjumping.lpi
  
To test find declaration, the codetools need to parse sources. Especially the RTL and FCL sources. FPC is a very complex project with lots of search paths, include files and makros. The codetools need to know all these paths and makros in order to parse this djungel. To setup all this easily the codetools contains predefined templates for FPC, Lazarus, Delphi and Kylix source directories.  
+
To test find declaration, the codetools need to parse sources. Especially the RTL and FCL sources. FPC is a very complex project with lots of search paths, include files and makros. The codetools need to know all these paths and makros in order to parse this jungle. To setup all this easily the codetools contain predefined templates for FPC, Lazarus, Delphi and Kylix source directories.  
 
See for a find declaration example
 
See for a find declaration example
 
   <lazarusdir>/components/codetools/finddeclaration.lpi
 
   <lazarusdir>/components/codetools/finddeclaration.lpi
  
Because the FPC sources contain multiple versions of some units, and the FPC sources changes often, the codetools does not use a fixed path table, but instead scan first the whole FPC directory structure and try to guess, what source is the right for the current TargetOS and TargetCPU. This scan may take a while. So the result is saved. From time to when the FPC sources have moved or renamed a unit this scan must be repeated. The IDE does this rescan, whenever the compiler executable changed or the user forces a 'Tools > Rescan FPC source directory'.
+
Because the FPC sources contain multiple versions of some units, and the FPC sources changes often, the codetools does not use a fixed path table, but instead scan first the whole FPC directory structure and try to guess, what source is the right for the current TargetOS and TargetCPU. This scan may take a while. So the result is saved. Whenever the FPC sources have moved or a unit is renamed, this scan must be repeated. The IDE does this rescan, whenever the compiler executable has changed or the user forces a 'Tools > Rescan FPC source directory'.
  
 
== Using the codetools in the IDE with the IDEIntf ==
 
== Using the codetools in the IDE with the IDEIntf ==

Revision as of 14:16, 26 February 2006

What are the codetools

The codetools are a module of their own and are licensed under GPL.

Using the codetools without the IDE (good for testing)

You can use the codetools without the IDE. This can be used to test a new tool. An easy example is

 <lazarusdir>/components/codetools/methodjumping.lpi

To test find declaration, the codetools need to parse sources. Especially the RTL and FCL sources. FPC is a very complex project with lots of search paths, include files and makros. The codetools need to know all these paths and makros in order to parse this jungle. To setup all this easily the codetools contain predefined templates for FPC, Lazarus, Delphi and Kylix source directories. See for a find declaration example

 <lazarusdir>/components/codetools/finddeclaration.lpi

Because the FPC sources contain multiple versions of some units, and the FPC sources changes often, the codetools does not use a fixed path table, but instead scan first the whole FPC directory structure and try to guess, what source is the right for the current TargetOS and TargetCPU. This scan may take a while. So the result is saved. Whenever the FPC sources have moved or a unit is renamed, this scan must be repeated. The IDE does this rescan, whenever the compiler executable has changed or the user forces a 'Tools > Rescan FPC source directory'.

Using the codetools in the IDE with the IDEIntf

See <lazarusdir>/examples/idequickfix/quickfixexample.lpk package. It demonstrates:

  • How to write an IDE package.
 When You install it will register a Quick Fix item.
  • How to write Quick Fix item for compiler messages 'Parameter "Sender" not used'
  • How to use the codetools to
     * parsing a unit
     * conversion of Filename,Line,Column to codetools source position
     * finding a codetools node at a cursor position
     * finding a procedure node and the begin..end node
     * creating a nice insertion position for a statement at the beginning of
       the begin..end block
     * getting the indentation of a line, so that the new line will
       work in sub procedure as well
     * inserting code with the codetools