Class: RubyLsp::Ree::ParsedBaseDocument

Inherits:
Object
  • Object
show all
Includes:
ReeLspUtils
Defined in:
lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb

Direct Known Subclasses

ParsedClassDocument, ParsedRspecDocument

Constant Summary

Constants included from ReeLspUtils

ReeLspUtils::Entry

Instance Attribute Summary collapse

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

Constructor Details

#initialize(ast, package_name = nil) ⇒ ParsedBaseDocument

Returns a new instance of ParsedBaseDocument.



6
7
8
9
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 6

def initialize(ast, package_name = nil)
  @ast = ast
  set_package_name(package_name) if package_name
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



4
5
6
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 4

def ast
  @ast
end

Returns the value of attribute link_nodes.



4
5
6
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 4

def link_nodes
  @link_nodes
end

#package_nameObject (readonly)

Returns the value of attribute package_name.



4
5
6
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 4

def package_name
  @package_name
end

Instance Method Details

#allows_root_links?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 63

def allows_root_links?
  raise "abstract method"
end

#find_import_for_package(name, package_name) ⇒ Object



51
52
53
54
55
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 51

def find_import_for_package(name, package_name)
  @link_nodes.detect do |link_node|
    link_node.imports.include?(name) && link_node.link_package_name == package_name
  end
end


47
48
49
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 47

def find_link_by_usage_name(name)
  @link_nodes.detect{ _1.usage_name == name }
end


43
44
45
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 43

def find_link_node(name)
  @link_nodes.detect{ node_name(_1) == name }
end

Returns:

  • (Boolean)


67
68
69
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 67

def has_blank_links_container?
  raise "abstract method"
end

#has_root_class?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 15

def has_root_class?
  false
end

#includes_dao_dsl?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 23

def includes_dao_dsl?
  false
end

Returns:

  • (Boolean)


19
20
21
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 19

def includes_link_dsl?
  false
end

#includes_linked_object?(obj_name) ⇒ Boolean

Returns:

  • (Boolean)


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

def includes_linked_object?(obj_name)
  @link_nodes.map(&:linked_objects).flatten.map(&:name).include?(obj_name)
end

#includes_mapper_dsl?Boolean

Returns:

  • (Boolean)


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

def includes_mapper_dsl?
  false
end

#includes_ree_dsl?Boolean

Returns:

  • (Boolean)


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

def includes_ree_dsl?
  false
end

#includes_routes_dsl?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 27

def includes_routes_dsl?
  false
end


71
72
73
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 71

def links_container_node
  raise "abstract method"
end

#node_name(node) ⇒ Object



57
58
59
60
61
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 57

def node_name(node)
  return nil unless node.respond_to?(:name)

  node.name
end


75
76
77
# File 'lib/ruby_lsp/ruby_lsp_ree/parsing/parsed_base_document.rb', line 75

def parse_links
  raise "abstract method"
end

#set_package_name(package_name) ⇒ Object



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

def set_package_name(package_name)
  @package_name = package_name
end