Sha256: 5326313703753217b3bd55687c440750e0e739846f7c5cef0ea662153b42ad5a

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

module Yoda
  module Parsing
    module Scopes
      # Wrapper class for class node.
      # @see https://github.com/whitequark/parser/blob/2.2/doc/AST_FORMAT.md#class
      # ```
      # (class (const nil :Foo) (const nil :Bar) (nil))
      # "class Foo < Bar; end"
      #  ~~~~~ keyword    ~~~ end
      #            ~ operator
      #  ~~~~~~~~~~~~~~~~~~~~ expression
      #
      # (class (const nil :Foo) nil (nil))
      # "class Foo; end"
      #  ~~~~~ keyword
      #             ~~~ end
      #  ~~~~~~~~~~~~~~ expression
      # ```
      class ClassDefinition < Base
        def const_node
          @const_node ||= NodeObjects::ConstNode.new(node.children[0])
        end

        def superclass_const_node
          @superclass_const_node ||= node.children && NodeObjects::ConstNode.new(node.children[1])
        end

        def body_nodes
          [body_node]
        end

        def body_node
          node.children.last
        end

        def kind
          :class
        end

        # @return [String]
        def scope_name
          const_node.to_s(parent.scope_name)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.10.0 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.9.0 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.8.0 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.7.2 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.7.1 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.7.0 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.6.2 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.6.1 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.6.0 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.5.0 lib/yoda/parsing/scopes/class_definition.rb
yoda-language-server-0.4.0 lib/yoda/parsing/scopes/class_definition.rb