[patch] CodeCompletion of indexed properties
Original Reporter info from Mantis: Penilopa P
-
Reporter name: Anton
Original Reporter info from Mantis: Penilopa P
- Reporter name: Anton
Description:
To reproduce:
1. New application project.
2. Add private field f:Integer and public property p:Integer as follows:
TForm1 = class(TForm)
private
{ private declarations }
f: Integer;
public
{ public declarations }
property p: Integer index 0 read f write SetP;
end;
3. Invoke code completion (Ctrl+Shift+C)
=> wrong private method "f" { function f(AIndex: integer): Integer } with empty body will be created. Program becomes wrong for compiler.
Additional information:
For the class
type
TMyClass = class
private
f: Integer;
public
property p0: Integer index 0 read f write f;
property p1: Integer index 1 read p_get write f;
property p2: Integer index 2 read f write p_set;
property p3: Integer index 3 read p_get write p_set;
end;
must be generated only 2 methods with AIndex parameter: p_get(), p_set():
function TMyClass.p_get(AIndex: integer): Integer;
begin
end;
procedure TMyClass.p_set(AIndex: integer; const AValue: Integer);
begin
end;
Delphi does it very well. More over: in Delphi AIndex has "const" modifier (but it does not matter).
Why the type of AIndex is "integer" (all lowercase)?
Data type "Integer" is declared in ObjPas.pp as
type
Integer = longint;
(first letter is capital)
Mantis conversion info:
- Mantis ID: 19151
- Version: 0.9.31 (SVN)
- Fixed in revision: 30597 (#b7f0a998)