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

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

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Method Summary collapse

Instance Method Details

#locatorObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/puppet/pops/model/model.rb', line 55

def locator
  unless result = getLocator
    # Adapt myself to get the Locator for me
    adapter = 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 = 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 = Parser::Locator::SubLocator.new(outer_locator,
      leading_line_count, offset, leading_line_offset)
    setLocator(result)
  end
  result
end