Difference between revisions of "Lazarus IDE Tools/fi"

From Lazarus wiki
Jump to navigationJump to search
Line 373: Line 373:
  
  
{{Note| Kursori on sijoitettava heti ':=' saa arvokseen operatorin jälkeen. Jos kursori sijoitetaan osoittamaan esim. OnPaint tunnisteeseen niin koodin suorittaminen viittaa "Local Variable Completion", joka epäonnistuu, koska OnPaint on jo määritetty.
+
{{Note| Kursori on sijoitettava heti ':=' saa arvokseen operatorin jälkeen. Jos kursori sijoitetaan osoittamaan esim. OnPaint tunnisteeseen niin koodin suorittaminen viittaa "Local Variable Completion", joka epäonnistuu, koska OnPaint on jo määritetty.}}
  
 
Vinkit:<br>
 
Vinkit:<br>
Line 408: Line 408:
  
 
===Variable Declaration Completion===
 
===Variable Declaration Completion===
"Variable Declaration Completion" is part of the Code Completion and adds a local variable definition for a Identifier:=Term; statement. It is invoked, when the cursor is on the identifier of an assignment or a parameter.
+
"Variable Declaration Completion" on osa Code Completion:a.
 +
Se lisää paikallisen muuttujan määritelmän tunnisteelle := Term; lause. Sitä kutsutaan, kun kohdistin on osoittaa parametria tai tunnistetta.
 +
 
 +
Esimerkiksi:
  
For example:
 
 
<source>procedure TForm1.Form1Create(Sender: TObject);
 
<source>procedure TForm1.Form1Create(Sender: TObject);
 
begin
 
begin
 
   i:=3;
 
   i:=3;
 
end;</source>
 
end;</source>
Place the cursor on the 'i' or just behind it. Then press {{keypress|Ctrl|Shift|C}} for code completion and you will get:
+
Kursorin paikka on tunnisteessa 'i' tai sen jälkeen. Painamalla {{keypress|Ctrl|Shift|C}} saadaan:
 
<source>procedure TForm1.Form1Create(Sender: TObject);
 
<source>procedure TForm1.Form1Create(Sender: TObject);
 
var
 
var
Line 423: Line 425:
 
end;</source>
 
end;</source>
  
The codetools first checks, if the identifier 'i' is already defined and if not it will add the declaration 'var i: integer;'. The type of the identifier is guessed from the term right to the assignment ':=' operator. Numbers like the 3 defaults to Integer.
+
Toiminto ensin tarkastaa onko tunnistetta 'i' jo määritelty. Jos sitä ei ole niin lisää määrittelyn 'var i: integer;'.
 +
Tunnisteen tyyppi arvatellaan  ": =" operaattorista. Kokonaisluvun, kuten 3 oletustyyppinä on Integer.
  
Another example:
+
Toinen esimerkki:
 
<source>type
 
<source>type
 
   TWhere = (Behind, Middle, InFront);
 
   TWhere = (Behind, Middle, InFront);
Line 436: Line 439:
 
   end;</source>
 
   end;</source>
  
Place the cursor on 'Where' and press {{keypress|Ctrl|Shift|C}} for code completion. You get:
+
Kursorin paikka on 'Where'-sanan kohdalla ja painetaan {{keypress|Ctrl|Shift|C}} niin saadaan:
 
<source>  procedure TForm1.Form1Create(Sender: TObject);
 
<source>  procedure TForm1.Form1Create(Sender: TObject);
 
   var
 
   var
Line 445: Line 448:
 
   end;</source>
 
   end;</source>
  
Since 0.9.11 Lazarus also completes parameters. For example
+
Lazarus on versiosta 0.9.11 lähtien myös täydentänyt parametreja. Esimerkiksi
 
<source>  procedure TForm1.FormPaint(Sender: TObject);
 
<source>  procedure TForm1.FormPaint(Sender: TObject);
 
   begin
 
   begin
Line 453: Line 456:
 
   end;</source>
 
   end;</source>
  
Place the cursor on 'x1' and press {{keypress|Ctrl|Shift|C}} for code completion. You get:
+
Sijoita kursori 'x1' ja paina {{keypress|Ctrl|Shift|C}} niin saadaan:
 
<source>  procedure TForm1.FormPaint(Sender: TObject);
 
<source>  procedure TForm1.FormPaint(Sender: TObject);
 
   var
 
   var
Line 463: Line 466:
 
   end;</source>
 
   end;</source>
  
Since 0.9.31 Lazarus completes pointer parameters. For example
+
Lazarus on versiosta 0.9.31 täydentänyt osoittimen parametrit. Esimerkiksi
  
 
<source>  procedure TForm1.FormCreate(Sender: TObject);
 
<source>  procedure TForm1.FormCreate(Sender: TObject);
Line 470: Line 473:
 
   end;</source>
 
   end;</source>
  
Place the cursor on 'IconInfo' and press {{keypress|Ctrl|Shift|C}} for code completion. You get:
+
Sijoita kursori 'IconInfo':n ja paina {{keypress|Ctrl|Shift|C}} niin saadaan:
 
<source>  procedure TForm1.FormCreate(Sender: TObject);
 
<source>  procedure TForm1.FormCreate(Sender: TObject);
 
   var
 
   var
Line 478: Line 481:
 
   end;</source>
 
   end;</source>
  
In all above examples you can use {{keypress|Ctrl|Shift|X}} to show a Code Creation dialog where you can set more options.
+
Kaikissa edellä olevissa esimerkeissä voit käyttää {{keypress|Ctrl|Shift|X}}-näppäintä näyttääksesi koodin luomisen valintaikkunan, jossa voit asettaa lisää vaihtoehtoja.
  
 
===Procedure Call Completion===
 
===Procedure Call Completion===
Code completion can create a new procedure from a call statement itself.
 
  
Assume you just wrote the statement "DoSomething(Width);"
+
Code completion voi luoda uuden aliohjelman sen kutsusta.
 +
 
 +
Oletataan että kirjoitettiin vain lause "DoSomething(Width);"
 
<source>procedure SomeProcedure;
 
<source>procedure SomeProcedure;
 
var
 
var
Line 492: Line 496:
 
end;</source>
 
end;</source>
  
Position the cursor over the identifier "DoSomething" and press {{keypress|Ctrl|Shift|C}} to get:
+
Sijoita kursori tekstiin "DoSomething" ja paina {{keypress|Ctrl|Shift|C}} niin saadaan:
  
 
<source>procedure DoSomething(aWidth: LongInt);
 
<source>procedure DoSomething(aWidth: LongInt);
Line 507: Line 511:
 
end;</source>
 
end;</source>
  
It does not yet create functions nor methods.
+
Se ei vielä luo funktioita tai metodeja.
  
 
===Reversed Class Completion===
 
===Reversed Class Completion===
  
"Reversed Class Completion" is part of the '''Code Completion''' and adds a private method declaration for the current method body. It is invoked, when the cursor is in a method body, not yet defined in the class.
+
"Reversed Class Completion" on osa '''Code Completion''' toimintaa.
This feature is available since Lazarus 0.9.21.
+
Se lisää yksityisen metodin ilmoituksen nykyiselle metodiryhmälle. Sitä kutsutaan, kun kursori on metodin rungossa, jota ei ole vielä määritelty luokassa. Tämä ominaisuus on saatavana Lazarus 0.9.21 versiosta alkaen.
  
For example:
+
Esimerkiksi:  
 
<source>  procedure TForm1.DoSomething(Sender: TObject);
 
<source>  procedure TForm1.DoSomething(Sender: TObject);
 
   begin
 
   begin
 
   end;</source>
 
   end;</source>
  
The method DoSomething is not yet declared in TForm1. Press {{keypress|Ctrl|Shift|C}} and the IDE will add "procedure DoSomething(Sender: TObject);" to the private methods of TForm1.
+
DoSomething-metodia ei ole vielä määritelty TForm1: ssä. Paina {{keypress|Ctrl|Shift|C}} ja IDE lisää aliohjelman "procedure DoSomething (Sender: TObject);" TForm1: n yksityisiin metodeihin.
 +
 
 +
Delphi käyttäjille:
 +
Class completion  toimii Lazaruksen mukaan aina yhdellä tavalla: Luokan käyttöliittymästä toteutukseen tai taaksepäin / päinvastoin luokan toteutuksesta käyttöliittymään. Delphi kutsuu aina molempiin suuntiin. Delphi-tapa on haitta, että jos on typo se luo helposti uuden tynkä metodin ilman huomaamatta.
  
For Delphians:
+
===Kommentit ja Code Completion===
Class completion works under Lazarus always in one way: From class interface to implementation or backwards/reversed from class implementation to interface. Delphi always invokes both directions. The Delphi way has the disadvantage, that if a typo will easily create a new method stub without noticing.
+
Code completion yrittää pitää kommentteja, johon ne kuuluvat.  
 +
Esimerkiksi:
  
===Comments and Code Completion===
 
Code completion tries to keep comments where they belong.
 
For example:
 
 
<source>  FList: TList; // list of TComponent
 
<source>  FList: TList; // list of TComponent
 
   FInt: integer;</source>
 
   FInt: integer;</source>
When inserting a new variable between FList and FInt, the comment is kept in the FList line. Same is true for
+
Kun lisätään uusi muuttuja FListin ja FInt: n välillä, kommentti pidetään FList-rivillä. Sama pätee myös
 
<source>  FList: TList; { list of TComponent
 
<source>  FList: TList; { list of TComponent
    This is a comment over several lines, starting
+
      Tämä on usean rivin kommentti, alkaen
    in the FList line, so codetools assumes it belongs
+
      FList-riviltä, joten codetools olettaa sen kuuluvan 
    to the FLIst line and will not break this
+
      FLIst-riviin ja ei riko tätä 
    relationship. Code is inserted behind the comment. }
+
      suhdetta. Koodi lisätään kommentin taakse. }
 
   FInt: integer;</source>
 
   FInt: integer;</source>
If the comment starts in the next line, then it will be treated as if it belongs to the code below. For example:
+
Jos kommentti alkaa seuraavalla rivillä, sitä käsitellään kuin se kuuluu alla olevaan koodiin. Esimerkiksi:
 
<source>  FList: TList; // list of TComponent
 
<source>  FList: TList; // list of TComponent
    { This comment belongs to the statement below.  
+
      { Tämä kommentti kuuluu alla olevaan lauseeseen.
      New code is inserted above this comment and
+
        Uusi koodi lisätään tämän kommentin yläpuolelle ja 
      behind the comment of the FList line. }
+
        FList-rivin kommentin taakse. }
 
   FInt: integer;</source>
 
   FInt: integer;</source>
  
===Method update===
+
===Metodin päivitys===
Normally class completion will add all missing method bodies. (Since 0.9.27) But if exactly one method differ between class and bodies then the method body is updated. For example: You have a method ''DoSomething''.
+
 
 +
Normaalisti luokan täydennys lisää kaikki puuttuvat metodin rungot.
 +
(Versiosta 0.9.27 lähtien) Jos täsmälleen yksi menetelmä eroaa luokan ja rungon välillä, niin metodin runko päivitetään. Esimerkiksi: On metodi DoSomething ''DoSomething''.
 
<source>  public
 
<source>  public
 
     procedure DoSomething;
 
     procedure DoSomething;
Line 553: Line 560:
 
end;</source>
 
end;</source>
  
Now add a parameter:
+
Nyt lisätään parameteri:
  
 
<source>  public
 
<source>  public
Line 559: Line 566:
 
   end;</source>
 
   end;</source>
  
and invoke Code Completion ({{keypress|Ctrl|Shift|C}}). The method body will be updated and the new parameter will be copied:
+
Code Completion kutsuminen ({{keypress|Ctrl|Shift|C}}) päivittää metodin rungon ja uusi parametri kopioidaan:
  
 
<source>procedure TForm.DoSomething(i: integer);
 
<source>procedure TForm.DoSomething(i: integer);

Revision as of 17:45, 24 March 2018

Deutsch (de) English (en) español (es) suomi (fi) français (fr) 日本語 (ja) 한국어 (ko) Nederlands (nl) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN)

Lazarus IDE Tools on Free Pascal- lähdekoodin jäsentämis- ja muokkaustyökalu, jota kutsutaan "codetoolsiksi".

Tämä työkalu tarjoaa ominaisuuksia, kuten Find Declaration, Code Completion, Extraction, Moving Inserting ja Beautifying Pascal lähdekoodia. Nämä toiminnot voivat säästää paljon aikaa ja päällekkäistä työtä. Ne ovat muokattavissa ja jokainen ominaisuus on käytettävissä pikavalintojen kautta (katso editoriasetukset).

Koska ne työskentelevät pelkästään Pascal-lähdekoodeilla ja ymmärtävät FPC-, Delphi- ja Kylix- koodeja, ne eivät tarvitse käännettyjä käännösyksiköitä tai asennettua Borland / Embarcadero-kääntäjää. Delphi- ja FPC-koodia voidaan muokata samanaikaisesti useilla Delphi- ja FPC-versioilla. Tämä tekee Delphi-koodin siirtämisen FPC / Lazarukselle paljon helpompaa.

Yhteenvetoraportti IDEn-pikanäppäimestä

Declaration Jumping Ctrl+klikkaa tai Alt+ (Hyppää tyypin tai muuttujan määrittelyyn)
Siirtyminen esittelyn ja toteuksen välillä Ctrl+ Shift+ (vaihtaa määritelmäosion ja toteutusosion välillä)
Code Templates Ctrl+J
Syncro Edit Ctrl+J (while text is selected)
Code Completion (Class Completion) Ctrl+ Shift+C, Ctrl+ Shift+X for creating class fields instead of local variables
Identifier Completion Ctrl+space
Word Completion Ctrl+W
Parametrivihjeet Ctrl+ Shift+space
Etsi kirjain kerrallaan Ctrl+E
Rename Identifier Ctrl+ Shift+E

Siirtyminen esittelyn ja toteuksen välillä

Jos halutaan siirtyä aliohjelman rungon (begin..end) ja aliohjelman (procedure Name;) esittelyn välillä käytä näppäinyhdistelmää Ctrl+ Shift+.

Esimerkiksi:

interface
 
procedure DoSomething; // Aliohjelman esittely
  
implementation
  
procedure DoSomething; // Aliohjelman määrittely 
begin
end;

Jos kursori on aliohjelman toteutusosiossa ja painetaan Ctrl+ Shift+ niin kursori siirtyy aliohjelman esittelyyn. Painamalla Ctrl+ Shift+ uudelleen niin tullan takaisin määrittelyyn heti 'begin' sanan jälkeiseen kohtaan.

Tämä toimii samanlailla myös luokan (class) metodin esittelyn ja toteutuksen välillä.

Vihje: Siirtyminen tapahtuu siihen aliohjelmaan jossa on samat parametrit. Jos ei löydy täysin samaa niin siirtyminen tapahtuu sopivampaan eli siihen jossa on vähiten eroja (Tälläistä toimintaa ei välttämättä löydy esim. Delphistä).

Esimerkki aliohjelmasta joiden esittelyssä ja toteutuksessa on erilaiset parametrityypit:

interface
 
procedure DoSomething(p: char); // procedure definition
 
implementation
   
procedure DoSomething(p: string); // procedure body
begin
end;

Siirtyminen toteuksen ja niiden esittelyjen välillä 'string' avainsana. Tätä voi käyttää kun haluaa uudelleen nimetä metodin ja/tai muuttaa parametrejä.

Esimerkiksi: uudelleen nimetään 'DoSomething' -> 'MakeIt':ksi:

interface
 
procedure MakeIt; // procedure definition
 
implementation
 
procedure DoSomething; // procedure body
begin
end;

Kun siirrytään 'MakeIt':n esittelystä toteukseen (joka on siis vielä väärän niminen). Lazarus etsii sopivaa toteustusta, jota ei löydy, sen jälkeen muita sopivia. Jos nimeä on muutettu ainoastaan yhdestä aliohjelmasta jolloin on yksi toteutus josta ei löydy määrittelyä niin tällöin siirrytään siihen. Näin voidaan yksinkertaisesti vaihtaa nimeä tai parametrejä.

Include Files

Include files ovat tiedostoja, jotka on lisätty lähdekoodiin {$I filename} tai {$INCLUDE filename} kääntäjän ohjeella. Lazarus ja FPC käyttävät usein include tiedostoja vähentämään redundanssia ja välttävät lukemattomia {$ IFDEF} -rakenteita, joita tarvitaan eri alustojen tukemiseen.

Toisin kuin Delphi, Lazarus IDE: llä on täysi tuki myös include-tiedostoihin. Voit esimerkiksi hypätä .pas-tiedoston aliohjelmasta sisällytetyn tiedoston toteutukseen. Kaikki codetools osiot, kuten koodin täydentäminen, käsittelevät include tiedostoja erityistapauksina.

Esimerkiksi: Kun koodin täydentäminen lisää uuden metodin toteuksen rungon toisen metodin rungon taakse, se pitää ne molemmissa samassa tiedostossa. Tällä tavalla voit laittaa kokoluokan toteutuksia include-tiedostoihin, kuten LCL tekee lähes kaikille kontrolleille.

Mutta aloittelijoille löytyy ansa: Jos avataan include tiedosto ensimmäisen kerran ja yritetään siirtyä esittelyn ja toteuksen välillä tai löytää määrittely niin saadaan virhe. IDE ei vielä tiedä, mihin yksikköön sisällytettävä tiedosto kuuluu. Sillä on ensin avattava käännösyksikkö.

Niin pian kuin IDE analysoi käännösyksikön, se analysoi include kääntäjänohjeet siellä ja IDE muistaa tämän suhteen. Se tallentaa nämä tiedot poistumiseen ja projektin tallentamiseen ~ / .lazarus / includelinks.xml. Kun seuraavan kerran avataan tämän include tiedosto ja siirrytään toteuksen ja niiden esittelyjen välillä, IDE avaa laitteen sisäisesti ja siirtyminen toimii. Voidaan myös viitata IDE: een asettamalla

{%mainunit yourunit.pas}

tiedoston yourinclude.inc alkuun.

Tällä mekanismilla on rajoituksia. Joihinkin tiedostoihin sisältyy kaksi tai useampia include tiedostoja. Esimerkiksi: lcl/include/winapih.inc.

Se miten siirrytään aliohjelman/metodin määrityksistä niiden include tiedostoihin riippuu viimeisestä toiminnosta. Jos ollaan työskennelty lcl / lclintf.pp: llä, IDE siirtyy winapi.inc: hen. Jos ollaan työskennelty lcl / interfacebase.pp: llä niin se siirtyy lcl / include / interfacebase.inc (tai johonkin muuhun include tiedostoon). Jos työskennellään molemmilla, niin se saadaan sekaisin. ;)

Code Templates

Code Templates muuntaa tietyn tunnisteen tekstiksi tai koodin palaseksi.

Code Templates oletuspikanäppäin on Ctrl+J. Kun kirjoittaa sopivan tunnisteen, painaa Ctrl+J niin tunniste korvataan tunnisteella määritellyllä tekstillä. Code Templates voidaan määritellä Työkalut -> Optiot -> CodeTools.

Esim: Kirjoita teksti 'classf', jätä kursori kirjaimen 'f' oikealle puolen ja paina Ctrl+J. Teksti 'classf' korvautuu riveillä

T = class(T)
private
 
public
  constructor Create;
  destructor Destroy; override;
end;

ja kursori on kirjaimen 'T' takana. Luettelo kaikista Code Template vaihtoehdoista saadaan sijoittamalla kohdistin välilyönnin perään (ei tunnisteeseen) ja painamalla Ctrl+J. Luettelo kaikista Code Template vaihtoehdoista ponnahtaa esiin. Käytä kursorinäppäimiä tai kirjoita joitain merkkejä valitaksesi. Painamalla Return luodaan valittu malli ja Esc sulkee ponnahdusikkunan.

Suurin ajan säästäjä on Code Template 'b'+Ctrl+J varatuille sanoille begin..end.

Parametrivihjeet

Parametrivihjeet näyttävät vihjeruutu, jossa on parametriluettelot kutsun parametrilistalle.

Esimerkiksi

  Canvas.FillRect(|);

Aseta kursori sulkujen väliin ja paina Ctrl+ Shift+space. Näyttöön tulee vihjeruutu, joka näyttää FillRectin parametrit.

Parameterhints1.png

Versiosta 0.9.31 asti on ollut jokaisen Parametrivihjeen oikealla puolella painike puuttuvien parametrien lisäämiseksi. Tämä kopioi parametrin nimet valitusta vihjeestä kohdistimen kohtaan.

Parameterhints2.png


Vihje: Käytä Variable Declaration Completion määrittääksesi muuttujia.

Light bulb  Huomaa: Pikanäppäimen nimi on "Show code context".

Etsi kirjain kerrallaan

Etsi kirjain kerrallaan muuttaa lähdekoodieditorin tilarivin. Kirjoita joitain kirjaimia ja editori etsii ja korostaa välittömästi kaikki niiden esiintymät tekstissä. Pikanäppäin on Ctrl+e.

  • Esimerkiksi painamalla e. Se etsii ja korostaa kaikki 'e':n esiintymät.
  • Sitten painetaan t. Se etsii ja korostaa kaikki esiintymät "et" ja niin edelleen.
  • Seuraavaan esiintymään voidaan siirtyä painamalla F3 (tai Ctrl+e kun ollaan haussa) ja edelliseen painamalla Shift+F3.
  • Backspace eli <- poistaa edellisen merkin
  • Return lopettaa haun lisäämättä uutta riviä editoriin.
  • Viimeistä hakua voidaan jatkaa painamalla Ctrl+e -näppäintä toisen kerran välittömästi sen jälkeen, kun olet käynnistänyt etsinnän painamalla Ctrl+e. Toisin sanoen hakutermi on vielä tyhjä.
  • Liittäminen Ctrl+V liittää tekstin leikepöydältä nykyiseen hakutekstiin (Ollut Lazarus versiosta 0.9.27 lähtien).

Vihje: Nopea haku tunnistimella käyttäen etsi kirjain kerrallaan toimintoa

  • Aseta tekstikohdistin tunnisteeseen (älä valitse mitään)
  • Paina Ctrl+C. Lähdekoodieditori valitsee tunnuksen ja kopioi sen leikepöydälle
  • Paina Ctrl+E aloittaaksesi etsi kirjain kerrallaan toiminnon.
  • Paina Ctrl+V joka liittää tekstin leikepöydältä nykyiseen hakutekstiin.
  • Käyttämällä F3 ja Shift+F3 siirtyäksesi nopeasti seuraavaan / edelliseen.
  • Lopeta haku painamalla mitä tahansa näppäintä (esimerkiksi kohdistinta vasemmalle tai oikealle).


Syncro Edit

Syncro Edit:llä voidaan muokata samanaikaisesti kaikkia sanojen esiintymiä (synkronoitu). Yksinkertaisesti voidaan muokata sanaa yhdessä paikassa ja kun sitä muutetaan niin kaikki muut sanan tapahtumat päivittyvät.

Syncro Edit toimii kaikkien valitun alueen sanoilla:

  • Valitse tekstilohko
  • Paina Ctrl+J tai klikkaa kuvaketta reunuksessa. (Tämä toimii vain, jos valittu sana esiintyy useamman kerran).
  • Valitse muokattava sana Tab näppäimellä (jos valittu sana esiintyy useamman kerran)
  • Muokkaa sanaa
  • Lopeta painamalla Esc näppäimellä

Katso animoitu esimerkki tästä

Light bulb  Huomaa: Ctrl+J käytetään myös template edit:ssä. Se vaihtaa merkitystään, jos valitset jonkin tekstin.

Etsi sanan seuraava esiintymiskohta/ Etsi sanan edellinen esiintymiskohta

Nämä kaksi funktiota löytyvät lähdekoodieditorin ponnahdusvalikosta

  • Lähdekoodieditori / ponnahdusvalikko / Etsi / Etsi sanan seuraava esiintymiskohta
  • Lähdekoodieditori / ponnahdusvalikko / Etsi / Etsi sanan edellinen esiintymiskohta

Näihin voidaan määrittää pikanäppäimet editorin asetuksissa.

Code Completion

Code Completion löytyy IDE-valikosta Edit -> Complete Code ja sen pikanäppäin on Ctrl+ Shift+C.

Delphi-käyttäjille: Delphi nimeää "code completion" funktioksi, joka näyttää tunnistetietojen luettelon kursorin kohdalla lähdekoodissa ( Ctrl+Space ). Lazaruksessa se on "Identifier completion".

Code Completion yhdistää useita tehokkaita toimintoja. esimerkkejä:

Mikä toiminto on käytössä, riippuu kohdistimen sijainnista editorissa ja sitä selitetään alla.

Code Completion löytyy IDE-valikosta Edit -> Complete Code ja sen pikanäppäin on Ctrl+ Shift+C.

Class Completion

Tehokkain koodin täydentäjä ominaisuus on "Class Completion". Kun kirjoitetaan luokkaa (class) johon lisätään metodeja ja ominaisuuksia niin Code Completion lisää metodien toteutuksen rungot, ominaisuuksien käyttörutiinit / muuttujat ja yksityiset muuttujat.

Esimerkiksi: Luo luokka eli class (Katso Code Templates jonka avulla voidaan säästää kirjoittamistyötä):

TExample = class(TObject)
public
  constructor Create;
  destructor Destroy; override;
end;

Aseta kohdistin johonkin kohtaan luokkaan ja paina Ctrl+ Shift+C. Tämä luo metodien puuttuvat rungot ja siirtää kohdistimen ensimmäiselle luodulle metodin rungolle, joten voidaan aloittaa luokan koodin kirjoittaminen:

{ TExample }
 
constructor TExample.Create;
begin
  |
end;
 
destructor TExample.Destroy;
begin
  inherited Destroy;
end;
Light bulb  Huomaa: Merkki '|' on kohdistin eikä sitä lisätä.

Vihje: On mahdollista siirtyä metodin ja sen rungon välillä Ctrl+ Shift+.

Nähdään, että IDE lisäsi myös 'inherited Destroy' kutsun. Tämä tehdään, jos luokan määritelmässä on 'override' avainsana.

Nyt lisätään metodi DoSomething:

TExample = class(TObject)
public
  constructor Create;
  procedure DoSomething(i: integer);
  destructor Destroy; override;
end;

Sitten paina Ctrl+ Shift+C ja IDE lisää

procedure TExample.DoSomething(i: integer);
begin
  |
end;

Nähdään että uusi metodin runko on sijoitettu Create ja Destroy -toimintojen väliin aivan kuten luokkamäärittelyssä. Tällä tavoin rungot pitävät saman loogisen järjestyksen kuin on määritetty. Lisäyskäytäntö voidaan määrittää Työkalut> Asetukset -> Codetools -> Code Creation.

Täydennä ominaisuuksilla
Lisää ominaisuus AnInteger:

TExample = class(TObject)
public
  constructor Create;
  procedure DoSomething(i: integer);
  destructor Destroy; override;
  property AnInteger: Integer;
end;

Paina Ctrl+ Shift+C jolloin saadaan:

procedure TExample.SetAnInteger(const AValue: integer);
begin
  |if FAnInteger=AValue then exit;
  FAnInteger:=AValue;
end;

code completion on lisännyt kirjoitusoikeuden muokkaajan ja lisännyt yleistä koodia. Siirry luokalle painamalla Ctrl+ Shift+ nähdäksesi uuden luokan:


TExample = class(TObject)
private
  FAnInteger: integer;
  procedure SetAnInteger(const AValue: integer);
public
  constructor Create;
  procedure DoSomething(i: integer);
  destructor Destroy; override;
  property AnInteger: integer read FAnInteger write SetAnInteger;
end;

Ominaisuutta laajennettiin Read (luku) ja Write (kirjoitus)-ominaisuuden avulla. Luokka sai uuden 'private' osion johon tuli muuttuja "FAnInteger" ja metodi "SetAnInteger". Yleisen Delphi-tyylisen käytännön mukaan yksityisiin muuttujiin lisätään 'F' kirjain ja kirjoitusmetodiin 'Set'. Tätä ominaisuutta voidaan muuttaa Työkalut -> Valinnat> Codetools -> Code Creation.


Luodaan property:n vain luku (read) :

property PropName: PropType read;

Laajennetaan

property PropName: PropType read FPropName;

Luodaan property:n vain kirjoitus (write) :

property PropName: PropType write;

Laajennetaan

property PropName: PropType write SetPropName;

Luodaan property:n vain luku (read) ja lukumetodi:

property PropName: PropType read GetPropName;

Säilytetään ja GetPropName-funktio lisätään:

function GetpropName: PropType;

Luodaan property jossa on stored määrite:

property PropName: PropType stored;

Laajennetaan

property PropName: PropType read FPropName write SetPropName stored PropNameIsStored;

Koska stored käytetään tietovirtojen lukemiseen ja kirjoittamiseen, ne myös lisätään automaattisesti.

Vihje: Identifier completion tunnistaa myös puutteelliset ominaisuudet ja ehdottaa oletusnimiä. Esimerkiksi:

property PropName: PropType read |;

Aseta kohdistin yksi välilyönti read-avainsanan taakse ja paina Ctrl+Space. Se antaa muuttujan "FPropName" ja aliohjelman "SetPropName".

Forward Procedure Completion

"Forward Procedure Completion" on osa Code Completion ja lisää aliohjelman rungon. Sitä käytetään, kun kohdistin on aliohjelman esittelyssä. It is invoked, when the cursor is on a forward defined procedure.

Esimerkiksi: Lisätään uusi aliohjelma interface osioon:

procedure DoSomething;

Aseta kohdistin sille ja paina Ctrl+ Shift+C. Se luo toteutusosassa (implementation):

procedure DoSomething;
begin
  |
end;

Vihje: Voidaan siirtyä aliohjelman esittelyn ja sen rungon välillä painamallaCtrl+ Shift+.

Uusi aliohjelman runko lisätään luokkametodien eteen. Jos rajapinnassa on jo joitain aliohjelmia, IDE yrittää säilyttää järjestyksen. Esimerkiksi:

procedure Proc1;
procedure Proc2; // new proc
procedure Proc3;

Jos aliohjelmien Proc1: n ja Proc3: n rungot ovat jo olemassa, niin Proc2 runko lisätään Proc1: n ja Proc3: n rungon väliin. Tämä toiminto voidaan asettaa Työkalut -> Valinnat -> Codetools -> Code Creation.

Useita aliohjelmia:

procedure Proc1_Old; // runko on jo olemassa
procedure Proc2_New; // runkoa ei ole vielä
procedure Proc3_New; //  "
procedure Proc4_New; //  "
procedure Proc5_Old; // runko on jo olemassa

Code Completion lisää kaikki kolme (3) aliohjelman runkoa (Proc2_New, Proc3_New, Proc4_New).

Miksi kutsua "Forward Procedure Completion"?

Koska se ei toimi vain interface osiossa määriteltyjen aliohjelmien, vaan myös "forward" -määritteen kanssa. Ja koska codetools käsittelee interface osiossa olevia aliohjelmia niin, että niillä on implisiittinen 'forward' -määrite.

Event Assignment Completion

"Event Assignment Completion" on osa Code Completion:a. Se täydentää yhden tapahtuman := | lauseen. Sitä kutsutaan, kun kohdistin on järjestetty tapahtumalle.

completes a single Event:=| statement. It is invoked, when the cursor is behind an assignment to an event.

Esimerkiksi: Kirjoita lomakkeen FormCreate-tapahtumaan rivi 'OnPaint:=':

procedure TForm1.Form1Create(Sender: TObject);
begin
  OnPaint:=|
end;

Kursorin paikka on merkitty '|' -kirjaimella eikä kyseistä kirjainta kirjoiteta. Code completion kutsutaan painamalla Ctrl+ Shift+C. Lause täydennetään

OnPaint:=@Form1Paint;

ja uusi metodi Form1Paint lisätään TForm1 luokkaan. Tällöin luokka valmistuu ja saadaan myös:

procedure TForm1.Form1Paint(Sender: TObject);
begin
  |
end;

Tämä toimii samalla tavoin kuin lisätään menetelmiä komponenttimuokkaimella.


Light bulb  Huomaa: Kursori on sijoitettava heti ':=' saa arvokseen operatorin jälkeen. Jos kursori sijoitetaan osoittamaan esim. OnPaint tunnisteeseen niin koodin suorittaminen viittaa "Local Variable Completion", joka epäonnistuu, koska OnPaint on jo määritetty.

Vinkit:

  • Uuden metodin oletusarvoinen näkyvyys voidaan valita Työkalut / Asetukset / Codetools / Luokan täydennys / Default section of methods (versiosta 1.8 lähtien)
  • Uuden metodin nimen voi määrittää itse. Esimerkiksi:
  OnPaint:=@ThePaintMethod;


Versiosta 0.9.31 Lazarus täydentää aliohjelman parametreja. Esimerkiksi

procedure TForm1.FormCreate(Sender: TObject);
var
  List: TList;
begin
  List:=TList.Create;
  List.Sort(@MySortFunction|);
end;

Sijoita kursori 'MySortFunction' kohtaan ja paina Ctrl+ Shift+C niin saadaan uusi aliohjelma:

function MySortFunction(Item1, Item2: Pointer): Integer;
begin
  |
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  List: TList;
begin
  List:=TList.Create;
  List.Sort(@MySortFunction);
end;


Variable Declaration Completion

"Variable Declaration Completion" on osa Code Completion:a. Se lisää paikallisen muuttujan määritelmän tunnisteelle := Term; lause. Sitä kutsutaan, kun kohdistin on osoittaa parametria tai tunnistetta.

Esimerkiksi:

procedure TForm1.Form1Create(Sender: TObject);
begin
  i:=3;
end;

Kursorin paikka on tunnisteessa 'i' tai sen jälkeen. Painamalla Ctrl+ Shift+C saadaan:

procedure TForm1.Form1Create(Sender: TObject);
var
  i: Integer;
begin
  i:=3;
end;

Toiminto ensin tarkastaa onko tunnistetta 'i' jo määritelty. Jos sitä ei ole niin lisää määrittelyn 'var i: integer;'. Tunnisteen tyyppi arvatellaan ": =" operaattorista. Kokonaisluvun, kuten 3 oletustyyppinä on Integer.

Toinen esimerkki:

type
  TWhere = (Behind, Middle, InFront);
 
  procedure TForm1.Form1Create(Sender: TObject);
  var
    a: array[TWhere] of char;
  begin
    for Where:=Low(a) to High(a) do writeln(a[Where]);
  end;

Kursorin paikka on 'Where'-sanan kohdalla ja painetaan Ctrl+ Shift+C niin saadaan:

  procedure TForm1.Form1Create(Sender: TObject);
  var
    a: array[TWhere] of char;
    Where: TWhere;
  begin
    for Where:=Low(a) to High(a) do writeln(a[Where]);
  end;

Lazarus on versiosta 0.9.11 lähtien myös täydentänyt parametreja. Esimerkiksi

  procedure TForm1.FormPaint(Sender: TObject);
  begin
    with Canvas do begin
      Line(x1,y1,x2,y2);
    end;
  end;

Sijoita kursori 'x1' ja paina Ctrl+ Shift+C niin saadaan:

  procedure TForm1.FormPaint(Sender: TObject);
  var
    x1: integer;
  begin
    with Canvas do begin
      Line(x1,y1,x2,y2);
    end;
  end;

Lazarus on versiosta 0.9.31 täydentänyt osoittimen parametrit. Esimerkiksi

  procedure TForm1.FormCreate(Sender: TObject);
  begin
    CreateIconIndirect(@IconInfo);
  end;

Sijoita kursori 'IconInfo':n ja paina Ctrl+ Shift+C niin saadaan:

  procedure TForm1.FormCreate(Sender: TObject);
  var
    IconInfo: TIconInfo;
  begin
    CreateIconIndirect(@IconInfo);
  end;

Kaikissa edellä olevissa esimerkeissä voit käyttää Ctrl+ Shift+X-näppäintä näyttääksesi koodin luomisen valintaikkunan, jossa voit asettaa lisää vaihtoehtoja.

Procedure Call Completion

Code completion voi luoda uuden aliohjelman sen kutsusta.

Oletataan että kirjoitettiin vain lause "DoSomething(Width);"

procedure SomeProcedure;
var
  Width: integer;
begin
  Width:=3;
  DoSomething(Width);
end;

Sijoita kursori tekstiin "DoSomething" ja paina Ctrl+ Shift+C niin saadaan:

procedure DoSomething(aWidth: LongInt);
begin

end;

procedure SomeProcedure;
var
  Width: integer;
begin
  Width:=3;
  DoSomething(Width);
end;

Se ei vielä luo funktioita tai metodeja.

Reversed Class Completion

"Reversed Class Completion" on osa Code Completion toimintaa. Se lisää yksityisen metodin ilmoituksen nykyiselle metodiryhmälle. Sitä kutsutaan, kun kursori on metodin rungossa, jota ei ole vielä määritelty luokassa. Tämä ominaisuus on saatavana Lazarus 0.9.21 versiosta alkaen.

Esimerkiksi:

  procedure TForm1.DoSomething(Sender: TObject);
  begin
  end;

DoSomething-metodia ei ole vielä määritelty TForm1: ssä. Paina Ctrl+ Shift+C ja IDE lisää aliohjelman "procedure DoSomething (Sender: TObject);" TForm1: n yksityisiin metodeihin.

Delphi käyttäjille: Class completion toimii Lazaruksen mukaan aina yhdellä tavalla: Luokan käyttöliittymästä toteutukseen tai taaksepäin / päinvastoin luokan toteutuksesta käyttöliittymään. Delphi kutsuu aina molempiin suuntiin. Delphi-tapa on haitta, että jos on typo se luo helposti uuden tynkä metodin ilman huomaamatta.

Kommentit ja Code Completion

Code completion yrittää pitää kommentteja, johon ne kuuluvat. Esimerkiksi:

  FList: TList; // list of TComponent
  FInt: integer;

Kun lisätään uusi muuttuja FListin ja FInt: n välillä, kommentti pidetään FList-rivillä. Sama pätee myös

  FList: TList; { list of TComponent
      Tämä on usean rivin kommentti, alkaen 
      FList-riviltä, joten codetools olettaa sen kuuluvan  
      FLIst-riviin ja ei riko tätä  
      suhdetta.  Koodi lisätään kommentin taakse.  }
  FInt: integer;

Jos kommentti alkaa seuraavalla rivillä, sitä käsitellään kuin se kuuluu alla olevaan koodiin. Esimerkiksi:

  FList: TList; // list of TComponent
      { Tämä kommentti kuuluu alla olevaan lauseeseen.  
        Uusi koodi lisätään tämän kommentin yläpuolelle ja  
        FList-rivin kommentin taakse.  }
  FInt: integer;

Metodin päivitys

Normaalisti luokan täydennys lisää kaikki puuttuvat metodin rungot.

(Versiosta 0.9.27 lähtien) Jos täsmälleen yksi menetelmä eroaa luokan ja rungon välillä, niin metodin runko päivitetään. Esimerkiksi: On metodi DoSomething DoSomething.
  public
    procedure DoSomething;
  end;

procedure TForm.DoSomething;
begin
end;

Nyt lisätään parameteri:

  public
    procedure DoSomething(i: integer);
  end;

Code Completion kutsuminen (Ctrl+ Shift+C) päivittää metodin rungon ja uusi parametri kopioidaan:

procedure TForm.DoSomething(i: integer);
begin
end;

Refactoring

Invert Assignments

Abstract
: "Invert Assignments" takes some selected pascal statements and inverts all assignments from this code. This tool is usefull for transforming a "save" code to a "load" one and inverse operation.

Example:

procedure DoSomething;
begin
  AValueStudio:= BValueStudio;
  AValueAppartment :=BValueAppartment;
  AValueHouse:=BValueHouse;
end;

Select the lines with assignments (between begin and end) and do Invert Assignments. All assignments will be inverted and identation will be add automatically. For example:

Result:

procedure DoSomething;
begin
  BValueStudio     := AValueStudio;
  BValueAppartment := AValueAppartment;
  BValueHouse      := AValueHouse;
end;

Enclose Selection

Select some text and invoke it. A dialog will popup where you can select if the selection should be enclosed into try..finally or many other common blocks.

Rename Identifier

Place the cursor on an identifier and invoke it. A dialog will appear, where you can setup the search scope and the new name.

  • It will rename all occurences and only those that actually use this declaration. That means it does not rename declarations with the same name.
  • And it will first check for name conflicts.
  • Limits: It only works on pascal sources, does not yet rename files nor adapt lfm/lrs files nor lazdoc files.

Find Identifier References

Place the cursor on an identifier and invoke it. A dialog will appear, where you can setup the search scope. The IDE will then search for all occurences and only those that actually use this declaration. That means it does not show other declarations with the same name.

Show abstract methods

This feature lists and auto completes virtual, abstracts methods that need to be implemented. Place the cursor on a class declaration and invoke it. If there are missing abstract methods a dialog will appear listing them. Select the methods to implement and the IDE creates the method stubs. Since Lazarus 1.3 it adds missing class interface methods too.

Extract Procedure

See Extract Procedure.

Find Declaration

Position the cursor on an identifier and do 'Find Declaration'. Then it will search the declaration of this identifier, open the file and jump to it. If the cursor is already at a declaration it will jump to the previous declaration with the same name. This allows to find redefinitions and overrides.

Every find declaration sets a Jump Point. That means you jump with find declaration to the declaration and easily jump back with Search -> Jump back.

There are some differences to Delphi: the codetools work on sources following the normal pascal rules, instead of using the compiler output. The compiler returns the final type. The codetools see the sources and all steps in between. For example:

The Visible property is first defined in TControl (controls.pp), then redefined in TCustomForm and finally redefined in TForm. Invoking find declaration on Visible will you first bring to Visible in TForm. Then you can invoke Find Declaration again to jump to Visible in TCustomForm and again to jump to Visible in TControl.

Same is true for types like TColor. For the compiler it is simply a 'longint'. But in the sources it is defined as

TGraphicsColor = -$7FFFFFFF-1..$7FFFFFFF;
TColor = TGraphicsColor;

And the same for forward defined classes: for instance in TControl, there is a private variable

FHostDockSite: TWinControl;

Find declaration on TWinControl jumps to the forward definition

TWinControl = class;

And invoking it again jumps to the real implementation

TWinControl = class(TControl)

This way you can track down every identifier and find every overload.

Hints

  • ump back with Ctrl+H.
  • view/navigate all visited locations via Menu: View -> "jump history"
  • With a 5 button Mouse the 2 extra buttons to go forward/backward between the visited points
using advanced mouse options the buttons can be remapped.

Identifier Completion

"Identifier Completion" is invoked by Ctrl+space. It shows all identifiers in scope. For example:

procedure TForm1.FormCreate(Sender: TObject);
begin
  |
end;

Place the cursor between begin and end and press Ctrl+space. The IDE/CodeTools will now parse all reachable code and present you a list of all found identifiers. The CodeTools cache the results, so invoking it a second time will be much faster.

Light bulb  Huomaa: for Delphians: Delphi calls it Code completion.

Some identifiers like 'Write', 'ReadLn', 'Low', 'SetLength', 'Self', 'Result', 'Copy' are built into the compiler and are not defined anywhere in source. The identifier completion has a lot of these things built in as well. If you find one missing, just create a feature request in the bug tracker.

Identifier completion does not complete all keywords. So you can not use it to complete 'repe' to 'repeat'. For these things use Ctrl+W Word Completion or Ctrl+J Code Templates. Since 0.9.27 identifier completion completes some keywords.

Identifier completion shows even those identifiers, that are not compatible.

Matching only the first part of a word

You can invoke identifier completion only on the first few characters in a word. Position the cursor within a word. Only characters to the left of the cursor will be used to look up identifiers. For example:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Ca|ption
end;

The box will show you only identifiers beginning with 'Ca' ( | indicates the cursor position).

Keys

  • Letter or number: add the character to the source editor and the current prefix. This will update the list.
  • Backspace: remove the last character from source editor and prefix. Updates the list.
  • Return: replace the whole word at cursor with the selected identifier and close the popup window.
  • Shift+Return: as Return, but replaces only the prefix (left part) of the word at the cursor.
  • Up/Down: move selection
  • Escape: close popup without change
  • Tab: completes the prefix to next choice. For example: The current prefix is 'But' and the identifier completion only shows 'Button1' and 'Button1Click'. Then pressing Tab will complete the prefix to 'Button1'.
  • Else: as Return and add the character to the source editor

Methods

When cursor is in a class definition and you identifier complete a method defined in an ancestor class the parameters and the override keyword will be added automatically. For example:

TMainForm = class(TForm)
protected
  mous|
end;

Completing MouseDown gives:

TMainForm = class(TForm)
protected
  procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,
         Y: Integer); override;
end;

Properties

property MyInt: integer read |;

Identifier completion will show FMyInt and GetMyInt.

property MyInt: integer write |;

Identifier completion will show FMyInt and SetMyInt.

Uses section / Unit names

In uses sections the identifier completion will show the filenames of all units in the search path. These will show all lowercase (e.g. avl_tree), because most units have lowercase filenames. On completion it will insert the case of the unit (e.g. AVL_Tree).

Statements

procedure TMainForm.Button1Click(Sender: TObject);
begin
  ModalRe|;
end;

becomes:

procedure TMainForm.Button1Click(Sender: TObject);
begin
  ModalResult:=|;
end;

Icons in completion window

In Lazarus 1.9+, option exists to show icons instead of "types", for lines in the completion window. Picture shows these icons:

ide completion icons.png

Word Completion

Word Completion is invoked by Ctrl+W. It shows all words of all currently open editors and can therefore be used in non pascal sources, in comments and for keywords.

Otherwise it works the same as identifier completion.

Goto Include Directive

"Goto Include Directive" in the search menu of the IDE jumps to {$I filename} statement where the current include file is used.

Publish Project

Creates a copy of the whole project. If you want to send someone just the sources and compiler settings of your code, this function is your friend.

A normal project directory contains a lot of information. Most of it is not needed to be published: the .lpi file can contain session information (like caret position and bookmarks of closed units) and the project directory contains a lot of .ppu, .o files and the executable. To create a lpi file with only the base information and only the sources, along with all sub directories use "Publish Project".

Light bulb  Huomaa: Since version 0.9.13 there is a new Project Option that allows you to store session information in a separate file from the normal .lpi file. This new file ends with the .lps extension and only contains session information, which will leave your .lpi file much cleaner.

In the dialog you can setup a filter to include and exclude certain files; with the command after you can compress the output into one archive.

Hints from comments

At several places the IDE shows hints for an identifier. For example when moving the mouse over an identifier in the source editor and waiting a few seconds. When the IDE shows a hint for an identifier it searches the declaration and all its ancestors and looks for comments and fpdoc files. There are many coding styles and many commenting styles. In order to support many of the common comment styles the IDE uses the following heuristics:

Comments shown in the hint

Comments in front of a declaration, without empty line and not starting with the < sign:

var
  {Comment}
  Identifier: integer;

Comments with the < sign belong to the prior identifier.

Comments behind an identifier on the same line:

var 
  identifier, // Comment
  other,

Comments behind the definition on the same line:

var
  identifier: 
    char; // Comment

An example for < sign:

const
  a = 1;
  //< comment for a
  b = 2;
  // comment for c
  c = 3;

All three comment types are supported:

  {Comment}(*Comment*)//Comment
  c = 1;

Comments not shown in the hint

Comments starting with $ or % are ignored. For example //% Hiddden, //$ Hidden, (*$ Hidden*).

Comments in front separated with an empty line are treated as not specific to the following identifier. For example the following class header comment is not shown in the hint:

type
  { TMyClass }
  
  TMyClass = class

The class header comments are created on class completion. You can turn this off in the Options / Codetools / Class completion / Header comment for class. If you want to show the header comment in the hint, just remove the empty line.

The following comment will be shown for GL_TRUE, but not for GL_FALSE:

  // Boolean
  GL_TRUE                           = 1;
  GL_FALSE                          = 0;

Quick Fixes

Quick Fixes are menu items for specific compiler messages. They help you to quickly fix the problem. Select a message in the Messages window and right click, or right click in the source editor on the icon to the left.

  • Unit not found: remove from uses section
  • Unit not found: find unit in loaded packages and allow to auto add package dependency
  • Constructing a class "$1" with abstract method "$2": show dialog to override all abstract methods
  • Local variable "$1" not used: remove definition
  • Circular unit reference between $1 and $2: show Unit Dependencies dialog with full path between the two units
  • Identifier not found: search via Code Browser
  • Identifier not found: search via Cody Dictionary (needs package Cody)
  • Identifier not found: add local variable
  • Recompiling $1, checksum changed for $2: show a dialog with search paths and other information
  • IDE warning: other sources path of package %s contains directory...: open package
  • any hint, note, warning: add IDE directive {%H-}
  • any hint, note, warning: add compiler directive {$warn id off} (since 1.7)
  • any hint, note, warning: add compiler option -vm<messageid>
  • Local variable "i" does not seem to be initialized: insert assignment (since 1.5)

Outline

This option is located in the IDE Options dialog, Editor - Display - Markup and Matches - Outline (global).

It makes highlighting of Pascal keywords together with their begin-end brackets. This allows to see nesting of big blocks. For example, for such procedure body:

  with ADockObject do
  begin
    if DropAlign = alNone then
    begin
      if DropOnControl <> nil then
        DropAlign := DropOnControl.GetDockEdge(DropOnControl.ScreenToClient(DragPos))
      else
        DropAlign := Control.GetDockEdge(DragTargetPos);
    end;
    PositionDockRect(Control, DropOnControl, DropAlign, FDockRect);
  end;

it highlights:

  • outer with-do-begin-end in orange
  • next if-then-begin-end in green
  • inner if-then-else in cyan

ide outline.png