Aiui Eclipse JDT (and probably other IDEs too) do something similar. It takes code that currently is not valid and tries to massage the AST until it becomes valid so that it can perform type-inference and use the type information to offer valid autocomplete suggestions even at the currently invalid location.