garetht / intellij-dhall

A Dhall plugin for IntelliJ IDEs
7 stars 1 forks source link

How to get started developing this plugin further? #27

Open winitzki opened 1 month ago

winitzki commented 1 month ago

This Dhall plugin seems to be unmaintained. I am interested in developing this plugin further. I would like to make it a full-featured plugin that enables productive working with Dhall source files.

I have recently implemented a Dhall binding in Scala - https://github.com/winitzki/scall That code uses fastparse for parsing and fully implements the most recent Dhall standard (all tests pass). So, I am quite familiar with both Dhall, its design and implementation, and with Scala / SBT. However, I am not at all familiar with IntelliJ plugin development / platform.

Where would I begin if I waned to make changes to the Dhall plugin so that the parsing is more up to date with the current revision of Dhall? How do I implement "go to definition", "show usages" and so on? I'd appreciate any help and pointers to documentation or sample code.

garetht commented 1 month ago

Hi! Sadly this plugin is not currently maintained, but I'm open to it if I have time in the future. Glad to hear you've made a Scala parser for Dhall.

This is the reference that should be used for IntelliJ plugin development for a custom language: https://plugins.jetbrains.com/docs/intellij/custom-language-support.html. I haven't done any of what I mention here before, so definitely follow the documentation if it contradicts what I say.

The first and least documented step is correctly mapping the fastparse AST into the IntelliJ AST format using PSIBuilder. There is a diagram for this here: https://plugins.jetbrains.com/docs/intellij/implementing-parser-and-psi.html#parser-implementation. However, IntelliJ's documentation is focused mostly on doing this with their GrammarKit utility - perhaps searching for other plugin implementations that use PSIBuilder directly could be useful.

Once a compatible IntelliJ AST is produced, how to implement most of the other features should be covered in the plugin documentation. Let me know if I can help, but I may sometimes take a while to respond.

winitzki commented 1 month ago

Hi! Thank you for your response. Let me just ask some quick questions.

  1. The current code of the plugin uses a BNF grammar with some jflex / jlex generated code. Does it make more sense to continue using the same BNF grammar with some changes in the BNF file, or is it better to create the PSI structure directly from the result of fastparse? One of the problems with fastparse is recursion depth limitation (stack overflow) when parsing deeply nested expressions. Is the jlex generated code stack-safe and can it parse arbitarily deeply nested expressions? How can I generate the parser code locally from the BNF grammar in the current code?
  2. I have opened a PR to update some dependencies so that I can at least load the current plugin code into IntelliJ and import build.sbt without dependency errors. The PR is here: https://github.com/garetht/intellij-dhall/pulls But I don't really know what to do after that. How can I test locally that the plugin works after my update?