diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-22 23:26:32 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-22 23:26:32 +0800 |
commit | d0ff66c9abe9d6abbca12fd811e0c3cb69c1033a (patch) | |
tree | bb34518d70b85de7656dbdbe958dfa221a3ff3b3 /server-beta/src/core/hover/label.lua | |
parent | 0a2c2ad15e1ec359171fb0dd4c72e57c5b66e9ba (diff) | |
download | lua-language-server-d0ff66c9abe9d6abbca12fd811e0c3cb69c1033a.zip |
整理一下目录结构
Diffstat (limited to 'server-beta/src/core/hover/label.lua')
-rw-r--r-- | server-beta/src/core/hover/label.lua | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/server-beta/src/core/hover/label.lua b/server-beta/src/core/hover/label.lua deleted file mode 100644 index 72ce60f4..00000000 --- a/server-beta/src/core/hover/label.lua +++ /dev/null @@ -1,103 +0,0 @@ -local buildName = require 'core.hover.name' -local buildArg = require 'core.hover.arg' -local buildReturn = require 'core.hover.return' -local buildTable = require 'core.hover.table' -local vm = require 'vm' -local util = require 'utility' - -local function asFunction(source) - local name = buildName(source) - local arg = buildArg(source) - local rtn = buildReturn(source) - local lines = {} - lines[1] = ('function %s(%s)'):format(name, arg) - lines[2] = rtn - return table.concat(lines, '\n') -end - -local function asLocal(source) - local name = buildName(source) - local type = vm.getType(source) - local literal = vm.getLiteral(source) - if type == 'table' then - type = buildTable(source) - end - if literal == nil then - return ('local %s: %s'):format(name, type) - else - return ('local %s: %s = %s'):format(name, type, util.viewLiteral(literal)) - end -end - -local function asGlobal(source) - local name = buildName(source) - local type = vm.getType(source) - local literal = vm.getLiteral(source) - if type == 'table' then - type = buildTable(source) - end - if literal == nil then - return ('global %s: %s'):format(name, type) - else - return ('global %s: %s = %s'):format(name, type, util.viewLiteral(literal)) - end -end - -local function isGlobalField(source) - if source.type == 'field' - or source.type == 'method' then - source = source.parent - end - if source.type == 'setfield' - or source.type == 'getfield' - or source.type == 'setmethod' - or source.type == 'getmethod' - or source.type == 'tablefield' then - local node = source.node - if node.type == 'setglobal' - or node.type == 'getglobal' then - return true - end - return isGlobalField(node) - else - return false - end -end - -local function asField(source) - if isGlobalField(source) then - return asGlobal(source) - end - local name = buildName(source) - local type = vm.getType(source) - local literal = vm.getLiteral(source) - if type == 'table' then - type = buildTable(source) - end - if literal == nil then - return ('field %s: %s'):format(name, type) - else - return ('field %s: %s = %s'):format(name, type, util.viewLiteral(literal)) - end -end - -return function (source) - if source.type == 'function' then - return asFunction(source) - elseif source.type == 'local' - or source.type == 'getlocal' - or source.type == 'setlocal' then - return asLocal(source) - elseif source.type == 'setglobal' - or source.type == 'getglobal' then - return asGlobal(source) - elseif source.type == 'getfield' - or source.type == 'setfield' - or source.type == 'getmethod' - or source.type == 'setmethod' - or source.type == 'tablefield' - or source.type == 'field' - or source.type == 'method' then - return asField(source) - end -end |