Difference between revisions of "Lazarus IDE Tools/ko"

From Lazarus wiki
Jump to navigationJump to search
m (Text replace - "delphi>" to "syntaxhighlight>")
m (Text replace - "Delphi>" to "syntaxhighlight>")
Line 427: Line 427:
 
===Method update===
 
===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''.
 
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>
+
<syntaxhighlight>
 
   public
 
   public
 
     procedure DoSomething;
 
     procedure DoSomething;
Line 435: Line 435:
 
begin
 
begin
 
end;
 
end;
</Delphi>
+
</syntaxhighlight>
  
 
Now add a parameter:
 
Now add a parameter:
  
<Delphi>
+
<syntaxhighlight>
 
   public
 
   public
 
     procedure DoSomething(i: integer);
 
     procedure DoSomething(i: integer);
 
   end;
 
   end;
</Delphi>
+
</syntaxhighlight>
  
 
and invoke Code Completion (Ctrl+Shift+C). The method body will be updated and the new parameter will be copied:
 
and invoke Code Completion (Ctrl+Shift+C). The method body will be updated and the new parameter will be copied:
  
<Delphi>
+
<syntaxhighlight>
 
procedure TForm.DoSomething(i: integer);
 
procedure TForm.DoSomething(i: integer);
 
begin
 
begin
 
end;
 
end;
</Delphi>
+
</syntaxhighlight>
  
 
==Refactoring==
 
==Refactoring==
Line 565: Line 565:
 
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:
 
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>
+
<syntaxhighlight>
 
TMainForm = class(TForm)
 
TMainForm = class(TForm)
 
protected
 
protected
Line 574: Line 574:
 
Completing '''MouseDown''' gives:
 
Completing '''MouseDown''' gives:
  
<Delphi>
+
<syntaxhighlight>
 
TMainForm = class(TForm)
 
TMainForm = class(TForm)
 
protected
 
protected
Line 584: Line 584:
 
===Properties===
 
===Properties===
  
<Delphi>
+
<syntaxhighlight>
 
property MyInt: integer read |;
 
property MyInt: integer read |;
 
</DELPHI>
 
</DELPHI>
Line 590: Line 590:
 
Identifier completion will show '''FMyInt''' and '''GetMyInt'''.
 
Identifier completion will show '''FMyInt''' and '''GetMyInt'''.
  
<Delphi>
+
<syntaxhighlight>
 
property MyInt: integer write |;
 
property MyInt: integer write |;
 
</DELPHI>
 
</DELPHI>

Revision as of 23:50, 24 March 2012

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 에서 삽입 규칙들을 정의할 수 있다.

프로퍼티 완성
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' 메쏘드를 추가한다. private 변수에 F르 붙이고 write 메쏘드에 'Set'을 붙이는 것은 전형적인 델파이 스타일이다. 이런 방식이 싫다면 Environment > Codetools Options -> Code Creation에서 변경할 수 있다.

읽기만 가능한 프로퍼티 생성:

property PropName: PropType read;

다음과 같이 확장될 수 있다

property PropName: PropType read FPropName;

쓰기만 가능한 프로퍼티 생성:

 property PropName: PropType write;

다음과 같이 확장될 수 있다

property PropName: PropType write SetPropName;

Read 메쏘드를 가진 읽기만 가능한 프로퍼티 생성:

property PropName: PropType read GetPropName;

그대로 둔 상태로 GetPropName 이 추가된다:

function GetpropName: PropType;

stored modifier를 가진 프로퍼티 생성:

property PropName: PropType stored;

다음과 같이 확장될 수 있다

property PropName: PropType read FPropName write SetPropName stored PropNameIsStored;

stored는 스트리밍 읽기와 쓰기 modifier가 자동적으로 추가 되도록 할 떄 사용된다.

힌트: 식별자완성은 불완전한 프로퍼니를 인식하여 디폴트 이름을 제시해준다. 에를 들면:

property PropName: PropType read |;

커서를 'read' 키워드 뒤의 공백에 놓고 Ctrl+Space를 누르면 식별자완성을 부르게된다. 이는 'FPropName'과 'SetPropName'을 보여줄 것이다.

Forward 프로시져 완성

"Forward Procedure Completion"은 코드 완성의 일부분이며 송실된 프로시져 본체를 추가해준다. 이것은 커서가 전방에 정의된 프로시져 위에 있을 때 일어난다.

예: 인터페이스 섹션에 새로운 프로시져를 추가한다: procedure DoSomething; 커서를 그 위에 놓고 Ctrl+Shift+C 를 눌러 코드완성을 하게 한다. 그러면 implementation 섹션에 다음 부분이 생성된다:

procedure DoSomething;
begin
  |
end;

힌트: 프로서져 정의 부분과 몸체 사이를 Ctrl+Shift+Up 키를 이용해서 왔다 갔다 할 수 있다.

새로운 프로시져 몸체는 클래스 메써드의 첫 부분에 추가될 것이다. 만약 인터페이스 부에 어떤 프로시져가 이미 있다면 IDE는 순서를 지킬 것이다. 예:

 procedure Proc1;
 procedure Proc2; // 새로운 프로시져
 procedure Proc3;

만약 Proc1 과 Proc3의 몸체가 이미 있었다면 Proc2 몸체는 Proc1 과 Proc3 의 몸체 사이에 삽입될 것이다. 이러한 행동은 Environment > Codetools Options -> Code Creation 에서 설정할 수 있다.

복수의 프로시져:

procedure Proc1_Old; // 몸체 존재
procedure Proc2_New; // 몸체 없음
procedure Proc3_New; //  "
procedure Proc4_New; //  "
procedure Proc5_Old; // 몸체 존재

코드완성은 3개의 프로시져 바디를 모두 추가할 것이다 (Proc2_New, Proc3_New, Proc4_New).

왜 "Forward Procedure Completion"이라고 부를까?

이것은 인터페이스에서 정의된 프로시져에대해 동작할 뿐아니라 "forward" modifier가 있는 프로시져에도 똑같이 동작한다. 그리고 코드툴은 인터페이스 내의 프로시져가 암시적인 'forward' modifier를 가진것처럼 취급하기 때문이다.

이벤트 할당 완성

"이벤트 할당 완성"은 코드완성의 일부분이며 단일 이벤트 Event:=| 문장을 완성한다. 이것은 커서가 이벤트에 대해 할당된 배후에 있을 때 일어난다.

예를 들면: 메써드 내에서, FormCreate 이벤트가 있고, 'OnPaint:='라인을 추가하면:

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

'|'는 커서이고 타이프하면 안된다. 그리고 Ctrl+Shift+C를 눌러 코드완성을 한다. 문장은 OnPaint:=@Form1Paint; 로 완성된다 새로운 메쏘드 Form1Paint는 TForm1 에 추가된다. 그러면 클래스 완성이 시작되고 다음과 같이 될 것이다:

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

이것은 오브젝트 인스펙터상에서 메써드를 추가하는 것과 같다.

Note:
커서를 ':=' 할당 오퍼레이터의 뒤에 놓아야 한다. 커서를 identifier (예, OnPaint) 위에 놓으면 OnPaint가 이미 정의되었기 때문에 코드 완성은 "지역변수 완성"을 일으키고 만다. Hint:
새로운 메써드 이름을 자의적으로 만들 수 있다. 예를 들면:

 OnPaint:=@ThePaintMethod;

변수 선언 완성

"변수 선언 완성" 은 코드 완성의 일부이며 Identifier:=Term; 문장에 대한 지역변수 정의를 추가한다. 커서가 할당문 또는 파라메터의 identifier 위에 있을 때 일어난다.

예를 들면:

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

커서를 'i' 또는 바로 뒤에 놓고 Ctrl+Shift+C 를 누르면 코드완성이 이루어지고 다음을 얻게 된다:

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

코드 툴은 먼저 식별자 'i'가 이미 정의 되어있는지 확인하고 없으면 'var i: integer;'을 선언을 추가한다. 식별자의 종류는 할달문 ':=' 연산자의 우측을 보고 판단한다. 3과 같은 숫자는 Integer 로 지정되어있다.

다른 예:

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;

커서를 'Where'에 놓고 Ctrl+Shift+C 를 누르고 코드완성을 하면 다음을 얻는다:

  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;

라자루스 0.9.11은 파라메터 완성도 한다. 예를 들면:

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

커서를 'x1'에 놓고 Ctrl+Shift+C 를 눌러 코드완성을 하면 다음을 얻는다:

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

프로시져 호출 완성

코드 완성은 호출문 자체에서 새로운 프로시져를 만들어낸다.

"DoSomething(Width);" 문을 작성했다고 가정하자

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

커서를 식별자 "DoSomething" 위에 놓고 Ctrl+Shift+C 를 눌러 다음을 얻는다:

procedure DoSomething(aWidth: LongInt);
begin

end;

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

이것은 아직 함수나 메써드를 만들지 않았다.

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.

  public
    procedure DoSomething;
  end;

procedure TForm.DoSomething;
begin
end;

Now add a parameter:

  public
    procedure DoSomething(i: integer);
  end;

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

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.

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:

<syntaxhighlight> TMainForm = class(TForm) protected

 mous|

end; </DELPHI>

Completing MouseDown gives:

<syntaxhighlight> TMainForm = class(TForm) protected

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

end; </DELPHI>

Properties

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

Identifier completion will show FMyInt and GetMyInt.

<syntaxhighlight> 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