Class: Solargraph::Parser::ParserGem::NodeChainer
- Inherits:
-
Object
- Object
- Solargraph::Parser::ParserGem::NodeChainer
- Includes:
- NodeMethods
- Defined in:
- lib/solargraph/parser/parser_gem/node_chainer.rb
Overview
A factory for generating chains from nodes.
Constant Summary collapse
Constants included from NodeMethods
Solargraph::Parser::ParserGem::NodeMethods::NIL_NODE
Class Method Summary collapse
Instance Method Summary collapse
- #chain ⇒ Source::Chain
-
#initialize(node, filename = nil, parent = nil) ⇒ NodeChainer
constructor
A new instance of NodeChainer.
Methods included from NodeMethods
any_splatted_call?, call_nodes_from, const_nodes_from, convert_hash, drill_signature, find_recipient_node, get_node_end_position, get_node_start_position, infer_literal_node_type, pack_name, repaired_find_recipient_node, returns_from_method_body, splatted_call?, splatted_hash?, unpack_name, value_position_nodes_only
Constructor Details
#initialize(node, filename = nil, parent = nil) ⇒ NodeChainer
Returns a new instance of NodeChainer.
15 16 17 18 19 |
# File 'lib/solargraph/parser/parser_gem/node_chainer.rb', line 15 def initialize node, filename = nil, parent = nil @node = node @filename = filename @parent = parent end |
Class Method Details
.chain(node, filename = nil, parent = nil) ⇒ Source::Chain
32 33 34 |
# File 'lib/solargraph/parser/parser_gem/node_chainer.rb', line 32 def chain node, filename = nil, parent = nil NodeChainer.new(node, filename, parent).chain end |
.load_string(code) ⇒ Source::Chain
38 39 40 41 42 43 |
# File 'lib/solargraph/parser/parser_gem/node_chainer.rb', line 38 def load_string(code) node = Parser.parse(code.sub(/\.$/, '')) chain = NodeChainer.new(node).chain chain.links.push(Chain::Link.new) if code.end_with?('.') chain end |
Instance Method Details
#chain ⇒ Source::Chain
22 23 24 25 |
# File 'lib/solargraph/parser/parser_gem/node_chainer.rb', line 22 def chain links = generate_links(@node) Chain.new(links, @node, (Parser.is_ast_node?(@node) && @node.type == :splat)) end |