luau/Analysis/include/Luau/FragmentAutocomplete.h

62 lines
1.5 KiB
C
Raw Normal View History

2024-09-28 01:11:46 +08:00
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once
#include "Luau/Ast.h"
2024-10-18 23:08:01 +08:00
#include "Luau/Parser.h"
#include "Luau/Autocomplete.h"
#include "Luau/DenseHash.h"
#include "Luau/Module.h"
2024-09-28 01:11:46 +08:00
2024-10-18 23:08:01 +08:00
#include <memory>
2024-09-28 01:11:46 +08:00
#include <vector>
namespace Luau
{
2024-10-26 00:46:08 +08:00
struct FrontendOptions;
2024-09-28 01:11:46 +08:00
struct FragmentAutocompleteAncestryResult
{
DenseHashMap<AstName, AstLocal*> localMap{AstName()};
std::vector<AstLocal*> localStack;
std::vector<AstNode*> ancestry;
2024-10-18 23:08:01 +08:00
AstStat* nearestStatement = nullptr;
};
struct FragmentParseResult
{
std::string fragmentToParse;
AstStatBlock* root = nullptr;
std::vector<AstNode*> ancestry;
std::unique_ptr<Allocator> alloc = std::make_unique<Allocator>();
2024-09-28 01:11:46 +08:00
};
2024-10-26 00:46:08 +08:00
struct FragmentTypeCheckResult
{
ModulePtr incrementalModule = nullptr;
Scope* freshScope = nullptr;
};
2024-09-28 01:11:46 +08:00
FragmentAutocompleteAncestryResult findAncestryForFragmentParse(AstStatBlock* root, const Position& cursorPos);
2024-10-18 23:08:01 +08:00
FragmentParseResult parseFragment(const SourceModule& srcModule, std::string_view src, const Position& cursorPos);
2024-10-26 00:46:08 +08:00
FragmentTypeCheckResult typecheckFragment(
Frontend& frontend,
const ModuleName& moduleName,
const Position& cursorPos,
std::optional<FrontendOptions> opts,
std::string_view src
);
2024-10-18 23:08:01 +08:00
AutocompleteResult fragmentAutocomplete(
Frontend& frontend,
std::string_view src,
const ModuleName& moduleName,
Position& cursorPosition,
2024-10-26 00:46:08 +08:00
std::optional<FrontendOptions> opts,
2024-10-18 23:08:01 +08:00
StringCompletionCallback callback
);
2024-09-28 01:11:46 +08:00
} // namespace Luau