steep 1.7.0.dev.4 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/README.md +18 -0
  4. data/guides/src/gem-rbs-collection/gem-rbs-collection.md +7 -24
  5. data/lib/steep/rake_task.rb +132 -0
  6. data/lib/steep/type_construction.rb +1 -0
  7. data/lib/steep/version.rb +1 -1
  8. data/steep.gemspec +4 -1
  9. metadata +4 -143
  10. data/.github/dependabot.yml +0 -28
  11. data/.github/workflows/ruby-windows.yml +0 -35
  12. data/.github/workflows/ruby.yml +0 -32
  13. data/.vscode/steep-shared.code-snippets +0 -41
  14. data/Gemfile +0 -14
  15. data/Gemfile.lock +0 -104
  16. data/Gemfile.steep +0 -0
  17. data/gemfile_steep/Gemfile +0 -3
  18. data/gemfile_steep/Gemfile.lock +0 -77
  19. data/rbs_collection.steep.lock.yaml +0 -108
  20. data/rbs_collection.steep.yaml +0 -23
  21. data/sig/shims/bundler.rbs +0 -3
  22. data/sig/shims/concurrent-ruby.rbs +0 -39
  23. data/sig/shims/exception.rbs +0 -4
  24. data/sig/shims/language-server_protocol.rbs +0 -450
  25. data/sig/shims/parser/comment.rbs +0 -33
  26. data/sig/shims/parser/nodes.rbs +0 -252
  27. data/sig/shims/parser/source/map.rbs +0 -146
  28. data/sig/shims/parser/source/range.rbs +0 -237
  29. data/sig/shims/parser.rbs +0 -69
  30. data/sig/shims/string.rbs +0 -4
  31. data/sig/shims/tagged_logging.rbs +0 -6
  32. data/sig/shims/yaml.rbs +0 -4
  33. data/sig/steep/annotation_parser.rbs +0 -60
  34. data/sig/steep/ast/annotation/collection.rbs +0 -78
  35. data/sig/steep/ast/annotation.rbs +0 -121
  36. data/sig/steep/ast/builtin.rbs +0 -69
  37. data/sig/steep/ast/ignore.rbs +0 -66
  38. data/sig/steep/ast/node/type_application.rbs +0 -31
  39. data/sig/steep/ast/node/type_assertion.rbs +0 -32
  40. data/sig/steep/ast/types/any.rbs +0 -29
  41. data/sig/steep/ast/types/boolean.rbs +0 -31
  42. data/sig/steep/ast/types/bot.rbs +0 -29
  43. data/sig/steep/ast/types/class.rbs +0 -33
  44. data/sig/steep/ast/types/factory.rbs +0 -110
  45. data/sig/steep/ast/types/helper.rbs +0 -24
  46. data/sig/steep/ast/types/instance.rbs +0 -33
  47. data/sig/steep/ast/types/intersection.rbs +0 -40
  48. data/sig/steep/ast/types/literal.rbs +0 -35
  49. data/sig/steep/ast/types/logic.rbs +0 -83
  50. data/sig/steep/ast/types/name.rbs +0 -84
  51. data/sig/steep/ast/types/nil.rbs +0 -31
  52. data/sig/steep/ast/types/proc.rbs +0 -53
  53. data/sig/steep/ast/types/record.rbs +0 -39
  54. data/sig/steep/ast/types/self.rbs +0 -33
  55. data/sig/steep/ast/types/top.rbs +0 -29
  56. data/sig/steep/ast/types/tuple.rbs +0 -37
  57. data/sig/steep/ast/types/union.rbs +0 -40
  58. data/sig/steep/ast/types/var.rbs +0 -42
  59. data/sig/steep/ast/types/void.rbs +0 -29
  60. data/sig/steep/ast/types.rbs +0 -16
  61. data/sig/steep/cli.rbs +0 -55
  62. data/sig/steep/diagnostic/deprecated/else_on_exhaustive_case.rbs +0 -13
  63. data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +0 -15
  64. data/sig/steep/diagnostic/helper.rbs +0 -15
  65. data/sig/steep/diagnostic/lsp_formatter.rbs +0 -36
  66. data/sig/steep/diagnostic/ruby.rbs +0 -703
  67. data/sig/steep/diagnostic/signature.rbs +0 -252
  68. data/sig/steep/drivers/annotations.rbs +0 -17
  69. data/sig/steep/drivers/check.rbs +0 -33
  70. data/sig/steep/drivers/checkfile.rbs +0 -27
  71. data/sig/steep/drivers/diagnostic_printer.rbs +0 -25
  72. data/sig/steep/drivers/init.rbs +0 -19
  73. data/sig/steep/drivers/langserver.rbs +0 -36
  74. data/sig/steep/drivers/print_project.rbs +0 -15
  75. data/sig/steep/drivers/stats.rbs +0 -47
  76. data/sig/steep/drivers/utils/driver_helper.rbs +0 -25
  77. data/sig/steep/drivers/utils/jobs_option.rbs +0 -19
  78. data/sig/steep/drivers/validate.rbs +0 -15
  79. data/sig/steep/drivers/vendor.rbs +0 -19
  80. data/sig/steep/drivers/watch.rbs +0 -27
  81. data/sig/steep/drivers/worker.rbs +0 -29
  82. data/sig/steep/equatable.rbs +0 -11
  83. data/sig/steep/expectations.rbs +0 -72
  84. data/sig/steep/index/rbs_index.rbs +0 -141
  85. data/sig/steep/index/signature_symbol_provider.rbs +0 -41
  86. data/sig/steep/index/source_index.rbs +0 -63
  87. data/sig/steep/interface/block.rbs +0 -41
  88. data/sig/steep/interface/builder.rbs +0 -111
  89. data/sig/steep/interface/function.rbs +0 -271
  90. data/sig/steep/interface/method_type.rbs +0 -105
  91. data/sig/steep/interface/shape.rbs +0 -80
  92. data/sig/steep/interface/substitution.rbs +0 -51
  93. data/sig/steep/interface/type_param.rbs +0 -43
  94. data/sig/steep/method_name.rbs +0 -30
  95. data/sig/steep/module_helper.rbs +0 -16
  96. data/sig/steep/node_helper.rbs +0 -91
  97. data/sig/steep/path_helper.rbs +0 -15
  98. data/sig/steep/project/dsl.rbs +0 -108
  99. data/sig/steep/project/options.rbs +0 -47
  100. data/sig/steep/project/pattern.rbs +0 -47
  101. data/sig/steep/project/target.rbs +0 -25
  102. data/sig/steep/project.rbs +0 -26
  103. data/sig/steep/range_extension.rbs +0 -7
  104. data/sig/steep/server/base_worker.rbs +0 -49
  105. data/sig/steep/server/change_buffer.rbs +0 -38
  106. data/sig/steep/server/delay_queue.rbs +0 -37
  107. data/sig/steep/server/interaction_worker.rbs +0 -90
  108. data/sig/steep/server/lsp_formatter.rbs +0 -63
  109. data/sig/steep/server/master.rbs +0 -299
  110. data/sig/steep/server/type_check_worker.rbs +0 -141
  111. data/sig/steep/server/worker_process.rbs +0 -97
  112. data/sig/steep/services/completion_provider.rbs +0 -264
  113. data/sig/steep/services/content_change.rbs +0 -37
  114. data/sig/steep/services/file_loader.rbs +0 -21
  115. data/sig/steep/services/goto_service.rbs +0 -106
  116. data/sig/steep/services/hover_provider/rbs.rbs +0 -47
  117. data/sig/steep/services/hover_provider/ruby.rbs +0 -127
  118. data/sig/steep/services/hover_provider/singleton_methods.rbs +0 -11
  119. data/sig/steep/services/path_assignment.rbs +0 -21
  120. data/sig/steep/services/signature_help_provider.rbs +0 -51
  121. data/sig/steep/services/signature_service.rbs +0 -156
  122. data/sig/steep/services/stats_calculator.rbs +0 -41
  123. data/sig/steep/services/type_check_service.rbs +0 -112
  124. data/sig/steep/services/type_name_completion.rbs +0 -135
  125. data/sig/steep/signature/validator.rbs +0 -85
  126. data/sig/steep/source/ignore_ranges.rbs +0 -38
  127. data/sig/steep/source.rbs +0 -105
  128. data/sig/steep/subtyping/cache.rbs +0 -17
  129. data/sig/steep/subtyping/check.rbs +0 -131
  130. data/sig/steep/subtyping/constraints.rbs +0 -111
  131. data/sig/steep/subtyping/relation.rbs +0 -63
  132. data/sig/steep/subtyping/result.rbs +0 -179
  133. data/sig/steep/subtyping/variable_variance.rbs +0 -25
  134. data/sig/steep/thread_waiter.rbs +0 -13
  135. data/sig/steep/type_construction.rbs +0 -542
  136. data/sig/steep/type_inference/block_params.rbs +0 -170
  137. data/sig/steep/type_inference/case_when.rbs +0 -130
  138. data/sig/steep/type_inference/constant_env.rbs +0 -29
  139. data/sig/steep/type_inference/context.rbs +0 -216
  140. data/sig/steep/type_inference/context_array.rbs +0 -38
  141. data/sig/steep/type_inference/logic_type_interpreter.rbs +0 -108
  142. data/sig/steep/type_inference/method_call.rbs +0 -124
  143. data/sig/steep/type_inference/method_params.rbs +0 -127
  144. data/sig/steep/type_inference/multiple_assignment.rbs +0 -76
  145. data/sig/steep/type_inference/send_args.rbs +0 -243
  146. data/sig/steep/type_inference/type_env.rbs +0 -160
  147. data/sig/steep/type_inference/type_env_builder.rbs +0 -81
  148. data/sig/steep/typing.rbs +0 -75
  149. data/sig/steep.rbs +0 -45
@@ -1,160 +0,0 @@
1
- module Steep
2
- module TypeInference
3
- # TypeEnv is the one-stop class to manage type of variables.
4
- #
5
- # ### Local variables primitive operations
6
- #
7
- # * Assigning to a local variable
8
- # * Adding local variable type enforcement
9
- # * Refine local variable types
10
- # * Resetting refinements
11
- #
12
- # ### Pure calls primitive operations
13
- #
14
- # * Adding pure calls
15
- # * Removing pure calls
16
- # * Refine pure call types
17
- # * Resetting pure call refinements
18
- #
19
- # ### Branch operations
20
- #
21
- # * Start branching with refinements
22
- # * Merge branches
23
- #
24
- #
25
- class TypeEnv
26
- include NodeHelper
27
-
28
- type local_variable_entry = [AST::Types::t, AST::Types::t?]
29
-
30
- attr_reader local_variable_types: Hash[Symbol, local_variable_entry]
31
-
32
- attr_reader pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
33
-
34
- attr_reader instance_variable_types: Hash[Symbol, AST::Types::t]
35
-
36
- attr_reader global_types: Hash[Symbol, AST::Types::t]
37
-
38
- attr_reader constant_types: Hash[RBS::TypeName, AST::Types::t]
39
-
40
- attr_reader constant_env: ConstantEnv
41
-
42
- @pure_node_descendants: Hash[Parser::AST::Node, Set[Parser::AST::Node]]
43
-
44
- def initialize: (
45
- ConstantEnv,
46
- ?local_variable_types: Hash[Symbol, local_variable_entry],
47
- ?instance_variable_types: Hash[Symbol, AST::Types::t],
48
- ?global_types: Hash[Symbol, AST::Types::t],
49
- ?constant_types: Hash[RBS::TypeName, AST::Types::t],
50
- ?pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
51
- ) -> void
52
-
53
- def update: (
54
- ?local_variable_types: Hash[Symbol, local_variable_entry],
55
- ?instance_variable_types: Hash[Symbol, AST::Types::t],
56
- ?global_types: Hash[Symbol, AST::Types::t],
57
- ?constant_types: Hash[RBS::TypeName, AST::Types::t],
58
- ?pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
59
- ) -> TypeEnv
60
-
61
- def merge: (
62
- ?local_variable_types: Hash[Symbol, local_variable_entry],
63
- ?instance_variable_types: Hash[Symbol, AST::Types::t],
64
- ?global_types: Hash[Symbol, AST::Types::t],
65
- ?constant_types: Hash[RBS::TypeName, AST::Types::t],
66
- ?pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
67
- ) -> TypeEnv
68
-
69
- # Returns type of `name`.
70
- #
71
- def []: (Symbol name) -> AST::Types::t?
72
- | (Parser::AST::Node node) -> AST::Types::t?
73
-
74
- # Tells the environment that local variables are updated.
75
- # Keeps their enforced types and invalidates related nodes.
76
- #
77
- def assign_local_variables: (Hash[Symbol, AST::Types::t]) -> TypeEnv
78
-
79
- # Tells the environment that the local variable is updated with it's enforced type.
80
- #
81
- # Invalidates related nodes.
82
- #
83
- def assign_local_variable: (Symbol name, AST::Types::t type, AST::Types::t? enforced_type) -> TypeEnv
84
-
85
- # Refines types of local variables and pure calls.
86
- #
87
- # * Receives types of updated local variables and pure calls.
88
- # * The local variable types will be
89
- #
90
- def refine_types: (?local_variable_types: Hash[Symbol, AST::Types::t], ?pure_call_types: Hash[Parser::AST::Node, AST::Types::t]) -> TypeEnv
91
-
92
- def enforced_type: (Symbol name) -> AST::Types::t?
93
-
94
- # Returns type of constant of `const_name`, or `const_name` under `mod_name`.
95
- #
96
- # Returns `nil` if no such constant found.
97
- #
98
- def constant: (Symbol const_name, bool toplevel) -> ConstantEnv::constant_tuple?
99
- | (RBS::TypeName mod_name, Symbol const_name) -> ConstantEnv::constant_tuple?
100
-
101
- def annotated_constant: (RBS::TypeName) -> AST::Types::t?
102
-
103
- # _Pin_ the local variables if array is given.
104
- # When `nil` is given, all local variables are _pinned_.
105
- #
106
- def pin_local_variables: (Array[Symbol]? names) -> Hash[Symbol, local_variable_entry]
107
-
108
- # _Unpin_ the local variables if array is given.
109
- # When `nil` is given, all local variables are _unpinned_.
110
- #
111
- def unpin_local_variables: (Array[Symbol]? names) -> TypeEnv
112
-
113
- def to_s: () -> String
114
-
115
- # Apply the substitution to the type of local variables.
116
- #
117
- def subst: (Interface::Substitution) -> TypeEnv
118
-
119
- # Returns a `TypeEnv` such that:
120
- #
121
- # * All of the given environments are result of the type checking of branches from `self`,
122
- # * All of the branches meet at one point, with the returned `TypeEnv`
123
- #
124
- # See the example below:
125
- #
126
- # ```ruby
127
- # if foo() # The original environment `self` is for after the evaluation of `foo()`
128
- # a = bar() # One environment `env1` can be given from after the evaluation of `bar()`
129
- # else
130
- # b = baz() # Another environment `env2` is from after the evaluation of `baz`
131
- # end
132
- #
133
- # ??? # How is the environment for here is `self.merge(env1, env2)`
134
- # # The environment has both optional types of `a` and `b`
135
- # ```
136
- #
137
- def join: (*TypeEnv) -> TypeEnv
138
-
139
- def add_pure_call: (Parser::AST::Node, MethodCall::Typed, AST::Types::t?) -> TypeEnv
140
-
141
- def replace_pure_call_type: (Parser::AST::Node, AST::Types::t) -> TypeEnv
142
-
143
- def invalidate_pure_node: (Parser::AST::Node) -> TypeEnv
144
-
145
- private
146
-
147
- def pure_node_invalidation: (Enumerable[Parser::AST::Node] invalidated_nodes) -> Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
148
-
149
- def invalidated_pure_nodes: (Parser::AST::Node) -> Set[Parser::AST::Node]
150
-
151
- def local_variable_name?: (Symbol) -> bool
152
-
153
- def local_variable_name!: (Symbol) -> void
154
-
155
- def instance_variable_name?: (Symbol) -> bool
156
-
157
- def global_name?: (Symbol) -> bool
158
- end
159
- end
160
- end
@@ -1,81 +0,0 @@
1
- module Steep
2
- module TypeInference
3
- class TypeEnvBuilder
4
- module Command
5
- interface _Base
6
- def call: (TypeEnv) -> TypeEnv
7
- end
8
-
9
- class RBSBase
10
- attr_reader environment: RBS::Environment
11
-
12
- attr_reader factory: AST::Types::Factory
13
-
14
- def initialize: (AST::Types::Factory) -> void
15
- end
16
-
17
- class AnnotationsBase
18
- attr_reader annotations: AST::Annotation::Collection
19
-
20
- def initialize: (AST::Annotation::Collection) -> void
21
- end
22
-
23
- # Insert local variable annotations.
24
- #
25
- # * When _merge mode_ is on, adds and overwrite local variables.
26
- # * When _merge mode_ is off, it wipes all existing local variables and adds from annotations.
27
- #
28
- class ImportLocalVariableAnnotations < AnnotationsBase
29
- include _Base
30
-
31
- attr_reader on_duplicate: (^(Symbol, AST::Types::t, AST::Types::t) -> void)?
32
-
33
- @merge: bool
34
-
35
- # Set _merge mode_ `on`.
36
- def merge!: (?bool) -> self
37
-
38
- def on_duplicate!: () { (Symbol name, AST::Types::t original, AST::Types::t annotation) -> void } -> self
39
- end
40
-
41
- # Insert global variable types into type environment from `RBS::Environment`.
42
- #
43
- class ImportGlobalDeclarations < RBSBase
44
- def merge!: (?bool) -> self
45
-
46
- @merge: bool
47
-
48
- include _Base
49
- end
50
-
51
- class ImportInstanceVariableAnnotations < AnnotationsBase
52
- def merge!: (?bool) -> self
53
-
54
- include _Base
55
-
56
- @merge: bool
57
- end
58
-
59
- class ImportInstanceVariableDefinition
60
- attr_reader definition: RBS::Definition?
61
-
62
- attr_reader factory: AST::Types::Factory
63
-
64
- def initialize: (RBS::Definition?, AST::Types::Factory) -> void
65
-
66
- include _Base
67
- end
68
-
69
- class ImportConstantAnnotations < AnnotationsBase
70
- include _Base
71
- end
72
- end
73
-
74
- attr_reader commands: Array[Command::_Base]
75
-
76
- def initialize: (*Command::_Base?) -> void
77
-
78
- def build: (TypeEnv) -> TypeEnv
79
- end
80
- end
81
- end
data/sig/steep/typing.rbs DELETED
@@ -1,75 +0,0 @@
1
- use Steep::TypeInference::Context, Steep::TypeInference::ContextArray, Steep::TypeInference::MethodCall
2
-
3
- module Steep
4
- class Typing
5
- class UnknownNodeError < StandardError
6
- attr_reader op: Symbol
7
-
8
- attr_reader node: Parser::AST::Node
9
-
10
- def initialize: (Symbol op, node: Parser::AST::Node) -> void
11
- end
12
-
13
- attr_reader source: Source
14
-
15
- attr_reader errors: Array[Diagnostic::Ruby::Base]
16
-
17
- attr_reader typing: Hash[Parser::AST::Node, AST::Types::t]
18
-
19
- attr_reader parent: Typing?
20
-
21
- attr_reader parent_last_update: Integer?
22
-
23
- attr_reader last_update: Integer
24
-
25
- attr_reader should_update: bool
26
-
27
- attr_reader contexts: ContextArray
28
-
29
- attr_reader root_context: Context
30
-
31
- attr_reader method_calls: Hash[Parser::AST::Node, MethodCall::t]
32
-
33
- attr_reader source_index: Index::SourceIndex
34
-
35
- def initialize: (source: Source, root_context: Context, ?parent: Typing?, ?parent_last_update: Integer?, ?contexts: ContextArray?, ?source_index: Index::SourceIndex?) -> void
36
-
37
- def add_error: (Diagnostic::Ruby::Base error) -> void
38
-
39
- def add_typing: (Parser::AST::Node node, AST::Types::t `type`, top) -> void
40
-
41
- def add_call: (Parser::AST::Node node, MethodCall::t call) -> void
42
-
43
- def add_context: (Range[Integer] range, context: Context) -> void
44
-
45
- def has_type?: (Parser::AST::Node node) -> bool
46
-
47
- def type_of: (node: Parser::AST::Node) -> AST::Types::t
48
-
49
- def call_of: (node: Parser::AST::Node) -> TypeInference::MethodCall::t
50
-
51
- def add_context_for_node: (Parser::AST::Node node, context: Context) -> void
52
-
53
- def block_range: (Parser::AST::Node node) -> Range[Integer]
54
-
55
- def add_context_for_body: (Parser::AST::Node node, context: Context) -> void
56
-
57
- def context_at: (line: Integer, column: Integer) -> Context
58
-
59
- def dump: (untyped io) -> untyped
60
-
61
- def self.summary: (untyped node) -> ::String
62
-
63
- def new_child: [A] (Range[Integer] range) { (Typing) -> A } -> A
64
- | (Range[Integer]) -> Typing
65
-
66
- def each_typing: () { ([Parser::AST::Node, AST::Types::t]) -> void } -> void
67
-
68
- # Push the current changes to the `#parent` typing
69
- #
70
- # * Raises an error if `#parent` is `nil`
71
- # * Raises an error if `#parent` is changed since `#new_child` call that instantiated `self`
72
- #
73
- def save!: () -> void
74
- end
75
- end
data/sig/steep.rbs DELETED
@@ -1,45 +0,0 @@
1
- module Steep
2
- VERSION: String
3
-
4
- # `ui_logger` is a logger for user interaction messages
5
- #
6
- # The *main* process has the logger.
7
- # The *worker* processes disables the logging through this.
8
- #
9
- def self.ui_logger: () -> (Logger & ActiveSupport::TaggedLogging)
10
-
11
- def self.logger: () -> (Logger & ActiveSupport::TaggedLogging)
12
-
13
- def self.new_logger: (IO output, Integer? prev_level) -> (Logger & ActiveSupport::TaggedLogging)
14
-
15
- attr_accessor self.log_output: IO
16
-
17
- def self.measure: [A] (String message, ?level: ::Symbol, ?threshold: Float) { () -> A } -> A
18
-
19
- def self.log_error: (Exception exn, ?message: ::String) -> void
20
-
21
- self.@logger: (Logger & ActiveSupport::TaggedLogging)?
22
-
23
- self.@ui_logger: (Logger & ActiveSupport::TaggedLogging)?
24
-
25
- class Sampler
26
- type sample = [String, Float]
27
- @samples: Array[sample]
28
-
29
- def initialize: () -> void
30
-
31
- def sample: [A] (String message) { () -> A } -> A
32
-
33
- def count: () -> Integer
34
-
35
- def total: () -> Float
36
-
37
- def slowests: (Integer num) -> Array[sample]
38
-
39
- def average: () -> Float
40
-
41
- def percentile: (Integer p) -> Float
42
- end
43
-
44
- def self.measure2: [A] (String message, ?level: ::Symbol) { (Sampler) -> A } -> A
45
- end