Class: Fast::SQL::Node
Overview
The SQL node is an AST node with additional tokenization info
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #first(pattern) ⇒ Object
- #replace(pattern, with = nil, &replacement) ⇒ Object
- #token ⇒ Object
- #tokens ⇒ Object
Methods inherited from Node
#<<, #==, #author, #blame_authors, #buffer_name, #capture, #deconstruct, #each_child_node, #each_descendant, #expression, #file, #from_file?, #git, #git_blob, #git_log, #hash, #initialize, #inspect, #last_commit, #line_range, #lines, #lines_of_code, #link, #location, #md_link, #md_link_description, #method_missing, #parent, parent_for, #permalink, #project_url, #remote_url, #respond_to_missing?, #root?, #search, set_parent, #sha, #source, #to_a, #to_ast, #to_s, #to_sexp, #updated
Constructor Details
This class inherits a constructor from Fast::Node
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Fast::Node
Instance Method Details
#first(pattern) ⇒ Object
85 86 87 |
# File 'lib/fast/sql.rb', line 85 def first(pattern) search(pattern).first end |
#replace(pattern, with = nil, &replacement) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/fast/sql.rb', line 89 def replace(pattern, with=nil, &replacement) replacement ||= -> (n) { replace(n.loc.expression, with) } if root? SQL.replace(pattern, self, &replacement) else parent.replace(pattern, &replacement) end end |
#token ⇒ Object
98 99 100 |
# File 'lib/fast/sql.rb', line 98 def token tokens.find{|e|e.start == location.begin} end |
#tokens ⇒ Object
102 103 104 |
# File 'lib/fast/sql.rb', line 102 def tokens location.expression.source_buffer.tokens end |