mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Fallback to forAutocomplete.globalScope if no env scope
This commit is contained in:
parent
b4ce00abc8
commit
e80c970bab
2 changed files with 8 additions and 4 deletions
|
@ -164,7 +164,7 @@ private:
|
||||||
|
|
||||||
static LintResult classifyLints(const std::vector<LintWarning>& warnings, const Config& config);
|
static LintResult classifyLints(const std::vector<LintWarning>& warnings, const Config& config);
|
||||||
|
|
||||||
ScopePtr getModuleEnvironment(const SourceModule& module, const Config& config);
|
ScopePtr getModuleEnvironment(const SourceModule& module, const Config& config, bool forAutocomplete = false);
|
||||||
|
|
||||||
std::unordered_map<std::string, ScopePtr> environments;
|
std::unordered_map<std::string, ScopePtr> environments;
|
||||||
std::unordered_map<std::string, std::function<void(TypeChecker&, ScopePtr)>> builtinDefinitions;
|
std::unordered_map<std::string, std::function<void(TypeChecker&, ScopePtr)>> builtinDefinitions;
|
||||||
|
|
|
@ -403,7 +403,7 @@ CheckResult Frontend::check(const ModuleName& name, std::optional<FrontendOption
|
||||||
|
|
||||||
Mode mode = sourceModule.mode.value_or(config.mode);
|
Mode mode = sourceModule.mode.value_or(config.mode);
|
||||||
|
|
||||||
ScopePtr environmentScope = getModuleEnvironment(sourceModule, config);
|
ScopePtr environmentScope = getModuleEnvironment(sourceModule, config, frontendOptions.forAutocomplete);
|
||||||
|
|
||||||
double timestamp = getTimestamp();
|
double timestamp = getTimestamp();
|
||||||
|
|
||||||
|
@ -625,9 +625,13 @@ bool Frontend::parseGraph(std::vector<ModuleName>& buildQueue, CheckResult& chec
|
||||||
return cyclic;
|
return cyclic;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopePtr Frontend::getModuleEnvironment(const SourceModule& module, const Config& config)
|
ScopePtr Frontend::getModuleEnvironment(const SourceModule& module, const Config& config, bool forAutocomplete)
|
||||||
{
|
{
|
||||||
ScopePtr result = typeChecker.globalScope;
|
ScopePtr result;
|
||||||
|
if (forAutocomplete)
|
||||||
|
result = typeCheckerForAutocomplete.globalScope;
|
||||||
|
else
|
||||||
|
result = typeChecker.globalScope;
|
||||||
|
|
||||||
if (module.environmentName)
|
if (module.environmentName)
|
||||||
result = getEnvironmentScope(*module.environmentName);
|
result = getEnvironmentScope(*module.environmentName);
|
||||||
|
|
Loading…
Add table
Reference in a new issue