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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dumb-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -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!

(s-chop-prefix ":" look-for))
((and (string= lang "ruby") (s-contains? "::" look-for))
(-last-item (s-split "::" look-for)))
Expand Down
2 changes: 2 additions & 0 deletions test/dumb-jump-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,13 @@
(result2 (dumb-jump-process-symbol-by-lang "clojure" "myns/myfunc"))
(result3 (dumb-jump-process-symbol-by-lang "ruby" ":myrubyfunc"))
(result3b (dumb-jump-process-symbol-by-lang "ruby" "Health::Checks::QueueGrowth"))
(result3c (dumb-jump-process-symbol-by-lang "ruby" "::Health"))
(result4 (dumb-jump-process-symbol-by-lang "systemverilog" "`myvlfunc")))
(should (string= result "somefunc"))
(should (string= result2 "myfunc"))
(should (string= result3 "myrubyfunc"))
(should (string= result3b "QueueGrowth"))
(should (string= result3c "Health"))
(should (string= result4 "myvlfunc"))))

(ert-deftest dumb-jump--result-follow-test ()
Expand Down