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

Initial support for tooltips: parse tree visualizations. #1305

Merged
merged 3 commits into from
Jun 15, 2023
Merged

Conversation

dan-zheng
Copy link
Collaborator

Dex has a reactive notebook and literate programming environment in dex web.

Tooltips add additional IDE information to the web environment, visible when hovering the cursor over code.

This initial PR adds infrastructure for tooltips, with parse tree visualizations as the first feature.

  • Backend: compiler computes a SpanTree describing all nested expression spans, based on concrete syntax trees.
  • Frontend: HTML rendering uses SpanTree to augment HTML elements with class attributes about span ranges. These span range attributes are highlighted on mouse hover.

First step towards #1304.

Demo

dex web

dex --prelude /dev/null web lib/prelude.dx 2>&/dev/null
Dex tooltips demo
Dex tooltips demo video

Exported HTML

Created via make docs.

prelude.html behaves exactly the same as the live demo above.

Dex has a reactive notebook and literate programming environment in `dex web`.

Tooltips add additional IDE information to the web environment, shown when
hovering the cursor over code.

This initial PR adds infrastructure for tooltips, with parse tree visualizations
as the first feature.

- Backend: compiler computes a `SpanTree` describing all nested expression
  spans, based on concrete syntax trees.

- Frontend: HTML rendering uses `SpanTree` to augment HTML elements with class
  attributes about span ranges. These span range attributes are highlighted on
  mouse hover.

Co-Authored-By: Dougal <d.maclaurin@gmail.com>
@dan-zheng dan-zheng added the tooling / notebooks Web notebooks and rendered HTML label Jun 14, 2023
@google-cla
Copy link

google-cla bot commented Jun 14, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@dan-zheng
Copy link
Collaborator Author

I think this PR is ready for review. I spent some time this week cleaning the code.

tests/unit/SourceInfoSpec.hs could be cleaned up and could have more testcases.

I'm happy to take a look later this week, or in a follow-up PR.

@dan-zheng dan-zheng requested a review from dougalm June 14, 2023 07:28
Copy link
Collaborator

@dougalm dougalm left a comment

Choose a reason for hiding this comment

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

Hooray! This looks great. Let's remove the unnecessary Typeable instance (as discussed off-thread) and then let's merge it.

`Typeable` instances were added to implement an older version of
TraverseSourceInfo using reflection to find all nested `SrcPosCtx` values.

This is no longer needed, as TraverseSourceInfo now only uses `Generic`, which
is more lightweight.
@dougalm dougalm merged commit ec9e052 into main Jun 15, 2023
@dan-zheng dan-zheng deleted the tooltips branch June 15, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling / notebooks Web notebooks and rendered HTML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants