[fpc-pascal] Using include files in code tools

Mattias Gaertner nc-gaertnma at netcologne.de
Sat May 9 11:36:31 CEST 2020

On Thu, 7 May 2020 20:21:35 +0700
Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:

> > On May 7, 2020, at 5:26 PM, Mattias Gaertner via fpc-pascal
> > <fpc-pascal at lists.freepascal.org> wrote:
> > 
> > Nodes are always associated with a Tool. Tool.MainFilename gives the
> > file, where parsing started.
> >   
> Just curious, can you explain the reasoning of "tools"? I haven't
> exactly figured out the delegation of tasks in your system.

Maybe this helps:

> >> I need this information so I can get navigate to the include file
> >> AND relative text offset into the include file text.   
> > 
> > There are plenty of functions for include files. Can you give an
> > example what you need?  
> I start with CodeToolBoss.Explore after loading the unit and get the
> current tool from that. I need to start with an actual unit right?

Yes, if you need the higher level functions like FindDeclaration.

Of course there are lower level functions to parse snippets. See unit

> don't think it will parse plain include files on its own, and that
> won't often work anyways because there are  macros in the unit which
> includes the include file.
> I'm collecting the symbols so that I can return them to the client
> and it can navigate to a particular file at a line/column number. The
> file which I navigate to must be the include file but I only have
> those location relative to the unit, not the include. 

Use Tool.CleanPosToCaret(Node.StartPos,xyp) to get the file, line and



More information about the fpc-pascal mailing list