Re: [fpc-pascal] Using include files in code tools
> On May 10, 2020, at 1:20 AM, Mattias Gaertner via fpc-pascal > wrote: > > CleanPosToCaret is using a binary search. Compared to the other > operations like parsing, this is is hardly measurable. Thanks, I got it working now. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
On Sat, 9 May 2020 20:55:24 +0700 Ryan Joseph via fpc-pascal wrote: > > On May 9, 2020, at 4:36 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > Use Tool.CleanPosToCaret(Node.StartPos,xyp) to get the file, line > > and column. > > Thanks, I was just using the raw Node.StartPos location. Is there any > flag in a node to know if it came from an include? That would be > helpful because otherwise I need to call CleanPosToCaret on every > symbol regardless of where it came from. CleanPosToCaret is using a binary search. Compared to the other operations like parsing, this is is hardly measurable. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
> On May 9, 2020, at 4:36 PM, Mattias Gaertner via fpc-pascal > wrote: > > Use Tool.CleanPosToCaret(Node.StartPos,xyp) to get the file, line and > column. Thanks, I was just using the raw Node.StartPos location. Is there any flag in a node to know if it came from an include? That would be helpful because otherwise I need to call CleanPosToCaret on every symbol regardless of where it came from. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
On Thu, 7 May 2020 20:21:35 +0700 Ryan Joseph via fpc-pascal wrote: > > On May 7, 2020, at 5:26 PM, Mattias Gaertner via fpc-pascal > > 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: https://wiki.freepascal.org/Codetools#Tool.2C_Node.2C_LinkScanner > >> 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 BasicCodetools. > 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 column. Mattias Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
> On May 7, 2020, at 8:21 PM, Ryan Joseph wrote: > >>> 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? I 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. sorry to pester but any ideas on this? I still haven't figured it out yet. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
> On May 7, 2020, at 5:26 PM, Mattias Gaertner via fpc-pascal > 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. > >> 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? I 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. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
On Thu, 7 May 2020 12:26:53 +0200 Mattias Gaertner via fpc-pascal wrote: >[...]how do I know which include a > > node came from? > > Nodes are always associated with a Tool. Tool.MainFilename gives the > file, where parsing started. > > > 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? Tool.CleanPosToCaret(Node.StartPos,CXY) Tool.CleanPosToCodePos(Node.StartPos,CP) Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using include files in code tools
On Thu, 7 May 2020 16:26:12 +0700 Ryan Joseph via fpc-pascal wrote: > When using code tools I've found that it needs to start from a main > unit (otherwise other relevant macros may not be set) and then insert > includes into the source text. This is fine but when I inspect the > node tree (TCodeTreeNode) how do I know which include a node came > from? Nodes are always associated with a Tool. Tool.MainFilename gives the file, where parsing started. > 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? Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal