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

info and eldoc ops: accept a Compliment-style context parameter #815

Merged
merged 7 commits into from
Sep 21, 2023

Conversation

vemv
Copy link
Member

@vemv vemv commented Sep 20, 2023

Fixes #812

Tested out locally - works as intended!

Cheers - V

(and ns sym) (info/info* info-params)
(and class member) (info/info-java class member)
:else (throw (Exception.
Copy link
Member Author

Choose a reason for hiding this comment

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

The throw wasn't compatible with the new logic. nil is more flexible and will result in a graceful op-specific reply (e.g. status no-info or no-eldoc)

@vemv vemv requested a review from bbatsov September 20, 2023 16:48
@vemv
Copy link
Member Author

vemv commented Sep 20, 2023

@alexander-yakushev - feel free to check out this PR. You may be happy to see Compliment used in a new way!

Maybe later as things get more time-proven, we may want to have an explicit API just for this kind of purpose.

[{:keys [ns sym class member context]
legacy-sym :symbol
:as msg}]
(let [sym (or (not-empty legacy-sym)
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need not-empty here?

Copy link
Member Author

Choose a reason for hiding this comment

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

For discarding empty strings

I don't necessarily expect them, but I've found it's a good habit to handle them.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I figured as much although clients are generally expected to omit params instead of sending empty strings. I don't think we've got any such checks in cider-nrepl, that's why I've mostly done "truthy" check instead. Anyways, not a big deal right now, but something we can discuss later for the sake of consistency.

Copy link
Member Author

@vemv vemv Sep 21, 2023

Choose a reason for hiding this comment

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

🤝

In an ideal world we'd have something like Spec checking/coercion at the edges

(let [sym (or (not-empty legacy-sym)
(not-empty sym))
class (try
(or (when (and (seq class)
Copy link
Member

Choose a reason for hiding this comment

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

Is this nil-punning here? I still think it doesn't read very well. :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure of what the alternative would be

(I had written a suggestion, but it wasn't accurate)

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine either way - I just don't like much mixing the use of seq and not-empty. Rich liked seq, but not-empty was other later on for those who felt seq wasn't very intention revealing.

Copy link
Member

Choose a reason for hiding this comment

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

(my main point was the one I made earlier - that probably checking for empty strings is redundant, although I understand your reasoning as well)

Copy link
Member Author

Choose a reason for hiding this comment

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

A nice convention is to exclusively use seq as a condition, and not-empty as an object one intends to further use

@bbatsov
Copy link
Member

bbatsov commented Sep 21, 2023

Other than the slightly confusing usage of not-empty and seq here and there it seems OK overall.

Base automatically changed from javadoc-v2-orchard-based to master September 21, 2023 07:47
@vemv vemv force-pushed the 812--compliment-inference branch from 785d21f to 94cd87a Compare September 21, 2023 08:04
@vemv vemv force-pushed the 812--compliment-inference branch from 485655a to 614df43 Compare September 21, 2023 08:52
@vemv vemv merged commit d0dda30 into master Sep 21, 2023
@vemv vemv deleted the 812--compliment-inference branch September 21, 2023 09:06
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.

Improve eldoc-reply with Compliment's type inference
2 participants