You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mechanism for libraries to add information to IDE documentation/tooltip #1993
Some folks have asked for things like showing the effective full HTTP route when hovering over an operation. Today, the docs shown on hover are limited to doc comments, @doc, and core language aspects of the entity. Computing the HTTP route is specific to the @cadl-lang/http library so we would need some sort of extensibility here so that the library could provide this data to the IDE.
Great point. Maybe if instead of a decorator, we had a dedicated compiler API like addIDEDoc that is explicitly blessed to be safe to call in onValidate?
Maybe we can have something more general in name than onLSP, like onAugment that is generally there to to allow adding additional decorators dynamically. I think this would run first, right after compilation, before validation.
Then a new decorator like @hover that an onAugment handler could add dynamically with a complete picture of the program.
One downside is that I think we're already repeating computation between onValidate and onEmit and we will likely compute the routes a third time for this.
One downside is that I think we're already repeating computation between onValidate and onEmit and we will likely compute the routes a third time for this.
Though it we assume onAugment can change the type graph(which is the point), it probably should be recomputed anyway.
Another possible concern. If I have one lib that uses onAugment to change HTTP routes (which we'd say is OK) and http lib uses it to add route to hover, then there's still a race.
Activity
timotheeguerin commentedon May 31, 2023
what if we have some internal decorator/helper that is
@ideDoc(Guess the problem is when do you call that:
onValidate: you shouldn't modify the graph at this pointonLsp?nguerrera commentedon May 31, 2023
Great point. Maybe if instead of a decorator, we had a dedicated compiler API like
addIDEDocthat is explicitly blessed to be safe to call inonValidate?nguerrera commentedon May 31, 2023
That's probably clumsy. This isn't "validation".
timotheeguerin commentedon May 31, 2023
yeah, would be an "easy" solution but not clean
nguerrera commentedon Jun 19, 2023
I think the new lifecycle hook could work.
Maybe we can have something more general in name than onLSP, like
onAugmentthat is generally there to to allow adding additional decorators dynamically. I think this would run first, right after compilation, before validation.Then a new decorator like
@hoverthat an onAugment handler could add dynamically with a complete picture of the program.nguerrera commentedon Jun 19, 2023
One downside is that I think we're already repeating computation between onValidate and onEmit and we will likely compute the routes a third time for this.
timotheeguerin commentedon Jun 19, 2023
Though it we assume
onAugmentcan change the type graph(which is the point), it probably should be recomputed anyway.nguerrera commentedon Jun 19, 2023
True!
nguerrera commentedon Jun 19, 2023
Another possible concern. If I have one lib that uses onAugment to change HTTP routes (which we'd say is OK) and http lib uses it to add route to hover, then there's still a race.
timotheeguerin commentedon Jun 20, 2023
That it a good point, maybe we need some order where you can say you
onAugmentshould run after all the otheronAugmentnguerrera commentedon Jun 20, 2023
This is bringing back memories of plugin systems that have a "priority" you can return and then someone returns +/- Infinity.
nguerrera commentedon Jun 26, 2023
Notes for discussion today
Proof-of-concept: #2116
onAugmentadded alongsideonEmitandonValidate@ideDocdecoratoronAugmentis generally provided to allow a library to add decorators once an otherwise complete whole view of the world is completed.onValidateonValidatebut 1) this is not validation, 2) what if you want to validate the result of this augmentation.Alternative (not implemented):
getIDEDocumentation(Program, Type)nguerrera commentedon Jun 26, 2023
Summary of discusssion today:
But without a high-pri motivating feature, we can leave this on the backlog.
feat(compiler): add experimental $provideTypeInfo provider and progra…