Re: [fpc-pascal] Pascal Language Server
On Sat, 2 May 2020 10:18:36 +0700 Ryan Joseph via fpc-pascal wrote: >[...] > Found the problem. I overwrote "FirstChild" of TCodeTreeNode using a > var param. oops! I still thought LoadFile should have rebuilt the > node tree but it doesn't seem to do this (even if UpdateFromDisk and > Revert params are set to true). LoadFile merely loads the file. > I'll post any new code tools questions to a new thread now and keep > this one for the language server. Thank You. 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
> On May 2, 2020, at 12:13 AM, Mattias Gaertner via fpc-pascal > wrote: > > By many functions in CodetoolBoss. Explore, FindDeclaration, > FindReferences, GatherIdentifiers. All of them checks if a file have > changed and rebuilds nodes. If no file/setting has changed, nodes are > kept. Found the problem. I overwrote "FirstChild" of TCodeTreeNode using a var param. oops! I still thought LoadFile should have rebuilt the node tree but it doesn't seem to do this (even if UpdateFromDisk and Revert params are set to true). I'll post any new code tools questions to a new thread now and keep this one for the language server. 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
On Fri, 1 May 2020 21:32:24 +0700 Ryan Joseph via fpc-pascal wrote: > > On May 1, 2020, at 9:28 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > "Explore" checks if some files have changed and if so rebuilds the > > nodes. > > so I missed something fundamental! I used Explore because I noticed > that I was able to get parser errors after calling it. When does the > actual node tree get built then? By many functions in CodetoolBoss. Explore, FindDeclaration, FindReferences, GatherIdentifiers. All of them checks if a file have changed and rebuilds nodes. If no file/setting has changed, nodes are kept. > I just want to load the file and > step through the nodes like I explained earlier. Maybe I misunderstand what "like I explained earlier" means. The thread was pretty long. 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
> On May 1, 2020, at 9:28 PM, Mattias Gaertner via fpc-pascal > wrote: > > "Explore" checks if some files have changed and if so rebuilds the > nodes. so I missed something fundamental! I used Explore because I noticed that I was able to get parser errors after calling it. When does the actual node tree get built then? I just want to load the file and step through the nodes like I explained earlier. 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
On Fri, 1 May 2020 20:23:01 +0700 Ryan Joseph via fpc-pascal wrote: >[...] > > What are you doing between calls of Explore? > > I'm walking the node tree and then using the Start/EndPos to read > into the source text so that I can extract identifier. It's just: > LoadFile, Explore, WalkTree. I didn't step through the debugger or > anything but I assume the actual node structure starting from > Tool.Tree.Root changed. "Explore" checks if some files have changed and if so rebuilds the nodes. > If that's not normal behavior I'll look harder and get into the > debugger. 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
> On May 1, 2020, at 4:55 PM, Mattias Gaertner via fpc-pascal > wrote: > > This thread is getting too long. > > Can you please create new threads for new topics? Sure. I'll respond now on this last question but I'll make new ones later if that's better for the list. > > On Fri, 1 May 2020 16:27:46 +0700 > Ryan Joseph via fpc-pascal wrote: > >> Ok, got things working now. Here's the basic pattern I'm using. I >> call explore and then walk the root tree node to find what I need but >> i've noticed the 2nd time I do this I get less results than the first >> time! What is happening? > > What are you doing between calls of Explore? I'm walking the node tree and then using the Start/EndPos to read into the source text so that I can extract identifier. It's just: LoadFile, Explore, WalkTree. I didn't step through the debugger or anything but I assume the actual node structure starting from Tool.Tree.Root changed. If that's not normal behavior I'll look harder and get into the debugger. 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
On Wed, 29 Apr 2020 21:18:02 +0700 Ryan Joseph via fpc-pascal wrote: > Testing this more I'm having a problem getting overwhelmed by > completions for classes because of methods from TObject (and other > parents) The RTL is powerful. That's why I prefer to put recently used identifiers at top of the completion box. > so I'd like to add some information about this. > > Using this method: > > if CodeToolBoss.GatherIdentifiers(Code,X + 1,Y + 1) then > begin > Count := CodeToolBoss.IdentifierList.GetFilteredCount; > for I := 0 to Count - 1 do > begin > Identifier := CodeToolBoss.IdentifierList.FilteredItems[I]; > > > can I find the parent class of "Identifier"(TIdentifierListItem)? > There's a TCodeTreeNode field that maybe I could walk up to find what > I need? Sure. Something like: while Node<>nil do begin if (Node.Desc=ctnClass) then begin if Tool.ExtractClassName(Node),false)='TObject' then ... break; end else Node:=Node.Parent; end; 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
This thread is getting too long. Can you please create new threads for new topics? On Fri, 1 May 2020 16:27:46 +0700 Ryan Joseph via fpc-pascal wrote: > Ok, got things working now. Here's the basic pattern I'm using. I > call explore and then walk the root tree node to find what I need but > i've noticed the 2nd time I do this I get less results than the first > time! What is happening? What are you doing between calls of Explore? > I assume it's caching something but do I > need to reference the cache myself? > > Code := CodeToolBoss.LoadFile(Path,false,false); > if not CodeToolBoss.Explore(Code,Tool,false,false) then > exit; > WalkTree(Tool.Tree.Root); 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
Ok, got things working now. Here's the basic pattern I'm using. I call explore and then walk the root tree node to find what I need but i've noticed the 2nd time I do this I get less results than the first time! What is happening? I assume it's caching something but do I need to reference the cache myself? Code := CodeToolBoss.LoadFile(Path,false,false); if not CodeToolBoss.Explore(Code,Tool,false,false) then exit; WalkTree(Tool.Tree.Root); 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
> On May 1, 2020, at 2:42 PM, Mattias Gaertner via fpc-pascal > wrote: > > The Node.StartPos are referring to the Tool.Scanner.CleanedSrc, which is > the code stripped of skipped $ifdef ranges and include files included. That's what I was missing. Thanks again. 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
On Fri, 1 May 2020 12:31:26 +0700 Ryan Joseph via fpc-pascal 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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
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]); 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. 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
> On Apr 29, 2020, at 3:15 PM, Ryan Joseph wrote: > > This wasn't doing what I thought. It still doesn't give an error until I > query at another point in the unit. I thought it would pre-parse or something > but it seems to be on demand. I may have to handle the errors in another way. > >Code := CodeToolBoss.FindFile(URI.Path + URI.Document); >for Change in contentChanges do >begin > Code.Source := TTextDocumentContentChangeEvent(Change).text; > if CodeToolBoss.ErrorMessage <> '' then >begin > writeln(stderr, 'Document Parse error: ', > CodeToolBoss.ErrorMessage, > CodeToolBoss.ErrorLine, ':', > CodeToolBoss.ErrorColumn); > flush(stderr); >end; >end; I found the "Explore" method which appears to do what I wanted. There's also CheckSyntax which appears to do basically the same thing. 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
Testing this more I'm having a problem getting overwhelmed by completions for classes because of methods from TObject (and other parents) so I'd like to add some information about this. Using this method: if CodeToolBoss.GatherIdentifiers(Code,X + 1,Y + 1) then begin Count := CodeToolBoss.IdentifierList.GetFilteredCount; for I := 0 to Count - 1 do begin Identifier := CodeToolBoss.IdentifierList.FilteredItems[I]; can I find the parent class of "Identifier"(TIdentifierListItem)? There's a TCodeTreeNode field that maybe I could walk up to find what I need? 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
On Wed, 29 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 29, 2020, at 3:37 PM, Michael Van Canneyt wrote: if the Lazarus team can implement a LSP plugin for the editor, then we'd have instant language support for a whole bunch of languages. That would be awesome... but language servers don't do any syntax styling so they're only half the solution. I was also disappointed to learn they don't allow arbitrary commands that apply text ranges to the editor. That would mean a unified interface for the countless scripts people write for editors like Sublime Text. Worst is the "Class Completion" feature in CodeTools can't be implemented in editors unless Microsoft extends the protocol. So much for the 'One editor to rule them all' advocates :-) 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
> On Apr 29, 2020, at 3:37 PM, Michael Van Canneyt > wrote: > > if the Lazarus team can implement a LSP plugin for the editor, then we'd have > instant language support > for a whole bunch of languages. That would be awesome... but language servers don't do any syntax styling so they're only half the solution. I was also disappointed to learn they don't allow arbitrary commands that apply text ranges to the editor. That would mean a unified interface for the countless scripts people write for editors like Sublime Text. Worst is the "Class Completion" feature in CodeTools can't be implemented in editors unless Microsoft extends the protocol. 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
On Wed, 29 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 29, 2020, at 3:23 PM, Michael Van Canneyt wrote: and then it should be a matter of creating a descendent of the language client. The C# one seems easy enough to convert :-) Let me know if you can figure it out. Will do. VSCode looks pretty difficult: https://github.com/donaldpipowitch/how-to-create-a-language-server-and-vscode-extension I think the client-side is relatively simple ? Sublime text was pretty easy (just install the LSP plugin and fill out the JSON settings). Yes, they did the heavy lifting for their editor. A good initiative. Well... if the Lazarus team can implement a LSP plugin for the editor, then we'd have instant language support for a whole bunch of languages. That would be awesome... 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
> On Apr 29, 2020, at 3:23 PM, Michael Van Canneyt > wrote: > > and then it should be a matter of creating a descendent of the language > client. > The C# one seems easy enough to convert :-) Let me know if you can figure it out. VSCode looks pretty difficult: https://github.com/donaldpipowitch/how-to-create-a-language-server-and-vscode-extension Sublime text was pretty easy (just install the LSP plugin and fill out the JSON settings). 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
On Wed, 29 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 28, 2020, at 7:47 PM, Michael Van Canneyt wrote: Incredibly looking forward to test-driving this in Atom... :-) Michael, do you actually know how to setup a language server in Atom? I've only tested on Sublime Text but I do plan to learn how to setup VSCode also when I find some time. From the research I did till now, for Atom a package must be installed: https://github.com/atom/atom-languageclient and then it should be a matter of creating a descendent of the language client. The C# one seems easy enough to convert :-) You should be able to build this and do some testing even if it's not finished and we'd like to know if it works on other editors. https://github.com/genericptr/pascal-language-server I won't have time to test till the weekend, but during the weekend I will test and report. Don't let me keep you from adding features in the meantime, though :-) 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
> On Apr 28, 2020, at 10:01 PM, Mattias Gaertner via fpc-pascal > wrote: > > Yes This wasn't doing what I thought. It still doesn't give an error until I query at another point in the unit. I thought it would pre-parse or something but it seems to be on demand. I may have to handle the errors in another way. Code := CodeToolBoss.FindFile(URI.Path + URI.Document); for Change in contentChanges do begin Code.Source := TTextDocumentContentChangeEvent(Change).text; if CodeToolBoss.ErrorMessage <> '' then begin writeln(stderr, 'Document Parse error: ', CodeToolBoss.ErrorMessage, CodeToolBoss.ErrorLine, ':', CodeToolBoss.ErrorColumn); flush(stderr); end; end; > >>end; >> [...] >>property ErrorColumn: integer read fErrorColumn; >>property ErrorLine: integer read fErrorLine; >>property ErrorMessage: string read fErrorMsg; > > The above should be self explanatory. Where can I know which file it was from? I've got error message from other units than the current one but I don't see a way to get the name of that file. 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
> On Apr 28, 2020, at 7:47 PM, Michael Van Canneyt > wrote: > > Incredibly looking forward to test-driving this in Atom... :-) Michael, do you actually know how to setup a language server in Atom? I've only tested on Sublime Text but I do plan to learn how to setup VSCode also when I find some time. You should be able to build this and do some testing even if it's not finished and we'd like to know if it works on other editors. https://github.com/genericptr/pascal-language-server 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
On Tue, 28 Apr 2020 20:58:18 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 28, 2020, at 8:52 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > Codetoolboss.Error* > > Not sure I'm understand the usage. When do I check for errors and are > there ever more than 1 or just the last error? Only one. Check when a function returns false. > I'm guessing maybe > after: > > URI := ParseURI(textDocument.uri); > Code := CodeToolBoss.FindFile(URI.Path + URI.Document); > for Change in contentChanges do > begin > Code.Source := TTextDocumentContentChangeEvent(Change).text; > // check for error here? Yes > end; >[...] > property ErrorColumn: integer read fErrorColumn; > property ErrorLine: integer read fErrorLine; > property ErrorMessage: string read fErrorMsg; The above should be self explanatory. 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
> On Apr 28, 2020, at 8:52 PM, Mattias Gaertner via fpc-pascal > wrote: > > Codetoolboss.Error* Not sure I'm understand the usage. When do I check for errors and are there ever more than 1 or just the last error? I'm guessing maybe after: URI := ParseURI(textDocument.uri); Code := CodeToolBoss.FindFile(URI.Path + URI.Document); for Change in contentChanges do begin Code.Source := TTextDocumentContentChangeEvent(Change).text; // check for error here? end; // exception handling procedure ClearError; function HandleException(AnException: Exception): boolean; procedure SetError(Id: int64; Code: TCodeBuffer; Line, Column: integer; const TheMessage: string); property CatchExceptions: boolean read FCatchExceptions write FCatchExceptions; property WriteExceptions: boolean read FWriteExceptions write FWriteExceptions; property ErrorCode: TCodeBuffer read fErrorCode; property ErrorColumn: integer read fErrorColumn; property ErrorLine: integer read fErrorLine; property ErrorMessage: string read fErrorMsg; property ErrorId: int64 read FErrorId; property ErrorTopLine: integer read fErrorTopLine; property ErrorDbgMsg: string read FErrorDbgMsg; property Abortable: boolean read FAbortable write SetAbortable; property OnCheckAbort: TOnCodeToolCheckAbort read FOnCheckAbort write FOnCheckAbort; 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
On Tue, 28 Apr 2020 20:28:16 +0700 Ryan Joseph via fpc-pascal wrote: >[...] > Speaking of that is there a way in code tools to get a list of > parsing errors that occurred for a given file? It's possible that > parsing fails but I don't know where errors occurred until I make a > query and comes back with an error. I'd like to get this up front so > I can use LSP diagnostic feature that shows inline errors or in the > gutter etc... Codetoolboss.Error* 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
> On Apr 28, 2020, at 7:47 PM, Michael Van Canneyt > wrote: > > Incredibly looking forward to test-driving this in Atom... :-) The biggest left is getting diagnostics working so we can see errors that popup. Speaking of that is there a way in code tools to get a list of parsing errors that occurred for a given file? It's possible that parsing fails but I don't know where errors occurred until I make a query and comes back with an error. I'd like to get this up front so I can use LSP diagnostic feature that shows inline errors or in the gutter etc... 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
On Tue, 28 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 28, 2020, at 4:04 PM, Michael Van Canneyt wrote: You can do what most VSCode/Atom project managers seem to, add package.json or somesuch: { "pascal-lsp" : { "projectfile" : "yourproject.pas", "searchpath" : ["a","b"] } } Yes, that's what the plugin for Sublime Text does also. Users will have to provide a "initializationOptions" to the language server which contains extra information. It would also be possible to add a lazarus project file and get the options from there but I'll let a lazarus user implement that later. Here's what I have now from a ST project file (which is plain JSON): "settings": { "LSP": { "pascal-language-server": { "enabled": true, "initializationOptions": { "FPCOptions": [ "-Fu./sources" ], "program": "./Main.pas" } } }, Great ! Incredibly looking forward to test-driving this in Atom... :-) 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
> On Apr 28, 2020, at 4:04 PM, Michael Van Canneyt > wrote: > > You can do what most VSCode/Atom project managers seem to, add package.json > or somesuch: > > { > "pascal-lsp" : { >"projectfile" : "yourproject.pas", >"searchpath" : ["a","b"] > } > } Yes, that's what the plugin for Sublime Text does also. Users will have to provide a "initializationOptions" to the language server which contains extra information. It would also be possible to add a lazarus project file and get the options from there but I'll let a lazarus user implement that later. Here's what I have now from a ST project file (which is plain JSON): "settings": { "LSP": { "pascal-language-server": { "enabled": true, "initializationOptions": { "FPCOptions": [ "-Fu./sources" ], "program": "./Main.pas" } } }, 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
On Tue, 28 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 28, 2020, at 3:45 PM, Michael Van Canneyt wrote: Why do you think so ? The codetools will find all referenced units that it finds in the unit search path. You're right. I was thinking there are going to be units that aren't referenced by the main program but why do you really want to search those anyways as they aren't actually part of the program. I'll see how it works to provide a main program file. I guess it can search for lazarus projects to insepect also but I'll leave that for later. My problems are mainly related to not having a notion of a project file like in lazarus that we can read paths from. You can do what most VSCode/Atom project managers seem to, add package.json or somesuch: { "pascal-lsp" : { "projectfile" : "yourproject.pas", "searchpath" : ["a","b"] } } And use that as a starting point. As a fallback you can scan for lpi/lpr (would be helpful for lazarus users) Most plugins I saw till now use a kind of helper file in the project dir. 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
> On Apr 28, 2020, at 3:45 PM, Michael Van Canneyt > wrote: > > Why do you think so ? The codetools will find all referenced units that it > finds in the unit search path. You're right. I was thinking there are going to be units that aren't referenced by the main program but why do you really want to search those anyways as they aren't actually part of the program. I'll see how it works to provide a main program file. I guess it can search for lazarus projects to insepect also but I'll leave that for later. My problems are mainly related to not having a notion of a project file like in lazarus that we can read paths from. 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
On Tue, 28 Apr 2020 15:34:57 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 28, 2020, at 3:26 PM, Michael Van Canneyt > > 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 loop. > 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. 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
On Tue, 28 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 28, 2020, at 3:26 PM, Michael Van Canneyt 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. Why do you think so ? The codetools will find all referenced units that it finds in the unit search path. Mattias says we can call AddStartUnit multiple times but there's no logic I can use besides adding all files in the provided directories. You don't need all files. You just need a starting point: the project. 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? You don't need all files, as far as I can see. "The references request is sent from the client to the server to resolve project-wide references for the symbol denoted by the given text document position." As far as I can tell this means: You don't need to do anything except add the project file. The codetools will use that as the starting point and that's it. 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
> On Apr 28, 2020, at 3:26 PM, Michael Van Canneyt > 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. Mattias says we can call AddStartUnit multiple times but there's no logic I can use besides adding all files in the provided directories. 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? 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
On Tue, 28 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 28, 2020, at 3:06 PM, Mattias Gaertner via fpc-pascal wrote: You can add any number of files as start. Just call AddStartUnit for every starting module. For example add all Pascal modules of the workspace directory. In TCodeToolsOptions we provide FPCOptions and ProjectDir so code tools should have a number of directories to search for. At startup does it parse these files automatically or otherwise scan for pascal files? I can rescan myself but I thought code tools may already have this loaded up and ready to us. 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. 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
> On Apr 28, 2020, at 3:06 PM, Mattias Gaertner via fpc-pascal > wrote: > > You can add any number of files as start. Just call AddStartUnit > for every starting module. > For example add all Pascal modules of the workspace directory. In TCodeToolsOptions we provide FPCOptions and ProjectDir so code tools should have a number of directories to search for. At startup does it parse these files automatically or otherwise scan for pascal files? I can rescan myself but I thought code tools may already have this loaded up and ready to us. 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
On Tue, 28 Apr 2020, Mattias Gaertner via fpc-pascal wrote: On Tue, 28 Apr 2020 09:34:36 +0700 Ryan Joseph via fpc-pascal wrote: > On Apr 28, 2020, at 4:18 AM, Mattias Gaertner via fpc-pascal > wrote: [...] 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? You can add any number of files as start. Just call AddStartUnit for every starting module. For example add all Pascal modules of the workspace directory. For clarity: a module is a program or library or lazarus package. That means you'll need to scan for it, or add some special file. TMS Software's VS Code studio plugin also requires the presence of 1 .dproj file in the top-level directory. Similar here. 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
On Tue, 28 Apr 2020 09:34:36 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 28, 2020, at 4:18 AM, Mattias Gaertner via fpc-pascal > > wrote: >[...] > 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? You can add any number of files as start. Just call AddStartUnit for every starting module. For example add all Pascal modules of the workspace directory. 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
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
Re: [fpc-pascal] Pascal Language Server
> 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
> 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
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
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
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
> 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
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; What do I supply for "SearchInCode" so that it searches the entire project (or entire folders)? 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
I'm still stuck on this problem. I can get the full proc head using CodeTool.ExtractProcHead but I can't get the name/type parameter pairs in a list (unless I do something stupid like parse the string from ExtractProcHead). I need to return the parameters in discrete pairs in text that matches the format of the header. I know ExtractProcHead finds this information but it's lost in the function before it returns. function ExtractContext(CurContext: TCodeContextInfoItem; var ParamPairs: TStringList): String; var Code: String; CurExprType: TExpressionType; CodeNode, ChildNode: TCodeTreeNode; CodeTool: TFindDeclarationTool; ParamList: TCodeTreeNode; begin CurExprType:=CurContext.Expr; Code:=ExpressionTypeDescNames[CurExprType.Desc]; if CurExprType.Context.Node<>nil then begin CodeNode:=CurExprType.Context.Node; CodeTool:=CurExprType.Context.Tool; case CodeNode.Desc of ctnProcedure: begin Code:=CodeTool.ExtractProcHead(CodeNode, [phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues, phpWithResultType]); // TODO: get param name/type pairs ParamList:=CodeTool.GetProcParamList(CodeNode); if ParamList <> nil then begin ChildNode:=ParamList.FirstChild; while ChildNode<>nil do begin Code += ChildNode.DescAsString+' '; ChildNode:=ChildNode.NextBrother; end; end; end; end; end; Result := Code; end; 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
On Sat, 25 Apr 2020 21:08:52 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 25, 2020, at 8:49 PM, Michael Van Canneyt > > wrote: > > > > It will run on a server that never installed lazarus. > > Excellent. Where are the caches kept btw? Memory. 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
On Sat, 25 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 25, 2020, at 8:49 PM, Michael Van Canneyt wrote: It will run on a server that never installed lazarus. Excellent. Where are the caches kept btw? I thought they were in the Lazarus directory but I guess not. I suspect in a file in ~/.lazarus or ~/.yourprojectname, probably the latter. Michael. 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
> On Apr 25, 2020, at 8:49 PM, Michael Van Canneyt > wrote: > > It will run on a server that never installed lazarus. Excellent. Where are the caches kept btw? I thought they were in the Lazarus directory but I guess not. 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
On Sat, 25 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 25, 2020, at 7:48 PM, Mattias Gaertner via fpc-pascal wrote: It's gpl/lgpl. Feel free to use parts. sure, but does it does it depend on other systems which are installed from Lazarus or will a stand-alone binary run on a system that never installed Lazarus? It will run on a server that never installed lazarus. 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
> On Apr 25, 2020, at 7:48 PM, Mattias Gaertner via fpc-pascal > wrote: > > It's gpl/lgpl. Feel free to use parts. sure, but does it does it depend on other systems which are installed from Lazarus or will a stand-alone binary run on a system that never installed Lazarus? 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
On Sat, 25 Apr 2020 19:43:32 +0700 Ryan Joseph via fpc-pascal wrote: > Is the following line something which can be cached? Currently this > is going to be called very often but is it an expensive operation? > Not sure what it does exactly > > Code := CodeToolBoss.FindFile(URI.Path + URI.Document); It does a binary search on the cached files. Should be barely measurable. 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
On Sat, 25 Apr 2020 19:29:41 +0700 Ryan Joseph via fpc-pascal wrote: >[...] > Since we're so invested in code tools now what is actually required > for users in terms of Lazarus? Can we just package a single binary > which links to code tools or do users need to install an entire > Lazarus setup? It's gpl/lgpl. Feel free to use parts. 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
Is the following line something which can be cached? Currently this is going to be called very often but is it an expensive operation? Not sure what it does exactly Code := CodeToolBoss.FindFile(URI.Path + URI.Document); 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
> On Apr 25, 2020, at 6:51 PM, Mattias Gaertner via fpc-pascal > wrote: > > Hmm. Maybe "make distclean" does not remove all files. I wish, you had > kept a copy. It'll probably happen again. ;) Since we're so invested in code tools now what is actually required for users in terms of Lazarus? Can we just package a single binary which links to code tools or do users need to install an entire Lazarus setup? 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
On Fri, 24 Apr 2020 15:55:44 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 3:32 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > Are there any ppu files left after "make distclean"? > > I just trashed the entire thing and started over. It was easier that > way, much easier. It's working now so I'm happy. :) Hmm. Maybe "make distclean" does not remove all files. I wish, you had kept a copy. 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
Op 25-04-2020 om 05:53 schreef Ryan Joseph via fpc-pascal In the FPC streaming system with published properties, what type do I use for an array of strings? I've tried TStringList and TCollection but they give me errors like: :: <~~ pascal-language-server 1: {'message': ' : Unsupported JSON type for object property: "jtArray"', 'code': -32603} "initializationOptions" is a JSON array of strings, i.e. 'initializationOptions': ['-Fu/path/to'] As I said before, the Cerialization-library is written with this kind of use-cases in mind. (https://gitlab.freepascal.org/Joost/cerialization) Although that what you want should be possible with the default libraries using TStringList and some events... Regards. Joost. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
On Sat, 25 Apr 2020 09:02:50 +0200 Mattias Gaertner via fpc-pascal wrote: > On Sat, 25 Apr 2020 12:03:55 +0700 > Ryan Joseph via fpc-pascal wrote: > > > I have FindCodeContext working correctly I believe because ProcName > > from TCodeContextInfo returns the correct name of the function. In > > TCodeContextInfoItem the params string list is nil though. Shouldn't > > that contain the list of parameters? Not sure how this intended to > > be used if that list of empty. > > Is X,Y inside the brackets? The TCodeContextInfoItem.ProcName is set only for compiler built-in functions. Normal functions have an Expr<>nil. See procedure TCodeContextFrm.CreateHints in lazarus/ide/codecontextform.pas 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
> On Apr 25, 2020, at 2:02 PM, Mattias Gaertner via fpc-pascal > wrote: > >> I have FindCodeContext working correctly I believe because ProcName >> from TCodeContextInfo returns the correct name of the function. In >> TCodeContextInfoItem the params string list is nil though. Shouldn't >> that contain the list of parameters? Not sure how this intended to be >> used if that list of empty. > > Is X,Y inside the brackets? You mean ()? Yes it is. ParameterIndex also increments so for example DoThis(a,b,c,^) will give ParameterIndex 4 if the cursor is at ^. Is Params supposed to be a list of the parameters in the format "name: type"? If so that's what I need to return along with the parameter index. See https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp 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
On Sat, 25 Apr 2020 12:03:55 +0700 Ryan Joseph via fpc-pascal wrote: > I have FindCodeContext working correctly I believe because ProcName > from TCodeContextInfo returns the correct name of the function. In > TCodeContextInfoItem the params string list is nil though. Shouldn't > that contain the list of parameters? Not sure how this intended to be > used if that list of empty. Is X,Y inside the brackets? 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
I have FindCodeContext working correctly I believe because ProcName from TCodeContextInfo returns the correct name of the function. In TCodeContextInfoItem the params string list is nil though. Shouldn't that contain the list of parameters? Not sure how this intended to be used if that list of empty. 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
In the FPC streaming system with published properties, what type do I use for an array of strings? I've tried TStringList and TCollection but they give me errors like: :: <~~ pascal-language-server 1: {'message': ' : Unsupported JSON type for object property: "jtArray"', 'code': -32603} "initializationOptions" is a JSON array of strings, i.e. 'initializationOptions': ['-Fu/path/to'] TInitializeParams = class(TPersistent) private fRootUri: string; fCapabilities: TClientCapabilities; fInitializationOptions: TCollection; published property rootUri: string read fRootUri write fRootUri; property capabilities: TClientCapabilities read fCapabilities write fCapabilities; property initializationOptions: TCollection read fInitializationOptions write fInitializationOptions; end; 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
> On Apr 24, 2020, at 9:44 PM, Mattias Gaertner via fpc-pascal > wrote: > >> I assumed it was just a >> reference to the current file which corresponds to the line/column >> numbers. >> >> Sorry, what do you want to see a demo of? The language server? > > Yes. The first message has the GitHub page. Of course the bugs and changes I've made are not included but I will put them up on GitHub over the weekend. What editor do you want to test on? I only know Sublime Text and Arjan can help with emacs (which i never used even once!). I'll learn VSCode eventually but its been enough to get this working with Sublime Text. 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
Op 24-04-2020 om 16:44 schreef Mattias Gaertner via fpc-pascal: On Fri, 24 Apr 2020 21:34:41 +0700 Ryan Joseph via fpc-pascal wrote: On Apr 24, 2020, at 9:28 PM, Mattias Gaertner via fpc-pascal wrote: Still FindFile instead of LoadFile? Do you get all mails from this list? I don't know what the code buffer technically is but FindFile works after the source was set previously. Ah. I didn't see any source set. ok. Thanks for the explanation. I assumed it was just a reference to the current file which corresponds to the line/column numbers. Sorry, what do you want to see a demo of? The language server? Yes. I don't know if Ryan has some changes of his own, but the project can be found here: https://github.com/arjanadriaanse/pascal-language-server Regards, Joost. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
On Fri, 24 Apr 2020 21:34:41 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 9:28 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > Still FindFile instead of LoadFile? > > > > Do you get all mails from this list? > > I don't know what the code buffer technically is but FindFile works > after the source was set previously. Ah. I didn't see any source set. ok. Thanks for the explanation. > I assumed it was just a > reference to the current file which corresponds to the line/column > numbers. > > Sorry, what do you want to see a demo of? The language server? Yes. 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
> On Apr 24, 2020, at 9:28 PM, Mattias Gaertner via fpc-pascal > wrote: > > Still FindFile instead of LoadFile? > > Do you get all mails from this list? I don't know what the code buffer technically is but FindFile works after the source was set previously. I assumed it was just a reference to the current file which corresponds to the line/column numbers. Sorry, what do you want to see a demo of? The language server? 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
On Fri, 24 Apr 2020 20:58:45 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 4:54 PM, Ryan Joseph > > wrote: > > > > I'm not able to get this one working then. Is the buffer the > > current file? This is what I'm doing: > > > > > >URI := ParseURI(textDocument.uri); > >Code := CodeToolBoss.FindFile(URI.Path + URI.Document); > >X := position.character; > >Y := position.line; > >hint := CodeToolBoss.FindSmartHint(Code, X, Y); > > > > > > Just returns an empty string but maybe the code buffer is not > > correct. > > Never mind, the line offsets are zero based so I needed to + 1 for > code manager. It's working now. Is there a demo somewhere? 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
On Fri, 24 Apr 2020 16:54:43 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 4:49 PM, Mattias Gaertner via fpc-pascal > > wrote: > >> When I hover over a function in Lazarus I get a function definition > >> and unit location. Is that coming from > >> TCodeManager.FindSmartHint? > > > > Yes > > I'm not able to get this one working then. Is the buffer the current > file? This is what I'm doing: > > > URI := ParseURI(textDocument.uri); > Code := CodeToolBoss.FindFile(URI.Path + URI.Document); Still FindFile instead of LoadFile? Do you get all mails from this list? > X := position.character; > Y := position.line; > hint := CodeToolBoss.FindSmartHint(Code, X, Y); > > > Just returns an empty string but maybe the code buffer is not correct. 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
> On Apr 24, 2020, at 4:54 PM, Ryan Joseph wrote: > > I'm not able to get this one working then. Is the buffer the current file? > This is what I'm doing: > > >URI := ParseURI(textDocument.uri); >Code := CodeToolBoss.FindFile(URI.Path + URI.Document); >X := position.character; >Y := position.line; >hint := CodeToolBoss.FindSmartHint(Code, X, Y); > > > Just returns an empty string but maybe the code buffer is not correct. Never mind, the line offsets are zero based so I needed to + 1 for code manager. It's working now. 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
> On Apr 24, 2020, at 5:28 PM, Joost van der Sluis wrote: > > I did not have a look at your code, but if you have serialization-issues, you > might consider looking at Cerialization. > (https://gitlab.freepascal.org/Joost/cerialization) > > It is what I use for my debugging-project. And it easier to adapt and extend > as the json-streaming classes that come with fpc. (Because you always have to > wait for the next fpc-version) I just barely understand the FPC serialization so I'll let Arjan decide what he wants to do on that. I does need to be resolved though because I've already had bugs appear in Sublime Text but passing in optional values as null objects. 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
Op 24-04-2020 om 11:25 schreef Arjan Adriaanse: Indeed with the current way JSON streaming is handled, optional values are not considered. This needs more work and the issue is tracked here https://github.com/arjanadriaanse/pascal-language-server/issues/7 [1]. I did not have a look at your code, but if you have serialization-issues, you might consider looking at Cerialization. (https://gitlab.freepascal.org/Joost/cerialization) It is what I use for my debugging-project. And it easier to adapt and extend as the json-streaming classes that come with fpc. (Because you always have to wait for the next fpc-version) Regards, Joost. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
On Fri, 24 Apr 2020 16:40:14 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 4:35 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > codetools that scans Lazarus packages. > > > > In Short: You can omit LAZARUSDIR. > > > > Setting PP might be useful. > > > > You can add unit and include paths: > > https://wiki.freepascal.org/Codetools#Defining_search_paths_and_macros > > Setting FPCDIR from the editor fixed the problem. I'm not crazy about > getting tons of completions from the System module though. Lots of > clutter for things I never use. Is there a way to hide those? In your loop Completion.detail:=Identifier.Node.Desc... Note: Always check if Node<>nil. You can check the unit via Tool:=Identifier.Tool; If Tool<>nil then if sametext(ExtractFilenameOnly(Tool.MainFilename),'system') then ...hide... 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
> On Apr 24, 2020, at 4:49 PM, Mattias Gaertner via fpc-pascal > wrote: > >> When I hover over a function in Lazarus I get a function definition >> and unit location. Is that coming from TCodeManager.FindSmartHint? > > Yes I'm not able to get this one working then. Is the buffer the current file? This is what I'm doing: URI := ParseURI(textDocument.uri); Code := CodeToolBoss.FindFile(URI.Path + URI.Document); X := position.character; Y := position.line; hint := CodeToolBoss.FindSmartHint(Code, X, Y); Just returns an empty string but maybe the code buffer is not correct. 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
On Fri, 24 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 24, 2020, at 4:25 PM, Arjan Adriaanse wrote: Indeed with the current way JSON streaming is handled, optional values are not considered. This needs more work and the issue is tracked here https://github.com/arjanadriaanse/pascal-language-server/issues/7 [1]. We may need to rip up your nice streaming system and iterate over properties then. Sven recently added custom attributes in the trunk which we could use to mark the published properties (I think) but then we're inside the JSON RPC library and we may lose control over this process. You'd need nullable types for 'optional' values. Your streaming library needs to be able to decide whether or not to stream an integer. AFAIK you could do that based on an attribute indicating a sentinel value which should not be streamed. You can do this with today's implementation with the OnStreamProperty event and some dictionary of 'optional' properties. TMyOptionals = specialize TDictionary; and as key use ClassName.PropName, and as value the sentinel value not to stream. Bit of a roundabout way, but at least can be done with the released FPC. I don't think that requiring trunk would be a good idea for this project. 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
On Fri, 24 Apr 2020 16:39:09 +0700 Ryan Joseph via fpc-pascal wrote: > When I hover over a function in Lazarus I get a function definition > and unit location. Is that coming from TCodeManager.FindSmartHint? Yes 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
> On Apr 24, 2020, at 4:35 PM, Mattias Gaertner via fpc-pascal > wrote: > > codetools that scans Lazarus packages. > > In Short: You can omit LAZARUSDIR. > > Setting PP might be useful. > > You can add unit and include paths: > https://wiki.freepascal.org/Codetools#Defining_search_paths_and_macros Setting FPCDIR from the editor fixed the problem. I'm not crazy about getting tons of completions from the System module though. Lots of clutter for things I never use. Is there a way to hide those? 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
When I hover over a function in Lazarus I get a function definition and unit location. Is that coming from TCodeManager.FindSmartHint? 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
On Fri, 24 Apr 2020 15:11:26 +0700 Ryan Joseph via fpc-pascal wrote: >[...] > > It does not require lazarus, but it does require the FPC source > > tree. > > Ok then. How do I setup code tools on the FPC source tree? See my mail about SimpleInit. 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
On Fri, 24 Apr 2020 10:59:21 +0200 Arjan Adriaanse wrote: > The options for initializing CodeToolsBoss are passed through > environment variables as described at > https://wiki.lazarus.freepascal.org/Codetools [1]. > > For example, mine are set up as follows through the Emacs client > settings. > > FPCDIR="/usr/lib/fpc/3.2.0/source" > LAZARUSDIR="/usr/share/lazarus" > > However, specifying the Lazarus source path does not seem to suffice > to find the units of a component like CodeTools. Therefore I would > recommend testing on simple code without many dependencies for now. The LAZARUSDIR merely sets a macro. There is no currently no code in codetools that scans Lazarus packages. In Short: You can omit LAZARUSDIR. Setting PP might be useful. You can add unit and include paths: https://wiki.freepascal.org/Codetools#Defining_search_paths_and_macros 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
> On Apr 24, 2020, at 4:25 PM, Arjan Adriaanse wrote: > > Indeed with the current way JSON streaming is handled, optional values > are not considered. This needs more work and the issue is tracked > here https://github.com/arjanadriaanse/pascal-language-server/issues/7 > [1]. We may need to rip up your nice streaming system and iterate over properties then. Sven recently added custom attributes in the trunk which we could use to mark the published properties (I think) but then we're inside the JSON RPC library and we may lose control over this process. 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
On Fri, 24 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 24, 2020, at 2:54 PM, Michael Van Canneyt wrote: What do you want to omit exactly ? For example, I'm not a lazarus user but I'm getting strange errors that don't relate to my single file program. That's going to confuse users like it did me. I'd like to omit the need to configure anything in Lazarus if possible. You don't need to configure lazarus ? You must configure the codetools used in the LSP. For non-Lazarus users it's going to be a problem. That means the language servers requires Lazarus to run at all. Not very good if we an avoid this. It does not require lazarus, but it does require the FPC source tree. Ok then. How do I setup code tools on the FPC source tree? This is something Mattias needs to answer. 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
Indeed with the current way JSON streaming is handled, optional values are not considered. This needs more work and the issue is tracked here https://github.com/arjanadriaanse/pascal-language-server/issues/7 [1]. Regards, Arjan [1] https://github.com/arjanadriaanse/pascal-language-server/issues/7 On Fri, 24 Apr 2020 16:10:47 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 3:59 PM, Arjan Adriaanse > > wrote: > > > > FPCDIR="/usr/lib/fpc/3.2.0/source" > > LAZARUSDIR="/usr/share/lazarus" > > I see now! I didn't know that but it's easy to document once we get > that far. > > btw, I'm having a problem with the fact that published un-set > properties are being set with null values. Some of the fields are > marked as optional in the protocol and returning a NULL value could > be an error which crashes the client. I don't have much experience > with streaming RTTI so I don't know how to resolve this. > > For example this "documentation" property will always be set to null > but really what want is to omit the key entirely. > > published > property documentation: TMarkupContent read fDocumentation write > fDocumentation; > > > Regards, > Ryan Joseph > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal pgps4WKflU_bC.pgp Description: OpenPGP digital signature ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
> On Apr 24, 2020, at 3:59 PM, Arjan Adriaanse wrote: > > FPCDIR="/usr/lib/fpc/3.2.0/source" > LAZARUSDIR="/usr/share/lazarus" I see now! I didn't know that but it's easy to document once we get that far. btw, I'm having a problem with the fact that published un-set properties are being set with null values. Some of the fields are marked as optional in the protocol and returning a NULL value could be an error which crashes the client. I don't have much experience with streaming RTTI so I don't know how to resolve this. For example this "documentation" property will always be set to null but really what want is to omit the key entirely. published property documentation: TMarkupContent read fDocumentation write fDocumentation; 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
The options for initializing CodeToolsBoss are passed through environment variables as described at https://wiki.lazarus.freepascal.org/Codetools [1]. For example, mine are set up as follows through the Emacs client settings. FPCDIR="/usr/lib/fpc/3.2.0/source" LAZARUSDIR="/usr/share/lazarus" However, specifying the Lazarus source path does not seem to suffice to find the units of a component like CodeTools. Therefore I would recommend testing on simple code without many dependencies for now. Regards, Arjan [1] https://wiki.lazarus.freepascal.org/Codetools On Fri, 24 Apr 2020 15:11:26 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 24, 2020, at 2:54 PM, Michael Van Canneyt > > wrote: > > > > What do you want to omit exactly ? > > For example, I'm not a lazarus user but I'm getting strange errors > that don't relate to my single file program. That's going to confuse > users like it did me. I'd like to omit the need to configure anything > in Lazarus if possible. > > > > >> For non-Lazarus users it's going to be a problem. That means the > >> language servers requires Lazarus to run at all. Not very good if > >> we an avoid this. > > > > It does not require lazarus, but it does require the FPC source > > tree. > > Ok then. How do I setup code tools on the FPC source tree? > > Regards, > Ryan Joseph > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal pgpN2Ca3xn2Ov.pgp Description: OpenPGP digital signature ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
> On Apr 24, 2020, at 3:32 PM, Mattias Gaertner via fpc-pascal > wrote: > > Are there any ppu files left after "make distclean"? I just trashed the entire thing and started over. It was easier that way, much easier. It's working now so I'm happy. :) I'm still getting that code tools error though so I wonder if it's related. 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
On Thu, 23 Apr 2020 22:11:54 +0700 Ryan Joseph via fpc-pascal wrote: > > On Apr 23, 2020, at 10:07 PM, Mattias Gaertner via fpc-pascal > > wrote: > > > > Please post the last couple of lines, e.g. starting at the last > > ppcx64 call. > > > > /bin/cp -f Makefile.compiled > units/x86_64-darwin/nogui/IDEIntf.compiled > /Applications/Xcode.app/Contents/Developer/usr/bin/make > -C components/lazdebuggergdbmi LCL_PLATFORM=nogui /bin/rm -f > units/x86_64-darwin/nogui/lazdebuggergdbmi.ppu /usr/local/bin/ppcx64 > -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -dLCL -dLCLnogui -gw > -Fu../../packager/units/x86_64-darwin > -Fu../lazutils/lib/x86_64-darwin -Fu../buildintf/units/x86_64-darwin > -Fu../../lcl/units/x86_64-darwin -Fu../debuggerintf/lib/x86_64-darwin > -Fu../../lcl/units/x86_64-darwin/nogui > -Fu../lazcontrols/lib/x86_64-darwin/nogui > -Fu../ideintf/units/x86_64-darwin/nogui -Fu. > -Fu/usr/local/lib/fpc/3.0.4/units/x86_64-darwin/rtl -FE. > -FUunits/x86_64-darwin/nogui These are the right paths. There should be a propedits.ppu in ideintf/units/x86_64-darwin/nogui > -dx86_64 lazdebuggergdbmi.pas Hint: > (11030) Start of reading config file /etc/fpc.cfg Hint: (11031) End > of reading config file /etc/fpc.cfg Free Pascal Compiler version > 3.0.4 [2018/09/30] for x86_64 Copyright (c) 1993-2017 by Florian > Klaempfl and others (1002) Target OS: Darwin for x86_64 (3104) > Compiling lazdebuggergdbmi.pas (3104) Compiling > gdbmidebugger.pp > /Users/ryanjoseph/Developer/lazarus/components/lazdebuggergdbmi/gdbmidebugger.pp(63,16) > Fatal: (10022) Can't find unit PropEdits used by GDBMIDebugger Fatal: > (1018) Compilation aborted make[1]: *** [lazdebuggergdbmi.ppu] Error > 1 make: *** [lazbuild] Error 2 Are there any ppu files left after "make distclean"? 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
> On Apr 24, 2020, at 2:54 PM, Michael Van Canneyt > wrote: > > What do you want to omit exactly ? For example, I'm not a lazarus user but I'm getting strange errors that don't relate to my single file program. That's going to confuse users like it did me. I'd like to omit the need to configure anything in Lazarus if possible. > >> For non-Lazarus users it's going to be a problem. That means the language >> servers requires Lazarus to run at all. Not very good if we an avoid this. > > It does not require lazarus, but it does require the FPC source tree. Ok then. How do I setup code tools on the FPC source tree? 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
On Fri, 24 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 24, 2020, at 2:37 PM, Mattias Gaertner via fpc-pascal wrote: fpextres.ppu is installed by default on darwin. Maybe you didn't setup codetools for your fpc units. Because of the vast amount of fpc units, codetools needs to scan them once. There is a simple init function, that uses the common environment variables PP, FPCDIR and PATH to find the fpc executable and the fpc sources. It creates a map ppu file to unit source and stores the result in the ConfigFilename. So next time it can quickly read it. I don't use Lazarus and just killed my entire install last night when I tried to rebuild. I guess I can do this in Lazarus so I'll check now. Can this not be omitted? What do you want to omit exactly ? For non-Lazarus users it's going to be a problem. That means the language servers requires Lazarus to run at all. Not very good if we an avoid this. It does not require lazarus, but it does require the FPC source tree. 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
> On Apr 24, 2020, at 2:37 PM, Mattias Gaertner via fpc-pascal > wrote: > > fpextres.ppu is installed by default on darwin. > Maybe you didn't setup codetools for your fpc units. Because of the > vast amount of fpc units, codetools needs to scan them once. There is a > simple init function, that uses the common environment variables PP, > FPCDIR and PATH to find the fpc executable and the fpc sources. It > creates a map ppu file to unit source and stores the result in the > ConfigFilename. So next time it can quickly read it. I don't use Lazarus and just killed my entire install last night when I tried to rebuild. I guess I can do this in Lazarus so I'll check now. Can this not be omitted? For non-Lazarus users it's going to be a problem. That means the language servers requires Lazarus to run at all. Not very good if we an avoid this. 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
On Fri, 24 Apr 2020 14:12:48 +0700 Ryan Joseph via fpc-pascal wrote: >[...] > In my test I'm getting an error at this block, "Parse error: unit not > found: fpextres". > > Does code tools need access to this unit? It's not part of the source > I've supplied it so I don't know why it's looking for this. fpextres.ppu is installed by default on darwin. Maybe you didn't setup codetools for your fpc units. Because of the vast amount of fpc units, codetools needs to scan them once. There is a simple init function, that uses the common environment variables PP, FPCDIR and PATH to find the fpc executable and the fpc sources. It creates a map ppu file to unit source and stores the result in the ConfigFilename. So next time it can quickly read it. CodeToolBoss.SimpleInit('~/.ChooseACacheFile'); If you need more control, look into the SimpleInit function. Keep in mind that most codetools are not threadsafe. 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
On Fri, 24 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 24, 2020, at 1:47 PM, Ryan Joseph wrote: end else begin if CodeToolBoss.ErrorMessage<>'' then writeln(stderr, 'Parse error: ',CodeToolBoss.ErrorMessage) else writeln(stderr, 'Error: no context'); end; In my test I'm getting an error at this block, "Parse error: unit not found: fpextres". Does code tools need access to this unit? It's not part of the source I've supplied it so I don't know why it's looking for this. This unit is responsible for reading resources and is part of FPC. It's probably used by one of the units you use. 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
> On Apr 24, 2020, at 1:47 PM, Ryan Joseph wrote: > >end else begin > if CodeToolBoss.ErrorMessage<>'' then >writeln(stderr, 'Parse error: ',CodeToolBoss.ErrorMessage) > else >writeln(stderr, 'Error: no context'); >end; In my test I'm getting an error at this block, "Parse error: unit not found: fpextres". Does code tools need access to this unit? It's not part of the source I've supplied it so I don't know why it's looking for this. 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
> On Apr 24, 2020, at 12:46 PM, Michael Van Canneyt > wrote: > > I fixed TCustomJSONRPCDispatcher not to add a Null in case of V2. But V1 > needs it. > see https://www.jsonrpc.org/specification_v1 > > Committed in revision 45047. Nice, it was a bug. :) So the Sublime Text people explained there was a special panel to get errors so I am seeing them now. Also it's important to flush the stderr pipe after writing to it or the messages will come out of order. However, I'm still not able to get completions despite this being the one feature which is claimed to be supported. I don't know if this is because of more errors or the completions are not what I think they are. Here is the code tools related function which gets completions at the current text offset. What does this do exactly? If there is an identifier "DoThis" in the current scope (say a function name) does this return "DoThis" if the cursor is after the word "Do"? Previously it was said "IdentifierCompletion" does this but I haven't looked into the code tools yet. function TCompletion.Process(var Params: TCompletionParams): TCompletionList; var URI: TURI; Code: TCodeBuffer; X, Y, PStart, PEnd, Count, I: Integer; Line: string; Completions: TCompletionItems; Identifier: TIdentifierListItem; Completion: TCompletionItem; begin with Params do begin URI := ParseURI(textDocument.uri); Code := CodeToolBoss.FindFile(URI.Path + URI.Document); X := position.character; Y := position.line; Line := Code.GetLine(Y); GetIdentStartEndAtPosition(Line, X + 1, PStart, PEnd); CodeToolBoss.IdentifierList.Prefix := Copy(Line, PStart, PEnd - PStart); Completions := TCompletionItems.Create; if CodeToolBoss.GatherIdentifiers(Code,X + 1,Y + 1) then begin Count := CodeToolBoss.IdentifierList.GetFilteredCount; for I := 0 to Count - 1 do begin Identifier := CodeToolBoss.IdentifierList.FilteredItems[I]; Completion := TCompletionItem(Completions.Add); Completion.insertText := Identifier.Identifier; Completion.detail:=Identifier.Node.DescAsString; Completion.insertTextFormat := TInsertTextFormat.PlainText; end; end else begin if CodeToolBoss.ErrorMessage<>'' then writeln(stderr, 'Parse error: ',CodeToolBoss.ErrorMessage) else writeln(stderr, 'Error: no context'); end; Result := TCompletionList.Create; Result.items := Completions; end; end; 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
On Fri, 24 Apr 2020, Ryan Joseph via fpc-pascal wrote: On Apr 24, 2020, at 10:23 AM, Ryan Joseph wrote: Just tested on my language server and the problem is you provided a null error key, which is not in the protocol. I've never seen the fpjsonrpc unit before so I don't know where this got inserted but it needs to be removed. I think we need to override a method to remove the null error, like this: function TLSPDispatcher.FormatResult(Const AClassName, AMethodName: TJSONStringType; Const Params,ID, Return : TJSONData) : TJSONData; begin Result:=TJSONObject.Create([ 'result',Return, TransactionProperty,ID.Clone ]); if jdoJSONRPC2 in options then TJSONObject(Result).Add('jsonrpc','2.0'); end; I fixed TCustomJSONRPCDispatcher not to add a Null in case of V2. But V1 needs it. see https://www.jsonrpc.org/specification_v1 Committed in revision 45047. 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
On Fri, 24 Apr 2020, Ryan Joseph via fpc-pascal wrote: OK, I just downloaded the laz sources and rebuilt from scratch (as usual) and it's building with the 3.3.1 now. I'm testing the server in Sublime Text and first thing I get is: LSP: invalid response payload {'id': 1, 'result': {'capabilities': {'completionProvider': {'triggerCharacters': None, 'allCommitCharacters': None, 'resolveProvider': False}, 'textDocumentSync': {'openClose': True, 'change': 1}}}, 'jsonrpc': '2.0', 'error': None} I assume this is the response from the initialize message being malformed. What client were you testing in when developing? I believe the OP was using Emacs. 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
> On Apr 24, 2020, at 10:23 AM, Ryan Joseph wrote: > > Just tested on my language server and the problem is you provided a null > error key, which is not in the protocol. > > I've never seen the fpjsonrpc unit before so I don't know where this got > inserted but it needs to be removed. I think we need to override a method to remove the null error, like this: function TLSPDispatcher.FormatResult(Const AClassName, AMethodName: TJSONStringType; Const Params,ID, Return : TJSONData) : TJSONData; begin Result:=TJSONObject.Create([ 'result',Return, TransactionProperty,ID.Clone ]); if jdoJSONRPC2 in options then TJSONObject(Result).Add('jsonrpc','2.0'); end; but I'm still not getting any results from Sublime Text. The bigger problem now however is that I'm not seeing stderr message in Sublime Text so I have no idea what's going on. There's apparently a new discord server for the LSP package so I'm going to ask questions here if you want to follow along (see link below). So anyways, I give up until I can get error messages. :) My server is socket based so I could run it in an terminal to see the output but I have no experience with stdio servers. If you have any means try Sublime Text for yourself and see if you can figure it out. The editor your using must be working though https://discordapp.com/channels/280102180189634562/645268178397560865 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
> On Apr 24, 2020, at 9:52 AM, Ryan Joseph wrote: > > LSP: invalid response payload {'id': 1, 'result': {'capabilities': > {'completionProvider': {'triggerCharacters': None, 'allCommitCharacters': > None, 'resolveProvider': False}, 'textDocumentSync': {'openClose': True, > 'change': 1}}}, 'jsonrpc': '2.0', 'error': None} Just tested on my language server and the problem is you provided a null error key, which is not in the protocol. I've never seen the fpjsonrpc unit before so I don't know where this got inserted but it needs to be removed. 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
OK, I just downloaded the laz sources and rebuilt from scratch (as usual) and it's building with the 3.3.1 now. I'm testing the server in Sublime Text and first thing I get is: LSP: invalid response payload {'id': 1, 'result': {'capabilities': {'completionProvider': {'triggerCharacters': None, 'allCommitCharacters': None, 'resolveProvider': False}, 'textDocumentSync': {'openClose': True, 'change': 1}}}, 'jsonrpc': '2.0', 'error': None} I assume this is the response from the initialize message being malformed. What client were you testing in when developing? 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
On Thu, 23 Apr 2020, 21:43 Ryan Joseph via fpc-pascal, < fpc-pascal@lists.freepascal.org> wrote: > ok, did this and now getting: > > /Users/ryanjoseph/Developer/lazarus/components/lazdebuggergdbmi/gdbmidebugger.pp(63,16) > Fatal: (10022) Can't find unit PropEdits used by GDBMIDebugger > > svn up says "At revision 63051." > > Never an easy time building lazarus for me. :) > > Regards, > Ryan Joseph > I usually revert to brute force troubleshooting in these instances: pass - va to the compiler. A lot of information, but usually the problem is close to the end so scanning the output in reverse should often reveal what is wrong. > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
Am 23.04.2020 um 16:28 schrieb Ryan Joseph via fpc-pascal: On Apr 23, 2020, at 9:11 PM, Arjan Adriaanse wrote: lazbuild --compiler=/usr/lib/fpc/3.2.0/ppcx64 pasls.lpi is there a macOS installer for 3.2? I found a link to a FTP server but I don't see this exists. Maybe fix that bug in trunk is the better idea. My lazarus sources are old also so perhaps this was fixed? You can find the macOS installer here. Despite it's name it also contains the x86_64-darwin one. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pascal Language Server
> On Apr 23, 2020, at 10:07 PM, Mattias Gaertner via fpc-pascal > wrote: > > Please post the last couple of lines, e.g. starting at the last > ppcx64 call. > /bin/cp -f Makefile.compiled units/x86_64-darwin/nogui/IDEIntf.compiled /Applications/Xcode.app/Contents/Developer/usr/bin/make -C components/lazdebuggergdbmi LCL_PLATFORM=nogui /bin/rm -f units/x86_64-darwin/nogui/lazdebuggergdbmi.ppu /usr/local/bin/ppcx64 -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -dLCL -dLCLnogui -gw -Fu../../packager/units/x86_64-darwin -Fu../lazutils/lib/x86_64-darwin -Fu../buildintf/units/x86_64-darwin -Fu../../lcl/units/x86_64-darwin -Fu../debuggerintf/lib/x86_64-darwin -Fu../../lcl/units/x86_64-darwin/nogui -Fu../lazcontrols/lib/x86_64-darwin/nogui -Fu../ideintf/units/x86_64-darwin/nogui -Fu. -Fu/usr/local/lib/fpc/3.0.4/units/x86_64-darwin/rtl -FE. -FUunits/x86_64-darwin/nogui -dx86_64 lazdebuggergdbmi.pas Hint: (11030) Start of reading config file /etc/fpc.cfg Hint: (11031) End of reading config file /etc/fpc.cfg Free Pascal Compiler version 3.0.4 [2018/09/30] for x86_64 Copyright (c) 1993-2017 by Florian Klaempfl and others (1002) Target OS: Darwin for x86_64 (3104) Compiling lazdebuggergdbmi.pas (3104) Compiling gdbmidebugger.pp /Users/ryanjoseph/Developer/lazarus/components/lazdebuggergdbmi/gdbmidebugger.pp(63,16) Fatal: (10022) Can't find unit PropEdits used by GDBMIDebugger Fatal: (1018) Compilation aborted make[1]: *** [lazdebuggergdbmi.ppu] Error 1 make: *** [lazbuild] Error 2 > >> svn up says "At revision 63051." >> >> Never an easy time building lazarus for me. :) > > Do you have local modifications? I did have some but I thought I got them merged in correctly. Perhaps not? I see the missing filling sitting right there: /Users/ryanjoseph/Developer/lazarus/components/ideintf/propedits.pp Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal