steep 1.10.0 → 2.1.0.dev.1

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +84 -1
  3. data/CLAUDE.md +114 -0
  4. data/README.md +2 -2
  5. data/Rakefile +365 -150
  6. data/Steepfile +13 -13
  7. data/doc/release.md +264 -0
  8. data/lib/steep/annotation_parser.rb +5 -1
  9. data/lib/steep/annotations_helper.rb +12 -2
  10. data/lib/steep/ast/node/type_application.rb +22 -16
  11. data/lib/steep/ast/node/type_assertion.rb +7 -4
  12. data/lib/steep/ast/types/factory.rb +3 -2
  13. data/lib/steep/cli.rb +246 -2
  14. data/lib/steep/daemon/configuration.rb +19 -0
  15. data/lib/steep/daemon/server.rb +476 -0
  16. data/lib/steep/daemon.rb +201 -0
  17. data/lib/steep/diagnostic/ruby.rb +54 -12
  18. data/lib/steep/diagnostic/signature.rb +31 -8
  19. data/lib/steep/drivers/check.rb +301 -140
  20. data/lib/steep/drivers/print_project.rb +9 -10
  21. data/lib/steep/drivers/query.rb +102 -0
  22. data/lib/steep/drivers/start_server.rb +19 -0
  23. data/lib/steep/drivers/stop_server.rb +20 -0
  24. data/lib/steep/drivers/watch.rb +2 -2
  25. data/lib/steep/index/rbs_index.rb +38 -13
  26. data/lib/steep/index/signature_symbol_provider.rb +24 -3
  27. data/lib/steep/interface/builder.rb +48 -15
  28. data/lib/steep/interface/shape.rb +13 -5
  29. data/lib/steep/locator.rb +377 -0
  30. data/lib/steep/node_helper.rb +2 -2
  31. data/lib/steep/project/dsl.rb +26 -5
  32. data/lib/steep/project/group.rb +8 -2
  33. data/lib/steep/project/target.rb +16 -2
  34. data/lib/steep/project.rb +21 -2
  35. data/lib/steep/server/base_worker.rb +2 -2
  36. data/lib/steep/server/change_buffer.rb +2 -1
  37. data/lib/steep/server/custom_methods.rb +12 -0
  38. data/lib/steep/server/inline_source_change_detector.rb +94 -0
  39. data/lib/steep/server/interaction_worker.rb +51 -74
  40. data/lib/steep/server/lsp_formatter.rb +48 -12
  41. data/lib/steep/server/master.rb +100 -18
  42. data/lib/steep/server/target_group_files.rb +124 -151
  43. data/lib/steep/server/type_check_controller.rb +276 -123
  44. data/lib/steep/server/type_check_worker.rb +104 -3
  45. data/lib/steep/services/completion_provider/rbs.rb +74 -0
  46. data/lib/steep/services/completion_provider/ruby.rb +652 -0
  47. data/lib/steep/services/completion_provider/type_name.rb +243 -0
  48. data/lib/steep/services/completion_provider.rb +39 -662
  49. data/lib/steep/services/content_change.rb +14 -1
  50. data/lib/steep/services/file_loader.rb +4 -2
  51. data/lib/steep/services/goto_service.rb +271 -68
  52. data/lib/steep/services/hover_provider/content.rb +67 -0
  53. data/lib/steep/services/hover_provider/rbs.rb +8 -9
  54. data/lib/steep/services/hover_provider/ruby.rb +124 -65
  55. data/lib/steep/services/hover_provider/singleton_methods.rb +4 -0
  56. data/lib/steep/services/signature_help_provider.rb +1 -1
  57. data/lib/steep/services/signature_service.rb +129 -54
  58. data/lib/steep/services/type_check_service.rb +72 -27
  59. data/lib/steep/signature/validator.rb +30 -18
  60. data/lib/steep/source/ignore_ranges.rb +14 -4
  61. data/lib/steep/source.rb +21 -7
  62. data/lib/steep/tagged_logging.rb +39 -0
  63. data/lib/steep/type_construction.rb +111 -24
  64. data/lib/steep/type_inference/block_params.rb +7 -7
  65. data/lib/steep/type_inference/context.rb +4 -2
  66. data/lib/steep/type_inference/logic_type_interpreter.rb +24 -3
  67. data/lib/steep/type_inference/method_call.rb +4 -0
  68. data/lib/steep/type_inference/type_env.rb +1 -1
  69. data/lib/steep/typing.rb +3 -5
  70. data/lib/steep/version.rb +1 -1
  71. data/lib/steep.rb +42 -32
  72. data/manual/ruby-diagnostics.md +67 -0
  73. data/sample/Steepfile +1 -0
  74. data/sample/lib/conference.rb +1 -0
  75. data/sample/lib/deprecated.rb +6 -0
  76. data/sample/lib/inline.rb +43 -0
  77. data/sample/sig/generics.rbs +3 -0
  78. data/steep.gemspec +4 -5
  79. metadata +27 -26
  80. data/lib/steep/services/type_name_completion.rb +0 -236
@@ -0,0 +1,377 @@
1
+ module Steep
2
+ class Locator
3
+ extend NodeHelper
4
+
5
+ module TypeNameLocator
6
+ def type_name_at(position, type)
7
+ buffer = type.location&.buffer or raise
8
+
9
+ locator = RBS::Locator.new(buffer: buffer, decls: [], dirs: [])
10
+ components = [] #: Array[RBS::Locator::component]
11
+
12
+ if locator.find_in_type(position, type: type, array: components)
13
+ symbol, type, * = components
14
+ if symbol.is_a?(Symbol)
15
+ case type
16
+ when RBS::Types::ClassInstance, RBS::Types::ClassSingleton, RBS::Types::Alias, RBS::Types::Interface
17
+ if symbol == :name
18
+ type_loc = type.location or raise
19
+ name_loc = type.location[:name]
20
+ return [type.name, name_loc]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ NodeResult = Data.define(:node, :parents)
29
+
30
+ TypeAssertionResult = Data.define(:assertion, :node)
31
+
32
+ TypeApplicationResult = Data.define(:application, :node)
33
+
34
+ AnnotationResult = Data.define(:annotation, :node, :block)
35
+
36
+ CommentResult = Data.define(:comment, :node)
37
+
38
+ InlineAnnotationResult = Data.define(:annotation, :attached_ast)
39
+
40
+ InlineTypeResult = Data.define(:type, :annotation_result)
41
+
42
+ InlineTypeNameResult = Data.define(:type_name, :location, :enclosing_result)
43
+
44
+ class TypeAssertionResult
45
+ include TypeNameLocator
46
+
47
+ def locate_type_name(position, nesting, subtyping, type_vars)
48
+ if type = assertion.rbs_type(nesting, subtyping, type_vars)
49
+ location = type.location or raise
50
+ if location.start_pos <= position && position <= location.end_pos
51
+ if loc = type_name_at(position, type)
52
+ return loc
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ class TypeApplicationResult
60
+ include TypeNameLocator
61
+
62
+ def locate_type_name(position, nesting, subtyping, type_vars)
63
+ application.each_rbs_type(nesting, subtyping, type_vars) do |type|
64
+ location = type.location or raise
65
+ if location.start_pos <= position && position <= location.end_pos
66
+ if loc = type_name_at(position, type)
67
+ return loc
68
+ end
69
+ end
70
+ end
71
+
72
+ nil
73
+ end
74
+ end
75
+
76
+ class Ruby
77
+ include NodeHelper
78
+
79
+ attr_reader :source
80
+
81
+ def initialize(source)
82
+ @source = source
83
+ end
84
+
85
+ def find(line, column)
86
+ position = source.buffer.loc_to_pos([line, column])
87
+
88
+ if nodes = source.find_heredoc_nodes(line, column, position)
89
+ heredoc_node, *parent_nodes = nodes
90
+ heredoc_node or raise
91
+ each_child_node(heredoc_node) do |child_node|
92
+ if result = find_ruby_node_in(position, child_node, nodes)
93
+ return ruby_result_from_node(result, position)
94
+ end
95
+ end
96
+ return NodeResult.new(heredoc_node, parent_nodes)
97
+ end
98
+
99
+ if source.node && node = find_ruby_node_in(position, source.node, [])
100
+ ruby_result_from_node(node, position)
101
+ else
102
+ comment = source.comments.find { _1.location.expression.begin_pos <= position && position <= _1.location.expression.end_pos }
103
+ if comment
104
+ CommentResult.new(comment, nil)
105
+ end
106
+ end
107
+ end
108
+
109
+ def ruby_result_from_node(node, position)
110
+ case node.node.type
111
+ when :assertion
112
+ TypeAssertionResult.new(node.node.children[1], node)
113
+ when :tapp
114
+ application = node.node.children[1] #: AST::Node::TypeApplication
115
+ TypeApplicationResult.new(application, node)
116
+ else
117
+ comment = source.comments.find do
118
+ _1.location.expression.begin_pos <= position && position <= _1.location.expression.end_pos
119
+ end
120
+
121
+ if block_node = source.find_block_node([node.node, *node.parents])
122
+ source.each_block_annotation(block_node) do |annotation|
123
+ if location = annotation.location
124
+ if location.start_pos <= position && position <= location.end_pos
125
+ return AnnotationResult.new(annotation, node, block_node)
126
+ end
127
+ end
128
+ end
129
+ end
130
+
131
+ if comment
132
+ return CommentResult.new(comment, NodeResult.new(node.node, node.parents))
133
+ end
134
+
135
+ node
136
+ end
137
+ end
138
+
139
+ def find_ruby_node_in(position, node, parents)
140
+ return unless node
141
+
142
+ range = node.location.expression&.to_range
143
+
144
+ return unless range
145
+
146
+ if range.begin <= position && position <= range.end
147
+ parents.unshift(node)
148
+ each_child_node(node) do |child|
149
+ if result = find_ruby_node_in(position, child, parents)
150
+ return result
151
+ end
152
+ end
153
+
154
+ parents.shift
155
+ return NodeResult.new(node, parents)
156
+ end
157
+ end
158
+ end
159
+
160
+ class Inline
161
+ attr_reader :source
162
+
163
+ def initialize(source)
164
+ @source = source
165
+ end
166
+
167
+ def find(line, column)
168
+ position = source.buffer.loc_to_pos([line, column])
169
+
170
+ source.declarations.each do |decl|
171
+ if ast = find0(position, decl)
172
+ return inline_result(position, ast)
173
+ end
174
+ end
175
+
176
+ nil
177
+ end
178
+
179
+ def find0(position, ast)
180
+ case ast
181
+ when RBS::AST::Ruby::Declarations::ClassDecl
182
+ if ast.location.start_pos <= position && position <= ast.location.end_pos
183
+ # Check if position is within super class
184
+ if ast.super_class
185
+ if ast.super_class.location.start_pos <= position && position <= ast.super_class.location.end_pos
186
+ # Check if position is on type arguments
187
+ if ast.super_class.type_annotation
188
+ if ast.super_class.type_annotation.location.start_pos <= position && position <= ast.super_class.type_annotation.location.end_pos
189
+ return InlineAnnotationResult.new(ast.super_class.type_annotation, ast)
190
+ end
191
+ end
192
+ end
193
+ end
194
+
195
+ ast.members.each do |member|
196
+ if sub = find0(position, member)
197
+ return sub
198
+ end
199
+ end
200
+ end
201
+ when RBS::AST::Ruby::Declarations::ModuleDecl
202
+ if ast.location.start_pos <= position && position <= ast.location.end_pos
203
+ ast.members.each do |member|
204
+ if sub = find0(position, member)
205
+ return sub
206
+ end
207
+ end
208
+ end
209
+ when RBS::AST::Ruby::Members::DefMember
210
+ case annotations = ast.method_type.type_annotations
211
+ when RBS::AST::Ruby::Members::MethodTypeAnnotation::DocStyle
212
+ if annotation = annotations.return_type_annotation
213
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
214
+ return InlineAnnotationResult.new(annotations.return_type_annotation, ast)
215
+ end
216
+ end
217
+ when Array
218
+ annotations.each do |annotation|
219
+ case annotation
220
+ when RBS::AST::Ruby::Annotations::ColonMethodTypeAnnotation
221
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
222
+ return InlineAnnotationResult.new(annotation, ast)
223
+ end
224
+ when RBS::AST::Ruby::Annotations::MethodTypesAnnotation
225
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
226
+ return InlineAnnotationResult.new(annotation, ast)
227
+ end
228
+ end
229
+ end
230
+ end
231
+ when RBS::AST::Ruby::Members::IncludeMember, RBS::AST::Ruby::Members::ExtendMember, RBS::AST::Ruby::Members::PrependMember
232
+ if ast.annotation.is_a?(RBS::AST::Ruby::Annotations::TypeApplicationAnnotation)
233
+ if ast.annotation.location.start_pos <= position && position <= ast.annotation.location.end_pos
234
+ return InlineAnnotationResult.new(ast.annotation, ast)
235
+ end
236
+ end
237
+ when RBS::AST::Ruby::Members::AttrReaderMember, RBS::AST::Ruby::Members::AttrWriterMember, RBS::AST::Ruby::Members::AttrAccessorMember
238
+ if annotation = ast.type_annotation
239
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
240
+ return InlineAnnotationResult.new(annotation, ast)
241
+ end
242
+ end
243
+ when RBS::AST::Ruby::Members::InstanceVariableMember
244
+ annotation = ast.annotation
245
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
246
+ return InlineAnnotationResult.new(annotation, ast)
247
+ end
248
+ when RBS::AST::Ruby::Declarations::ConstantDecl
249
+ if annotation = ast.type_annotation
250
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
251
+ return InlineAnnotationResult.new(annotation, ast)
252
+ end
253
+ end
254
+ when RBS::AST::Ruby::Declarations::ClassModuleAliasDecl
255
+ if annotation = ast.annotation
256
+ if annotation.location.start_pos <= position && position <= annotation.location.end_pos
257
+ return InlineAnnotationResult.new(annotation, ast)
258
+ end
259
+ end
260
+ end
261
+
262
+ nil
263
+ end
264
+
265
+ def inline_result(position, result)
266
+ type_result = nil #: InlineTypeResult?
267
+
268
+ case result.annotation
269
+ when RBS::AST::Ruby::Annotations::ReturnTypeAnnotation
270
+ if type_location = result.annotation.return_type.location
271
+ if type_location.start_pos <= position && position <= type_location.end_pos
272
+ type_result = InlineTypeResult.new(result.annotation.return_type, result)
273
+ end
274
+ end
275
+ when RBS::AST::Ruby::Annotations::ColonMethodTypeAnnotation
276
+ type = result.annotation.method_type.each_type.find do |type|
277
+ if type_location = type.location
278
+ type_location.start_pos <= position && position <= type_location.end_pos
279
+ end
280
+ end
281
+
282
+ if type
283
+ type_result = InlineTypeResult.new(type, result)
284
+ end
285
+ when RBS::AST::Ruby::Annotations::MethodTypesAnnotation
286
+ overload = result.annotation.overloads.find do
287
+ if location = _1.method_type.location
288
+ location.start_pos <= position && position <= location.end_pos
289
+ end
290
+ end
291
+
292
+ if overload
293
+ type = overload.method_type.each_type.find do |type|
294
+ if type_location = type.location
295
+ type_location.start_pos <= position && position <= type_location.end_pos
296
+ end
297
+ end
298
+
299
+ if type
300
+ type_result = InlineTypeResult.new(type, result)
301
+ end
302
+ end
303
+ when RBS::AST::Ruby::Annotations::TypeApplicationAnnotation
304
+ # Find type argument that contains the position
305
+ type = result.annotation.type_args.find do |type_arg|
306
+ if type_location = type_arg.location
307
+ type_location.start_pos <= position && position <= type_location.end_pos
308
+ end
309
+ end
310
+
311
+ if type
312
+ type_result = InlineTypeResult.new(type, result)
313
+ end
314
+ when RBS::AST::Ruby::Annotations::NodeTypeAssertion
315
+ # Handle type annotations for attr_reader/writer/accessor
316
+ if type_location = result.annotation.type.location
317
+ if type_location.start_pos <= position && position <= type_location.end_pos
318
+ type_result = InlineTypeResult.new(result.annotation.type, result)
319
+ end
320
+ end
321
+ when RBS::AST::Ruby::Annotations::InstanceVariableAnnotation
322
+ # Handle type annotations for instance variables
323
+ if type_location = result.annotation.type.location
324
+ if type_location.start_pos <= position && position <= type_location.end_pos
325
+ type_result = InlineTypeResult.new(result.annotation.type, result)
326
+ end
327
+ end
328
+ when RBS::AST::Ruby::Annotations::ClassAliasAnnotation, RBS::AST::Ruby::Annotations::ModuleAliasAnnotation
329
+ # Handle class-alias and module-alias annotations with explicit type names
330
+ if result.annotation.type_name && result.annotation.type_name_location
331
+ if result.annotation.type_name_location.start_pos <= position && position <= result.annotation.type_name_location.end_pos
332
+ return InlineTypeNameResult.new(
333
+ result.annotation.type_name,
334
+ result.annotation.type_name_location,
335
+ result
336
+ )
337
+ end
338
+ end
339
+ end
340
+
341
+ if type_result
342
+ type_name_result(position, type_result)
343
+ else
344
+ result
345
+ end
346
+ end
347
+
348
+ def type_name_result(position, result)
349
+ locator = RBS::Locator.new(buffer: source.buffer, decls: [], dirs: [])
350
+ components = [] #: Array[RBS::Locator::component]
351
+
352
+ if locator.find_in_type(position, type: result.type, array: components)
353
+ symbol, type, * = components
354
+ if symbol.is_a?(Symbol)
355
+ type_name = nil #: RBS::TypeName?
356
+ location = nil #: RBS::Location?
357
+
358
+ case type
359
+ when RBS::Types::ClassInstance, RBS::Types::ClassSingleton, RBS::Types::Alias, RBS::Types::Interface
360
+ if symbol == :name
361
+ type_loc = type.location or raise
362
+ type_name = type.name
363
+ location = type_loc[:name] or raise
364
+ end
365
+ end
366
+
367
+ if type_name && location
368
+ return InlineTypeNameResult.new(type_name, location, result)
369
+ end
370
+ end
371
+ end
372
+
373
+ result
374
+ end
375
+ end
376
+ end
377
+ end
@@ -220,7 +220,7 @@ module Steep
220
220
 
221
221
  def private_send?(node)
222
222
  case node.type
223
- when :block, :numblock
223
+ when :block, :numblock, :itblock
224
224
  private_send?(node.children[0])
225
225
  when :send, :csend
226
226
  receiver, = deconstruct_send_node!(node)
@@ -243,7 +243,7 @@ module Steep
243
243
  when :send, :csend, :super
244
244
  if block_node
245
245
  case block_node.type
246
- when :block, :numblock
246
+ when :block, :numblock, :itblock
247
247
  if send_node.equal?(block_node.children[0])
248
248
  return [send_node, block_node]
249
249
  end
@@ -70,12 +70,20 @@ module Steep
70
70
  end
71
71
 
72
72
  module WithPattern
73
- def check(*args)
74
- sources.concat(args)
73
+ def check(*args, inline: false)
74
+ if inline
75
+ inline_sources.concat(args)
76
+ else
77
+ sources.concat(args)
78
+ end
75
79
  end
76
80
 
77
- def ignore(*args)
78
- ignored_sources.concat(args)
81
+ def ignore(*args, inline: false)
82
+ if inline
83
+ ignored_inline_sources.concat(args)
84
+ else
85
+ ignored_sources.concat(args)
86
+ end
79
87
  end
80
88
 
81
89
  def signature(*args)
@@ -94,6 +102,14 @@ module Steep
94
102
  @ignored_sources ||= []
95
103
  end
96
104
 
105
+ def inline_sources
106
+ @inline_sources ||= []
107
+ end
108
+
109
+ def ignored_inline_sources
110
+ @ignored_inline_sources ||= []
111
+ end
112
+
97
113
  def signatures
98
114
  @signatures ||= []
99
115
  end
@@ -109,6 +125,10 @@ module Steep
109
125
  def signature_pattern
110
126
  Pattern.new(patterns: signatures, ignores: ignored_signatures, ext: ".rbs")
111
127
  end
128
+
129
+ def inline_source_pattern
130
+ Pattern.new(patterns: inline_sources, ignores: ignored_inline_sources, ext: ".rb")
131
+ end
112
132
  end
113
133
 
114
134
  class TargetDSL
@@ -248,6 +268,7 @@ module Steep
248
268
  target = Project::Target.new(
249
269
  name: dsl.name,
250
270
  source_pattern: dsl.source_pattern,
271
+ inline_source_pattern: dsl.inline_source_pattern,
251
272
  signature_pattern: dsl.signature_pattern,
252
273
  options: dsl.library_configured? ? dsl.to_library_options : nil,
253
274
  code_diagnostics_config: dsl.code_diagnostics_config,
@@ -257,7 +278,7 @@ module Steep
257
278
  )
258
279
 
259
280
  dsl.groups.each do
260
- group = Group.new(target, _1.name, _1.source_pattern, _1.signature_pattern, _1.code_diagnostics_config || target.code_diagnostics_config)
281
+ group = Group.new(target, _1.name, _1.source_pattern, _1.inline_source_pattern, _1.signature_pattern, _1.code_diagnostics_config || target.code_diagnostics_config)
261
282
  target.groups << group
262
283
  end
263
284
 
@@ -3,14 +3,16 @@ module Steep
3
3
  class Group
4
4
  attr_reader :name
5
5
  attr_reader :source_pattern
6
+ attr_reader :inline_source_pattern
6
7
  attr_reader :signature_pattern
7
8
  attr_reader :target
8
9
  attr_reader :code_diagnostics_config
9
10
 
10
- def initialize(target, name, source_pattern, signature_pattern, code_diagnostics_config)
11
+ def initialize(target, name, source_pattern, inline_source_pattern, signature_pattern, code_diagnostics_config)
11
12
  @target = target
12
13
  @name = name
13
14
  @source_pattern = source_pattern
15
+ @inline_source_pattern = inline_source_pattern
14
16
  @signature_pattern = signature_pattern
15
17
  @code_diagnostics_config = code_diagnostics_config
16
18
  end
@@ -20,12 +22,16 @@ module Steep
20
22
  end
21
23
 
22
24
  def possible_source_file?(path)
23
- source_pattern =~ path
25
+ source_pattern =~ path && inline_source_pattern !~ path
24
26
  end
25
27
 
26
28
  def possible_signature_file?(path)
27
29
  signature_pattern =~ path
28
30
  end
31
+
32
+ def possible_inline_source_file?(path)
33
+ inline_source_pattern =~ path
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -6,16 +6,18 @@ module Steep
6
6
 
7
7
  attr_reader :source_pattern
8
8
  attr_reader :signature_pattern
9
+ attr_reader :inline_source_pattern
9
10
  attr_reader :code_diagnostics_config
10
11
  attr_reader :project
11
12
  attr_reader :unreferenced
12
13
  attr_reader :groups
13
14
  attr_reader :implicitly_returns_nil
14
15
 
15
- def initialize(name:, options:, source_pattern:, signature_pattern:, code_diagnostics_config:, project:, unreferenced:, implicitly_returns_nil:)
16
+ def initialize(name:, options:, source_pattern:, inline_source_pattern:, signature_pattern:, code_diagnostics_config:, project:, unreferenced:, implicitly_returns_nil:)
16
17
  @name = name
17
18
  @target_options = options
18
19
  @source_pattern = source_pattern
20
+ @inline_source_pattern = inline_source_pattern
19
21
  @signature_pattern = signature_pattern
20
22
  @code_diagnostics_config = code_diagnostics_config
21
23
  @project = project
@@ -33,7 +35,7 @@ module Steep
33
35
  return target
34
36
  end
35
37
 
36
- if source_pattern =~ path
38
+ if source_pattern =~ path && inline_source_pattern !~ path
37
39
  return self
38
40
  end
39
41
 
@@ -52,6 +54,18 @@ module Steep
52
54
  nil
53
55
  end
54
56
 
57
+ def possible_inline_source_file?(path)
58
+ if group = groups.find { _1.possible_inline_source_file?(path) }
59
+ return group
60
+ end
61
+
62
+ if inline_source_pattern =~ path
63
+ return self
64
+ end
65
+
66
+ nil
67
+ end
68
+
55
69
  def new_env_loader()
56
70
  Target.construct_env_loader(options: options, project: project)
57
71
  end
data/lib/steep/project.rb CHANGED
@@ -41,7 +41,7 @@ module Steep
41
41
  end
42
42
 
43
43
  def group_for_path(path)
44
- group_for_source_path(path) || group_for_signature_path(path)
44
+ group_for_source_path(path) || group_for_signature_path(path) || group_for_inline_source_path(path)
45
45
  end
46
46
 
47
47
  def group_for_signature_path(path)
@@ -53,6 +53,16 @@ module Steep
53
53
  nil
54
54
  end
55
55
 
56
+ def group_for_inline_source_path(path)
57
+ relative = relative_path(path)
58
+ targets.each do
59
+ ret = _1.possible_inline_source_file?(relative)
60
+ return ret if ret
61
+ end
62
+
63
+ nil
64
+ end
65
+
56
66
  def target_for_source_path(path)
57
67
  case group = group_for_source_path(path)
58
68
  when Target
@@ -71,8 +81,17 @@ module Steep
71
81
  end
72
82
  end
73
83
 
84
+ def target_for_inline_source_path(path)
85
+ case group = group_for_inline_source_path(path)
86
+ when Target
87
+ group
88
+ when Group
89
+ group.target
90
+ end
91
+ end
92
+
74
93
  def target_for_path(path)
75
- target_for_source_path(path) || target_for_signature_path(path)
94
+ target_for_source_path(path) || target_for_signature_path(path) || target_for_inline_source_path(path)
76
95
  end
77
96
  end
78
97
  end
@@ -38,11 +38,11 @@ module Steep
38
38
  end
39
39
 
40
40
  def run
41
- tags = Steep.logger.formatter.current_tags.dup
41
+ tags = Steep.logger.current_tags.dup
42
42
  thread = Thread.new do
43
43
  Thread.current.abort_on_exception = true
44
44
 
45
- Steep.logger.formatter.push_tags(*tags)
45
+ Steep.logger.push_tags(*tags)
46
46
  Steep.logger.tagged "background" do
47
47
  while job = queue.pop
48
48
  case job
@@ -29,7 +29,8 @@ module Steep
29
29
  push_buffer do |changes|
30
30
  input.each do |filename, content|
31
31
  if content.is_a?(Hash)
32
- content = Base64.decode64(content[:text]).force_encoding(Encoding::UTF_8)
32
+ base64_decoded = content[:text].unpack1("m") #: String
33
+ content = base64_decoded.force_encoding(Encoding::UTF_8)
33
34
  end
34
35
  changes[Pathname(filename.to_s)] = [Services::ContentChange.new(text: content)]
35
36
  end
@@ -84,6 +84,18 @@ module Steep
84
84
  { id: id, result: result }
85
85
  end
86
86
  end
87
+
88
+ module Query__Definition
89
+ METHOD = "$/steep/query/definition"
90
+
91
+ def self.request(id, params)
92
+ { method: METHOD, id: id, params: params }
93
+ end
94
+
95
+ def self.response(id, result)
96
+ { id: id, result: result }
97
+ end
98
+ end
87
99
  end
88
100
  end
89
101
  end