Module: Puppet::Pops::Model::SubLocatedExpression::ClassModule

Defined in:
lib/puppet/pops/model/model.rb

Instance Method Summary collapse

Instance Method Details

#locatorObject



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/puppet/pops/model/model.rb', line 306

def locator
  unless result = getLocator
    # Adapt myself to get the Locator for me
    adapter = Puppet::Pops::Adapters::SourcePosAdapter.adapt(self)
    # Get the program (root), and deal with case when not contained in a program
    program = eAllContainers.find {|c| c.is_a?(Program) }
    source_ref = program.nil? ? '' : program.source_ref

    # An outer locator is needed since SubLocator only deals with offsets. This outer locator
    # has 0,0 as origin.
    outer_locator = Puppet::Pops::Parser::Locator.locator(adpater.extract_text, source_ref, line_offsets)

    # Create a sublocator that describes an offset from the outer
    # NOTE: the offset of self is the same as the sublocator's leading_offset
    result = Puppet::Pops::Parser::Locator::SubLocator.new(outer_locator,
      leading_line_count, offset, leading_line_offset)
    setLocator(result)
  end
  result
end