Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ruby/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
require "ruby/signature/substitution"
require "ruby/signature/constant"
require "ruby/signature/constant_table"
require "ruby/signature/ast/comment"

require "ruby/signature/parser"
29 changes: 29 additions & 0 deletions lib/ruby/signature/ast/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Ruby
module Signature
module AST
class Comment
attr_reader :string
attr_reader :location

def initialize(string:, location:)
@string = string
@location = location
end

def ==(other)
other.is_a?(Comment) && other.string == string
end

alias eql? ==

def hash
self.class.hash ^ string.hash
end

def to_json(*a)
{ string: string, location: location }.to_json(*a)
end
end
end
end
end
49 changes: 35 additions & 14 deletions lib/ruby/signature/ast/declarations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ def to_json(*a)
attr_reader :super_class
attr_reader :annotations
attr_reader :location
attr_reader :comment

def initialize(name:, type_params:, super_class:, members:, annotations:, location:)
def initialize(name:, type_params:, super_class:, members:, annotations:, location:, comment:)
@name = name
@type_params = type_params
@super_class = super_class
@members = members
@annotations = annotations
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -68,7 +70,8 @@ def to_json(*a)
members: members,
super_class: super_class,
annotations: annotations,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand All @@ -80,14 +83,16 @@ class Module
attr_reader :location
attr_reader :annotations
attr_reader :self_type
attr_reader :comment

def initialize(name:, type_params:, members:, self_type:, annotations:, location:)
def initialize(name:, type_params:, members:, self_type:, annotations:, location:, comment:)
@name = name
@type_params = type_params
@self_type = self_type
@members = members
@annotations = annotations
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -112,7 +117,8 @@ def to_json(*a)
members: members,
self_type: self_type,
annotations: annotations,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand All @@ -124,14 +130,16 @@ class Extension
attr_reader :members
attr_reader :annotations
attr_reader :location
attr_reader :comment

def initialize(name:, type_params:, extension_name:, members:, annotations:, location:)
def initialize(name:, type_params:, extension_name:, members:, annotations:, location:, comment:)
@name = name
@type_params = type_params
@extension_name = extension_name
@members = members
@annotations = annotations
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -156,7 +164,8 @@ def to_json(*a)
extension_name: extension_name,
members: members,
annotations: annotations,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand All @@ -167,13 +176,15 @@ class Interface
attr_reader :members
attr_reader :annotations
attr_reader :location
attr_reader :comment

def initialize(name:, type_params:, members:, annotations:, location:)
def initialize(name:, type_params:, members:, annotations:, location:, comment:)
@name = name
@type_params = type_params
@members = members
@annotations = annotations
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -196,7 +207,8 @@ def to_json(*a)
type_params: type_params,
members: members,
annotations: annotations,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand All @@ -206,12 +218,14 @@ class Alias
attr_reader :type
attr_reader :annotations
attr_reader :location
attr_reader :comment

def initialize(name:, type:, annotations:, location:)
def initialize(name:, type:, annotations:, location:, comment:)
@name = name
@type = type
@annotations = annotations
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -232,7 +246,8 @@ def to_json(*a)
name: name,
type: type,
annotations: annotations,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand All @@ -241,11 +256,13 @@ class Constant
attr_reader :name
attr_reader :type
attr_reader :location
attr_reader :comment

def initialize(name:, type:, location:)
def initialize(name:, type:, location:, comment:)
@name = name
@type = type
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -265,7 +282,8 @@ def to_json(*a)
declaration: :constant,
name: name,
type: type,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand All @@ -274,11 +292,13 @@ class Global
attr_reader :name
attr_reader :type
attr_reader :location
attr_reader :comment

def initialize(name:, type:, location:)
def initialize(name:, type:, location:, comment:)
@name = name
@type = type
@location = location
@comment = comment
end

def ==(other)
Expand All @@ -298,7 +318,8 @@ def to_json(*a)
declaration: :global,
name: name,
type: type,
location: location
location: location,
comment: comment
}.to_json(*a)
end
end
Expand Down
Loading