Class: RubyLsp::Requests::GoToRelevantFile

Inherits:
Request
  • Object
show all
Defined in:
lib/ruby_lsp/requests/go_to_relevant_file.rb

Overview

GoTo Relevant File is a custom [LSP request](microsoft.github.io/language-server-protocol/specification#requestMessage) that navigates to the relevant file for the current document. Currently, it supports source code file <> test file navigation.

Constant Summary collapse

TEST_KEYWORDS =
["test", "spec", "integration_test"]
TEST_PREFIX_PATTERN =
/^(#{TEST_KEYWORDS.join("_|")}_)/
TEST_SUFFIX_PATTERN =
/(_#{TEST_KEYWORDS.join("|_")})$/
TEST_PATTERN =
/#{TEST_PREFIX_PATTERN}|#{TEST_SUFFIX_PATTERN}/
TEST_PREFIX_GLOB =

: String

"#{TEST_KEYWORDS.join("_,")}_"
TEST_SUFFIX_GLOB =

: String

"_#{TEST_KEYWORDS.join(",_")}"

Instance Method Summary collapse

Constructor Details

#initialize(path, workspace_path) ⇒ GoToRelevantFile

: (String path, String workspace_path) -> void



21
22
23
24
25
26
# File 'lib/ruby_lsp/requests/go_to_relevant_file.rb', line 21

def initialize(path, workspace_path)
  super()

  @workspace_path = workspace_path
  @path = path.delete_prefix(workspace_path) #: String
end

Instance Method Details

#performObject

: -> Array



30
31
32
# File 'lib/ruby_lsp/requests/go_to_relevant_file.rb', line 30

def perform
  find_relevant_paths
end