summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/compile.lua14
-rw-r--r--server/src/matcher/init.lua3
-rw-r--r--server/src/matcher/type_inference.lua43
3 files changed, 60 insertions, 0 deletions
diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua
index 557f4f59..bcf2ca91 100644
--- a/server/src/matcher/compile.lua
+++ b/server/src/matcher/compile.lua
@@ -187,7 +187,9 @@ function mt:searchCall(call, func, lastobj)
if lastobj then
table.insert(self.results.calls, {
call = call,
+ func = func,
lastobj = lastobj,
+ results = results,
})
end
@@ -312,6 +314,18 @@ function mt:setValue(var, value)
return
end
var.value = value.value or value
+ local group = var.group or value.group
+ if not group then
+ group = {}
+ end
+ if not group[var] then
+ var.group = group
+ group[var] = group
+ end
+ if not group[value] then
+ value.group = group
+ group[value] = group
+ end
if value.childs then
var.childs = value.childs
for _, child in pairs(value.childs) do
diff --git a/server/src/matcher/init.lua b/server/src/matcher/init.lua
index cacef3e5..eda4ac7b 100644
--- a/server/src/matcher/init.lua
+++ b/server/src/matcher/init.lua
@@ -6,6 +6,9 @@ local api = {
hover = require 'matcher.hover',
diagnostics = require 'matcher.diagnostics',
compile = require 'matcher.compile',
+ typeInference = require 'matcher.type_inference',
+ findResult = require 'matcher.find_result',
+ findLib = require 'matcher.find_lib',
}
return api
diff --git a/server/src/matcher/type_inference.lua b/server/src/matcher/type_inference.lua
new file mode 100644
index 00000000..59874a7e
--- /dev/null
+++ b/server/src/matcher/type_inference.lua
@@ -0,0 +1,43 @@
+local mt = {}
+mt.__index = mt
+
+function mt:searchGroup(group)
+ if not group then
+ return
+ end
+ if group.type ~= nil then
+ return
+ end
+ for obj in pairs(group) do
+ if obj.valuetype then
+ group.type = obj.valuetype
+ return
+ end
+ end
+ group.type = false
+end
+
+function mt:searchVar(var)
+ if var.valuetype then
+ return
+ end
+ if self.lock[var] then
+ return
+ end
+ self.lock[var] = true
+ self:searchGroup(var.group)
+ self.lock[var] = nil
+end
+
+function mt:searchVars(vars)
+ for _, var in ipairs(vars) do
+ self:searchVar(var)
+ end
+end
+
+return function (results)
+ local session = setmetatable({
+ lock = {},
+ }, mt)
+ session:searchVars(results.vars)
+end