Skip to content

feat: add range parameter to getInteractiveDiagnostics - #722

Merged
Kha merged 1 commit into
masterfrom
intdiagrange
Oct 11, 2021
Merged

Kha merged 1 commit into
masterfrom
intdiagrange

Conversation

@gebner

@gebner gebner commented Oct 11, 2021

Copy link
Copy Markdown
Member

Currently, getInteractiveDiagnostics blocks until the whole file is processed. This means that the infoview hangs and doesn't show diagnostics. See e.g. Julian/lean.nvim#162

This PR adds a range parameter to the getInteractiveDiagnostics RPC call:

interface LineRange {
  start: number;
  end: number;
}

interface GetInteractiveDiagnosticsParams {
  /** Only return diagnostics for the specified range. */
  lineRange?: LineRange;
}

If lineRange is present, the server will only wait until the document has finished processing up to the end position. Furthermore only diagnostics whose fullRange intersects the range parameter are returned. This also solves another potential performance issue by significantly reducing the amount of diagnostics that are sent.

Tested using Julian/lean.nvim#169

structure LineRange where
start : Nat
«end» : Nat
deriving Inhabited, Repr, RpcEncoding

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two types should be in Lsp/Extra.lean. It should also suffice to derive From/ToJson instead of RpcEncoding as this contains no RPC refs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved. I didn't want to put it there at first because it's not an LSP type (and other types used in RPC are not defined there either).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, that's because of dependency issues with types that derive RpcEncoding (which Extra.lean can't import iirc). But every type that we can, we should put in Extra.lean whose point is to collate all our additions to LSP. So I would put the GetInteractiveDiagnosticsParams there as well (and also only derive From/ToJson for it, RpcEncoding has an umbrella instance for JSON-encodable types).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait no, I forgot RPC calls are all one LSP request 🤦 Okay, let's leave the Params here for now. I will add a file similar to Lsp/Extra.lean describing all RPC requests later.

@Kha
Kha merged commit d6ba8e5 into master Oct 11, 2021
@gebner
gebner deleted the intdiagrange branch July 11, 2022 13:07
ChrisHughes24 pushed a commit to ChrisHughes24/lean4 that referenced this pull request Dec 2, 2022
mathlib3 SHA: 6b3325cdf0b4b23496391a451324c95a1dc36d9e

porting notes:
* overall, very straightforward
* I made `GroupWithZero` extend `Nontrivial` to match mathlib3, and we didn't have this instance previously because it didn't extend that class.

Co-authored-by: Scott Morrison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants