Class: CodeModels::SourceInfo
- Inherits:
-
Object
- Object
- CodeModels::SourceInfo
- Defined in:
- lib/codemodels/source_info.rb
Overview
Info which specify from which part of the code a node was obtained.
Some methods can accept a scope to be :relative or :absolute. When a piece of code derives from some embedded snipped (e.g., a piece of JS in html file) the relative position is specified in respect to the snippet, while the absolute in respect to the containing file.
Instance Attribute Summary collapse
-
#artifact(scope = :relative) ⇒ Object
Returns the value of attribute artifact.
-
#position(scope = :relative) ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
-
#absolute_position ⇒ Object
Deprecated, use position(:absolute) instead.
- #begin_column(scope = :relative) ⇒ Object
- #begin_line(scope = :relative) ⇒ Object
- #begin_point(scope = :relative) ⇒ Object
- #begin_point=(data) ⇒ Object
- #code ⇒ Object
- #embedded? ⇒ Boolean
- #embedding_level ⇒ Object
- #end_column(flag = :relative) ⇒ Object
- #end_line(scope = :relative) ⇒ Object
- #end_point(scope = :relative) ⇒ Object
- #end_point=(data) ⇒ Object
Instance Attribute Details
#artifact(scope = :relative) ⇒ Object
Returns the value of attribute artifact.
18 19 20 |
# File 'lib/codemodels/source_info.rb', line 18 def artifact @artifact end |
#position(scope = :relative) ⇒ Object
Returns the value of attribute position.
19 20 21 |
# File 'lib/codemodels/source_info.rb', line 19 def position @position end |
Instance Method Details
#absolute_position ⇒ Object
Deprecated, use position(:absolute) instead
92 93 94 95 |
# File 'lib/codemodels/source_info.rb', line 92 def absolute_position raise "#{self} is not placed in any artifact" unless @artifact @artifact.position_to_absolute(@position) end |
#begin_column(scope = :relative) ⇒ Object
63 64 65 |
# File 'lib/codemodels/source_info.rb', line 63 def begin_column(scope=:relative) position(scope).begin_point.column end |
#begin_line(scope = :relative) ⇒ Object
55 56 57 |
# File 'lib/codemodels/source_info.rb', line 55 def begin_line(scope=:relative) position(scope).begin_point.line end |
#begin_point(scope = :relative) ⇒ Object
71 72 73 |
# File 'lib/codemodels/source_info.rb', line 71 def begin_point(scope=:relative) position(scope).begin_point end |
#begin_point=(data) ⇒ Object
42 43 44 45 46 |
# File 'lib/codemodels/source_info.rb', line 42 def begin_point=(data) point = data_to_point(data) @position = SourcePosition.new unless @position @position.begin_point = point end |
#code ⇒ Object
32 33 34 |
# File 'lib/codemodels/source_info.rb', line 32 def code position(:absolute).get_string(artifact.final_host.code) end |
#embedded? ⇒ Boolean
97 98 99 |
# File 'lib/codemodels/source_info.rb', line 97 def @artifact. end |
#embedding_level ⇒ Object
101 102 103 |
# File 'lib/codemodels/source_info.rb', line 101 def @artifact. end |
#end_column(flag = :relative) ⇒ Object
67 68 69 |
# File 'lib/codemodels/source_info.rb', line 67 def end_column(flag=:relative) position(scope).end_point.column end |
#end_line(scope = :relative) ⇒ Object
59 60 61 |
# File 'lib/codemodels/source_info.rb', line 59 def end_line(scope=:relative) position(scope).end_point.line end |
#end_point(scope = :relative) ⇒ Object
75 76 77 |
# File 'lib/codemodels/source_info.rb', line 75 def end_point(scope=:relative) position(scope).end_point end |
#end_point=(data) ⇒ Object
49 50 51 52 53 |
# File 'lib/codemodels/source_info.rb', line 49 def end_point=(data) point = data_to_point(data) @position = SourcePosition.new unless @position @position.end_point = point end |