lib/rubocop/rbs/cop_base.rb in rubocop-on-rbs-0.3.0 vs lib/rubocop/rbs/cop_base.rb in rubocop-on-rbs-0.4.0
- old
+ new
@@ -84,8 +84,34 @@
end
def location_to_range(location)
range_between(location.start_pos, location.end_pos)
end
+
+ def tokenize(source)
+ ::RBS::Parser.lex(source).value.reject { |t| t.type == :tTRIVIA }
+ end
+
+ def on_type(types, type, &block)
+ case type
+ when *types
+ yield type
+ end
+ type.each_type do |t|
+ on_type(types, t, &block)
+ end
+ end
+
+ def on_not_type(types, type, &block)
+ case type
+ when *types
+ # not
+ else
+ yield type
+ end
+ type.each_type do |t|
+ on_not_type(types, t, &block)
+ end
+ end
end
end
end