@@ -323,13 +323,9 @@ TEST_CASE_FIXTURE(Fixture, "includes_documentation_for_type_alias_declarations")
323323
324324 auto result = workspace.hover (params, nullptr );
325325 REQUIRE (result);
326- CHECK_EQ (
327- result->contents .value ,
328- codeBlock (" luau" , " type Meters = number" ) +
329- kDocumentationBreaker +
330- " The metre (or meter in [US spelling]; symbol: m) is the [base unit] of [length]\n " +
331- " in the [International System of Units] (SI)\n "
332- );
326+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " type Meters = number" ) + kDocumentationBreaker +
327+ " The metre (or meter in [US spelling]; symbol: m) is the [base unit] of [length]\n " +
328+ " in the [International System of Units] (SI)\n " );
333329}
334330
335331TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_type_alias_declarations_of_intersected_tables" )
@@ -356,13 +352,9 @@ TEST_CASE_FIXTURE(Fixture, "includes_documentation_for_type_alias_declarations_o
356352
357353 auto result = workspace.hover (params, nullptr );
358354 REQUIRE (result);
359- CHECK_EQ (
360- result->contents .value ,
361- codeBlock (" luau" , " type Foobar = {\n bar: \" Bar\"\n } & {\n foo: \" Foo\"\n }" ) +
362- kDocumentationBreaker +
363- " The terms foobar (/ˈfuːbɑːr/), foo, bar, baz, qux, quux, and others are used as\n " +
364- " metasyntactic variables and placeholder names in computer programming or computer-related documentation\n "
365- );
355+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " type Foobar = {\n bar: \" Bar\"\n } & {\n foo: \" Foo\"\n }" ) + kDocumentationBreaker +
356+ " The terms foobar (/ˈfuːbɑːr/), foo, bar, baz, qux, quux, and others are used as\n " +
357+ " metasyntactic variables and placeholder names in computer programming or computer-related documentation\n " );
366358}
367359
368360TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_type_references" )
@@ -417,6 +409,189 @@ TEST_CASE_FIXTURE(Fixture, "includes_documentation_for_external_type_references"
417409 CHECK_EQ (result->contents .value , codeBlock (" luau" , " type Types.Value = string" ) + kDocumentationBreaker + " This is a type\n " );
418410}
419411
412+ TEST_CASE_FIXTURE (Fixture, " show_type_of_global_variable" )
413+ {
414+ auto source = R"(
415+ print(DocumentedGlobalVariable)
416+ )" ;
417+
418+ auto uri = newDocument (" foo.luau" , source);
419+
420+ lsp::HoverParams params;
421+ params.textDocument = lsp::TextDocumentIdentifier{uri};
422+ params.position = lsp::Position{1 , 23 };
423+
424+ auto result = workspace.hover (params, nullptr );
425+ REQUIRE (result);
426+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " type DocumentedGlobalVariable = number" ));
427+ }
428+
429+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_a_global_type_table_from_definitions_file" )
430+ {
431+ auto source = R"(
432+ local x: DocumentedTable = nil
433+ )" ;
434+
435+ auto uri = newDocument (" foo.luau" , source);
436+
437+ lsp::HoverParams params;
438+ params.textDocument = lsp::TextDocumentIdentifier{uri};
439+ params.position = lsp::Position{1 , 24 };
440+
441+ auto result = workspace.hover (params, nullptr );
442+ REQUIRE (result);
443+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " type DocumentedTable = {\n "
444+ " member1: string\n "
445+ " }" ) +
446+ kDocumentationBreaker + " This is a documented table\n " );
447+ }
448+
449+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_a_global_type_table_from_definitions_file_when_hovering_over_variable_with_type" )
450+ {
451+ auto source = R"(
452+ local x: DocumentedTable = nil
453+ )" ;
454+
455+ auto uri = newDocument (" foo.luau" , source);
456+
457+ lsp::HoverParams params;
458+ params.textDocument = lsp::TextDocumentIdentifier{uri};
459+ params.position = lsp::Position{1 , 14 };
460+
461+ auto result = workspace.hover (params, nullptr );
462+ REQUIRE (result);
463+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " local x: {\n "
464+ " member1: string\n "
465+ " }" ) +
466+ kDocumentationBreaker + " This is a documented table\n " );
467+ }
468+
469+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_a_global_type_table_from_definitions_file_when_hovering_over_property" )
470+ {
471+ auto source = R"(
472+ local x: DocumentedTable = nil
473+ local y = x.member1
474+ )" ;
475+
476+ auto uri = newDocument (" foo.luau" , source);
477+
478+ lsp::HoverParams params;
479+ params.textDocument = lsp::TextDocumentIdentifier{uri};
480+ params.position = lsp::Position{2 , 23 };
481+
482+ auto result = workspace.hover (params, nullptr );
483+ REQUIRE (result);
484+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " string" ) + kDocumentationBreaker + " This is documented member1 of the table\n " );
485+ }
486+
487+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_for_a_global_function_call_from_definitions_file" )
488+ {
489+ auto source = R"(
490+ DocumentedGlobalFunction()
491+ )" ;
492+
493+ auto uri = newDocument (" foo.luau" , source);
494+
495+ lsp::HoverParams params;
496+ params.textDocument = lsp::TextDocumentIdentifier{uri};
497+ params.position = lsp::Position{1 , 20 };
498+
499+ auto result = workspace.hover (params, nullptr );
500+ REQUIRE (result);
501+ CHECK_EQ (result->contents .value ,
502+ codeBlock (" luau" , " function DocumentedGlobalFunction(): number" ) + kDocumentationBreaker + " This is a documented global function\n " );
503+ }
504+
505+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_when_hovering_over_class_type_from_definitions_file" )
506+ {
507+ auto source = R"(
508+ local x: DocumentedClass
509+ )" ;
510+
511+ auto uri = newDocument (" foo.luau" , source);
512+
513+ lsp::HoverParams params;
514+ params.textDocument = lsp::TextDocumentIdentifier{uri};
515+ params.position = lsp::Position{1 , 23 };
516+
517+ auto result = workspace.hover (params, nullptr );
518+ REQUIRE (result);
519+ CHECK_EQ (
520+ result->contents .value , codeBlock (" luau" , " type DocumentedClass = DocumentedClass" ) + kDocumentationBreaker + " This is a documented class\n " );
521+ }
522+
523+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_when_hovering_over_variable_with_class_type" )
524+ {
525+ auto source = R"(
526+ local x: DocumentedClass
527+ )" ;
528+
529+ auto uri = newDocument (" foo.luau" , source);
530+
531+ lsp::HoverParams params;
532+ params.textDocument = lsp::TextDocumentIdentifier{uri};
533+ params.position = lsp::Position{1 , 14 };
534+
535+ auto result = workspace.hover (params, nullptr );
536+ REQUIRE (result);
537+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " local x: DocumentedClass" ) + kDocumentationBreaker + " This is a documented class\n " );
538+ }
539+
540+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_when_hovering_over_class_type_property" )
541+ {
542+ auto source = R"(
543+ local x: DocumentedClass
544+ local y = x.member1
545+ )" ;
546+
547+ auto uri = newDocument (" foo.luau" , source);
548+
549+ lsp::HoverParams params;
550+ params.textDocument = lsp::TextDocumentIdentifier{uri};
551+ params.position = lsp::Position{2 , 23 };
552+
553+ auto result = workspace.hover (params, nullptr );
554+ REQUIRE (result);
555+ CHECK_EQ (result->contents .value , codeBlock (" luau" , " string" ) + kDocumentationBreaker + " This is a documented member1 of the class\n " );
556+ }
557+
558+ TEST_CASE_FIXTURE (Fixture, " includes_documentation_when_hovering_over_class_type_method_call" )
559+ {
560+ auto source = R"(
561+ local x: DocumentedClass
562+ local y = x:function1()
563+ )" ;
564+
565+ auto uri = newDocument (" foo.luau" , source);
566+
567+ lsp::HoverParams params;
568+ params.textDocument = lsp::TextDocumentIdentifier{uri};
569+ params.position = lsp::Position{2 , 23 };
570+
571+ auto result = workspace.hover (params, nullptr );
572+ REQUIRE (result);
573+ CHECK_EQ (result->contents .value ,
574+ codeBlock (" luau" , " function DocumentedClass:function1(): number" ) + kDocumentationBreaker + " This is a documented function1 of the class\n " );
575+ }
576+
577+ // TEST_CASE_FIXTURE(Fixture, "includes_documentation_when_hovering_over_global_variable_from_definitions_file")
578+ // {
579+ // auto source = R"(
580+ // print(DocumentedGlobalVariable)
581+ // )";
582+ //
583+ // auto uri = newDocument("foo.luau", source);
584+ //
585+ // lsp::HoverParams params;
586+ // params.textDocument = lsp::TextDocumentIdentifier{uri};
587+ // params.position = lsp::Position{1, 23};
588+ //
589+ // auto result = workspace.hover(params, nullptr);
590+ // REQUIRE(result);
591+ // CHECK_EQ(result->contents.value,
592+ // codeBlock("luau", "type DocumentedGlobalVariable = number") + kDocumentationBreaker + "This is a documented global variable\n");
593+ // }
594+
420595TEST_CASE_FIXTURE (Fixture, " handles_type_references_without_types_graph" )
421596{
422597 auto source = newDocument (" types.luau" , R"(
0 commit comments