Sha256: 0e911b79217d47842a9f36aac48f047fb70779c2510491cfb91d7fbc86616aad
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
module RGen module Instantiator # This module is meant to be mixed into a resolver class providing the method +resolveIdentifier+ module ReferenceResolver # Instances of this class represent information about not yet resolved references. # This consists of the +element+ and metamodel +featureName+ which hold/is to hold the reference # and the proxy object which is the placeholder for the reference. UnresolvedReference = Struct.new(:element, :featureName, :proxy) # tries to resolve the given +unresolvedReferences+ # if resolution is successful, the proxy object will be removed # otherwise there will be an error description in +problems+ # returns an array of the references which are still unresolved def resolveReferences(unresolvedReferences, problems=[]) stillUnresolvedReferences = [] unresolvedReferences.each do |ur| target = resolveIdentifier(ur.proxy.targetIdentifier) if target && !target.is_a?(Array) if ur.element.hasManyMethods(ur.featureName) ur.element.removeGeneric(ur.featureName, ur.proxy) ur.element.addGeneric(ur.featureName, target) else # this will replace the proxy ur.element.setGeneric(ur.featureName, target) end elsif target problems << "identifier #{ur.proxy.targetIdentifier} not uniq" stillUnresolvedReferences << ur else problems << "identifier #{ur.proxy.targetIdentifier} not found" stillUnresolvedReferences << ur end end stillUnresolvedReferences end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rgen-0.5.3 | lib/rgen/instantiator/reference_resolver.rb |
rgen-0.5.4 | lib/rgen/instantiator/reference_resolver.rb |
rgen-0.5.2 | lib/rgen/instantiator/reference_resolver.rb |