lib/rbs/ast/members.rb in rbs-0.4.0 vs lib/rbs/ast/members.rb in rbs-0.5.0

- old
+ new

@@ -1,58 +1,82 @@ module RBS module AST module Members - class MethodDefinition + class Base + end + + class MethodDefinition < Base attr_reader :name attr_reader :kind attr_reader :types attr_reader :annotations attr_reader :location attr_reader :comment attr_reader :attributes + attr_reader :overload - def initialize(name:, kind:, types:, annotations:, location:, comment:, attributes:) + def initialize(name:, kind:, types:, annotations:, location:, comment:, attributes:, overload:) @name = name @kind = kind @types = types @annotations = annotations @location = location @comment = comment @attributes = attributes + @overload = overload end def ==(other) other.is_a?(MethodDefinition) && other.name == name && other.kind == kind && other.types == types && - other.attributes == attributes + other.attributes == attributes && + other.overload == overload end alias eql? == def hash - self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ attributes.hash + self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ attributes.hash ^ overload.hash end def instance? kind == :instance || kind == :singleton_instance end def singleton? kind == :singleton || kind == :singleton_instance end + def overload? + overload + end + + def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, attributes: self.attributes, overload: self.overload) + self.class.new( + name: name, + kind: kind, + types: types, + annotations: annotations, + location: location, + comment: comment, + attributes: attributes, + overload: overload + ) + end + def to_json(*a) { member: :method_definition, kind: kind, types: types, annotations: annotations, location: location, comment: comment, - attributes: attributes + attributes: attributes, + overload: overload }.to_json(*a) end end module Var @@ -77,11 +101,11 @@ def hash self.class.hash ^ name.hash ^ type.hash end end - class InstanceVariable + class InstanceVariable < Base include Var def to_json(*a) { member: :instance_variable, @@ -91,11 +115,11 @@ comment: comment }.to_json(*a) end end - class ClassInstanceVariable + class ClassInstanceVariable < Base include Var def to_json(*a) { member: :class_instance_variable, @@ -105,11 +129,11 @@ comment: comment }.to_json(*a) end end - class ClassVariable + class ClassVariable < Base include Var def to_json(*a) { member: :class_variable, @@ -147,11 +171,11 @@ def hash self.class.hash ^ name.hash ^ args.hash end end - class Include + class Include < Base include Mixin def to_json(*a) { member: :include, @@ -162,11 +186,11 @@ comment: comment }.to_json(*a) end end - class Extend + class Extend < Base include Mixin def to_json(*a) { member: :extend, @@ -177,11 +201,11 @@ comment: comment }.to_json(*a) end end - class Prepend + class Prepend < Base include Mixin def to_json(*a) { member: :prepend, @@ -223,11 +247,11 @@ def hash self.class.hash ^ name.hash ^ type.hash ^ ivar_name.hash end end - class AttrReader + class AttrReader < Base include Attribute def to_json(*a) { member: :attr_reader, @@ -239,11 +263,11 @@ comment: comment }.to_json(*a) end end - class AttrAccessor + class AttrAccessor < Base include Attribute def to_json(*a) { member: :attr_accessor, @@ -255,11 +279,11 @@ comment: comment }.to_json(*a) end end - class AttrWriter + class AttrWriter < Base include Attribute def to_json(*a) { member: :attr_writer, @@ -289,26 +313,26 @@ def hash self.class.hash end end - class Public + class Public < Base include LocationOnly def to_json(*a) { member: :public, location: location }.to_json(*a) end end - class Private + class Private < Base include LocationOnly def to_json(*a) { member: :private, location: location }.to_json(*a) end end - class Alias + class Alias < Base attr_reader :new_name attr_reader :old_name attr_reader :kind attr_reader :annotations attr_reader :location