Skip to content

Conversation

C3pa
Copy link
Contributor

@C3pa C3pa commented May 28, 2022

Since the annotation files for LOVE API are built automatically, I updated the builder. If an argument is of table type its default field is always nil. I added a function that iterates over all the fields in the argument's table field and checks whether all of them have a default value. If so, I assign default = true to the argument. That should make the builder add the needed '?' next to the parameter name in the generated meta file.

See the love-api project's graphics module.

@C3pa C3pa mentioned this pull request May 28, 2022
for _, param in ipairs(func.variants[1].arguments or {}) do
for paramName in param.name:gmatch '[%a_][%w_]*' do
params[#params+1] = paramName
local optional = (param.type == 'table' and isTableOptional(param.table) or param.default)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be (param.default ~= nil)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@sumneko
Copy link
Collaborator

sumneko commented May 28, 2022

Thank you!

@sumneko sumneko merged commit 9060bc4 into LuaLS:master May 28, 2022
@C3pa C3pa deleted the fix-1173-alternate branch December 27, 2022 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants