sorbet-eraser 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +5 -5
- data/lib/sorbet/eraser/t/props.rb +2 -3
- data/lib/sorbet/eraser/t.rb +1 -1
- data/lib/sorbet/eraser/version.rb +1 -1
- data/lib/sorbet/eraser.rb +17 -19
- data/sorbet-eraser.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ad0af501c0fd60762345ff02fdca609a9380405416e686776afc349de9b50e1
|
4
|
+
data.tar.gz: b53c44b99f68070cdeff20fb98946c9ad36865f0713ae827e7a668eed72d927f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9522badb70d5cf342fdd35d9d017d989c042dd1cbab76c341a6f890cc9992e2a33f4c8e6c3e031f9e579c0b0e0b164f272defc8660a4ce0247fc00bc8c933e01
|
7
|
+
data.tar.gz: 1e60091bdc1def556f37d0021fb683632196f08c4cbc01ad9163c0f7930043cee1c85b03109d53a1c7140fd78a517dc579dc4f98c198fb741a00d17a8770a726
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.7.0] - 2024-02-14
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Use `prism` as the parser, not `yarp`.
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Fix the return value of `T::Private:Methods.signature_for_method`.
|
18
|
+
- `T::Props#props` is expected to be a hash not an array.
|
19
|
+
|
9
20
|
## [0.6.0] - 2023-09-11
|
10
21
|
|
11
22
|
### Added
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sorbet-eraser (0.
|
5
|
-
|
4
|
+
sorbet-eraser (0.7.0)
|
5
|
+
prism
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
minitest (5.
|
11
|
-
|
12
|
-
|
10
|
+
minitest (5.22.2)
|
11
|
+
prism (0.22.0)
|
12
|
+
rake (13.1.0)
|
13
13
|
|
14
14
|
PLATFORMS
|
15
15
|
arm64-darwin-21
|
@@ -16,7 +16,7 @@ module T
|
|
16
16
|
# them and not raise errors and for bookkeeping.
|
17
17
|
module ClassMethods
|
18
18
|
def props
|
19
|
-
@props ||=
|
19
|
+
@props ||= {}
|
20
20
|
end
|
21
21
|
|
22
22
|
def prop(name, rules = {})
|
@@ -32,8 +32,7 @@ module T
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def create_prop(name, rules)
|
35
|
-
props
|
36
|
-
props.sort_by!(&:first)
|
35
|
+
props[name] = rules
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
data/lib/sorbet/eraser/t.rb
CHANGED
data/lib/sorbet/eraser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "prism"
|
4
4
|
|
5
5
|
require "sorbet/eraser/version"
|
6
6
|
require "sorbet/eraser/t"
|
@@ -23,7 +23,7 @@ module Sorbet
|
|
23
23
|
module Eraser
|
24
24
|
# This class is a YARP visitor that finds the ranges of bytes that should be
|
25
25
|
# erased from the source code.
|
26
|
-
class Ranges <
|
26
|
+
class Ranges < Prism::Visitor
|
27
27
|
attr_reader :ranges
|
28
28
|
|
29
29
|
def initialize(ranges)
|
@@ -32,7 +32,7 @@ module Sorbet
|
|
32
32
|
|
33
33
|
def visit_call_node(node)
|
34
34
|
case node.name
|
35
|
-
when
|
35
|
+
when :abstract!, :final!, :interface!
|
36
36
|
# abstract!
|
37
37
|
# abstract!()
|
38
38
|
# final!
|
@@ -42,7 +42,7 @@ module Sorbet
|
|
42
42
|
if !node.receiver && !node.arguments && !node.block
|
43
43
|
ranges << (node.location.start_offset...node.location.end_offset)
|
44
44
|
end
|
45
|
-
when
|
45
|
+
when :assert_type!, :bind, :cast, :let
|
46
46
|
# T.assert_type! foo, String
|
47
47
|
# T.assert_type!(foo, String)
|
48
48
|
# T.bind self, String
|
@@ -51,9 +51,7 @@ module Sorbet
|
|
51
51
|
# T.cast(foo, String)
|
52
52
|
# T.let foo, String
|
53
53
|
# T.let(foo, String)
|
54
|
-
if node.receiver.is_a?(
|
55
|
-
arguments = node.arguments.arguments
|
56
|
-
|
54
|
+
if node.receiver.is_a?(Prism::ConstantReadNode) && node.receiver.name == :T && (arguments = node.arguments&.arguments) && !node.block && arguments.length == 2
|
57
55
|
if node.opening_loc
|
58
56
|
ranges << (node.location.start_offset...node.opening_loc.start_offset)
|
59
57
|
ranges << (arguments.first.location.end_offset...node.closing_loc.start_offset)
|
@@ -62,7 +60,7 @@ module Sorbet
|
|
62
60
|
ranges << (arguments.last.location.end_offset...node.location.end_offset)
|
63
61
|
end
|
64
62
|
end
|
65
|
-
when
|
63
|
+
when :const, :prop
|
66
64
|
# const :foo, String
|
67
65
|
# const :foo, String, required: true
|
68
66
|
# const(:foo, String)
|
@@ -71,8 +69,8 @@ module Sorbet
|
|
71
69
|
# prop :foo, String, required: true
|
72
70
|
# prop(:foo, String)
|
73
71
|
# prop(:foo, String, required: true)
|
74
|
-
if !node.receiver && node.arguments && !node.block
|
75
|
-
arguments =
|
72
|
+
if !node.receiver && (arguments = node.arguments) && !node.block
|
73
|
+
arguments = arguments.arguments
|
76
74
|
|
77
75
|
case arguments.length
|
78
76
|
when 2
|
@@ -81,21 +79,21 @@ module Sorbet
|
|
81
79
|
ranges << (arguments[1].location.start_offset...arguments[2].location.start_offset)
|
82
80
|
end
|
83
81
|
end
|
84
|
-
when
|
82
|
+
when :mixes_in_class_methods
|
85
83
|
# mixes_in_class_methods Foo
|
86
84
|
# mixes_in_class_methods(Foo)
|
87
|
-
if !node.receiver && node.arguments && !node.block &&
|
85
|
+
if !node.receiver && (arguments = node.arguments&.arguments) && !node.block && arguments.length == 1
|
88
86
|
ranges << (node.location.start_offset...node.location.end_offset)
|
89
87
|
end
|
90
|
-
when
|
88
|
+
when :must, :reveal_type, :unsafe
|
91
89
|
# T.must foo
|
92
90
|
# T.must(foo)
|
93
91
|
# T.reveal_type foo
|
94
92
|
# T.reveal_type(foo)
|
95
93
|
# T.unsafe foo
|
96
94
|
# T.unsafe(foo)
|
97
|
-
if node.receiver.is_a?(
|
98
|
-
argument =
|
95
|
+
if (receiver = node.receiver).is_a?(Prism::ConstantReadNode) && receiver.name == :T && (arguments = node.arguments&.arguments) && !node.block && arguments.length == 1
|
96
|
+
argument = arguments.first
|
99
97
|
|
100
98
|
if node.opening_loc
|
101
99
|
ranges << (node.location.start_offset...node.opening_loc.start_offset)
|
@@ -105,7 +103,7 @@ module Sorbet
|
|
105
103
|
ranges << (argument.location.end_offset...node.location.end_offset)
|
106
104
|
end
|
107
105
|
end
|
108
|
-
when
|
106
|
+
when :sig
|
109
107
|
# sig { ... }
|
110
108
|
# sig do ... end
|
111
109
|
if !node.receiver && !node.arguments && node.block
|
@@ -122,14 +120,14 @@ module Sorbet
|
|
122
120
|
# with a string that contains Ruby source. It returns the modified Ruby
|
123
121
|
# source.
|
124
122
|
def erase(source)
|
125
|
-
erase_result(
|
123
|
+
erase_result(Prism.parse(source), source)
|
126
124
|
end
|
127
125
|
|
128
126
|
# This is one of the two entrypoints to the module. This should be called
|
129
127
|
# with a filepath that points to a file that contains Ruby source. It
|
130
128
|
# returns the modified Ruby source.
|
131
129
|
def erase_file(filepath)
|
132
|
-
erase_result(
|
130
|
+
erase_result(Prism.parse_file(filepath), File.read(filepath))
|
133
131
|
end
|
134
132
|
|
135
133
|
private
|
@@ -144,7 +142,7 @@ module Sorbet
|
|
144
142
|
# Implicitly assuming that comments are in order.
|
145
143
|
break if comment.location.start_line >= minimum
|
146
144
|
|
147
|
-
if comment.
|
145
|
+
if comment.is_a?(Prism::InlineComment) && comment.location.slice.match?(/\A#\s*typed:\s*(?:ignore|false|true|strict|strong)\s*\z/)
|
148
146
|
ranges << ((comment.location.start_offset + 1)...comment.location.end_offset)
|
149
147
|
end
|
150
148
|
end
|
data/sorbet-eraser.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_dependency "
|
33
|
+
spec.add_dependency "prism"
|
34
34
|
|
35
35
|
spec.add_development_dependency "bundler"
|
36
36
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-eraser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: prism
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -103,7 +103,7 @@ licenses:
|
|
103
103
|
- MIT
|
104
104
|
metadata:
|
105
105
|
bug_tracker_uri: https://github.com/kddnewton/sorbet-eraser/issues
|
106
|
-
changelog_uri: https://github.com/kddnewton/sorbet-eraser/blob/v0.
|
106
|
+
changelog_uri: https://github.com/kddnewton/sorbet-eraser/blob/v0.7.0/CHANGELOG.md
|
107
107
|
source_code_uri: https://github.com/kddnewton/sorbet-eraser
|
108
108
|
rubygems_mfa_required: 'true'
|
109
109
|
post_install_message:
|