fix(lsp): Do not mark the bodies of lemmas as ghost. #1830
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves dafny-lang/ide-vscode#126 by explicitly excluding lemmas when traversing the AST to collect ghost statements.
Taking this a step further: Since @RustanLeino couldn't always reproduce the issue, I suspect there's more than just lemmas being highlighted. I have two things in mind that could lead to the situation that the bug is not easily reproducible:
GhostStateDiagnosticCollector runs even when the resolution failed. See TextDocumentLoader. The reported ghost statement in the AST might be incorrect due to this. The fix would be quite easy here: Only report ghost states for documents that resolved successfully. However, if that was the case, the error should surface not only within lemmas.
The other thing that might be worth a thought is the situation when the document moves into migrated state. That happens when the currently processed change is being canceled by a newer change. The language server then relocates the symbol table as well as the diagnostics according to this change (see DocumentDatabase). We'd either need to relocate the ghost diagnostics or discard them. Otherwise, I believe they might show invalid locations.