Sha256: 21af0fb8c401b2c061f5786553b39d590ec305574fc05e36395b334fe805da49

Contents?: true

Size: 970 Bytes

Versions: 21

Compression:

Stored size: 970 Bytes

Contents

require "expressir/express_exp/formatter"

module Expressir
  module ExpressExp
    class HyperlinkFormatter < Formatter
      def format_expressions_simple_reference(node)
        return node.id if node.parent.is_a? Model::Expressions::AttributeReference

        # skip hyperlink if target node can't be found
        target_node = node.find(node.id)
        return node.id unless target_node

        # skip hyperlink for implicit scopes
        return node.id if target_node.is_a? Model::Statements::Alias or target_node.is_a? Model::Statements::Repeat or target_node.is_a? Model::Expressions::QueryExpression

        # skip hyperlink if this node and target node are in the same main item
        node_path_parts = node.path.split(".")
        target_node_path_parts = target_node.path.split(".")
        return node.id if node_path_parts[0..1] == target_node_path_parts[0..1]

        "{{{<<express:#{target_node.path},#{node.id}>>}}}"
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
expressir-0.2.14 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.14-x86_64-linux lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.14-x86_64-darwin lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.14-x86-mingw32 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.14-x86-linux lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.14-x64-mingw32 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.14-arm64-darwin lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13-x86_64-linux lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13-x86_64-darwin lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13-x86-mingw32 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13-x86-linux lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13-x64-mingw32 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.13-arm64-darwin lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.12 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.12-x86_64-linux lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.12-x86_64-darwin lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.12-x86-mingw32 lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.12-x86-linux lib/expressir/express_exp/hyperlink_formatter.rb
expressir-0.2.12-x64-mingw32 lib/expressir/express_exp/hyperlink_formatter.rb