summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/main.lua2
-rw-r--r--server/src/core/definition.lua8
-rw-r--r--server/src/core/diagnostics.lua15
-rw-r--r--server/src/core/references.lua6
-rw-r--r--server/src/emmy/class.lua8
-rw-r--r--server/src/emmy/manager.lua26
-rw-r--r--server/src/emmy/type.lua12
-rw-r--r--server/src/vm/emmy.lua4
-rw-r--r--server/src/vm/value.lua16
-rw-r--r--server/test/crossfile/definition.lua34
-rw-r--r--server/test/references/init.lua6
11 files changed, 117 insertions, 20 deletions
diff --git a/server/main.lua b/server/main.lua
index ac7860c5..685fce01 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -22,7 +22,7 @@ local function tryDebugger()
log.info('Debugger startup, listen port: 11411')
end
---pcall(tryDebugger)
+pcall(tryDebugger)
require 'utility'
require 'global_protect'
diff --git a/server/src/core/definition.lua b/server/src/core/definition.lua
index a704cb57..8370e7a0 100644
--- a/server/src/core/definition.lua
+++ b/server/src/core/definition.lua
@@ -33,7 +33,7 @@ local function parseValue(callback, vm, source, lsp)
value:eachInfo(function (info, src)
if info.type == 'set' or info.type == 'local' or info.type == 'return' then
if vm.uri == src:getUri() then
- if source.id > src.id then
+ if isGlobal or source.id > src.id then
callback(src)
end
elseif value.uri == src:getUri() then
@@ -73,8 +73,10 @@ end
local function parseClass(callback, vm, source)
local className = source:get 'target class'
vm.emmyMgr:eachClass(className, function (class)
- local src = class:getSource()
- callback(src)
+ if class.type == 'emmy.class' then
+ local src = class:getSource()
+ callback(src)
+ end
end)
end
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index 0732b7e3..9f46d724 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -410,6 +410,9 @@ function mt:checkEmmyClass(source, callback)
local name = class:getName()
local related = {}
self.vm.emmyMgr:eachClass(name, function (class)
+ if class.type ~= 'emmy.class' then
+ return
+ end
local src = class:getSource()
if src ~= source then
related[#related+1] = {
@@ -428,7 +431,9 @@ function mt:checkEmmyClass(source, callback)
return
end
local parent = self.vm.emmyMgr:eachClass(extends, function (parent)
- return parent
+ if parent.type == 'emmy.class' then
+ return parent
+ end
end)
if not parent then
callback(source[2].start, source[2].finish, lang.script.DIAG_UNDEFINED_CLASS)
@@ -449,7 +454,9 @@ function mt:checkEmmyClass(source, callback)
uri = current:getSource().uri,
}
current = self.vm.emmyMgr:eachClass(extends, function (parent)
- return parent
+ if parent.type == 'emmy.class' then
+ return parent
+ end
end)
if not current then
break
@@ -465,7 +472,9 @@ function mt:checkEmmyType(source, callback)
for _, tpsource in ipairs(source) do
local name = tpsource[1]
local class = self.vm.emmyMgr:eachClass(name, function (class)
- return class
+ if class.type == 'emmy.class' then
+ return class
+ end
end)
if not class then
callback(tpsource.start, tpsource.finish, lang.script.DIAG_UNDEFINED_CLASS)
diff --git a/server/src/core/references.lua b/server/src/core/references.lua
index d07e48c7..33b38fec 100644
--- a/server/src/core/references.lua
+++ b/server/src/core/references.lua
@@ -53,6 +53,12 @@ local function parseResult(vm, source, declarat, callback)
end
end)
end
+ --local emmy = source:getEmmy()
+ --if emmy then
+ -- if emmy.type == 'emmy.class' or emmy.type == 'emmy.type' --then
+--
+ -- end
+ --end
return isGlobal
end
diff --git a/server/src/emmy/class.lua b/server/src/emmy/class.lua
index 5e87181d..fe67cf40 100644
--- a/server/src/emmy/class.lua
+++ b/server/src/emmy/class.lua
@@ -24,6 +24,14 @@ function mt:getValue()
return self.value
end
+function mt:eachChild(callback)
+ self._manager:eachClass(self.name, function (obj)
+ if obj.type == 'emmy.type' then
+ callback(obj)
+ end
+ end)
+end
+
return function (manager, source)
local self = setmetatable({
name = source[1][1],
diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua
index a3de42df..ecc344bf 100644
--- a/server/src/emmy/manager.lua
+++ b/server/src/emmy/manager.lua
@@ -59,23 +59,34 @@ function mt:eachClass(...)
end
end
-function mt:addClass(source)
- local className = source[1][1]
- self:flushClass(className)
- local list = self._class[className]
+function mt:getClass(name)
+ self:flushClass(name)
+ local list = self._class[name]
local version = listMgr.getVersion()
if not list then
list = {
version = version,
}
- self._class[className] = list
+ self._class[name] = list
end
+ return list
+end
+
+function mt:addClass(source)
+ local className = source[1][1]
+ local list = self:getClass(className)
list[source.id] = newClass(self, source)
return list[source.id]
end
-function mt:createType(source)
- return newType(self, source)
+function mt:addType(source)
+ local typeObj = newType(self, source)
+ for _, obj in ipairs(source) do
+ local className = obj[1]
+ local list = self:getClass(className)
+ list[source.id] = typeObj
+ end
+ return typeObj
end
function mt:remove()
@@ -85,6 +96,7 @@ return function ()
---@class emmyMgr
local self = setmetatable({
_class = {},
+ _type = {},
}, mt)
return self
end
diff --git a/server/src/emmy/type.lua b/server/src/emmy/type.lua
index c2195810..63653bad 100644
--- a/server/src/emmy/type.lua
+++ b/server/src/emmy/type.lua
@@ -26,11 +26,21 @@ end
function mt:getClass()
local class = self._manager:eachClass(self.name, function (class)
- return class
+ if class.type == 'emmy.class' then
+ return class
+ end
end)
return class
end
+function mt:setValue(value)
+ self.value = value
+end
+
+function mt:getValue()
+ return self.value
+end
+
return function (manager, source)
local self = setmetatable({
name = buildName(source),
diff --git a/server/src/vm/emmy.lua b/server/src/vm/emmy.lua
index 22f72ae6..c542cf4b 100644
--- a/server/src/vm/emmy.lua
+++ b/server/src/vm/emmy.lua
@@ -33,6 +33,7 @@ function mt:getEmmy()
end
function mt:doEmmyClass(action)
+ ---@type emmyMgr
local emmyMgr = self.emmyMgr
self:instantSource(action)
local class = emmyMgr:addClass(action)
@@ -49,9 +50,10 @@ function mt:doEmmyClass(action)
end
function mt:doEmmyType(action)
+ ---@type emmyMgr
local emmyMgr = self.emmyMgr
self:instantSource(action)
- local type = emmyMgr:createType(action)
+ local type = emmyMgr:addType(action)
self._emmy = type
action:set('emmy.type', type)
for _, obj in ipairs(action) do
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 20e6f5d7..63e15cc8 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -322,7 +322,7 @@ function mt:mergeValue(value)
if not value then
return
end
- local global = self._global
+ local global = self._global or value._global
local list = {self, value}
local pos = 1
while true do
@@ -351,13 +351,14 @@ function mt:mergeValue(value)
list[#list+1] = bc
end
end
- if global then
- bc:markGlobal()
- end
a._child[k] = bc
end
end
b._child = a._child
+ if global then
+ a:markGlobal()
+ b:markGlobal()
+ end
if b._meta then
a._meta = b._meta
@@ -530,7 +531,14 @@ function mt:setEmmy(emmy)
end
if emmy.type == 'emmy.class' then
emmy:setValue(self)
+ emmy:eachChild(function (obj)
+ local value = obj:getValue()
+ if value then
+ value:mergeValue(self)
+ end
+ end)
elseif emmy.type == 'emmy.type' then
+ emmy:setValue(self)
local class = emmy:getClass()
if class then
self:mergeValue(class:getValue())
diff --git a/server/test/crossfile/definition.lua b/server/test/crossfile/definition.lua
index ee62345a..4e3a00ef 100644
--- a/server/test/crossfile/definition.lua
+++ b/server/test/crossfile/definition.lua
@@ -275,3 +275,37 @@ TEST {
]],
},
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ ---@class Class
+ local <!obj!>
+ ]]
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ ---@type Class
+ local <?obj?>
+ ]]
+ },
+}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ ---@type Class
+ local <?obj?>
+ ]]
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ ---@class Class
+ local <!obj!>
+ ]]
+ },
+}
diff --git a/server/test/references/init.lua b/server/test/references/init.lua
index e5d0b1cc..ad84eb80 100644
--- a/server/test/references/init.lua
+++ b/server/test/references/init.lua
@@ -100,3 +100,9 @@ table.<!dump!>()
function table.<?dump?>()
end
]]
+
+--TEST [[
+-----@class <?Class?>
+-----@type <!Class!>
+-----@type <!Class!>
+--]]