summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-21 18:32:40 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-21 18:32:40 +0800
commitc354b5e8bd05ba117857ac93e8d647980875d98d (patch)
tree2ec81c0e5c0713760a1c94b475cabe2baae9a2d2 /server-beta/src
parent3ef04652c31fa95ce1749f0309566f386ec70854 (diff)
downloadlua-language-server-c354b5e8bd05ba117857ac93e8d647980875d98d.zip
暂存
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/core/hover/function.lua10
-rw-r--r--server-beta/src/core/hover/init.lua39
2 files changed, 49 insertions, 0 deletions
diff --git a/server-beta/src/core/hover/function.lua b/server-beta/src/core/hover/function.lua
new file mode 100644
index 00000000..15e54306
--- /dev/null
+++ b/server-beta/src/core/hover/function.lua
@@ -0,0 +1,10 @@
+local m = {}
+
+function m.label(source)
+ if source.type ~= 'function' then
+ return
+ end
+
+end
+
+return m
diff --git a/server-beta/src/core/hover/init.lua b/server-beta/src/core/hover/init.lua
new file mode 100644
index 00000000..af1bf6da
--- /dev/null
+++ b/server-beta/src/core/hover/init.lua
@@ -0,0 +1,39 @@
+local files = require 'files'
+local guide = require 'parser.guide'
+local vm = require 'vm'
+local funcHover = require 'core.hover.function'
+
+local function getHoverAsFunction(source)
+ local values = vm.getValue(source)
+ for _, value in ipairs(values) do
+ if value.type == 'function' then
+ local funcLabel = funcHover.label(value.source)
+ end
+ end
+end
+
+local function getHover(source)
+ local isFunction = vm.hasType(source, 'function')
+ if isFunction then
+ getHoverAsFunction(source)
+ end
+end
+
+return function (uri, offset)
+ local ast = files.getAst(uri)
+ if not ast then
+ return nil
+ end
+ local hover = guide.eachSourceContain(ast.ast, offset, function (source)
+ if source.type == 'local'
+ or source.type == 'setlocal'
+ or source.type == 'getlocal'
+ or source.type == 'setglobal'
+ or source.type == 'getglobal'
+ or source.type == 'field'
+ or source.type == 'method' then
+ return getHover(source)
+ end
+ end)
+ return hover
+end