summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-23 16:15:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-23 16:15:13 +0800
commit366d163edf1373ca4f7c56ef44b77b818d9ee4f8 (patch)
tree768aef8f9a8c2f6c8dc046a019dd43a9a3d1e299
parent1e7e9eba031eadfb5045a7fec01ee8519a967be6 (diff)
downloadlua-language-server-366d163edf1373ca4f7c56ef44b77b818d9ee4f8.zip
fix #567
-rw-r--r--changelog.md1
-rw-r--r--script/core/noder.lua11
-rw-r--r--script/core/searcher.lua13
-rw-r--r--test.lua2
-rw-r--r--test/crossfile/definition.lua15
-rw-r--r--test/full/projects.lua2
-rw-r--r--test/type_inference/init.lua4
7 files changed, 41 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md
index afc62256..8a10293e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,7 @@
# changelog
## 2.0.2
+* `FIX` [#567](https://github.com/sumneko/lua-language-server/issues/567)
* `FIX` [#570](https://github.com/sumneko/lua-language-server/issues/570)
## 2.0.1
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 413f2007..d6d0f59a 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -988,6 +988,17 @@ function m.getLastID(id)
return lastID
end
+---获取ID的长度
+---@param id string
+---@return integer
+function m.getIDLength(id)
+ if not id then
+ return 0
+ end
+ local _, count = id:gsub(SPLIT_CHAR, SPLIT_CHAR)
+ return count + 1
+end
+
---测试id是否包含field,如果遇到函数调用则中断
---@param id string
---@return boolean
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 6c8ca60a..87769de4 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -249,7 +249,8 @@ function m.searchRefsByID(status, uri, expect, mode)
local callStack = status.callStack
- local mark = {}
+ local mark = status.flock[uri] or {}
+ status.flock[uri] = mark
local function search(id, field)
local firstID = noder.getFirstID(id)
@@ -297,7 +298,8 @@ function m.searchRefsByID(status, uri, expect, mode)
cmark = {}
mark[id] = cmark
end
- if cmark[LAST] then
+ local fieldLength = noder.getIDLength(field)
+ if cmark[LAST] and fieldLength >= cmark[LAST] then
return
end
local lastID = noder.getLastID(id)
@@ -308,7 +310,7 @@ function m.searchRefsByID(status, uri, expect, mode)
if field then
newField = newField .. field
end
- cmark[LAST] = true
+ cmark[LAST] = fieldLength
search(lastID, newField)
return lastID
end
@@ -620,10 +622,10 @@ function m.searchRefsByID(status, uri, expect, mode)
local stepCount = 0
local stepMaxCount = 1e3
- local statusMaxCount = 1e4
+ local statusMaxCount = 1e5
if mode == 'allref' or mode == 'alldef' then
stepMaxCount = 1e4
- statusMaxCount = 1e5
+ statusMaxCount = 1e6
end
function searchStep(id, field)
stepCount = stepCount + 1
@@ -853,6 +855,7 @@ function m.status(mode)
callStack = {},
crossed = {},
lock = {},
+ flock = {},
results = {},
rmark = {},
smark = {},
diff --git a/test.lua b/test.lua
index f408d227..3f2cf2cd 100644
--- a/test.lua
+++ b/test.lua
@@ -9,7 +9,7 @@ local fs = require 'bee.filesystem'
ROOT = fs.path(rootPath)
TEST = true
DEVELOP = true
---FOOTPRINT = true
+FOOTPRINT = true
--TRACE = true
LOGPATH = LOGPATH or (ROOT .. '/log')
METAPATH = METAPATH or (ROOT .. '/meta')
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index 467e6af5..d1b613cc 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -771,3 +771,18 @@ TEST {
},
}
config.config.runtime.path = originRuntimePath
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ a = b.x
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ b = a.<?x?>
+ ]],
+ },
+}
diff --git a/test/full/projects.lua b/test/full/projects.lua
index 84a20c0d..b2e6d3cc 100644
--- a/test/full/projects.lua
+++ b/test/full/projects.lua
@@ -25,7 +25,7 @@ local function doProjects(pathname)
local uri = furi.encode(path:string())
local text = fsu.loadFile(path)
files.setText(uri, text)
- --files.open(uri)
+ files.open(uri)
end)
print('开始诊断...')
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 7a968972..7d5ea44f 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -742,3 +742,7 @@ local <?test?> = Rct.new(Rct)
return test
]]
+
+TEST 'function' [[
+string.gsub():gsub():<?gsub?>()
+]]