lib/rbs/ast/members.rb in rbs-2.1.0 vs lib/rbs/ast/members.rb in rbs-2.2.0

- old
+ new

@@ -10,33 +10,36 @@ attr_reader :types attr_reader :annotations attr_reader :location attr_reader :comment attr_reader :overload + attr_reader :visibility - def initialize(name:, kind:, types:, annotations:, location:, comment:, overload:) + def initialize(name:, kind:, types:, annotations:, location:, comment:, overload:, visibility: nil) @name = name @kind = kind @types = types @annotations = annotations @location = location @comment = comment @overload = overload ? true : false + @visibility = visibility end def ==(other) other.is_a?(MethodDefinition) && other.name == name && other.kind == kind && other.types == types && - other.overload == overload + other.overload == overload && + other.visibility == visibility end alias eql? == def hash - self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ overload.hash + name.hash ^ kind.hash ^ types.hash ^ overload.hash end def instance? kind == :instance || kind == :singleton_instance end @@ -47,19 +50,20 @@ def overload? overload end - def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload) + def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload, visibility: self.visibility) self.class.new( name: name, kind: kind, types: types, annotations: annotations, location: location, comment: comment, - overload: overload + overload: overload, + visibility: visibility ) end def to_json(state = _ = nil) { @@ -92,11 +96,11 @@ end alias eql? == def hash - self.class.hash ^ name.hash ^ type.hash + name.hash ^ type.hash end end class InstanceVariable < Base include Var @@ -162,11 +166,11 @@ def eql?(other) self == other end def hash - self.class.hash ^ name.hash ^ args.hash + name.hash ^ args.hash end end class Include < Base include Mixin @@ -219,45 +223,49 @@ attr_reader :kind attr_reader :ivar_name attr_reader :annotations attr_reader :location attr_reader :comment + attr_reader :visibility - def initialize(name:, type:, ivar_name:, kind:, annotations:, location:, comment:) + def initialize(name:, type:, ivar_name:, kind:, annotations:, location:, comment:, visibility: nil) @name = name @type = type @ivar_name = ivar_name @annotations = annotations @location = location @comment = comment @kind = kind + @visibility = visibility end def ==(other) other.is_a?(self.class) && other.name == name && other.type == type && other.ivar_name == ivar_name && - other.kind == kind + other.kind == kind && + other.visibility == visibility end alias eql? == def hash - self.class.hash ^ name.hash ^ type.hash ^ ivar_name.hash ^ kind.hash + name.hash ^ type.hash ^ ivar_name.hash ^ kind.hash ^ visibility.hash end - def update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: self.kind, annotations: self.annotations, location: self.location, comment: self.comment) + def update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: self.kind, annotations: self.annotations, location: self.location, comment: self.comment, visibility: self.visibility) klass = _ = self.class klass.new( name: name, type: type, ivar_name: ivar_name, kind: kind, annotations: annotations, location: location, - comment: comment + comment: comment, + visibility: visibility ) end end class AttrReader < Base @@ -370,10 +378,10 @@ end alias eql? == def hash - self.class.hash ^ new_name.hash ^ old_name.hash ^ kind.hash + new_name.hash ^ old_name.hash ^ kind.hash end def to_json(state = _ = nil) { member: :alias,