Class: RBS::AST::Declarations::Constant

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

Instance Method Summary collapse

Instance Method Details

#format(q) ⇒ Object

Prints out a constant declaration, which looks like: Foo: String



92
93
94
95
96
97
98
99
100
# File 'lib/syntax_tree/rbs/declarations.rb', line 92

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

  q.group do
    name.format(q)
    q.text(": ")
    type.format(q)
  end
end

#pretty_print(q) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/syntax_tree/rbs/declarations.rb', line 102

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

    q.breakable
    q.text("name=")
    q.pp(name)

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