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
4 changes: 4 additions & 0 deletions lib/rbs/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ def write_decl(decl)
puts "end"
when AST::Declarations::Constant
write_comment decl.comment
write_annotation decl.annotations
puts "#{decl.name}: #{decl.type}"

when AST::Declarations::Global
write_comment decl.comment
write_annotation decl.annotations
puts "#{decl.name}: #{decl.type}"

when AST::Declarations::TypeAlias
Expand All @@ -174,12 +176,14 @@ def write_decl(decl)

when AST::Declarations::ClassAlias
write_comment decl.comment
write_annotation decl.annotations
write_loc_source(decl) {
puts "class #{decl.new_name} = #{decl.old_name}"
}

when AST::Declarations::ModuleAlias
write_comment decl.comment
write_annotation decl.annotations
write_loc_source(decl) {
puts "module #{decl.new_name} = #{decl.old_name}"
}
Expand Down
31 changes: 31 additions & 0 deletions test/rbs/writer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@ module C = D
SIG
end

def test_annotated_decl
assert_writer <<-SIG
%a{deprecated}
FOO: Integer

%a{deprecated}
$foo: Integer

# Alias of B.
%a{deprecated}
class A = B

# Alias of D.
%a{deprecated}
module C = D

module Foo
%a{deprecated}
FOO: Integer

# Alias of B.
%a{deprecated}
class A = B

# Alias of D.
%a{deprecated}
module C = D
end
SIG
end

def test_class_decl
assert_writer <<-SIG
class Foo::Bar[X] < Array[String]
Expand Down
Loading