broadinstitute / wdl-ide

Rich IDE support for Workflow Description Language
BSD 3-Clause "New" or "Revised" License
40 stars 8 forks source link

Implement auto-completion #6

Open dinvlad opened 4 years ago

dinvlad commented 4 years ago

Currently, the MiniWDL package we're using to parse a WDL tree, validates it first. If we have "partial" input like during typing for auto-complete, it will be considered an "invalid" WDL and so it will not produce the tree to understand which context to apply the completion to.

One way to overcome this could be to not call MiniWDL upon a textDocument/completion request, but rather try to see if there's already a cached version of the tree (parsed by MiniWDL before the user started typing). If there's one, we could re-use it and understand which completion items to return back to the user, based on the cursor position in the document.

Additionally, whenever there's intent to auto-complete, we should "block" or "delay" automatic re-validation of the document (which happens every time the user "stops" typing for 500ms or more), so that we don't just display errors when the user expects something useful to return.

Another (more significant) limitation is that MiniWDL does not return "tree nodes" for every piece of WDL we'd like to auto-complete. So some syntax tokens will be entirely missed with this strategy. We could ask MiniWDL library owners to add those to the tree, but that could be quite a lot of work. I think we could start simple and see how much (if anything) needs to be amended.