Sha256: 1cf9f474962105b3586d550d2e994e9a16fc15c2672881a50ee203cd981fb28b

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

module Yoda
  module Parsing
    module Scopes
      # Wrapper class for instance method node.
      # @see https://github.com/whitequark/parser/blob/2.2/doc/AST_FORMAT.md#instance-methods
      # ```
      # (def :foo (args) nil)
      # "def foo; end"
      #  ~~~ keyword
      #      ~~~ name
      #           ~~~ end
      #  ~~~~~~~~~~~~ expression
      # ```
      class MethodDefinition < Base
        # @return [Symbol]
        def name
          node.children[0]
        end

        # @return [Parser::AST::Node]
        def arg_node
          node.children[1]
        end

        # @return [Parser::AST::Node]
        def body_node
          node.children[2]
        end

        # @return [Array<Parser::AST::Node>]
        def body_nodes
          [body_node]
        end

        # @return [String]
        def full_name
          "#{namespace.full_name}##{name}"
        end

        # @return [String]
        def namespace_name
          namespace.full_name
        end

        def singleton?
          false
        end

        def kind
          :method
        end

        def method?
          true
        end

        # @return [String]
        def scope_name
          parent.scope_name
        end

        # @return [Array<String>]
        def ancestor_scopes
          parent.ancestor_scopes
        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/method_definition.rb
yoda-language-server-0.10.0 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.9.0 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.8.0 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.7.2 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.7.1 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.7.0 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.6.2 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.6.1 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.6.0 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.5.0 lib/yoda/parsing/scopes/method_definition.rb
yoda-language-server-0.4.0 lib/yoda/parsing/scopes/method_definition.rb