kkawakam / rustyline

Readline Implementation in Rust
https://crates.io/crates/rustyline/
MIT License
1.54k stars 177 forks source link

Common information sharing for helper components #427

Open suikabreaker opened 4 years ago

suikabreaker commented 4 years ago

It would be helpful for different components of helper, e.g. , completer and hinter, to share some information.

Completer and hinter may both take item from a candidate list.

Furthermore, they may share the intermidiate parsing result to avoid parsing input multiple times and replicating calls to parsing code.

gwenn commented 4 years ago

See: https://github.com/kkawakam/rustyline/blob/bc687690309a0c4cd4f67fbff8f7569250b816c2/BUGS.md#document--syntax

Because, when you have tokens (which may be as simple as words) or an AST, completion / suggestion / highlighting / validation become easy. So we need to send events to a lexer/parser, update Document accordingly. And fix Completer / Hinter / Highlighter API such as they have access to Document.

https://github.com/kkawakam/rustyline/issues/207#issuecomment-503204915

For one syntax, Hinter, Highlighter and Completer, Validator should/would/will be correlated. Because they should/would/will share the same Tokenizer/Parser. Currently, each one parses the same input...