summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-17 19:02:01 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-17 19:02:01 +0800
commite8e5e00ff910bbbd7729d473198eff92e7581e64 (patch)
treebbc8adf49ed195219acb6df53dad783487889762 /script-beta/core
parent3e4411e10f8c0ebd10341450edd6c868866d04cb (diff)
downloadlua-language-server-e8e5e00ff910bbbd7729d473198eff92e7581e64.zip
优化性能
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/completion.lua2
-rw-r--r--script-beta/core/diagnostics/redundant-parameter.lua9
-rw-r--r--script-beta/core/hover/arg.lua4
-rw-r--r--script-beta/core/hover/init.lua2
-rw-r--r--script-beta/core/hover/label.lua6
-rw-r--r--script-beta/core/hover/table.lua6
6 files changed, 15 insertions, 14 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index f04f11c9..e4310673 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -152,7 +152,7 @@ local function buildFunctionSnip(source)
end
local function buildDetail(source)
- local types = vm.getType(source)
+ local types = vm.getInferType(source)
return types
end
diff --git a/script-beta/core/diagnostics/redundant-parameter.lua b/script-beta/core/diagnostics/redundant-parameter.lua
index b424c2bf..acb6f63c 100644
--- a/script-beta/core/diagnostics/redundant-parameter.lua
+++ b/script-beta/core/diagnostics/redundant-parameter.lua
@@ -65,10 +65,11 @@ return function (uri, callback)
if not vm.hasType(func, 'function') then
return
end
- local values = vm.getInfers(func)
- for _, value in ipairs(values) do
- if value.type and value.source.type == 'function' then
- local args = countFuncArgs(value.source)
+ local defs = vm.getDefs(func)
+ for _, def in ipairs(defs) do
+ local value = guide.getObjectValue(def) or def
+ if value.type == 'function' then
+ local args = countFuncArgs(value)
if not funcArgs or args > funcArgs then
funcArgs = args
end
diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua
index dc8db16c..37c5e6ad 100644
--- a/script-beta/core/hover/arg.lua
+++ b/script-beta/core/hover/arg.lua
@@ -10,9 +10,9 @@ local function asFunction(source, oop)
local arg = source.args[i]
local name = arg.name or guide.getName(arg)
if name then
- args[i] = ('%s: %s'):format(name, vm.getType(arg))
+ args[i] = ('%s: %s'):format(name, vm.getInferType(arg))
else
- args[i] = ('%s'):format(vm.getType(arg))
+ args[i] = ('%s'):format(vm.getInferType(arg))
end
end
local methodDef
diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua
index e123bb06..82cc310d 100644
--- a/script-beta/core/hover/init.lua
+++ b/script-beta/core/hover/init.lua
@@ -75,7 +75,7 @@ end
local function getHover(source)
vm.setSearchLevel(5)
- local isFunction = vm.hasType(source, 'function')
+ local isFunction = vm.hasInferType(source, 'function')
if isFunction then
return getHoverAsFunction(source)
else
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index 6b3d0988..6e5b284c 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -19,11 +19,11 @@ end
local function asValue(source, title)
local name = buildName(source)
local infers = vm.getInfers(source)
- local type = vm.getType(source)
+ local type = vm.getInferType(source)
local class = vm.getClass(source)
- local literal = vm.getLiteral(source)
+ local literal = vm.getInferLiteral(source)
local cont
- if vm.hasType(source, 'table') then
+ if vm.hasInferType(source, 'table') then
cont = buildTable(source)
end
local pack = {}
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua
index 97209a4f..f16eed9b 100644
--- a/script-beta/core/hover/table.lua
+++ b/script-beta/core/hover/table.lua
@@ -12,7 +12,7 @@ local function getKey(src)
if class then
return ('[%s]'):format(class)
end
- local tp = vm.getType(src.index)
+ local tp = vm.getInferType(src.index)
if tp then
return ('[%s]'):format(tp)
end
@@ -36,9 +36,9 @@ local function getField(src)
or src.parent.type == 'getindex' then
src = src.parent
end
- local tp = vm.getType(src)
+ local tp = vm.getInferType(src)
local class = vm.getClass(src)
- local literal = vm.getLiteral(src)
+ local literal = vm.getInferLiteral(src)
local key = getKey(src)
if type(literal) == 'string' and #literal >= 50 then
literal = literal:sub(1, 47) .. '...'