summaryrefslogtreecommitdiff
path: root/script/core/hover
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-06 20:02:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-06 20:02:08 +0800
commitd060e870a5d24e3e575459a0e02d229d9234109a (patch)
treeb04b4913015fc2c1888afe386d23a8e061eb53ca /script/core/hover
parentb1a1b3f46771ac5461182a8156452517c280b153 (diff)
downloadlua-language-server-d060e870a5d24e3e575459a0e02d229d9234109a.zip
cleanup
Diffstat (limited to 'script/core/hover')
-rw-r--r--script/core/hover/label.lua31
-rw-r--r--script/core/hover/name.lua5
2 files changed, 19 insertions, 17 deletions
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index 0bb4fe89..8531ebb9 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -11,26 +11,33 @@ local files = require 'files'
local guide = require 'parser.guide'
local function asFunction(source, oop)
- local name
- name, oop = buildName(source, oop)
+ if oop == nil then
+ oop = guide.isOOP(source, oop)
+ end
+ local name = buildName(source, oop)
local arg = buildArg(source, oop)
local rtn = buildReturn(source)
local lines = {}
- lines[1] = ('%s%s %s(%s)'):format(
- vm.isAsync(source) and 'async ' or '',
- oop and 'method' or 'function',
- name or '', arg
+ lines[1] = string.format('%s%s %s(%s)'
+ , vm.isAsync(source) and 'async ' or ''
+ , oop and 'method' or 'function'
+ , name or ''
+ , arg
)
lines[2] = rtn
return table.concat(lines, '\n')
end
-local function asDocFunction(source)
- local name = buildName(source)
- local arg = buildArg(source)
- local rtn = buildReturn(source)
+local function asDocFunction(source, oop)
+ local name = buildName(source, oop)
+ local arg = buildArg(source, oop)
+ local rtn = buildReturn(source)
local lines = {}
- lines[1] = ('function %s(%s)'):format(name or '', arg)
+ lines[1] = string.format('%s%s %s(%s)'
+ , ''
+ , oop and 'method' or 'function'
+ , name or ''
+ , arg)
lines[2] = rtn
return table.concat(lines, '\n')
end
@@ -211,7 +218,7 @@ return function (source, oop)
or source.type == 'integer' then
return asNumber(source)
elseif source.type == 'doc.type.function' then
- return asDocFunction(source)
+ return asDocFunction(source, oop)
elseif source.type == 'doc.type.name' then
return asDocTypeName(source)
elseif source.type == 'doc.field.name' then
diff --git a/script/core/hover/name.lua b/script/core/hover/name.lua
index 0de13c9a..2d1e361c 100644
--- a/script/core/hover/name.lua
+++ b/script/core/hover/name.lua
@@ -66,11 +66,6 @@ local function asDocField(source)
end
function buildName(source, oop)
- if oop == nil then
- oop = source.type == 'setmethod'
- or source.type == 'getmethod'
- or nil
- end
if source.type == 'local' then
return asLocal(source) or '', oop
end