module Puppet::Pops::Evaluator::ExternalSyntaxSupport
Public Instance Methods
assert_external_syntax(_, result, syntax, reference_expr)
click to toggle source
# File lib/puppet/pops/evaluator/external_syntax_support.rb 6 def assert_external_syntax(_, result, syntax, reference_expr) 7 # ignore 'unspecified syntax' 8 return if syntax.nil? || syntax == '' 9 10 checker = checker_for_syntax(nil, syntax) 11 # ignore syntax with no matching checker 12 return unless checker 13 14 # Call checker and give it the location information from the expression 15 # (as opposed to where the heredoc tag is (somewhere on the line above)). 16 acceptor = Puppet::Pops::Validation::Acceptor.new() 17 checker.check(result, syntax, acceptor, reference_expr) 18 19 if acceptor.error_count > 0 20 checker_message = "Invalid produced text having syntax: '#{syntax}'." 21 Puppet::Pops::IssueReporter.assert_and_report(acceptor, :message => checker_message) 22 raise ArgumentError, _("Internal Error: Configuration of runtime error handling wrong: should have raised exception") 23 end 24 end
checker_for_syntax(_, syntax)
click to toggle source
Finds the most significant checker for the given syntax (most significant is to the right). Returns nil if there is no registered checker.
# File lib/puppet/pops/evaluator/external_syntax_support.rb 29 def checker_for_syntax(_, syntax) 30 checkers_hash = Puppet.lookup(:plugins)[Puppet::Plugins::SyntaxCheckers::SYNTAX_CHECKERS_KEY] 31 checkers_hash[lookup_keys_for_syntax(syntax).find {|x| checkers_hash[x] }] 32 end
lookup_keys_for_syntax(syntax)
click to toggle source
Returns an array of possible syntax names
# File lib/puppet/pops/evaluator/external_syntax_support.rb 35 def lookup_keys_for_syntax(syntax) 36 segments = syntax.split(/\+/) 37 result = [] 38 loop do 39 result << segments.join("+") 40 segments.shift 41 break if segments.empty? 42 end 43 result 44 end