diff --git a/CHANGELOG.md b/CHANGELOG.md index 77e5c6c4..68dd5178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fixed `:FindFirstChild()` not supporting a boolean "recursive" 2nd parameter on DataModel types ([#704](https://github.com/JohnnyMorganz/luau-lsp/issues/704)) - Fixed `:WaitForChild()` not supporting a number "timeout" 2nd parameter on DataModel types ([#704](https://github.com/JohnnyMorganz/luau-lsp/issues/704)) - Fixed inlay hint off-by-one on a function definition with an explicit self (i.e., `function Class.foo(self, param)`) ([#702](https://github.com/JohnnyMorganz/luau-lsp/issues/702)) +- Fixed `:GetPropertyChangedSignal()` still showing children in autocomplete for DataModel types ([#699](https://github.com/JohnnyMorganz/luau-lsp/issues/699)) ## [1.32.0] - 2024-07-14 diff --git a/src/platform/roblox/RobloxSourcemap.cpp b/src/platform/roblox/RobloxSourcemap.cpp index 428b66d3..c4ff2cc9 100644 --- a/src/platform/roblox/RobloxSourcemap.cpp +++ b/src/platform/roblox/RobloxSourcemap.cpp @@ -172,7 +172,14 @@ static Luau::TypeId getSourcemapType(const Luau::GlobalTypes& globals, Luau::Typ // Add children as properties for (const auto& child : node->children) - ctv->props[child->name] = Luau::makeProperty(getSourcemapType(globals, arena, child)); + ctv->props[child->name] = ctv->props[child->name] = Luau::Property{ + getSourcemapType(globals, arena, child), + /* deprecated */ false, + /* deprecatedSuggestion */ {}, + /* location */ std::nullopt, + /* tags */ {kSourcemapGeneratedTag}, + /* documentationSymbol*/ std::nullopt, + }; // Add FindFirstAncestor and FindFirstChild if (auto instanceType = getTypeIdForClass(globals.globalScope, "Instance")) diff --git a/tests/Autocomplete.test.cpp b/tests/Autocomplete.test.cpp index 329048da..25c39c6f 100644 --- a/tests/Autocomplete.test.cpp +++ b/tests/Autocomplete.test.cpp @@ -342,6 +342,41 @@ TEST_CASE_FIXTURE(Fixture, "get_property_changed_signal_does_not_include_childre checkStringCompletionExists(result, "ClassName"); } +TEST_CASE_FIXTURE(Fixture, "get_property_changed_signal_does_not_include_children_from_sourcemap_second_level_getsourcemaptype_ty") +{ + loadSourcemap(R"( + { + "name": "Game", + "className": "DataModel", + "children": [ + { + "name": "ReplicatedStorage", + "className": "ReplicatedStorage", + "children": [{"name": "Part", "className": "Part"}] + } + ] + })"); + + auto [source, marker] = sourceWithMarker(R"( + --!strict + game.ReplicatedStorage:GetPropertyChangedSignal("|") + )"); + + auto uri = newDocument("foo.luau", source); + + lsp::CompletionParams params; + params.textDocument = lsp::TextDocumentIdentifier{uri}; + params.position = marker; + + auto result = workspace.completion(params); + + CHECK_EQ(result.size(), 3); + CHECK_EQ(getItem(result, "Part"), std::nullopt); + checkStringCompletionExists(result, "Name"); + checkStringCompletionExists(result, "Parent"); + checkStringCompletionExists(result, "ClassName"); +} + TEST_CASE_FIXTURE(Fixture, "find_first_child_on_datamodel_contains_children") { loadSourcemap(R"(