Class: Solargraph::Parser::Legacy::NodeChainer
- Inherits:
-
Object
- Object
- Solargraph::Parser::Legacy::NodeChainer
- Includes:
- NodeMethods
- Defined in:
- lib/solargraph/parser/legacy/node_chainer.rb
Overview
A factory for generating chains from nodes.
Constant Summary collapse
Constants included from NodeMethods
Solargraph::Parser::Legacy::NodeMethods::NIL_NODE
Class Method Summary collapse
Instance Method Summary collapse
- #chain ⇒ Source::Chain
-
#initialize(node, filename = nil, in_block = false) ⇒ 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, splatted_call?, splatted_hash?, unpack_name
Constructor Details
#initialize(node, filename = nil, in_block = false) ⇒ NodeChainer
Returns a new instance of NodeChainer.
14 15 16 17 18 |
# File 'lib/solargraph/parser/legacy/node_chainer.rb', line 14 def initialize node, filename = nil, in_block = false @node = node @filename = filename @in_block = in_block ? 1 : 0 end |
Class Method Details
.chain(node, filename = nil, in_block = false) ⇒ Source::Chain
30 31 32 |
# File 'lib/solargraph/parser/legacy/node_chainer.rb', line 30 def chain node, filename = nil, in_block = false NodeChainer.new(node, filename, in_block).chain end |
.load_string(code) ⇒ Source::Chain
36 37 38 39 40 41 |
# File 'lib/solargraph/parser/legacy/node_chainer.rb', line 36 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
21 22 23 24 |
# File 'lib/solargraph/parser/legacy/node_chainer.rb', line 21 def chain links = generate_links(@node) Chain.new(links, @node, (Parser.is_ast_node?(@node) && @node.type == :splat)) end |