Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish versioned diagnostics #716

Open
radeksimko opened this issue Nov 17, 2021 · 0 comments
Open

Publish versioned diagnostics #716

radeksimko opened this issue Nov 17, 2021 · 0 comments

Comments

@radeksimko
Copy link
Member

radeksimko commented Nov 17, 2021

Background

Prior to #714 we would only (re)publish diagnostics as part of RPC request handlers, which reduced the chance of publishing outdated diagnostics as we wouldn't respond to the original didChange request until diagnostics were actually published.

For (practical) reasons described in the linked PR however there is now some chance that the user is briefly presented with outdated diagnostics as they get published continuously, as we finish (re)parsing of any file/module.

Use-cases

Reduce the chance of user being presented with outdated diagnostic by letting client drop any diagnostics which are associated with old versions of a document.

Attempted Solutions

Diagnostic publishing coupled with RPC request handling, as mentioned.

Proposal

Obtain last document version before parsing it within parser.ParseModuleFiles() and parser.ParseVariableFiles()

func ParseModuleFiles(fs FS, modPath string) (ast.ModFiles, ast.ModDiags, error) {

func ParseVariableFiles(fs FS, modPath string) (ast.VarsFiles, ast.VarsDiags, error) {

and track it for each diagnostic, possibly by repurposing ast.ModFilename as ast.ModFileVersion and ast.VarsFilename as ast.VarsFileVersion to hold both the filename and version.

type ModFilename string

type VarsFilename string

That way we might be able to eventually read it from where we eventually publish the diagnostics, i.e.

if err := jrpc2.ServerFromContext(d.ctx).Notify(d.ctx, "textDocument/publishDiagnostics", lsp.PublishDiagnosticsParams{
URI: d.uri,
Diagnostics: d.diags,
}); err != nil {

Pending Questions

  • What implications does this have for validate diagnostics?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants