summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-28 14:31:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-28 14:31:47 +0800
commite588667ee5657b6123bfd1e0c6a193710e67f6d3 (patch)
treecb3b1837499f5e2cea27f485d823457326528302
parentc2027c12ada4b588182c499d250fb69e55dd408b (diff)
downloadlua-language-server-e588667ee5657b6123bfd1e0c6a193710e67f6d3.zip
save file cache
-rw-r--r--.vscode/settings.json1
-rw-r--r--changelog.md3
-rw-r--r--script/files.lua23
-rw-r--r--script/provider/provider.lua1
-rw-r--r--test.lua1
5 files changed, 24 insertions, 5 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 54ad1616..090b9478 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -5,7 +5,6 @@
"OUT",
"IN",
"log",
- "ac",
"_G",
"GC",
"ID",
diff --git a/changelog.md b/changelog.md
index c0591d66..27118cc1 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
# changelog
+## 1.12.3
+* `FIX` endless loop
+
## 1.12.2
`2021-1-27`
* `CHG` performance optimization
diff --git a/script/files.lua b/script/files.lua
index dc724b94..61ebb564 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -24,6 +24,8 @@ m.notifyCache = {}
m.assocVersion = -1
m.assocMatcher = nil
m.globalVersion = 0
+m.fileCount = 0
+m.astCount = 0
m.linesMap = setmetatable({}, { __mode = 'v' })
m.originLinesMap = setmetatable({}, { __mode = 'v' })
m.astMap = setmetatable({}, { __mode = 'v' })
@@ -135,6 +137,7 @@ function m.setText(uri, text, isTrust)
uri = originUri,
version = 0,
}
+ m.fileCount = m.fileCount + 1
create = true
m._pairsCache = nil
end
@@ -226,6 +229,7 @@ function m.removeAll()
m._pairsCache = nil
for uri in pairs(m.fileMap) do
if not m.libraryMap[uri] then
+ m.fileCount = m.fileCount - 1
m.fileMap[uri] = nil
m.astMap[uri] = nil
m.linesMap[uri] = nil
@@ -243,6 +247,7 @@ function m.removeAllClosed()
for uri in pairs(m.fileMap) do
if not m.openMap[uri]
and not m.libraryMap[uri] then
+ m.fileCount = m.fileCount - 1
m.fileMap[uri] = nil
m.astMap[uri] = nil
m.linesMap[uri] = nil
@@ -336,6 +341,15 @@ function m.compileAst(uri, text)
if passed > 0.1 then
log.warn(('Parse LuaDoc of [%s] takes [%.3f] sec, size [%.3f] kb.'):format(uri, passed, #text / 1000))
end
+ m.astCount = m.astCount + 1
+ local removed
+ setmetatable(state, {__gc = function ()
+ if removed then
+ return
+ end
+ removed = true
+ m.astCount = m.astCount - 1
+ end})
return state
else
log.error(err)
@@ -759,7 +773,7 @@ function m.flushFileCache(uri)
file.cache = {}
end
-local function init()
+function m.init()
--TODO 可以清空文件缓存,之后看要不要启用吧
--timer.loop(10, function ()
-- local list = {}
@@ -776,8 +790,11 @@ local function init()
-- collectgarbage()
-- end
--end)
-end
+ --local prog = progress.create('已缓存文件')
-xpcall(init, log.error)
+ --timer.loop(0.1, function ()
+ -- prog:setMessage(('%s/%s'):format(m.astCount, m.fileCount))
+ --end)()
+end
return m
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 3447c9cd..cac91acf 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -98,6 +98,7 @@ proto.on('initialize', function (params)
end)
proto.on('initialized', function (params)
+ files.init()
local _ <close> = progress.create('正在初始化...', 0.5)
updateConfig()
proto.awaitRequest('client/registerCapability', {
diff --git a/test.lua b/test.lua
index 6116c16a..9005cd72 100644
--- a/test.lua
+++ b/test.lua
@@ -17,7 +17,6 @@ collectgarbage 'generational'
log = require 'log'
log.init(ROOT, ROOT / 'log' / 'test.log')
log.debug('测试开始')
-ac = {}
--dofile((ROOT / 'build_package.lua'):string())
require 'tracy'