Skip to content

Mechanism for libraries to add information to IDE documentation/tooltip #1993

Closed

Description

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.

Activity

  1. timotheeguerin commented on May 31, 2023

    @timotheeguerin
    Member

    what if we have some internal decorator/helper that is @ideDoc(

    Guess the problem is when do you call that:

    • in a decorator: might not have the bigger picture yet
    • in onValidate: you shouldn't modify the graph at this point
    • a new lifecycle hook? onLsp?
  2. nguerrera commented on May 31, 2023

    @nguerrera
    ContributorAuthor

    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?

  3. nguerrera commented on May 31, 2023

    @nguerrera
    ContributorAuthor

    That's probably clumsy. This isn't "validation".

  4. timotheeguerin commented on May 31, 2023

    @timotheeguerin
    Member

    yeah, would be an "easy" solution but not clean

  5. nguerrera commented on Jun 19, 2023

    @nguerrera
    ContributorAuthor

    I think the new lifecycle hook could work.

    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.

  6. nguerrera commented on Jun 19, 2023

    @nguerrera
    ContributorAuthor

    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.

  7. timotheeguerin commented on Jun 19, 2023

    @timotheeguerin
    Member

    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.

  8. nguerrera commented on Jun 19, 2023

    @nguerrera
    ContributorAuthor

    True!

  9. nguerrera commented on Jun 19, 2023

    @nguerrera
    ContributorAuthor

    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.

  10. timotheeguerin commented on Jun 20, 2023

    @timotheeguerin
    Member

    That it a good point, maybe we need some order where you can say you onAugment should run after all the other onAugment

  11. nguerrera commented on Jun 20, 2023

    @nguerrera
    ContributorAuthor

    This is bringing back memories of plugin systems that have a "priority" you can return and then someone returns +/- Infinity.

  12. nguerrera commented on Jun 26, 2023

    @nguerrera
    ContributorAuthor

    Notes for discussion today

    Proof-of-concept: #2116

    • more general approach
    • new onAugment added alongside onEmit and onValidate
    • new @ideDoc decorator
    • onAugment is generally provided to allow a library to add decorators once an otherwise complete whole view of the world is completed.
    • runs before onValidate
    • could have done this in onValidate but 1) this is not validation, 2) what if you want to validate the result of this augmentation.
    • adds yet another pass (over all routes in HTTP case, other emitters/libs could also end up making more redundant computation)
    • what if one onAugmnet handler wants to base its decisions on the results of another, how to order them?

    Alternative (not implemented):

    • IDE specific callback to get additional docs for a given entity
    • e.g. library could register handler somehow for getIDEDocumentation(Program, Type)
    • solves ordering issues since we no longer need to change the type graph just answer questions about it
    • but less general purpose
    • if handled naively could lead to even more redundant work, recomputing all the routes for each hover for example (!)
  13. nguerrera commented on Jun 26, 2023

    @nguerrera
    ContributorAuthor

    Summary of discusssion today:

    1. route-in-tooltip not a sufficient motivating feature.
    2. We should not add another phase for this, the costs are too high.
    3. We can either look at the alternative described above or look if we can find a way to have this happen during the decoration phase somehow.

    But without a high-pri motivating feature, we can leave this on the backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design:neededA design request has been raised that needs a proposal

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions