diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-18 13:36:23 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-18 13:36:23 +0800 |
commit | 10680f1a44f92aa0cd32db5e3bb1960bdbb29a25 (patch) | |
tree | bfdd6346b174519e287803d41c9f49f13551b5f3 /server | |
parent | 04c3ce15f1515b11e43e4630888e323c6372b409 (diff) | |
download | lua-language-server-10680f1a44f92aa0cd32db5e3bb1960bdbb29a25.zip |
值类型参考class
Diffstat (limited to 'server')
-rw-r--r-- | server/src/emmy/class.lua | 4 | ||||
-rw-r--r-- | server/src/emmy/manager.lua | 3 | ||||
-rw-r--r-- | server/src/vm/emmy.lua | 5 | ||||
-rw-r--r-- | server/src/vm/value.lua | 6 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 2 | ||||
-rw-r--r-- | server/test/hover/init.lua | 8 |
6 files changed, 18 insertions, 10 deletions
diff --git a/server/src/emmy/class.lua b/server/src/emmy/class.lua index 69d731ee..33a01be2 100644 --- a/server/src/emmy/class.lua +++ b/server/src/emmy/class.lua @@ -3,7 +3,7 @@ mt.__index = mt mt.type = 'emmy.class' function mt:getType() - return self._name + return self.name end return function (class, parent) @@ -11,6 +11,6 @@ return function (class, parent) name = class[1], source = class.id, parent = parent and parent.id, - }) + }, mt) return self end diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua index 5f83c9d1..8ca102ca 100644 --- a/server/src/emmy/manager.lua +++ b/server/src/emmy/manager.lua @@ -39,6 +39,7 @@ end function mt:addClass(class, parent) local className = class[1] + self:flushClass(className) local list = self._class[className] local version = listMgr.getVersion() if not list then @@ -48,7 +49,7 @@ function mt:addClass(class, parent) self._class[className] = list end list[class.id] = newClass(class, parent) - self:flushClass(className) + return list[class.id] end function mt:remove() diff --git a/server/src/vm/emmy.lua b/server/src/vm/emmy.lua index a9899477..900747e6 100644 --- a/server/src/vm/emmy.lua +++ b/server/src/vm/emmy.lua @@ -1,10 +1,7 @@ local mt = require 'vm.manager' function mt:doEmmyClass(action) - if not self.lsp then - return - end - local emmyMgr = self.lsp.emmyMgr + local emmyMgr = self.emmyMgr local class = action[1] local parent = action[2] self:instantSource(class) diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 3b3a8c01..b3cc5f80 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -77,10 +77,10 @@ end function mt:getType() if self:getEmmy() then - return self:getEmmy():getType() + return self:getEmmy():getType(), 1.0 end if not self._type then - return 'nil' + return 'nil', 0.0 end local mRate = 0.0 local mType @@ -97,7 +97,7 @@ function mt:getType() end end end - return mType or 'any' + return mType or 'any', mRate end function mt:rawSet(index, value, source) diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 3bacfc6c..6f6a4d59 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -7,6 +7,7 @@ local sourceMgr = require 'vm.source' local buildGlobal = require 'vm.global' local createMulti = require 'vm.multi' local libraryBuilder = require 'vm.library' +local emmyMgr = require 'emmy.manager' local config = require 'config' local mt = require 'vm.manager' @@ -1277,6 +1278,7 @@ return function (ast, lsp, uri) main = nil, env = nil, emmy = nil, + emmyMgr = lsp and lsp.emmyMgr or emmyMgr(), lsp = lsp, uri = uri or '', }, mt) diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua index d71d2407..df9b9586 100644 --- a/server/test/hover/init.lua +++ b/server/test/hover/init.lua @@ -464,3 +464,11 @@ local <?n?> = pairs() function n<next>(table: table [, index: any]) -> key: any, value: any ]] + +TEST[[ +---@class Class +local <?x?> = class() +]] +[[ +local x: *Class +]] |