Subject: [feature idea #2] finish class [Print This Page] Author:
klemm Time: 2007-1-30 11:00 Subject: [feature idea #2] finish class
Hello!
I find myself doing same manual work a lot:
I define a new class header - add fields, methods and properties.
Then i proceed to copy all the methods from the new class header and move to implementation part of a unit.
I then paste the methods;
add "TClassname." to method names;
add "begin..end" blocks to all of them;
some times add {$MESSAGE WARN 'Not implemented yet!'} between begin..end.
All of the described work after defining class header can be automated. The wizard would have to check each method for implementation body (so it can be used on partially complete classes also), create it if not found, then check next header. When done, it should move cursor to first body or back to class definition.
Here's an example:
(part #1 -- this i type)
type
TMyClass = class
private
FText: String;
procedure SetText(Value: String);
public
constructor Create(AText: String);
procedure Show(Canvas: TCanvas);
function GetSize(Canvas: TCanvas): TPoint; virtual;
procedure Whatever; virtual; abstract;
property Text: String read FText write SetText;
end;
constructor TMyClass.Create(AText: String);
begin
{$MESSAGE WARN 'Not implemented yet!'}
end;
procedure TMyClass.Show(Canvas: TCanvas);
begin
{$MESSAGE WARN 'Not implemented yet!'}
end;
function TMyClass.GetSize(Canvas: TCanvas): TPoint;
begin
{$MESSAGE WARN 'Not implemented yet!'}
end;
(the abstract method was skipped)
(end of example)
Also it would be nice if methods would be created in implementation in same order as in definition -- when i add a new procedure header between two old (complete with body) procedures then the new body should be created after the body of the previous procedure.
Another example is in order:
(#1 change in header)
type
TMyClass = class
private
FText: String;
procedure SetText(Value: String);
public
constructor Create(AText: String);
procedure Show(Canvas: TCanvas);
procedure Update(AText: String); <--- new method added
function GetSize(Canvas: TCanvas): TPoint;
property Text: String read FText write SetText;
end;
(#2 new method is placed in proper place when wizard is run)
(placed after Show, same as in definition)
procedure TMyClass.Update(AText: String);
begin
{$MESSAGE WARN 'Not implemented yet!'}
(cursor here)
end;
function TMyClass.GetSize(Canvas: TCanvas): TPoint;
begin
{$MESSAGE WARN 'Not implemented yet!'}
end;
What do you think?
--
BR,
LauriAuthor:
Dans Time: 2007-5-7 21:57 Subject: Reply #1 klemm's post
Hi, klemm
You should take a look at MMX - http://www.modelmakertools.com/code-explorer/index.html it has many features that you requested. Class templates, default methods body, sorting and many many things.
Currently Finish class (Complete Class) is not implemented but scheduled - it's complicated thing that needs parsing many modules.