Skip to content

Add code lens extension (for Rails) #67

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

Merged
merged 9 commits into from
Jun 27, 2023
Merged

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented May 8, 2023

Based on #59

Reminder: Ensure @adisonlampert is credited in the release notes.

This depends on Shopify/vscode-ruby-lsp#639

TODO:

Testing

  gem "ruby-lsp", github: "Shopify/ruby-lsp"
  gem "ruby-lsp-rails", github: "Shopify/ruby-lsp-rails", branch: "andyw8/add-code-lens-extension"

@andyw8
Copy link
Contributor Author

andyw8 commented Jun 1, 2023

Note: This will requires changes if Shopify/ruby-lsp#734 is merged.

extend T::Sig
extend T::Generic

ResponseType = type_member { { fixed: T.nilable(T::Array[::RubyLsp::Interface::CodeLens]) } }

This comment was marked as resolved.

@response = T.let([], ResponseType)
@visibility = T.let("public", String)
@prev_visibility = T.let("public", String)
@path = T.let(uri.delete_prefix("file://"), String)

This comment was marked as resolved.

assert_match("Debug", response[5].command.title)

ensure
RubyLsp::Requests::Hover.listeners.clear

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't actually need this line, I've removed it.

assert_match("Debug", response[5].command.title)

ensure
RubyLsp::Requests::Hover.listeners.clear

This comment was marked as resolved.

module Rails
class CodeLensTest < ActiveSupport::TestCase
test "recognizes Rails Active Support test cases" do
message_queue = Thread::Queue.new

This comment was marked as resolved.

@andyw8 andyw8 force-pushed the andyw8/add-code-lens-extension branch 4 times, most recently from 347fe08 to 30624fa Compare June 23, 2023 19:05
@andyw8 andyw8 force-pushed the andyw8/add-code-lens-extension branch from 30624fa to abb108b Compare June 23, 2023 19:13
@andyw8 andyw8 marked this pull request as ready for review June 26, 2023 19:34
@andyw8 andyw8 requested a review from a team as a code owner June 26, 2023 19:34
@andyw8 andyw8 requested review from st0012 and egiurleo June 26, 2023 19:34
Comment on lines 50 to 51
@visibility = T.let("public", String)
@prev_visibility = T.let("public", String)

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That may have been accidentally removed in a refactoring, but probably means we are missing a test, I'll look into.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, these can just be removed. Methods defined with test do don't respect public/private/protected. (see Slack conversation in team channel from June 21).

Copy link
Contributor

@egiurleo egiurleo left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉 Yay this is so cool!

Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Vini & Stan

module Rails
# ![CodeLens demo](../../code_lens.gif)
#
# This feature adds several CodeLens features for Rails applications using the built-in test framework:
Copy link
Member

Choose a reason for hiding this comment

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

Let's say Active Support test cases.

# [code lens](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens)
# request informs the editor of runnable commands such as tests
#
# Example:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Example:
# # Example

# ```ruby
# Run
# class HelloTest < ActiveSupport::TestCase
# test "outputs hello" do
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# test "outputs hello" do
# test "outputs hello" do # <- Will show code lenses for executing this test

This comment was marked as resolved.

@andyw8 andyw8 merged commit 9b72a87 into main Jun 27, 2023
@andyw8 andyw8 deleted the andyw8/add-code-lens-extension branch June 27, 2023 14:52
@shopify-shipit shopify-shipit bot temporarily deployed to production June 30, 2023 19:47 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants