CnPack Forum


 
Subject: [feature idea #2] finish class
klemm
普通灌水员
Rank: 2



UID 4759
Digest Posts 0
Credits 79
Posts 38
点点分 79
Reading Access 10
Registered 2007-1-19
Status Offline
Post at 2007-1-30 11:00  Profile | Blog | P.M. 
[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;

implementation

(part #2 -- this can be generated)

procedure TMyClass.SetText(Value: String);
begin
  {$MESSAGE WARN 'Not implemented yet!'}
  (cursor here?)
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)

...
procedure TMyClass.Show(Canvas: TCanvas);
begin
  {$MESSAGE WARN 'Not implemented yet!'}
end;

(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,
Lauri
Top
Dans
新警察
Rank: 1



UID 13191
Digest Posts 0
Credits 18
Posts 7
点点分 18
Reading Access 10
Registered 2007-5-7
Status Offline
Post at 2007-5-7 21:57  Profile | Blog | P.M. 
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.

Best regards,
Dans
Top
 




All times are GMT++8, the time now is 2024-11-23 19:56

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007473 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP