Skip to content

Commit f06a485

Browse files
committed
Expose Block location
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
1 parent 75886d4 commit f06a485

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ nodes:
345345
- name: RBS::Types::Bases::Top
346346
- name: RBS::Types::Bases::Void
347347
- name: RBS::Types::Block
348-
expose_location: false
348+
expose_location: true
349349
fields:
350350
- name: type
351351
c_type: rbs_node

ext/rbs_extension/ast_translation.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
905905
rbs_types_block_t *node = (rbs_types_block_t *)instance;
906906

907907
VALUE h = rb_hash_new();
908+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
908909
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
909910
rb_hash_aset(h, ID2SYM(rb_intern("required")), node->required ? Qtrue : Qfalse);
910911
rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node

lib/rbs/types.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,10 @@ class Block
13391339
attr_reader :type
13401340
attr_reader :required
13411341
attr_reader :self_type
1342+
attr_reader :location
13421343

1343-
def initialize(type:, required:, self_type: nil)
1344+
def initialize(location: nil, type:, required:, self_type: nil)
1345+
@location = location
13441346
@type = type
13451347
@required = required ? true : false
13461348
@self_type = self_type

0 commit comments

Comments
 (0)