[fpc-pascal] Pascal Language Server

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Apr 28 10:55:33 CEST 2020

On Tue, 28 Apr 2020 15:34:57 +0700
Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:

> > On Apr 28, 2020, at 3:26 PM, Michael Van Canneyt
> > <michael at freepascal.org> wrote:
> > 
> > That's a wrong approach. Pascal units are in a uses-tree. You need
> > a starting point, the top of the tree: a single module.  
> I can make the user provide the program file and start from there but
> then the references in other units not related to the  main program
> will not be found.

Correct. As it should be. Why should it find unrelated units?

> Mattias says we can call AddStartUnit multiple times but there's no
> logic I can use besides adding all files in the provided directories.

If you really don't know the program file, and have no meta
information to find it, then blindly parsing every file is the way
to go. If it is an include file, parsing will probably fail. If it is an
unrelated file needing other compile flag, parsing might fail too.
So basically you have to blindly open all these files, use
CodetoolsBoss.Explore and see if parsing works. You can check if it is
a program and add it via the AddStartUnit.
Or if you really want all unrelated files too, then you can skip the
graph and simply feed all found, parseable files to the FindReferences

> Here's what I'm trying to implement:
> https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_references
> It's just a project wide search so what can we do besides just add
> all files found in the project?

Since most compilers require a start file, maybe you can look at other
LSP, how they determine the start file.


More information about the fpc-pascal mailing list