Class: Fast::SQL::Node
- Inherits:
-
Node
- Object
- Astrolabe::Node
- Node
- Fast::SQL::Node
show all
- Defined in:
- lib/fast/sql.rb
Overview
The SQL node is an AST node with additional tokenization info
Instance Method Summary
collapse
Methods inherited from Node
#author, #blame_authors, #buffer_name, #capture, #expression, #file, #from_file?, #git, #git_blob, #git_log, #last_commit, #line_range, #lines, #lines_of_code, #link, #md_link, #md_link_description, #permalink, #project_url, #remote_url, #search, #sha, #source
Instance Method Details
#first(pattern) ⇒ Object
84
85
86
|
# File 'lib/fast/sql.rb', line 84
def first(pattern)
search(pattern).first
end
|
#replace(pattern, with = nil, &replacement) ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'lib/fast/sql.rb', line 88
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
97
98
99
|
# File 'lib/fast/sql.rb', line 97
def token
tokens.find{|e|e.start == location.begin}
end
|
#tokens ⇒ Object
101
102
103
|
# File 'lib/fast/sql.rb', line 101
def tokens
location.expression.source_buffer.tokens
end
|