diff options
-rw-r--r-- | changelog.md | 7 | ||||
-rw-r--r-- | script/config/config.lua | 2 | ||||
-rw-r--r-- | script/core/command/solve.lua | 11 | ||||
-rw-r--r-- | script/core/diagnostics/ambiguity-1.lua | 16 | ||||
-rw-r--r-- | script/core/noder.lua | 20 | ||||
-rw-r--r-- | script/filewatch.lua | 9 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 2 | ||||
-rw-r--r-- | test/type_inference/init.lua | 44 |
8 files changed, 91 insertions, 20 deletions
diff --git a/changelog.md b/changelog.md index b8bb1c28..cee2349c 100644 --- a/changelog.md +++ b/changelog.md @@ -25,6 +25,13 @@ * `CHG` skip huge files (>= 10 MB) * `CHG` after using `Lua.runtime.nonstandardSymbol` to treat `//` as a comment, `//` is no longer parsed as an operator +## 2.4.10 +* `FIX` [#790](https://github.com/sumneko/lua-language-server/issues/790) +* `FIX` [#798](https://github.com/sumneko/lua-language-server/issues/798) +* `FIX` [#804](https://github.com/sumneko/lua-language-server/issues/804) +* `FIX` [#806](https://github.com/sumneko/lua-language-server/issues/806) +* `FIX` [#807](https://github.com/sumneko/lua-language-server/issues/807) + ## 2.4.9 `2021-11-18` * `CHG` for performance reasons, some of the features that are not cost-effective in IntelliSense have been disabled by default, and you can re-enable them through the following settings: diff --git a/script/config/config.lua b/script/config/config.lua index 2f923d89..0e18428f 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -170,7 +170,7 @@ local Template = { ['Lua.diagnostics.workspaceRate'] = Type.Integer >> 100, ['Lua.diagnostics.libraryFiles'] = Type.String >> 'Opened', ['Lua.diagnostics.ignoredFiles'] = Type.String >> 'Opened', - ['Lua.workspace.ignoreDir'] = Type.Hash(Type.String, Type.Boolean, ';'), + ['Lua.workspace.ignoreDir'] = Type.Array(Type.String), ['Lua.workspace.ignoreSubmodules'] = Type.Boolean >> true, ['Lua.workspace.useGitIgnore'] = Type.Boolean >> true, ['Lua.workspace.maxPreload'] = Type.Integer >> 1000, diff --git a/script/core/command/solve.lua b/script/core/command/solve.lua index 19148092..8065aa9d 100644 --- a/script/core/command/solve.lua +++ b/script/core/command/solve.lua @@ -31,14 +31,14 @@ local literalMap = { return function (data) local uri = data.uri local text = files.getText(uri) - local ast = files.getState(uri) - if not ast then + local state = files.getState(uri) + if not state then return end local start, finish = converter.unpackRange(uri, data.range) - local result = guide.eachSourceContain(ast.ast, start, function (source) + local result = guide.eachSourceContain(state.ast, start, function (source) if source.start ~= start or source.finish ~= finish then return @@ -87,7 +87,10 @@ return function (data) [uri] = { { range = converter.packRange(uri, result.start, result.finish), - newText = ('(%s)'):format(text:sub(result.start, result.finish)), + newText = ('(%s)'):format(text:sub( + guide.positionToOffset(state, result.start + 1), + guide.positionToOffset(state, result.finish) + )), } }, } diff --git a/script/core/diagnostics/ambiguity-1.lua b/script/core/diagnostics/ambiguity-1.lua index dbaa101d..f03f4361 100644 --- a/script/core/diagnostics/ambiguity-1.lua +++ b/script/core/diagnostics/ambiguity-1.lua @@ -26,12 +26,12 @@ local literalMap = { } return function (uri, callback) - local ast = files.getState(uri) - if not ast then + local state = files.getState(uri) + if not state then return end local text = files.getText(uri) - guide.eachSourceType(ast.ast, 'binary', function (source) + guide.eachSourceType(state.ast, 'binary', function (source) if source.op.type ~= 'or' then return end @@ -51,7 +51,10 @@ return function (uri, callback) callback { start = source.start, finish = source.finish, - message = lang.script('DIAG_AMBIGUITY_1', text:sub(first.start, first.finish)) + message = lang.script('DIAG_AMBIGUITY_1', text:sub( + guide.positionToOffset(state, first.start + 1), + guide.positionToOffset(state, first.finish) + )) } end end @@ -65,7 +68,10 @@ return function (uri, callback) callback { start = source.start, finish = source.finish, - message = lang.script('DIAG_AMBIGUITY_1', text:sub(second.start, second.finish)) + message = lang.script('DIAG_AMBIGUITY_1', text:sub( + guide.positionToOffset(state, second.start + 1), + guide.positionToOffset(state, second.finish) + )) } end end diff --git a/script/core/noder.lua b/script/core/noder.lua index 12dcc3c7..0fc83905 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -940,7 +940,10 @@ compileNodeMap = util.switch() : call(function (noders, id, source) if source.bindSources then for _, src in ipairs(source.bindSources) do - pushForward(noders, getID(src), id) + if src.parent.type ~= 'funcargs' + and not src.dummy then + pushForward(noders, getID(src), id) + end end end for _, enumUnit in ipairs(source.enums) do @@ -954,7 +957,10 @@ compileNodeMap = util.switch() pushForward(noders, id, unitID) if source.bindSources then for _, src in ipairs(source.bindSources) do - pushBackward(noders, unitID, getID(src)) + if src.parent.type ~= 'funcargs' + and not src.dummy then + pushBackward(noders, unitID, getID(src)) + end end end end @@ -1031,8 +1037,11 @@ compileNodeMap = util.switch() or src.type == 'tablefield' or src.type == 'tableindex' or src.type == 'setglobal' then - pushForward(noders, getID(src), id) - pushForward(noders, id, getID(src)) + if src.parent.type ~= 'funcargs' + and not src.dummy then + pushForward(noders, getID(src), id) + pushForward(noders, id, getID(src)) + end end end end @@ -1372,8 +1381,7 @@ compileNodeMap = util.switch() end for _, rtn in ipairs(source.returns) do for _, src in ipairs(source.bindSources) do - if src.type == 'function' - or guide.isSet(src) then + if src.type == 'function' then local fullID = sformat('%s%s%s' , getID(src) , RETURN_INDEX diff --git a/script/filewatch.lua b/script/filewatch.lua index 28f7376f..dd46d1a3 100644 --- a/script/filewatch.lua +++ b/script/filewatch.lua @@ -8,11 +8,14 @@ local RENAME = 1 << 1 local function exists(filename) local path = fs.path(filename) local suc, res = pcall(fs.exists, path) - if suc and res then - return true - else + if not suc or not res then return false end + suc, res = pcall(fs.canonical, path) + if not suc or res:string() ~= path:string() then + return false + end + return true end ---@class filewatch diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index de534a96..099196ce 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -131,7 +131,7 @@ function m.getNativeMatcher() end end -- config.get 'workspace.ignoreDir' - for path in pairs(config.get 'Lua.workspace.ignoreDir') do + for _, path in ipairs(config.get 'Lua.workspace.ignoreDir') do log.info('Ignore directory:', path) pattern[#pattern+1] = path end diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index e071fdf7..c76e372c 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -948,3 +948,47 @@ local x <?x?> = 1 ]] + +TEST 'any' [[ +---@return number +local function f(x) + local <?y?> = x() +end +]] + +TEST 'any' [[ +local mt + +---@return number +function mt:f() end + +local <?v?> = mt() +]] + +TEST 'any' [[ +local <?mt?> + +---@class X +function mt:f(x) end +]] + +TEST 'any' [[ +local mt + +---@class X +function mt:f(<?x?>) end +]] + +TEST 'any' [[ +local <?mt?> + +---@type number +function mt:f(x) end +]] + +TEST 'any' [[ +local mt + +---@type number +function mt:f(<?x?>) end +]] |