diff options
Diffstat (limited to 'server/src/core/diagnostics.lua')
-rw-r--r-- | server/src/core/diagnostics.lua | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index d49f8da2..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) @@ -439,10 +444,6 @@ function mt:checkEmmyClass(source, callback) local related = {} local current = class for _ = 1, 10 do - if parent:getName() == class:getName() then - callback(source.start, source.finish, lang.script.DIAG_CYCLIC_EXTENDS, related) - break - end local extends = current.extends if not extends then break @@ -452,13 +453,32 @@ function mt:checkEmmyClass(source, callback) finish = current:getSource().finish, uri = current:getSource().uri, } - current = parent - parent = self.vm.emmyMgr:eachClass(extends, function (parent) - return parent + current = self.vm.emmyMgr:eachClass(extends, function (parent) + if parent.type == 'emmy.class' then + return parent + end end) - if not parent then + if not current then break end + if current:getName() == class:getName() then + callback(source.start, source.finish, lang.script.DIAG_CYCLIC_EXTENDS, related) + break + end + end +end + +function mt:checkEmmyType(source, callback) + for _, tpsource in ipairs(source) do + local name = tpsource[1] + local class = self.vm.emmyMgr:eachClass(name, function (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) + end end end @@ -466,6 +486,8 @@ function mt:searchEmmyLua(callback) self.vm:eachSource(function (source) if source.type == 'emmyClass' then self:checkEmmyClass(source, callback) + elseif source.type == 'emmyType' then + self:checkEmmyType(source, callback) end end) end |