Skip to content

Commit 60c9aaa

Browse files
authored
Merge pull request #116 from tomoasleep/add-attribute-signature
Generate RBS signatures of attribute method signatures
2 parents c7d8677 + 7e6ca7a commit 60c9aaa

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

0 commit comments

Comments
 (0)