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

Stacktrace at point or in region #758

Merged
merged 13 commits into from
Nov 26, 2022

Conversation

r0man
Copy link
Contributor

@r0man r0man commented Sep 18, 2022

This PR adds Stacktrace at point or in region support.

Please see: clojure-emacs/orchard#164


Before submitting a PR make sure the following things have been done:

  • The commits are consistent with our contribution guidelines
  • You've added tests to cover your change(s)
  • All tests are passing
  • The new code is not generating reflection warnings
  • You've updated the README (if adding/changing middleware)

@bbatsov
Copy link
Member

bbatsov commented Sep 19, 2022

Looks good, failing CI aside.

:optional wrap-print-optional-arguments
:optional (assoc wrap-print-optional-arguments "stacktrace" "The stacktrace to be parsed and analyzed as a string.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbatsov @vemv I am wondering if I should a new "parse stacktrace" op instead off adding this new optional parameter? It feels cleaner instead of hijacking the existing op to me. Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I agree. Generally we've been using action-like names for most ops (e.g. eval, clone, etc), so the stacktrace op was named somewhat poorly in that regard anyways, as it was super clear what does it do by its name alone.

@@ -437,7 +437,11 @@ Depending on the type of the return value of the evaluation this middleware may
:expects #{}
:handles {"stacktrace" {:doc "Return messages describing each cause and stack frame of the most recent exception."
:optional wrap-print-optional-arguments
:returns {"status" "\"done\", or \"no-error\" if `*e` is nil"}}}}))
:returns {"status" "\"done\", or \"no-error\" if `*e` is nil"}}
"parse-stacktrace" {:doc "Parse the `stacktrace` and return messages describing each cause and stack frame."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbatsov I added a new op called parse-stacktrace. Are you fine with this name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think I rename it to analyze-stacktrace ...

:requires {"stacktrace" "The stacktrace to be parsed and analyzed as a string."}
:optional wrap-print-optional-arguments
:returns {"status" "\"done\", or \"no-error\" if `stracktrace` is not recognized"}}
"stacktrace" {:doc "Return messages describing each cause and stack frame of the most recent exception."
Copy link
Member

Choose a reason for hiding this comment

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

We can also add some alias for this op with a more descriptive name - e.g. analyze-last-stacktrace or something like this. Or we can consider the new name an alias of the old one and make them behave the same way with/without an explicit stacktrace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I like analyze-last-stacktrace but how would you do this alias? Just adding a new op and pointing to the same implementation? How do we deprecate the old one?

I think your second suggestion is what I had before (minus the rename). If the stacktrace parameter is present it would parse and analyze the value from the parameter, otherwise use the last exception when present. I think I would prefer separating those 2 ops, but up to you, I'm also fine with the optional parameter.

Copy link
Member

Choose a reason for hiding this comment

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

I think I like analyze-last-stacktrace but how would you do this alias? Just adding a new op and pointing to the same implementation? How do we deprecate the old one?

Yeah, just a new pointing to the same implementation. At some point it might be nice to add better support for this to nREPL itself. As for the deprecation - some note in the docs will do. You can also use notify-client to send them deprecation messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbatsov I added the analyze-last-stacktrace op and made the stacktrace op deprecated. The deprecation is reflected in the docs and the stacktrace op also does send a notification to the user. I am not sure if this is a good idea, because I had to make a change in Cider to handle this notification in the response. See here:
clojure-emacs/cider@0d0633a#diff-e5e7f12a3638dc838dbd4f61a5bd797efc0ac6120e58c80ec1a92970eea3a27cR479

I don't know which clients we have, but if they don't handle notification messages in a stacktrace response they might break. So I would suggest removing the client notification to not break anyone and just mark the stacktrace op deprecated in the docs. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Fair point about some clients probably not supporting this (I'm surprised we forgot to add it to CIDER :D ), so I guess we can just rely on a deprecation in the docs.

project.clj Outdated
@@ -8,7 +8,8 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:scm {:name "git" :url "https://github.com/clojure-emacs/cider-nrepl"}
:dependencies [[nrepl "1.0.0"]
^:inline-dep [cider/orchard "0.10.0" :exclusions [com.google.code.findbugs/jsr305 com.google.errorprone/error_prone_annotations]]
^:inline-dep [cider/orchard "0.0.0" :exclusions [com.google.code.findbugs/jsr305 com.google.errorprone/error_prone_annotations]]
Copy link
Member

Choose a reason for hiding this comment

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

What's 0.0.0?

(sorry if I missed it from a possible previous conversation)

Normally, locally I just run make install on the Orchard project and I still get to use 0.10.0 (i.e. the unaltered version) with local changes applied

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, that was a mistake. Yeah, this was me trying this locally. I changed it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or actually I bumped it to the next orchard version.

@r0man r0man force-pushed the stacktrace-at-point branch from 396c48a to cce1aac Compare November 26, 2022 11:56
@r0man
Copy link
Contributor Author

r0man commented Nov 26, 2022

@bbatsov @vemv This one would be ready from my side.

@bbatsov bbatsov merged commit 1fa95f2 into clojure-emacs:master Nov 26, 2022
@bbatsov
Copy link
Member

bbatsov commented Nov 26, 2022

After merging it I noticed we forgot to update the changelog.

@bbatsov
Copy link
Member

bbatsov commented Nov 26, 2022

It also seems to me you've updated ops.adoc manually, instead of generating it from the middleware descriptors. This will have to be fixed, otherwise your nice docs will disappear once this is regenerated with the lein docs task.

@r0man
Copy link
Contributor Author

r0man commented Nov 27, 2022

Oops, I opened another PR to address those issues: #762

@r0man r0man deleted the stacktrace-at-point branch November 27, 2022 09:46
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.

3 participants