Sha256: 23e50f7b52a1984398d51291e17a49b6033328220778f02ab63faf59ef2f47f7

Contents?: true

Size: 893 Bytes

Versions: 4

Compression:

Stored size: 893 Bytes

Contents

require 'unparser'

module Yoda
  module Model
    module Descriptions
      class NodeDescription < Base
        # @return [::Parser::AST::Node]
        attr_reader :node

        # @return [Typing::Traces::Base]
        attr_reader :trace

        # @param node  [::Parser::AST::Node]
        # @param trace [Typing::Traces::Base]
        def initialize(node, trace)
          @node = node
          @trace = trace
        end

        # @return [String]
        def title
          node_body
        end

        # @return [String]
        def sort_text
          node_body
        end

        # @return [String]
        def to_markdown
          <<~EOS
          #{node_body.gsub("\n", ";")}: #{trace.type}
          EOS
        end

        private

        # @return [String]
        def node_body
          @node_body ||= Unparser.unparse(node)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoda-language-server-0.7.2 lib/yoda/model/descriptions/node_description.rb
yoda-language-server-0.7.1 lib/yoda/model/descriptions/node_description.rb
yoda-language-server-0.7.0 lib/yoda/model/descriptions/node_description.rb
yoda-language-server-0.6.2 lib/yoda/model/descriptions/node_description.rb