more typechecking
This commit is contained in:
parent
17cdbf0a50
commit
b3ffef7341
4 changed files with 15 additions and 35 deletions
|
|
@ -26,20 +26,10 @@
|
|||
---@field default_language? string
|
||||
---@field timeout_ms? number
|
||||
|
||||
---@class HookContext
|
||||
---@field problem_id string
|
||||
---@field platform string
|
||||
---@field contest_id string
|
||||
---@field source_file string
|
||||
---@field input_file string
|
||||
---@field output_file string
|
||||
---@field expected_file string
|
||||
---@field contest_config table
|
||||
|
||||
---@class Hooks
|
||||
---@field before_run? fun(ctx: HookContext)
|
||||
---@field before_debug? fun(ctx: HookContext)
|
||||
---@field setup_code? fun(ctx: HookContext)
|
||||
---@field before_run? fun(ctx: ProblemContext)
|
||||
---@field before_debug? fun(ctx: ProblemContext)
|
||||
---@field setup_code? fun(ctx: ProblemContext)
|
||||
|
||||
---@class cp.Config
|
||||
---@field contests table<string, ContestConfig>
|
||||
|
|
@ -103,7 +93,9 @@ function M.setup(user_config)
|
|||
for contest_name, contest_config in pairs(user_config.contests) do
|
||||
for lang_name, lang_config in pairs(contest_config) do
|
||||
if type(lang_config) == "table" and lang_config.extension then
|
||||
if not vim.tbl_contains(vim.tbl_keys(languages.filetype_to_language), lang_config.extension) then
|
||||
if
|
||||
not vim.tbl_contains(vim.tbl_keys(languages.filetype_to_language), lang_config.extension)
|
||||
then
|
||||
error(
|
||||
("Invalid extension '%s' for language '%s' in contest '%s'. Valid extensions: %s"):format(
|
||||
lang_config.extension,
|
||||
|
|
|
|||
|
|
@ -103,9 +103,9 @@ local function compile_generic(language_config, substitutions)
|
|||
local compile_cmd = substitute_template(language_config.compile, substitutions)
|
||||
logger.log(("compiling: %s"):format(table.concat(compile_cmd, " ")))
|
||||
|
||||
local start_time = vim.loop.hrtime()
|
||||
local start_time = vim.uv.hrtime()
|
||||
local result = vim.system(compile_cmd, { text = true }):wait()
|
||||
local compile_time = (vim.loop.hrtime() - start_time) / 1000000
|
||||
local compile_time = (vim.uv.hrtime() - start_time) / 1000000
|
||||
|
||||
if result.code == 0 then
|
||||
logger.log(("compilation successful (%.1fms)"):format(compile_time))
|
||||
|
|
@ -129,7 +129,7 @@ local function execute_command(cmd, input_data, timeout_ms)
|
|||
|
||||
logger.log(("executing: %s"):format(table.concat(cmd, " ")))
|
||||
|
||||
local start_time = vim.loop.hrtime()
|
||||
local start_time = vim.uv.hrtime()
|
||||
|
||||
local result = vim.system(cmd, {
|
||||
stdin = input_data,
|
||||
|
|
@ -137,7 +137,7 @@ local function execute_command(cmd, input_data, timeout_ms)
|
|||
text = true,
|
||||
}):wait()
|
||||
|
||||
local end_time = vim.loop.hrtime()
|
||||
local end_time = vim.uv.hrtime()
|
||||
local execution_time = (end_time - start_time) / 1000000
|
||||
|
||||
local actual_code = result.code or 0
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ local function set_platform(platform)
|
|||
end
|
||||
|
||||
state.platform = platform
|
||||
vim.fn.mkdir("build", "p")
|
||||
vim.fn.mkdir("io", "p")
|
||||
vim.fs.mkdir("build", { parents = true })
|
||||
vim.fs.mkdir("io", { parents = true })
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue