Skip to content

Commit 424b9a1

Browse files
authored
Merge pull request #875 from xuhuanzy/fix
update
2 parents 62cf037 + b032896 commit 424b9a1

File tree

39 files changed

+1104
-301
lines changed

39 files changed

+1104
-301
lines changed

crates/emmylua_code_analysis/resources/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
"arrayIndex": true,
139139
"docBaseConstMatchBaseType": true,
140140
"metaOverrideFileDefine": true,
141+
"requireExportGlobal": false,
141142
"requirePath": false,
142143
"typeCall": false
143144
}
@@ -1044,6 +1045,11 @@
10441045
"type": "boolean",
10451046
"default": true
10461047
},
1048+
"requireExportGlobal": {
1049+
"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).",
1050+
"type": "boolean",
1051+
"default": false
1052+
},
10471053
"requirePath": {
10481054
"description": "Whether to enable strict mode require path.",
10491055
"type": "boolean",

crates/emmylua_code_analysis/resources/std/builtin.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116

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

119+
---
119120
--- built-in type for Select function
120121
---@alias std.Select<T, StartOrLen> unknown
121122

@@ -143,22 +144,28 @@
143144

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

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

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

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

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

157162
--- attribute
158163

164+
---
159165
--- Deprecated. Receives an optional message parameter.
160166
---@attribute deprecated(message: string?)
161167

168+
---
162169
--- Language Server Optimization Items.
163170
---
164171
--- Parameters:
@@ -167,11 +174,13 @@
167174
--- Only valid for `local` declarations with no initial value.
168175
---@attribute lsp_optimization(code: "check_table_field"|"delayed_definition")
169176

177+
---
170178
--- Index field alias, will be displayed in `hint` and `completion`.
171179
---
172180
--- Receives a string parameter for the alias name.
173181
---@attribute index_alias(name: string)
174182

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

194+
---
185195
--- Associates `getter` and `setter` methods with a field. Currently provides only definition navigation functionality,
186196
--- and the target methods must reside within the same class.
187197
---

crates/emmylua_code_analysis/resources/std/coroutine.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@ function coroutine.create(f) end
3434
---@nodiscard
3535
function coroutine.isyieldable() end
3636

37-
38-
37+
---@version > 5.4
3938
---
4039
---Closes coroutine `co` , closing all its pending to-be-closed variables and putting the coroutine in a dead state.
4140
---
42-
---@version > 5.4
4341
---@param co thread
4442
---@return boolean noerror
4543
---@return any errorobject
4644
function coroutine.close(co) end
4745

48-
4946
---
5047
--- Starts or continues the execution of coroutine `co`. The first time you
5148
--- resume a coroutine, it starts running its body. The values `val1`, ...

crates/emmylua_code_analysis/resources/std/debug.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ function debug.gethook(thread) end
6464
---@field activelines table
6565

6666
---@alias debuglib.InfoWhat
67-
---|+"n" # `name` `namewhat`
68-
---|+"S" # `source``short_src``linedefined``lalinedefined`,和 `what`
67+
---|+"n" # `name`, `namewhat`
68+
---|+"S" # `source`, `short_src`, `linedefined`, `lalinedefined`, `what`
6969
---|+"l" # `currentline`
7070
---|+"t" # `istailcall`
71-
---|+"u" # `nups``nparams` `isvararg`
71+
---|+"u" # `nups`, `nparams`, `isvararg`
7272
---|+"f" # `func`
73-
---|+"r" # `ftransfer` `ntransfer`
73+
---|+"r" # `ftransfer`, `ntransfer`
7474
---|+"L" # `activelines`
7575
---| string
7676

@@ -102,7 +102,7 @@ function debug.gethook(thread) end
102102
---@nodiscard
103103
function debug.getinfo(thread, f, what) end
104104

105-
--- @version >5.2, JIT
105+
---@version >5.2, JIT
106106
---
107107
--- This function returns the name and the value of the local variable with
108108
--- index `local` of the function at level `level f` of the stack. This function
@@ -134,7 +134,7 @@ function debug.getinfo(thread, f, what) end
134134
--- @nodiscard
135135
function debug.getlocal(thread, f, index) end
136136

137-
--- @version 5.1
137+
---@version 5.1
138138
---
139139
--- This function returns the name and the value of the local variable with
140140
--- index `index` of the function at level `level` of the stack. (The first
@@ -203,6 +203,7 @@ function debug.getuservalue(u, n) end
203203
---@param limit integer
204204
---@return integer|boolean
205205
function debug.setcstacklimit(limit) end
206+
206207
---
207208
---Sets the environment of the given `object` to the given `table` .
208209
---
@@ -307,7 +308,6 @@ function debug.setuservalue(udata, value, n) end
307308
---@return string
308309
function debug.traceback(thread, message, level) end
309310

310-
311311
--- Returns a unique identifier (as a light userdata) for the upvalue numbered
312312
--- `n` from the given function.
313313
---
@@ -322,7 +322,6 @@ function debug.traceback(thread, message, level) end
322322
---@nodiscard
323323
function debug.upvalueid(f, n) end
324324

325-
326325
---
327326
--- Make the `n1`-th upvalue of the Lua closure f1 refer to the `n2`-th upvalue
328327
--- of the Lua closure f2.

crates/emmylua_code_analysis/resources/std/global.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ function load(chunk, chunkname, mode, env) end
164164
---
165165
---Loads a chunk from the given string.
166166
---
167-
---
168167
---@version 5.1, JIT
169168
---@param text Language<"Lua">
170169
---@param chunkname? string
@@ -237,6 +236,7 @@ function next(table, index) end
237236
---@param t table<K, V> | V[] | {[K]: V}
238237
---@return fun(tbl: any):K, V
239238
function pairs(t) end
239+
240240
---
241241
--- Calls function `f` with the given arguments in *protected mode*. This
242242
--- means that any error inside `f` is not propagated; instead, `pcall` catches
@@ -337,7 +337,6 @@ function require(modname) end
337337
---@return std.Select<T..., Num>
338338
function select(index, ...) end
339339

340-
341340
---@class std.metatable
342341
---@field __mode? 'v'|'k'|'kv'
343342
---@field __metatable? any
@@ -450,6 +449,7 @@ _VERSION = "Lua 5.4"
450449
function xpcall(f, msgh, ...) end
451450

452451
---@version 5.1, JIT
452+
---
453453
---@generic T, Start: integer, End: integer
454454
---@param i? std.ConstTpl<Start>
455455
---@param j? std.ConstTpl<End>
@@ -458,6 +458,7 @@ function xpcall(f, msgh, ...) end
458458
function unpack(list, i, j) end
459459

460460
---@version > 5.4
461+
---
461462
---@param message string
462463
function warn(message) end
463464

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

473474

474475
---@version 5.1, JIT
476+
---
475477
--- Sets the environment for the specified function.
476478
---@param f function|integer The function for which the environment is to be set.
477479
---@param env table The environment table to assign to the function.
478480
function setfenv(f, env) end
479481

480482
---@version 5.1, JIT
483+
---
481484
--- Retrieves the environment table of the specified function.
482485
---@param f function|integer The function whose environment is to be retrieved.
483486
---@return table The environment table associated with the given function.

crates/emmylua_code_analysis/resources/std/io.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function io.input(file) end
5656
function io.lines(filename, ...) end
5757

5858
---@alias iolib.OpenMode "r" | "w" | "a" | "r+" | "w+" | "a+" | "rb" | "wb" | "ab" | "rb+" | "wb+" | "ab+" | "r+b" | "w+b" | "a+b"
59+
5960
---
6061
--- This function opens a file, in the mode specified in the string `mode`. In
6162
--- case of success, it returns a new file handle. The `mode` string can be
@@ -139,7 +140,7 @@ function io.write(...) end
139140
---@class file
140141
local file = {}
141142

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

155-
--- @version 5.1, JIT
156+
---@version 5.1, JIT
156157
---
157158
--- Closes `file`. Note that files are automatically closed when their
158159
--- handles are garbage collected, but that takes an unpredictable amount of

crates/emmylua_code_analysis/resources/std/os.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function os.date(format, time) end
8181
---@return number
8282
function os.difftime(t2, t1) end
8383

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

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

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

129-
--- @version 5.1
129+
---@version 5.1
130130
---
131131
--- Calls the C function exit, with an optional `code`, to terminate the host
132132
--- program. The default value for `code` is the success code.

crates/emmylua_code_analysis/resources/std/package.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ package.preload = {}
101101
package.loaders = {}
102102

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

174+
---@version 5.1, JIT
173175
---
174176
---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` .
175177
---
176-
---@version 5.1, JIT
177178
---@param module table
178179
function package.seeall(module) end
179180

crates/emmylua_code_analysis/resources/std/string.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ function string.lower(s) end
226226
function string.match(s, pattern, init) end
227227

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

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

285287
---@version >5.3
288+
---
286289
--- Returns the values packed in string `s` according to the format string
287290
--- `fmt`. An optional `pos` marks where to start reading in `s` (default is 1).
288291
--- After the read values, this function also returns the index of the first

crates/emmylua_code_analysis/resources/std/table.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function table.remove(list, pos) end
104104
function table.sort(list, comp) end
105105

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

139-
140+
---@version 5.1, JIT
140141
---
141142
---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.
142143
---
143-
---@version 5.1, JIT
144144
---@generic T
145145
---@param list any
146146
---@param callback fun(key: string, value: any):T|nil
147147
---@return T?
148148
---@deprecated
149149
function table.foreachi(list, callback) end
150150

151-
151+
---@version 5.1, JIT
152152
---
153153
---Returns the number of elements in the table. This function is equivalent to `#list`.
154154
---
155155
---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.getn"])
156-
---@version 5.1, JIT
157156
---@generic T
158157
---@param list T[]
159158
---@return integer
160159
---@nodiscard
161160
---@deprecated
162161
function table.getn(list) end
163162

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

0 commit comments

Comments
 (0)