summaryrefslogtreecommitdiff
path: root/server/src/emmy
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-05-05 20:06:08 +0800
committersumneko <sumneko@hotmail.com>2019-05-05 20:06:08 +0800
commit6b95bb52f39082e9df605a954cb6a16d75b9611c (patch)
treec425335076a50e90f28f3c42ab825fb6c042c13b /server/src/emmy
parente00842cf43b6d2e2ff3900db32d3aa4e18a8f800 (diff)
downloadlua-language-server-6b95bb52f39082e9df605a954cb6a16d75b9611c.zip
emmyFunctionçš„hover
Diffstat (limited to 'server/src/emmy')
-rw-r--r--server/src/emmy/funcType.lua49
-rw-r--r--server/src/emmy/manager.lua6
2 files changed, 55 insertions, 0 deletions
diff --git a/server/src/emmy/funcType.lua b/server/src/emmy/funcType.lua
new file mode 100644
index 00000000..405de594
--- /dev/null
+++ b/server/src/emmy/funcType.lua
@@ -0,0 +1,49 @@
+local listMgr = require 'vm.list'
+
+---@class EmmyFunctionType
+local mt = {}
+mt.__index = mt
+mt.type = 'emmy.functionType'
+
+function mt:getType()
+ return 'function'
+end
+
+function mt:getSource()
+ return listMgr.get(self.source)
+end
+
+function mt:setValue(value)
+ self.value = value
+end
+
+function mt:getValue()
+ return self.value
+end
+
+function mt:addParam(name, type)
+ self._params[#self._params+1] = { name, type }
+end
+
+function mt:addReturn(type)
+ self._return = type
+end
+
+function mt:eachParam(callback)
+ for _, data in ipairs(self._params) do
+ callback(data[1], data[2])
+ end
+end
+
+function mt:getReturn()
+ return self._return
+end
+
+return function (manager, source)
+ local self = setmetatable({
+ source = source.id,
+ _params = {},
+ _manager = manager,
+ }, mt)
+ return self
+end
diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua
index dad456a8..128ed029 100644
--- a/server/src/emmy/manager.lua
+++ b/server/src/emmy/manager.lua
@@ -9,6 +9,7 @@ local newField = require 'emmy.field'
local newGeneric = require 'emmy.generic'
local newArrayType = require 'emmy.arrayType'
local newTableType = require 'emmy.tableType'
+local newFuncType = require 'emmy.funcType'
local mt = {}
mt.__index = mt
@@ -116,6 +117,11 @@ function mt:addTableType(source, keyType, valueType)
return typeObj
end
+function mt:addFunctionType(source)
+ local typeObj = newFuncType(self, source)
+ return typeObj
+end
+
function mt:addAlias(source, typeObj)
local aliasName = source[1][1]
local aliasObj = newAlias(self, source)