Class: Scryer::MethodInfo
- Inherits:
-
Struct
- Object
- Struct
- Scryer::MethodInfo
- Defined in:
- lib/scryer/method_extractor.rb
Overview
Extracts each def/def self.x method from a parsed file as a
MethodInfo (name, file, start/end line, source text) by walking the
Ripper sexp tree for :def and :defs nodes. Sexp nodes don't carry an
explicit end line, so we find it by locating the matching top-level
statement boundary: the next sibling's start line minus one, or the
bodystmt's last statement's line if there's no next sibling, with a
fallback that scans forward for the line containing a bare "end" if
neither is available. In practice, we don't need exact end lines for
duplicate detection — the token stream (not the source substring) is
what actually gets compared, so we lex from the method's body sexp's own
descendants (whose positions we DO have precisely) rather than fragile
source-line slicing.
Instance Attribute Summary collapse
-
#end_line ⇒ Object
Returns the value of attribute end_line.
-
#file ⇒ Object
Returns the value of attribute file.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source_snippet ⇒ Object
Returns the value of attribute source_snippet.
-
#start_line ⇒ Object
Returns the value of attribute start_line.
-
#token_stream ⇒ Object
Returns the value of attribute token_stream.
Instance Attribute Details
#end_line ⇒ Object
Returns the value of attribute end_line
16 17 18 |
# File 'lib/scryer/method_extractor.rb', line 16 def end_line @end_line end |
#file ⇒ Object
Returns the value of attribute file
16 17 18 |
# File 'lib/scryer/method_extractor.rb', line 16 def file @file end |
#name ⇒ Object
Returns the value of attribute name
16 17 18 |
# File 'lib/scryer/method_extractor.rb', line 16 def name @name end |
#source_snippet ⇒ Object
Returns the value of attribute source_snippet
16 17 18 |
# File 'lib/scryer/method_extractor.rb', line 16 def source_snippet @source_snippet end |
#start_line ⇒ Object
Returns the value of attribute start_line
16 17 18 |
# File 'lib/scryer/method_extractor.rb', line 16 def start_line @start_line end |
#token_stream ⇒ Object
Returns the value of attribute token_stream
16 17 18 |
# File 'lib/scryer/method_extractor.rb', line 16 def token_stream @token_stream end |