Class: Solargraph::Parser::Region
- Inherits:
-
Object
- Object
- Solargraph::Parser::Region
- Defined in:
- lib/solargraph/parser/region.rb
Overview
Data used by the parser to track context at various locations in a source.
Instance Attribute Summary collapse
- #closure ⇒ Pin::Closure readonly
- #lvars ⇒ Array<Symbol> readonly
- #scope ⇒ Symbol readonly
- #source ⇒ Solargraph::Source readonly
- #visibility ⇒ Symbol readonly
Instance Method Summary collapse
- #code_for(node) ⇒ String
- #filename ⇒ String
-
#initialize(source: Solargraph::Source.load_string(''), closure: nil, scope: nil, visibility: :public, lvars: []) ⇒ Region
constructor
A new instance of Region.
-
#update(closure: nil, scope: nil, visibility: nil, lvars: nil) ⇒ Region
Generate a new Region with the provided attribute changes.
Constructor Details
#initialize(source: Solargraph::Source.load_string(''), closure: nil, scope: nil, visibility: :public, lvars: []) ⇒ Region
Returns a new instance of Region.
28 29 30 31 32 33 34 35 36 |
# File 'lib/solargraph/parser/region.rb', line 28 def initialize source: Solargraph::Source.load_string(''), closure: nil, scope: nil, visibility: :public, lvars: [] @source = source # @closure = closure @closure = closure || Pin::Namespace.new(name: '', location: source.location) @scope = scope @visibility = visibility @lvars = lvars end |
Instance Attribute Details
#closure ⇒ Pin::Closure (readonly)
10 11 12 |
# File 'lib/solargraph/parser/region.rb', line 10 def closure @closure end |
#lvars ⇒ Array<Symbol> (readonly)
22 23 24 |
# File 'lib/solargraph/parser/region.rb', line 22 def lvars @lvars end |
#scope ⇒ Symbol (readonly)
13 14 15 |
# File 'lib/solargraph/parser/region.rb', line 13 def scope @scope end |
#source ⇒ Solargraph::Source (readonly)
19 20 21 |
# File 'lib/solargraph/parser/region.rb', line 19 def source @source end |
#visibility ⇒ Symbol (readonly)
16 17 18 |
# File 'lib/solargraph/parser/region.rb', line 16 def visibility @visibility end |
Instance Method Details
#code_for(node) ⇒ String
61 62 63 |
# File 'lib/solargraph/parser/region.rb', line 61 def code_for node source.code_for(node) end |
#filename ⇒ String
39 40 41 |
# File 'lib/solargraph/parser/region.rb', line 39 def filename source.filename end |
#update(closure: nil, scope: nil, visibility: nil, lvars: nil) ⇒ Region
Generate a new Region with the provided attribute changes.
49 50 51 52 53 54 55 56 57 |
# File 'lib/solargraph/parser/region.rb', line 49 def update closure: nil, scope: nil, visibility: nil, lvars: nil Region.new( source: source, closure: closure || self.closure, scope: scope || self.scope, visibility: visibility || self.visibility, lvars: lvars || self.lvars ) end |