Class: Solargraph::Parser::Rubyvm::NodeChainer
- Inherits:
-
Object
- Object
- Solargraph::Parser::Rubyvm::NodeChainer
- Includes:
- NodeMethods
- Defined in:
- lib/solargraph/parser/rubyvm/node_chainer.rb
Overview
A factory for generating chains from nodes.
Constant Summary collapse
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, find_recipient_node, infer_literal_node_type, node?, pack_name, returns_from, splatted_call?, splatted_hash?, splatted_node?, unpack_name
Constructor Details
#initialize(node, filename = nil, in_block = false) ⇒ NodeChainer
Returns a new instance of NodeChainer.
15 16 17 18 19 |
# File 'lib/solargraph/parser/rubyvm/node_chainer.rb', line 15 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
31 32 33 |
# File 'lib/solargraph/parser/rubyvm/node_chainer.rb', line 31 def chain node, filename = nil, in_block = false NodeChainer.new(node, filename, in_block).chain end |
.load_string(code) ⇒ Source::Chain
37 38 39 40 41 42 |
# File 'lib/solargraph/parser/rubyvm/node_chainer.rb', line 37 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/rubyvm/node_chainer.rb', line 22 def chain links = generate_links(@node) Chain.new(links, @node, (Parser.is_ast_node?(@node) && @node.type == :SPLAT)) end |