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

Simple highlighting #398

Merged
merged 5 commits into from
Jul 25, 2023
Merged

Simple highlighting #398

merged 5 commits into from
Jul 25, 2023

Conversation

kimo-k
Copy link
Contributor

@kimo-k kimo-k commented Jul 20, 2023

No description provided.

This solves a dependency conflict over borkdude/edamame. We barely use
malli, so there's no breakage.
This solves a dependency conflict over rewrite-clj.
`find-bounds` & its helpers aren't really view logic, IMO.
They also seem like a reverse-engineering of our own libraries.

I think we can delete them soon, so this is a step on the way.

Next steps:

- rewrite-clj records the string position of each form it parses
- build a highlighter from rewrite-clj (in the following commit)
- build re-frame.trace from rewrite-clj (I think it's doable)

Once this is done, all our code will understand the position of forms,
and we won't have to do any regex reverse-engineering.
The highlight.js integration has been costly to maintain, both for
day8 and for our users. See:

#376

Now, we use rewrite-clj and reagent for minimalistic
highlighting. This is similar to borkdude's approach:

https://blog.michielborkent.nl/writing-clojure-highlighter.html

rewrite-clj labels forms by their type and purpose. It provides a
zipper api for expressive traversal, including line & char
numbers.

Now, we simply transform rewrite-clj's node tree into hiccup. We do
two post-order traversals, which isn't ideal, but it works. We could
consolidate the traversal with some careful refactoring.

TODO: ::highlighted-form-bounds is mostly regex math which
reverse-engineers the output of re-frame-debux. Now, ::highlighted?
adds another layer of reverse-engineering. It seems like we could
delete all this calculation, and delete zprint, if re-frame-debux
could simply provide the node tree.

re-frame-debux could also provide some analysis data from clj-kondo,
making it possible to color locals differently from globals, for
instance.
@kimo-k kimo-k merged commit 16a423d into master Jul 25, 2023
2 checks passed
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.

1 participant