-
Notifications
You must be signed in to change notification settings - Fork 24
Add support for new Sorbet configs (Cache, Prism, and RBS) #888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,12 +32,30 @@ class Config | |
| #: bool | ||
| attr_accessor :no_stdlib | ||
|
|
||
| #: String? | ||
| attr_accessor :cache_dir | ||
|
|
||
| #: Symbol? | ||
| attr_accessor :parser | ||
|
|
||
| #: bool | ||
| attr_accessor :use_rbs | ||
|
|
||
| #: -> bool | ||
| def parse_with_prism? = @parser == :prism | ||
|
|
||
| #: -> bool | ||
| def use_rbs? = @use_rbs | ||
|
|
||
| #: -> void | ||
| def initialize | ||
| @paths = [] #: Array[String] | ||
| @ignore = [] #: Array[String] | ||
| @allowed_extensions = [] #: Array[String] | ||
| @no_stdlib = false #: bool | ||
| @cache_dir = nil #: String? | ||
| @parser = nil #: Symbol? | ||
| @use_rbs = false #: bool | ||
| end | ||
|
|
||
| #: -> Config | ||
|
|
@@ -47,6 +65,9 @@ def copy | |
| new_config.ignore.concat(@ignore) | ||
| new_config.allowed_extensions.concat(@allowed_extensions) | ||
| new_config.no_stdlib = @no_stdlib | ||
| new_config.cache_dir = @cache_dir | ||
| new_config.parser = @parser | ||
| new_config.use_rbs = @use_rbs | ||
| new_config | ||
| end | ||
|
|
||
|
|
@@ -69,6 +90,8 @@ def options_string | |
| opts.concat(ignore.map { |p| "--ignore '#{p}'" }) | ||
| opts.concat(allowed_extensions.map { |ext| "--allowed-extension '#{ext}'" }) | ||
| opts << "--no-stdlib" if @no_stdlib | ||
| opts << "--cache-dir='#{@cache_dir}'" if @cache_dir | ||
| opts << "--parser=#{@parser}" if @parser | ||
| opts.join(" ") | ||
| end | ||
|
|
||
|
|
@@ -110,6 +133,16 @@ def parse_string(sorbet_config) | |
| when /^--no-stdlib(=|$)/ | ||
| config.no_stdlib = parse_bool_option(line) | ||
| next | ||
| when /^--cache-dir=/ | ||
| value = parse_option(line) | ||
| config.cache_dir = value.empty? ? nil : value | ||
| next | ||
| when /^--parser=/ | ||
| config.parser = parse_option(line).to_sym | ||
| next | ||
| when /^--enable-experimental-rbs-(comments|signatures|assertions)(=|$)/ | ||
| config.use_rbs = parse_bool_option(line) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering about the three separate RBS flags ( The last one wins and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I was trying to keep it simple, since the whole point of the deprecation was to not have to worry about the distinction (like I think I'll change this to use the ORing of values, and raise if there's a mix of trues/falses |
||
| next | ||
| when /^--.*=/ | ||
| next | ||
| when /^--/ | ||
|
|
@@ -141,7 +174,7 @@ def parse_string(sorbet_config) | |
|
|
||
| #: (String line) -> String | ||
| def parse_option(line) | ||
| T.must(line.split("=").last).strip | ||
| T.must(line.split("=", 2).last).strip | ||
| end | ||
|
|
||
| #: (String line) -> bool | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use_rbsis missing fromoptions_string. Bothcache_dirandparserare included, butuse_rbsis not, so a parse →options_stringround-trip silently drops the RBS config.Should we add something like:
(or whichever RBS flag makes the most sense as canonical)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to map Sorbet version <:> feature like we do in Tapioca