[fpc-pascal] Pascal Language Server

Mattias Gaertner nc-gaertnma at netcologne.de
Fri May 1 09:42:13 CEST 2020


On Fri, 1 May 2020 12:31:26 +0700
Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:

> Stuck on another code tools problem.
> 
> I've been using code like this to find words at node offsets and this
> works well until there are $ifdefs in the file and then the text
> position getting offset and fail to return the correct identifiers.
> 
> GetIdentifier(@Code.Source[Node.StartPos]);

The Node.StartPos are referring to the Tool.Scanner.CleanedSrc, which is
the code stripped of skipped $ifdef ranges and include files included.

 
> How should this be resolved? I don't see there is a copy of the
> actual text parsed (without ifdefs) so I don't know how to reference
> the text that the parser actually used.

You can convert the cleanpos to actual file position using

Tool.CleanPosToCodePos

Mattias


More information about the fpc-pascal mailing list