steep 1.4.0.dev.1 → 1.4.0.dev.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +12 -12
- data/Gemfile.steep +1 -1
- data/Gemfile.steep.lock +15 -12
- data/Steepfile +16 -0
- data/lib/steep/annotation_parser.rb +40 -20
- data/lib/steep/ast/types/factory.rb +56 -10
- data/lib/steep/ast/types/name.rb +10 -0
- data/lib/steep/diagnostic/ruby.rb +1 -1
- data/lib/steep/diagnostic/signature.rb +40 -0
- data/lib/steep/index/rbs_index.rb +12 -3
- data/lib/steep/index/signature_symbol_provider.rb +1 -1
- data/lib/steep/project/target.rb +1 -3
- data/lib/steep/server/interaction_worker.rb +37 -20
- data/lib/steep/server/lsp_formatter.rb +14 -5
- data/lib/steep/services/completion_provider.rb +10 -12
- data/lib/steep/services/goto_service.rb +15 -14
- data/lib/steep/services/hover_provider/rbs.rb +29 -9
- data/lib/steep/services/hover_provider/ruby.rb +16 -10
- data/lib/steep/services/signature_service.rb +36 -39
- data/lib/steep/signature/validator.rb +28 -6
- data/lib/steep/subtyping/check.rb +1 -1
- data/lib/steep/type_construction.rb +16 -14
- data/lib/steep/type_inference/constant_env.rb +7 -3
- data/lib/steep/version.rb +1 -1
- data/rbs_collection.steep.lock.yaml +16 -20
- data/rbs_collection.steep.yaml +3 -1
- data/sample/lib/conference.rb +10 -0
- data/sample/sig/conference.rbs +23 -0
- data/sig/steep/annotation_parser.rbs +3 -2
- data/sig/steep/ast/annotation/collection.rbs +1 -1
- data/sig/steep/ast/types/factory.rbs +2 -0
- data/sig/steep/ast/types/name.rbs +4 -0
- data/sig/steep/diagnostic/signature.rbs +18 -14
- data/sig/steep/index/rbs_index.rbs +6 -2
- data/sig/steep/project/target.rbs +7 -7
- data/sig/steep/server/interaction_worker.rbs +2 -2
- data/sig/steep/server/lsp_formatter.rbs +4 -2
- data/sig/steep/services/completion_provider.rbs +6 -0
- data/sig/steep/services/hover_provider/rbs.rbs +6 -4
- data/sig/steep/services/hover_provider/ruby.rbs +8 -4
- data/sig/steep/services/signature_service.rbs +27 -3
- data/sig/steep/signature/validator.rbs +9 -5
- data/sig/steep/type_construction.rbs +1 -1
- data/sig/steep/type_inference/constant_env.rbs +2 -0
- data/smoke/regexp/a.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e9c57b89791ad6d989bddd6439f1ce792ceccf8e17034a1f2ab56c85f2ca41
|
4
|
+
data.tar.gz: dfbe3445dcc72a84a2d4d4e608eb5d74e9da4e1cef03f4979a44e377bf65a917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c14673012d5db258399c4f5d7bda6e3fb6aaca0dbc5c241efca52f8c4e947a5a4fd1a60a42ce6a45e87642926b6e44f65d6058bb241581e5a143251a158f383f
|
7
|
+
data.tar.gz: '0889651d16f198063b243aef34cb300325fb04dcbb7165f0d8c972d7f0f2076d86af77393c8c3f0f216d1a42f6fa8bd2c4cbf78d3e0c106d8c7f883d96099839'
|
data/Gemfile
CHANGED
@@ -3,10 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in steep.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "rbs", "~>3.0.0
|
6
|
+
gem "rbs", "~> 3.0.0"
|
7
7
|
|
8
8
|
gem "rake"
|
9
|
-
gem "minitest", "~> 5.
|
9
|
+
gem "minitest", "~> 5.17"
|
10
10
|
gem "minitest-hooks"
|
11
11
|
group :stackprof, optional: true do
|
12
12
|
gem "stackprof"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steep (1.4.0.dev.
|
4
|
+
steep (1.4.0.dev.2)
|
5
5
|
activesupport (>= 5.1)
|
6
6
|
csv (>= 3.0.9)
|
7
7
|
fileutils (>= 1.1.0)
|
@@ -21,13 +21,13 @@ PATH
|
|
21
21
|
GEM
|
22
22
|
remote: https://rubygems.org/
|
23
23
|
specs:
|
24
|
-
activesupport (7.0.4)
|
24
|
+
activesupport (7.0.4.2)
|
25
25
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
26
|
i18n (>= 1.6, < 2)
|
27
27
|
minitest (>= 5.1)
|
28
28
|
tzinfo (~> 2.0)
|
29
29
|
ast (2.4.2)
|
30
|
-
concurrent-ruby (1.
|
30
|
+
concurrent-ruby (1.2.2)
|
31
31
|
csv (3.2.6)
|
32
32
|
debase (0.2.5.beta2)
|
33
33
|
debase-ruby_core_source (>= 0.10.12)
|
@@ -37,18 +37,18 @@ GEM
|
|
37
37
|
i18n (1.12.0)
|
38
38
|
concurrent-ruby (~> 1.0)
|
39
39
|
json (2.6.3)
|
40
|
-
language_server-protocol (3.17.0.
|
41
|
-
listen (3.
|
40
|
+
language_server-protocol (3.17.0.3)
|
41
|
+
listen (3.8.0)
|
42
42
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
43
43
|
rb-inotify (~> 0.9, >= 0.9.10)
|
44
44
|
logger (1.5.3)
|
45
|
-
minitest (5.
|
45
|
+
minitest (5.17.0)
|
46
46
|
minitest-hooks (1.5.0)
|
47
47
|
minitest (> 5.3)
|
48
48
|
minitest-slow_test (0.2.0)
|
49
49
|
minitest (>= 5.0)
|
50
50
|
parallel (1.22.1)
|
51
|
-
parser (3.2.
|
51
|
+
parser (3.2.1.0)
|
52
52
|
ast (~> 2.4.1)
|
53
53
|
pathname (0.2.1)
|
54
54
|
rainbow (3.1.1)
|
@@ -56,15 +56,15 @@ GEM
|
|
56
56
|
rb-fsevent (0.11.2)
|
57
57
|
rb-inotify (0.10.1)
|
58
58
|
ffi (~> 1.0)
|
59
|
-
rbs (3.0.
|
59
|
+
rbs (3.0.1)
|
60
60
|
ruby-debug-ide (0.7.3)
|
61
61
|
rake (>= 0.8.1)
|
62
62
|
securerandom (0.2.2)
|
63
63
|
stackprof (0.2.23)
|
64
|
-
strscan (3.0.
|
64
|
+
strscan (3.0.6)
|
65
65
|
terminal-table (3.0.2)
|
66
66
|
unicode-display_width (>= 1.1.1, < 3)
|
67
|
-
tzinfo (2.0.
|
67
|
+
tzinfo (2.0.6)
|
68
68
|
concurrent-ruby (~> 1.0)
|
69
69
|
unicode-display_width (2.4.2)
|
70
70
|
|
@@ -73,11 +73,11 @@ PLATFORMS
|
|
73
73
|
|
74
74
|
DEPENDENCIES
|
75
75
|
debase (>= 0.2.5.beta2)
|
76
|
-
minitest (~> 5.
|
76
|
+
minitest (~> 5.17)
|
77
77
|
minitest-hooks
|
78
78
|
minitest-slow_test
|
79
79
|
rake
|
80
|
-
rbs (~> 3.0.0
|
80
|
+
rbs (~> 3.0.0)
|
81
81
|
ruby-debug-ide
|
82
82
|
stackprof
|
83
83
|
steep!
|
data/Gemfile.steep
CHANGED
data/Gemfile.steep.lock
CHANGED
@@ -8,28 +8,29 @@ GEM
|
|
8
8
|
tzinfo (~> 2.0)
|
9
9
|
ast (2.4.2)
|
10
10
|
concurrent-ruby (1.1.10)
|
11
|
-
csv (3.2.
|
11
|
+
csv (3.2.6)
|
12
12
|
ffi (1.15.5)
|
13
|
-
fileutils (1.
|
13
|
+
fileutils (1.7.0)
|
14
14
|
i18n (1.12.0)
|
15
15
|
concurrent-ruby (~> 1.0)
|
16
|
-
json (2.6.
|
17
|
-
language_server-protocol (3.17.0.
|
16
|
+
json (2.6.3)
|
17
|
+
language_server-protocol (3.17.0.2)
|
18
18
|
listen (3.7.1)
|
19
19
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
20
20
|
rb-inotify (~> 0.9, >= 0.9.10)
|
21
|
-
logger (1.5.
|
22
|
-
minitest (5.
|
21
|
+
logger (1.5.3)
|
22
|
+
minitest (5.17.0)
|
23
23
|
parallel (1.22.1)
|
24
|
-
parser (3.
|
24
|
+
parser (3.2.0.0)
|
25
25
|
ast (~> 2.4.1)
|
26
|
+
pathname (0.2.1)
|
26
27
|
rainbow (3.1.1)
|
27
28
|
rb-fsevent (0.11.2)
|
28
29
|
rb-inotify (0.10.1)
|
29
30
|
ffi (~> 1.0)
|
30
31
|
rbs (3.0.0.dev.1)
|
31
|
-
securerandom (0.2.
|
32
|
-
steep (1.
|
32
|
+
securerandom (0.2.2)
|
33
|
+
steep (1.4.0.dev.1)
|
33
34
|
activesupport (>= 5.1)
|
34
35
|
csv (>= 3.0.9)
|
35
36
|
fileutils (>= 1.1.0)
|
@@ -39,24 +40,26 @@ GEM
|
|
39
40
|
logger (>= 1.3.0)
|
40
41
|
parallel (>= 1.0.0)
|
41
42
|
parser (>= 3.1)
|
43
|
+
pathname (>= 0.2.1)
|
42
44
|
rainbow (>= 2.2.2, < 4.0)
|
43
45
|
rbs (>= 2.8.0)
|
44
46
|
securerandom (>= 0.1)
|
45
47
|
strscan (>= 1.0.0)
|
46
48
|
terminal-table (>= 2, < 4)
|
47
|
-
strscan (3.0.
|
49
|
+
strscan (3.0.5)
|
48
50
|
terminal-table (3.0.2)
|
49
51
|
unicode-display_width (>= 1.1.1, < 3)
|
50
52
|
tzinfo (2.0.5)
|
51
53
|
concurrent-ruby (~> 1.0)
|
52
|
-
unicode-display_width (2.
|
54
|
+
unicode-display_width (2.4.2)
|
53
55
|
|
54
56
|
PLATFORMS
|
55
57
|
arm64-darwin-21
|
58
|
+
arm64-darwin-22
|
56
59
|
|
57
60
|
DEPENDENCIES
|
58
61
|
rbs (~> 3.0.0.dev)
|
59
|
-
steep (~> 1.
|
62
|
+
steep (~> 1.4.0.dev)
|
60
63
|
|
61
64
|
BUNDLED WITH
|
62
65
|
2.3.15
|
data/Steepfile
CHANGED
@@ -10,7 +10,23 @@ target :app do
|
|
10
10
|
hash[D::Ruby::MethodDefinitionMissing] = :hint
|
11
11
|
end
|
12
12
|
|
13
|
+
FileUtils.mkpath("tmp")
|
14
|
+
tmp_rbs_dir = File.join("tmp", "rbs-sig")
|
15
|
+
|
16
|
+
definition = Bundler::Definition.build(Pathname("Gemfile"), Pathname("Gemfile.lock"), nil)
|
17
|
+
rbs_dep = definition.dependencies.find {|dep| dep.name == "rbs" }
|
18
|
+
if (source = rbs_dep.source).is_a?(Bundler::Source::Path)
|
19
|
+
unless Pathname(tmp_rbs_dir).exist?
|
20
|
+
FileUtils.ln_s(Pathname.pwd + source.path + "sig", tmp_rbs_dir, force: true)
|
21
|
+
end
|
22
|
+
signature tmp_rbs_dir
|
23
|
+
else
|
24
|
+
FileUtils.rm_f(tmp_rbs_dir)
|
25
|
+
library "rbs"
|
26
|
+
end
|
27
|
+
|
13
28
|
library(
|
29
|
+
"rdoc",
|
14
30
|
"set",
|
15
31
|
"pathname",
|
16
32
|
"monitor",
|
@@ -20,16 +20,19 @@ module Steep
|
|
20
20
|
attr_reader :source
|
21
21
|
attr_reader :location
|
22
22
|
|
23
|
-
def initialize(source:, location:, exn: nil)
|
23
|
+
def initialize(source:, location:, exn: nil, message: nil)
|
24
24
|
@source = source
|
25
25
|
@location = location
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
if exn
|
28
|
+
message =
|
29
|
+
case exn
|
30
|
+
when RBS::ParsingError
|
31
|
+
Diagnostic::Signature::SyntaxError.parser_syntax_error_message(exn)
|
32
|
+
else
|
33
|
+
exn.message
|
34
|
+
end
|
35
|
+
end
|
33
36
|
|
34
37
|
super message
|
35
38
|
end
|
@@ -41,8 +44,25 @@ module Steep
|
|
41
44
|
PARAM = /[A-Z][A-Za-z0-9_]*/
|
42
45
|
TYPE_PARAMS = /(\[(?<params>#{PARAM}(,\s*#{PARAM})*)\])?/
|
43
46
|
|
44
|
-
def parse_type(
|
45
|
-
|
47
|
+
def parse_type(match, name = :type, location:)
|
48
|
+
string = match[name] or raise
|
49
|
+
st, en = match.offset(name)
|
50
|
+
st or raise
|
51
|
+
en or raise
|
52
|
+
loc = RBS::Location.new(location.buffer, location.start_pos + st, location.start_pos + en)
|
53
|
+
|
54
|
+
type =
|
55
|
+
begin
|
56
|
+
RBS::Parser.parse_type(string)
|
57
|
+
rescue RBS::ParsingError => exn
|
58
|
+
raise SyntaxError.new(source: string, location: loc, exn: exn)
|
59
|
+
end or raise
|
60
|
+
|
61
|
+
unless (type.location || raise).source == string.strip
|
62
|
+
raise SyntaxError.new(source: string, location: loc, message: "Failed to parse a type in annotation")
|
63
|
+
end
|
64
|
+
|
65
|
+
factory.type(type)
|
46
66
|
end
|
47
67
|
|
48
68
|
def keyword_subject_type(keyword, name)
|
@@ -59,10 +79,9 @@ module Steep
|
|
59
79
|
Regexp.last_match.yield_self do |match|
|
60
80
|
match or raise
|
61
81
|
name = match[:name] or raise
|
62
|
-
type = match[:type] or raise
|
63
82
|
|
64
83
|
AST::Annotation::VarType.new(name: name.to_sym,
|
65
|
-
type: parse_type(
|
84
|
+
type: parse_type(match, location: location),
|
66
85
|
location: location)
|
67
86
|
end
|
68
87
|
|
@@ -72,7 +91,7 @@ module Steep
|
|
72
91
|
name = match[:name] or raise
|
73
92
|
type = match[:type] or raise
|
74
93
|
|
75
|
-
method_type = factory.method_type(RBS::Parser.parse_method_type(type), method_decls: Set[])
|
94
|
+
method_type = factory.method_type(RBS::Parser.parse_method_type(type) || raise, method_decls: Set[])
|
76
95
|
|
77
96
|
AST::Annotation::MethodType.new(name: name.to_sym,
|
78
97
|
type: method_type,
|
@@ -83,7 +102,7 @@ module Steep
|
|
83
102
|
Regexp.last_match.yield_self do |match|
|
84
103
|
match or raise
|
85
104
|
name = match[:name] or raise
|
86
|
-
type = parse_type(match
|
105
|
+
type = parse_type(match, location: location)
|
87
106
|
|
88
107
|
AST::Annotation::ConstType.new(name: TypeName(name), type: type, location: location)
|
89
108
|
end
|
@@ -92,7 +111,7 @@ module Steep
|
|
92
111
|
Regexp.last_match.yield_self do |match|
|
93
112
|
match or raise
|
94
113
|
name = match[:name] or raise
|
95
|
-
type = parse_type(match
|
114
|
+
type = parse_type(match, location: location)
|
96
115
|
|
97
116
|
AST::Annotation::IvarType.new(name: name.to_sym,
|
98
117
|
type: type,
|
@@ -102,42 +121,43 @@ module Steep
|
|
102
121
|
when keyword_and_type("return")
|
103
122
|
Regexp.last_match.yield_self do |match|
|
104
123
|
match or raise
|
105
|
-
type = parse_type(match
|
124
|
+
type = parse_type(match, location: location)
|
106
125
|
AST::Annotation::ReturnType.new(type: type, location: location)
|
107
126
|
end
|
108
127
|
|
109
128
|
when keyword_and_type("block")
|
110
129
|
Regexp.last_match.yield_self do |match|
|
111
130
|
match or raise
|
112
|
-
type = parse_type(match
|
131
|
+
type = parse_type(match, location: location)
|
113
132
|
AST::Annotation::BlockType.new(type: type, location: location)
|
114
133
|
end
|
115
134
|
|
116
135
|
when keyword_and_type("self")
|
117
136
|
Regexp.last_match.yield_self do |match|
|
118
137
|
match or raise
|
119
|
-
type = parse_type(match
|
138
|
+
type = parse_type(match, location: location)
|
120
139
|
AST::Annotation::SelfType.new(type: type, location: location)
|
121
140
|
end
|
122
141
|
|
123
142
|
when keyword_and_type("instance")
|
124
143
|
Regexp.last_match.yield_self do |match|
|
125
144
|
match or raise
|
126
|
-
type = parse_type(match
|
145
|
+
type = parse_type(match, location: location)
|
127
146
|
AST::Annotation::InstanceType.new(type: type, location: location)
|
128
147
|
end
|
129
148
|
|
130
149
|
when keyword_and_type("module")
|
131
150
|
Regexp.last_match.yield_self do |match|
|
132
151
|
match or raise
|
133
|
-
type = parse_type(match
|
152
|
+
type = parse_type(match, location: location)
|
134
153
|
AST::Annotation::ModuleType.new(type: type, location: location)
|
135
154
|
end
|
136
155
|
|
137
156
|
when keyword_and_type("break")
|
138
157
|
Regexp.last_match.yield_self do |match|
|
139
158
|
match or raise
|
140
|
-
type = parse_type(match
|
159
|
+
type = parse_type(match, location: location)
|
160
|
+
|
141
161
|
AST::Annotation::BreakType.new(type: type, location: location)
|
142
162
|
end
|
143
163
|
|
@@ -370,19 +370,11 @@ module Steep
|
|
370
370
|
end
|
371
371
|
|
372
372
|
def module_name?(type_name)
|
373
|
-
|
374
|
-
entry.is_a?(RBS::Environment::ModuleEntry)
|
375
|
-
else
|
376
|
-
false
|
377
|
-
end
|
373
|
+
env.module_entry(type_name) ? true : false
|
378
374
|
end
|
379
375
|
|
380
376
|
def class_name?(type_name)
|
381
|
-
|
382
|
-
entry.is_a?(RBS::Environment::ClassEntry)
|
383
|
-
else
|
384
|
-
false
|
385
|
-
end
|
377
|
+
env.class_entry(type_name) ? true : false
|
386
378
|
end
|
387
379
|
|
388
380
|
def env
|
@@ -434,6 +426,60 @@ module Steep
|
|
434
426
|
nil
|
435
427
|
end
|
436
428
|
end
|
429
|
+
|
430
|
+
def normalize_type(type)
|
431
|
+
case type
|
432
|
+
when AST::Types::Name::Instance
|
433
|
+
AST::Types::Name::Instance.new(
|
434
|
+
name: env.normalize_module_name(type.name),
|
435
|
+
args: type.args.map {|ty| normalize_type(ty) },
|
436
|
+
location: type.location
|
437
|
+
)
|
438
|
+
when AST::Types::Name::Singleton
|
439
|
+
AST::Types::Name::Singleton.new(
|
440
|
+
name: env.normalize_module_name(type.name),
|
441
|
+
location: type.location
|
442
|
+
)
|
443
|
+
when AST::Types::Any, AST::Types::Boolean, AST::Types::Bot, AST::Types::Nil,
|
444
|
+
AST::Types::Top, AST::Types::Void, AST::Types::Literal, AST::Types::Class, AST::Types::Instance,
|
445
|
+
AST::Types::Self, AST::Types::Var, AST::Types::Logic::Base
|
446
|
+
type
|
447
|
+
when AST::Types::Intersection
|
448
|
+
AST::Types::Intersection.build(
|
449
|
+
types: type.types.map {|type| normalize_type(type) },
|
450
|
+
location: type.location
|
451
|
+
)
|
452
|
+
when AST::Types::Union
|
453
|
+
AST::Types::Union.build(
|
454
|
+
types: type.types.map {|type| normalize_type(type) },
|
455
|
+
location: type.location
|
456
|
+
)
|
457
|
+
when AST::Types::Record
|
458
|
+
AST::Types::Record.new(
|
459
|
+
elements: type.elements.transform_values {|type| normalize_type(type) },
|
460
|
+
location: type.location
|
461
|
+
)
|
462
|
+
when AST::Types::Tuple
|
463
|
+
AST::Types::Tuple.new(
|
464
|
+
types: type.types.map {|type| normalize_type(type) },
|
465
|
+
location: type.location
|
466
|
+
)
|
467
|
+
when AST::Types::Proc
|
468
|
+
type.map_type {|type| normalize_type(type) }
|
469
|
+
when AST::Types::Name::Alias
|
470
|
+
AST::Types::Name::Alias.new(
|
471
|
+
name: type.name,
|
472
|
+
args: type.args.map {|ty| normalize_type(ty) },
|
473
|
+
location: type.location
|
474
|
+
)
|
475
|
+
when AST::Types::Name::Interface
|
476
|
+
AST::Types::Name::Interface.new(
|
477
|
+
name: type.name,
|
478
|
+
args: type.args.map {|ty| normalize_type(ty) },
|
479
|
+
location: type.location
|
480
|
+
)
|
481
|
+
end
|
482
|
+
end
|
437
483
|
end
|
438
484
|
end
|
439
485
|
end
|
data/lib/steep/ast/types/name.rb
CHANGED
@@ -20,6 +20,10 @@ module Steep
|
|
20
20
|
def level
|
21
21
|
[0]
|
22
22
|
end
|
23
|
+
|
24
|
+
def map_type(&block)
|
25
|
+
self
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
class Applying < Base
|
@@ -87,6 +91,12 @@ module Steep
|
|
87
91
|
def level
|
88
92
|
[0] + level_of_children(args)
|
89
93
|
end
|
94
|
+
|
95
|
+
def map_type(&block)
|
96
|
+
args = self.args.map(&block)
|
97
|
+
|
98
|
+
_ = self.class.new(name: self.name, args: self.args, location: self.location)
|
99
|
+
end
|
90
100
|
end
|
91
101
|
|
92
102
|
class Singleton < Base
|
@@ -783,7 +783,7 @@ module Steep
|
|
783
783
|
end
|
784
784
|
|
785
785
|
def header_line
|
786
|
-
"Assertion cannot hold: no relationship between
|
786
|
+
"Assertion cannot hold: no relationship between inferred type (`#{node_type.to_s}`) and asserted type (`#{assertion_type.to_s}`)"
|
787
787
|
end
|
788
788
|
end
|
789
789
|
|
@@ -381,6 +381,42 @@ module Steep
|
|
381
381
|
end
|
382
382
|
end
|
383
383
|
|
384
|
+
class InconsistentClassModuleAliasError < Base
|
385
|
+
attr_reader :decl
|
386
|
+
|
387
|
+
def initialize(decl:)
|
388
|
+
@decl = decl
|
389
|
+
super(location: decl.location&.[](:old_name))
|
390
|
+
end
|
391
|
+
|
392
|
+
def header_line
|
393
|
+
expected_kind =
|
394
|
+
case decl
|
395
|
+
when RBS::AST::Declarations::ModuleAlias
|
396
|
+
"module"
|
397
|
+
when RBS::AST::Declarations::ClassAlias
|
398
|
+
"class"
|
399
|
+
else
|
400
|
+
raise
|
401
|
+
end
|
402
|
+
|
403
|
+
"A #{expected_kind} `#{decl.new_name}` cannot be an alias of `#{decl.old_name}`"
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
class CyclicClassAliasDefinitionError < Base
|
408
|
+
attr_reader :decl
|
409
|
+
|
410
|
+
def initialize(decl:)
|
411
|
+
@decl = decl
|
412
|
+
super(location: decl.location&.[](:new_name))
|
413
|
+
end
|
414
|
+
|
415
|
+
def header_line
|
416
|
+
"#{decl.new_name} is a cyclic definition"
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
384
420
|
def self.from_rbs_error(error, factory:)
|
385
421
|
case error
|
386
422
|
when RBS::ParsingError
|
@@ -475,6 +511,10 @@ module Steep
|
|
475
511
|
)
|
476
512
|
when RBS::InheritModuleError
|
477
513
|
Diagnostic::Signature::InheritModuleError.new(error.super_decl)
|
514
|
+
when RBS::InconsistentClassModuleAliasError
|
515
|
+
Diagnostic::Signature::InconsistentClassModuleAliasError.new(decl: error.alias_entry.decl)
|
516
|
+
when RBS::CyclicClassAliasDefinitionError
|
517
|
+
Diagnostic::Signature::CyclicClassAliasDefinitionError.new(decl: error.alias_entry.decl)
|
478
518
|
else
|
479
519
|
raise error
|
480
520
|
end
|
@@ -18,7 +18,9 @@ module Steep
|
|
18
18
|
declarations << decl
|
19
19
|
when RBS::AST::Declarations::Interface
|
20
20
|
declarations << decl
|
21
|
-
when RBS::AST::Declarations::
|
21
|
+
when RBS::AST::Declarations::TypeAlias
|
22
|
+
declarations << decl
|
23
|
+
when RBS::AST::Declarations::ClassAlias, RBS::AST::Declarations::ModuleAlias
|
22
24
|
declarations << decl
|
23
25
|
else
|
24
26
|
raise "Unexpected type declaration: #{decl}"
|
@@ -41,7 +43,9 @@ module Steep
|
|
41
43
|
references << ref
|
42
44
|
when RBS::AST::Declarations::Constant, RBS::AST::Declarations::Global
|
43
45
|
references << ref
|
44
|
-
when RBS::AST::Declarations::
|
46
|
+
when RBS::AST::Declarations::TypeAlias
|
47
|
+
references << ref
|
48
|
+
when RBS::AST::Declarations::ClassAlias, RBS::AST::Declarations::ModuleAlias
|
45
49
|
references << ref
|
46
50
|
else
|
47
51
|
raise "Unexpected type reference: #{ref}"
|
@@ -312,6 +316,11 @@ module Steep
|
|
312
316
|
end
|
313
317
|
end
|
314
318
|
|
319
|
+
env.class_alias_decls.each do |name, entry|
|
320
|
+
index.add_type_declaration(name, entry.decl)
|
321
|
+
index.add_type_reference(entry.decl.old_name, entry.decl)
|
322
|
+
end
|
323
|
+
|
315
324
|
env.interface_decls.each do |name, decl|
|
316
325
|
index.add_type_declaration(name, decl.decl)
|
317
326
|
|
@@ -320,7 +329,7 @@ module Steep
|
|
320
329
|
end
|
321
330
|
end
|
322
331
|
|
323
|
-
env.
|
332
|
+
env.type_alias_decls.each do |name, decl|
|
324
333
|
index.add_type_declaration(name, decl.decl)
|
325
334
|
type_reference decl.decl.type, from: decl.decl
|
326
335
|
end
|
data/lib/steep/project/target.rb
CHANGED
@@ -14,9 +14,6 @@ module Steep
|
|
14
14
|
@source_pattern = source_pattern
|
15
15
|
@signature_pattern = signature_pattern
|
16
16
|
@code_diagnostics_config = code_diagnostics_config
|
17
|
-
|
18
|
-
@source_files = {}
|
19
|
-
@signature_files = {}
|
20
17
|
end
|
21
18
|
|
22
19
|
def possible_source_file?(path)
|
@@ -55,6 +52,7 @@ module Steep
|
|
55
52
|
|
56
53
|
options.libraries.each do |lib|
|
57
54
|
name, version = lib.split(/:/, 2)
|
55
|
+
name or raise
|
58
56
|
loader.add(library: name, version: version)
|
59
57
|
end
|
60
58
|
loader.add_collection(options.collection_lock) if options.collection_lock
|