Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-07

Codetools, identity nodes from includes

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

Currently I walk the node tree for a given unit and collect all the relevant symbols into a list which represents the symbols in the current document. I'm running into problems with include files because I'm getting symbols which technically belong to another file which should not be displayed according to the LSP.

Given a TCodeTreeNode can I identity if the node came from an include file or not so I can ignore it?

Regards,
Ryan Joseph

Reply by email

Mattias Gaertner
to Ryan Joseph
Show quoted text 8 lines
Currently I walk the node tree for a given unit and collect all the relevant symbols into a list which represents the symbols in the current document. I'm running into problems with include files because I'm getting symbols which technically belong to another file which should not be displayed according to the LSP. Given a TCodeTreeNode can I identity if the node came from an include file or not so I can ignore it?

Something like this:

Node:=AItem.Node;
if Nodenil then
begin
  Scanner:=Tool.Scanner;
  LinkIndex:=Scanner.LinkIndexAtCleanPos(Node.StartPos);
  if LinkIndex<0 then
    // dangling node, e.g. syntax error
  else
    InIncludeFile:=Scanner.LinkP[LinkIndex]^.CodeScanner.MainCode;
end else
  ; // artificial node, e.g. intrinsic

Mattias

Reply by email

Ryan Joseph
to Mattias Gaertner
Show quoted text 15 lines
On Jul 7, 2020, at 4:57 AM, Mattias Gaertner via fpc-pascal wrote: Something like this: Node:=AItem.Node; if Nodenil then begin Scanner:=Tool.Scanner; LinkIndex:=Scanner.LinkIndexAtCleanPos(Node.StartPos); if LinkIndex<0 then // dangling node, e.g. syntax error else InIncludeFile:=Scanner.LinkP[LinkIndex]^.CodeScanner.MainCode; end else ; // artificial node, e.g. intrinsic

works well, thanks.

Regards,
Ryan Joseph

Reply by email

Mattias Gaertner
to Ryan Joseph
Show quoted text 9 lines
> On Jul 7, 2020, at 4:57 AM, Mattias Gaertner via fpc-pascal > wrote: > > Something like this: > > Node:=AItem.Node; > if Nodenil then > begin > Scanner:=Tool.Scanner;
Scanner:=AItem.Tool.Scanner;
Show quoted text 7 lines
> LinkIndex:=Scanner.LinkIndexAtCleanPos(Node.StartPos); > if LinkIndex<0 then > // dangling node, e.g. syntax error > else > InIncludeFile:=Scanner.LinkP[LinkIndex]^.CodeScanner.MainCode; > end else > ; // artificial node, e.g. intrinsic

Mattias

Reply by email