mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
e491128f95
## What's new * Added `math.map` function to the standard library, based on https://rfcs.luau-lang.org/function-math-map.html * `FileResolver` can provide an implementation of `getRequireSuggestions` to provide auto-complete suggestions for require-by-string ## New Solver * In user-defined type functions, `readproperty` and `writeproperty` will return `nil` instead of erroring if property is not found * Fixed incorrect scope of variadic arguments in the data-flow graph * Fixed multiple assertion failures --- Internal Contributors: Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
73 lines
1.4 KiB
C++
73 lines
1.4 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
class AstExpr;
|
|
|
|
using ModuleName = std::string;
|
|
|
|
struct SourceCode
|
|
{
|
|
enum Type
|
|
{
|
|
None,
|
|
Module,
|
|
Script,
|
|
Local
|
|
};
|
|
|
|
std::string source;
|
|
Type type;
|
|
};
|
|
|
|
struct ModuleInfo
|
|
{
|
|
ModuleName name;
|
|
bool optional = false;
|
|
};
|
|
|
|
using RequireSuggestion = std::string;
|
|
using RequireSuggestions = std::vector<RequireSuggestion>;
|
|
|
|
struct FileResolver
|
|
{
|
|
virtual ~FileResolver() {}
|
|
|
|
virtual std::optional<SourceCode> readSource(const ModuleName& name) = 0;
|
|
|
|
virtual std::optional<ModuleInfo> resolveModule(const ModuleInfo* context, AstExpr* expr)
|
|
{
|
|
return std::nullopt;
|
|
}
|
|
|
|
virtual std::string getHumanReadableModuleName(const ModuleName& name) const
|
|
{
|
|
return name;
|
|
}
|
|
|
|
virtual std::optional<std::string> getEnvironmentForModule(const ModuleName& name) const
|
|
{
|
|
return std::nullopt;
|
|
}
|
|
|
|
virtual std::optional<RequireSuggestions> getRequireSuggestions(const ModuleName& requirer, const std::optional<std::string>& pathString) const
|
|
{
|
|
return std::nullopt;
|
|
}
|
|
};
|
|
|
|
struct NullFileResolver : FileResolver
|
|
{
|
|
std::optional<SourceCode> readSource(const ModuleName& name) override
|
|
{
|
|
return std::nullopt;
|
|
}
|
|
};
|
|
|
|
} // namespace Luau
|