I have seen GoWorks has implemented code auto code completion using ANTLR4, but I am more curious to know -1. How is it handling the cases when there are errors before caret position ?
2. Does it require to write the extra grammar rule to handle the error cases ?
Mike’s statement here isn’t precise. GoWorks includes several mechanisms intended to avoid the loss of code completion performance or accuracy in the case of errors (including those which appear before the caret). A more accurate statement would be:
There are cases where code completion will not perform in the event of an error before the caret. The “severity” of the error (from the perspective of the parser) as well as the proximity to the caret correlate with the impact on code completion.
The overall intent is code completion should not be impacted by code which is not visible on screen (out of sight, out of mind). Specific mechanisms involved in this include:
The restart points for the code completion, hover tips, smart indent, and other related features are called “anchor points”, and come in two forms. The first is reference anchor points. These are calculated and cached following a successful parse of the entire file. The second is called dynamic anchor points, which I intended to calculate as a modification to the reference anchor points using incomplete information following parse operations with errors. However, in practice I found that the reference anchor points alone performed so well that I never added the secondary logic.
Sam
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mike’s statement here isn’t precise. GoWorks includes several mechanisms intended to avoid the loss of code completion performance or accuracy in the case of errors (including those which appear before the caret). A more accurate statement would be:There are cases where code completion will not perform in the event of an error before the caret. The “severity” of the error (from the perspective of the parser) as well as the proximity to the caret correlate with the impact on code completion.The overall intent is code completion should not be impacted by code which is not visible on screen (out of sight, out of mind). Specific mechanisms involved in this include:
- Symbol and navigation information from previous versions of a file are not discarded from caches until a file parses correctly, so code completion can continue to reference these symbols while a user is typing.
- Code completion doesn’t attempt to parse the entire file, but instead starts as close to the caret as possible.
The restart points for the code completion, hover tips, smart indent, and other related features are called “anchor points”, and come in two forms. The first is reference anchor points. These are calculated and cached following a successful parse of the entire file. The second is called dynamic anchor points, which I intended to calculate as a modification to the reference anchor points using incomplete information following parse operations with errors. However, in practice I found that the reference anchor points alone performed so well that I never added the secondary logic.