Class: RBS::AST::Declarations::Interface

Inherits:
Object
  • Object
show all
Includes:
ShimTypeParams
Defined in:
lib/syntax_tree/rbs/declarations.rb

Instance Method Summary collapse

Methods included from ShimTypeParams

#type_params

Instance Method Details

#format(q) ⇒ Object

Prints out an interface declaration, which looks like: interface _Foo end



148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/syntax_tree/rbs/declarations.rb', line 148

def format(q)
  SyntaxTree::RBS::Comment.maybe_format(q, comment)
  SyntaxTree::RBS::Annotations.maybe_format(q, annotations)

  q.group do
    q.text("interface ")
    SyntaxTree::RBS::NameAndTypeParams.new(self).format(q)
    q.indent { SyntaxTree::RBS::Members.new(self).format(q) }
    q.breakable(force: true)
    q.text("end")
  end
end

#pretty_print(q) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/syntax_tree/rbs/declarations.rb', line 161

def pretty_print(q)
  q.group(2, "(interface", ")") do
    SyntaxTree::RBS::Comment.maybe_pretty_print(q, comment)
    SyntaxTree::RBS::Annotations.maybe_pretty_print(q, annotations)

    q.pp(SyntaxTree::RBS::NameAndTypeParams.new(self))

    q.breakable
    q.text("members=")
    q.pp(members)
  end
end