Sign in Join
Wiki copytemporary

Codetools/fr: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Codetools/fr

OldNewLine
1+## Que sont les outils de code(codetools)
2+
3+Le paquet "outils de code" est un paquet de Lazarus fournissant des outils pour analyser, explorer, éditer et refactoriser les sources en langage Pascal. Les outils de code sont un module par eux-mêmes et sont proposés sous la licence GPL. Il existe de nombreux exemples sur comment utiliser les outils de code dans vos propres programmes dans le répertoire components/codetools/examples.
4+
5+svn:
6+
7+ * Lazarus : <http://svn.freepascal.org/svn/lazarus/trunk>
8+ * Seulement les outils de code : <http://svn.freepascal.org/svn/lazarus/trunk/components/codetools>
9+
10+## Utilisation des outils de code sans l'IDE
11+
12+Vous pouvez utiliser les outils de code sans l'IDE. Ceci peut être utile pour tester un nouvel outil. Un exemple simple est proposé avec
13+```
14+<lazarusdir>/components/codetools/examples/methodjumping.lpi
15+```
16+
17+Pour tester et trouver les déclarations, les outils de code ont besoin d'analyser les sources, notamment les sources RTL et FCL. Les exemples utilisent les variables d'environnement suivantes :
18+
19+ * FPCDIR : chemin des sources FPC, par défaut _~/freepascal/fpc_.
20+ * PP : chemin de l'exécutable du compilateur (/usr/bin/fpc ou /usr/bin/ppc386 ou C:\lazarus\ppc386.exe). Les codetools ont besoin de demander au compilateurs les paramètres d'exécution. Par défaut, la recherche s'effectue grâce à 'fpc' _via_ la variable PATH.
21+ * FPCTARGETOS : indique aux codetools de travailler pour un autre système d'exploitation (compilation transversale). Par exemple : linux, freebsd, darwin, win32, win64, wince.
22+ * FPCTARGETCPU : lors d'un travail avec un autre CPU. Par exemple : i386, powerpc, x86_64, arm, sparc.
23+ * LAZARUSDIR: chemin des sources de Lazarus. Utile seulement si vous travaillez avec elles.
24+
25+FPC is a very complex project with lots of search paths, include files and macros. The codetools need to know all these paths and macros 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
26+```
27+<lazarusdir>/components/codetools/examples/finddeclaration.lpi
28+```
29+
30+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 depending on your disk speed. All examples save the result in **codetools.config** , so that on next start the scan is skipped.
31+
32+Whenever the FPC sources have moved or a unit is renamed, just delete the file **codetools.config**. The Lazarus IDE has its own config file and does the rescan, whenever the compiler executable has changed or the user forces a 'Environment > Rescan FPC source directory'.
33+
34+## Using the codetools in the IDE with the IDEIntf
35+
36+See <lazarusdir>/examples/idequickfix/quickfixexample.lpk package. It demonstrates:
37+
38+ * How to write an IDE package.
39+
40+```
41+When You install it will register a Quick Fix item.
42+```
43+
44+ * How to write Quick Fix item for compiler messages 'Parameter "Sender" not used'
45+ * How to use the codetools to
46+
47+```
48+* parsing a unit
49+ * conversion of Filename,Line,Column to codetools source position
50+ * finding a codetools node at a cursor position
51+ * finding a procedure node and the begin..end node
52+ * creating a nice insertion position for a statement at the beginning of
53+ the begin..end block
54+ * getting the indentation of a line, so that the new line will
55+ work in sub procedure as well
56+ * inserting code with the codetools
57+```
58+
59+---
60+*From the Free Pascal wiki, page "Codetools/fr", as the Internet Archive kept it on 2025-05-15. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history