luaur_web/methods/demo_config_resolver_demo_config_resolver.rs
1//! `DemoConfigResolver::DemoConfigResolver()` (`CLI/src/Web.cpp:51-54`).
2//!
3//! ```cpp
4//! DemoConfigResolver()
5//! {
6//! defaultConfig.mode = Luau::Mode::Strict;
7//! }
8//! ```
9//!
10//! Wires the `ConfigResolver` vtable slot (`getConfig`) to the demo thunk.
11//!
12//! DELIBERATE DEVIATION from `Web.cpp`, which hard-sets `Mode::Strict`: the
13//! playground defaults to `Nonstrict` so each script's own `--!strict` /
14//! `--!nonstrict` mode comment governs (matching the `luaur-analyze` CLI). This
15//! avoids type-checking unannotated example scripts under strict and reporting
16//! findings that read, to a casual visitor, as the checker flagging clean code.
17
18use crate::records::demo_config_resolver::{
19 demo_config_resolver_get_config_thunk, DemoConfigResolver,
20};
21use luaur_analysis::records::config_resolver::ConfigResolver;
22use luaur_ast::enums::mode::Mode;
23use luaur_config::records::config::Config;
24
25impl DemoConfigResolver {
26 pub fn demo_config_resolver() -> Self {
27 let mut default_config = Config::default();
28 default_config.mode = Mode::Nonstrict;
29
30 DemoConfigResolver {
31 base: ConfigResolver {
32 get_config: Some(demo_config_resolver_get_config_thunk),
33 },
34 default_config,
35 }
36 }
37}
38
39impl Default for DemoConfigResolver {
40 fn default() -> Self {
41 Self::demo_config_resolver()
42 }
43}