Class: RubyLsp::Ree::ParsedRspecDocument

Inherits:
ParsedBaseDocument show all
Includes:
ReeLspUtils
Defined in:
lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb

Constant Summary

Constants included from ReeLspUtils

ReeLspUtils::Entry

Instance Attribute Summary collapse

Attributes inherited from ParsedBaseDocument

#ast, #link_nodes, #package_name

Instance Method Summary collapse

Methods included from ReeLspUtils

#camelize, #find_local_file_path, #get_range_for_fn_insert, #get_ree_type, #get_uri_path, #package_name_from_spec_uri, #package_name_from_uri, #package_path_from_uri, #parameter_name, #path_from_package_folder, #signature_params_from_node, #spec_relative_file_path_from_uri, #underscore

Methods inherited from ParsedBaseDocument

#find_import_for_package, #find_link_by_usage_name, #find_link_node, #has_root_class?, #includes_dao_dsl?, #includes_link_dsl?, #includes_linked_object?, #includes_mapper_dsl?, #includes_ree_dsl?, #includes_routes_dsl?, #node_name, #set_package_name

Constructor Details

#initialize(ast, package_name = nil) ⇒ ParsedRspecDocument

Returns a new instance of ParsedRspecDocument.



11
12
13
14
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 11

def initialize(ast, package_name = nil)
  super
  parse_describe_node    
end

Instance Attribute Details

#describe_nodeObject (readonly)

Returns the value of attribute describe_node.



9
10
11
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 9

def describe_node
  @describe_node
end

Instance Method Details

#allows_root_links?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 16

def allows_root_links?
  true
end

Returns:

  • (Boolean)


31
32
33
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 31

def has_blank_links_container?
  false
end


20
21
22
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 20

def links_container_node
  nil
end

#parse_describe_nodeObject



35
36
37
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 35

def parse_describe_node
  @describe_node ||= @ast.statements.body.detect{ |node| node.is_a?(Prism::CallNode) && node.name == :describe }
end


39
40
41
42
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 39

def parse_links
  container = @describe_node.block.body.body
  @link_nodes = RubyLsp::Ree::LinksParser.new(container, package_name).parse_links
end

#root_node_line_locationObject



24
25
26
27
28
29
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_rspec_document.rb', line 24

def root_node_line_location
  OpenStruct.new(
    start_line: @describe_node.location.start_line,
    end_column: @describe_node.block.opening_loc.end_column
  )
end