-
Notifications
You must be signed in to change notification settings - Fork 216
/
Copy pathdirectives.rbs
77 lines (58 loc) · 1.79 KB
/
directives.rbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
module RBS
module AST
module Directives
type t = Use | ResolveTypeNames
class Base
end
# ```
# use Foo, Foo::Bar as FBar, Foo:Baz::*
# ```
#
class Use < Base
type clause = SingleClause | WildcardClause
class SingleClause
# Foo::Bar
# ^^^^^^^^ type_name
#
# Foo::Bar as X
# ^^ keyword
# ^ new_name
#
type loc = Location[:type_name, :keyword | :new_name]
attr_reader type_name: TypeName
attr_reader new_name: Symbol?
attr_reader location: loc?
def initialize: (type_name: TypeName, new_name: Symbol?, location: loc?) -> void
end
class WildcardClause
# Foo::Bar::*
# ^^^^^^^^^^ namespace
# ^ star
#
type loc = Location[:namespace | :star, bot]
attr_reader namespace: Namespace
attr_reader location: loc?
def initialize: (namespace: Namespace, location: loc?) -> void
end
# use Foo
# ^^^ keyword
type loc = Location[:keyword, bot]
attr_reader clauses: Array[clause]
attr_reader location: loc?
def initialize: (clauses: Array[clause], location: loc?) -> void
end
class ResolveTypeNames < Base
# ```
# # resolve-type-names: false
# ^^^^^^^^^^^^^^^^^^ keyword
# ^ colon
# ^^^^^ value
# ```
type loc = Location[:keyword | :colon | :value, bot]
attr_reader location: loc?
attr_reader value: bool
def initialize: (value: bool, location: loc?) -> void
end
end
end
end