nextflow-io / language-server

The Nextflow language server
Apache License 2.0
0 stars 0 forks source link

Support Groovy classes in `lib` directory #18

Closed bentsherman closed 3 weeks ago

bentsherman commented 2 months ago

Close #4

Adds a custom Groovy AST cache to compile Groovy classes in the lib directory, and provide them to the ResolveVisitor. It mostly works, some expressions aren't being resolved correctly though.

The main challenge that remains is to keep the cache up to date as the user edits. I could implement full language support for *.groovy files and hook into all of the lifecycle events, but I probably wouldn't want to extend it to all Groovy files. Maybe it could work if I manage only the lib directory. Or I could add the lib directory to the list of "watched files" and update that way.

Also, the classes in the lib directory are automatically exported to all Nextflow scripts, so if I update something in the lib directory, all Nextflow scripts would have to be re-compiled. Maybe we should require lib classes to be explicitly imported by a module via include statement, so that the static analysis can be more efficient. Probably would make the Nextflow scripts more readable too.

bentsherman commented 2 months ago

Really the only thing to be updated for Nextflow scripts is name checking and beyond, they don't need to be re-parsed. That's probably good enough for a first iteration. Making the includes explicit would be a nice improvement in the future

bentsherman commented 3 weeks ago

Maybe I can just re-compile the entire lib directory every time the ast cache is updated. I could even check the file timestamps to see if they were changed.

bentsherman commented 3 weeks ago

Merged via 3583c60d255eb8f684624ac1cd78616eecab84c9