Class: RubyLsp::Ree::ReeContext
- Inherits:
-
Object
- Object
- RubyLsp::Ree::ReeContext
show all
- Includes:
- ReeConstants
- Defined in:
- lib/ruby_lsp/ruby_lsp_ree/ree_context.rb
Constant Summary
collapse
- FROM_ARG_KEY =
'from'
RubyLsp::Ree::ReeConstants::CONTRACT_CALL_NODE_NAMES, RubyLsp::Ree::ReeConstants::DAO_DSL_MODULE, RubyLsp::Ree::ReeConstants::ERROR_DEFINITION_NAMES, RubyLsp::Ree::ReeConstants::LINKS_CONTAINER_TYPES, RubyLsp::Ree::ReeConstants::LINK_DSL_MODULE, RubyLsp::Ree::ReeConstants::MAPPER_DSL_MODULE, RubyLsp::Ree::ReeConstants::ROUTES_DSL_MODULE
Instance Method Summary
collapse
Constructor Details
#initialize(node_context) ⇒ ReeContext
Returns a new instance of ReeContext.
11
12
13
|
# File 'lib/ruby_lsp/ruby_lsp_ree/ree_context.rb', line 11
def initialize(node_context)
@node_context = node_context
end
|
Instance Method Details
#is_error_definition? ⇒ Boolean
15
16
17
18
19
|
# File 'lib/ruby_lsp/ruby_lsp_ree/ree_context.rb', line 15
def is_error_definition?
return false unless has_call_parent?
ERROR_DEFINITION_NAMES.include?(@node_context.parent.name)
end
|
#is_link_object? ⇒ Boolean
21
22
23
24
25
|
# File 'lib/ruby_lsp/ruby_lsp_ree/ree_context.rb', line 21
def is_link_object?
return false unless has_call_parent?
@node_context.parent.name == :link || @node_context.parent.name == :import
end
|
#is_package_argument? ⇒ Boolean
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/ruby_lsp/ruby_lsp_ree/ree_context.rb', line 27
def is_package_argument?
return false unless has_call_parent?
return false if !@node_context.parent.arguments || @node_context.parent.arguments.arguments.size < 2
first_arg = @node_context.parent.arguments.arguments.first
return false if @node_context.node.unescaped == symbol_node_name(first_arg)
kw_args = @node_context.parent.arguments.arguments.detect{ |arg| arg.is_a?(Prism::KeywordHashNode) }
return false unless kw_args
package_param = kw_args.elements.detect{ _1.key.unescaped == FROM_ARG_KEY }
package_param.value.unescaped == @node_context.node.unescaped
end
|