Sha256: 4d303129c0710a8956bdd05ebe53134e44d3e669a7e17faabbaec91a6ed199bc

Contents?: true

Size: 766 Bytes

Versions: 14

Compression:

Stored size: 766 Bytes

Contents

require "expressir/express_exp/model_visitor"
require "expressir/model"

module Expressir
  module ExpressExp
    class ResolveReferencesModelVisitor < ModelVisitor
      def visit(node)
        if node.is_a? Model::Expressions::SimpleReference
          visit_expressions_simple_reference(node)
        end

        super
      end

      def visit_expressions_simple_reference(node)
        return if node.parent.is_a? Model::Expressions::AttributeReference

        if node.parent.is_a? Model::InterfaceItem
          base_item = node.find("#{node.parent.parent.schema.id}.#{node.parent.ref.id}")
        else
          base_item = node.find(node.id)
        end
        return unless base_item

        node.base_path = base_item.path
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
expressir-0.2.27 lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.27-x86_64-linux lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.27-x86_64-darwin lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.27-x86-mingw32 lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.27-x86-linux lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.27-x64-mingw32 lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.27-arm64-darwin lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26 lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26-x86_64-linux lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26-x86_64-darwin lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26-x86-mingw32 lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26-x86-linux lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26-x64-mingw32 lib/expressir/express_exp/resolve_references_model_visitor.rb
expressir-0.2.26-arm64-darwin lib/expressir/express_exp/resolve_references_model_visitor.rb