From 46f7d5bc7af55a3d13a2f5edc70667f360b8bd4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= <sumneko@hotmail.com> Date: Tue, 24 Aug 2021 16:52:05 +0800 Subject: [PATCH] fix #660 --- changelog.md | 1 + script/core/noder.lua | 4 +++- script/core/searcher.lua | 2 +- test/completion/common.lua | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 16c31605a..e9b98ef6d 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,7 @@ * `CHG` completion: improve misspelling results * `FIX` runtime errors * `FIX` hint: may show param-2 as `self` +* `FIX` [#660](https://github.com/sumneko/lua-language-server/issues/660) ## 2.3.7 `2021-8-17` diff --git a/script/core/noder.lua b/script/core/noder.lua index 70c24c854..3fd316eba 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -57,8 +57,10 @@ local INFO_META_INDEX = { end } local INFO_CLASS_TO_EXNTENDS = { - filter = function (_, field) + filter = function (_, field, mode) return field ~= nil + or mode == 'field' + or mode == 'allfield' end, filterValid = function (_, field) return not field diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 108a9c37f..1407d617f 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -617,7 +617,7 @@ function m.searchRefsByID(status, suri, expect, mode) ---@param info node.info local function checkInfoFilter(id, field, info) for filter in next, filters do - if not filter(id, field) then + if not filter(id, field, mode) then return false end end diff --git a/test/completion/common.lua b/test/completion/common.lua index b3a2a36ae..2efa63ad7 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -2637,3 +2637,19 @@ m.$ { [1] = EXISTS, } + +TEST [[ +---@class class1 +class1 = {} + +function class1:method1() end + +---@class class2 : class1 +class2 = {} + +class2:$ + +]] +{ + [1] = EXISTS, +} -- GitLab