steep 1.8.0.dev.2 → 1.8.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/bin/mem_graph.rb +67 -0
  4. data/bin/mem_prof.rb +102 -0
  5. data/bin/stackprof_test.rb +19 -0
  6. data/bin/steep-check.rb +251 -0
  7. data/lib/steep/annotation_parser.rb +1 -1
  8. data/lib/steep/ast/builtin.rb +5 -5
  9. data/lib/steep/ast/node/type_application.rb +7 -6
  10. data/lib/steep/ast/types/any.rb +1 -9
  11. data/lib/steep/ast/types/boolean.rb +8 -16
  12. data/lib/steep/ast/types/bot.rb +2 -10
  13. data/lib/steep/ast/types/class.rb +1 -13
  14. data/lib/steep/ast/types/factory.rb +101 -85
  15. data/lib/steep/ast/types/instance.rb +1 -13
  16. data/lib/steep/ast/types/intersection.rb +8 -15
  17. data/lib/steep/ast/types/literal.rb +2 -8
  18. data/lib/steep/ast/types/logic.rb +3 -24
  19. data/lib/steep/ast/types/name.rb +5 -16
  20. data/lib/steep/ast/types/nil.rb +3 -12
  21. data/lib/steep/ast/types/proc.rb +4 -13
  22. data/lib/steep/ast/types/record.rb +21 -12
  23. data/lib/steep/ast/types/self.rb +1 -13
  24. data/lib/steep/ast/types/shared_instance.rb +11 -0
  25. data/lib/steep/ast/types/top.rb +1 -9
  26. data/lib/steep/ast/types/tuple.rb +4 -10
  27. data/lib/steep/ast/types/union.rb +10 -15
  28. data/lib/steep/ast/types/var.rb +4 -13
  29. data/lib/steep/ast/types/void.rb +2 -10
  30. data/lib/steep/diagnostic/ruby.rb +4 -4
  31. data/lib/steep/drivers/check.rb +11 -14
  32. data/lib/steep/drivers/checkfile.rb +8 -10
  33. data/lib/steep/drivers/stats.rb +17 -13
  34. data/lib/steep/drivers/utils/driver_helper.rb +24 -3
  35. data/lib/steep/drivers/watch.rb +3 -3
  36. data/lib/steep/interface/builder.rb +162 -138
  37. data/lib/steep/interface/method_type.rb +12 -20
  38. data/lib/steep/interface/shape.rb +66 -10
  39. data/lib/steep/interface/substitution.rb +2 -0
  40. data/lib/steep/interface/type_param.rb +20 -7
  41. data/lib/steep/located_value.rb +20 -0
  42. data/lib/steep/server/change_buffer.rb +5 -7
  43. data/lib/steep/server/custom_methods.rb +61 -0
  44. data/lib/steep/server/delay_queue.rb +8 -1
  45. data/lib/steep/server/interaction_worker.rb +10 -5
  46. data/lib/steep/server/lsp_formatter.rb +8 -6
  47. data/lib/steep/server/master.rb +193 -140
  48. data/lib/steep/server/type_check_worker.rb +18 -19
  49. data/lib/steep/server/work_done_progress.rb +64 -0
  50. data/lib/steep/services/completion_provider.rb +24 -22
  51. data/lib/steep/services/goto_service.rb +3 -2
  52. data/lib/steep/services/hover_provider/ruby.rb +7 -6
  53. data/lib/steep/services/signature_help_provider.rb +7 -6
  54. data/lib/steep/services/signature_service.rb +1 -1
  55. data/lib/steep/services/type_check_service.rb +3 -3
  56. data/lib/steep/signature/validator.rb +17 -20
  57. data/lib/steep/subtyping/check.rb +105 -55
  58. data/lib/steep/subtyping/constraints.rb +11 -15
  59. data/lib/steep/type_construction.rb +100 -100
  60. data/lib/steep/type_inference/block_params.rb +6 -6
  61. data/lib/steep/type_inference/logic_type_interpreter.rb +11 -7
  62. data/lib/steep/type_inference/method_call.rb +3 -3
  63. data/lib/steep/type_inference/method_params.rb +1 -1
  64. data/lib/steep/type_inference/send_args.rb +1 -1
  65. data/lib/steep/typing.rb +158 -102
  66. data/lib/steep/version.rb +1 -1
  67. data/lib/steep.rb +28 -3
  68. data/steep.gemspec +2 -2
  69. metadata +16 -9
  70. data/lib/steep/type_inference/context_array.rb +0 -112
@@ -1,112 +0,0 @@
1
- module Steep
2
- module TypeInference
3
- class ContextArray
4
- class Entry
5
- attr_reader :range, :context, :sub_entries
6
-
7
- def initialize(range:, context:)
8
- @range = range
9
- @context = context
10
- @sub_entries = Set[].compare_by_identity
11
- end
12
- end
13
-
14
- attr_reader :buffer
15
- attr_reader :root
16
-
17
- def initialize(buffer:, context:, range: 0..buffer.content.size)
18
- @buffer = buffer
19
- @root = Entry.new(range: range, context: context)
20
- end
21
-
22
- def range
23
- root.range
24
- end
25
-
26
- def self.from_source(source:, range: nil, context:)
27
- content = if source.node
28
- source.node.location.expression.source_buffer.source
29
- else
30
- ""
31
- end
32
- buffer = RBS::Buffer.new(name: source.path, content: content)
33
- range ||= 0..buffer.content.size
34
- new(buffer: buffer, context: context, range: range)
35
- end
36
-
37
- def insert_context(range, context:, entry: self.root)
38
- entry.sub_entries.each do |sub|
39
- next if sub.range.begin <= range.begin && range.end <= sub.range.end
40
- next if range.begin <= sub.range.begin && sub.range.end <= range.end
41
- next if range.end <= sub.range.begin
42
- next if sub.range.end <= range.begin
43
-
44
- Steep.logger.error { "Range crossing: sub range=#{sub.range}, new range=#{range}" }
45
- raise
46
- end
47
-
48
- sup = entry.sub_entries.find do |sub|
49
- sub.range.begin < range.begin && range.end <= sub.range.end
50
- end
51
-
52
- if sup
53
- insert_context(range, context: context, entry: sup)
54
- else
55
- subs = entry.sub_entries.select do |sub|
56
- range.begin < sub.range.begin && sub.range.end <= range.end
57
- end
58
-
59
- new_entry = Entry.new(range: range, context: context)
60
- entry.sub_entries.subtract(subs)
61
- new_entry.sub_entries.merge(subs)
62
- entry.sub_entries << new_entry
63
- end
64
- end
65
-
66
- def each_entry(&block)
67
- if block
68
- es = [root]
69
-
70
- while e = es.pop
71
- es.push(*e.sub_entries.to_a)
72
-
73
- yield e
74
- end
75
- else
76
- enum_for :each_entry
77
- end
78
- end
79
-
80
- def context_at(index, entry: self.root)
81
- return nil if index < entry.range.begin || entry.range.end < index
82
-
83
- sub = entry.sub_entries.find do |sub|
84
- sub.range.begin <= index && index <= sub.range.end
85
- end
86
-
87
- if sub
88
- context_at(index, entry: sub)
89
- else
90
- entry.context
91
- end
92
- end
93
-
94
- def [](index)
95
- context_at(index)
96
- end
97
-
98
- def at(line:, column:)
99
- pos = buffer.loc_to_pos([line, column])
100
- self[pos]
101
- end
102
-
103
- def merge(subtree)
104
- subtree.each_entry do |entry|
105
- if entry.context
106
- insert_context entry.range, context: entry.context
107
- end
108
- end
109
- end
110
- end
111
- end
112
- end