steep 1.4.0.dev.1 → 1.4.0.dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -2
- data/Gemfile +2 -2
- data/Gemfile.lock +13 -15
- data/Gemfile.steep +1 -2
- data/Gemfile.steep.lock +20 -18
- data/README.md +7 -1
- data/Steepfile +16 -3
- data/bin/rbs +0 -1
- data/guides/README.md +5 -0
- data/guides/src/gem-rbs-collection/gem-rbs-collection.md +143 -0
- data/guides/src/getting-started/getting-started.md +164 -0
- data/guides/src/nil-optional/nil-optional.md +195 -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 +80 -5
- data/lib/steep/diagnostic/signature.rb +40 -0
- data/lib/steep/drivers/check.rb +4 -4
- data/lib/steep/index/rbs_index.rb +12 -3
- data/lib/steep/index/signature_symbol_provider.rb +1 -1
- data/lib/steep/interface/block.rb +10 -0
- data/lib/steep/module_helper.rb +13 -11
- data/lib/steep/path_helper.rb +4 -0
- data/lib/steep/project/target.rb +1 -3
- data/lib/steep/server/interaction_worker.rb +102 -72
- 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/services/type_name_completion.rb +157 -0
- data/lib/steep/signature/validator.rb +28 -6
- data/lib/steep/source.rb +1 -0
- data/lib/steep/subtyping/check.rb +1 -1
- data/lib/steep/type_construction.rb +414 -239
- data/lib/steep/type_inference/block_params.rb +13 -0
- data/lib/steep/type_inference/constant_env.rb +7 -3
- data/lib/steep/type_inference/context.rb +3 -3
- data/lib/steep/type_inference/method_params.rb +42 -16
- data/lib/steep/type_inference/send_args.rb +79 -50
- data/lib/steep/type_inference/type_env.rb +7 -1
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +1 -0
- data/rbs_collection.steep.lock.yaml +9 -41
- data/rbs_collection.steep.yaml +11 -8
- data/sample/lib/conference.rb +22 -0
- data/sample/sig/conference.rbs +28 -0
- data/sig/shims/language-server_protocol.rbs +12 -0
- data/sig/shims/parser/nodes.rbs +37 -0
- data/sig/shims/parser.rbs +1 -0
- data/sig/shims/string.rbs +4 -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 +12 -8
- data/sig/steep/ast/types/name.rbs +4 -0
- data/sig/steep/diagnostic/lsp_formatter.rbs +1 -1
- data/sig/steep/diagnostic/ruby.rbs +38 -2
- data/sig/steep/diagnostic/signature.rbs +18 -14
- data/sig/steep/drivers/check.rbs +1 -1
- data/sig/steep/drivers/checkfile.rbs +1 -1
- data/sig/steep/drivers/diagnostic_printer.rbs +1 -1
- data/sig/steep/drivers/watch.rbs +1 -1
- data/sig/steep/index/rbs_index.rbs +6 -2
- data/sig/steep/index/signature_symbol_provider.rbs +1 -1
- data/sig/steep/interface/block.rbs +2 -0
- data/sig/steep/interface/builder.rbs +5 -3
- data/sig/steep/interface/method_type.rbs +5 -3
- data/sig/steep/module_helper.rbs +9 -0
- data/sig/steep/path_helper.rbs +3 -1
- data/sig/steep/project/target.rbs +7 -7
- data/sig/steep/server/base_worker.rbs +1 -1
- data/sig/steep/server/interaction_worker.rbs +46 -17
- data/sig/steep/server/lsp_formatter.rbs +4 -2
- data/sig/steep/server/master.rbs +1 -1
- data/sig/steep/server/type_check_worker.rbs +7 -5
- data/sig/steep/server/worker_process.rbs +6 -4
- data/sig/steep/services/completion_provider.rbs +8 -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/services/type_name_completion.rbs +122 -0
- data/sig/steep/signature/validator.rbs +9 -5
- data/sig/steep/type_construction.rbs +100 -31
- data/sig/steep/type_inference/block_params.rbs +4 -0
- data/sig/steep/type_inference/constant_env.rbs +2 -0
- data/sig/steep/type_inference/context.rbs +70 -22
- data/sig/steep/type_inference/method_params.rbs +43 -24
- data/sig/steep/type_inference/multiple_assignment.rbs +1 -1
- data/sig/steep/type_inference/send_args.rbs +13 -3
- data/sig/steep/typing.rbs +7 -2
- data/smoke/diagnostics/test_expectations.yml +1 -0
- data/smoke/regexp/a.rb +2 -2
- data/steep.gemspec +0 -1
- metadata +11 -17
|
@@ -51,6 +51,12 @@ module Steep
|
|
|
51
51
|
attr_reader full_name: RBS::TypeName
|
|
52
52
|
|
|
53
53
|
def initialize: (env: RBS::Environment, identifier: Symbol, range: Range, type: AST::Types::t, full_name: RBS::TypeName) -> void
|
|
54
|
+
|
|
55
|
+
def class?: () -> bool
|
|
56
|
+
|
|
57
|
+
def module?: () -> bool
|
|
58
|
+
|
|
59
|
+
def comments: () -> Array[RBS::AST::Comment]
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
class MethodNameItem
|
|
@@ -71,6 +77,8 @@ module Steep
|
|
|
71
77
|
def inherited?: () -> bool
|
|
72
78
|
end
|
|
73
79
|
|
|
80
|
+
type item = InstanceVariableItem | LocalVariableItem | ConstantItem | MethodNameItem
|
|
81
|
+
|
|
74
82
|
attr_reader source_text: String
|
|
75
83
|
|
|
76
84
|
attr_reader path: Pathname
|
|
@@ -5,17 +5,19 @@ module Steep
|
|
|
5
5
|
class TypeAliasContent
|
|
6
6
|
attr_reader location: ::RBS::Location[untyped, untyped]
|
|
7
7
|
|
|
8
|
-
attr_reader decl: ::RBS::AST::Declarations::
|
|
8
|
+
attr_reader decl: ::RBS::AST::Declarations::TypeAlias
|
|
9
9
|
|
|
10
|
-
def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::
|
|
10
|
+
def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::TypeAlias) -> void
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
class ClassContent
|
|
14
14
|
attr_reader location: ::RBS::Location[untyped, untyped]
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
type decl = ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module | ::RBS::AST::Declarations::ClassAlias | ::RBS::AST::Declarations::ModuleAlias
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
attr_reader decl: decl
|
|
19
|
+
|
|
20
|
+
def initialize: (location: ::RBS::Location[untyped, untyped], decl: decl) -> void
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
class InterfaceContent
|
|
@@ -82,23 +82,27 @@ module Steep
|
|
|
82
82
|
|
|
83
83
|
type decl = ::RBS::Environment::ClassEntry
|
|
84
84
|
| ::RBS::Environment::ModuleEntry
|
|
85
|
-
| ::RBS::Environment::
|
|
85
|
+
| ::RBS::Environment::ClassAliasEntry
|
|
86
|
+
| ::RBS::Environment::ModuleAliasEntry
|
|
87
|
+
| ::RBS::Environment::ConstantEntry
|
|
86
88
|
|
|
87
89
|
attr_reader decl: decl
|
|
88
90
|
|
|
89
91
|
attr_reader class_decl(): ::RBS::Environment::ClassEntry | ::RBS::Environment::ModuleEntry | nil
|
|
90
92
|
|
|
91
|
-
attr_reader
|
|
93
|
+
attr_reader class_alias(): ::RBS::Environment::ClassAliasEntry | ::RBS::Environment::ModuleAliasEntry | nil
|
|
94
|
+
|
|
95
|
+
attr_reader constant_decl(): ::RBS::Environment::ConstantEntry?
|
|
92
96
|
|
|
93
97
|
def initialize: (location: Parser::Source::Range, full_name: ::RBS::TypeName, type: AST::Types::t, decl: decl) -> void
|
|
94
98
|
|
|
95
99
|
def comments: () -> Array[::RBS::AST::Comment]
|
|
96
100
|
|
|
97
101
|
# Returns true if `decl` is a class/module definition
|
|
98
|
-
def class_or_module?: () ->
|
|
102
|
+
def class_or_module?: () -> bool
|
|
99
103
|
|
|
100
104
|
# Returns true if `decl` is a constant definition
|
|
101
|
-
def constant?: () ->
|
|
105
|
+
def constant?: () -> bool
|
|
102
106
|
end
|
|
103
107
|
|
|
104
108
|
type content = TypeContent | VariableContent | MethodCallContent | DefinitionContent | ConstantContent | TypeAssertionContent
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
module Steep
|
|
2
2
|
module Services
|
|
3
|
+
# SignatureService takes care of two sets of RBS files.
|
|
4
|
+
#
|
|
5
|
+
# 1. RBS files loaded from `EnvironmentLoader` -- usually type signatures of libraries
|
|
6
|
+
# 2. RBS files managed in editors -- usually type signatures of the development target (app or gem)
|
|
7
|
+
#
|
|
8
|
+
# The files in #2 are managed throuth `#status` and the changes are tracked.
|
|
9
|
+
#
|
|
3
10
|
class SignatureService
|
|
4
11
|
type status = SyntaxErrorStatus | AncestorErrorStatus | LoadedStatus
|
|
5
12
|
|
|
@@ -65,17 +72,25 @@ module Steep
|
|
|
65
72
|
def constant_resolver: () -> RBS::Resolver::ConstantResolver
|
|
66
73
|
end
|
|
67
74
|
|
|
75
|
+
# A file has one of the three states:
|
|
76
|
+
#
|
|
77
|
+
# 1. The parsing succeeded and loaded a list of declarations
|
|
78
|
+
# 2. The content has a syntax error and parsing failed
|
|
79
|
+
# 3. Other unexpected error
|
|
80
|
+
#
|
|
68
81
|
class FileStatus
|
|
69
82
|
attr_reader path: Pathname
|
|
70
83
|
|
|
71
84
|
attr_reader content: String
|
|
72
85
|
|
|
73
|
-
|
|
86
|
+
type signature = [RBS::Buffer, Array[RBS::AST::Directives::t], Array[RBS::AST::Declarations::t]]
|
|
87
|
+
|
|
88
|
+
attr_reader signature: signature | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
|
|
74
89
|
|
|
75
90
|
def initialize: (
|
|
76
91
|
path: Pathname,
|
|
77
92
|
content: String,
|
|
78
|
-
|
|
93
|
+
signature: signature | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
|
|
79
94
|
) -> void
|
|
80
95
|
end
|
|
81
96
|
|
|
@@ -85,11 +100,17 @@ module Steep
|
|
|
85
100
|
|
|
86
101
|
@env_rbs_paths: Set[Pathname]?
|
|
87
102
|
|
|
103
|
+
# All RBS paths in environment, both dependency RBS and target RBS
|
|
104
|
+
#
|
|
88
105
|
def env_rbs_paths: () -> Set[Pathname]
|
|
89
106
|
|
|
107
|
+
# Yield all RBS paths in the environment, both dependency RBS and target RBS
|
|
108
|
+
#
|
|
90
109
|
def each_rbs_path: () { (Pathname) -> void } -> void
|
|
91
110
|
| () -> Enumerator[Pathname, void]
|
|
92
111
|
|
|
112
|
+
# The Target files
|
|
113
|
+
#
|
|
93
114
|
def files: () -> Hash[Pathname, FileStatus]
|
|
94
115
|
|
|
95
116
|
def pending_changed_paths: () -> Set[Pathname]
|
|
@@ -106,10 +127,13 @@ module Steep
|
|
|
106
127
|
|
|
107
128
|
def apply_changes: (Hash[Pathname, FileStatus] files, Server::ChangeBuffer::changes changes) -> Hash[Pathname, FileStatus]
|
|
108
129
|
|
|
130
|
+
# The entry point to apply the edit to the signatures
|
|
131
|
+
#
|
|
109
132
|
def update: (Server::ChangeBuffer::changes changes) -> void
|
|
110
133
|
|
|
111
134
|
def update_env: (
|
|
112
|
-
Hash[Pathname, FileStatus] updated_files,
|
|
135
|
+
Hash[Pathname, FileStatus] updated_files,
|
|
136
|
+
paths: Set[Pathname]
|
|
113
137
|
) -> (RBS::DefinitionBuilder::AncestorBuilder | Array[Diagnostic::Signature::Base])
|
|
114
138
|
|
|
115
139
|
def rescue_rbs_error: (Array[RBS::BaseError] errors) { () -> void } -> void
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
use RBS::TypeName, RBS::Namespace, RBS::Environment, RBS::Resolver, RBS::AST::Directives
|
|
2
|
+
|
|
3
|
+
module Steep
|
|
4
|
+
module Services
|
|
5
|
+
class TypeNameCompletion
|
|
6
|
+
module Prefix
|
|
7
|
+
type t = nil # no prefix
|
|
8
|
+
| RawIdentPrefix
|
|
9
|
+
| NamespacedIdentPrefix
|
|
10
|
+
| NamespacePrefix
|
|
11
|
+
|
|
12
|
+
# Uident or Lident is given, but no `::` (==namespace)
|
|
13
|
+
#
|
|
14
|
+
# ```
|
|
15
|
+
# Str← Uident
|
|
16
|
+
# c← Lident
|
|
17
|
+
# ```
|
|
18
|
+
#
|
|
19
|
+
class RawIdentPrefix
|
|
20
|
+
attr_reader ident: String
|
|
21
|
+
|
|
22
|
+
# Returns true if the `ident` is a Ruby class name
|
|
23
|
+
#
|
|
24
|
+
def const_name?: () -> bool
|
|
25
|
+
|
|
26
|
+
def initialize: (String ident) -> void
|
|
27
|
+
|
|
28
|
+
def size: () -> Integer
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Uident or Lident following a namespace
|
|
32
|
+
#
|
|
33
|
+
# ```
|
|
34
|
+
# ::L← Uident
|
|
35
|
+
# RBS::Enviro← Uident
|
|
36
|
+
# ```
|
|
37
|
+
#
|
|
38
|
+
class NamespacedIdentPrefix
|
|
39
|
+
attr_reader namespace: Namespace
|
|
40
|
+
|
|
41
|
+
attr_reader ident: String
|
|
42
|
+
|
|
43
|
+
def const_name?: () -> bool
|
|
44
|
+
|
|
45
|
+
def initialize: (Namespace, String ident, Integer size) -> void
|
|
46
|
+
|
|
47
|
+
def size: () -> Integer
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Namespace is given
|
|
51
|
+
#
|
|
52
|
+
# ```
|
|
53
|
+
# RBS::←
|
|
54
|
+
# ::←
|
|
55
|
+
# ```
|
|
56
|
+
class NamespacePrefix
|
|
57
|
+
attr_reader namespace: Namespace
|
|
58
|
+
|
|
59
|
+
def initialize: (Namespace, Integer size) -> void
|
|
60
|
+
|
|
61
|
+
def size: () -> Integer
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# line number is 1 origin (Rubyish)
|
|
65
|
+
#
|
|
66
|
+
def self.parse: (RBS::Buffer input, line: Integer, column: Integer) -> t
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class Item
|
|
70
|
+
# The text to be completed
|
|
71
|
+
#
|
|
72
|
+
attr_reader complete_text: String
|
|
73
|
+
|
|
74
|
+
# The prefix
|
|
75
|
+
attr_reader prefix: Prefix::t?
|
|
76
|
+
|
|
77
|
+
# Name of the type or constant
|
|
78
|
+
#
|
|
79
|
+
attr_reader full_name: TypeName
|
|
80
|
+
|
|
81
|
+
# The text to be inserted after the prefix
|
|
82
|
+
#
|
|
83
|
+
def insert_text: () -> String
|
|
84
|
+
|
|
85
|
+
def initialize: (prefix: Prefix::t?, full_name: TypeName, complete_text: String) -> void
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
attr_reader env: Environment
|
|
89
|
+
|
|
90
|
+
attr_reader context: Resolver::context
|
|
91
|
+
|
|
92
|
+
attr_reader type_name_resolver: Resolver::TypeNameResolver
|
|
93
|
+
|
|
94
|
+
attr_reader map: Environment::UseMap
|
|
95
|
+
|
|
96
|
+
def initialize: (env: Environment, context: Resolver::context, dirs: Array[Directives::t]) -> void
|
|
97
|
+
|
|
98
|
+
def complete_class_name: (RBS::Buffer input, line: Integer, column: Integer) -> Array[Item]
|
|
99
|
+
|
|
100
|
+
# Find type names from the context for RBS
|
|
101
|
+
#
|
|
102
|
+
# Doesn't take account of ancestors of the context.
|
|
103
|
+
#
|
|
104
|
+
def find_type_names: (Prefix::t) -> Array[TypeName]
|
|
105
|
+
|
|
106
|
+
# Returns a pair of
|
|
107
|
+
#
|
|
108
|
+
# * Absolute type name
|
|
109
|
+
# * Relative type name in given context if possible (or absolute name)
|
|
110
|
+
#
|
|
111
|
+
def resolve_name_in_context: (TypeName) -> [TypeName, TypeName]
|
|
112
|
+
|
|
113
|
+
def format_constant_name: (TypeName) -> String
|
|
114
|
+
|
|
115
|
+
def each_type_name: () { (TypeName) -> void } -> void
|
|
116
|
+
| () -> Enumerator[TypeName, void]
|
|
117
|
+
|
|
118
|
+
def each_outer_module: (?Resolver::context) { (Namespace) -> void } -> Namespace
|
|
119
|
+
| () -> Enumerator[Namespace, void]
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -9,7 +9,7 @@ module Steep
|
|
|
9
9
|
|
|
10
10
|
@errors: Array[Diagnostic::Signature::Base]
|
|
11
11
|
|
|
12
|
-
@type_name_resolver: RBS::TypeNameResolver?
|
|
12
|
+
@type_name_resolver: RBS::Resolver::TypeNameResolver?
|
|
13
13
|
|
|
14
14
|
@validator: RBS::Validator?
|
|
15
15
|
|
|
@@ -26,7 +26,7 @@ module Steep
|
|
|
26
26
|
|
|
27
27
|
def builder: () -> RBS::DefinitionBuilder
|
|
28
28
|
|
|
29
|
-
def type_name_resolver: () -> RBS::TypeNameResolver
|
|
29
|
+
def type_name_resolver: () -> RBS::Resolver::TypeNameResolver
|
|
30
30
|
|
|
31
31
|
def validator: () -> RBS::Validator
|
|
32
32
|
|
|
@@ -60,13 +60,17 @@ module Steep
|
|
|
60
60
|
|
|
61
61
|
def validate_const: () -> void
|
|
62
62
|
|
|
63
|
-
def validate_one_constant: (RBS::TypeName name, RBS::Environment::
|
|
63
|
+
def validate_one_constant: (RBS::TypeName name, RBS::Environment::ConstantEntry entry) -> void
|
|
64
64
|
|
|
65
65
|
def validate_global: () -> void
|
|
66
66
|
|
|
67
|
-
def validate_one_global: (Symbol name, RBS::Environment::
|
|
67
|
+
def validate_one_global: (Symbol name, RBS::Environment::GlobalEntry) -> void
|
|
68
68
|
|
|
69
|
-
def validate_one_alias: (RBS::TypeName name, ?RBS::Environment::
|
|
69
|
+
def validate_one_alias: (RBS::TypeName name, ?RBS::Environment::TypeAliasEntry entry) -> void
|
|
70
|
+
|
|
71
|
+
def validate_one_class_decl: (RBS::TypeName) -> void
|
|
72
|
+
|
|
73
|
+
def validate_one_class_alias: (RBS::TypeName, RBS::Environment::ClassAliasEntry | RBS::Environment::ModuleAliasEntry) -> void
|
|
70
74
|
|
|
71
75
|
def validate_alias: () -> void
|
|
72
76
|
|
|
@@ -20,6 +20,8 @@ module Steep
|
|
|
20
20
|
|
|
21
21
|
include NodeHelper
|
|
22
22
|
|
|
23
|
+
include ModuleHelper
|
|
24
|
+
|
|
23
25
|
attr_reader checker: Subtyping::Check
|
|
24
26
|
|
|
25
27
|
attr_reader source: Source
|
|
@@ -30,9 +32,7 @@ module Steep
|
|
|
30
32
|
|
|
31
33
|
attr_reader context: TypeInference::Context
|
|
32
34
|
|
|
33
|
-
%a{pure} def module_context: () -> TypeInference::Context::ModuleContext
|
|
34
|
-
|
|
35
|
-
def module_context!: () -> TypeInference::Context::ModuleContext
|
|
35
|
+
%a{pure} def module_context: () -> TypeInference::Context::ModuleContext
|
|
36
36
|
|
|
37
37
|
%a{pure} def method_context: () -> TypeInference::Context::MethodContext?
|
|
38
38
|
|
|
@@ -40,6 +40,8 @@ module Steep
|
|
|
40
40
|
|
|
41
41
|
%a{pure} def block_context: () -> TypeInference::Context::BlockContext?
|
|
42
42
|
|
|
43
|
+
def block_context!: () -> TypeInference::Context::BlockContext
|
|
44
|
+
|
|
43
45
|
%a{pure} def break_context: () -> TypeInference::Context::BreakContext?
|
|
44
46
|
|
|
45
47
|
%a{pure} def self_type: () -> AST::Types::t
|
|
@@ -58,7 +60,7 @@ module Steep
|
|
|
58
60
|
|
|
59
61
|
def update_type_env: () { (TypeInference::TypeEnv) -> TypeInference::TypeEnv } -> TypeConstruction
|
|
60
62
|
|
|
61
|
-
def check_relation: (sub_type: AST::Types::t, super_type: AST::Types::t, ?constraints: Subtyping::Constraints) -> Subtyping::Result::
|
|
63
|
+
def check_relation: (sub_type: AST::Types::t, super_type: AST::Types::t, ?constraints: Subtyping::Constraints) -> Subtyping::Result::t
|
|
62
64
|
|
|
63
65
|
# This is a variation of `#check_relation` method.
|
|
64
66
|
# It checks if given subtyping relation `sub_type <: super_type` holds or not, and returns truthy when *doesn't* hold.
|
|
@@ -80,9 +82,9 @@ module Steep
|
|
|
80
82
|
|
|
81
83
|
def with_method_constr: (untyped method_name, untyped node, args: untyped, self_type: untyped, definition: untyped) { (untyped) -> untyped } -> untyped
|
|
82
84
|
|
|
83
|
-
def implement_module: (module_name:
|
|
85
|
+
def implement_module: (module_name: RBS::TypeName, annotations: AST::Annotation::Collection, ?super_name: RBS::TypeName?) -> AST::Annotation::Implements::Module?
|
|
84
86
|
|
|
85
|
-
def default_module_context: (
|
|
87
|
+
def default_module_context: (AST::Annotation::Implements::Module? implement_module_name, nesting: RBS::Resolver::context) -> TypeInference::Context::ModuleContext
|
|
86
88
|
|
|
87
89
|
def for_module: (untyped node, untyped new_module_name) -> untyped
|
|
88
90
|
|
|
@@ -104,7 +106,7 @@ module Steep
|
|
|
104
106
|
|
|
105
107
|
def for_sclass: (Parser::AST::Node node, AST::Types::t `type`) -> TypeConstruction?
|
|
106
108
|
|
|
107
|
-
def for_branch: (Parser::AST::Node node, ?break_context: TypeInference::Context::BreakContext?) ->
|
|
109
|
+
def for_branch: (Parser::AST::Node node, ?break_context: TypeInference::Context::BreakContext?) -> TypeConstruction
|
|
108
110
|
|
|
109
111
|
def add_typing: (Parser::AST::Node node, type: AST::Types::t, ?constr: TypeConstruction) -> Pair
|
|
110
112
|
|
|
@@ -112,7 +114,7 @@ module Steep
|
|
|
112
114
|
|
|
113
115
|
def synthesize: (Parser::AST::Node node, ?hint: AST::Types::t?, ?condition: bool) -> Pair
|
|
114
116
|
|
|
115
|
-
def check: (Parser::AST::Node node, AST::Types::t `type`, ?constraints: Subtyping::Constraints) { (AST::Types::t, AST::Types::t, Subtyping::Result::
|
|
117
|
+
def check: (Parser::AST::Node node, AST::Types::t `type`, ?constraints: Subtyping::Constraints) { (AST::Types::t, AST::Types::t, Subtyping::Result::t) -> void } -> Pair
|
|
116
118
|
|
|
117
119
|
def masgn_lhs?: (untyped lhs) -> untyped
|
|
118
120
|
|
|
@@ -126,13 +128,43 @@ module Steep
|
|
|
126
128
|
|
|
127
129
|
def constant_typename: (Parser::AST::Node parent, Symbol name) -> RBS::TypeName?
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
# Synthesize a constant declaration -- :cdecl, :class, or :module
|
|
132
|
+
#
|
|
133
|
+
# * `node` is the node that references a constant
|
|
134
|
+
# * `parent_node` is the parent (namespace) of a constant reference
|
|
135
|
+
# * `constant_name` is the name of constant
|
|
136
|
+
#
|
|
137
|
+
# Yields a block that is expected to add an error, or it reports Diagnostic::Ruby::UnknownConstant if not given.
|
|
138
|
+
#
|
|
139
|
+
# Returns a tuple of
|
|
140
|
+
#
|
|
141
|
+
# * The type of the constant
|
|
142
|
+
# * TypeConstruction instance after the evaluation
|
|
143
|
+
# * The full name of the constant
|
|
144
|
+
#
|
|
145
|
+
def synthesize_constant_decl: (Parser::AST::Node? node, Parser::AST::Node? parent_node, Symbol constant_name) ?{ () -> void } -> [AST::Types::t, TypeConstruction, RBS::TypeName?]
|
|
146
|
+
|
|
147
|
+
# Synthesize a constant reference
|
|
148
|
+
#
|
|
149
|
+
# * `node` is the node that references a constant
|
|
150
|
+
# * `parent_node` is the parent (namespace) of a constant reference
|
|
151
|
+
# * `constant_name` is the name of constant
|
|
152
|
+
#
|
|
153
|
+
# Yields a block that is expected to add an error, or it reports Diagnostic::Ruby::UnknownConstant if not given.
|
|
154
|
+
#
|
|
155
|
+
# Returns a tuple of
|
|
156
|
+
#
|
|
157
|
+
# * The type of the constant
|
|
158
|
+
# * TypeConstruction instance after the evaluation
|
|
159
|
+
# * The full name of the constant
|
|
160
|
+
#
|
|
161
|
+
def synthesize_constant: (Parser::AST::Node? node, Parser::AST::Node? parent_node, Symbol constant_name) ?{ () -> void } -> [AST::Types::t, TypeConstruction, RBS::TypeName?]
|
|
130
162
|
|
|
131
163
|
def optional_proc?: (untyped `type`) -> (untyped | nil | nil | nil | nil)
|
|
132
164
|
|
|
133
|
-
def type_lambda: (Parser::AST::Node node, params_node: Parser::AST::Node, body_node: Parser::AST::Node, type_hint: AST::Types::t?) -> Pair
|
|
165
|
+
def type_lambda: (Parser::AST::Node & Parser::AST::_BlockNode node, params_node: Parser::AST::Node, body_node: Parser::AST::Node, type_hint: AST::Types::t?) -> Pair
|
|
134
166
|
|
|
135
|
-
def synthesize_children: (Parser::AST::Node node, ?skips: Array[Parser::AST::Node]) -> TypeConstruction
|
|
167
|
+
def synthesize_children: (Parser::AST::Node node, ?skips: Array[Parser::AST::Node?]) -> TypeConstruction
|
|
136
168
|
|
|
137
169
|
# Synthesize `:send`, `:csend`, `:block`, and `:numblock` node
|
|
138
170
|
#
|
|
@@ -255,7 +287,13 @@ module Steep
|
|
|
255
287
|
|
|
256
288
|
def eliminate_vars: (untyped `type`, untyped variables, ?to: untyped) -> untyped
|
|
257
289
|
|
|
290
|
+
# Type check arguments
|
|
291
|
+
#
|
|
292
|
+
# * Receives the `method_name` of a method that is being called
|
|
293
|
+
# * `method_name` is `nil` if it type checks arguments of block or proc
|
|
294
|
+
#
|
|
258
295
|
def type_check_args: (
|
|
296
|
+
Symbol | nil,
|
|
259
297
|
TypeInference::SendArgs,
|
|
260
298
|
Subtyping::Constraints,
|
|
261
299
|
Array[Diagnostic::Ruby::Base]
|
|
@@ -263,7 +301,7 @@ module Steep
|
|
|
263
301
|
|
|
264
302
|
def type_check_argument: (Parser::AST::Node node, type: AST::Types::t, constraints: Subtyping::Constraints, errors: Array[Diagnostic::Ruby::Base], ?report_node: Parser::AST::Node) -> Pair
|
|
265
303
|
|
|
266
|
-
def type_block_without_hint: (node: Parser::AST::Node, block_annotations: AST::Annotation::Collection, block_params: TypeInference::BlockParams?, block_body: Parser::AST::Node?) ?{ (Diagnostic::Ruby::Base) -> void } -> void
|
|
304
|
+
def type_block_without_hint: (node: Parser::AST::Node & Parser::AST::_BlockNode, block_annotations: AST::Annotation::Collection, block_params: TypeInference::BlockParams?, block_body: Parser::AST::Node?) ?{ (Diagnostic::Ruby::Base) -> void } -> void
|
|
267
305
|
|
|
268
306
|
def set_up_block_mlhs_params_env: (
|
|
269
307
|
Parser::AST::Node mlhs_node,
|
|
@@ -299,15 +337,19 @@ module Steep
|
|
|
299
337
|
|
|
300
338
|
# Synthesize the block body and returns the type of the body
|
|
301
339
|
#
|
|
302
|
-
# The constructor can be discarded because it cannot change anything outer than block.
|
|
340
|
+
# The constructor can be safely discarded because it cannot change anything outer than block.
|
|
303
341
|
#
|
|
304
|
-
def synthesize_block: (
|
|
342
|
+
def synthesize_block: (
|
|
343
|
+
node: Parser::AST::Node & Parser::AST::_BlockNode,
|
|
344
|
+
block_type_hint: AST::Types::t?,
|
|
345
|
+
block_body: Parser::AST::Node?
|
|
346
|
+
) -> AST::Types::t
|
|
305
347
|
|
|
306
|
-
def nesting: () -> RBS::Resolver::context
|
|
348
|
+
%a{pure} def nesting: () -> RBS::Resolver::context
|
|
307
349
|
|
|
308
350
|
def absolute_name: (untyped name) -> untyped
|
|
309
351
|
|
|
310
|
-
def union_type: (*AST::Types::t types) -> AST::Types::t
|
|
352
|
+
def union_type: (*AST::Types::t? types) -> AST::Types::t
|
|
311
353
|
|
|
312
354
|
# Returns union type of given types
|
|
313
355
|
#
|
|
@@ -328,27 +370,35 @@ module Steep
|
|
|
328
370
|
#
|
|
329
371
|
def union_of_tuple_to_tuple_of_union: (AST::Types::Union) -> AST::Types::Tuple?
|
|
330
372
|
|
|
331
|
-
def validate_method_definitions: (
|
|
373
|
+
def validate_method_definitions: (Parser::AST::Node node, AST::Annotation::Implements::Module module_name) -> void
|
|
332
374
|
|
|
333
375
|
def fallback_to_any: (Parser::AST::Node node) ?{ () -> Diagnostic::Ruby::Base } -> Pair
|
|
334
376
|
|
|
335
|
-
|
|
377
|
+
# Return `true` if `node` is `self.class`
|
|
378
|
+
def self_class?: (Parser::AST::Node node) -> bool
|
|
336
379
|
|
|
337
|
-
|
|
380
|
+
# Returns `true` if the given `node` is a `class` or `module` declaration that only contains module/class definitions
|
|
381
|
+
#
|
|
382
|
+
def namespace_module?: (Parser::AST::Node node) -> bool
|
|
338
383
|
|
|
339
384
|
def type_any_rec: (Parser::AST::Node node) -> Pair
|
|
340
385
|
|
|
341
386
|
def unwrap: (AST::Types::t `type`) -> AST::Types::t
|
|
342
387
|
|
|
388
|
+
# Returns `nil` if `type` is recursive
|
|
389
|
+
#
|
|
390
|
+
# See `Factory#deep_expand_alias`.
|
|
391
|
+
#
|
|
343
392
|
def deep_expand_alias: (AST::Types::t `type`) -> AST::Types::t?
|
|
344
393
|
|
|
345
|
-
|
|
394
|
+
# `A | B | ... | Z` => `[A, B, ..., Z]`
|
|
395
|
+
def flatten_union: (AST::Types::t) -> Array[AST::Types::t]
|
|
346
396
|
|
|
347
|
-
def select_flatten_types: (
|
|
397
|
+
def select_flatten_types: (AST::Types::t) { (AST::Types::t) -> boolish } -> Array[AST::Types::t]
|
|
348
398
|
|
|
349
|
-
def partition_flatten_types: (AST::Types::t
|
|
399
|
+
def partition_flatten_types: (AST::Types::t) { (AST::Types::t) -> boolish } -> [Array[AST::Types::t], Array[AST::Types::t]]
|
|
350
400
|
|
|
351
|
-
def flatten_array_elements: (
|
|
401
|
+
def flatten_array_elements: (AST::Types::t) -> Array[AST::Types::t]
|
|
352
402
|
|
|
353
403
|
def expand_alias: (AST::Types::t `type`) -> AST::Types::t
|
|
354
404
|
| [A] (AST::Types::t) { (AST::Types::t) -> A } -> A
|
|
@@ -357,7 +407,12 @@ module Steep
|
|
|
357
407
|
|
|
358
408
|
def to_instance_type: (untyped `type`, ?args: untyped?) -> untyped
|
|
359
409
|
|
|
360
|
-
|
|
410
|
+
# Synthesize the type of a node, assuming it has tuple type when possible
|
|
411
|
+
#
|
|
412
|
+
# * Try `#try_tuple_type` if applicable, or
|
|
413
|
+
# * Run the normal `#synthesize` else
|
|
414
|
+
#
|
|
415
|
+
def try_tuple_type!: (Parser::AST::Node node, ?hint: AST::Types::t?) -> Pair
|
|
361
416
|
|
|
362
417
|
# Try to give `array_node` a tuple type
|
|
363
418
|
#
|
|
@@ -428,22 +483,36 @@ module Steep
|
|
|
428
483
|
# * When hint is union type, it tries recursively with the union cases.
|
|
429
484
|
# * Otherwise, it tries to be a hash instance.
|
|
430
485
|
#
|
|
431
|
-
def type_hash: (
|
|
486
|
+
def type_hash: (Parser::AST::Node hash_node, hint: AST::Types::t?) -> untyped
|
|
432
487
|
|
|
433
488
|
# Returns the first one from elements of `types` that returns a type `t` where `t <: hint`.
|
|
434
489
|
#
|
|
435
490
|
def pick_one_of: (Array[AST::Types::t] types, range: untyped) { (AST::Types::t hint, TypeConstruction) -> Pair? } -> Pair?
|
|
436
491
|
|
|
437
|
-
|
|
492
|
+
# *Commit* the transaction (current typing) and returns a `TypeConstruction` with saved typing
|
|
493
|
+
#
|
|
494
|
+
# ```ruby
|
|
495
|
+
# transaction = typing.new_child(range) {|child| constr.with_new_typing(child) }
|
|
496
|
+
#
|
|
497
|
+
# # Do something that may fail
|
|
498
|
+
#
|
|
499
|
+
# if succeeded
|
|
500
|
+
# # Commit the may-fail operation
|
|
501
|
+
# constr = transaction.save_typing()
|
|
502
|
+
# else
|
|
503
|
+
# # Abort the transaction
|
|
504
|
+
# end
|
|
505
|
+
# ```
|
|
506
|
+
def save_typing: () -> TypeConstruction
|
|
438
507
|
|
|
439
|
-
# Returns `true` if a method call can be identified as _pure_
|
|
508
|
+
# Returns `true` if a method call can be identified as _pure_:
|
|
440
509
|
#
|
|
441
|
-
# * The `node` is not a call with
|
|
442
|
-
# * It always calls _pure_ method
|
|
443
|
-
# * The `receiver` is _pure_
|
|
510
|
+
# * The `node` is not a call with block,
|
|
511
|
+
# * It always calls _pure_ method,
|
|
512
|
+
# * The `receiver` is _pure_, and
|
|
444
513
|
# * All of the arguments are _pure_
|
|
445
514
|
#
|
|
446
|
-
def pure_send?: (TypeInference::MethodCall::Typed call, Parser::AST::Node receiver, Array[Parser::AST::Node] arguments) -> bool
|
|
515
|
+
def pure_send?: (TypeInference::MethodCall::Typed call, Parser::AST::Node? receiver, Array[Parser::AST::Node] arguments) -> bool
|
|
447
516
|
|
|
448
517
|
# Transform given `node` to a node that has a local variable instead of the outer most call/non-value node
|
|
449
518
|
#
|
|
@@ -149,6 +149,10 @@ module Steep
|
|
|
149
149
|
|
|
150
150
|
def each: () { (Param | MultipleParam) -> void } -> void
|
|
151
151
|
| () -> Enumerator[Param | MultipleParam, void]
|
|
152
|
+
|
|
153
|
+
# Yields `Param` recursively
|
|
154
|
+
#
|
|
155
|
+
def each_single_param: () { (Param) -> void } -> void
|
|
152
156
|
end
|
|
153
157
|
end
|
|
154
158
|
end
|