@@ -402,7 +402,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
402
402
assert macro_result . function == "some_macro"
403
403
assert macro_result . arity == 2
404
404
assert macro_result . documentation =~ "An example macro"
405
-
405
+
406
406
# Check that metadata is included (since: "1.1.0")
407
407
assert macro_result . documentation =~ "Since"
408
408
assert macro_result . documentation =~ "1.1.0"
@@ -437,7 +437,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
437
437
assert macrocallback_result . callback == "some_macrocallback"
438
438
assert macrocallback_result . arity == 1
439
439
assert macrocallback_result . documentation =~ "An example callback"
440
-
440
+
441
441
# Check that we got the documentation (metadata may be formatted differently for callbacks)
442
442
assert macrocallback_result . documentation
443
443
end
@@ -459,23 +459,33 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
459
459
460
460
test "verifies macro and macrocallback specs are included" do
461
461
# Test callback spec
462
- assert { :ok , result } = LlmDocsAggregator . execute ( [ [ "ElixirSenseExample.ModuleWithDocs.some_callback/1" ] ] , % { } )
462
+ assert { :ok , result } =
463
+ LlmDocsAggregator . execute (
464
+ [ [ "ElixirSenseExample.ModuleWithDocs.some_callback/1" ] ] ,
465
+ % { }
466
+ )
467
+
463
468
assert Map . has_key? ( result , :results )
464
469
assert length ( result . results ) == 1
465
-
470
+
466
471
callback_result = hd ( result . results )
467
472
assert Map . has_key? ( callback_result , :spec )
468
473
assert Map . has_key? ( callback_result , :kind )
469
474
assert Map . has_key? ( callback_result , :metadata )
470
475
assert callback_result . spec == "@callback some_callback(integer()) :: atom()"
471
476
assert callback_result . kind == :callback
472
477
assert callback_result . metadata . since == "1.1.0"
473
-
478
+
474
479
# Test macrocallback spec
475
- assert { :ok , result } = LlmDocsAggregator . execute ( [ [ "ElixirSenseExample.ModuleWithDocs.some_macrocallback/1" ] ] , % { } )
480
+ assert { :ok , result } =
481
+ LlmDocsAggregator . execute (
482
+ [ [ "ElixirSenseExample.ModuleWithDocs.some_macrocallback/1" ] ] ,
483
+ % { }
484
+ )
485
+
476
486
assert Map . has_key? ( result , :results )
477
487
assert length ( result . results ) == 1
478
-
488
+
479
489
macrocallback_result = hd ( result . results )
480
490
assert Map . has_key? ( macrocallback_result , :spec )
481
491
assert Map . has_key? ( macrocallback_result , :kind )
@@ -499,7 +509,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
499
509
assert func_result . function == "some_fun"
500
510
assert func_result . arity == 2
501
511
assert func_result . documentation =~ "An example fun"
502
-
512
+
503
513
# Verify that specs are included in the documentation
504
514
assert func_result . documentation =~ "**Specs:**"
505
515
assert func_result . documentation =~ "@spec some_fun"
@@ -521,7 +531,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
521
531
assert macro_result . function == "some_macro"
522
532
assert macro_result . arity == 2
523
533
assert macro_result . documentation =~ "An example macro"
524
-
534
+
525
535
# Verify that specs are included in the macro documentation
526
536
assert macro_result . documentation =~ "**Specs:**"
527
537
assert macro_result . documentation =~ "@spec some_macro"
@@ -541,11 +551,13 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
541
551
# Find the result with arity 2 (which has specs)
542
552
func_result = Enum . find ( result . results , & ( & 1 . arity == 2 ) )
543
553
assert func_result
544
-
554
+
545
555
# Verify spec formatting
546
556
assert func_result . documentation =~ "**Specs:**"
547
557
assert func_result . documentation =~ "```elixir"
548
- assert func_result . documentation =~ "@spec some_fun(integer(), integer() | nil) :: integer()"
558
+
559
+ assert func_result . documentation =~
560
+ "@spec some_fun(integer(), integer() | nil) :: integer()"
549
561
end
550
562
551
563
test "verifies macro specs are properly formatted" do
@@ -560,13 +572,51 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregatorTest
560
572
# Find the result with arity 2 (which has specs)
561
573
macro_result = Enum . find ( result . results , & ( & 1 . arity == 2 ) )
562
574
assert macro_result
563
-
575
+
564
576
# Verify spec formatting for macro
565
577
assert macro_result . documentation =~ "**Specs:**"
566
578
assert macro_result . documentation =~ "```elixir"
567
- assert macro_result . documentation =~ "@spec some_macro(Macro.t(), Macro.t() | nil) :: Macro.t()"
579
+
580
+ assert macro_result . documentation =~
581
+ "@spec some_macro(Macro.t(), Macro.t() | nil) :: Macro.t()"
568
582
end
569
583
584
+ test "handles builtin types with various arities" do
585
+ # Test builtin type without arity - returns all matching types
586
+ modules = [ "list" ]
587
+ assert { :ok , result } = LlmDocsAggregator . execute ( [ modules ] , % { } )
588
+ assert Map . has_key? ( result , :results )
589
+ assert length ( result . results ) == 2
590
+
591
+ # Should get both list() and list/1
592
+ list_result = Enum . find ( result . results , & ( & 1 . type == "list()" ) )
593
+ assert list_result
594
+ assert list_result . documentation == "A list"
595
+
596
+ list1_result = Enum . find ( result . results , & ( & 1 . type == "list/1" ) )
597
+ assert list1_result
598
+ assert list1_result . documentation == "Proper list ([]-terminated)"
599
+
600
+ # Test builtin type with arity 0
601
+ modules = [ "list/0" ]
602
+ assert { :ok , result } = LlmDocsAggregator . execute ( [ modules ] , % { } )
603
+ assert Map . has_key? ( result , :results )
604
+ assert length ( result . results ) == 1
605
+
606
+ list0_result = hd ( result . results )
607
+ assert list0_result . type == "list()"
608
+ assert list0_result . documentation == "A list"
609
+
610
+ # Test builtin type with arity 1
611
+ modules = [ "list/1" ]
612
+ assert { :ok , result } = LlmDocsAggregator . execute ( [ modules ] , % { } )
613
+ assert Map . has_key? ( result , :results )
614
+ assert length ( result . results ) == 1
615
+
616
+ list1_single = hd ( result . results )
617
+ assert list1_single . type == "list/1"
618
+ assert list1_single . documentation == "Proper list ([]-terminated)"
619
+ end
570
620
571
621
test "returns error for invalid arguments" do
572
622
# Test with non-list argument
0 commit comments