From c354b5e8bd05ba117857ac93e8d647980875d98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 21 Nov 2019 18:32:40 +0800 Subject: =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/hover/function.lua | 10 +++++++++ server-beta/src/core/hover/init.lua | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 server-beta/src/core/hover/function.lua create mode 100644 server-beta/src/core/hover/init.lua (limited to 'server-beta/src') 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 -- cgit v1.2.3