Code tools search paths

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Code tools search paths

Free Pascal - General mailing list
I found out that setting TCodeToolsOptions.FPCOptions (-Fu and -Fi) was doing something because it helped FindDeclaration to search for units not in the same same directory as the main program. However now I've encountered problems with FindReferences (the example Mattias made for me) which seem to be caused by the inclusion of FPCOptions (if I remove the FPC options it properly builds the unit search graph).

reading on https://wiki.lazarus.freepascal.org/Codetools it sounds like I need to be using TDefineTemplate to add unit search paths. Which is the correct way to do this?


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list
On Sun, 10 May 2020 16:34:11 +0700
Ryan Joseph via fpc-pascal <[hidden email]> wrote:

> I found out that setting TCodeToolsOptions.FPCOptions (-Fu and -Fi)
> was doing something because it helped FindDeclaration to search for
> units not in the same same directory as the main program. However now
> I've encountered problems with FindReferences (the example Mattias
> made for me) which seem to be caused by the inclusion of FPCOptions
> (if I remove the FPC options it properly builds the unit search
> graph).
>
> reading on https://wiki.lazarus.freepascal.org/Codetools it sounds
> like I need to be using TDefineTemplate to add unit search paths.
> Which is the correct way to do this?

TDefineTemplates.
see for example
lazarus/components/codetools/examples/setincludepath.pas

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list


> On May 10, 2020, at 4:47 PM, Mattias Gaertner via fpc-pascal <[hidden email]> wrote:
>
> TDefineTemplates.
> see for example
> lazarus/components/codetools/examples/setincludepath.pas
>

Ok, I'll move to this. What are the FPC options for then? I thought I could do things like -Fu and -d with it.

Are include paths and unit paths the same? I just see TDefineTemplate which seems to do both.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list
On Mon, 11 May 2020 10:56:32 +0700
Ryan Joseph via fpc-pascal <[hidden email]> wrote:

> > On May 10, 2020, at 4:47 PM, Mattias Gaertner via fpc-pascal
> > <[hidden email]> wrote:
> >
> > TDefineTemplates.
> > see for example
> > lazarus/components/codetools/examples/setincludepath.pas
> >  
>
> Ok, I'll move to this. What are the FPC options for then? I thought I
> could do things like -Fu and -d with it.

Yes, you can.
They are treated like global options, i.e. as if added to the fpc.cfg.
 
> Are include paths and unit paths the same?

No.


> I just see TDefineTemplate which seems to do both.

There are separate macros.


Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list
In reply to this post by Free Pascal - General mailing list


> On May 11, 2020, at 10:56 AM, Ryan Joseph <[hidden email]> wrote:
>
> Ok, I'll move to this. What are the FPC options for then? I thought I could do things like -Fu and -d with it.
>
> Are include paths and unit paths the same? I just see TDefineTemplate which seems to do both.

Removing the FPCOptions fixed the FindReferences but I still don't seem to be getting your define template system:

If I just want to add unit search paths do I do this? The user is just going to supply absolute paths to the language server (just like they would from the command line).


// add all the unit paths
for Path in Paths do
begin
        DirectoryTemplate := TDefineTemplate.Create('Directory','','',ExpandFileName(Path),da_Directory);

          UnitPathTemplate := TDefineTemplate.Create('???','???',
            UnitPathMacroName,
            UnitPathMacro+';'+ExpandFileName(Path),
            da_Define
            );
          DirectoryTemplate.AddChild(UnitPathTemplate);

          CodeToolBoss.DefineTree.Add(DirectoryTemplate);
end;


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list
In reply to this post by Free Pascal - General mailing list


> On May 11, 2020, at 4:55 PM, Mattias Gaertner via fpc-pascal <[hidden email]> wrote:
>
> Yes, you can.
> They are treated like global options, i.e. as if added to the fpc.cfg.

Then I don't understand why those affect FindReferences but worked for other areas. Using those were easier than what I'm doing with the define templates but maybe I'm confused (see my follow up I just sent).

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list
In reply to this post by Free Pascal - General mailing list
On Mon, 11 May 2020 16:58:54 +0700
Ryan Joseph via fpc-pascal <[hidden email]> wrote:

>[...]
> If I just want to add unit search paths do I do this? The user is
> just going to supply absolute paths to the language server (just like
> they would from the command line).

FPC is happy with ppu files. Codetools need sources. So it needs the
settings where the ppu files are coming from. Therefore codetools
allows to have different settings for each directory.


> // add all the unit paths
> for Path in Paths do
> begin
> DirectoryTemplate :=
> TDefineTemplate.Create('Directory','','',ExpandFileName(Path),da_Directory);

This creates a node for directory Path. Path should be your program
directory.

 
>           UnitPathTemplate := TDefineTemplate.Create('???','???',
>             UnitPathMacroName,
>             UnitPathMacro+';'+ExpandFileName(Path),
>             da_Define
>             );
>           DirectoryTemplate.AddChild(UnitPathTemplate);

This expands the UnitPath of directory Path with Path.
Maybe you meant
UnitPathMacro+';'+ExpandFileName(SomeUnitPath),
?
 
>           CodeToolBoss.DefineTree.Add(DirectoryTemplate);
> end;


Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list


> On May 11, 2020, at 6:41 PM, Mattias Gaertner via fpc-pascal <[hidden email]> wrote:
>
> This creates a node for directory Path. Path should be your program
> directory.
>
>
>>          UnitPathTemplate := TDefineTemplate.Create('???','???',
>>            UnitPathMacroName,
>>            UnitPathMacro+';'+ExpandFileName(Path),
>>            da_Define
>>            );
>>          DirectoryTemplate.AddChild(UnitPathTemplate);
>
> This expands the UnitPath of directory Path with Path.
> Maybe you meant
> UnitPathMacro+';'+ExpandFileName(SomeUnitPath),

I wanted this to behave like the compiler normally does, that is you supply paths to the units with -Fu and includes with -Fi. What is the way to achieve that here?

For example in my test project I have the directory that contains the program and another direction to test units in other directories so I basically just want:

pp /path/to/test.pas -Fu/path/to/other_units

Pretty simple but I don't seem to be going about it correctly.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list


> On May 11, 2020, at 8:02 PM, Ryan Joseph <[hidden email]> wrote:
>
> I wanted this to behave like the compiler normally does, that is you supply paths to the units with -Fu and includes with -Fi. What is the way to achieve that here?
>
> For example in my test project I have the directory that contains the program and another direction to test units in other directories so I basically just want:
>
> pp /path/to/test.pas -Fu/path/to/other_units

I still haven't figured this out. I would be happy to use FPCOptions at init time but those break FindReferences for some reason.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Code tools search paths

Free Pascal - General mailing list
On Wed, 13 May 2020 10:45:21 +0700
Ryan Joseph via fpc-pascal <[hidden email]> wrote:

> > On May 11, 2020, at 8:02 PM, Ryan Joseph <[hidden email]>
> > wrote:
> >
> > I wanted this to behave like the compiler normally does, that is
> > you supply paths to the units with -Fu and includes with -Fi. What
> > is the way to achieve that here?
> >
> > For example in my test project I have the directory that contains
> > the program and another direction to test units in other
> > directories so I basically just want:
> >
> > pp /path/to/test.pas -Fu/path/to/other_units  
>
> I still haven't figured this out. I would be happy to use FPCOptions
> at init time but those break FindReferences for some reason.

Please create bug report with an example.

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal