Skip to content

Commit a2b4b51

Browse files
committed
Rename from goto to go_to
1 parent 8a39f82 commit a2b4b51

File tree

9 files changed

+46
-45
lines changed

9 files changed

+46
-45
lines changed

lib/ruby_lsp/internal.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
require "ruby_lsp/requests/document_symbol"
8181
require "ruby_lsp/requests/folding_ranges"
8282
require "ruby_lsp/requests/formatting"
83-
require "ruby_lsp/requests/goto_relevant_file"
83+
require "ruby_lsp/requests/go_to_relevant_file"
8484
require "ruby_lsp/requests/hover"
8585
require "ruby_lsp/requests/inlay_hints"
8686
require "ruby_lsp/requests/on_type_formatting"

lib/ruby_lsp/requests/goto_relevant_file.rb lib/ruby_lsp/requests/go_to_relevant_file.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
module RubyLsp
55
module Requests
6-
# Goto Relevant File is a custom [LSP
6+
# GoTo Relevant File is a custom [LSP
77
# request](https://microsoft.github.io/language-server-protocol/specification#requestMessage)
88
# that navigates to the relevant file for the current document.
99
# Currently, it supports source code file <> test file navigation.
10-
class GotoRelevantFile < Request
10+
class GoToRelevantFile < Request
1111
extend T::Sig
1212

1313
TEST_KEYWORDS = ["test", "spec", "integration_test"]

lib/ruby_lsp/server.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def process_message(message)
113113
discover_tests(message)
114114
when "rubyLsp/resolveTestCommands"
115115
resolve_test_commands(message)
116-
when "experimental/gotoRelevantFile"
117-
experimental_goto_relevant_file(message)
116+
when "experimental/goToRelevantFile"
117+
experimental_go_to_relevant_file(message)
118118
when "$/cancelRequest"
119119
@global_state.synchronize { @cancelled_requests << message[:params][:id] }
120120
when nil
@@ -293,7 +293,7 @@ def run_initialize(message)
293293
experimental: {
294294
addon_detection: true,
295295
compose_bundle: true,
296-
goto_relevant_file: true,
296+
go_to_relevant_file: true,
297297
},
298298
),
299299
serverInfo: {
@@ -1145,7 +1145,7 @@ def text_document_show_syntax_tree(message)
11451145
end
11461146

11471147
#: (Hash[Symbol, untyped] message) -> void
1148-
def experimental_goto_relevant_file(message)
1148+
def experimental_go_to_relevant_file(message)
11491149
path = message.dig(:params, :textDocument, :uri).to_standardized_path
11501150
unless path.nil? || path.start_with?(@global_state.workspace_path)
11511151
send_empty_response(message[:id])
@@ -1158,7 +1158,7 @@ def experimental_goto_relevant_file(message)
11581158
end
11591159

11601160
response = {
1161-
locations: Requests::GotoRelevantFile.new(path, @global_state.workspace_path).perform,
1161+
locations: Requests::GoToRelevantFile.new(path, @global_state.workspace_path).perform,
11621162
}
11631163
send_message(Result.new(id: message[:id], response: response))
11641164
end

test/requests/goto_relevant_file_test.rb test/requests/go_to_relevant_file_test.rb

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33

44
require "test_helper"
55

6-
class GotoRelevantFileTest < Minitest::Test
6+
class GoToRelevantFileTest < Minitest::Test
77
def test_when_input_is_test_file_returns_array_of_implementation_file_locations
8-
stub_glob_pattern("**/goto_relevant_file.rb", ["lib/ruby_lsp/requests/goto_relevant_file.rb"])
8+
stub_glob_pattern("**/go_to_relevant_file.rb", ["lib/ruby_lsp/requests/go_to_relevant_file.rb"])
99

10-
test_file_path = "/workspace/test/requests/goto_relevant_file_test.rb"
11-
expected = ["/workspace/lib/ruby_lsp/requests/goto_relevant_file.rb"]
10+
test_file_path = "/workspace/test/requests/go_to_relevant_file_test.rb"
11+
expected = ["/workspace/lib/ruby_lsp/requests/go_to_relevant_file.rb"]
1212

13-
result = RubyLsp::Requests::GotoRelevantFile.new(test_file_path, "/workspace").perform
13+
result = RubyLsp::Requests::GoToRelevantFile.new(test_file_path, "/workspace").perform
1414
assert_equal(expected, result)
1515
end
1616

1717
def test_when_input_is_implementation_file_returns_array_of_test_file_locations
1818
pattern =
19-
"**/{{test_,spec_,integration_test_}goto_relevant_file,goto_relevant_file{_test,_spec,_integration_test}}.rb"
20-
stub_glob_pattern(pattern, ["test/requests/goto_relevant_file_test.rb"])
19+
"**/{{test_,spec_,integration_test_}go_to_relevant_file,go_to_relevant_file{_test,_spec,_integration_test}}.rb"
20+
stub_glob_pattern(pattern, ["test/requests/go_to_relevant_file_test.rb"])
2121

22-
impl_path = "/workspace/lib/ruby_lsp/requests/goto_relevant_file.rb"
23-
expected = ["/workspace/test/requests/goto_relevant_file_test.rb"]
22+
impl_path = "/workspace/lib/ruby_lsp/requests/go_to_relevant_file.rb"
23+
expected = ["/workspace/test/requests/go_to_relevant_file_test.rb"]
2424

25-
result = RubyLsp::Requests::GotoRelevantFile.new(impl_path, "/workspace").perform
25+
result = RubyLsp::Requests::GoToRelevantFile.new(impl_path, "/workspace").perform
2626
assert_equal(expected, result)
2727
end
2828

@@ -40,7 +40,7 @@ def test_return_all_file_locations_that_have_the_same_highest_coefficient
4040
"/workspace/test/integration/some_feature_test.rb",
4141
]
4242

43-
result = RubyLsp::Requests::GotoRelevantFile.new(impl_path, "/workspace").perform
43+
result = RubyLsp::Requests::GoToRelevantFile.new(impl_path, "/workspace").perform
4444
assert_equal(expected.sort, result.sort)
4545
end
4646

@@ -49,7 +49,7 @@ def test_return_empty_array_when_no_filename_matches
4949
stub_glob_pattern(pattern, [])
5050

5151
file_path = "/workspace/lib/ruby_lsp/requests/nonexistent_file.rb"
52-
result = RubyLsp::Requests::GotoRelevantFile.new(file_path, "/workspace").perform
52+
result = RubyLsp::Requests::GoToRelevantFile.new(file_path, "/workspace").perform
5353
assert_empty(result)
5454
end
5555

@@ -59,7 +59,7 @@ def test_it_finds_implementation_when_file_has_test_suffix
5959
test_path = "/workspace/test/feature_test.rb"
6060
expected = ["/workspace/lib/feature.rb"]
6161

62-
result = RubyLsp::Requests::GotoRelevantFile.new(test_path, "/workspace").perform
62+
result = RubyLsp::Requests::GoToRelevantFile.new(test_path, "/workspace").perform
6363
assert_equal(expected, result)
6464
end
6565

@@ -69,7 +69,7 @@ def test_it_finds_implementation_when_file_has_spec_suffix
6969
test_path = "/workspace/spec/feature_spec.rb"
7070
expected = ["/workspace/lib/feature.rb"]
7171

72-
result = RubyLsp::Requests::GotoRelevantFile.new(test_path, "/workspace").perform
72+
result = RubyLsp::Requests::GoToRelevantFile.new(test_path, "/workspace").perform
7373
assert_equal(expected, result)
7474
end
7575

@@ -79,7 +79,7 @@ def test_it_finds_implementation_when_file_has_integration_test_suffix
7979
test_path = "/workspace/test/feature_integration_test.rb"
8080
expected = ["/workspace/lib/feature.rb"]
8181

82-
result = RubyLsp::Requests::GotoRelevantFile.new(test_path, "/workspace").perform
82+
result = RubyLsp::Requests::GoToRelevantFile.new(test_path, "/workspace").perform
8383
assert_equal(expected, result)
8484
end
8585

@@ -89,7 +89,7 @@ def test_it_finds_implementation_when_file_has_test_prefix
8989
test_path = "/workspace/test/test_feature.rb"
9090
expected = ["/workspace/lib/feature.rb"]
9191

92-
result = RubyLsp::Requests::GotoRelevantFile.new(test_path, "/workspace").perform
92+
result = RubyLsp::Requests::GoToRelevantFile.new(test_path, "/workspace").perform
9393
assert_equal(expected, result)
9494
end
9595

@@ -99,7 +99,7 @@ def test_it_finds_implementation_when_file_has_spec_prefix
9999
test_path = "/workspace/test/spec_feature.rb"
100100
expected = ["/workspace/lib/feature.rb"]
101101

102-
result = RubyLsp::Requests::GotoRelevantFile.new(test_path, "/workspace").perform
102+
result = RubyLsp::Requests::GoToRelevantFile.new(test_path, "/workspace").perform
103103
assert_equal(expected, result)
104104
end
105105

@@ -109,7 +109,7 @@ def test_it_finds_implementation_when_file_has_integration_test_prefix
109109
test_path = "/workspace/test/integration_test_feature.rb"
110110
expected = ["/workspace/lib/feature.rb"]
111111

112-
result = RubyLsp::Requests::GotoRelevantFile.new(test_path, "/workspace").perform
112+
result = RubyLsp::Requests::GoToRelevantFile.new(test_path, "/workspace").perform
113113
assert_equal(expected, result)
114114
end
115115

@@ -120,7 +120,7 @@ def test_it_finds_tests_for_implementation
120120
impl_path = "/workspace/lib/feature.rb"
121121
expected = ["/workspace/test/feature_test.rb"]
122122

123-
result = RubyLsp::Requests::GotoRelevantFile.new(impl_path, "/workspace").perform
123+
result = RubyLsp::Requests::GoToRelevantFile.new(impl_path, "/workspace").perform
124124
assert_equal(expected, result)
125125
end
126126

@@ -131,7 +131,7 @@ def test_it_finds_specs_for_implementation
131131
impl_path = "/workspace/lib/feature.rb"
132132
expected = ["/workspace/spec/feature_spec.rb"]
133133

134-
result = RubyLsp::Requests::GotoRelevantFile.new(impl_path, "/workspace").perform
134+
result = RubyLsp::Requests::GoToRelevantFile.new(impl_path, "/workspace").perform
135135
assert_equal(expected, result)
136136
end
137137

@@ -142,7 +142,7 @@ def test_it_finds_integration_tests_for_implementation
142142
impl_path = "/workspace/lib/feature.rb"
143143
expected = ["/workspace/test/feature_integration_test.rb"]
144144

145-
result = RubyLsp::Requests::GotoRelevantFile.new(impl_path, "/workspace").perform
145+
result = RubyLsp::Requests::GoToRelevantFile.new(impl_path, "/workspace").perform
146146
assert_equal(expected, result)
147147
end
148148

vscode/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"group": "navigation"
6262
},
6363
{
64-
"command": "rubyLsp.gotoRelevantFile",
64+
"command": "rubyLsp.goToRelevantFile",
6565
"when": "rubyLsp.activated && view == 'workbench.explorer.fileView'",
6666
"group": "navigation"
6767
}
@@ -73,7 +73,7 @@
7373
"group": "2_workspace"
7474
},
7575
{
76-
"command": "rubyLsp.gotoRelevantFile",
76+
"command": "rubyLsp.goToRelevantFile",
7777
"when": "rubyLsp.activated",
7878
"group": "2_workspace"
7979
}
@@ -170,8 +170,8 @@
170170
"icon": "$(ruby)"
171171
},
172172
{
173-
"command": "rubyLsp.gotoRelevantFile",
174-
"title": "Goto relevant file (test <> source code)",
173+
"command": "rubyLsp.goToRelevantFile",
174+
"title": "Go to relevant file (test <> source code)",
175175
"category": "Ruby LSP"
176176
},
177177
{
@@ -817,3 +817,4 @@
817817
"vscode-languageclient": "^9.0.1"
818818
}
819819
}
820+

vscode/src/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,10 @@ export default class Client extends LanguageClient implements ClientInterface {
516516
return super.dispose(timeout);
517517
}
518518

519-
async sendGotoRelevantFileRequest(
519+
async sendGoToRelevantFileRequest(
520520
uri: vscode.Uri,
521521
): Promise<{ locations: string[] } | null> {
522-
return this.sendRequest("experimental/gotoRelevantFile", {
522+
return this.sendRequest("experimental/goToRelevantFile", {
523523
textDocument: { uri: uri.toString() },
524524
});
525525
}

vscode/src/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export enum Command {
3333
StartServerInDebugMode = "rubyLsp.startServerInDebugMode",
3434
ShowOutput = "rubyLsp.showOutput",
3535
MigrateLaunchConfiguration = "rubyLsp.migrateLaunchConfiguration",
36-
GotoRelevantFile = "rubyLsp.gotoRelevantFile",
36+
GoToRelevantFile = "rubyLsp.goToRelevantFile",
3737
}
3838

3939
export interface RubyInterface {

vscode/src/rubyLsp.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,13 @@ export class RubyLsp {
705705
);
706706
},
707707
),
708-
vscode.commands.registerCommand(Command.GotoRelevantFile, async () => {
708+
vscode.commands.registerCommand(Command.GoToRelevantFile, async () => {
709709
const uri = vscode.window.activeTextEditor?.document.uri;
710710
if (!uri) {
711711
return;
712712
}
713713
const response: { locations: string[] } | null | undefined =
714-
await this.currentActiveWorkspace()?.lspClient?.sendGotoRelevantFileRequest(
714+
await this.currentActiveWorkspace()?.lspClient?.sendGoToRelevantFileRequest(
715715
uri,
716716
);
717717

vscode/src/test/suite/client.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -994,20 +994,20 @@ suite("Client", () => {
994994
workspaceUri,
995995
"test",
996996
"requests",
997-
"goto_relevant_file_test.rb",
997+
"go_to_relevant_file_test.rb",
998998
);
999999
implUri = vscode.Uri.joinPath(
10001000
workspaceUri,
10011001
"lib",
10021002
"ruby_lsp",
10031003
"requests",
1004-
"goto_relevant_file.rb",
1004+
"go_to_relevant_file.rb",
10051005
);
10061006
});
10071007

10081008
test("for test file", async () => {
10091009
const response: { locations: string[] } = await client.sendRequest(
1010-
"experimental/gotoRelevantFile",
1010+
"experimental/goToRelevantFile",
10111011
{
10121012
textDocument: {
10131013
uri: testUri.toString(),
@@ -1018,13 +1018,13 @@ suite("Client", () => {
10181018
assert.ok(response.locations.length === 1);
10191019
assert.match(
10201020
response.locations[0],
1021-
/lib\/ruby_lsp\/requests\/goto_relevant_file\.rb$/,
1021+
/lib\/ruby_lsp\/requests\/go_to_relevant_file\.rb$/,
10221022
);
10231023
}).timeout(20000);
10241024

10251025
test("for implementation file", async () => {
10261026
const response: { locations: string[] } = await client.sendRequest(
1027-
"experimental/gotoRelevantFile",
1027+
"experimental/goToRelevantFile",
10281028
{
10291029
textDocument: {
10301030
uri: implUri.toString(),
@@ -1035,15 +1035,15 @@ suite("Client", () => {
10351035
assert.ok(response.locations.length === 1);
10361036
assert.match(
10371037
response.locations[0],
1038-
/test\/requests\/goto_relevant_file_test\.rb$/,
1038+
/test\/requests\/go_to_relevant_file_test\.rb$/,
10391039
);
10401040
}).timeout(20000);
10411041

10421042
test("returns empty array for invalid file", async () => {
10431043
const uri = vscode.Uri.joinPath(workspaceUri, "nonexistent", "file.rb");
10441044

10451045
const response: { locations: string[] } = await client.sendRequest(
1046-
"experimental/gotoRelevantFile",
1046+
"experimental/goToRelevantFile",
10471047
{
10481048
textDocument: {
10491049
uri: uri.toString(),

0 commit comments

Comments
 (0)