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

[inspector] Unify inspector entrypoints #244

Merged
merged 3 commits into from
Apr 22, 2024
Merged

[inspector] Unify inspector entrypoints #244

merged 3 commits into from
Apr 22, 2024

Conversation

alexander-yakushev
Copy link
Member

@alexander-yakushev alexander-yakushev commented Apr 22, 2024

I tried to make sense of all the ways to initiate a new inspection or re-inspection – start, fresh, clear. The problem with current state is that "an empty inspector" is not really a thing, it has to be inspecting something. So, an API call like (fresh) doesn't really make sense. Also, reusing an inspector to inspect a new object (unrelated to the current one) actually means only reusing the dynamically changed config (page size, truncation limits, etc.); we don't want to reuse any part of the state.

The updated API has start as the single entrypoint into an inspector. 1-arg takes a value to be inspected and returns a rendered inspector object. 2-arg takes a value and the config. An already existing inspector object can be passed as the config. There are no other legal ways to obtain a new inspector object besides start.

fresh and clear functions were retained and marked as deprecated in case somebody uses them.

  • You've added tests to cover your change(s)
  • All tests are passing
  • You've updated the changelog (if adding/changing user-visible functionality)

Inspector object should not be nil, this should be ensured by the caller (e.g.
cider-nrepl).
@bbatsov
Copy link
Member

bbatsov commented Apr 22, 2024

I agree that the current API is weird. That's mostly related to the fact that some parts of it are as old as swank-clojure from where this code was originally imported:

Originally it was part of swank-clojure, afterwards it was moved to
javert, then forked to another project from which it
was contributed to cider-nrepl. Finally cider-nrepl
was split into two libraries and the code ended up here.

It's great you're pushing forward some efforts to clean up the codebase.

fresh and clear functions were retained and marked as deprecated in case somebody uses them.

I'm around 99% sure cider-nrepl is the only user of this part of Orchard, but that's a prudent move regardless.

:current-page 0, :rendered [], :indentation 0}))
(def ^:private default-inspector-config
"Default configuration values for the inspector."
{:page-size 32
Copy link
Member

Choose a reason for hiding this comment

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

In light of our previous conversation we might also add a couple of short comments explaining how the defaults were chosen.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add comments to those where the default isn't completely arbitrary.

@alexander-yakushev alexander-yakushev marked this pull request as ready for review April 22, 2024 07:37
@bbatsov
Copy link
Member

bbatsov commented Apr 22, 2024

One more thought about this PR - perhaps it'd be even better to add a function called inspect (start can be it's alias), as I think this reflects better how the inspector works - you said yourself it needs a value to inspect.

@alexander-yakushev
Copy link
Member Author

This makes sense, but we already have inspect in the namespace (public no less) which is an intermediate multimethod. Renaming all those methods to something else is possible but it's easier to leave this as is.

@bbatsov
Copy link
Member

bbatsov commented Apr 22, 2024

This makes sense, but we already have inspect in the namespace (public no less) which is an intermediate multimethod. Renaming all those methods to something else is possible but it's easier to leave this as is.

Fair enough. I didn't notice the existing inspect multimethod.

@bbatsov bbatsov merged commit ea3651f into master Apr 22, 2024
57 checks passed
@bbatsov bbatsov deleted the inspector-refactor branch April 22, 2024 11:19
@alexander-yakushev alexander-yakushev added the enhancement Improvement to an existing feature label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants