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

Ruby: support for fully qualified constants #248

Merged
merged 2 commits into from
Dec 21, 2018

Conversation

dustym
Copy link
Contributor

@dustym dustym commented Dec 21, 2018

Adds support for fully qualified constants like "::Foo". Currently dumb-jump peeks at the first character of the symbol to see if it starts with a colon and thus is a ruby symbol, then strips the colon. This patch checks to see if the symbol starts with two colons and, if so, doesn't strip the colon.

@coveralls
Copy link

coveralls commented Dec 21, 2018

Coverage Status

Coverage remained the same at 97.081% when pulling c5417de on dustym:root-qualified-constants into 72a6580 on jacktasia:master.

@jacktasia jacktasia self-requested a review December 21, 2018 23:06
dumb-jump.el Outdated
@@ -1751,7 +1751,7 @@ to keep looking for another root."
(cond
((and (string= lang "clojure") (s-contains? "/" look-for))
(nth 1 (s-split "/" look-for)))
((and (or (string= lang "ruby") (string= lang "crystal")) (s-starts-with? ":" look-for))
((and (or (string= lang "ruby") (string= lang "crystal")) (and (s-starts-with? ":" look-for) (and (not (s-starts-with? "::" look-for)))))
Copy link
Owner

Choose a reason for hiding this comment

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

The second and here is unnecessary. That said, now that I understand the issue you're fixing I am pretty sure we don't need to actually add anything and we can simply swap the conditional blocks so it looks like this:

   ((and (string= lang "ruby") (s-contains? "::" look-for))
    (-last-item (s-split "::" look-for)))
   ((and (or (string= lang "ruby") (string= lang "crystal")) (s-starts-with? ":" look-for))
    (s-chop-prefix ":" look-for))

Does that seem right to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup @jacktasia that works. I've reverted my changes and re-ordered the code and have left the test case in. Thanks!

@jacktasia
Copy link
Owner

Thanks for the PR and report! I made one small comment.

Copy link
Owner

@jacktasia jacktasia left a comment

Choose a reason for hiding this comment

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

LGTM

@jacktasia jacktasia merged commit 41ab1d6 into jacktasia:master Dec 21, 2018
@jacktasia
Copy link
Owner

Thanks!

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