summaryrefslogtreecommitdiff
path: root/script/vm/global-manager.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-03-03 19:53:02 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-03-03 19:53:02 +0800
commitd4c620b0d24df00bf185daf750886ba996d94552 (patch)
tree413cfc7edad9cd4c0ec04ee794f752a8efdd6e7e /script/vm/global-manager.lua
parent98ec375b0d758a4bd206149aef5f9d2d84878962 (diff)
downloadlua-language-server-d4c620b0d24df00bf185daf750886ba996d94552.zip
stash
Diffstat (limited to 'script/vm/global-manager.lua')
-rw-r--r--script/vm/global-manager.lua36
1 files changed, 30 insertions, 6 deletions
diff --git a/script/vm/global-manager.lua b/script/vm/global-manager.lua
index e59e4930..438d3d72 100644
--- a/script/vm/global-manager.lua
+++ b/script/vm/global-manager.lua
@@ -135,15 +135,31 @@ local compilerGlobalMap = util.switch()
end
end
end)
+ : case 'doc.class'
+ : call(function (source)
+ local uri = guide.getUri(source)
+ local name = guide.getKeyName(source)
+ local class = m.declareGlobal('type', name, uri)
+ class:addSet(uri, source)
+ end)
+ : case 'doc.alias'
+ : call(function (source)
+ local uri = guide.getUri(source)
+ local name = guide.getKeyName(source)
+ local alias = m.declareGlobal('type', name, uri)
+ alias:addSet(uri, source)
+ end)
: getMap()
----@param cat '"variable"' | '"type"' | '"alias"'
+---@alias vm.global.cate '"variable"' | '"type"'
+
+---@param cate vm.global.cate
---@param name string
---@param uri uri
---@return vm.node.global
-function m.declareGlobal(cat, name, uri)
- local key = cat .. '|' .. name
+function m.declareGlobal(cate, name, uri)
+ local key = cate .. '|' .. name
m.globalSubs[uri][key] = true
if not m.globals[key] then
m.globals[key] = globalBuilder(name)
@@ -151,12 +167,12 @@ function m.declareGlobal(cat, name, uri)
return m.globals[key]
end
----@param cat '"variable"' | '"type"' | '"alias"'
+---@param cate vm.global.cate
---@param name string
---@param field? string
---@return vm.node.global?
-function m.getGlobal(cat, name, field)
- local key = cat .. '|' .. name
+function m.getGlobal(cate, name, field)
+ local key = cate .. '|' .. name
if field then
key = key .. m.ID_SPLITE .. field
end
@@ -185,6 +201,14 @@ function m.compileAst(source)
guide.eachSpecialOf(source, 'rawget', function (src)
m.compileObject(src.parent)
end)
+ guide.eachSourceTypes(source.docs, {
+ 'doc.class',
+ 'doc.alias',
+ 'doc.type.name',
+ 'doc.extends.name',
+ }, function (src)
+ m.compileObject(src)
+ end)
end
---@return vm.node.global