On Sat, 05 May 2007 17:58:47 +0200
Darius Blaszijk <[EMAIL PROTECTED]> wrote:
> Mattias Gaertner wrote:
> > On Sat, 05 May 2007 02:03:59 +0200
> > Darius Blaszijk <[EMAIL PROTECTED]> wrote:
> >
> >> I would like to insert a new class definition through the code
> >> tools.
> >>
> >> eg:
> >> TMyClass = class(TObject)
> >> end;
> >>
> >> Is this possible using currently available methods in TCodeTool?
> >> Or should I create a new method that does this.
> >
> > There is no simple method 'AddClass'.
> >
> > Normally insertion works like this:
> > - parse existing code
> > - find insert postion and indentation
> > - create text to insert
> > - call SourceChangeCache.Replace
> > - call SourceChangeCache.Apply
> >
> > See for example:
> > stdcodetools.pas TStandardCodeTool.SetApplicationTitleStatement
> >
> > The modified files are listed in
> > CodeToolBoss.SourceChangeCache.BuffersToModify
> >
> > Note: Normally you work on the parsed code (cleaned from IFDEF and
> > INCLUDE directives). The SourceChangeCache will automatically
> > translate back to the unit and include files.
> >
> > Should I create a short example?
> Yes please, I would be grateful if you would do that.
Added.
addclass.lpi
Mattias
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives