make content completion work again
Content completion doesn’t work at the moment. Cause might be: double parsing in
Submitted by Sebastian Erdweg on 13 September 2011 at 11:35SugarJParser
, which enables background processing.
Issue Log
Avoided double parsing when content completion is requested. Instead, the SugarJ parser uses the resulting grammar from the previous run of the SugarJ parser to incrementally parse the file and provide a completion proposal.
My first attempt was to parse the whole file with the resulting grammar. However, error recovery was not strong enough to derive helpful completion proposals then. When parsing the input incrementally this seems to work much better.
Besides, the content completion mechanism still feels “dirty”. A token like “COMPLETION12345678” is introduced into the program text at the cursor position and this text is fed into the parser. It is not at all clear that the parser will be able to figure out a useful AST in response to the “COMPLETION12345678” token. Error recovery helps, of course, but recovery is neither reliable nor predictable.
Note that the latest version also supports a new approach to content completion, where specialized completion production rules are used to provide improved, cursor-based recovery and completion behavior. Unfortunately, we don’t generate those rules yet, so you’ll have to bear with the
COMPLETION12345678
hack for the time being.
The new cursor-based runtime support can be used though with manual written completion rules, obtained by taking a prefix of the original left-hand-side and constructing a suitable abstract representation at the right hand side. Below an example for the Java ForEach construct (the @#$ is a trick to improve performance). (automatic generation of such rules is still in experimental phase)
Original production:
“for” “(” FormalParam “:” Expr “)” Stm -> Stm {cons(“ForEach”)}Completion Productions:
-> “@#$” {completion}“@#$” “for” “(” FormalParam “:” Expr “)”? -> Stm {completion, ast(“ForEach(<1>,<2>,Block([]))”)}
“@#$” “for” “(” FormalParam “:”? “)”? -> Stm {completion, ast(“ForEach(<1>,This,Block([]))”)}
Log in to post comments