On Tue, 09 May 2006 20:14:30 +0200 Dean Zobec <[EMAIL PROTECTED]> wrote:
> Mattias Gaertner wrote: > > >> Then I'm investigating about a way to add the possibility to > >> automatically create the stubs for the tests as in Eclipse, through a > >> parsing of the unit containing the classes to be tested. > >> I would also like to improve the integration in Lazarus. I'm absolutely > >> fascinated by the power of the code tools, I think we could give the > >> failing tests a first class treatment in Lazarus, similar to compiling > >> errors, by creating some special marks in the source editor. > >> Though I'm sure I'll need some help from a codetools expert for this. > > > > What do you want to know? > > > thank you for your reply. > > 1) to parse the pascal classes and locate the methods of the class as a > candidate for the tests I've used the PasTree, PParser, PScanner units. > Though I found quite complicated to get the whole interface of the > methods, parameters included. Is there a better way to do the parsing > using the codetools in Lazarus? It depends on what you mean with 'whole interface'. The codetools can give you the information ranging from names to code with comments. There are alone 5 flags to define how much information to retrieve from a parameter list. Can you give an example, what you need? See the codeexplorer for an example for iterating through the codetree. > 2) what code do you suggest me to study to understand how to effectively > use codetools to locate and jump to the code in the source editor given > a name of the class and the method name for example? This will load a unit source, parse it, search the class in the interface and jumps to the method body (after the 'begin'): Code:=CodeToolBoss.LoadFile('/full/path/to/unit1.pas',false,false); CodeToolBoss.JumpToPublishedMethodBody(Code,'TForm1','OnClick',NewCode,NewX ,NewY,NewTopLine); Don't let you confuse by the 'Published' word. It does not search in ancestor classes for the method. If the method belongs to an ancestor class, it gets more complicated. Mattias _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives