lean4-htt/src/Lean
Marc Huisinga 8b8561a699
feat: improved go to definition (#9040)
This PR improves the 'Go to Definition' UX, specifically:
- Using 'Go to Definition' on a type class projection will now extract
the specific instances that were involved and provide them as locations
to jump to. For example, using 'Go to Definition' on the `toString` of
`toString 0` will yield results for `ToString.toString` and `ToString
Nat`.
- Using 'Go to Definition' on a macro that produces syntax with type
class projections will now also extract the specific instances that were
involved and provide them as locations to jump to. For example, using
'Go to Definition' on the `+` of `1 + 1` will yield results for
`HAdd.hAdd`, `HAdd α α α` and `Add Nat`.
- Using 'Go to Declaration' will now provide all the results of 'Go to
Definition' in addition to the elaborator and the parser that were
involved. For example, using 'Go to Declaration' on the `+` of `1 + 1`
will yield results for `HAdd.hAdd`, `HAdd α α α`, `Add Nat`,
``macro_rules | `($x + $y) => ...`` and `infixl:65 " + " => HAdd.hAdd`.
- Using 'Go to Type Definition' on a value with a type that contains
multiple constants will now provide 'Go to Definition' results for each
constant. For example, using 'Go to Type Definition' on `x` for `x :
Array Nat` will yield results for `Array` and `Nat`.

### Details
'Go to Definition' for type class projections was first implemented by
#1767, but there were still a couple of shortcomings with the
implementation. E.g. in order to jump to the instance in `toString 0`,
one had to add another space within the application and then use 'Go to
Definition' on that, or macros would block instances from being
displayed. Then, when the .ilean format was added, most 'Go to
Definition' requests were already handled using the .ileans in the
watchdog process, and so the file worker never received them to handle
them with the semantic information that it has available.

This PR resolves most of the issues with the previous implementation and
refactors the 'Go to Definition' control flow so that 'Go to Definition'
requests are always handled by the file worker, with the watchdog merely
using its .ilean position information to update the positions in the
response to a more up-to-date state. This is necessary because the file
worker obtains its position information from the .oleans, which need to
be rebuilt in order to be up-to-date, while the watchdog always receives
.ilean update notifications from each active file worker with the
current position information in the editor.

Finally, all of the 'Go to Definition' code is refactored to be easier
to maintain.

### Breaking changes
`InfoTree.hoverableInfoAt?` has been generalized to
`InfoTree.hoverableInfoAtM?` and now takes a general `filter` argument
instead of several boolean flags, as was the case before.
2025-07-21 15:47:44 +00:00
..
Compiler refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Data feat: improved go to definition (#9040) 2025-07-21 15:47:44 +00:00
DocString perf: do not import non-meta IR 2025-06-27 08:13:31 -07:00
Elab refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
ErrorExplanations feat: update and explain "unknown constant" and "failed to infer type" errors (#9423) 2025-07-18 19:20:31 +00:00
Language chore: allow use of the module system in all of core (#9078) 2025-06-29 13:49:27 +00:00
Linter refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Meta refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Parser refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
ParserCompiler
PrettyPrinter refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Server feat: improved go to definition (#9040) 2025-07-21 15:47:44 +00:00
Util refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Widget refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
AddDecl.lean fix: module system: remove WellFounded-specific hacks (#9143) 2025-07-02 11:58:50 +00:00
Attributes.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
AuxRecursor.lean refactor: remove binductionOn, use brecOn instead (#8820) 2025-06-17 07:07:24 +00:00
BuiltinDocAttr.lean chore: follow up on #8173 post-stage0 update (#8722) 2025-06-16 09:08:35 +00:00
Class.lean doc: add documentation for builtin attributes (#8173) 2025-06-11 09:04:37 +00:00
Compiler.lean chore: remove now-unused Lean.Compiler.AtMostOnce (#9278) 2025-07-09 14:31:15 +00:00
CoreM.lean refactor: Expose DeclNameGenerator idx (#9020) 2025-07-13 10:24:04 +00:00
Data.lean
Declaration.lean feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
DeclarationRange.lean refactor: environment extension state splitting (#8653) 2025-06-11 12:52:04 +00:00
DefEqAttrib.lean feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
DocString.lean
Elab.lean feat: add hints for missing structure instance fields (#9317) 2025-07-17 03:22:34 +00:00
EnvExtension.lean refactor: environment extension state splitting (#8653) 2025-06-11 12:52:04 +00:00
Environment.lean feat: update and explain "unknown constant" and "failed to infer type" errors (#9423) 2025-07-18 19:20:31 +00:00
ErrorExplanation.lean feat: add elaborators, completions, and hovers for named errors (#8730) 2025-06-18 15:51:34 +00:00
ErrorExplanations.lean feat: update and explain "unknown constant" and "failed to infer type" errors (#9423) 2025-07-18 19:20:31 +00:00
Exception.lean feat: update and explain "unknown constant" and "failed to infer type" errors (#9423) 2025-07-18 19:20:31 +00:00
Expr.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
HeadIndex.lean
Hygiene.lean
ImportingFlag.lean
InternalExceptionId.lean
KeyedDeclsAttribute.lean
LabelAttribute.lean
Level.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Linter.lean feat: linter.unusedSimpArgs (#8901) 2025-06-22 09:10:21 +00:00
LoadDynlib.lean
LocalContext.lean feat: add usedLetOnly to LocalContext binder functions (#9131) 2025-07-01 18:41:49 +00:00
Log.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Message.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Meta.lean feat: add Meta.letToHave and the let_to_have tactic (#8954) 2025-06-24 01:33:53 +00:00
MetavarContext.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Modifiers.lean fix: assorted module system fixes (#9406) 2025-07-16 13:31:08 +00:00
MonadEnv.lean feat: update and explain "unknown constant" and "failed to infer type" errors (#9423) 2025-07-18 19:20:31 +00:00
Namespace.lean
Parser.lean
ParserCompiler.lean refactor: migrate to new ranges (#8841) 2025-07-07 12:41:53 +00:00
PremiseSelection.lean
PrettyPrinter.lean feat: prettier expected type mismatch error message (#9099) 2025-07-01 07:50:53 +00:00
PrivateName.lean
ProjFns.lean
ReducibilityAttrs.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Replay.lean
ReservedNameAction.lean feat: make equational theorems of non-exposed defs private (#8519) 2025-06-04 11:52:08 +00:00
ResolveName.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Runtime.lean
ScopedEnvExtension.lean fix: do not export private instances (#9407) 2025-07-16 18:59:48 +00:00
Server.lean
Setup.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Shell.lean feat: ignore lean -R if module name is in setup (#8874) 2025-06-23 17:55:52 +00:00
Structure.lean refactor: migrate to new ranges (#8841) 2025-07-07 12:41:53 +00:00
SubExpr.lean refactor: remove Lean.RBMap usages (#9260) 2025-07-21 14:04:45 +00:00
Syntax.lean refactor: migrate to new ranges (#8841) 2025-07-07 12:41:53 +00:00
ToExpr.lean
ToLevel.lean
Util.lean feat: server support for new module setup (#8699) 2025-06-23 18:00:14 +00:00
Widget.lean