google / google/codeworld

Better parsing for extracting autocomplete/hint options from source code

Aperta
#798 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Haskell
Stelle
1.3k
Fork
201
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.