@@ -9,7 +9,6 @@ def setup
99 @uri = URI ( "file:///fake.rb" )
1010 @store = RubyLsp ::Store . new
1111 @executor = RubyLsp ::Executor . new ( @store , @message_queue )
12- stub_no_typechecker
1312 end
1413
1514 def teardown
@@ -175,6 +174,7 @@ def test_completion_is_not_triggered_if_argument_is_not_a_string
175174 end
176175
177176 def test_completion_for_constants
177+ stub_no_typechecker
178178 document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
179179 class Foo
180180 end
@@ -196,6 +196,7 @@ class Foo
196196 end
197197
198198 def test_completion_for_constant_paths
199+ stub_no_typechecker
199200 document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
200201 class Bar
201202 end
@@ -235,6 +236,7 @@ module Foo
235236 end
236237
237238 def test_completion_conflicting_constants
239+ stub_no_typechecker
238240 document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
239241 module Foo
240242 class Qux; end
@@ -264,6 +266,7 @@ class Qux; end
264266 end
265267
266268 def test_completion_for_top_level_constants_inside_nesting
269+ stub_no_typechecker
267270 document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
268271 class Bar
269272 end
@@ -292,6 +295,7 @@ module Foo
292295 end
293296
294297 def test_completion_private_constants_inside_the_same_namespace
298+ stub_no_typechecker
295299 document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
296300 class A
297301 CONST = 1
@@ -542,6 +546,58 @@ def qux
542546 assert_equal ( [ "bar" , "bar=" ] , result . map { |completion | completion . text_edit . new_text } )
543547 end
544548
549+ def test_with_typed_false
550+ document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
551+ # typed: false
552+ class Foo
553+ def complete_me
554+ end
555+
556+ def you
557+ comp
558+ end
559+ end
560+ RUBY
561+
562+ end_position = { line : 6 , character : 8 }
563+ @store . set ( uri : @uri , source : document . source , version : 1 )
564+
565+ index = @executor . instance_variable_get ( :@index )
566+ index . index_single ( RubyIndexer ::IndexablePath . new ( nil , @uri . to_standardized_path ) , document . source )
567+
568+ result = run_request (
569+ method : "textDocument/completion" ,
570+ params : { textDocument : { uri : @uri . to_s } , position : end_position } ,
571+ )
572+ assert_equal ( [ "complete_me" ] , result . map ( &:label ) )
573+ end
574+
575+ def test_with_typed_true
576+ document = RubyLsp ::RubyDocument . new ( source : +<<~RUBY , version : 1 , uri : @uri )
577+ # typed: true
578+ class Foo
579+ def complete_me
580+ end
581+
582+ def you
583+ comp
584+ end
585+ end
586+ RUBY
587+
588+ end_position = { line : 6 , character : 8 }
589+ @store . set ( uri : @uri , source : document . source , version : 1 )
590+
591+ index = @executor . instance_variable_get ( :@index )
592+ index . index_single ( RubyIndexer ::IndexablePath . new ( nil , @uri . to_standardized_path ) , document . source )
593+
594+ result = run_request (
595+ method : "textDocument/completion" ,
596+ params : { textDocument : { uri : @uri . to_s } , position : end_position } ,
597+ )
598+ assert_empty ( result )
599+ end
600+
545601 private
546602
547603 def run_request ( method :, params : { } )
0 commit comments