Skip to content

Commit 7e6ca7a

Browse files
committed
Generate RBS definitions of attribute method signatures
1 parent 529cbfc commit 7e6ca7a

File tree

310 files changed

+2701
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+2701
-2
lines changed

scripts/generateFiles.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,23 @@ const convertTypeToRbs: ((type: string) => string) = (type) => {
291291
return "untyped";
292292
};
293293

294-
Handlebars.registerHelper("method_signature", (members: InterfaceResult["members"]) => {
294+
Handlebars.registerHelper("constructor_signature", (members: InterfaceResult["members"]) => {
295295
return members
296296
.map(
297297
(member) =>
298298
`${member.optional ? "?" : ""}${snake(member.name)}: ${convertTypeToRbs(member.type)}${member.nullable ? "?" : ""}`
299299
)
300300
.join(", ");
301301
});
302+
Handlebars.registerHelper("attribute_signature", (member: SerializeResult) => {
303+
const rbsType = convertTypeToRbs(member.type);
304+
let suffix = "";
305+
if (rbsType !== "untyped" && rbsType !== "nil") {
306+
suffix = member.optional || member.nullable ? "?" : "";
307+
}
308+
309+
return `${rbsType}${suffix}`;
310+
});
302311
Handlebars.registerHelper("convertTypeToRbs", convertTypeToRbs);
303312

304313
(async () => {
@@ -424,10 +433,15 @@ module LanguageServer
424433
#
425434
{{/if}}
426435
class {{definition.interface.name}}
427-
def initialize: ({{method_signature definition.allMembers}}) -> void
436+
def initialize: ({{constructor_signature definition.allMembers}}) -> void
428437
429438
@attributes: Hash[Symbol, untyped]
430439
attr_reader attributes: Hash[Symbol, untyped]
440+
{{#each definition.allMembers}}
441+
442+
%a{pure}
443+
def {{snake name}}: () -> {{attribute_signature this}}
444+
{{/each}}
431445
432446
def to_hash: () -> Hash[Symbol, untyped]
433447

sig/language_server/protocol/interface/annotated_text_edit.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ module LanguageServer
1010
@attributes: Hash[Symbol, untyped]
1111
attr_reader attributes: Hash[Symbol, untyped]
1212

13+
%a{pure}
14+
def range: () -> untyped
15+
16+
%a{pure}
17+
def new_text: () -> String
18+
19+
%a{pure}
20+
def annotation_id: () -> String
21+
1322
def to_hash: () -> Hash[Symbol, untyped]
1423

1524
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/apply_workspace_edit_params.rbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def label: () -> String?
12+
13+
%a{pure}
14+
def edit: () -> untyped
15+
1016
def to_hash: () -> Hash[Symbol, untyped]
1117

1218
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/apply_workspace_edit_result.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def applied: () -> bool
12+
13+
%a{pure}
14+
def failure_reason: () -> String?
15+
16+
%a{pure}
17+
def failed_change: () -> Integer?
18+
1019
def to_hash: () -> Hash[Symbol, untyped]
1120

1221
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_client_capabilities.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def dynamic_registration: () -> bool?
12+
1013
def to_hash: () -> Hash[Symbol, untyped]
1114

1215
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_incoming_call.rbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def from: () -> untyped
12+
13+
%a{pure}
14+
def from_ranges: () -> Array[untyped]
15+
1016
def to_hash: () -> Hash[Symbol, untyped]
1117

1218
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_incoming_calls_params.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def work_done_token: () -> untyped
12+
13+
%a{pure}
14+
def partial_result_token: () -> untyped
15+
16+
%a{pure}
17+
def item: () -> untyped
18+
1019
def to_hash: () -> Hash[Symbol, untyped]
1120

1221
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_item.rbs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def name: () -> String
12+
13+
%a{pure}
14+
def kind: () -> untyped
15+
16+
%a{pure}
17+
def tags: () -> Array[untyped]?
18+
19+
%a{pure}
20+
def detail: () -> String?
21+
22+
%a{pure}
23+
def uri: () -> String
24+
25+
%a{pure}
26+
def range: () -> untyped
27+
28+
%a{pure}
29+
def selection_range: () -> untyped
30+
31+
%a{pure}
32+
def data: () -> untyped
33+
1034
def to_hash: () -> Hash[Symbol, untyped]
1135

1236
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_options.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def work_done_progress: () -> bool?
12+
1013
def to_hash: () -> Hash[Symbol, untyped]
1114

1215
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_outgoing_call.rbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def to: () -> untyped
12+
13+
%a{pure}
14+
def from_ranges: () -> Array[untyped]
15+
1016
def to_hash: () -> Hash[Symbol, untyped]
1117

1218
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_outgoing_calls_params.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def work_done_token: () -> untyped
12+
13+
%a{pure}
14+
def partial_result_token: () -> untyped
15+
16+
%a{pure}
17+
def item: () -> untyped
18+
1019
def to_hash: () -> Hash[Symbol, untyped]
1120

1221
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_prepare_params.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def text_document: () -> untyped
12+
13+
%a{pure}
14+
def position: () -> untyped
15+
16+
%a{pure}
17+
def work_done_token: () -> untyped
18+
1019
def to_hash: () -> Hash[Symbol, untyped]
1120

1221
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/call_hierarchy_registration_options.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def document_selector: () -> untyped
12+
13+
%a{pure}
14+
def work_done_progress: () -> bool?
15+
16+
%a{pure}
17+
def id: () -> String?
18+
1019
def to_hash: () -> Hash[Symbol, untyped]
1120

1221
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/cancel_params.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def id: () -> untyped
12+
1013
def to_hash: () -> Hash[Symbol, untyped]
1114

1215
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/change_annotation.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ module LanguageServer
1010
@attributes: Hash[Symbol, untyped]
1111
attr_reader attributes: Hash[Symbol, untyped]
1212

13+
%a{pure}
14+
def label: () -> String
15+
16+
%a{pure}
17+
def needs_confirmation: () -> bool?
18+
19+
%a{pure}
20+
def description: () -> String?
21+
1322
def to_hash: () -> Hash[Symbol, untyped]
1423

1524
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/client_capabilities.rbs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def workspace: () -> untyped
12+
13+
%a{pure}
14+
def text_document: () -> untyped
15+
16+
%a{pure}
17+
def notebook_document: () -> untyped
18+
19+
%a{pure}
20+
def window: () -> untyped
21+
22+
%a{pure}
23+
def general: () -> untyped
24+
25+
%a{pure}
26+
def experimental: () -> untyped
27+
1028
def to_hash: () -> Hash[Symbol, untyped]
1129

1230
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/code_action.rbs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@ module LanguageServer
1414
@attributes: Hash[Symbol, untyped]
1515
attr_reader attributes: Hash[Symbol, untyped]
1616

17+
%a{pure}
18+
def title: () -> String
19+
20+
%a{pure}
21+
def kind: () -> String?
22+
23+
%a{pure}
24+
def diagnostics: () -> Array[untyped]?
25+
26+
%a{pure}
27+
def is_preferred: () -> bool?
28+
29+
%a{pure}
30+
def disabled: () -> untyped
31+
32+
%a{pure}
33+
def edit: () -> untyped
34+
35+
%a{pure}
36+
def command: () -> untyped
37+
38+
%a{pure}
39+
def data: () -> untyped
40+
1741
def to_hash: () -> Hash[Symbol, untyped]
1842

1943
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/code_action_client_capabilities.rbs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def dynamic_registration: () -> bool?
12+
13+
%a{pure}
14+
def code_action_literal_support: () -> untyped
15+
16+
%a{pure}
17+
def is_preferred_support: () -> bool?
18+
19+
%a{pure}
20+
def disabled_support: () -> bool?
21+
22+
%a{pure}
23+
def data_support: () -> bool?
24+
25+
%a{pure}
26+
def resolve_support: () -> untyped
27+
28+
%a{pure}
29+
def honors_change_annotations: () -> bool?
30+
1031
def to_hash: () -> Hash[Symbol, untyped]
1132

1233
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/code_action_context.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ module LanguageServer
1111
@attributes: Hash[Symbol, untyped]
1212
attr_reader attributes: Hash[Symbol, untyped]
1313

14+
%a{pure}
15+
def diagnostics: () -> Array[untyped]
16+
17+
%a{pure}
18+
def only: () -> Array[String]?
19+
20+
%a{pure}
21+
def trigger_kind: () -> untyped
22+
1423
def to_hash: () -> Hash[Symbol, untyped]
1524

1625
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/code_action_options.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ module LanguageServer
77
@attributes: Hash[Symbol, untyped]
88
attr_reader attributes: Hash[Symbol, untyped]
99

10+
%a{pure}
11+
def work_done_progress: () -> bool?
12+
13+
%a{pure}
14+
def code_action_kinds: () -> Array[String]?
15+
16+
%a{pure}
17+
def resolve_provider: () -> bool?
18+
1019
def to_hash: () -> Hash[Symbol, untyped]
1120

1221
def to_json: (*untyped) -> String

sig/language_server/protocol/interface/code_action_params.rbs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ module LanguageServer
1010
@attributes: Hash[Symbol, untyped]
1111
attr_reader attributes: Hash[Symbol, untyped]
1212

13+
%a{pure}
14+
def work_done_token: () -> untyped
15+
16+
%a{pure}
17+
def partial_result_token: () -> untyped
18+
19+
%a{pure}
20+
def text_document: () -> untyped
21+
22+
%a{pure}
23+
def range: () -> untyped
24+
25+
%a{pure}
26+
def context: () -> untyped
27+
1328
def to_hash: () -> Hash[Symbol, untyped]
1429

1530
def to_json: (*untyped) -> String

0 commit comments

Comments
 (0)