Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/emmylua_code_analysis/resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"arrayIndex": true,
"docBaseConstMatchBaseType": true,
"metaOverrideFileDefine": true,
"requireExportGlobal": false,
"requirePath": false,
"typeCall": false
}
Expand Down Expand Up @@ -1044,6 +1045,11 @@
"type": "boolean",
"default": true
},
"requireExportGlobal": {
"description": "This option limits the visibility of third-party libraries.\n\nWhen enabled, third-party libraries must use `---@export global` annotation to be importable (i.e., no diagnostic errors and visible in auto-import).",
"type": "boolean",
"default": false
},
"requirePath": {
"description": "Whether to enable strict mode require path.",
"type": "boolean",
Expand Down
10 changes: 10 additions & 0 deletions crates/emmylua_code_analysis/resources/std/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

---@alias std.Nullable<T> T + ?

---
--- built-in type for Select function
---@alias std.Select<T, StartOrLen> unknown

Expand Down Expand Up @@ -143,22 +144,28 @@

---@alias Language<T: string> string

---
--- Get the parameters of a function as a tuple
---@alias Parameters<T extends function> T extends (fun(...: infer P): any) and P or never

---
--- Get the parameters of a constructor as a tuple
---@alias ConstructorParameters<T> T extends new (fun(...: infer P): any) and P or never

---
---@alias ReturnType<T extends function> T extends (fun(...: any): infer R) and R or any

---
--- Make all properties in T optional
---@alias Partial<T> { [P in keyof T]?: T[P]; }

--- attribute

---
--- Deprecated. Receives an optional message parameter.
---@attribute deprecated(message: string?)

---
--- Language Server Optimization Items.
---
--- Parameters:
Expand All @@ -167,11 +174,13 @@
--- Only valid for `local` declarations with no initial value.
---@attribute lsp_optimization(code: "check_table_field"|"delayed_definition")

---
--- Index field alias, will be displayed in `hint` and `completion`.
---
--- Receives a string parameter for the alias name.
---@attribute index_alias(name: string)

---
--- This attribute must be applied to function parameters, and the function parameter's type must be a string template generic,
--- used to specify the default constructor of a class.
---
Expand All @@ -182,6 +191,7 @@
--- - `return_self`: Whether the constructor is forced to return `self`, defaults to `true`
---@attribute constructor(name: string, root_class: string?, strip_self: boolean?, return_self: boolean?)

---
--- Associates `getter` and `setter` methods with a field. Currently provides only definition navigation functionality,
--- and the target methods must reside within the same class.
---
Expand Down
5 changes: 1 addition & 4 deletions crates/emmylua_code_analysis/resources/std/coroutine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ function coroutine.create(f) end
---@nodiscard
function coroutine.isyieldable() end



---@version > 5.4
---
---Closes coroutine `co` , closing all its pending to-be-closed variables and putting the coroutine in a dead state.
---
---@version > 5.4
---@param co thread
---@return boolean noerror
---@return any errorobject
function coroutine.close(co) end


---
--- Starts or continues the execution of coroutine `co`. The first time you
--- resume a coroutine, it starts running its body. The values `val1`, ...
Expand Down
15 changes: 7 additions & 8 deletions crates/emmylua_code_analysis/resources/std/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ function debug.gethook(thread) end
---@field activelines table

---@alias debuglib.InfoWhat
---|+"n" # `name` `namewhat`
---|+"S" # `source``short_src``linedefined``lalinedefined`,和 `what`
---|+"n" # `name`, `namewhat`
---|+"S" # `source`, `short_src`, `linedefined`, `lalinedefined`, `what`
---|+"l" # `currentline`
---|+"t" # `istailcall`
---|+"u" # `nups``nparams` `isvararg`
---|+"u" # `nups`, `nparams`, `isvararg`
---|+"f" # `func`
---|+"r" # `ftransfer` `ntransfer`
---|+"r" # `ftransfer`, `ntransfer`
---|+"L" # `activelines`
---| string

Expand Down Expand Up @@ -102,7 +102,7 @@ function debug.gethook(thread) end
---@nodiscard
function debug.getinfo(thread, f, what) end

--- @version >5.2, JIT
---@version >5.2, JIT
---
--- This function returns the name and the value of the local variable with
--- index `local` of the function at level `level f` of the stack. This function
Expand Down Expand Up @@ -134,7 +134,7 @@ function debug.getinfo(thread, f, what) end
--- @nodiscard
function debug.getlocal(thread, f, index) end

--- @version 5.1
---@version 5.1
---
--- This function returns the name and the value of the local variable with
--- index `index` of the function at level `level` of the stack. (The first
Expand Down Expand Up @@ -203,6 +203,7 @@ function debug.getuservalue(u, n) end
---@param limit integer
---@return integer|boolean
function debug.setcstacklimit(limit) end

---
---Sets the environment of the given `object` to the given `table` .
---
Expand Down Expand Up @@ -307,7 +308,6 @@ function debug.setuservalue(udata, value, n) end
---@return string
function debug.traceback(thread, message, level) end


--- Returns a unique identifier (as a light userdata) for the upvalue numbered
--- `n` from the given function.
---
Expand All @@ -322,7 +322,6 @@ function debug.traceback(thread, message, level) end
---@nodiscard
function debug.upvalueid(f, n) end


---
--- Make the `n1`-th upvalue of the Lua closure f1 refer to the `n2`-th upvalue
--- of the Lua closure f2.
Expand Down
7 changes: 5 additions & 2 deletions crates/emmylua_code_analysis/resources/std/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ function load(chunk, chunkname, mode, env) end
---
---Loads a chunk from the given string.
---
---
---@version 5.1, JIT
---@param text Language<"Lua">
---@param chunkname? string
Expand Down Expand Up @@ -237,6 +236,7 @@ function next(table, index) end
---@param t table<K, V> | V[] | {[K]: V}
---@return fun(tbl: any):K, V
function pairs(t) end

---
--- Calls function `f` with the given arguments in *protected mode*. This
--- means that any error inside `f` is not propagated; instead, `pcall` catches
Expand Down Expand Up @@ -337,7 +337,6 @@ function require(modname) end
---@return std.Select<T..., Num>
function select(index, ...) end


---@class std.metatable
---@field __mode? 'v'|'k'|'kv'
---@field __metatable? any
Expand Down Expand Up @@ -450,6 +449,7 @@ _VERSION = "Lua 5.4"
function xpcall(f, msgh, ...) end

---@version 5.1, JIT
---
---@generic T, Start: integer, End: integer
---@param i? std.ConstTpl<Start>
---@param j? std.ConstTpl<End>
Expand All @@ -458,6 +458,7 @@ function xpcall(f, msgh, ...) end
function unpack(list, i, j) end

---@version > 5.4
---
---@param message string
function warn(message) end

Expand All @@ -472,12 +473,14 @@ _ENV = {}


---@version 5.1, JIT
---
--- Sets the environment for the specified function.
---@param f function|integer The function for which the environment is to be set.
---@param env table The environment table to assign to the function.
function setfenv(f, env) end

---@version 5.1, JIT
---
--- Retrieves the environment table of the specified function.
---@param f function|integer The function whose environment is to be retrieved.
---@return table The environment table associated with the given function.
Expand Down
5 changes: 3 additions & 2 deletions crates/emmylua_code_analysis/resources/std/io.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function io.input(file) end
function io.lines(filename, ...) end

---@alias iolib.OpenMode "r" | "w" | "a" | "r+" | "w+" | "a+" | "rb" | "wb" | "ab" | "rb+" | "wb+" | "ab+" | "r+b" | "w+b" | "a+b"

---
--- This function opens a file, in the mode specified in the string `mode`. In
--- case of success, it returns a new file handle. The `mode` string can be
Expand Down Expand Up @@ -139,7 +140,7 @@ function io.write(...) end
---@class file
local file = {}

--- @version > 5.2
---@version > 5.2
---
--- Closes `file`. Note that files are automatically closed when their
--- handles are garbage collected, but that takes an unpredictable amount of
Expand All @@ -152,7 +153,7 @@ local file = {}
--- @return integer
function file:close() end

--- @version 5.1, JIT
---@version 5.1, JIT
---
--- Closes `file`. Note that files are automatically closed when their
--- handles are garbage collected, but that takes an unpredictable amount of
Expand Down
8 changes: 4 additions & 4 deletions crates/emmylua_code_analysis/resources/std/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function os.date(format, time) end
---@return number
function os.difftime(t2, t1) end

--- @version > 5.2
---@version > 5.2
---
--- This function is equivalent to the C function `system`. It passes `command`
--- to be executed by an operating system shell. Its first result is **true** if
Expand All @@ -102,7 +102,7 @@ function os.difftime(t2, t1) end
--- @return integer
function os.execute(command) end

--- @version 5.1, JIT
---@version 5.1, JIT
---
--- This function is equivalent to the C function system. It passes command to
--- be executed by an operating system shell. It returns a status code, which is
Expand All @@ -112,7 +112,7 @@ function os.execute(command) end
--- @return integer
function os.execute(command) end

--- @version > 5.2, JIT
---@version > 5.2, JIT
---
--- Calls the ISO C function `exit` to terminate the host program. If `code` is
--- **true**, the returned status is `EXIT_SUCCESS`; if `code` is **false**, the
Expand All @@ -126,7 +126,7 @@ function os.execute(command) end
---@return integer
function os.exit(code, close) end

--- @version 5.1
---@version 5.1
---
--- Calls the C function exit, with an optional `code`, to terminate the host
--- program. The default value for `code` is the success code.
Expand Down
3 changes: 2 additions & 1 deletion crates/emmylua_code_analysis/resources/std/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ package.preload = {}
package.loaders = {}

---@version > 5.2
---
--- A table used by require to control how to load modules.
---
--- Each entry in this table is a *searcher function*. When looking for a
Expand Down Expand Up @@ -170,10 +171,10 @@ package.searchers = {}
---@return string
function package.searchpath(name, path, sep, rep) end

---@version 5.1, JIT
---
---Sets a metatable for `module` with its `__index` field referring to the global environment, so that this module inherits values from the global environment. To be used as an option to function `module` .
---
---@version 5.1, JIT
---@param module table
function package.seeall(module) end

Expand Down
3 changes: 3 additions & 0 deletions crates/emmylua_code_analysis/resources/std/string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function string.lower(s) end
function string.match(s, pattern, init) end

---@version >5.3
---
--- Returns a binary string containing the values `v1`, `v2`, etc. packed (that
--- is, serialized in binary form) according to the format string `fmt`.
---@param fmt string
Expand All @@ -236,6 +237,7 @@ function string.match(s, pattern, init) end
function string.pack(fmt, v1, v2, ...) end

---@version >5.3
---
--- Returns the size of a string resulting from `string.pack` with the given
--- format. The format string cannot have the variable-length options '`s`' or
--- '`z`'
Expand Down Expand Up @@ -283,6 +285,7 @@ function string.reverse(s) end
function string.sub(s, i, j) end

---@version >5.3
---
--- Returns the values packed in string `s` according to the format string
--- `fmt`. An optional `pos` marks where to start reading in `s` (default is 1).
--- After the read values, this function also returns the index of the first
Expand Down
8 changes: 3 additions & 5 deletions crates/emmylua_code_analysis/resources/std/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function table.remove(list, pos) end
function table.sort(list, comp) end

---@version > 5.2, JIT
---
--- Returns the elements from the given list. This function is equivalent to
--- return `list[i]`, `list[i+1]`, `···`, `list[j]`
--- By default, i is 1 and j is #list.
Expand Down Expand Up @@ -136,32 +137,29 @@ function table.pack(...) end
---@deprecated
function table.foreach(list, callback) end


---@version 5.1, JIT
---
---Executes the given f over the numerical indices of table. For each index, f is called with the index and respective value as arguments. Indices are visited in sequential order, from 1 to n, where n is the size of the table. If f returns a non-nil value, then the loop is broken and this value is returned as the result of foreachi.
---
---@version 5.1, JIT
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T?
---@deprecated
function table.foreachi(list, callback) end


---@version 5.1, JIT
---
---Returns the number of elements in the table. This function is equivalent to `#list`.
---
---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.getn"])
---@version 5.1, JIT
---@generic T
---@param list T[]
---@return integer
---@nodiscard
---@deprecated
function table.getn(list) end


---Creates a new empty table, preallocating memory. This preallocation may help
---performance and save memory when you know in advance how many elements the table will have.
---Parameter `nseq` is a hint for how many elements the table will have as a sequence. Optional parameter `nrec`
Expand Down
Loading