Class: Solargraph::SourceMap::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/source_map/region.rb

Overview

Data used by the NodeProcessor library to track context at various locations in a source.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source: Solargraph::Source.load_string(''), closure: nil, scope: nil, visibility: :public) ⇒ Region


23
24
25
26
27
28
29
30
# File 'lib/solargraph/source_map/region.rb', line 23

def initialize source: Solargraph::Source.load_string(''), closure: nil,
               scope: nil, visibility: :public
  @source = source
  # @closure = closure
  @closure = closure || Pin::Namespace.new(name: '', location: source.location)
  @scope = scope
  @visibility = visibility
end

Instance Attribute Details

#closurePin::Closure (readonly)


8
9
10
# File 'lib/solargraph/source_map/region.rb', line 8

def closure
  @closure
end

#scopeSymbol (readonly)


11
12
13
# File 'lib/solargraph/source_map/region.rb', line 11

def scope
  @scope
end

#sourceSolargraph::Source (readonly)


17
18
19
# File 'lib/solargraph/source_map/region.rb', line 17

def source
  @source
end

#visibilitySymbol (readonly)


14
15
16
# File 'lib/solargraph/source_map/region.rb', line 14

def visibility
  @visibility
end

Instance Method Details

#code_for(node) ⇒ String


54
55
56
# File 'lib/solargraph/source_map/region.rb', line 54

def code_for node
  source.code_for(node)
end

#filenameString


33
34
35
# File 'lib/solargraph/source_map/region.rb', line 33

def filename
  source.filename
end

#update(closure: nil, scope: nil, visibility: nil) ⇒ Region

Generate a new Region with the provided attribute changes.


43
44
45
46
47
48
49
50
# File 'lib/solargraph/source_map/region.rb', line 43

def update closure: nil, scope: nil, visibility: nil
  Region.new(
    source: source,
    closure: closure || self.closure,
    scope: scope || self.scope,
    visibility: visibility || self.visibility
  )
end