diff options
author | jefersonf <jeferson.silva> | 2021-10-30 13:19:12 -0300 |
---|---|---|
committer | jefersonf <jeferson.silva> | 2021-10-30 13:19:12 -0300 |
commit | f0c5bbeb62794116b6517be51efa6054254076eb (patch) | |
tree | fee585182a7ec10e987e758a53edcbd7db9dca9b | |
parent | f41a33de696dc5ff802d2f5e540da1c87861dac9 (diff) | |
parent | 107b57cc7728824a0e9515727f9a6123c5f7c902 (diff) | |
download | lua-language-server-f0c5bbeb62794116b6517be51efa6054254076eb.zip |
Merge branch 'master' of https://github.com/sumneko/lua-language-server into pt-br-locale-support
47 files changed, 1013 insertions, 371 deletions
diff --git a/.github/workflows/checkPR.yml b/.github/workflows/checkPR.yml new file mode 100644 index 00000000..c83bf3ab --- /dev/null +++ b/.github/workflows/checkPR.yml @@ -0,0 +1,16 @@ +name: checkPR +on: pull_request +jobs: + compile: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-18.04, macos-latest] + steps: + - uses: actions/checkout@v1 + with: + ref: ${{ github.event.pull_request.head.sha }} + submodules : recursive + - uses: actboy168/setup-luamake@master + - run: luamake diff --git a/.vscode/launch.json b/.vscode/launch.json index b39fa4b5..bb14e759 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -40,6 +40,7 @@ "type": "lua", "request": "launch", "stopOnEntry": false, + "luaexe": "${workspaceFolder}/bin/Windows/lua-language-server.exe", "program": "${workspaceRoot}/tools/love-api.lua", "cpath": "${workspaceFolder}/bin/Windows/?.dll", "arg": [ @@ -102,7 +102,7 @@ Please [help me][en-US] improve the quality of `en-US`. ## Setting * In VSCode: Just use the setting of VSCode. -* Standalone: See https://github.com/sumneko/lua-language-server/wiki/Setting-without-VSCode +* Standalone: See https://github.com/sumneko/lua-language-server/wiki/Setting ## Credit diff --git a/changelog.md b/changelog.md index 3d9fcf9f..6ee49a79 100644 --- a/changelog.md +++ b/changelog.md @@ -1,10 +1,25 @@ # changelog +## 2.5.0 +* `NEW` setting `Lua.runtime.pathStrict` +* `NEW` skip huge files (>= 100 MB) +* `CHG` no longer asks to trust plugin in VSCode, because VSCode already provides the workspace trust feature + +## 2.4.7 +`2021-10-27` +* `FIX` [#762](https://github.com/sumneko/lua-language-server/issues/762) + ## 2.4.6 +`2021-10-26` +* `NEW` diagnostic: `redundant-return` * `FIX` [#744](https://github.com/sumneko/lua-language-server/issues/744) * `FIX` [#748](https://github.com/sumneko/lua-language-server/issues/748) * `FIX` [#749](https://github.com/sumneko/lua-language-server/issues/749) * `FIX` [#752](https://github.com/sumneko/lua-language-server/issues/752) +* `FIX` [#753](https://github.com/sumneko/lua-language-server/issues/753) +* `FIX` [#756](https://github.com/sumneko/lua-language-server/issues/756) +* `FIX` [#758](https://github.com/sumneko/lua-language-server/issues/758) +* `FIX` [#760](https://github.com/sumneko/lua-language-server/issues/760) ## 2.4.5 `2021-10-18` diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua index fd423ced..fde50ae9 100644 --- a/locale/en-us/script.lua +++ b/locale/en-us/script.lua @@ -42,6 +42,7 @@ DIAG_COUNT_DOWN_LOOP = 'Do you mean `{}` ?' DIAG_IMPLICIT_ANY = 'Can not infer type.' DIAG_DEPRECATED = 'Deprecated.' DIAG_DIFFERENT_REQUIRES = 'The same file is required with different names.' +DIAG_REDUNDANT_RETURN = 'Redundant return.' DIAG_CIRCLE_DOC_CLASS = 'Circularly inherited classes.' DIAG_DOC_FIELD_NO_CLASS = 'The field must be defined after the class.' @@ -65,6 +66,7 @@ MWS_WCONFIG_UPDATED = 'Workspace setting updated.' WORKSPACE_SKIP_LARGE_FILE = 'Too large file: {} skipped. The currently set size limit is: {} KB, and the file size is: {} KB.' WORKSPACE_LOADING = 'Loading workspace' WORKSPACE_DIAGNOSTIC = 'Diagnosing workspace' +WORKSPACE_SKIP_HUGE_FILE = 'For performance reasons, the parsing of this file has been stopped: {}' PARSER_CRASH = 'Parser crashed! Last words:{}' PARSER_UNKNOWN = 'Unknown syntax error...' diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua index cad50612..120ce765 100644 --- a/locale/zh-cn/script.lua +++ b/locale/zh-cn/script.lua @@ -42,6 +42,7 @@ DIAG_COUNT_DOWN_LOOP = '你的意思是 `{}` 吗?' DIAG_IMPLICIT_ANY = '无法推测出类型。' DIAG_DEPRECATED = '已废弃。' DIAG_DIFFERENT_REQUIRES = '使用了不同的名字 require 了同一个文件。' +DIAG_REDUNDANT_RETURN = '冗余返回。' DIAG_CIRCLE_DOC_CLASS = '循环继承的类。' DIAG_DOC_FIELD_NO_CLASS = '字段必须定义在类之后。' @@ -65,6 +66,7 @@ MWS_WCONFIG_UPDATED = '工作区配置已更新。' WORKSPACE_SKIP_LARGE_FILE = '已跳过过大的文件:{}。当前设置的大小限制为:{} KB,该文件大小为:{} KB' WORKSPACE_LOADING = '正在加载工作目录' WORKSPACE_DIAGNOSTIC = '正在对工作目录进行诊断' +WORKSPACE_SKIP_HUGE_FILE = '出于性能考虑,已停止对此文件解析:{}' PARSER_CRASH = '语法解析崩溃了!遗言:{}' PARSER_UNKNOWN = '未知语法错误...' diff --git a/make/bootstrap.lua b/make/bootstrap.lua index f01646a0..e9e61c77 100644 --- a/make/bootstrap.lua +++ b/make/bootstrap.lua @@ -52,6 +52,7 @@ local root; do root = package.cpath:match("([^;]+)"..pattern..pattern..pattern.."$")
arg[0] = root .. package.config:sub(1,1) .. 'main.lua'
end
+ root = root:gsub('[/\\]', package.config:sub(1,1))
end
package.path = table.concat({
diff --git a/meta/3rd/love2d/library/love.audio.lua b/meta/3rd/love2d/library/love.audio.lua index a0a8b3bd..acd59384 100644 --- a/meta/3rd/love2d/library/love.audio.lua +++ b/meta/3rd/love2d/library/love.audio.lua @@ -63,6 +63,9 @@ function love.audio.getOrientation() end --- ---Returns the position of the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources. --- +---@return number x # The X position of the listener. +---@return number y # The Y position of the listener. +---@return number z # The Z position of the listener. function love.audio.getPosition() end --- @@ -84,6 +87,9 @@ function love.audio.getSourceCount() end --- ---Returns the velocity of the listener. --- +---@return number x # The X velocity of the listener. +---@return number y # The Y velocity of the listener. +---@return number z # The Z velocity of the listener. function love.audio.getVelocity() end --- @@ -104,7 +110,7 @@ function love.audio.isEffectsSupported() end ---@param samplerate number # Number of samples per second when playing. ---@param bitdepth number # Bits per sample (8 or 16). ---@param channels number # 1 for mono or 2 for stereo. ----@param buffercount number # The number of buffers that can be queued up at any given time with Source:queue. Cannot be greater than 64. A sensible default (~8) is chosen if no value is specified. +---@param buffercount? number # The number of buffers that can be queued up at any given time with Source:queue. Cannot be greater than 64. A sensible default (~8) is chosen if no value is specified. ---@return love.Source source # The new Source usable with Source:queue. function love.audio.newQueueableSource(samplerate, bitdepth, channels, buffercount) end @@ -182,12 +188,18 @@ function love.audio.setOrientation(fx, fy, fz, ux, uy, uz) end --- ---Sets the position of the listener, which determines how sounds play. --- -function love.audio.setPosition() end +---@param x number # The x position of the listener. +---@param y number # The y position of the listener. +---@param z number # The z position of the listener. +function love.audio.setPosition(x, y, z) end --- ---Sets the velocity of the listener. --- -function love.audio.setVelocity() end +---@param x number # The X velocity of the listener. +---@param y number # The Y velocity of the listener. +---@param z number # The Z velocity of the listener. +function love.audio.setVelocity(x, y, z) end --- ---Sets the master volume. @@ -257,9 +269,9 @@ function RecordingDevice:isRecording() end ---Begins recording audio using this device. --- ---@param samplecount number # The maximum number of samples to store in an internal ring buffer when recording. RecordingDevice:getData clears the internal buffer when called. ----@param samplerate number # The number of samples per second to store when recording. ----@param bitdepth number # The number of bits per sample. ----@param channels number # Whether to record in mono or stereo. Most microphones don't support more than 1 channel. +---@param samplerate? number # The number of samples per second to store when recording. +---@param bitdepth? number # The number of bits per sample. +---@param channels? number # Whether to record in mono or stereo. Most microphones don't support more than 1 channel. ---@return boolean success # True if the device successfully began recording using the specified parameters, false if not. function RecordingDevice:start(samplecount, samplerate, bitdepth, channels) end @@ -325,12 +337,15 @@ function Source:getCone() end --- ---Gets the direction of the Source. --- +---@return number x # The X part of the direction vector. +---@return number y # The Y part of the direction vector. +---@return number z # The Z part of the direction vector. function Source:getDirection() end --- ---Gets the duration of the Source. For streaming Sources it may not always be sample-accurate, and may return -1 if the duration cannot be determined at all. --- ----@param unit love.TimeUnit # The time unit for the return value. +---@param unit? love.TimeUnit # The time unit for the return value. ---@return number duration # The duration of the Source, or -1 if it cannot be determined. function Source:getDuration(unit) end @@ -340,7 +355,7 @@ function Source:getDuration(unit) end ---This function returns nil if the effect was applied with no filter settings associated to it. --- ---@param name string # The name of the effect. ----@param filtersettings table # An optional empty table that will be filled with the filter settings. +---@param filtersettings? table # An optional empty table that will be filled with the filter settings. ---@return {volume: number, highgain: number, lowgain: number} filtersettings # The settings for the filter associated to this effect, or nil if the effect is not present in this Source or has no filter associated. The table has the following fields: function Source:getEffect(name, filtersettings) end @@ -365,6 +380,9 @@ function Source:getPitch() end --- ---Gets the position of the Source. --- +---@return number x # The X position of the Source. +---@return number y # The Y position of the Source. +---@return number z # The Z position of the Source. function Source:getPosition() end --- @@ -382,6 +400,9 @@ function Source:getType() end --- ---Gets the velocity of the Source. --- +---@return number x # The X part of the velocity vector. +---@return number y # The Y part of the velocity vector. +---@return number z # The Z part of the velocity vector. function Source:getVelocity() end --- @@ -439,7 +460,7 @@ function Source:queue(sounddata) end ---Sets the currently playing position of the Source. --- ---@param offset number # The position to seek to. ----@param unit love.TimeUnit # The unit of the position value. +---@param unit? love.TimeUnit # The unit of the position value. function Source:seek(offset, unit) end --- @@ -466,13 +487,16 @@ function Source:setAttenuationDistances(ref, max) end --- ---@param innerAngle number # The inner angle from the Source's direction, in radians. The Source will play at normal volume if the listener is inside the cone defined by this angle. ---@param outerAngle number # The outer angle from the Source's direction, in radians. The Source will play at a volume between the normal and outer volumes, if the listener is in between the cones defined by the inner and outer angles. ----@param outerVolume number # The Source's volume when the listener is outside both the inner and outer cone angles. +---@param outerVolume? number # The Source's volume when the listener is outside both the inner and outer cone angles. function Source:setCone(innerAngle, outerAngle, outerVolume) end --- ---Sets the direction vector of the Source. A zero vector makes the source non-directional. --- -function Source:setDirection() end +---@param x number # The X part of the direction vector. +---@param y number # The Y part of the direction vector. +---@param z number # The Z part of the direction vector. +function Source:setDirection(x, y, z) end --- ---Applies an audio effect to the Source. @@ -481,7 +505,7 @@ function Source:setDirection() end --- ---@overload fun(name: string, filtersettings: table):boolean ---@param name string # The name of the effect previously set up with love.audio.setEffect. ----@param enable boolean # If false and the given effect name was previously enabled on this Source, disables the effect. +---@param enable? boolean # If false and the given effect name was previously enabled on this Source, disables the effect. ---@return boolean success # Whether the effect was successfully applied to this Source. function Source:setEffect(name, enable) end @@ -508,14 +532,17 @@ function Source:setPitch(pitch) end --- ---Sets the position of the Source. Please note that this only works for mono (i.e. non-stereo) sound files! --- -function Source:setPosition() end +---@param x number # The X position of the Source. +---@param y number # The Y position of the Source. +---@param z number # The Z position of the Source. +function Source:setPosition(x, y, z) end --- ---Sets whether the Source's position, velocity, direction, and cone angles are relative to the listener, or absolute. --- ---By default, all sources are absolute and therefore relative to the origin of love's coordinate system 0, 0. Only absolute sources are affected by the position of the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources. --- ----@param enable boolean # True to make the position, velocity, direction and cone angles relative to the listener, false to make them absolute. +---@param enable? boolean # True to make the position, velocity, direction and cone angles relative to the listener, false to make them absolute. function Source:setRelative(enable) end --- @@ -531,7 +558,10 @@ function Source:setRolloff(rolloff) end --- ---This does '''not''' change the position of the Source, but lets the application know how it has to calculate the doppler effect. --- -function Source:setVelocity() end +---@param x number # The X part of the velocity vector. +---@param y number # The Y part of the velocity vector. +---@param z number # The Z part of the velocity vector. +function Source:setVelocity(x, y, z) end --- ---Sets the current volume of the Source. @@ -554,7 +584,7 @@ function Source:stop() end --- ---Gets the currently playing position of the Source. --- ----@param unit love.TimeUnit # The type of unit for the return value. +---@param unit? love.TimeUnit # The type of unit for the return value. ---@return number position # The currently playing position of the Source. function Source:tell(unit) end diff --git a/meta/3rd/love2d/library/love.data.lua b/meta/3rd/love2d/library/love.data.lua index c2139c8d..53a51d4b 100644 --- a/meta/3rd/love2d/library/love.data.lua +++ b/meta/3rd/love2d/library/love.data.lua @@ -13,7 +13,7 @@ love.data = {} ---@param container love.ContainerType # What type to return the compressed data as. ---@param format love.CompressedDataFormat # The format to use when compressing the string. ---@param rawstring string # The raw (un-compressed) string to compress. ----@param level number # The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. +---@param level? number # The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. ---@return love.CompressedData|string compressedData # CompressedData/string which contains the compressed version of rawstring. function love.data.compress(container, format, rawstring, level) end @@ -44,7 +44,7 @@ function love.data.decompress(container, compressedData) end ---@param container love.ContainerType # What type to return the encoded data as. ---@param format love.EncodeFormat # The format of the output data. ---@param sourceString string # The raw data to encode. ----@param linelength number # The maximum line length of the output. Only supported for base64, ignored if 0. +---@param linelength? number # The maximum line length of the output. Only supported for base64, ignored if 0. ---@return love.ByteData|string encoded # ByteData/string which contains the encoded version of source. function love.data.encode(container, format, sourceString, linelength) end @@ -105,7 +105,7 @@ function love.data.pack(container, format, v1) end ---@overload fun(format: string, data: love.Data, pos: number):number|boolean|string, number|boolean|string, number ---@param format string # A string determining how the values were packed. Follows the rules of Lua 5.3's string.pack format strings. ---@param datastring string # A string containing the packed (serialized) data. ----@param pos number # Where to start reading in the string. Negative values can be used to read relative from the end of the string. +---@param pos? number # Where to start reading in the string. Negative values can be used to read relative from the end of the string. ---@return number|boolean|string v1 # The first value (number, boolean, or string) that was unpacked. ---@return number index # The index of the first unread byte in the data string. function love.data.unpack(format, datastring, pos) end diff --git a/meta/3rd/love2d/library/love.event.lua b/meta/3rd/love2d/library/love.event.lua index 759b5b36..3e8d7ff4 100644 --- a/meta/3rd/love2d/library/love.event.lua +++ b/meta/3rd/love2d/library/love.event.lua @@ -14,6 +14,7 @@ function love.event.clear() end --- ---Returns an iterator for messages in the event queue. --- +---@return function i # Iterator function usable in a for loop. function love.event.poll() end --- @@ -32,7 +33,14 @@ function love.event.pump() end --- ---From 0.10.0 onwards, you may pass an arbitrary amount of arguments with this function, though the default callbacks don't ever use more than six. --- -function love.event.push() end +---@param n love.Event # The name of the event. +---@param a? any # First event argument. +---@param b? any # Second event argument. +---@param c? any # Third event argument. +---@param d? any # Fourth event argument. +---@param e? any # Fifth event argument. +---@param f? any # Sixth event argument. +function love.event.push(n, a, b, c, d, e, f) end --- ---Adds the quit event to the queue. @@ -40,12 +48,19 @@ function love.event.push() end ---The quit event is a signal for the event handler to close LÖVE. It's possible to abort the exit process with the love.quit callback. --- ---@overload fun(restart: string|"'restart'") ----@param exitstatus number # The program exit status to use when closing the application. +---@param exitstatus? number # The program exit status to use when closing the application. function love.event.quit(exitstatus) end --- ---Like love.event.poll(), but blocks until there is an event in the queue. --- +---@return love.Event n # The name of event. +---@return any a # First event argument. +---@return any b # Second event argument. +---@return any c # Third event argument. +---@return any d # Fourth event argument. +---@return any e # Fifth event argument. +---@return any f # Sixth event argument. function love.event.wait() end --- diff --git a/meta/3rd/love2d/library/love.filesystem.lua b/meta/3rd/love2d/library/love.filesystem.lua index 1d00c798..9f2d9ce8 100644 --- a/meta/3rd/love2d/library/love.filesystem.lua +++ b/meta/3rd/love2d/library/love.filesystem.lua @@ -12,7 +12,7 @@ love.filesystem = {} ---@overload fun(name: string, data: love.Data, size: number):boolean, string ---@param name string # The name (and path) of the file. ---@param data string # The string data to append to the file. ----@param size number # How many bytes to write. +---@param size? number # How many bytes to write. ---@return boolean success # True if the operation was successful, or nil if there was an error. ---@return string errormsg # The error message on failure. function love.filesystem.append(name, data, size) end @@ -72,7 +72,7 @@ function love.filesystem.getIdentity() end ---@overload fun(path: string, info: table):table ---@overload fun(path: string, filtertype: love.FileType, info: table):table ---@param path string # The file or directory path to check. ----@param filtertype love.FileType # If supplied, this parameter causes getInfo to only return the info table if the item at the given path matches the specified file type. +---@param filtertype? love.FileType # If supplied, this parameter causes getInfo to only return the info table if the item at the given path matches the specified file type. ---@return {type: love.FileType, size: number, modtime: number} info # A table containing information about the specified path, or nil if nothing exists at the path. The table contains the following fields: function love.filesystem.getInfo(path, filtertype) end @@ -171,7 +171,7 @@ function love.filesystem.load(name) end ---@overload fun(data: love.Data, archivename: string, mountpoint: string, appendToPath: boolean):boolean ---@param archive string # The folder or zip file in the game's save directory to mount. ---@param mountpoint string # The new path the archive will be mounted to. ----@param appendToPath boolean # Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories. +---@param appendToPath? boolean # Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories. ---@return boolean success # True if the archive was successfully mounted, false otherwise. function love.filesystem.mount(archive, mountpoint, appendToPath) end @@ -199,7 +199,7 @@ function love.filesystem.newFileData(contents, name) end --- ---@overload fun(container: love.ContainerType, name: string, size: number):love.FileData|string, number, nil, string ---@param name string # The name (and path) of the file. ----@param size number # How many bytes to read. +---@param size? number # How many bytes to read. ---@return string contents # The file contents. ---@return number size # How many bytes have been read. ---@return nil contents # returns nil as content. @@ -267,7 +267,7 @@ function love.filesystem.unmount(archive) end ---@overload fun(name: string, data: love.Data, size: number):boolean, string ---@param name string # The name (and path) of the file. ---@param data string # The string data to write to the file. ----@param size number # How many bytes to write. +---@param size? number # How many bytes to write. ---@return boolean success # If the operation was successful. ---@return string message # Error message if operation was unsuccessful. function love.filesystem.write(name, data, size) end @@ -354,7 +354,7 @@ function File:open(mode) end ---Read a number of bytes from a file. --- ---@overload fun(container: love.ContainerType, bytes: number):love.FileData|string, number ----@param bytes number # The number of bytes to read. +---@param bytes? number # The number of bytes to read. ---@return string contents # The contents of the read bytes. ---@return number size # How many bytes have been read. function File:read(bytes) end @@ -372,7 +372,7 @@ function File:seek(pos) end ---File:flush will force any buffered data to be written to the disk. --- ---@param mode love.BufferMode # The buffer mode to use. ----@param size number # The maximum size in bytes of the file's buffer. +---@param size? number # The maximum size in bytes of the file's buffer. ---@return boolean success # Whether the buffer mode was successfully set. ---@return string errorstr # The error string, if the buffer mode could not be set and an error occurred. function File:setBuffer(mode, size) end @@ -388,7 +388,7 @@ function File:tell() end --- ---@overload fun(data: love.Data, size: number):boolean, string ---@param data string # The string data to write. ----@param size number # How many bytes to write. +---@param size? number # How many bytes to write. ---@return boolean success # Whether the operation was successful. ---@return string err # The error string if an error occurred. function File:write(data, size) end diff --git a/meta/3rd/love2d/library/love.font.lua b/meta/3rd/love2d/library/love.font.lua index 1efbf057..27f49d0e 100644 --- a/meta/3rd/love2d/library/love.font.lua +++ b/meta/3rd/love2d/library/love.font.lua @@ -12,7 +12,7 @@ love.font = {} ---@overload fun(fileName: string, glyphs: string, dpiscale: number):love.Rasterizer ---@param imageData love.ImageData # The image data containing the drawable pictures of font glyphs. ---@param glyphs string # The sequence of glyphs in the ImageData. ----@param dpiscale number # DPI scale. +---@param dpiscale? number # DPI scale. ---@return love.Rasterizer rasterizer # The rasterizer. function love.font.newBMFontRasterizer(imageData, glyphs, dpiscale) end @@ -28,8 +28,8 @@ function love.font.newGlyphData(rasterizer, glyph) end --- ---@param imageData love.ImageData # Font image data. ---@param glyphs string # String containing font glyphs. ----@param extraSpacing number # Font extra spacing. ----@param dpiscale number # Font DPI scale. +---@param extraSpacing? number # Font extra spacing. +---@param dpiscale? number # Font DPI scale. ---@return love.Rasterizer rasterizer # The rasterizer. function love.font.newImageRasterizer(imageData, glyphs, extraSpacing, dpiscale) end @@ -51,9 +51,9 @@ function love.font.newRasterizer(filename) end --- ---@overload fun(fileName: string, size: number, hinting: love.HintingMode, dpiscale: number):love.Rasterizer ---@overload fun(fileData: love.FileData, size: number, hinting: love.HintingMode, dpiscale: number):love.Rasterizer ----@param size number # The font size. ----@param hinting love.HintingMode # True Type hinting mode. ----@param dpiscale number # The font DPI scale. +---@param size? number # The font size. +---@param hinting? love.HintingMode # True Type hinting mode. +---@param dpiscale? number # The font DPI scale. ---@return love.Rasterizer rasterizer # The rasterizer. function love.font.newTrueTypeRasterizer(size, hinting, dpiscale) end @@ -79,6 +79,8 @@ function GlyphData:getBearing() end --- ---Gets glyph bounding box. --- +---@return number x # Glyph position x. +---@return number y # Glyph position y. ---@return number width # Glyph width. ---@return number height # Glyph height. function GlyphData:getBoundingBox() end diff --git a/meta/3rd/love2d/library/love.graphics.lua b/meta/3rd/love2d/library/love.graphics.lua index f70efefd..c6b5ead8 100644 --- a/meta/3rd/love2d/library/love.graphics.lua +++ b/meta/3rd/love2d/library/love.graphics.lua @@ -25,11 +25,13 @@ function love.graphics.applyTransform(transform) end --- ---@overload fun(drawmode: love.DrawMode, arctype: love.ArcType, x: number, y: number, radius: number, angle1: number, angle2: number, segments: number) ---@param drawmode love.DrawMode # How to draw the arc. +---@param x number # The position of the center along x-axis. +---@param y number # The position of the center along y-axis. ---@param radius number # Radius of the arc. ---@param angle1 number # The angle at which the arc begins. ---@param angle2 number # The angle at which the arc terminates. ----@param segments number # The number of segments used for drawing the arc. -function love.graphics.arc(drawmode, radius, angle1, angle2, segments) end +---@param segments? number # The number of segments used for drawing the arc. +function love.graphics.arc(drawmode, x, y, radius, angle1, angle2, segments) end --- ---Creates a screenshot once the current frame is done (after love.draw has finished). @@ -46,8 +48,10 @@ function love.graphics.captureScreenshot(filename) end --- ---@overload fun(mode: love.DrawMode, x: number, y: number, radius: number, segments: number) ---@param mode love.DrawMode # How to draw the circle. +---@param x number # The position of the center along x-axis. +---@param y number # The position of the center along y-axis. ---@param radius number # The radius of the circle. -function love.graphics.circle(mode, radius) end +function love.graphics.circle(mode, x, y, radius) end --- ---Clears the screen or active Canvas to the specified color. @@ -73,8 +77,8 @@ function love.graphics.clear() end ---On some desktop systems this function may do nothing. --- ---@overload fun(discardcolors: table, discardstencil: boolean) ----@param discardcolor boolean # Whether to discard the texture(s) of the active Canvas(es) (the contents of the screen if no Canvas is active.) ----@param discardstencil boolean # Whether to discard the contents of the stencil buffer of the screen / active Canvas. +---@param discardcolor? boolean # Whether to discard the texture(s) of the active Canvas(es) (the contents of the screen if no Canvas is active.) +---@param discardstencil? boolean # Whether to discard the contents of the stencil buffer of the screen / active Canvas. function love.graphics.discard(discardcolor, discardstencil) end --- @@ -94,13 +98,16 @@ function love.graphics.discard(discardcolor, discardstencil) end ---@overload fun(drawable: love.Drawable, transform: love.Transform) ---@overload fun(texture: love.Texture, quad: love.Quad, transform: love.Transform) ---@param drawable love.Drawable # A drawable object. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). -function love.graphics.draw(drawable, sx, sy, ox, oy, kx, ky) end +---@param x? number # The position to draw the object (x-axis). +---@param y? number # The position to draw the object (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). +function love.graphics.draw(drawable, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Draws many instances of a Mesh with a single draw call, using hardware geometry instancing. @@ -112,13 +119,16 @@ function love.graphics.draw(drawable, sx, sy, ox, oy, kx, ky) end ---@overload fun(mesh: love.Mesh, instancecount: number, transform: love.Transform) ---@param mesh love.Mesh # The mesh to render. ---@param instancecount number # The number of instances to render. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). -function love.graphics.drawInstanced(mesh, instancecount, sx, sy, ox, oy, kx, ky) end +---@param x? number # The position to draw the instances (x-axis). +---@param y? number # The position to draw the instances (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). +function love.graphics.drawInstanced(mesh, instancecount, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Draws a layer of an Array Texture. @@ -128,22 +138,27 @@ function love.graphics.drawInstanced(mesh, instancecount, sx, sy, ox, oy, kx, ky ---@overload fun(texture: love.Texture, layerindex: number, quad: love.Quad, transform: love.Transform) ---@param texture love.Texture # The Array Texture to draw. ---@param layerindex number # The index of the layer to use when drawing. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). -function love.graphics.drawLayer(texture, layerindex, sx, sy, ox, oy, kx, ky) end +---@param x? number # The position to draw the texture (x-axis). +---@param y? number # The position to draw the texture (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). +function love.graphics.drawLayer(texture, layerindex, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Draws an ellipse. --- ---@overload fun(mode: love.DrawMode, x: number, y: number, radiusx: number, radiusy: number, segments: number) ---@param mode love.DrawMode # How to draw the ellipse. +---@param x number # The position of the center along x-axis. +---@param y number # The position of the center along y-axis. ---@param radiusx number # The radius of the ellipse along the x-axis (half the ellipse's width). ---@param radiusy number # The radius of the ellipse along the y-axis (half the ellipse's height). -function love.graphics.ellipse(mode, radiusx, radiusy) end +function love.graphics.ellipse(mode, x, y, radiusx, radiusy) end --- ---Immediately renders any pending automatically batched draws. @@ -161,6 +176,10 @@ function love.graphics.flushBatch() end --- ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- +---@return number r # The red component (0-1). +---@return number g # The green component (0-1). +---@return number b # The blue component (0-1). +---@return number a # The alpha component (0-1). function love.graphics.getBackgroundColor() end --- @@ -188,6 +207,10 @@ function love.graphics.getCanvasFormats() end --- ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- +---@return number r # The red component (0-1). +---@return number g # The green component (0-1). +---@return number b # The blue component (0-1). +---@return number a # The alpha component (0-1). function love.graphics.getColor() end --- @@ -195,6 +218,10 @@ function love.graphics.getColor() end --- ---The color mask determines whether individual components of the colors of drawn objects will affect the color of the screen. They affect love.graphics.clear and Canvas:clear as well. --- +---@return boolean r # Whether the red color component is active when rendering. +---@return boolean g # Whether the green color component is active when rendering. +---@return boolean b # Whether the blue color component is active when rendering. +---@return boolean a # Whether the alpha color component is active when rendering. function love.graphics.getColorMask() end --- @@ -328,6 +355,8 @@ function love.graphics.getRendererInfo() end --- ---Gets the current scissor box. --- +---@return number x # The x-component of the top-left point of the box. +---@return number y # The y-component of the top-left point of the box. ---@return number width # The width of the box. ---@return number height # The height of the box. function love.graphics.getScissor() end @@ -395,9 +424,11 @@ function love.graphics.getWidth() end --- ---The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...). --- +---@param x number # The x-coordinate of the upper left corner of the rectangle to intersect with the existing scissor rectangle. +---@param y number # The y-coordinate of the upper left corner of the rectangle to intersect with the existing scissor rectangle. ---@param width number # The width of the rectangle to intersect with the existing scissor rectangle. ---@param height number # The height of the rectangle to intersect with the existing scissor rectangle. -function love.graphics.intersectScissor(width, height) end +function love.graphics.intersectScissor(x, y, width, height) end --- ---Converts the given 2D position from screen-space into global coordinates. @@ -451,7 +482,7 @@ function love.graphics.line(x1, y1, x2, y2) end ---To use an array image in a Shader, it must be declared as a ArrayImage or sampler2DArray type (instead of Image or sampler2D). The Texel(ArrayImage image, vec3 texturecoord) shader function must be used to get pixel colors from a slice of the array image. The vec3 argument contains the texture coordinate in the first two components, and the 0-based slice index in the third component. --- ---@param slices table # A table containing filepaths to images (or File, FileData, ImageData, or CompressedImageData objects), in an array. Each sub-image must have the same dimensions. A table of tables can also be given, where each sub-table contains all mipmap levels for the slice index of that sub-table. ----@param settings {mipmaps: boolean, linear: boolean, dpiscale: number} # Optional table of settings to configure the array image, containing the following fields: +---@param settings? {mipmaps: boolean, linear: boolean, dpiscale: number} # Optional table of settings to configure the array image, containing the following fields: ---@return love.Image image # An Array Image object. function love.graphics.newArrayImage(slices, settings) end @@ -511,7 +542,7 @@ function love.graphics.newCanvas() end --- ---@overload fun(faces: table, settings: table):love.Image ---@param filename string # The filepath to a cubemap image file (or a File, FileData, or ImageData). ----@param settings {mipmaps: boolean, linear: boolean} # Optional table of settings to configure the cubemap image, containing the following fields: +---@param settings? {mipmaps: boolean, linear: boolean} # Optional table of settings to configure the cubemap image, containing the following fields: ---@return love.Image image # An cubemap Image object. function love.graphics.newCubeImage(filename, settings) end @@ -562,8 +593,8 @@ function love.graphics.newImageFont(filename, glyphs) end ---@overload fun(vertexformat: table, vertexcount: number, mode: love.MeshDrawMode, usage: love.SpriteBatchUsage):love.Mesh ---@overload fun(vertexcount: number, texture: love.Texture, mode: love.MeshDrawMode):love.Mesh ---@param vertices {["1"]: number, ["2"]: number, ["3"]: number, ["4"]: number, ["5"]: number, ["6"]: number, ["7"]: number, ["8"]: number} # The table filled with vertex information tables for each vertex as follows: ----@param mode love.MeshDrawMode # How the vertices are used when drawing. The default mode 'fan' is sufficient for simple convex polygons. ----@param usage love.SpriteBatchUsage # The expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. +---@param mode? love.MeshDrawMode # How the vertices are used when drawing. The default mode 'fan' is sufficient for simple convex polygons. +---@param usage? love.SpriteBatchUsage # The expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. ---@return love.Mesh mesh # The new mesh. function love.graphics.newMesh(vertices, mode, usage) end @@ -572,7 +603,7 @@ function love.graphics.newMesh(vertices, mode, usage) end --- ---@overload fun(texture: love.Texture, buffer: number):love.ParticleSystem ---@param image love.Image # The image to use. ----@param buffer number # The max number of particles at the same time. +---@param buffer? number # The max number of particles at the same time. ---@return love.ParticleSystem system # A new ParticleSystem. function love.graphics.newParticleSystem(image, buffer) end @@ -581,12 +612,14 @@ function love.graphics.newParticleSystem(image, buffer) end --- ---The purpose of a Quad is to use a fraction of an image to draw objects, as opposed to drawing entire image. It is most useful for sprite sheets and atlases: in a sprite atlas, multiple sprites reside in same image, quad is used to draw a specific sprite from that image; in animated sprites with all frames residing in the same image, quad is used to draw specific frame from the animation. --- +---@param x number # The top-left position in the Image along the x-axis. +---@param y number # The top-left position in the Image along the y-axis. ---@param width number # The width of the Quad in the Image. (Must be greater than 0.) ---@param height number # The height of the Quad in the Image. (Must be greater than 0.) ---@param sw number # The reference width, the width of the Image. (Must be greater than 0.) ---@param sh number # The reference height, the height of the Image. (Must be greater than 0.) ---@return love.Quad quad # The new Quad. -function love.graphics.newQuad(width, height, sw, sh) end +function love.graphics.newQuad(x, y, width, height, sw, sh) end --- ---Creates a new Shader object for hardware-accelerated vertex and pixel effects. A Shader contains either vertex shader code, pixel shader code, or both. @@ -604,7 +637,7 @@ function love.graphics.newShader(code) end ---@overload fun(image: love.Image, maxsprites: number, usage: love.SpriteBatchUsage):love.SpriteBatch ---@overload fun(texture: love.Texture, maxsprites: number, usage: love.SpriteBatchUsage):love.SpriteBatch ---@param image love.Image # The Image to use for the sprites. ----@param maxsprites number # The maximum number of sprites that the SpriteBatch can contain at any given time. Since version 11.0, additional sprites added past this number will automatically grow the spritebatch. +---@param maxsprites? number # The maximum number of sprites that the SpriteBatch can contain at any given time. Since version 11.0, additional sprites added past this number will automatically grow the spritebatch. ---@return love.SpriteBatch spriteBatch # The new SpriteBatch. function love.graphics.newSpriteBatch(image, maxsprites) end @@ -612,7 +645,7 @@ function love.graphics.newSpriteBatch(image, maxsprites) end ---Creates a new drawable Text object. --- ---@param font love.Font # The font to use for the text. ----@param textstring string # The initial string of text that the new Text object will contain. May be nil. +---@param textstring? string # The initial string of text that the new Text object will contain. May be nil. ---@return love.Text text # The new drawable Text object. function love.graphics.newText(font, textstring) end @@ -639,7 +672,7 @@ function love.graphics.newVideo(filename) end ---Array images are a much better choice than volume images for storing multiple different sprites in a single array image for directly drawing them. --- ---@param layers table # A table containing filepaths to images (or File, FileData, ImageData, or CompressedImageData objects), in an array. A table of tables can also be given, where each sub-table represents a single mipmap level and contains all layers for that mipmap. ----@param settings {mipmaps: boolean, linear: boolean} # Optional table of settings to configure the volume image, containing the following fields: +---@param settings? {mipmaps: boolean, linear: boolean} # Optional table of settings to configure the volume image, containing the following fields: ---@return love.Image image # A volume Image object. function love.graphics.newVolumeImage(layers, settings) end @@ -655,7 +688,9 @@ function love.graphics.origin() end --- ---@overload fun(points: table) ---@overload fun(points: table) -function love.graphics.points() end +---@param x number # The position of the first point on the x-axis. +---@param y number # The position of the first point on the y-axis. +function love.graphics.points(x, y) end --- ---Draw a polygon. @@ -695,13 +730,16 @@ function love.graphics.present() end ---@overload fun(text: string, font: love.Font, transform: love.Transform) ---@overload fun(coloredtext: table, font: love.Font, transform: love.Transform) ---@param text string # The text to draw. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). -function love.graphics.print(text, sx, sy, ox, oy, kx, ky) end +---@param x? number # The position to draw the object (x-axis). +---@param y? number # The position to draw the object (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). +function love.graphics.print(text, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Draws formatted text, with word wrap and alignment. @@ -722,15 +760,18 @@ function love.graphics.print(text, sx, sy, ox, oy, kx, ky) end ---@overload fun(coloredtext: table, transform: love.Transform, limit: number, align: love.AlignMode) ---@overload fun(coloredtext: table, font: love.Font, transform: love.Transform, limit: number, align: love.AlignMode) ---@param text string # A text string. +---@param x number # The position on the x-axis. +---@param y number # The position on the y-axis. ---@param limit number # Wrap the line after this many horizontal pixels. ----@param align love.AlignMode # The alignment. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). -function love.graphics.printf(text, limit, align, sx, sy, ox, oy, kx, ky) end +---@param align? love.AlignMode # The alignment. +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). +function love.graphics.printf(text, x, y, limit, align, r, sx, sy, ox, oy, kx, ky) end --- ---Copies and pushes the current coordinate transformation to the transformation stack. @@ -745,9 +786,11 @@ function love.graphics.push() end --- ---@overload fun(mode: love.DrawMode, x: number, y: number, width: number, height: number, rx: number, ry: number, segments: number) ---@param mode love.DrawMode # How to draw the rectangle. +---@param x number # The position of top-left corner along the x-axis. +---@param y number # The position of top-left corner along the y-axis. ---@param width number # Width of the rectangle. ---@param height number # Height of the rectangle. -function love.graphics.rectangle(mode, width, height) end +function love.graphics.rectangle(mode, x, y, width, height) end --- ---Replaces the current coordinate transformation with the given Transform object. @@ -782,7 +825,7 @@ function love.graphics.rotate(angle) end ---Scaling lasts until love.draw() exits. --- ---@param sx number # The scaling in the direction of the x-axis. ----@param sy number # The scaling in the direction of the y-axis. If omitted, it defaults to same as parameter sx. +---@param sy? number # The scaling in the direction of the y-axis. If omitted, it defaults to same as parameter sx. function love.graphics.scale(sx, sy) end --- @@ -793,7 +836,7 @@ function love.graphics.scale(sx, sy) end ---@param red number # The red component (0-1). ---@param green number # The green component (0-1). ---@param blue number # The blue component (0-1). ----@param alpha number # The alpha component (0-1). +---@param alpha? number # The alpha component (0-1). function love.graphics.setBackgroundColor(red, green, blue, alpha) end --- @@ -811,7 +854,7 @@ function love.graphics.setBlendMode(mode) end ---@overload fun(canvas: love.Canvas, slice: number, mipmap: number) ---@overload fun(setup: table) ---@param canvas love.Canvas # The new target. ----@param mipmap number # The mipmap level to render to, for Canvases with mipmaps. +---@param mipmap? number # The mipmap level to render to, for Canvases with mipmaps. function love.graphics.setCanvas(canvas, mipmap) end --- @@ -823,7 +866,7 @@ function love.graphics.setCanvas(canvas, mipmap) end ---@param red number # The amount of red. ---@param green number # The amount of green. ---@param blue number # The amount of blue. ----@param alpha number # The amount of alpha. The alpha value will be applied to all subsequent draw operations, even the drawing of an image. +---@param alpha? number # The amount of alpha. The alpha value will be applied to all subsequent draw operations, even the drawing of an image. function love.graphics.setColor(red, green, blue, alpha) end --- @@ -841,7 +884,7 @@ function love.graphics.setColorMask(red, green, blue, alpha) end --- ---@param min love.FilterMode # Filter mode used when scaling the image down. ---@param mag love.FilterMode # Filter mode used when scaling the image up. ----@param anisotropy number # Maximum amount of Anisotropic Filtering used. +---@param anisotropy? number # Maximum amount of Anisotropic Filtering used. function love.graphics.setDefaultFilter(min, mag, anisotropy) end --- @@ -905,7 +948,7 @@ function love.graphics.setMeshCullMode(mode) end ---@overload fun(file: love.File, size: number):love.Font ---@overload fun(data: love.Data, size: number):love.Font ---@overload fun(rasterizer: love.Rasterizer):love.Font ----@param size number # The size of the font. +---@param size? number # The size of the font. ---@return love.Font font # The new font. function love.graphics.setNewFont(size) end @@ -923,9 +966,11 @@ function love.graphics.setPointSize(size) end ---The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...). --- ---@overload fun() +---@param x number # x coordinate of upper left corner. +---@param y number # y coordinate of upper left corner. ---@param width number # width of clipping rectangle. ---@param height number # height of clipping rectangle. -function love.graphics.setScissor(width, height) end +function love.graphics.setScissor(x, y, width, height) end --- ---Sets or resets a Shader as the current pixel effect or vertex shaders. All drawing operations until the next ''love.graphics.setShader'' will be drawn using the Shader object specified. @@ -965,9 +1010,9 @@ function love.graphics.shear(kx, ky) end ---Stencil values are integers within the range of 255. --- ---@param stencilfunction function # Function which draws geometry. The stencil values of pixels, rather than the color of each pixel, will be affected by the geometry. ----@param action love.StencilAction # How to modify any stencil values of pixels that are touched by what's drawn in the stencil function. ----@param value number # The new stencil value to use for pixels if the 'replace' stencil action is used. Has no effect with other stencil actions. Must be between 0 and 255. ----@param keepvalues boolean # True to preserve old stencil values of pixels, false to re-set every pixel's stencil value to 0 before executing the stencil function. love.graphics.clear will also re-set all stencil values. +---@param action? love.StencilAction # How to modify any stencil values of pixels that are touched by what's drawn in the stencil function. +---@param value? number # The new stencil value to use for pixels if the 'replace' stencil action is used. Has no effect with other stencil actions. Must be between 0 and 255. +---@param keepvalues? boolean # True to preserve old stencil values of pixels, false to re-set every pixel's stencil value to 0 before executing the stencil function. love.graphics.clear will also re-set all stencil values. function love.graphics.stencil(stencilfunction, action, value, keepvalues) end --- @@ -1172,7 +1217,7 @@ function Font:setFallbacks(fallbackfont1) end --- ---@param min love.FilterMode # How to scale a font down. ---@param mag love.FilterMode # How to scale a font up. ----@param anisotropy number # Maximum amount of anisotropic filtering used. +---@param anisotropy? number # Maximum amount of anisotropic filtering used. function Font:setFilter(min, mag, anisotropy) end --- @@ -1208,9 +1253,11 @@ function Image:isCompressed() end --- ---@param data love.ImageData # The new ImageData to replace the contents with. ---@param slice number # Which cubemap face, array index, or volume layer to replace, if applicable. ----@param mipmap number # The mimap level to replace, if the Image has mipmaps. +---@param mipmap? number # The mimap level to replace, if the Image has mipmaps. +---@param x? number # The x-offset in pixels from the top-left of the image to replace. The given ImageData's width plus this value must not be greater than the pixel width of the Image's specified mipmap level. +---@param y? number # The y-offset in pixels from the top-left of the image to replace. The given ImageData's height plus this value must not be greater than the pixel height of the Image's specified mipmap level. ---@param reloadmipmaps boolean # Whether to generate new mipmaps after replacing the Image's pixels. True by default if the Image was created with automatically generated mipmaps, false by default otherwise. -function Image:replacePixels(data, slice, mipmap, reloadmipmaps) end +function Image:replacePixels(data, slice, mipmap, x, y, reloadmipmaps) end --- ---A 2D polygon mesh used for drawing arbitrary textured shapes. @@ -1367,7 +1414,7 @@ function Mesh:setVertexMap(map) end ---@overload fun(data: love.Data, startvertex: number) ---@overload fun(vertices: table) ---@param vertices {attributecomponent: number} # The table filled with vertex information tables for each vertex, in the form of {vertex, ...} where each vertex is a table in the form of {attributecomponent, ...}. ----@param startvertex number # The index of the first vertex to replace. +---@param startvertex? number # The index of the first vertex to replace. function Mesh:setVertices(vertices, startvertex) end --- @@ -1492,6 +1539,8 @@ function ParticleSystem:getParticleLifetime() end --- ---Gets the position of the emitter. --- +---@return number x # Position along x-axis. +---@return number y # Position along y-axis. function ParticleSystem:getPosition() end --- @@ -1595,7 +1644,9 @@ function ParticleSystem:isStopped() end --- ---Moves the position of the emitter. This results in smoother particle spawning behaviour than if ParticleSystem:setPosition is used every frame. --- -function ParticleSystem:moveTo() end +---@param x number # Position along x-axis. +---@param y number # Position along y-axis. +function ParticleSystem:moveTo(x, y) end --- ---Pauses the particle emitter. @@ -1646,8 +1697,8 @@ function ParticleSystem:setDirection(direction) end ---@param distribution love.AreaSpreadDistribution # The type of distribution for new particles. ---@param dx number # The maximum spawn distance from the emitter along the x-axis for uniform distribution, or the standard deviation along the x-axis for normal distribution. ---@param dy number # The maximum spawn distance from the emitter along the y-axis for uniform distribution, or the standard deviation along the y-axis for normal distribution. ----@param angle number # The angle in radians of the emission area. ----@param directionRelativeToCenter boolean # True if newly spawned particles will be oriented relative to the center of the emission area, false otherwise. +---@param angle? number # The angle in radians of the emission area. +---@param directionRelativeToCenter? boolean # True if newly spawned particles will be oriented relative to the center of the emission area, false otherwise. function ParticleSystem:setEmissionArea(distribution, dx, dy, angle, directionRelativeToCenter) end --- @@ -1675,15 +1726,15 @@ function ParticleSystem:setInsertMode(mode) end --- ---@param xmin number # The minimum acceleration along the x axis. ---@param ymin number # The minimum acceleration along the y axis. ----@param xmax number # The maximum acceleration along the x axis. ----@param ymax number # The maximum acceleration along the y axis. +---@param xmax? number # The maximum acceleration along the x axis. +---@param ymax? number # The maximum acceleration along the y axis. function ParticleSystem:setLinearAcceleration(xmin, ymin, xmax, ymax) end --- ---Sets the amount of linear damping (constant deceleration) for particles. --- ---@param min number # The minimum amount of linear damping applied to particles. ----@param max number # The maximum amount of linear damping applied to particles. +---@param max? number # The maximum amount of linear damping applied to particles. function ParticleSystem:setLinearDamping(min, max) end --- @@ -1691,19 +1742,23 @@ function ParticleSystem:setLinearDamping(min, max) end --- ---If this function is not used, the particles rotate around their center. --- -function ParticleSystem:setOffset() end +---@param x number # The x coordinate of the rotation offset. +---@param y number # The y coordinate of the rotation offset. +function ParticleSystem:setOffset(x, y) end --- ---Sets the lifetime of the particles. --- ---@param min number # The minimum life of the particles (in seconds). ----@param max number # The maximum life of the particles (in seconds). +---@param max? number # The maximum life of the particles (in seconds). function ParticleSystem:setParticleLifetime(min, max) end --- ---Sets the position of the emitter. --- -function ParticleSystem:setPosition() end +---@param x number # Position along x-axis. +---@param y number # Position along y-axis. +function ParticleSystem:setPosition(x, y) end --- ---Sets a series of Quads to use for the particle sprites. Particles will choose a Quad from the list based on the particle's current lifetime, allowing for the use of animated sprite sheets with ParticleSystems. @@ -1717,7 +1772,7 @@ function ParticleSystem:setQuads(quad1, quad2) end ---Set the radial acceleration (away from the emitter). --- ---@param min number # The minimum acceleration. ----@param max number # The maximum acceleration. +---@param max? number # The maximum acceleration. function ParticleSystem:setRadialAcceleration(min, max) end --- @@ -1730,7 +1785,7 @@ function ParticleSystem:setRelativeRotation(enable) end ---Sets the rotation of the image upon particle creation (in radians). --- ---@param min number # The minimum initial angle (radians). ----@param max number # The maximum initial angle (radians). +---@param max? number # The maximum initial angle (radians). function ParticleSystem:setRotation(min, max) end --- @@ -1753,14 +1808,14 @@ function ParticleSystem:setSizes(size1, size2, size8) end ---Sets the speed of the particles. --- ---@param min number # The minimum linear speed of the particles. ----@param max number # The maximum linear speed of the particles. +---@param max? number # The maximum linear speed of the particles. function ParticleSystem:setSpeed(min, max) end --- ---Sets the spin of the sprite. --- ---@param min number # The minimum spin (radians per second). ----@param max number # The maximum spin (radians per second). +---@param max? number # The maximum spin (radians per second). function ParticleSystem:setSpin(min, max) end --- @@ -1779,7 +1834,7 @@ function ParticleSystem:setSpread(spread) end ---Sets the tangential acceleration (acceleration perpendicular to the particle's direction). --- ---@param min number # The minimum acceleration. ----@param max number # The maximum acceleration. +---@param max? number # The maximum acceleration. function ParticleSystem:setTangentialAcceleration(min, max) end --- @@ -1822,14 +1877,22 @@ function Quad:getTextureDimensions() end --- ---Gets the current viewport of this Quad. --- +---@return number x # The top-left corner along the x-axis. +---@return number y # The top-left corner along the y-axis. +---@return number w # The width of the viewport. +---@return number h # The height of the viewport. function Quad:getViewport() end --- ---Sets the texture coordinates according to a viewport. --- +---@param x number # The top-left corner along the x-axis. +---@param y number # The top-left corner along the y-axis. +---@param w number # The width of the viewport. +---@param h number # The height of the viewport. ---@param sw number # The reference width, the width of the Image. (Must be greater than 0.) ---@param sh number # The reference height, the height of the Image. (Must be greater than 0.) -function Quad:setViewport(sw, sh) end +function Quad:setViewport(x, y, w, h, sw, sh) end --- ---A Shader is used for advanced hardware-accelerated pixel or vertex manipulation. These effects are written in a language based on GLSL (OpenGL Shading Language) with a few things simplified for easier coding. @@ -1917,14 +1980,17 @@ local SpriteBatch = {} ---Adds a sprite to the batch. Sprites are drawn in the order they are added. --- ---@overload fun(quad: love.Quad, x: number, y: number, r: number, sx: number, sy: number, ox: number, oy: number, kx: number, ky: number):number ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shear factor (x-axis). ----@param ky number # Shear factor (y-axis). +---@param x number # The position to draw the object (x-axis). +---@param y number # The position to draw the object (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shear factor (x-axis). +---@param ky? number # Shear factor (y-axis). ---@return number id # An identifier for the added sprite. -function SpriteBatch:add(sx, sy, ox, oy, kx, ky) end +function SpriteBatch:add(x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Adds a sprite to a batch created with an Array Texture. @@ -1933,14 +1999,17 @@ function SpriteBatch:add(sx, sy, ox, oy, kx, ky) end ---@overload fun(layerindex: number, transform: love.Transform):number ---@overload fun(layerindex: number, quad: love.Quad, transform: love.Transform):number ---@param layerindex number # The index of the layer to use for this sprite. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). +---@param x? number # The position to draw the sprite (x-axis). +---@param y? number # The position to draw the sprite (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). ---@return number spriteindex # The index of the added sprite, for use with SpriteBatch:set or SpriteBatch:setLayer. -function SpriteBatch:addLayer(layerindex, sx, sy, ox, oy, kx, ky) end +function SpriteBatch:addLayer(layerindex, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Attaches a per-vertex attribute from a Mesh onto this SpriteBatch, for use when drawing. This can be combined with a Shader to augment a SpriteBatch with per-vertex or additional per-sprite information instead of just having per-sprite colors. @@ -1978,6 +2047,10 @@ function SpriteBatch:getBufferSize() end --- ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- +---@return number r # The red component (0-1). +---@return number g # The green component (0-1). +---@return number b # The blue component (0-1). +---@return number a # The alpha component (0-1). function SpriteBatch:getColor() end --- @@ -1997,13 +2070,16 @@ function SpriteBatch:getTexture() end --- ---@overload fun(spriteindex: number, quad: love.Quad, x: number, y: number, r: number, sx: number, sy: number, ox: number, oy: number, kx: number, ky: number) ---@param spriteindex number # The index of the sprite that will be changed. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shear factor (x-axis). ----@param ky number # Shear factor (y-axis). -function SpriteBatch:set(spriteindex, sx, sy, ox, oy, kx, ky) end +---@param x number # The position to draw the object (x-axis). +---@param y number # The position to draw the object (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shear factor (x-axis). +---@param ky? number # Shear factor (y-axis). +function SpriteBatch:set(spriteindex, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Sets the color that will be used for the next add and set operations. Calling the function without arguments will disable all per-sprite colors for the SpriteBatch. @@ -2013,7 +2089,11 @@ function SpriteBatch:set(spriteindex, sx, sy, ox, oy, kx, ky) end ---In version 0.9.2 and older, the global color set with love.graphics.setColor will not work on the SpriteBatch if any of the sprites has its own color. --- ---@overload fun() -function SpriteBatch:setColor() end +---@param r number # The amount of red. +---@param g number # The amount of green. +---@param b number # The amount of blue. +---@param a? number # The amount of alpha. +function SpriteBatch:setColor(r, g, b, a) end --- ---Restricts the drawn sprites in the SpriteBatch to a subset of the total. @@ -2031,13 +2111,16 @@ function SpriteBatch:setDrawRange(start, count) end ---@overload fun(spriteindex: number, layerindex: number, quad: love.Quad, transform: love.Transform) ---@param spriteindex number # The index of the existing sprite to replace. ---@param layerindex number # The index of the layer in the Array Texture to use for this sprite. ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing factor (x-axis). ----@param ky number # Shearing factor (y-axis). -function SpriteBatch:setLayer(spriteindex, layerindex, sx, sy, ox, oy, kx, ky) end +---@param x? number # The position to draw the sprite (x-axis). +---@param y? number # The position to draw the sprite (y-axis). +---@param r? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing factor (x-axis). +---@param ky? number # Shearing factor (y-axis). +function SpriteBatch:setLayer(spriteindex, layerindex, x, y, r, sx, sy, ox, oy, kx, ky) end --- ---Sets the texture (Image or Canvas) used for the sprites in the batch, when drawing. @@ -2056,15 +2139,17 @@ local Text = {} --- ---@overload fun(coloredtext: table, x: number, y: number, angle: number, sx: number, sy: number, ox: number, oy: number, kx: number, ky: number):number ---@param textstring string # The text to add to the object. ----@param angle number # The orientation of the new text in radians. ----@param sx number # Scale factor on the x-axis. ----@param sy number # Scale factor on the y-axis. ----@param ox number # Origin offset on the x-axis. ----@param oy number # Origin offset on the y-axis. ----@param kx number # Shearing / skew factor on the x-axis. ----@param ky number # Shearing / skew factor on the y-axis. +---@param x? number # The position of the new text on the x-axis. +---@param y? number # The position of the new text on the y-axis. +---@param angle? number # The orientation of the new text in radians. +---@param sx? number # Scale factor on the x-axis. +---@param sy? number # Scale factor on the y-axis. +---@param ox? number # Origin offset on the x-axis. +---@param oy? number # Origin offset on the y-axis. +---@param kx? number # Shearing / skew factor on the x-axis. +---@param ky? number # Shearing / skew factor on the y-axis. ---@return number index # An index number that can be used with Text:getWidth or Text:getHeight. -function Text:add(textstring, angle, sx, sy, ox, oy, kx, ky) end +function Text:add(textstring, x, y, angle, sx, sy, ox, oy, kx, ky) end --- ---Adds additional formatted / colored text to the Text object at the specified position. @@ -2075,15 +2160,17 @@ function Text:add(textstring, angle, sx, sy, ox, oy, kx, ky) end ---@param textstring string # The text to add to the object. ---@param wraplimit number # The maximum width in pixels of the text before it gets automatically wrapped to a new line. ---@param align love.AlignMode # The alignment of the text. ----@param angle number # Orientation (radians). ----@param sx number # Scale factor (x-axis). ----@param sy number # Scale factor (y-axis). ----@param ox number # Origin offset (x-axis). ----@param oy number # Origin offset (y-axis). ----@param kx number # Shearing / skew factor (x-axis). ----@param ky number # Shearing / skew factor (y-axis). +---@param x number # The position of the new text (x-axis). +---@param y number # The position of the new text (y-axis). +---@param angle? number # Orientation (radians). +---@param sx? number # Scale factor (x-axis). +---@param sy? number # Scale factor (y-axis). +---@param ox? number # Origin offset (x-axis). +---@param oy? number # Origin offset (y-axis). +---@param kx? number # Shearing / skew factor (x-axis). +---@param ky? number # Shearing / skew factor (y-axis). ---@return number index # An index number that can be used with Text:getWidth or Text:getHeight. -function Text:addf(textstring, wraplimit, align, angle, sx, sy, ox, oy, kx, ky) end +function Text:addf(textstring, wraplimit, align, x, y, angle, sx, sy, ox, oy, kx, ky) end --- ---Clears the contents of the Text object. @@ -2288,7 +2375,7 @@ function Texture:setDepthSampleMode(compare) end --- ---@param min love.FilterMode # Filter mode to use when minifying the texture (rendering it at a smaller size on-screen than its size in pixels). ---@param mag love.FilterMode # Filter mode to use when magnifying the texture (rendering it at a larger size on-screen than its size in pixels). ----@param anisotropy number # Maximum amount of anisotropic filtering to use. +---@param anisotropy? number # Maximum amount of anisotropic filtering to use. function Texture:setFilter(min, mag, anisotropy) end --- @@ -2302,7 +2389,7 @@ function Texture:setFilter(min, mag, anisotropy) end --- ---@overload fun() ---@param filtermode love.FilterMode # The filter mode to use in between mipmap levels. 'nearest' will often give better performance. ----@param sharpness number # A positive sharpness value makes the texture use a more detailed mipmap level when drawing, at the expense of performance. A negative value does the reverse. +---@param sharpness? number # A positive sharpness value makes the texture use a more detailed mipmap level when drawing, at the expense of performance. A negative value does the reverse. function Texture:setMipmapFilter(filtermode, sharpness) end --- @@ -2313,8 +2400,8 @@ function Texture:setMipmapFilter(filtermode, sharpness) end ---Clamped textures appear only once (with the edges of the texture stretching to fill the extent of the Quad), whereas repeated ones repeat as many times as there is room in the Quad. --- ---@param horiz love.WrapMode # Horizontal wrapping mode of the texture. ----@param vert love.WrapMode # Vertical wrapping mode of the texture. ----@param depth love.WrapMode # Wrapping mode for the z-axis of a Volume texture. +---@param vert? love.WrapMode # Vertical wrapping mode of the texture. +---@param depth? love.WrapMode # Wrapping mode for the z-axis of a Volume texture. function Texture:setWrap(horiz, vert, depth) end --- @@ -2394,13 +2481,13 @@ function Video:seek(offset) end --- ---@param min love.FilterMode # The filter mode used when scaling the Video down. ---@param mag love.FilterMode # The filter mode used when scaling the Video up. ----@param anisotropy number # Maximum amount of anisotropic filtering used. +---@param anisotropy? number # Maximum amount of anisotropic filtering used. function Video:setFilter(min, mag, anisotropy) end --- ---Sets the audio Source used for playing back the video's audio. The audio Source also controls playback speed and synchronization. --- ----@param source love.Source # The audio Source used for audio playback, or nil to disable audio synchronization. +---@param source? love.Source # The audio Source used for audio playback, or nil to disable audio synchronization. function Video:setSource(source) end --- diff --git a/meta/3rd/love2d/library/love.image.lua b/meta/3rd/love2d/library/love.image.lua index 85070b9c..9dc9c6e7 100644 --- a/meta/3rd/love2d/library/love.image.lua +++ b/meta/3rd/love2d/library/love.image.lua @@ -92,7 +92,7 @@ local ImageData = {} ---@overload fun(outFile: string) ---@overload fun(outFile: string, format: love.ImageFormat) ---@param format love.ImageFormat # The format to encode the image as. ----@param filename string # The filename to write the file to. If nil, no file will be written but the FileData will still be returned. +---@param filename? string # The filename to write the file to. If nil, no file will be written but the FileData will still be returned. ---@return love.FileData filedata # The encoded image as a new FileData object. function ImageData:encode(format, filename) end @@ -116,7 +116,13 @@ function ImageData:getHeight() end --- ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- -function ImageData:getPixel() end +---@param x number # The position of the pixel on the x-axis. +---@param y number # The position of the pixel on the y-axis. +---@return number r # The red component (0-1). +---@return number g # The green component (0-1). +---@return number b # The blue component (0-1). +---@return number a # The alpha component (0-1). +function ImageData:getPixel(x, y) end --- ---Gets the width of the ImageData in pixels. @@ -146,9 +152,11 @@ function ImageData:getWidth() end ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- ---@param pixelFunction function # Function to apply to every pixel. ----@param width number # The width of the area within the ImageData to apply the function to. ----@param height number # The height of the area within the ImageData to apply the function to. -function ImageData:mapPixel(pixelFunction, width, height) end +---@param x? number # The x-axis of the top-left corner of the area within the ImageData to apply the function to. +---@param y? number # The y-axis of the top-left corner of the area within the ImageData to apply the function to. +---@param width? number # The width of the area within the ImageData to apply the function to. +---@param height? number # The height of the area within the ImageData to apply the function to. +function ImageData:mapPixel(pixelFunction, x, y, width, height) end --- ---Paste into ImageData from another source ImageData. @@ -169,7 +177,13 @@ function ImageData:paste(source, dx, dy, sx, sy, sw, sh) end --- ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- -function ImageData:setPixel() end +---@param x number # The position of the pixel on the x-axis. +---@param y number # The position of the pixel on the y-axis. +---@param r number # The red component (0-1). +---@param g number # The green component (0-1). +---@param b number # The blue component (0-1). +---@param a number # The alpha component (0-1). +function ImageData:setPixel(x, y, r, g, b, a) end --- ---Compressed image data formats. Here and here are a couple overviews of many of the formats. diff --git a/meta/3rd/love2d/library/love.joystick.lua b/meta/3rd/love2d/library/love.joystick.lua index dab3ea25..65cfdc6b 100644 --- a/meta/3rd/love2d/library/love.joystick.lua +++ b/meta/3rd/love2d/library/love.joystick.lua @@ -58,7 +58,7 @@ function love.joystick.saveGamepadMappings(filename) end ---@param button love.GamepadButton # The virtual gamepad button to bind. ---@param inputtype love.JoystickInputType # The type of input to bind the virtual gamepad button to. ---@param inputindex number # The index of the axis, button, or hat to bind the virtual gamepad button to. ----@param hatdir love.JoystickHat # The direction of the hat, if the virtual gamepad button will be bound to a hat. nil otherwise. +---@param hatdir? love.JoystickHat # The direction of the hat, if the virtual gamepad button will be bound to a hat. nil otherwise. ---@return boolean success # Whether the virtual gamepad button was successfully bound. function love.joystick.setGamepadMapping(guid, button, inputtype, inputindex, hatdir) end diff --git a/meta/3rd/love2d/library/love.lua b/meta/3rd/love2d/library/love.lua index ed26afad..c5897608 100644 --- a/meta/3rd/love2d/library/love.lua +++ b/meta/3rd/love2d/library/love.lua @@ -99,6 +99,7 @@ function Object:type() end ---Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true. --- ---@param name string # The name of the type to check for. +---@return boolean b # True if the object is of the specified type, false otherwise. function Object:typeOf(name) end --- diff --git a/meta/3rd/love2d/library/love.math.lua b/meta/3rd/love2d/library/love.math.lua index 2cc07c15..5cd0c64f 100644 --- a/meta/3rd/love2d/library/love.math.lua +++ b/meta/3rd/love2d/library/love.math.lua @@ -12,25 +12,33 @@ love.math = {} ---@param rb number # Red color component in 0..255 range. ---@param gb number # Green color component in 0..255 range. ---@param bb number # Blue color component in 0..255 range. ----@param ab number # Alpha color component in 0..255 range. +---@param ab? number # Alpha color component in 0..255 range. +---@return number r # Red color component in 0..1 range. +---@return number g # Green color component in 0..1 range. +---@return number b # Blue color component in 0..1 range. +---@return number a # Alpha color component in 0..1 range or nil if alpha is not specified. function love.math.colorFromBytes(rb, gb, bb, ab) end --- ---Converts a color from 0..1 to 0..255 range. --- +---@param r number # Red color component. +---@param g number # Green color component. +---@param b number # Blue color component. +---@param a? number # Alpha color component. ---@return number rb # Red color component in 0..255 range. ---@return number gb # Green color component in 0..255 range. ---@return number bb # Blue color component in 0..255 range. ---@return number ab # Alpha color component in 0..255 range or nil if alpha is not specified. -function love.math.colorToBytes() end +function love.math.colorToBytes(r, g, b, a) end --- ---Compresses a string or data using a specific compression algorithm. --- ---@overload fun(data: love.Data, format: love.CompressedDataFormat, level: number):love.CompressedData ---@param rawstring string # The raw (un-compressed) string to compress. ----@param format love.CompressedDataFormat # The format to use when compressing the string. ----@param level number # The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. +---@param format? love.CompressedDataFormat # The format to use when compressing the string. +---@param level? number # The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. ---@return love.CompressedData compressedData # A new Data object containing the compressed version of the string. function love.math.compress(rawstring, format, level) end @@ -52,10 +60,13 @@ function love.math.decompress(compressedData) end --- ---@overload fun(color: table):number, number, number ---@overload fun(c: number):number +---@param r number # The red channel of the sRGB color to convert. +---@param g number # The green channel of the sRGB color to convert. +---@param b number # The blue channel of the sRGB color to convert. ---@return number lr # The red channel of the converted color in linear RGB space. ---@return number lg # The green channel of the converted color in linear RGB space. ---@return number lb # The blue channel of the converted color in linear RGB space. -function love.math.gammaToLinear() end +function love.math.gammaToLinear(r, g, b) end --- ---Gets the seed of the random number generator. @@ -138,8 +149,9 @@ function love.math.newTransform() end ---@overload fun(x: number, y: number):number ---@overload fun(x: number, y: number, z: number):number ---@overload fun(x: number, y: number, z: number, w: number):number +---@param x number # The number used to generate the noise value. ---@return number value # The noise value in the range of 1. -function love.math.noise() end +function love.math.noise(x) end --- ---Generates a pseudo-random number in a platform independent manner. The default love.run seeds this function at startup, so you generally don't need to seed it yourself. @@ -152,8 +164,8 @@ function love.math.random() end --- ---Get a normally distributed pseudo random number. --- ----@param stddev number # Standard deviation of the distribution. ----@param mean number # The mean of the distribution. +---@param stddev? number # Standard deviation of the distribution. +---@param mean? number # The mean of the distribution. ---@return number number # Normally distributed random number with variance (stddev)² and the specified mean. function love.math.randomNormal(stddev, mean) end @@ -193,12 +205,18 @@ local BezierCurve = {} --- ---This function can be used to move objects along paths or tween parameters. However it should not be used to render the curve, see BezierCurve:render for that purpose. --- -function BezierCurve:evaluate() end +---@param t number # Where to evaluate the curve. +---@return number x # x coordinate of the curve at parameter t. +---@return number y # y coordinate of the curve at parameter t. +function BezierCurve:evaluate(t) end --- ---Get coordinates of the i-th control point. Indices start with 1. --- -function BezierCurve:getControlPoint() end +---@param i number # Index of the control point. +---@return number x # Position of the control point along the x axis. +---@return number y # Position of the control point along the y axis. +function BezierCurve:getControlPoint(i) end --- ---Get the number of control points in the Bézier curve. @@ -231,7 +249,10 @@ function BezierCurve:getSegment(startpoint, endpoint) end --- ---Insert control point as the new i-th control point. Existing control points from i onwards are pushed back by 1. Indices start with 1. Negative indices wrap around: -1 is the last control point, -2 the one before the last, etc. --- -function BezierCurve:insertControlPoint() end +---@param x number # Position of the control point along the x axis. +---@param y number # Position of the control point along the y axis. +---@param i? number # Index of the control point. +function BezierCurve:insertControlPoint(x, y, i) end --- ---Removes the specified control point. @@ -246,7 +267,7 @@ function BezierCurve:removeControlPoint(index) end --- ---If you are just interested to know the position on the curve given a parameter, use BezierCurve:evaluate. --- ----@param depth number # Number of recursive subdivision steps. +---@param depth? number # Number of recursive subdivision steps. ---@return table coordinates # List of x,y-coordinate pairs of points on the curve. function BezierCurve:render(depth) end @@ -259,7 +280,7 @@ function BezierCurve:render(depth) end --- ---@param startpoint number # The starting point along the curve. Must be between 0 and 1. ---@param endpoint number # The end of the segment to render. Must be between 0 and 1. ----@param depth number # Number of recursive subdivision steps. +---@param depth? number # Number of recursive subdivision steps. ---@return table coordinates # List of x,y-coordinate pairs of points on the specified part of the curve. function BezierCurve:renderSegment(startpoint, endpoint, depth) end @@ -267,21 +288,25 @@ function BezierCurve:renderSegment(startpoint, endpoint, depth) end ---Rotate the Bézier curve by an angle. --- ---@param angle number # Rotation angle in radians. ----@param ox number # X coordinate of the rotation center. ----@param oy number # Y coordinate of the rotation center. +---@param ox? number # X coordinate of the rotation center. +---@param oy? number # Y coordinate of the rotation center. function BezierCurve:rotate(angle, ox, oy) end --- ---Scale the Bézier curve by a factor. --- ----@param ox number # X coordinate of the scaling center. ----@param oy number # Y coordinate of the scaling center. -function BezierCurve:scale(ox, oy) end +---@param s number # Scale factor. +---@param ox? number # X coordinate of the scaling center. +---@param oy? number # Y coordinate of the scaling center. +function BezierCurve:scale(s, ox, oy) end --- ---Set coordinates of the i-th control point. Indices start with 1. --- -function BezierCurve:setControlPoint() end +---@param i number # Index of the control point. +---@param x number # Position of the control point along the x axis. +---@param y number # Position of the control point along the y axis. +function BezierCurve:setControlPoint(i, x, y) end --- ---Move the Bézier curve by an offset. @@ -324,8 +349,8 @@ function RandomGenerator:random() end --- ---Get a normally distributed pseudo random number. --- ----@param stddev number # Standard deviation of the distribution. ----@param mean number # The mean of the distribution. +---@param stddev? number # Standard deviation of the distribution. +---@param mean? number # The mean of the distribution. ---@return number number # Normally distributed random number with variance (stddev)² and the specified mean. function RandomGenerator:randomNormal(stddev, mean) end @@ -417,7 +442,7 @@ function Transform:rotate(angle) end ---Scales the Transform's coordinate system. This method does not reset any previously applied transformations. --- ---@param sx number # The relative scale factor along the x-axis. ----@param sy number # The relative scale factor along the y-axis. +---@param sy? number # The relative scale factor along the y-axis. ---@return love.Transform transform # The Transform object the method was called on. Allows easily chaining Transform methods. function Transform:scale(sx, sy) end @@ -436,15 +461,17 @@ function Transform:setMatrix(e1_1, e1_2, e4_4) end --- ---Resets the Transform to the specified transformation parameters. --- ----@param angle number # The orientation of the Transform in radians. ----@param sx number # Scale factor on the x-axis. ----@param sy number # Scale factor on the y-axis. ----@param ox number # Origin offset on the x-axis. ----@param oy number # Origin offset on the y-axis. ----@param kx number # Shearing / skew factor on the x-axis. ----@param ky number # Shearing / skew factor on the y-axis. +---@param x number # The position of the Transform on the x-axis. +---@param y number # The position of the Transform on the y-axis. +---@param angle? number # The orientation of the Transform in radians. +---@param sx? number # Scale factor on the x-axis. +---@param sy? number # Scale factor on the y-axis. +---@param ox? number # Origin offset on the x-axis. +---@param oy? number # Origin offset on the y-axis. +---@param kx? number # Shearing / skew factor on the x-axis. +---@param ky? number # Shearing / skew factor on the y-axis. ---@return love.Transform transform # The Transform object the method was called on. Allows easily chaining Transform methods. -function Transform:setTransformation(angle, sx, sy, ox, oy, kx, ky) end +function Transform:setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky) end --- ---Applies a shear factor (skew) to the Transform's coordinate system. This method does not reset any previously applied transformations. diff --git a/meta/3rd/love2d/library/love.mouse.lua b/meta/3rd/love2d/library/love.mouse.lua index d25808ba..3e9de39c 100644 --- a/meta/3rd/love2d/library/love.mouse.lua +++ b/meta/3rd/love2d/library/love.mouse.lua @@ -15,6 +15,8 @@ function love.mouse.getCursor() end --- ---Returns the current position of the mouse. --- +---@return number x # The position of the mouse along the x-axis. +---@return number y # The position of the mouse along the y-axis. function love.mouse.getPosition() end --- @@ -39,11 +41,13 @@ function love.mouse.getSystemCursor(ctype) end --- ---Returns the current x-position of the mouse. --- +---@return number x # The position of the mouse along the x-axis. function love.mouse.getX() end --- ---Returns the current y-position of the mouse. --- +---@return number y # The position of the mouse along the y-axis. function love.mouse.getY() end --- @@ -85,8 +89,8 @@ function love.mouse.isVisible() end ---@overload fun(filename: string, hotx: number, hoty: number):love.Cursor ---@overload fun(fileData: love.FileData, hotx: number, hoty: number):love.Cursor ---@param imageData love.ImageData # The ImageData to use for the new Cursor. ----@param hotx number # The x-coordinate in the ImageData of the cursor's hot spot. ----@param hoty number # The y-coordinate in the ImageData of the cursor's hot spot. +---@param hotx? number # The x-coordinate in the ImageData of the cursor's hot spot. +---@param hoty? number # The y-coordinate in the ImageData of the cursor's hot spot. ---@return love.Cursor cursor # The new Cursor object. function love.mouse.newCursor(imageData, hotx, hoty) end @@ -106,7 +110,9 @@ function love.mouse.setGrabbed(grab) end --- ---Sets the current position of the mouse. Non-integer values are floored. --- -function love.mouse.setPosition() end +---@param x number # The new position of the mouse along the x-axis. +---@param y number # The new position of the mouse along the y-axis. +function love.mouse.setPosition(x, y) end --- ---Sets whether relative mode is enabled for the mouse. @@ -129,14 +135,16 @@ function love.mouse.setVisible(visible) end --- ---Non-integer values are floored. --- -function love.mouse.setX() end +---@param x number # The new position of the mouse along the x-axis. +function love.mouse.setX(x) end --- ---Sets the current Y position of the mouse. --- ---Non-integer values are floored. --- -function love.mouse.setY() end +---@param y number # The new position of the mouse along the y-axis. +function love.mouse.setY(y) end --- ---Represents a hardware cursor. diff --git a/meta/3rd/love2d/library/love.physics.lua b/meta/3rd/love2d/library/love.physics.lua index 5c382108..7d3cd04d 100644 --- a/meta/3rd/love2d/library/love.physics.lua +++ b/meta/3rd/love2d/library/love.physics.lua @@ -42,9 +42,11 @@ function love.physics.getMeter() end ---The mass of the body gets calculated when a Fixture is attached or removed, but can be changed at any time with Body:setMass or Body:resetMassData. --- ---@param world love.World # The world to create the body in. ----@param type love.BodyType # The type of the body. +---@param x? number # The x position of the body. +---@param y? number # The y position of the body. +---@param type? love.BodyType # The type of the body. ---@return love.Body body # A new body. -function love.physics.newBody(world, type) end +function love.physics.newBody(world, x, y, type) end --- ---Creates a new ChainShape. @@ -77,7 +79,7 @@ function love.physics.newCircleShape(radius) end ---@param y1 number # The y position of the first anchor point (world space). ---@param x2 number # The x position of the second anchor point (world space). ---@param y2 number # The y position of the second anchor point (world space). ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.DistanceJoint joint # The new distance joint. function love.physics.newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected) end @@ -98,7 +100,7 @@ function love.physics.newEdgeShape(x1, y1, x2, y2) end --- ---@param body love.Body # The body which gets the fixture attached. ---@param shape love.Shape # The shape to be copied to the fixture. ----@param density number # The density of the fixture. +---@param density? number # The density of the fixture. ---@return love.Fixture fixture # The new fixture. function love.physics.newFixture(body, shape, density) end @@ -108,9 +110,11 @@ function love.physics.newFixture(body, shape, density) end ---@overload fun(body1: love.Body, body2: love.Body, x1: number, y1: number, x2: number, y2: number, collideConnected: boolean):love.FrictionJoint ---@param body1 love.Body # The first body to attach to the joint. ---@param body2 love.Body # The second body to attach to the joint. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param x number # The x position of the anchor point. +---@param y number # The y position of the anchor point. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.FrictionJoint joint # The new FrictionJoint. -function love.physics.newFrictionJoint(body1, body2, collideConnected) end +function love.physics.newFrictionJoint(body1, body2, x, y, collideConnected) end --- ---Create a GearJoint connecting two Joints. @@ -121,8 +125,8 @@ function love.physics.newFrictionJoint(body1, body2, collideConnected) end --- ---@param joint1 love.Joint # The first joint to connect with a gear joint. ---@param joint2 love.Joint # The second joint to connect with a gear joint. ----@param ratio number # The gear ratio. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param ratio? number # The gear ratio. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.GearJoint joint # The new gear joint. function love.physics.newGearJoint(joint1, joint2, ratio, collideConnected) end @@ -134,7 +138,7 @@ function love.physics.newGearJoint(joint1, joint2, ratio, collideConnected) end ---@overload fun(body1: love.Body, body2: love.Body, correctionFactor: number, collideConnected: boolean):love.MotorJoint ---@param body1 love.Body # The first body to attach to the joint. ---@param body2 love.Body # The second body to attach to the joint. ----@param correctionFactor number # The joint's initial position correction factor, in the range of 1. +---@param correctionFactor? number # The joint's initial position correction factor, in the range of 1. ---@return love.MotorJoint joint # The new MotorJoint. function love.physics.newMotorJoint(body1, body2, correctionFactor) end @@ -146,8 +150,10 @@ function love.physics.newMotorJoint(body1, body2, correctionFactor) end ---The advantage of using a MouseJoint instead of just changing a body position directly is that collisions and reactions to other joints are handled by the physics engine. --- ---@param body love.Body # The body to attach to the mouse. +---@param x number # The x position of the connecting point. +---@param y number # The y position of the connecting point. ---@return love.MouseJoint joint # The new mouse joint. -function love.physics.newMouseJoint(body) end +function love.physics.newMouseJoint(body, x, y) end --- ---Creates a new PolygonShape. @@ -173,11 +179,13 @@ function love.physics.newPolygonShape(x1, y1, x2, y2, x3, y3) end ---@overload fun(body1: love.Body, body2: love.Body, x1: number, y1: number, x2: number, y2: number, ax: number, ay: number, collideConnected: boolean, referenceAngle: number):love.PrismaticJoint ---@param body1 love.Body # The first body to connect with a prismatic joint. ---@param body2 love.Body # The second body to connect with a prismatic joint. +---@param x number # The x coordinate of the anchor point. +---@param y number # The y coordinate of the anchor point. ---@param ax number # The x coordinate of the axis vector. ---@param ay number # The y coordinate of the axis vector. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.PrismaticJoint joint # The new prismatic joint. -function love.physics.newPrismaticJoint(body1, body2, ax, ay, collideConnected) end +function love.physics.newPrismaticJoint(body1, body2, x, y, ax, ay, collideConnected) end --- ---Creates a PulleyJoint to join two bodies to each other and the ground. @@ -196,8 +204,8 @@ function love.physics.newPrismaticJoint(body1, body2, ax, ay, collideConnected) ---@param y1 number # The y coordinate of the pulley joint anchor in the first body. ---@param x2 number # The x coordinate of the pulley joint anchor in the second body. ---@param y2 number # The y coordinate of the pulley joint anchor in the second body. ----@param ratio number # The joint ratio. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param ratio? number # The joint ratio. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.PulleyJoint joint # The new pulley joint. function love.physics.newPulleyJoint(body1, body2, gx1, gy1, gx2, gy2, x1, y1, x2, y2, ratio, collideConnected) end @@ -220,9 +228,11 @@ function love.physics.newRectangleShape(width, height) end ---@overload fun(body1: love.Body, body2: love.Body, x1: number, y1: number, x2: number, y2: number, collideConnected: boolean, referenceAngle: number):love.RevoluteJoint ---@param body1 love.Body # The first body. ---@param body2 love.Body # The second body. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param x number # The x position of the connecting point. +---@param y number # The y position of the connecting point. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.RevoluteJoint joint # The new revolute joint. -function love.physics.newRevoluteJoint(body1, body2, collideConnected) end +function love.physics.newRevoluteJoint(body1, body2, x, y, collideConnected) end --- ---Creates a joint between two bodies. Its only function is enforcing a max distance between these bodies. @@ -234,7 +244,7 @@ function love.physics.newRevoluteJoint(body1, body2, collideConnected) end ---@param x2 number # The x position of the second anchor point. ---@param y2 number # The y position of the second anchor point. ---@param maxLength number # The maximum distance for the bodies. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.RopeJoint joint # The new RopeJoint. function love.physics.newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected) end @@ -245,9 +255,11 @@ function love.physics.newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, coll ---@overload fun(body1: love.Body, body2: love.Body, x1: number, y1: number, x2: number, y2: number, collideConnected: boolean, referenceAngle: number):love.WeldJoint ---@param body1 love.Body # The first body to attach to the joint. ---@param body2 love.Body # The second body to attach to the joint. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param x number # The x position of the anchor point (world space). +---@param y number # The y position of the anchor point (world space). +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.WeldJoint joint # The new WeldJoint. -function love.physics.newWeldJoint(body1, body2, collideConnected) end +function love.physics.newWeldJoint(body1, body2, x, y, collideConnected) end --- ---Creates a wheel joint. @@ -255,18 +267,20 @@ function love.physics.newWeldJoint(body1, body2, collideConnected) end ---@overload fun(body1: love.Body, body2: love.Body, x1: number, y1: number, x2: number, y2: number, ax: number, ay: number, collideConnected: boolean):love.WheelJoint ---@param body1 love.Body # The first body. ---@param body2 love.Body # The second body. +---@param x number # The x position of the anchor point. +---@param y number # The y position of the anchor point. ---@param ax number # The x position of the axis unit vector. ---@param ay number # The y position of the axis unit vector. ----@param collideConnected boolean # Specifies whether the two bodies should collide with each other. +---@param collideConnected? boolean # Specifies whether the two bodies should collide with each other. ---@return love.WheelJoint joint # The new WheelJoint. -function love.physics.newWheelJoint(body1, body2, ax, ay, collideConnected) end +function love.physics.newWheelJoint(body1, body2, x, y, ax, ay, collideConnected) end --- ---Creates a new World. --- ----@param xg number # The x component of gravity. ----@param yg number # The y component of gravity. ----@param sleep boolean # Whether the bodies in this world are allowed to sleep. +---@param xg? number # The x component of gravity. +---@param yg? number # The y component of gravity. +---@param sleep? boolean # Whether the bodies in this world are allowed to sleep. ---@return love.World world # A brave new World. function love.physics.newWorld(xg, yg, sleep) end @@ -370,6 +384,7 @@ function Body:getAngularDamping() end --- ---If you need the ''rate of change of position over time'', use Body:getLinearVelocity. --- +---@return number w # The angular velocity in radians/second. function Body:getAngularVelocity() end --- @@ -429,6 +444,8 @@ function Body:getLinearDamping() end --- ---See page 136 of 'Essential Mathematics for Games and Interactive Applications' for definitions of local and world coordinates. --- +---@return number x # The x-component of the velocity vector +---@return number y # The y-component of the velocity vector function Body:getLinearVelocity() end --- @@ -438,9 +455,11 @@ function Body:getLinearVelocity() end --- ---The point on the body must given in local coordinates. Use Body:getLinearVelocityFromWorldPoint to specify this with world coordinates. --- +---@param x number # The x position to measure velocity. +---@param y number # The y position to measure velocity. ---@return number vx # The x component of velocity at point (x,y). ---@return number vy # The y component of velocity at point (x,y). -function Body:getLinearVelocityFromLocalPoint() end +function Body:getLinearVelocityFromLocalPoint(x, y) end --- ---Get the linear velocity of a point on the body. @@ -449,15 +468,19 @@ function Body:getLinearVelocityFromLocalPoint() end --- ---The point on the body must given in world coordinates. Use Body:getLinearVelocityFromLocalPoint to specify this with local coordinates. --- +---@param x number # The x position to measure velocity. +---@param y number # The y position to measure velocity. ---@return number vx # The x component of velocity at point (x,y). ---@return number vy # The y component of velocity at point (x,y). -function Body:getLinearVelocityFromWorldPoint() end +function Body:getLinearVelocityFromWorldPoint(x, y) end --- ---Get the center of mass position in local coordinates. --- ---Use Body:getWorldCenter to get the center of mass in world coordinates. --- +---@return number x # The x coordinate of the center of mass. +---@return number y # The y coordinate of the center of mass. function Body:getLocalCenter() end --- @@ -489,6 +512,8 @@ function Body:getMass() end --- ---Returns the mass, its center, and the rotational inertia. --- +---@return number x # The x position of the center of mass. +---@return number y # The y position of the center of mass. ---@return number mass # The mass of the body. ---@return number inertia # The rotational inertia. function Body:getMassData() end @@ -498,6 +523,8 @@ function Body:getMassData() end --- ---Note that this may not be the center of mass of the body. --- +---@return number x # The x position. +---@return number y # The y position. function Body:getPosition() end --- @@ -505,6 +532,8 @@ function Body:getPosition() end --- ---Note that the position may not be the center of mass of the body. An angle of 0 radians will mean 'looking to the right'. Although radians increase counter-clockwise, the y axis points down so it becomes clockwise from our point of view. --- +---@return number x # The x component of the position. +---@return number y # The y component of the position. ---@return number angle # The angle in radians. function Body:getTransform() end @@ -531,6 +560,8 @@ function Body:getWorld() end --- ---Use Body:getLocalCenter to get the center of mass in local coordinates. --- +---@return number x # The x coordinate of the center of mass. +---@return number y # The y coordinate of the center of mass. function Body:getWorldCenter() end --- @@ -567,11 +598,13 @@ function Body:getWorldVector(localX, localY) end --- ---Get the x position of the body in world coordinates. --- +---@return number x # The x position in world coordinates. function Body:getX() end --- ---Get the y position of the body in world coordinates. --- +---@return number y # The y position in world coordinates. function Body:getY() end --- @@ -669,7 +702,8 @@ function Body:setAngularDamping(damping) end --- ---This function will not accumulate anything; any impulses previously applied since the last call to World:update will be lost. --- -function Body:setAngularVelocity() end +---@param w number # The new angular velocity, in radians per second +function Body:setAngularVelocity(w) end --- ---Wakes the body up or puts it to sleep. @@ -728,7 +762,9 @@ function Body:setLinearDamping(ld) end --- ---This function will not accumulate anything; any impulses previously applied since the last call to World:update will be lost. --- -function Body:setLinearVelocity() end +---@param x number # The x-component of the velocity vector. +---@param y number # The y-component of the velocity vector. +function Body:setLinearVelocity(x, y) end --- ---Sets a new body mass. @@ -739,9 +775,11 @@ function Body:setMass(mass) end --- ---Overrides the calculated mass data. --- +---@param x number # The x position of the center of mass. +---@param y number # The y position of the center of mass. ---@param mass number # The mass of the body. ---@param inertia number # The rotational inertia. -function Body:setMassData(mass, inertia) end +function Body:setMassData(x, y, mass, inertia) end --- ---Set the position of the body. @@ -750,7 +788,9 @@ function Body:setMassData(mass, inertia) end --- ---This function cannot wake up the body. --- -function Body:setPosition() end +---@param x number # The x position. +---@param y number # The y position. +function Body:setPosition(x, y) end --- ---Sets the sleeping behaviour of the body. Should sleeping be allowed, a body at rest will automatically sleep. A sleeping body is not simulated unless it collided with an awake body. Be wary that one can end up with a situation like a floating sleeping body if the floor was removed. @@ -765,8 +805,10 @@ function Body:setSleepingAllowed(allowed) end --- ---This function cannot wake up the body. --- +---@param x number # The x component of the position. +---@param y number # The y component of the position. ---@param angle number # The angle in radians. -function Body:setTransform(angle) end +function Body:setTransform(x, y, angle) end --- ---Sets a new body type. @@ -787,14 +829,16 @@ function Body:setUserData(value) end --- ---This function cannot wake up the body. --- -function Body:setX() end +---@param x number # The x position. +function Body:setX(x) end --- ---Set the y position of the body. --- ---This function cannot wake up the body. --- -function Body:setY() end +---@param y number # The y position. +function Body:setY(y) end --- ---A ChainShape consists of multiple line segments. It can be used to create the boundaries of your terrain. The shape does not have volume and can only collide with PolygonShape and CircleShape. @@ -816,12 +860,16 @@ function ChainShape:getChildEdge(index) end --- ---Setting next and previous ChainShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- +---@return number x # The x-component of the vertex, or nil if ChainShape:setNextVertex hasn't been called. +---@return number y # The y-component of the vertex, or nil if ChainShape:setNextVertex hasn't been called. function ChainShape:getNextVertex() end --- ---Returns a point of the shape. --- ---@param index number # The index of the point to return. +---@return number x # The x-coordinate of the point. +---@return number y # The y-coordinate of the point. function ChainShape:getPoint(index) end --- @@ -838,6 +886,8 @@ function ChainShape:getPoints() end --- ---Setting next and previous ChainShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- +---@return number x # The x-component of the vertex, or nil if ChainShape:setPreviousVertex hasn't been called. +---@return number y # The y-component of the vertex, or nil if ChainShape:setPreviousVertex hasn't been called. function ChainShape:getPreviousVertex() end --- @@ -851,14 +901,18 @@ function ChainShape:getVertexCount() end --- ---This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- -function ChainShape:setNextVertex() end +---@param x number # The x-component of the vertex. +---@param y number # The y-component of the vertex. +function ChainShape:setNextVertex(x, y) end --- ---Sets a vertex that establishes a connection to the previous shape. --- ---This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- -function ChainShape:setPreviousVertex() end +---@param x number # The x-component of the vertex. +---@param y number # The y-component of the vertex. +function ChainShape:setPreviousVertex(x, y) end --- ---Circle extends Shape and adds a radius and a local position. @@ -869,6 +923,8 @@ local CircleShape = {} --- ---Gets the center point of the circle shape. --- +---@return number x # The x-component of the center point of the circle. +---@return number y # The y-component of the center point of the circle. function CircleShape:getPoint() end --- @@ -880,7 +936,9 @@ function CircleShape:getRadius() end --- ---Sets the location of the center of the circle shape. --- -function CircleShape:setPoint() end +---@param x number # The x-component of the new center point of the circle. +---@param y number # The y-component of the new center point of the circle. +function CircleShape:setPoint(x, y) end --- ---Sets the radius of the circle. @@ -992,6 +1050,7 @@ function DistanceJoint:getFrequency() end --- ---Gets the equilibrium distance between the two Bodies. --- +---@return number l # The length between the two Bodies. function DistanceJoint:getLength() end --- @@ -1009,7 +1068,8 @@ function DistanceJoint:setFrequency(Hz) end --- ---Sets the equilibrium distance between the two Bodies. --- -function DistanceJoint:setLength() end +---@param l number # The length between the two Bodies. +function DistanceJoint:setLength(l) end --- ---A EdgeShape is a line segment. They can be used to create the boundaries of your terrain. The shape does not have volume and can only collide with PolygonShape and CircleShape. @@ -1022,6 +1082,8 @@ local EdgeShape = {} --- ---Setting next and previous EdgeShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- +---@return number x # The x-component of the vertex, or nil if EdgeShape:setNextVertex hasn't been called. +---@return number y # The y-component of the vertex, or nil if EdgeShape:setNextVertex hasn't been called. function EdgeShape:getNextVertex() end --- @@ -1038,6 +1100,8 @@ function EdgeShape:getPoints() end --- ---Setting next and previous EdgeShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- +---@return number x # The x-component of the vertex, or nil if EdgeShape:setPreviousVertex hasn't been called. +---@return number y # The y-component of the vertex, or nil if EdgeShape:setPreviousVertex hasn't been called. function EdgeShape:getPreviousVertex() end --- @@ -1045,14 +1109,18 @@ function EdgeShape:getPreviousVertex() end --- ---This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- -function EdgeShape:setNextVertex() end +---@param x number # The x-component of the vertex. +---@param y number # The y-component of the vertex. +function EdgeShape:setNextVertex(x, y) end --- ---Sets a vertex that establishes a connection to the previous shape. --- ---This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. --- -function EdgeShape:setPreviousVertex() end +---@param x number # The x-component of the vertex. +---@param y number # The y-component of the vertex. +function EdgeShape:setPreviousVertex(x, y) end --- ---Fixtures attach shapes to bodies. @@ -1074,7 +1142,7 @@ function Fixture:getBody() end --- ---Returns the points of the fixture bounding box. In case the fixture has multiple children a 1-based index can be specified. For example, a fixture will have multiple children with a chain shape. --- ----@param index number # A bounding box of the fixture. +---@param index? number # A bounding box of the fixture. ---@return number topLeftX # The x position of the top-left point. ---@return number topLeftY # The y position of the top-left point. ---@return number bottomRightX # The x position of the bottom-right point. @@ -1128,6 +1196,8 @@ function Fixture:getMask() end --- ---Returns the mass, its center and the rotational inertia. --- +---@return number x # The x position of the center of mass. +---@return number y # The y position of the center of mass. ---@return number mass # The mass of the fixture. ---@return number inertia # The rotational inertia. function Fixture:getMassData() end @@ -1178,7 +1248,7 @@ function Fixture:isSensor() end ---@param x2 number # The x position of the input line end point. ---@param y2 number # The y position of the input line end point. ---@param maxFraction number # Ray length parameter. ----@param childIndex number # The index of the child the ray gets cast against. +---@param childIndex? number # The index of the child the ray gets cast against. ---@return number xn # The x component of the normal vector of the edge where the ray hit the shape. ---@return number yn # The y component of the normal vector of the edge where the ray hit the shape. ---@return number fraction # The position on the input line where the intersection happened as a factor of the line length. @@ -1267,8 +1337,10 @@ function Fixture:setUserData(value) end --- ---Checks if a point is inside the shape of the fixture. --- +---@param x number # The x position of the point. +---@param y number # The y position of the point. ---@return boolean isInside # True if the point is inside or false if it is outside. -function Fixture:testPoint() end +function Fixture:testPoint(x, y) end --- ---A FrictionJoint applies friction to a body. @@ -1359,12 +1431,16 @@ function Joint:getBodies() end --- ---Gets whether the connected Bodies collide. --- +---@return boolean c # True if they collide, false otherwise. function Joint:getCollideConnected() end --- ---Returns the reaction force in newtons on the second body --- -function Joint:getReactionForce() end +---@param x number # How long the force applies. Usually the inverse time step or 1/dt. +---@return number x # The x-component of the force. +---@return number y # The y-component of the force. +function Joint:getReactionForce(x) end --- ---Returns the reaction torque on the second body. @@ -1414,6 +1490,8 @@ function MotorJoint:getAngularOffset() end --- ---Gets the target linear offset between the two Bodies the Joint is attached to. --- +---@return number x # The x component of the target linear offset, relative to the first Body. +---@return number y # The y component of the target linear offset, relative to the first Body. function MotorJoint:getLinearOffset() end --- @@ -1425,7 +1503,9 @@ function MotorJoint:setAngularOffset(angleoffset) end --- ---Sets the target linear offset between the two Bodies the Joint is attached to. --- -function MotorJoint:setLinearOffset() end +---@param x number # The x component of the target linear offset, relative to the first Body. +---@param y number # The y component of the target linear offset, relative to the first Body. +function MotorJoint:setLinearOffset(x, y) end --- ---For controlling objects with the mouse. @@ -1448,11 +1528,14 @@ function MouseJoint:getFrequency() end --- ---Gets the highest allowed force. --- +---@return number f # The max allowed force. function MouseJoint:getMaxForce() end --- ---Gets the target point. --- +---@return number x # The x-component of the target. +---@return number y # The x-component of the target. function MouseJoint:getTarget() end --- @@ -1470,12 +1553,15 @@ function MouseJoint:setFrequency(freq) end --- ---Sets the highest allowed force. --- -function MouseJoint:setMaxForce() end +---@param f number # The max allowed force. +function MouseJoint:setMaxForce(f) end --- ---Sets the target point. --- -function MouseJoint:setTarget() end +---@param x number # The x-component of the target. +---@param y number # The y-component of the target. +function MouseJoint:setTarget(x, y) end --- ---A PolygonShape is a convex polygon with up to 8 vertices. @@ -1509,16 +1595,20 @@ function PrismaticJoint:areLimitsEnabled() end --- ---Gets the world-space axis vector of the Prismatic Joint. --- +---@return number x # The x-axis coordinate of the world-space axis vector. +---@return number y # The y-axis coordinate of the world-space axis vector. function PrismaticJoint:getAxis() end --- ---Get the current joint angle speed. --- +---@return number s # Joint angle speed in meters/second. function PrismaticJoint:getJointSpeed() end --- ---Get the current joint translation. --- +---@return number t # Joint translation, usually in meters.. function PrismaticJoint:getJointTranslation() end --- @@ -1537,6 +1627,7 @@ function PrismaticJoint:getLowerLimit() end --- ---Gets the maximum motor force. --- +---@return number f # The maximum motor force, usually in N. function PrismaticJoint:getMaxMotorForce() end --- @@ -1549,6 +1640,7 @@ function PrismaticJoint:getMotorForce(invdt) end --- ---Gets the motor speed. --- +---@return number s # The motor speed, usually in meters per second. function PrismaticJoint:getMotorSpeed() end --- @@ -1585,7 +1677,8 @@ function PrismaticJoint:setLowerLimit(lower) end --- ---Set the maximum motor force. --- -function PrismaticJoint:setMaxMotorForce() end +---@param f number # The maximum motor force, usually in N. +function PrismaticJoint:setMaxMotorForce(f) end --- ---Enables/disables the joint motor. @@ -1596,7 +1689,8 @@ function PrismaticJoint:setMotorEnabled(enable) end --- ---Sets the motor speed. --- -function PrismaticJoint:setMotorSpeed() end +---@param s number # The motor speed, usually in meters per second. +function PrismaticJoint:setMotorSpeed(s) end --- ---Sets the upper limit. @@ -1694,6 +1788,7 @@ function RevoluteJoint:getJointAngle() end --- ---Get the current joint angle speed. --- +---@return number s # Joint angle speed in radians/second. function RevoluteJoint:getJointSpeed() end --- @@ -1712,16 +1807,19 @@ function RevoluteJoint:getLowerLimit() end --- ---Gets the maximum motor force. --- +---@return number f # The maximum motor force, in Nm. function RevoluteJoint:getMaxMotorTorque() end --- ---Gets the motor speed. --- +---@return number s # The motor speed, radians per second. function RevoluteJoint:getMotorSpeed() end --- ---Get the current motor force. --- +---@return number f # The current motor force, in Nm. function RevoluteJoint:getMotorTorque() end --- @@ -1764,7 +1862,8 @@ function RevoluteJoint:setLowerLimit(lower) end --- ---Set the maximum motor force. --- -function RevoluteJoint:setMaxMotorTorque() end +---@param f number # The maximum motor force, in Nm. +function RevoluteJoint:setMaxMotorTorque(f) end --- ---Enables/disables the joint motor. @@ -1775,7 +1874,8 @@ function RevoluteJoint:setMotorEnabled(enable) end --- ---Sets the motor speed. --- -function RevoluteJoint:setMotorSpeed() end +---@param s number # The motor speed, radians per second. +function RevoluteJoint:setMotorSpeed(s) end --- ---Sets the upper limit. @@ -1817,7 +1917,7 @@ local Shape = {} ---@param tx number # The translation of the shape on the x-axis. ---@param ty number # The translation of the shape on the y-axis. ---@param tr number # The shape rotation. ----@param childIndex number # The index of the child to compute the bounding box of. +---@param childIndex? number # The index of the child to compute the bounding box of. ---@return number topLeftX # The x position of the top-left point. ---@return number topLeftY # The y position of the top-left point. ---@return number bottomRightX # The x position of the bottom-right point. @@ -1828,6 +1928,8 @@ function Shape:computeAABB(tx, ty, tr, childIndex) end ---Computes the mass properties for the shape with the specified density. --- ---@param density number # The shape density. +---@return number x # The x postition of the center of mass. +---@return number y # The y postition of the center of mass. ---@return number mass # The mass of the shape. ---@return number inertia # The rotational inertia. function Shape:computeMass(density) end @@ -1871,7 +1973,7 @@ function Shape:getType() end ---@param tx number # The translation of the shape on the x-axis. ---@param ty number # The translation of the shape on the y-axis. ---@param tr number # The shape rotation. ----@param childIndex number # The index of the child the ray gets cast against. +---@param childIndex? number # The index of the child the ray gets cast against. ---@return number xn # The x component of the normal vector of the edge where the ray hit the shape. ---@return number yn # The y component of the normal vector of the edge where the ray hit the shape. ---@return number fraction # The position on the input line where the intersection happened as a factor of the line length. @@ -1883,8 +1985,10 @@ function Shape:rayCast(x1, y1, x2, y2, maxFraction, tx, ty, tr, childIndex) end ---@param tx number # Translates the shape along the x-axis. ---@param ty number # Translates the shape along the y-axis. ---@param tr number # Rotates the shape. +---@param x number # The x-component of the point. +---@param y number # The y-component of the point. ---@return boolean hit # True if inside, false if outside -function Shape:testPoint(tx, ty, tr) end +function Shape:testPoint(tx, ty, tr, x, y) end --- ---A WeldJoint essentially glues two bodies together. @@ -1925,6 +2029,8 @@ local WheelJoint = {} --- ---Gets the world-space axis vector of the Wheel Joint. --- +---@return number x # The x-axis coordinate of the world-space axis vector. +---@return number y # The y-axis coordinate of the world-space axis vector. function WheelJoint:getAxis() end --- @@ -2022,6 +2128,7 @@ function World:getBodies() end --- ---Returns the number of bodies in the world. --- +---@return number n # The number of bodies in the world. function World:getBodyCount() end --- @@ -2036,6 +2143,7 @@ function World:getCallbacks() end --- ---Returns the number of contacts in the world. --- +---@return number n # The number of contacts in the world. function World:getContactCount() end --- @@ -2053,11 +2161,14 @@ function World:getContacts() end --- ---Get the gravity of the world. --- +---@return number x # The x component of gravity. +---@return number y # The y component of gravity. function World:getGravity() end --- ---Returns the number of joints in the world. --- +---@return number n # The number of joints in the world. function World:getJointCount() end --- @@ -2100,11 +2211,13 @@ function World:queryBoundingBox(topLeftX, topLeftY, bottomRightX, bottomRightY, ---Casts a ray and calls a function for each fixtures it intersects. --- ---@param fixture love.Fixture # The fixture intersecting the ray. +---@param x number # The x position of the intersection point. +---@param y number # The y position of the intersection point. ---@param xn number # The x value of the surface normal vector of the shape edge. ---@param yn number # The y value of the surface normal vector of the shape edge. ---@param fraction number # The position of the intersection on the ray as a number from 0 to 1 (or even higher if the ray length was changed with the return value). ---@return number control # The ray can be controlled with the return value. A positive value sets a new ray length where 1 is the default value. A value of 0 terminates the ray. If the callback function returns -1, the intersection gets ignored as if it didn't happen. -function World:rayCast(fixture, xn, yn, fraction) end +function World:rayCast(fixture, x, y, xn, yn, fraction) end --- ---Sets functions for the collision callbacks during the world update. @@ -2132,7 +2245,9 @@ function World:setContactFilter(filter) end --- ---Set the gravity of the world. --- -function World:setGravity() end +---@param x number # The x component of gravity. +---@param y number # The y component of gravity. +function World:setGravity(x, y) end --- ---Sets the sleep behaviour of the world. @@ -2143,14 +2258,16 @@ function World:setSleepingAllowed(allow) end --- ---Translates the World's origin. Useful in large worlds where floating point precision issues become noticeable at far distances from the origin. --- -function World:translateOrigin() end +---@param x number # The x component of the new origin with respect to the old origin. +---@param y number # The y component of the new origin with respect to the old origin. +function World:translateOrigin(x, y) end --- ---Update the state of the world. --- ---@param dt number # The time (in seconds) to advance the physics simulation. ----@param velocityiterations number # The maximum number of steps used to determine the new velocities when resolving a collision. ----@param positioniterations number # The maximum number of steps used to determine the new positions when resolving a collision. +---@param velocityiterations? number # The maximum number of steps used to determine the new velocities when resolving a collision. +---@param positioniterations? number # The maximum number of steps used to determine the new positions when resolving a collision. function World:update(dt, velocityiterations, positioniterations) end --- diff --git a/meta/3rd/love2d/library/love.sound.lua b/meta/3rd/love2d/library/love.sound.lua index 8e1786e8..2dd18b6d 100644 --- a/meta/3rd/love2d/library/love.sound.lua +++ b/meta/3rd/love2d/library/love.sound.lua @@ -11,7 +11,7 @@ love.sound = {} --- ---@overload fun(filename: string, buffer: number):love.Decoder ---@param file love.File # The file with encoded sound data. ----@param buffer number # The size of each decoded chunk, in bytes. +---@param buffer? number # The size of each decoded chunk, in bytes. ---@return love.Decoder decoder # A new Decoder object. function love.sound.newDecoder(file, buffer) end @@ -95,8 +95,9 @@ function SoundData:getDuration() end ---Gets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order. --- ---@overload fun(i: number, channel: number):number +---@param i number # An integer value specifying the position of the sample (starting at 0). ---@return number sample # The normalized samplepoint (range -1.0 to 1.0). -function SoundData:getSample() end +function SoundData:getSample(i) end --- ---Returns the number of samples per channel of the SoundData. @@ -114,5 +115,6 @@ function SoundData:getSampleRate() end ---Sets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order. --- ---@overload fun(i: number, channel: number, sample: number) +---@param i number # An integer value specifying the position of the sample (starting at 0). ---@param sample number # The normalized samplepoint (range -1.0 to 1.0). -function SoundData:setSample(sample) end +function SoundData:setSample(i, sample) end diff --git a/meta/3rd/love2d/library/love.system.lua b/meta/3rd/love2d/library/love.system.lua index a3c41df3..2419688a 100644 --- a/meta/3rd/love2d/library/love.system.lua +++ b/meta/3rd/love2d/library/love.system.lua @@ -56,7 +56,7 @@ function love.system.setClipboardText(text) end --- ---Causes the device to vibrate, if possible. Currently this will only work on Android and iOS devices that have a built-in vibration motor. --- ----@param seconds number # The duration to vibrate for. If called on an iOS device, it will always vibrate for 0.5 seconds due to limitations in the iOS system APIs. +---@param seconds? number # The duration to vibrate for. If called on an iOS device, it will always vibrate for 0.5 seconds due to limitations in the iOS system APIs. function love.system.vibrate(seconds) end --- diff --git a/meta/3rd/love2d/library/love.timer.lua b/meta/3rd/love2d/library/love.timer.lua index c675072d..ad9e9771 100644 --- a/meta/3rd/love2d/library/love.timer.lua +++ b/meta/3rd/love2d/library/love.timer.lua @@ -35,7 +35,8 @@ function love.timer.getTime() end --- ---Pauses the current thread for the specified amount of time. --- -function love.timer.sleep() end +---@param s number # Seconds to sleep for. +function love.timer.sleep(s) end --- ---Measures the time between two frames. diff --git a/meta/3rd/love2d/library/love.touch.lua b/meta/3rd/love2d/library/love.touch.lua index e36744e3..793eb5ac 100644 --- a/meta/3rd/love2d/library/love.touch.lua +++ b/meta/3rd/love2d/library/love.touch.lua @@ -10,6 +10,8 @@ love.touch = {} ---Gets the current position of the specified touch-press, in pixels. --- ---@param id lightuserdata # The identifier of the touch-press. Use love.touch.getTouches, love.touchpressed, or love.touchmoved to obtain touch id values. +---@return number x # The position along the x-axis of the touch-press inside the window, in pixels. +---@return number y # The position along the y-axis of the touch-press inside the window, in pixels. function love.touch.getPosition(id) end --- diff --git a/meta/3rd/love2d/library/love.window.lua b/meta/3rd/love2d/library/love.window.lua index beff6623..359ffdbe 100644 --- a/meta/3rd/love2d/library/love.window.lua +++ b/meta/3rd/love2d/library/love.window.lua @@ -40,7 +40,7 @@ function love.window.getDPIScale() end --- ---Gets the width and height of the desktop. --- ----@param displayindex number # The index of the display, if multiple monitors are available. +---@param displayindex? number # The index of the display, if multiple monitors are available. ---@return string width # The width of the desktop. ---@return string height # The height of the desktop. function love.window.getDesktopDimensions(displayindex) end @@ -54,14 +54,14 @@ function love.window.getDisplayCount() end --- ---Gets the name of a display. --- ----@param displayindex number # The index of the display to get the name of. +---@param displayindex? number # The index of the display to get the name of. ---@return string name # The name of the specified display. function love.window.getDisplayName(displayindex) end --- ---Gets current device display orientation. --- ----@param displayindex number # Display index to get its display orientation, or nil for default display index. +---@param displayindex? number # Display index to get its display orientation, or nil for default display index. ---@return love.DisplayOrientation orientation # Current device display orientation. function love.window.getDisplayOrientation(displayindex) end @@ -75,7 +75,7 @@ function love.window.getFullscreen() end --- ---Gets a list of supported fullscreen modes. --- ----@param displayindex number # The index of the display, if multiple monitors are available. +---@param displayindex? number # The index of the display, if multiple monitors are available. ---@return table modes # A table of width/height pairs. (Note that this may not be in order.) function love.window.getFullscreenModes(displayindex) end @@ -98,12 +98,18 @@ function love.window.getMode() end --- ---The window position is in the coordinate space of the display it is currently in. --- +---@return number x # The x-coordinate of the window's position. +---@return number y # The y-coordinate of the window's position. ---@return number displayindex # The index of the display that the window is in. function love.window.getPosition() end --- ---Gets area inside the window which is known to be unobstructed by a system title bar, the iPhone X notch, etc. Useful for making sure UI elements can be seen by the user. --- +---@return number x # Starting position of safe area (x-axis). +---@return number y # Starting position of safe area (y-axis). +---@return number w # Width of safe area. +---@return number h # Height of safe area. function love.window.getSafeArea() end --- @@ -183,7 +189,7 @@ function love.window.minimize() end --- ---In Windows the taskbar icon will flash, and in OS X the dock icon will bounce. --- ----@param continuous boolean # Whether to continuously request attention until the window becomes active, or to do it only once. +---@param continuous? boolean # Whether to continuously request attention until the window becomes active, or to do it only once. function love.window.requestAttention(continuous) end --- @@ -232,8 +238,10 @@ function love.window.setMode(width, height, flags) end --- ---The window position is in the coordinate space of the specified display. --- ----@param displayindex number # The index of the display that the new window position is relative to. -function love.window.setPosition(displayindex) end +---@param x number # The x-coordinate of the window's position. +---@param y number # The y-coordinate of the window's position. +---@param displayindex? number # The index of the display that the new window position is relative to. +function love.window.setPosition(x, y, displayindex) end --- ---Sets the window title. @@ -253,8 +261,8 @@ function love.window.setVSync(vsync) end ---@overload fun(title: string, message: string, buttonlist: table, type: love.MessageBoxType, attachtowindow: boolean):number ---@param title string # The title of the message box. ---@param message string # The text inside the message box. ----@param type love.MessageBoxType # The type of the message box. ----@param attachtowindow boolean # Whether the message box should be attached to the love window or free-floating. +---@param type? love.MessageBoxType # The type of the message box. +---@param attachtowindow? boolean # Whether the message box should be attached to the love window or free-floating. ---@return boolean success # Whether the message box was successfully displayed. function love.window.showMessageBox(title, message, type, attachtowindow) end diff --git a/meta/3rd/skynet/library/skynet.lua b/meta/3rd/skynet/library/skynet.lua index 4fdb29d0..2ce96339 100644 --- a/meta/3rd/skynet/library/skynet.lua +++ b/meta/3rd/skynet/library/skynet.lua @@ -12,35 +12,35 @@ ---|+'"debug"' ---|+'"trace"' ---@alias SERVICEADDR '".servicename"' | '":0000000C"' | integer ----@alias MESSAGEHANDLER fun(session:integer, source:integer, ...) +---@alias MESSAGEHANDLER fun(session:integer, source:integer, cmd:string, ...) local skynet = { - -- read skynet.h - PTYPE_TEXT = 0, - PTYPE_RESPONSE = 1, - PTYPE_MULTICAST = 2, - PTYPE_CLIENT = 3, - PTYPE_SYSTEM = 4, - PTYPE_HARBOR = 5, - PTYPE_SOCKET = 6, - PTYPE_ERROR = 7, - PTYPE_QUEUE = 8, -- used in deprecated mqueue, use skynet.queue instead - PTYPE_DEBUG = 9, - PTYPE_LUA = 10, - PTYPE_SNAX = 11, - PTYPE_TRACE = 12, -- use for debug trace - PNAME_TEXT = "text", - PNAME_RESPONSE = "response", - PNAME_MULTICAST = "muliticast", - PNAME_CLIENT = "client", - PNAME_SYSTEM = "system", - PNAME_HARBOR = "harbor", - PNAME_SOCKET = "socket", - PNAME_ERROR = "error", - PNAME_QUEUE = "queue", - PNAME_DEBUG = "debug", - PNAME_LUA = "lua", - PNAME_SNAX = "snax", - PNAME_TRACE = "trace", + -- read skynet.h + PTYPE_TEXT = 0, + PTYPE_RESPONSE = 1, + PTYPE_MULTICAST = 2, + PTYPE_CLIENT = 3, + PTYPE_SYSTEM = 4, + PTYPE_HARBOR = 5, + PTYPE_SOCKET = 6, + PTYPE_ERROR = 7, + PTYPE_QUEUE = 8, -- used in deprecated mqueue, use skynet.queue instead + PTYPE_DEBUG = 9, + PTYPE_LUA = 10, + PTYPE_SNAX = 11, + PTYPE_TRACE = 12, -- use for debug trace + PNAME_TEXT = "text", + PNAME_RESPONSE = "response", + PNAME_MULTICAST = "muliticast", + PNAME_CLIENT = "client", + PNAME_SYSTEM = "system", + PNAME_HARBOR = "harbor", + PNAME_SOCKET = "socket", + PNAME_ERROR = "error", + PNAME_QUEUE = "queue", + PNAME_DEBUG = "debug", + PNAME_LUA = "lua", + PNAME_SNAX = "snax", + PNAME_TRACE = "trace", } @@ -97,9 +97,12 @@ end ---* 向当前会话返回数据 ---* 会自动获取当前线程所关联的会话ID和返回地址 ----* 由于某些历史原因(早期的 skynet 默认消息类别是文本,而没有经过特殊编码),这个 API 被设计成传递一个 C 指针和长度,而不是经过当前消息的 pack 函数打包。或者你也可以省略 size 而传入一个字符串。 +---* 由于某些历史原因(早期的 skynet 默认消息类别是文本,而没有经过特殊编码), +---这个 API 被设计成传递一个 C 指针和长度,而不是经过当前消息的 pack 函数打包。或者你也可以省略 size 而传入一个字符串。 ---* 在同一个消息处理的 coroutine 中只可以被调用一次,多次调用会触发异常。 ----* 你需要挂起一个请求,等将来时机满足,再回应它。而回应的时候已经在别的 coroutine 中了。针对这种情况,你可以调用 skynet.response(skynet.pack) 获得一个闭包,以后调用这个闭包即可把回应消息发回。这里的参数 skynet.pack 是可选的,你可以传入其它打包函数,默认即是 skynet.pack 。 +---* 你需要挂起一个请求,等将来时机满足,再回应它。而回应的时候已经在别的 coroutine 中了。 +---针对这种情况,你可以调用 skynet.response(skynet.pack) 获得一个闭包,以后调用这个闭包即可把回应消息发回。 +---这里的参数 skynet.pack 是可选的,你可以传入其它打包函数,默认即是 skynet.pack 。 ---@param msg lightuserdata ---@param sz integer function skynet.ret(msg, sz) @@ -110,8 +113,8 @@ function skynet.retpack(...) end ---返回一个闭包以进行延迟回应 ----@param pack fun(...):string| userdata,sz ----@return fun(isOK:boolean | 'TEST', ...): +---@param pack fun(...):string|lightuserdata,integer #默认会用 skynet.pack +---@return fun(isOK:boolean | 'TEST', ...) function skynet.response(pack) end @@ -138,7 +141,9 @@ end --------------------序列化相关API--------------- ---* 可以将一组 lua 对象序列化为一个由 malloc 分配出来的 C 指针加一个数字长度 ----* 你需要考虑 C 指针引用的数据块何时释放的问题。当然,如果你只是将 skynet.pack 填在消息处理框架里时,框架解决了这个管理问题。skynet 将 C 指针发送到其他服务,而接收方会在使用完后释放这个指针。 +---* 你需要考虑 C 指针引用的数据块何时释放的问题。当然,如果你只是将 skynet.pack 填在消息 +--- 处理框架里时,框架解决了这个管理问题。skynet 将 C 指针发送到其他服务,而接收方会在使用完 +--- 后释放这个指针。 ---@vararg any ---@return lightuserdata, number function skynet.pack(...) @@ -159,8 +164,8 @@ function skynet.unpack(msg, sz) end ---* 将 C 指针转换成 Lua 字符串 ----@param msg lightuserdata ----@param sz number +---@param msg lightuserdata|string +---@param sz number #如果是传递的 string,则不需要 此参数 ---@return string function skynet.tostring(msg, sz) end @@ -176,7 +181,8 @@ end ---* **非阻塞API** ---* 这条 API 可以把一条类别为 typename 的消息发送给 address 。它会先经过事先注册的 pack 函数打包 ... 的内容。 ---* 实际上也是利用了 c.send 不过传送的会话ID是0 ----* 接收端接收完毕消息后,默认情况下,消息会由 skynet 释放。具体可以查看 skynet-server.c 中的 dispatch_message 的代码 +---* 接收端接收完毕消息后,默认情况下,消息会由 skynet 释放。 +--- 具体可以查看 skynet-server.c 中的 dispatch_message 的代码 ---@param addr SERVICEADDR ---@param typename string @类型名 ---@vararg any @传输的数据 @@ -239,7 +245,7 @@ end function request:select(timeout) end ----@param obj? +---@param obj? table ---@return request function skynet.request(obj) end @@ -286,6 +292,8 @@ end --- 用于启动一个新的 Lua 服务。name 是脚本的名字(不用写 .lua 后缀)。只有被启动的脚本的 start 函数返回后,这个 API 才会返回启动的服务的地址,这是一个阻塞 API 。如果被启动的脚本在初始化环节抛出异常,或在初始化完成前就调用 skynet.exit 退出,skynet.newservice 都会抛出异常。如果被启动的脚本的 start 函数是一个永不结束的循环,那么 newservice 也会被永远阻塞住。 --- > 启动参数其实是以字符串拼接的方式传递过去的。所以不要在参数中传递复杂的 Lua 对象。接收到的参数都是字符串,且字符串中不可以有空格(否则会被分割成多个参数)。这种参数传递方式是历史遗留下来的,有很多潜在的问题。目前推荐的惯例是,让你的服务响应一个启动消息。在 newservice 之后,立刻调用 skynet.call 发送启动请求。 +---@param name string #脚本名字 +---@vararg string #可选参数 function skynet.newservice(name, ...) end @@ -475,25 +483,31 @@ function skynet.memlimit(bytes) end ------------------以下是属于 skynet.manager 中的 api + +---* **skynet.manager API** ---* 启动一个C 服务,具体参数要看 C服务是怎么编写的 ---@vararg any function skynet.launch(...) end +---* **skynet.manager API** --- 可以用来强制关闭别的服务。但强烈不推荐这样做。因为对象会在任意一条消息处理完毕后,毫无征兆的退出。所以推荐的做法是,发送一条消息,让对方自己善后以及调用 skynet.exit 。注:skynet.kill(skynet.self()) 不完全等价于 skynet.exit() ,后者更安全。 ---@param name number|string function skynet.kill(name) end +---* **skynet.manager API** ---* 向引擎发送一个 ABORT 命令,退出自身服务 function skynet.abort() end +---* **skynet.manager API** ---* 给服务注册一个名字 ---@param name string function skynet.register(name) end +---* **skynet.manager API** ---* 给服务命名 以 . 开头的名字是在同一 skynet 节点下有效的 ---* skynet.name(name, skynet.self()) 和 skynet.register(name) 功能等价。 ---@param name string @@ -501,6 +515,7 @@ end function skynet.name(name, handle) end +---* **skynet.manager API** ---* 将本服务实现为消息转发器,对一类消息进行转发 ---* 设置指定类型的消息,不由 skynet 框架释放 ---* 对于在 map 中的消息,不进行释放 @@ -510,12 +525,14 @@ end function skynet.forward_type(map, start_func) end +---* **skynet.manager API** ---过滤消息再处理。(注:filter 可以将 type, msg, sz, session, source 五个参数先处理过再返回新的 5 个参数。) ---@param f any ---@param start_func any function skynet.filter(f, start_func) end +---* **skynet.manager API** ---给当前 skynet 进程设置一个全局的服务监控。 ---@param service any ---@param query any diff --git a/script/config/config.lua b/script/config/config.lua index 461ec260..8661e0d0 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -151,6 +151,7 @@ local Template = { "?.lua", "?/init.lua", }, + ['Lua.runtime.pathStrict'] = Type.Boolean >> false, ['Lua.runtime.special'] = Type.Hash(Type.String, Type.String), ['Lua.runtime.meta'] = Type.String >> '${version} ${language} ${encoding}', ['Lua.runtime.unicodeName'] = Type.Boolean, diff --git a/script/core/command/autoRequire.lua b/script/core/command/autoRequire.lua index aa641967..ca8826d7 100644 --- a/script/core/command/autoRequire.lua +++ b/script/core/command/autoRequire.lua @@ -135,7 +135,7 @@ return function (data) end local path = furi.decode(target) - local visiblePaths = rpath.getVisiblePath(path, config.get 'Lua.runtime.path') + local visiblePaths = rpath.getVisiblePath(path) if not visiblePaths or #visiblePaths == 0 then return end diff --git a/script/core/completion.lua b/script/core/completion.lua index 74017ec6..8b31614d 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -885,7 +885,7 @@ local function collectRequireNames(mode, myUri, literal, source, smark, position goto CONTINUE end local path = workspace.getRelativePath(uri) - local infos = rpath.getVisiblePath(path, config.get 'Lua.runtime.path') + local infos = rpath.getVisiblePath(path) for _, info in ipairs(infos) do if matchKey(literal, info.expect) then if not collect[info.expect] then diff --git a/script/core/diagnostics/redundant-return.lua b/script/core/diagnostics/redundant-return.lua new file mode 100644 index 00000000..486db6cd --- /dev/null +++ b/script/core/diagnostics/redundant-return.lua @@ -0,0 +1,27 @@ +local files = require 'files' +local guide = require 'parser.guide' +local lang = require 'language' +local define = require 'proto.define' + +-- reports 'return' without any return values at the end of functions +return function (uri, callback) + local ast = files.getState(uri) + if not ast then + return + end + + guide.eachSourceType(ast.ast, 'return', function (source) + if not source.parent or source.parent.type ~= "function" then + return + end + if #source > 0 then + return + end + callback { + start = source.start, + finish = source.finish, + tags = { define.DiagnosticTag.Unnecessary }, + message = lang.script.DIAG_REDUNDANT_RETURN, + } + end) +end diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua index 0f0d85e0..49f9536a 100644 --- a/script/core/hover/return.lua +++ b/script/core/hover/return.lua @@ -54,6 +54,13 @@ local function asFunction(source) line[#line+1] = ('% 3d. '):format(i) end for n = 1, #rtn do + if rtn[n].type == 'doc.type' then + for _, typeUnit in ipairs(rtn[n].types) do + if typeUnit[1] == 'nil' then + infers['nil'] = true + end + end + end local values = infer.searchInfers(rtn[n]) for tp in pairs(values) do infers[tp] = true diff --git a/script/core/infer.lua b/script/core/infer.lua index ab297209..6e667e65 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -216,7 +216,6 @@ local function searchLiteralOfValue(value, literals, mark) end end end - return end local function bindClassOrType(source) diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 4d72b038..c5180a54 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -960,6 +960,7 @@ function m.searchRefsByID(status, suri, expect, mode) end search(suri, expect, nil) + flushGeneric() end local function prepareSearch(source) diff --git a/script/encoder/utf16be.lua b/script/encoder/utf16be.lua index 179a676d..5fc19b2c 100644 --- a/script/encoder/utf16be.lua +++ b/script/encoder/utf16be.lua @@ -8,7 +8,7 @@ local function tobyte(s, i) end local function char(code) - if code <= 0xffff then + if code <= 0xFFFF then return tochar(code) end code = code - 0x10000 @@ -19,7 +19,7 @@ local m = {} function m.encode(s) local r = {} - for _, c in utf8.codes(s) do + for _, c in utf8.codes(s, true) do r[#r+1] = char(c) end return table.concat(r) @@ -30,13 +30,13 @@ function m.decode(s) local i = 1 while i < #s do local code1 = tobyte(s, i) - if code1 < 0xD800 then - r[#r+1] = utf8.char(code1) - else + if code1 >= 0xD800 and code1 < 0xE000 then i = i + 2 local code2 = tobyte(s, i) local code = 0x10000 + ((code1 - 0xD800) << 10) + ((code2 - 0xDC00) & 0x3FF) r[#r+1] = utf8.char(code) + else + r[#r+1] = utf8.char(code1) end i = i + 2 end diff --git a/script/encoder/utf16le.lua b/script/encoder/utf16le.lua index cfbc33c2..d51b4cfb 100644 --- a/script/encoder/utf16le.lua +++ b/script/encoder/utf16le.lua @@ -8,7 +8,7 @@ local function tobyte(s, i) end local function char(code) - if code <= 0xffff then + if code <= 0xFFFF then return tochar(code) end code = code - 0x10000 @@ -19,7 +19,7 @@ local m = {} function m.encode(s) local r = {} - for _, c in utf8.codes(s) do + for _, c in utf8.codes(s, true) do r[#r+1] = char(c) end return table.concat(r) @@ -30,13 +30,13 @@ function m.decode(s) local i = 1 while i < #s do local code1 = tobyte(s, i) - if code1 < 0xD800 then - r[#r+1] = utf8.char(code1) - else + if code1 >= 0xD800 and code1 < 0xE000 then i = i + 2 local code2 = tobyte(s, i) local code = 0x10000 + ((code1 - 0xD800) << 10) + ((code2 - 0xDC00) & 0x3FF) r[#r+1] = utf8.char(code) + else + r[#r+1] = utf8.char(code1) end i = i + 2 end diff --git a/script/files.lua b/script/files.lua index 4d649b29..29a66d48 100644 --- a/script/files.lua +++ b/script/files.lua @@ -120,10 +120,15 @@ end --- 设置文件文本 ---@param uri uri ---@param text string -function m.setText(uri, text, isTrust, instance) +function m.setText(uri, text, isTrust) if not text then return end + if #text > 1024 * 1024 * 100 then + local client = require 'client' + client.showMessage('Warning', lang.script('WORKSPACE_SKIP_HUGE_FILE', uri)) + return + end --log.debug('setText', uri) local create if not m.fileMap[uri] then diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index ca0bc66a..0b721a7a 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -1639,6 +1639,30 @@ local function parseTable() return tbl end +local function addDummySelf(node, call) + if node.type ~= 'getmethod' then + return + end + -- dummy param `self` + if not call.args then + call.args = { + type = 'callargs', + start = call.start, + finish = call.finish, + parent = call, + } + end + local newNode = {} + for k, v in next, call.node.node do + newNode[k] = v + end + newNode.mirror = call.node.node + newNode.dummy = true + newNode.parent = call.args + call.node.node.mirror = newNode + tinsert(call.args, 1, newNode) +end + local function parseSimple(node, funcName) local lastMethod while true do @@ -1740,26 +1764,7 @@ local function parseSimple(node, funcName) args.parent = call call.args = args end - if node.type == 'getmethod' then - -- dummy param `self` - if not call.args then - call.args = { - type = 'callargs', - start = call.start, - finish = call.finish, - parent = call, - } - end - local newNode = {} - for k, v in next, call.node.node do - newNode[k] = v - end - newNode.mirror = call.node.node - newNode.dummy = true - newNode.parent = call.args - call.node.node.mirror = newNode - tinsert(call.args, 1, newNode) - end + addDummySelf(node, call) node.parent = call node = call elseif token == '{' then @@ -1781,6 +1786,7 @@ local function parseSimple(node, funcName) [1] = tbl, } call.args = args + addDummySelf(node, call) tbl.parent = args node.parent = call node = call @@ -1803,6 +1809,7 @@ local function parseSimple(node, funcName) [1] = str, } call.args = args + addDummySelf(node, call) str.parent = args node.parent = call node = call @@ -1826,6 +1833,7 @@ local function parseSimple(node, funcName) [1] = str, } call.args = args + addDummySelf(node, call) str.parent = args node.parent = call node = call diff --git a/script/plugin.lua b/script/plugin.lua index 26f39226..26e99d53 100644 --- a/script/plugin.lua +++ b/script/plugin.lua @@ -100,7 +100,7 @@ function m.init() m.showError(err) return end - if not checkTrustLoad() then + if not client.isVSCode() and not checkTrustLoad() then return end local suc, err = xpcall(f, log.error, f) diff --git a/script/proto/define.lua b/script/proto/define.lua index 63153423..713857af 100644 --- a/script/proto/define.lua +++ b/script/proto/define.lua @@ -29,6 +29,7 @@ m.DiagnosticDefaultSeverity = { ['newline-call'] = 'Information', ['newfield-call'] = 'Warning', ['redundant-parameter'] = 'Warning', + ['redundant-return'] = 'Warning', ['ambiguity-1'] = 'Warning', ['lowercase-global'] = 'Information', ['undefined-env-child'] = 'Information', @@ -82,6 +83,7 @@ m.DiagnosticDefaultNeededFileStatus = { ['newline-call'] = 'Any', ['newfield-call'] = 'Any', ['redundant-parameter'] = 'Opened', + ['redundant-return'] = 'Opened', ['ambiguity-1'] = 'Any', ['lowercase-global'] = 'Any', ['undefined-env-child'] = 'Any', diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua index 2ec2918c..e2149bac 100644 --- a/script/workspace/require-path.lua +++ b/script/workspace/require-path.lua @@ -27,7 +27,9 @@ local function getOnePath(path, searcher) return nil end -function m.getVisiblePath(path, searchers, strict) +function m.getVisiblePath(path) + local searchers = config.get 'Lua.runtime.path' + local strict = config.get 'Lua.runtime.pathStrict' path = path:gsub('^[/\\]+', '') local uri = furi.encode(path) local libraryPath = files.getLibraryPath(uri) @@ -91,7 +93,9 @@ files.watch(function (ev) end) config.watch(function (key, value, oldValue) - if key == 'Lua.completion.requireSeparator' then + if key == 'Lua.completion.requireSeparator' + or key == 'Lua.runtime.path' + or key == 'Lua.runtime.pathStrict' then m.flush() end end) diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index 5b87b2bb..726bec09 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -246,7 +246,7 @@ local function loadFileFactory(root, progressData, isLibrary) log.info('++++As library of:', root) files.setLibraryPath(uri, root) end - files.setText(uri, text, false, true) + files.setText(uri, text, false) else files.remove(uri) end @@ -391,17 +391,22 @@ function m.findUrisByFilePath(path) return resultCache[path].results, resultCache[path].posts end tracy.ZoneBeginN('findUrisByFilePath #1') + local strict = config.get 'Lua.runtime.pathStrict' local results = {} local posts = {} for uri in files.eachFile() do if not uri:find(lpath, 1, true) then goto CONTINUE end + local relat = m.getRelativePath(uri) local pathLen = #path - local curPath = furi.decode(uri) + local curPath = relat local curLen = #curPath local seg = curPath:sub(curLen - pathLen, curLen - pathLen) if seg == '/' or seg == '\\' or seg == '' then + if strict and seg ~= '' then + goto CONTINUE + end local see = curPath:sub(curLen - pathLen + 1, curLen) if see == path then results[#results+1] = uri diff --git a/test/completion/init.lua b/test/completion/init.lua index 051c288c..58885149 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -83,9 +83,11 @@ function TEST(script) assert(result ~= nil) result.enableCommon = nil for _, item in ipairs(result) do - local r = core.resolve(item.id) - for k, v in pairs(r or {}) do - item[k] = v + if item.id then + local r = core.resolve(item.id) + for k, v in pairs(r or {}) do + item[k] = v + end end for k in pairs(item) do if not Cared[k] then diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua index 455f0600..27acb15d 100644 --- a/test/crossfile/completion.lua +++ b/test/crossfile/completion.lua @@ -87,7 +87,7 @@ function TEST(data) local pos for _, info in ipairs(data) do local uri = furi.encode(info.path) - local script = info.content + local script = info.content or '' if info.main then local newScript, catched = catch(script, '?') pos = catched['?'][1][1] @@ -108,9 +108,11 @@ function TEST(data) result.enableCommon = nil removeMetas(result) for _, item in ipairs(result) do - local r = core.resolve(item.id) - for k, v in pairs(r or {}) do - item[k] = v + if item.id then + local r = core.resolve(item.id) + for k, v in pairs(r or {}) do + item[k] = v + end end for k in pairs(item) do if not Cared[k] then @@ -563,8 +565,114 @@ TEST { ]], main = true, }, + completion = nil, +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require '<??>' + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require 'a<??>' + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +config.set('Lua.runtime.pathStrict', true) + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require '<??>' + ]], + main = true, + }, + completion = { + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require 'a<??>' + ]], + main = true, + }, + completion = { + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } } +config.set('Lua.runtime.pathStrict', false) + TEST { { path = 'xxx.lua', diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index 37c10db6..862d95e8 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -117,6 +117,31 @@ TEST { }, } +config.set('Lua.runtime.pathStrict', true) +TEST { + { + path = 'aaa/bbb.lua', + content = '', + }, + { + path = 'b.lua', + content = 'require "<?bbb?>"', + }, +} + +TEST { + { + path = 'aaa/bbb.lua', + content = '<!!>', + }, + { + path = 'b.lua', + content = 'require "<?aaa.bbb?>"', + }, +} + +config.set('Lua.runtime.pathStrict', false) + TEST { { path = 'a.lua', diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index b1c4c804..35528446 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -40,7 +40,7 @@ end function TEST(expect) files.removeAll() - local targetScript = expect[1].content + local targetScript, targetList = catch(expect[1].content, '?') local targetUri = furi.encode(expect[1].path) local sourceScript, sourceList = catch(expect[2].content, '?') @@ -49,6 +49,10 @@ function TEST(expect) files.setText(targetUri, targetScript) files.setText(sourceUri, sourceScript) + if targetList['?'] then + local targetPos = (targetList['?'][1][1] + targetList['?'][1][2]) // 2 + core.byUri(targetUri, targetPos) + end local sourcePos = (sourceList['?'][1][1] + sourceList['?'][1][2]) // 2 local hover = core.byUri(sourceUri, sourcePos) assert(hover) @@ -1018,3 +1022,32 @@ function fn() line1 line2]]} + +TEST { + { + path = 'a.lua', + content = [[ +---@type string[] +local ss + +for _, s in ipairs(ss) do + print(<?s?>) +end +]], + }, + { + path = 'b.lua', + content = [[ + + + +for _, x in ipairs({} and {}) do + print(<?x?>) -- `x` is infered as `string` +end +]], + }, + hover = [[ +```lua +local x: any +```]] +} diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index c526560a..ab55cd92 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -1311,6 +1311,43 @@ end local val = {} location('uri', val) ]] + +-- redundant-return +TEST [[ +local function f() + <!return!> +end +f() +]] + +TEST [[ +local function f() + return nil +end +f() +]] + +TEST [[ +local function f() + local function x() + <!return!> + end + x() + return true +end +f() +]] + +TEST [[ +local function f() + local function x() + return true + end + return x() +end +f() +]] + ---TODO(arthur) do return end diff --git a/test/hover/init.lua b/test/hover/init.lua index 0a05e1cc..36fbd6d2 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1714,3 +1714,12 @@ local t: A<string, number> { y: number, } ]] + +TEST [[ +---@return nil +local function <?f?>() end +]] +[[ +function f() + -> nil +]] diff --git a/tools/love-api.lua b/tools/love-api.lua index bb7f6c8e..32ded033 100644 --- a/tools/love-api.lua +++ b/tools/love-api.lua @@ -129,17 +129,18 @@ local function buildFunction(func, node) end local params = {} for _, param in ipairs(func.variants[1].arguments or {}) do - for paramName in param.name:gmatch '[%a_][%w_]+' do + for paramName in param.name:gmatch '[%a_][%w_]*' do params[#params+1] = paramName - text[#text+1] = ('---@param %s %s # %s'):format( + text[#text+1] = ('---@param %s%s %s # %s'):format( paramName, + param.default == nil and '' or '?', buildType(param), param.description ) end end for _, rtn in ipairs(func.variants[1].returns or {}) do - for returnName in rtn.name:gmatch '[%a_][%w_]+' do + for returnName in rtn.name:gmatch '[%a_][%w_]*' do text[#text+1] = ('---@return %s %s # %s'):format( buildType(rtn), returnName, |