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

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

Instance Method Summary collapse

Instance Method Details

#locatorObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/puppet/pops/model/model.rb', line 46

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