@@ -147,6 +147,34 @@ TEST_CASE_FIXTURE(Fixture, "find_references_from_an_inline_table_property_in_a_t
147147 CHECK_EQ (lsp::Range{{6 , 20 }, {6 , 24 }}, result->at (1 ).range );
148148}
149149
150+ TEST_CASE_FIXTURE (Fixture, " find_references_of_a_property_includes_the_original_table_type" )
151+ {
152+ // Finding reference of "name" in "T.name"
153+ auto source = R"(
154+ type Tbl = {
155+ name: string
156+ }
157+
158+ local T: Tbl
159+ local x = T.name
160+ )" ;
161+
162+ auto uri = newDocument (" foo.luau" , source);
163+
164+ lsp::ReferenceParams params;
165+ params.textDocument = lsp::TextDocumentIdentifier{uri};
166+ params.position = lsp::Position{6 , 22 };
167+
168+ auto result = workspace.references (params, nullptr );
169+ REQUIRE (result);
170+ REQUIRE_EQ (2 , result->size ());
171+
172+ sortResults (result);
173+
174+ CHECK_EQ (lsp::Range{{2 , 12 }, {2 , 16 }}, result->at (0 ).range );
175+ CHECK_EQ (lsp::Range{{6 , 20 }, {6 , 24 }}, result->at (1 ).range );
176+ }
177+
150178TEST_CASE_FIXTURE (Fixture, " find_references_of_a_global_function" )
151179{
152180 auto source = R"(
@@ -413,6 +441,41 @@ TEST_CASE_FIXTURE(Fixture, "cross_module_find_references_of_an_exported_table_ty
413441 CHECK_EQ (result->at (1 ).range , lsp::Range{{4 , 20 }, {4 , 28 }});
414442}
415443
444+ TEST_CASE_FIXTURE (Fixture, " cross_module_find_references_of_an_exported_table_type_property_when_selecting_a_property_usage" )
445+ {
446+ auto uri = newDocument (" tbl.luau" , R"(
447+ export type Table = {
448+ Property: string
449+ }
450+ return {}
451+ )" );
452+
453+ auto user = newDocument (" user.luau" , R"(
454+ local tbl = require("tbl.luau")
455+
456+ local t: tbl.Table
457+ local v = t.Property
458+ )" );
459+
460+ // Index reverse deps
461+ workspace.frontend .parse (workspace.fileResolver .getModuleName (user));
462+
463+ lsp::ReferenceParams params;
464+ params.textDocument = lsp::TextDocumentIdentifier{user};
465+ params.position = lsp::Position{4 , 23 }; // 'Property' usage when indexing 't'
466+
467+ auto result = workspace.references (params, nullptr );
468+ REQUIRE (result);
469+ REQUIRE_EQ (2 , result->size ());
470+
471+ sortResults (result);
472+
473+ CHECK_EQ (result->at (0 ).uri , uri);
474+ CHECK_EQ (result->at (0 ).range , lsp::Range{{2 , 12 }, {2 , 20 }});
475+ CHECK_EQ (result->at (1 ).uri , user);
476+ CHECK_EQ (result->at (1 ).range , lsp::Range{{4 , 20 }, {4 , 28 }});
477+ }
478+
416479TEST_CASE_FIXTURE (Fixture, " references_respect_cancellation" )
417480{
418481 auto cancellationToken = std::make_shared<Luau::FrontendCancellationToken>();
0 commit comments