Difference between revisions of "Lazarus IDE Tools/ko"

From Lazarus wiki
Jump to navigationJump to search
Line 149: Line 149:
 
   destructor Destroy; override;
 
   destructor Destroy; override;
 
  end;
 
  end;
Position the cursor somewhere in the class and press Ctrl+Shift+C. This will create the method missing bodies and move the cursor to the first created method body, so you can just start writing the class code:  
+
 
 +
커서를 클래스내의 아무 위치에나 놓고 Ctrl+Shift+C를 누른면 본체가 없는 메쏘드를 만들고 커서를 첫번째 메쏘드 바디에 위치시키므로 그 자리에서 클래스 코드를 작성하면 된다:  
  
 
  { TExample }
 
  { TExample }
Line 162: Line 163:
 
   inherited Destroy;
 
   inherited Destroy;
 
  end;
 
  end;
Note: The '|' is the cursor and is not added.  
+
노트: '|'는 커서이고 더해지지 않는다.
  
Hint: You can jump between a method and its body with Ctrl+Shift+Up.  
+
힌트: 메쏘드와 몸체사이를 Ctrl+Shift+Up을 사용하여 이동할 수 있다.
  
You can see, that the IDE added the 'inherited Destroy' call too. This is done, if there is an 'override' keyword in the class definition.  
+
IDE가 'inherited Destroy' 콜 함수를 더한 것을 역시 볼 수 있을 것이다. 클래스 정의에 'override' 키워드가 있다면 말이다.
  
Now add a method DoSomething:  
+
이제 DoSomething 메쏘드를 추가해보자:
  
 
  TExample = class(TObject)
 
  TExample = class(TObject)
Line 176: Line 177:
 
   destructor Destroy; override;
 
   destructor Destroy; override;
 
  end;
 
  end;
Then press Ctrl+Shift+C and the IDE will add
+
그리고 Ctrl+Shift+C를 누르면 IDE가 추가해 줄 것이다.
  
 
  procedure TExample.DoSomething(i: integer);
 
  procedure TExample.DoSomething(i: integer);
Line 182: Line 183:
 
   |
 
   |
 
  end;
 
  end;
You can see, that the new method body is inserted between Create and Destroy, exactly as in the class definition. This way the bodies keep the same logical ordering as you define. You can define the insertion policy in Environment > Codetools Options -> Code Creation.  
+
새로운 메쏘드 몸체가 클래스 정의에서 그랬던 것처럼 정확히 Create와 Destroy 사이에 삽입되어 있는 것을 알수 있을 것이다. 이러한 방식으로 정의된 순서와 같이 동일한 눈리적인 순서를 유지하도록 해준다. Environment > Codetools Options -> Code Creation 에서 삽입 규칙들을 정의할 수 있다.
  
 
'''Complete Properties'''<br>
 
'''Complete Properties'''<br>
Add a property AnInteger:
+
AnInteger 프로퍼티를 추가한다:
 
  TExample = class(TObject)
 
  TExample = class(TObject)
 
  public
 
  public
Line 193: Line 194:
 
   property AnInteger: Integer;
 
   property AnInteger: Integer;
 
  end;
 
  end;
Press Ctrl+Shift+C and you will get:
+
Ctrl+Shift+C를 누르면 다음이 나타난다:
 
  procedure TExample.SetAnInteger(const AValue: integer);
 
  procedure TExample.SetAnInteger(const AValue: integer);
 
  begin
 
  begin
Line 199: Line 200:
 
   FAnInteger:=AValue;
 
   FAnInteger:=AValue;
 
  end;
 
  end;
The code completion has added a Write access modifier and added some common code.
+
코드완성은 Write 접근 modifier를 추가하고 몇몇 공통 코드를 추가한다.
Jump to the class with Ctrl+Shift+Up to see the new class:
+
새로운 클래스를 보기위해서는 Ctrl+Shift+Up를 이용하여 클래스로 점프할 수 있을 것이다:
 
  TExample = class(TObject)
 
  TExample = class(TObject)
 
  private
 
  private
Line 211: Line 212:
 
   property AnInteger: integer read FAnInteger write SetAnInteger;
 
   property AnInteger: integer read FAnInteger write SetAnInteger;
 
  end;
 
  end;
The property was extended by a Read and Write access modifier. The class got the new section 'private' with a Variable 'FAnInteger' and the method 'SetAnInteger'.
+
프로퍼티는 Read와 Write 접근 modifier에 의해 확장될 수 있다. 클래스는 'FAnInteger' 에 private성질을 가진 새로운 섹션과 'SetAnInteger' 메쏘드를 추가한다.
 
It is a common Delphi style rule to prepend private variables with an 'F' and the write method with a 'Set'. If you don't like that, you can change this in Environment > Codetools Options -> Code Creation.
 
It is a common Delphi style rule to prepend private variables with an 'F' and the write method with a 'Set'. If you don't like that, you can change this in Environment > Codetools Options -> Code Creation.
  

Revision as of 06:20, 12 February 2009

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)

개관

이 IDE는 파스칼 라이브러리를 이용하여 소스를 파싱하고 편집하는 도구, 즉 "코드툴"입니다. 이 툴은 선언을 검색하고, 코드완성, 추출, 파스칼 코드를 이동, 삽입하며 보기좋게 할수 있는 특징을 제공합니다. 이 기능들은 많은 시간을 절약하게 하고 작업능률을 배가 시킵니다. 이것들은 커스터마이즈 할 수 있으며 각 특징들은 단축키를 통해 사용할 수 있습니다(에디터 옵션을 보세요).

이것들은 소스코드상에서 독립적으로 동작하고 fpc, 델파이 및 카일리스를 인식하기 때문에 볼랜드 컴파일러로 컴파일된 유닛이나 설치를 필요로 하지 않는다. 또한 델파이 및 FPC 코드를 동시에 편집할 수 있다. 여러개의 델파이와 FPC 버젼과도 작업할 수 있어 델파이 코드를 포팅하기 훨씬더 쉽게 해준다.

IDE 단축키 요약표

선언부 이동 Ctrl+Click 또는 Alt+Up (변수나 형 선언부로 이동)
메쏘드 이동 Ctrl+Shift+Up (정의와 함수 본체 사이를 번갈아 이동)
코드 템플리트 Ctrl+J
코드 완성 (클래스 완성) Ctrl+Shift+C
식별자 완성 Ctrl+Space
단어 완성 Ctrl+W
파라메터 힌트 Ctrl+Shift+Space

메쏘드 이동

함수 본체(begin..end_)와 함수 정의부(procedure Name;) 사이를 이동하기 위해서는 Ctrl+Shift+Up을 사용하세요.

예제:

interface

procedure DoSomething; // 함수 정의
 
implementation
 
procedure DoSomething; // 함수 몸체 
begin
end;

만약 커서가 함수 몸체위에 있을 때 Ctrl+Shift+Up을 누르면 커서는 선언부로 이동할 것이다.Ctrl+Shift+Up을 다시 누르면 본체의 'begin'다음으로 이동할 것이다.

이것은 메쏘드(클래스내에 있는 프로시저)사이에서도 동일하게 동작한다.

힌트: '메소드 점프'는 같은 이름의 같은 파라메터 리스트를 가진 함수로 이동을 한다. 만약 정확한 함수가 없다면 가장 근접한 프로시저와 첫번째 차이가 나는 위치로 커서가 이동할 것이다.(델파이 사용자:델파이에는 이런 기능이 없다).

예를 들어 서로 다른 파라메터 타입을 가진 프로시저일 때:

interface

procedure DoSomething(p: char); // 프로시저 정의

implementation
  
procedure DoSomething(p: string); // 프로시저 본체
begin
end;

정의부에서 본체로 점프하여 'string' 키워드 커서가 위치할 것이다.이것은 메쏘드 이름을 변경하거나 파라메터를 변경 혹은 이름를 바꿀 떄 사용할 수 있다.

예:
'DoSomething' 을 'MakeIt'으로 이름을 변경할 때:

interface

procedure MakeIt; // 함수 정의

implementation

procedure DoSomething; // 함수 본체
begin
end;

MakeIt에서 본체로 점프할 것이다. IDE는 적절한 본체를 검색하지만 찾를 못할 것이고 비슷한 후보자를 찾을 것이다. 한개의 프로시저만 이름을 바꾸었다면 정의(DoSomething)가 없는 몸체가 될 것이어서 커서는 DoSomething으로 점프하여 'DoSomething'의 우측에 위치할 것이다. 그러면 간단히 이름을 바꾸기만 하면 될 것이다. 이것은 파라메터에서동 동일하게 동작한다.

인클루드 파일

인클루드 파일은 소스에 {$I 파일명} 또는 {$INCLUDE 파일명} 컴파일러 지시자와 함께 삽입되는 파일이다. 라자루스와 FPC는 중복을 피하고, 이기종 플랫폼을 지원하기위해 사용되는 읽기 어려운 {IFDEF}구조를 피하고자 인클루드파일을 많이 사용한다.

델파이와는 반대로 라자루스 IDE는 인크르루드 파일을 완전히 지원한다. 예를 들어 .pas 파일상의 메쏘드에서 인클루드 파일의 메쏘드 본체로 점프할 수도 있다. 코드 완성과 마찬가지로 모든 코드툴은 인클루드 파일을 특별한 부분으로 고려한다.

예를 들어: 코드 완성기능으로 다른 메쏘드 본체 뒤에 새로운 메쏘드 본체를 더할 때도 같은 파일에서 둘을 유지시킨다. 이러한 방법은 인크루드 파일에 완전한 클래스 선언을 할 수 있어 LCL과 같이 거의 모든 컨트롤을 가능하게 한다.

그러나 여기에도 함정은 있다: 만약 인크루드 파일을 처음 열어 메쏘드 점핑을 하거나 선언을 찾으려고 하면 에러가 날 것이다. IDE는 어떤 유닛이 인클루드 파일을 포함하는지 모르므로 유닛 을 먼저 열어야만 한다.

IDE가 유닛을 파싱하자마자 유닛에서 인클루드 지시어를 파싱할 수 있으므로 IDE는 이 관계를 기억하게 될 것이다. IDE는 종료시 이 정보를 저장하며 프로젝트에서는 ~/.lazarus/includelinks.xml로 저장할 수 있다. 다음번에 이 인클루드 파일을 열거 점프하거나 선언을 검색할 수 있어, IDE는 내부적을 유닛을 열어 점프하는 동작을 한게 된다.

이 동작 방법은 물론 한계가 있다. 몇몇 인클루드 파일은 두번 또는 그 이상으로 인클루드 되어있다. 예: lcl/include/winapih.inc.

이 인클루드 파일의 procedure/method 정의에서 몸체로 점프하는 것은 바로 전에 행한 동작과 관련이 있다. 만약 lcl/lclintf.pp에서 작업했다면 IDE는 winapi.inc로 점프할 것이다. 만약 lcl/interfacebase.pp에서 작업했다면 lcl/include/interfacebase.inc(또는 다른 인클루드 파일중의 하나)로 점프할 것이다. 만약 둘다에서 작업하고 있다면 예상과 다른 결과를 얻을 수도 있을 것이다 ;)

코드 템플릿

코드 템플릿은 식별자를 텍스트나 또는 코드 조각으로 전환한다.

코드 템플릿에 대한 디폴트 단축키는 Ctrl+J이다. 식별자를 타이핑하고 Ctrl+J를 누르면 식별자는 식별자에따라 정의된 텍스트로 교체된다. 코드 템플릿은 Environment -> Editor Options -> CodeTools에서 정의할 수 있다.

예: 'classf' 식별자를 쓰로 커서를 f의 바로 뒤에 옮긴 후 Ctrl+J를 누른다. 'classf'는 다음 문장으로 치환 될 것이다.

T = class(T)
private

public
  constructor Create;
  destructor Destroy; override;
end;

그리고 커서는 'T'다음에 있을 것이다. 이러한 템플릿의 리스트는 커서를 공백에 위치하고(식별자 위가 아니다) Ctrl+J를 누르면 얻을 수 있다. 코드 템플릿의 리스트가 팝업으로 나올 것이다. 키나 선택할 수 있는 문자를 눌러 선택한다. 엔터는 선택된 템플릿을 만들고, Escape는 팝업을 닫는다.

가장 크게 시간을 절약할 수 있는 템플릿은 'b'+Ctrl+J로 정의된 begin..end이다.

파라메터 힌트

파라메터 힌트는 현재 파라메터 리스트에 대해서 파라메터 선언을 힌트박스로 보여준다.

 Canvas.FillRect(|);

커서를 괄호안에 위치하고 Ctrl+Shift+Space를 누르면 힌트박스로 FillRect에 대한 파라메터를 보여줄 것이다.

코드 완성

코드 완성은 IDE메뉴의 Edit -> Complete Code에서 찾을 수 있으며 Ctrl+Shift+C를 표준 단축키로 제공한다.

델파이 사용자: 델파이는 "code completion"함수를 불러 현재 소스 위치(Ctrl+Space)의 식별자 리스트를 보여준다. 라자우스에서는 "Identifier completion"을 부른다..

코드 완성은 몇가지 강력한 함수와 결부되어 있다. 예:

  • 클래스 완성: 프로퍼티를 완성하며, 메소드 본체를 더하거나 업데이트하며, private 변화와 private 접근 메쏘드를 더한다.
  • 포워드 프로시저 완성: 프러시저 본체를 더한다.
  • 이벤트 할당 완성: 이벤트 할당을 완성하고 메쏘드 정의와 본체를 더한다.
  • 변수 선언 완성: 지역변수 정의를 더한다.
  • 프로시저 호출 완성: 새로운 프로시저를 더한다.
  • 역 프로시저 완성: 프로시저/함수에 본체에 대한 프로시저 선언을 더한다.
  • 역 클래스 완성: 메쏘드 본체에 대한 메쏘드 선언을 더한다

어느 함수가 사용되는지는 에디터상의 커서 위치에 따라 달라진다.

코드완성은 IDE메뉴의 Edit -> Complete Code에서 찾을 수 있으며 표준 단축키는 Ctrl+Shift+C이다.

클래스 완성

가장 강력한 코드 완성 특징은 "클래스 완성"이다. 클래스를 작성하고 메쏘드와 프로퍼티를 추가하면 코드완성은 메쏘드 본체를 더하게되고 프로퍼티는 메쏘드/변수 및 private 변수에 접근하게 된다.

예: 클래스를 만든다(타이핑하는 수고를 조금라도 덜려면 코드템플릿을 보세요):

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

커서를 클래스내의 아무 위치에나 놓고 Ctrl+Shift+C를 누른면 본체가 없는 메쏘드를 만들고 커서를 첫번째 메쏘드 바디에 위치시키므로 그 자리에서 클래스 코드를 작성하면 된다:

{ TExample }

constructor TExample.Create;
begin
  |
end;

destructor TExample.Destroy;
begin
  inherited Destroy;
end;

노트: '|'는 커서이고 더해지지 않는다.

힌트: 메쏘드와 몸체사이를 Ctrl+Shift+Up을 사용하여 이동할 수 있다.

IDE가 'inherited Destroy' 콜 함수를 더한 것을 역시 볼 수 있을 것이다. 클래스 정의에 'override' 키워드가 있다면 말이다.

이제 DoSomething 메쏘드를 추가해보자:

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

그리고 Ctrl+Shift+C를 누르면 IDE가 추가해 줄 것이다.

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

새로운 메쏘드 몸체가 클래스 정의에서 그랬던 것처럼 정확히 Create와 Destroy 사이에 삽입되어 있는 것을 알수 있을 것이다. 이러한 방식으로 정의된 순서와 같이 동일한 눈리적인 순서를 유지하도록 해준다. Environment > Codetools Options -> Code Creation 에서 삽입 규칙들을 정의할 수 있다.

Complete Properties
AnInteger 프로퍼티를 추가한다:

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

Ctrl+Shift+C를 누르면 다음이 나타난다:

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

코드완성은 Write 접근 modifier를 추가하고 몇몇 공통 코드를 추가한다. 새로운 클래스를 보기위해서는 Ctrl+Shift+Up를 이용하여 클래스로 점프할 수 있을 것이다:

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;

프로퍼티는 Read와 Write 접근 modifier에 의해 확장될 수 있다. 클래스는 'FAnInteger' 에 private성질을 가진 새로운 섹션과 'SetAnInteger' 메쏘드를 추가한다. It is a common Delphi style rule to prepend private variables with an 'F' and the write method with a 'Set'. If you don't like that, you can change this in Environment > Codetools Options -> Code Creation.

Creating a read only property:

property PropName: PropType read;

Will be expanded to

property PropName: PropType read FPropName;

Creating a write only property:

 property PropName: PropType write;

Will be expanded to

property PropName: PropType write SetPropName;

Creating a read only property with a Read method:

property PropName: PropType read GetPropName;

Will be kept and a GetPropName function will be added:

function GetpropName: PropType;

Creating a property with a stored modifier:

property PropName: PropType stored;

Will be expanded to

property PropName: PropType read FPropName write SetPropName stored PropNameIsStored;

Because stored is used for streaming read and write modifiers are automatically added as well.

Hint: Identifier completion also recognizes incomplete properties and will suggest the default names. For example:

property PropName: PropType read |;

Place the cursor one space behind the 'read' keyword and press Ctrl+Space for the identifier completion. It will present you the variable 'FPropName' and the procedure 'SetPropName'.

Forward Procedure Completion

"Forward Procedure Completion" is part of the Code Completion and adds missing procedure bodies. It is invoked, when the cursor is on a forward defined procedure.

For example: Add a new procedure to the interface section:

procedure DoSomething;

Place the cursor on it and press Ctrl+Shift+C for code completion. It will create in the implementation section:

procedure DoSomething;
begin
  |
end;

Hint: You can jump between a procedure definition and its body with Ctrl+Shift+Up.

The new procedure body will be added in front of the class methods. If there are already some procedures in the interface the IDE tries to keep the ordering. For example:

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

If the bodies of Proc1 and Proc3 already exists, then the Proc2 body will be inserted between the bodies of Proc1 and Proc3. This behaviour can be setup in Environment > Codetools Options -> Code Creation.

Multiple procedures:

procedure Proc1_Old; // body exists
procedure Proc2_New; // body does not exists
procedure Proc3_New; //  "
procedure Proc4_New; //  "
procedure Proc5_Old; // body exists

Code Completion will add all 3 procedure bodies (Proc2_New, Proc3_New, Proc4_New).

Why calling it "Forward Procedure Completion"?

Because it does not only work for procedures defined in the interface, but for procedures with the "forward" modifier as well. And because the codetools treats procedures in the interface as having an implicit 'forward' modifier.

Event Assignment Completion

"Event Assignment Completion" is part of the Code Completion and completes a single Event:=| statement. It is invoked, when the cursor is behind an assignment to an event.

For example: In a method, say the FormCreate event, add a line 'OnPaint:=':

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

The '|' is the cursor and should not be typed. Then press Ctrl+Shift+C for code completion. The statement will be completed to

OnPaint:=@Form1Paint;

A new method Form1Paint will be added to the TForm1 class. Then class completion is started and you get:

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

This works just like adding methods in the object inspector.

Note:
You must place the cursor behind the ':=' assignment operator. If you place the cursor on the identifier (e.g. OnPaint) code completion will invoke "Local Variable Completion", which fails, because OnPaint is already defined.

Hint:
You can define the new method name by yourself. For example:

 OnPaint:=@ThePaintMethod;

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.

For example: <delphi> procedure TForm1.Form1Create(Sender: TObject); begin

 i:=3;

end; </delphi> Place the cursor on the 'i' or just behind it. Then press Ctrl+Shift+C for code completion and you will get: <delphi> procedure TForm1.Form1Create(Sender: TObject); var

 i: Integer;

begin

 i:=3;

end; </delphi> 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.

Another example: <delphi> 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;

</delphi> Place the cursor on 'Where' and press Ctrl+Shift+C for code completion. You get: <delphi>

 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;

</delphi>

Since 0.9.11 Lazarus also completes parameters. For example <delphi>

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

</delphi> Place the cursor on 'x1' and press Ctrl+Shift+C for code completion. You get: <delphi>

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

</delphi>

Procedure Call Completion

Code completion can create a new procedure from a call statement itself.

Assume you just wrote the statement "DoSomething(Width);" <delphi> procedure SomeProcedure; var

 Width: integer;

begin

 Width:=3;
 DoSomething(Width);

end; </delphi>

Position the cursor over the identifier "DoSomething" and press Ctrl+Shift+C to get:

<delphi> procedure DoSomething(aWidth: LongInt); begin

end;

procedure SomeProcedure; var

 Width: integer;

begin

 Width:=3;
 DoSomething(Width);

end; </delphi>

It does not yet create functions nor methods.

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. This feature is available since Lazarus 0.9.21.

For example:

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

The method DoSomething is not yet declared in TForm1. Press Ctrl+Shift+C and the IDE will add "procedure DoSomething(Sender: TObject);" to the private methods of TForm1.

For Delphians: 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.

Comments and Code Completion

Code completion tries to keep comments where they belong. For example:

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

When inserting a new variable between FList and FInt, the comment is kept in the FList line. Same is true for

 FList: TList; { list of TComponent
   This is a comment over several lines, starting
   in the FList line, so codetools assumes it belongs 
   to the FLIst line and will not break this 
   relationship. Code is inserted behind the comment. }
 FInt: integer;

If the comment starts in the next line, then it will be treated as if it belongs to the code below. For example:

 FList: TList; // list of TComponent
   { This comment belongs to the statement below. 
     New code is inserted above this comment and 
     behind the comment of the FList line. }
 FInt: integer;

Method update

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. <Delphi>

 public
   procedure DoSomething;
 end;

procedure TForm.DoSomething; begin end; </Delphi>

Now add a parameter:

<Delphi>

 public
   procedure DoSomething(i: integer);
 end;

</Delphi>

and invoke Code Completion (Ctrl+Shift+C). The method body will be updated and the new parameter will be copied:

<Delphi> procedure TForm.DoSomething(i: integer); begin end; </Delphi>

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.

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.

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: You can jump back with Ctrl+H.

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.

Note 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 keywords. So you can not use it to complete 'proc' to 'procedure'. For these things use Ctrl+W Word Completion instead or Ctrl+J Code Templates.

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

Prefix

You can start identifier completion in a word. Then the letters to the left will be taken as prefix. For example:

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

The box will show you only the identifiers beginning with 'Ca'.

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. For example:

<Delphi> TMainForm = class(TForm) protected

 mous|

end; </DELPHI>

Completing MouseDown gives:

<Delphi> TMainForm = class(TForm) protected

 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,
        Y: Integer); override;

end; </DELPHI>

Properties

<Delphi> property MyInt: integer read |; </DELPHI>

Identifier completion will show FMyInt and GetMyInt.

<Delphi> property MyInt: integer write |; </DELPHI>

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 nice case of the unit (e.g. AVL_Tree).

Statements

<DELPHI> procedure TMainForm.Button1Click(Sender: TObject); begin

 ModalRe|;

end; </DELPHI>

becomes:

<DELPHI> procedure TMainForm.Button1Click(Sender: TObject); begin

 ModalResult:=|;

end; </DELPHI>

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 contains 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".

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

In the dialog you can setup the exclude and include filter, and with the command after you can compress the output into one archive.

Original contributors

This page has been converted from the epikwiki version.

  • Created page and initial template - 4/6/2004 VlxAdmin
  • Initial content posted - 4/10/2004 MattiasG
  • Small wiki and formatting fixes - 4/11/2004 VlxAdmin
  • Added a summary table for IdeTools shortcuts - 12 July 2004 User:Kirkpatc

Lazarus Database Tutorial