Content completion doesn’t work at the moment. Cause might be: double parsing in SugarJParser, which enables background processing.

Submitted by Sebastian Erdweg on 13 September 2011 at 11:35

On 13 September 2011 at 11:36 Sebastian Erdweg tagged plugin

On 13 September 2011 at 11:36 Sebastian Erdweg tagged editor_services

On 9 October 2011 at 18:19 Sebastian Erdweg commented:

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.


On 9 October 2011 at 18:19 Sebastian Erdweg closed this issue.

On 9 October 2011 at 18:22 Lennart Kats tagged !maartje

On 9 October 2011 at 18:27 Lennart Kats commented:

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.


On 10 October 2011 at 12:17 Maartje commented:

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([]))”)}


On 10 October 2011 at 12:21 Lennart Kats removed tag !maartje

Log in to post comments