mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
d19a5f0699
## What's Changed? * Optimized the vector dot product by up to 24% * Allow for x/y/z/X/Y/Z vector field access by registering a `vector` metatable with an `__index` method (Fixes #1521) * Fixed a bug preventing consistent recovery from parse errors in table types. * Optimized `k*n` and `k+n` when types are known * Allow fragment autocomplete to handle cases like the automatic insertion of parens, keywords, strings, etc., while maintaining a correct relative positioning ### New Solver * Allow for `nil` assignment to tables and classes with indexers --------- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@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>
95 lines
2.2 KiB
C++
95 lines
2.2 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 "Luau/DenseHash.h"
|
|
#include "Luau/LinterConfig.h"
|
|
#include "Luau/ParseOptions.h"
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
using ModuleName = std::string;
|
|
|
|
constexpr const char* kConfigName = ".luaurc";
|
|
|
|
struct Config
|
|
{
|
|
Config();
|
|
Config(const Config& other);
|
|
Config& operator=(const Config& other);
|
|
Config(Config&& other) = default;
|
|
Config& operator=(Config&& other) = default;
|
|
|
|
Mode mode = Mode::Nonstrict;
|
|
|
|
ParseOptions parseOptions;
|
|
|
|
LintOptions enabledLint;
|
|
LintOptions fatalLint;
|
|
|
|
bool lintErrors = false;
|
|
bool typeErrors = true;
|
|
|
|
std::vector<std::string> globals;
|
|
|
|
struct AliasInfo
|
|
{
|
|
std::string value;
|
|
std::string_view configLocation;
|
|
};
|
|
|
|
DenseHashMap<std::string, AliasInfo> aliases{""};
|
|
|
|
void setAlias(std::string alias, std::string value, const std::string& configLocation);
|
|
|
|
private:
|
|
// Prevents making unnecessary copies of the same config location string.
|
|
DenseHashMap<std::string, std::unique_ptr<std::string>> configLocationCache{""};
|
|
};
|
|
|
|
struct ConfigResolver
|
|
{
|
|
virtual ~ConfigResolver() {}
|
|
|
|
virtual const Config& getConfig(const ModuleName& name) const = 0;
|
|
};
|
|
|
|
struct NullConfigResolver : ConfigResolver
|
|
{
|
|
Config defaultConfig;
|
|
|
|
virtual const Config& getConfig(const ModuleName& name) const override;
|
|
};
|
|
|
|
std::optional<std::string> parseModeString(Mode& mode, const std::string& modeString, bool compat = false);
|
|
std::optional<std::string> parseLintRuleString(
|
|
LintOptions& enabledLints,
|
|
LintOptions& fatalLints,
|
|
const std::string& warningName,
|
|
const std::string& value,
|
|
bool compat = false
|
|
);
|
|
|
|
bool isValidAlias(const std::string& alias);
|
|
|
|
struct ConfigOptions
|
|
{
|
|
bool compat = false;
|
|
|
|
struct AliasOptions
|
|
{
|
|
std::string configLocation;
|
|
bool overwriteAliases;
|
|
};
|
|
std::optional<AliasOptions> aliasOptions = std::nullopt;
|
|
};
|
|
|
|
std::optional<std::string> parseConfig(const std::string& contents, Config& config, const ConfigOptions& options = ConfigOptions{});
|
|
|
|
} // namespace Luau
|