Skip to content

Commit

Permalink
Merge branch 'master' into cast-table-to-class
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko authored Aug 15, 2024
2 parents abd5daa + b71cb7a commit 2c79870
Show file tree
Hide file tree
Showing 32 changed files with 952 additions and 483 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Report LuaLS.github.io issues
url: https://github.com/LuaLS/LuaLS.github.io/issues
about: Please report issues regarding our website (and the documentation on it) in the website repository.
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/doc-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Documentation Report
description: Report an issue with documentation in the lua-language-server.
labels:
- documentation
assignees:
- carsakiller
body:
- type: markdown
attributes:
value: >
For issues with our [website](https://luals.github.io) and its wiki,
please visit the [correct repository](https://github.com/LuaLS/LuaLS.github.io/issues).
- type: markdown
attributes:
value: >
**Please check for similar issues before continuing!**
- type: textarea
id: expected
attributes:
label: Issue Description
description: Please describe the documentation issue. Is something incorrect, missing or improveable?
validations:
required: true
- type: textarea
id: additional-notes
attributes:
label: Additional Notes
description: >
Please provide any additional notes, context,
and media you have.
- type: markdown
attributes:
value: |
Thank you very much for helping improve the language server! ❤️
36 changes: 31 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,44 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `NEW` Add matching checks between the shape of tables and classes, during type checking. [#2768](https://github.com/LuaLS/lua-language-server/pull/2768
* `FIX` Error `attempt to index a nil value` when `Lua.hint.semicolon == 'All'` [#2788](https://github.com/LuaLS/lua-language-server/issues/2788)

## 3.10.3
`2024-8-8`
* `FIX` Memory leak with `---@enum(partical)`

## 3.10.2
`2024-8-7`
* `NEW` Add support for binary metamethod on right operand [#2777](https://github.com/LuaLS/lua-language-server/pull/2777)
* `FIX` Incorrect indentation fixing in some case

## 3.10.1
`2024-8-2`
* `FIX` Runtime error
* `FIX` Disable indentation fixing for Non-VSCode

## 3.10.0
`2024-8-1`
* `NEW` Add postfix snippet for `unpack`
* `FIX` `diagnostics.severity` defaulting to "Warning" when run using `--check` [#2730](https://github.com/LuaLS/lua-language-server/issues/2730)
* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
* `FIX` Respect `completion.showParams` config for local function completion
* `NEW` Added lua regular expression support for `Lua.doc.<scope>Name` [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
* `NEW` You can now click on "References" in CodeLen to display the reference list(VSCode)
* `NEW` Improved behavior for inserting new lines:
+ When inside an annotation, an annotation tag will be added at the beginning of the line (VSCode).
+ When between `function () end` or similar constructs, the format will be adjusted to a more reasonable one (VSCode) and leading/trailing spaces will be removed (generic).
+ Attempts to semantically fix improper indentation (generic).
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic
* `CHG` Change spacing of parameter inlay hints to match other LSPs, like `rust-analyzer`
* `FIX` `diagnostics.severity` defaulting to "Warning" when run using `--check` [#2730](https://github.com/LuaLS/lua-language-server/issues/2730)
* `FIX` Respect `completion.showParams` config for local function completion
* `FIX` Addons can now self-recommend as expected. Fixed by correcting the `wholeMatch` function
* `FIX` Now correctly evaluates the visibility of fields in a class when they are defined directly in the object. use for completion and invisible dianostic. [#2752](https://github.com/LuaLS/lua-language-server/issues/2752)
* `NEW` added lua regular expression support for Lua.doc.<scope>Name [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
* `FIX` Bad triggering of the `inject-field` diagnostic, when the fields are declared at the creation of the object [#2746](https://github.com/LuaLS/lua-language-server/issues/2746)
* `CHG` Change spacing of parameter inlay hints to match other LSPs, like `rust-analyzer`
* `FIX` Inconsistent type narrow behavior of function call args [#2758](https://github.com/LuaLS/lua-language-server/issues/2758)
* `NEW` Add matching checks between the shape of tables and classes, during type checking. [#2768](https://github.com/LuaLS/lua-language-server/pull/2768
* `FIX` Improve the `missing-fields` logic to be able to correctly handle classes defined several times [#22770](https://github.com/LuaLS/lua-language-server/pull/2770)
* `FIX` Typos in annotation descriptions
* `FIX` incorrect `CompletionItemKind` for postfix snippets [#2773](https://github.com/LuaLS/lua-language-server/pull/2773)

## 3.9.3
`2024-6-11`
Expand Down
4 changes: 2 additions & 2 deletions locale/en-us/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ Provide type declaration for [operator metamethods](http://lua-users.org/wiki/Me
### Vector Add Metamethod
```
---@class Vector
---@operation add(Vector):Vector
---@operator add(Vector):Vector
vA = Vector.new(1, 2, 3)
vB = Vector.new(10, 20, 30)
Expand All @@ -1178,7 +1178,7 @@ vC = vA + vB
### Unary Minus
```
---@class Passcode
---@operation unm:integer
---@operator unm:integer
pA = Passcode.new(1234)
pB = -pA
Expand Down
8 changes: 4 additions & 4 deletions locale/pt-br/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ Provide type declaration for [operator metamethods](http://lua-users.org/wiki/Me
### Vector Add Metamethod
```
---@class Vector
---@operation add(Vector):Vector
---@operator add(Vector):Vector
vA = Vector.new(1, 2, 3)
vB = Vector.new(10, 20, 30)
Expand All @@ -1178,7 +1178,7 @@ vC = vA + vB
### Unary Minus
```
---@class Passcode
---@operation unm:integer
---@operator unm:integer
pA = Passcode.new(1234)
pB = -pA
Expand Down Expand Up @@ -1216,7 +1216,7 @@ setColor(colors.green)
LUADOC_DESC_SOURCE = -- TODO: need translate!
[=[
Provide a reference to some source code which lives in another file. When
searching for the defintion of an item, its `@source` will be used.
searching for the definition of an item, its `@source` will be used.
## Syntax
`@source <path>`
Expand Down Expand Up @@ -1264,7 +1264,7 @@ end
LUADOC_DESC_PRIVATE = -- TODO: need translate!
[=[
Mark a function as private to a @class. Private functions can be accessed only
from within their class and are not accessable from child classes.
from within their class and are not accessible from child classes.
## Syntax
`@private`
Expand Down
8 changes: 4 additions & 4 deletions locale/zh-cn/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ Provide type declaration for [operator metamethods](http://lua-users.org/wiki/Me
### Vector Add Metamethod
```
---@class Vector
---@operation add(Vector):Vector
---@operator add(Vector):Vector
vA = Vector.new(1, 2, 3)
vB = Vector.new(10, 20, 30)
Expand All @@ -1178,7 +1178,7 @@ vC = vA + vB
### Unary Minus
```
---@class Passcode
---@operation unm:integer
---@operator unm:integer
pA = Passcode.new(1234)
pB = -pA
Expand Down Expand Up @@ -1216,7 +1216,7 @@ setColor(colors.green)
LUADOC_DESC_SOURCE = -- TODO: need translate!
[=[
Provide a reference to some source code which lives in another file. When
searching for the defintion of an item, its `@source` will be used.
searching for the definition of an item, its `@source` will be used.
## Syntax
`@source <path>`
Expand Down Expand Up @@ -1264,7 +1264,7 @@ end
LUADOC_DESC_PRIVATE = -- TODO: need translate!
[=[
Mark a function as private to a @class. Private functions can be accessed only
from within their class and are not accessable from child classes.
from within their class and are not accessible from child classes.
## Syntax
`@private`
Expand Down
8 changes: 4 additions & 4 deletions locale/zh-tw/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ Provide type declaration for [operator metamethods](http://lua-users.org/wiki/Me
### Vector Add Metamethod
```
---@class Vector
---@operation add(Vector):Vector
---@operator add(Vector):Vector
vA = Vector.new(1, 2, 3)
vB = Vector.new(10, 20, 30)
Expand All @@ -1172,7 +1172,7 @@ vC = vA + vB
### Unary Minus
```
---@class Passcode
---@operation unm:integer
---@operator unm:integer
pA = Passcode.new(1234)
pB = -pA
Expand Down Expand Up @@ -1210,7 +1210,7 @@ setColor(colors.green)
LUADOC_DESC_SOURCE = -- TODO: need translate!
[=[
Provide a reference to some source code which lives in another file. When
searching for the defintion of an item, its `@source` will be used.
searching for the definition of an item, its `@source` will be used.
## Syntax
`@source <path>`
Expand Down Expand Up @@ -1258,7 +1258,7 @@ end
LUADOC_DESC_PRIVATE = -- TODO: need translate!
[=[
Mark a function as private to a @class. Private functions can be accessed only
from within their class and are not accessable from child classes.
from within their class and are not accessible from child classes.
## Syntax
`@private`
Expand Down
7 changes: 6 additions & 1 deletion script/cli/check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ local util = require 'utility'

local numThreads = tonumber(NUM_THREADS or 1)

local exe = arg[-1]
local exe
local minIndex = -1
while arg[minIndex] do
exe = arg[minIndex]
minIndex = minIndex - 1
end
-- TODO: is this necessary? got it from the shell.lua helper in bee.lua tests
if platform.os == 'windows' and not exe:match('%.[eE][xX][eE]$') then
exe = exe..'.exe'
Expand Down
36 changes: 30 additions & 6 deletions script/core/code-lens.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local await = require 'await'
local conv = require 'proto.converter'
local getRef = require 'core.reference'
local lang = require 'language'
local client = require 'client'

---@class parser.state
---@field package _codeLens? codeLens
Expand Down Expand Up @@ -88,12 +89,35 @@ end
function mt:resolveReference(source)
local refs = getRef(self.uri, source.finish, false)
local count = refs and #refs or 0
local command = conv.command(
lang.script('COMMAND_REFERENCE_COUNT', count),
'',
{}
)
return command
if client.getOption('codeLensViewReferences') then
local locations = {}
for _, ref in ipairs(refs or {}) do
local state = files.getState(ref.uri)
if state then
locations[#locations+1] = conv.location(
ref.uri,
conv.packRange(state, ref.target.start, ref.target.finish)
)
end
end
local command = conv.command(
lang.script('COMMAND_REFERENCE_COUNT', count),
'lua.showReferences',
{
self.uri,
conv.packPosition(self.state, source.start),
locations,
}
)
return command
else
local command = conv.command(
lang.script('COMMAND_REFERENCE_COUNT', count),
'',
{}
)
return command
end
end

---@async
Expand Down
2 changes: 1 addition & 1 deletion script/core/completion/postfix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ local function checkPostFix(state, word, wordPosition, position, symbol, results
end):gsub('%$%{?%d+%}?', '')
results[#results+1] = {
label = action.key,
kind = define.CompletionItemKind.Event,
kind = define.CompletionItemKind.Snippet,
description = markdown()
: add('lua', descText)
: string(),
Expand Down
78 changes: 46 additions & 32 deletions script/core/diagnostics/missing-fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,75 @@ return function (uri, callback)
guide.eachSourceType(state.ast, 'table', function (src)
await.delay()

vm.removeNode(src) -- the node is not updated correctly, reason still unknown
local defs = vm.getDefs(src)
local sortedDefs = {}
for _, def in ipairs(defs) do
if def.type == 'doc.class' and def.bindSource then
if guide.isInRange(def.bindSource, src.start) then
if def.type == 'doc.class' then
if def.bindSource and guide.isInRange(def.bindSource, src.start) then
return
end
local className = def.class[1]
if not sortedDefs[className] then
sortedDefs[className] = {}
end
local samedefs = sortedDefs[className]
samedefs[#samedefs+1] = def
end
if def.type == 'doc.type.array'
or def.type == 'doc.type.table' then
return
end
end

local myKeys
local warnings = {}
for _, def in ipairs(defs) do
if def.type == 'doc.class' then
if not def.fields then
return
for className, samedefs in pairs(sortedDefs) do
local missedKeys = {}
for _, def in ipairs(samedefs) do
if not def.fields or #def.fields == 0 then
goto continue
end

if not myKeys then
myKeys = {}
for _, field in ipairs(src) do
local key = vm.getKeyName(field) or field.tindex
if key then
myKeys[key] = true
end
end
end

local requiresKeys = {}
for _, field in ipairs(def.fields) do
if not field.optional
and not vm.compileNode(field):isNullable() then
local key = vm.getKeyName(field)
if key and not requiresKeys[key] then
requiresKeys[key] = true
requiresKeys[#requiresKeys+1] = key
if not key then
local fieldnode = vm.compileNode(field.field)[1]
if fieldnode and fieldnode.type == 'doc.type.integer' then
---@cast fieldnode parser.object
key = vm.getKeyName(fieldnode)
end
end
end
end

if #requiresKeys == 0 then
return
end
local myKeys = {}
for _, field in ipairs(src) do
local key = vm.getKeyName(field)
if key then
myKeys[key] = true
end
end

local missedKeys = {}
for _, key in ipairs(requiresKeys) do
if not myKeys[key] then
missedKeys[#missedKeys+1] = ('`%s`'):format(key)
if key and not myKeys[key] then
if type(key) == "number" then
missedKeys[#missedKeys+1] = ('`[%s]`'):format(key)
else
missedKeys[#missedKeys+1] = ('`%s`'):format(key)
end
end
end
end
::continue::
end

if #missedKeys == 0 then
return
end

warnings[#warnings+1] = lang.script('DIAG_MISSING_FIELDS', def.class[1], table.concat(missedKeys, ', '))
if #missedKeys == 0 then
return
end

warnings[#warnings+1] = lang.script('DIAG_MISSING_FIELDS', className, table.concat(missedKeys, ', '))
end

if #warnings == 0 then
Expand Down
Loading

0 comments on commit 2c79870

Please sign in to comment.