diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 20:14:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 20:14:02 +0800 |
commit | 6f889136264e39a9c47e8cce569274414c9b4a50 (patch) | |
tree | ccfa83257aeec26c03ad42c10e0ddac459d48acf /script/vm/tracer.lua | |
parent | 1ca3b7d67c0c30af1f67fae71b5c770b9008e4d5 (diff) | |
download | lua-language-server-6f889136264e39a9c47e8cce569274414c9b4a50.zip |
cast global
Diffstat (limited to 'script/vm/tracer.lua')
-rw-r--r-- | script/vm/tracer.lua | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/script/vm/tracer.lua b/script/vm/tracer.lua index 5aa5f63e..7999eaaa 100644 --- a/script/vm/tracer.lua +++ b/script/vm/tracer.lua @@ -8,6 +8,7 @@ local util = require 'utility' ---@field package _casts? parser.object[] ---@class vm.tracer +---@field name string ---@field source parser.object ---@field assigns parser.object[] ---@field assignMap table<parser.object, true> @@ -30,7 +31,7 @@ function mt:getCasts() root._casts = {} local docs = root.docs for _, doc in ipairs(docs) do - if doc.type == 'doc.cast' and doc.loc then + if doc.type == 'doc.cast' and doc.name then root._casts[#root._casts+1] = doc end end @@ -113,10 +114,10 @@ function mt:collectLocal() local casts = self:getCasts() for _, cast in ipairs(casts) do - if cast.loc[1] == self.source[1] + if cast.name[1] == self.name and cast.start > startPos and cast.finish < finishPos - and guide.getLocal(self.source, self.source[1], cast.start) == self.source then + and guide.getLocal(self.source, self.name, cast.start) == self.source then self.casts[#self.casts+1] = cast end end @@ -153,6 +154,17 @@ function mt:collectGlobal() finishPos = get.finish end end + + local casts = self:getCasts() + for _, cast in ipairs(casts) do + if cast.name[1] == self.name then + self.casts[#self.casts+1] = cast + end + end + + if #self.casts > 0 then + self.fastCalc = false + end end ---@param start integer @@ -794,8 +806,10 @@ local function createTracer(source) if source.type == 'local' or source.type == 'self' then + tracer.name = source[1] tracer:collectLocal() else + tracer.name = source.global:getName() tracer:collectGlobal() end |