class Hocon::Impl::ConfigReference
Constants
- NotPossibleToResolve
-
This exception means that a value is inherently not resolveable, at the moment the only known cause is a cycle of substitutions. This is a checked exception since it’s internal to the library and we want to be sure we handle it before passing it out to public API. This is only supposed to be thrown by the target of a cyclic reference and it’s supposed to be caught by the
ConfigReference
looking up that reference, so it should be impossible for an outermost resolve() to throw this.Contrast with ConfigException.NotResolved which just means nobody called resolve().
- UnresolvedSubstitutionError
Attributes
Public Class Methods
Source
# File lib/hocon/impl/config_reference.rb, line 21 def initialize(origin, expr, prefix_length = 0) super(origin) @expr = expr @prefix_length = prefix_length end
Hocon::Impl::AbstractConfigValue::new
Public Instance Methods
Source
# File lib/hocon/impl/config_reference.rb, line 118 def ==(other) # note that "origin" is deliberately NOT part of equality if other.is_a? Hocon::Impl::ConfigReference can_equal(other) && @expr == other.expr end end
Source
# File lib/hocon/impl/config_reference.rb, line 114 def can_equal(other) other.is_a? Hocon::Impl::ConfigReference end
Source
# File lib/hocon/impl/config_reference.rb, line 125 def hash # note that "origin" is deliberately NOT part of equality @expr.hash end
Source
# File lib/hocon/impl/config_reference.rb, line 100 def ignores_fallbacks? false end
Source
# File lib/hocon/impl/config_reference.rb, line 96 def new_copy(new_origin) Hocon::Impl::ConfigReference.new(new_origin, @expr, @prefix_length) end
Source
# File lib/hocon/impl/config_reference.rb, line 108 def relativized(prefix) new_expr = @expr.change_path(@expr.path.prepend(prefix)) Hocon::Impl::ConfigReference.new(origin, new_expr, @prefix_length + prefix.length) end
Source
# File lib/hocon/impl/config_reference.rb, line 130 def render_value_to_sb(sb, indent, at_root, options) sb << @expr.to_s end
Source
# File lib/hocon/impl/config_reference.rb, line 104 def resolve_status Hocon::Impl::ResolveStatus::UNRESOLVED end
Source
# File lib/hocon/impl/config_reference.rb, line 35 def resolve_substitutions(context, source) new_context = context.add_cycle_marker(self) begin result_with_path = source.lookup_subst(new_context, @expr, @prefix_length) new_context = result_with_path.result.context if result_with_path.result.value != nil if Hocon::Impl::ConfigImpl.trace_substitution_enabled Hocon::Impl::ConfigImpl.trace( "recursively resolving #{result_with_path} which was the resolution of #{expr} against #{source}", context.depth) end recursive_resolve_source = Hocon::Impl::ResolveSource.new( result_with_path.path_from_root.last, result_with_path.path_from_root) if Hocon::Impl::ConfigImpl.trace_substitution_enabled Hocon::Impl::ConfigImpl.trace("will recursively resolve against #{recursive_resolve_source}", context.depth) end result = new_context.resolve(result_with_path.result.value, recursive_resolve_source) v = result.value new_context = result.context else v = nil end rescue NotPossibleToResolve => e if Hocon::Impl::ConfigImpl.trace_substitution_enabled Hocon::Impl::ConfigImpl.trace( "not possible to resolve #{expr}, cycle involved: #{e.trace_string}", new_context.depth) end if @expr.optional v = nil else raise UnresolvedSubstitutionError.new( origin, "#{@expr} was part of a cycle of substitutions involving #{e.trace_string}", e) end end if v == nil && !@expr.optional if new_context.options.allow_unresolved ResolveResult.make(new_context.remove_cycle_marker(self), self) else raise UnresolvedSubstitutionError.new(origin, @expr.to_s) end else Hocon::Impl::ResolveResult.make(new_context.remove_cycle_marker(self), v) end end
ConfigReference
should be a firewall against NotPossibleToResolve
going further up the stack; it should convert everything to ConfigException. This way it ‘s impossible for NotPossibleToResolve
to “escape” since any failure to resolve has to start with a ConfigReference
.
Source
# File lib/hocon/impl/config_reference.rb, line 27 def unmerged_values [self] end
Source
# File lib/hocon/impl/config_reference.rb, line 92 def unwrapped raise not_resolved end
Source
# File lib/hocon/impl/config_reference.rb, line 88 def value_type raise not_resolved end
Private Instance Methods
Source
# File lib/hocon/impl/config_reference.rb, line 140 def not_resolved error_message = "need to Config#resolve, see the API docs for Config#resolve; substitution not resolved: #{self}" Hocon::ConfigError::ConfigNotResolvedError.new(error_message, nil) end