Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Ryan Joseph via fpc-pascal


> On Apr 26, 2020, at 4:46 PM, Ryan Joseph  wrote:
> 
> The other thing I'm stuck on with code tools. In TCodeManagerTool:
> 
>function FindReferences(IdentifierCode: TCodeBuffer;
>  X, Y: integer; SearchInCode: TCodeBuffer; SkipComments: boolean;
>  var ListOfPCodeXYPosition: TFPList;
>  var Cache: TFindIdentifierReferenceCache  // you must free Cache
>  ): boolean;

Any word on this? Is it even possible to find all references in a project or do 
we need to extend code tools for this to work?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Michael Van Canneyt



On Mon, 27 Apr 2020, Ryan Joseph via fpc-pascal wrote:





On Apr 26, 2020, at 4:46 PM, Ryan Joseph  wrote:

The other thing I'm stuck on with code tools. In TCodeManagerTool:

   function FindReferences(IdentifierCode: TCodeBuffer;
 X, Y: integer; SearchInCode: TCodeBuffer; SkipComments: boolean;
 var ListOfPCodeXYPosition: TFPList;
 var Cache: TFindIdentifierReferenceCache  // you must free Cache
 ): boolean;


Any word on this? Is it even possible to find all references in a project or do 
we need to extend code tools for this to work?


It is definitely possible.

Check lazarus sources, directory ide, unit findrenameidentifier.pas:

Around line 302:

   // add packages, projects
case Options.Scope of
frProject:
  begin
OwnerList:=TFPList.Create;
OwnerList.Add(LazarusIDE.ActiveProject);
  end;

That should give you a start.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Mattias Gaertner via fpc-pascal
On Mon, 27 Apr 2020 22:12:30 +0700
Ryan Joseph via fpc-pascal  wrote:

> > On Apr 26, 2020, at 4:46 PM, Ryan Joseph 
> > wrote:
> > 
> > The other thing I'm stuck on with code tools. In TCodeManagerTool:
> > 
> >function FindReferences(IdentifierCode: TCodeBuffer;
> >  X, Y: integer; SearchInCode: TCodeBuffer; SkipComments:
> > boolean; var ListOfPCodeXYPosition: TFPList;
> >  var Cache: TFindIdentifierReferenceCache  // you must free
> > Cache ): boolean;  
> 
> Any word on this? Is it even possible to find all references in a
> project or do we need to extend code tools for this to work?

No, codetools have everything needed. FindReferences is merely one part.
You need a combination of several tools. Depending on your needs these
may vary.

I added an example for FindReferences:
lazarus/components/codetools/example/findreferences.lpi

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Zoë Peterson

Ryan,

Do you have a link to the LSP discord channel?  I tried following the 
one you posted Friday, but I got an error that I either didn't have 
access to any text channels or there weren't any on the server.


Thanks!


On 4/27/2020 10:12 AM, Ryan Joseph via fpc-pascal wrote:



On Apr 26, 2020, at 4:46 PM, Ryan Joseph  wrote:

The other thing I'm stuck on with code tools. In TCodeManagerTool:

function FindReferences(IdentifierCode: TCodeBuffer;
  X, Y: integer; SearchInCode: TCodeBuffer; SkipComments: boolean;
  var ListOfPCodeXYPosition: TFPList;
  var Cache: TFindIdentifierReferenceCache  // you must free Cache
  ): boolean;

Any word on this? Is it even possible to find all references in a project or do 
we need to extend code tools for this to work?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Ryan Joseph via fpc-pascal


> On Apr 28, 2020, at 4:36 AM, Zoë Peterson  wrote:
> 
> Ryan,
> 
> Do you have a link to the LSP discord channel?  I tried following the one you 
> posted Friday, but I got an error that I either didn't have access to any 
> text channels or there weren't any on the server.
> 
> Thanks!

Here's the LSP GitHub page. Scroll to "Getting help" for the link.

https://github.com/sublimelsp/LSP

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Ryan Joseph via fpc-pascal


> On Apr 28, 2020, at 4:18 AM, Mattias Gaertner via fpc-pascal 
>  wrote:
> 
> I added an example for FindReferences:
> lazarus/components/codetools/example/findreferences.lpi

I see now, there are more steps involved than I thought. 

LSP doesn't have a concept of the "main file" but this seems to require the 
main program file to start the search from. All we get from LSP is the 
workspace root directory and I've passed in some -Fu paths via FPCOptions.

Is there a workaround to this or can we get the main program from code tools?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Language Server

2020-04-27 Thread Ryan Joseph via fpc-pascal

I've learned how to use FindBlockCounterPart but it would be preferable to get 
the ranges which contain the identifiers that are the start/end of the blocks. 
For example the ranges of "begin" and "end" instead of the entire range which 
spans from the cursor to the end of the block. 

Any suggestions?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal