Better parsing for extracting autocomplete/hint options from source code
- Dominant language
- Haskell
- Stars
- 1.3k
- Forks
- 201
- PR merge metrics
- No merged PRs in 30d
Description
There's some existing code for finding type declarations in the current module, and augmenting the autocomplete list with them. @nixorn is extending that to his new doc-on-hover feature, as well. However, the extraction code isn't all that great right now. Specifically:
1. It only looks at one line at a time. This generates incorrect results when the type declaration is wrapped across lines.
2. It mis-parses some syntax. For example `pic1,pic2 :: Picture` will add a single item called `pic1,pic2`, when it should add separate items for both of the two pictures.
3. It would be nice to extend the parsing to recognize definition lines (like `f x = sqrt x + 1`). Type inference isn't needed here, but I think it would be great if that gave `f` an incomplete type in autocomplete and docs, like `f :: ? -> ?`. Of course, an explicit type signature should replace the incomplete definition with a complete one.
4. When extraction does succeed, it still leaves unnecessary formatting in place. So if the original source code says:
short :: Number
reallyReallyVeryVeryLong :: Number
the extracted doc for `short` will have all those spaces between `short` and `::`, even though those extra spaces aren't sensible in the new context.
One must probably resist the temptation to completely reimplement the Haskell parser in JavaScript, but I think enough special cases could go a long way.
Contributor guide
Assessment
This issue has not been assessed yet.