From d2243ba26327a7ef97147b7027a759a509327072 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sun, 7 Jul 2024 13:16:58 +0200 Subject: [PATCH] Store comments in SourceModule for definition files --- Analysis/src/Frontend.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Analysis/src/Frontend.cpp b/Analysis/src/Frontend.cpp index 4339960d5..13db2be0b 100644 --- a/Analysis/src/Frontend.cpp +++ b/Analysis/src/Frontend.cpp @@ -35,6 +35,7 @@ LUAU_FASTINT(LuauTarjanChildLimit) LUAU_FASTFLAG(LuauInferInNoCheckMode) LUAU_FASTFLAGVARIABLE(LuauKnowsTheDataModel3, false) LUAU_FASTFLAGVARIABLE(LuauCancelFromProgress, false) +LUAU_FASTFLAGVARIABLE(LuauStoreCommentsForDefinitionFiles, false) LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution) LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJson, false) LUAU_FASTFLAGVARIABLE(DebugLuauLogSolverToJsonFile, false) @@ -126,6 +127,12 @@ static ParseResult parseSourceForModule(std::string_view source, Luau::SourceMod Luau::ParseResult parseResult = Luau::Parser::parse(source.data(), source.size(), *sourceModule.names, *sourceModule.allocator, options); sourceModule.root = parseResult.root; sourceModule.mode = Mode::Definition; + + if (FFlag::LuauStoreCommentsForDefinitionFiles && options.captureComments) + { + sourceModule.hotcomments = std::move(parseResult.hotcomments); + sourceModule.commentLocations = std::move(parseResult.commentLocations); + } return parseResult; }