summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-28 15:51:19 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-28 15:51:19 +0800
commit3342b201614baeb067e29b7941e26807ff13a244 (patch)
treef78dc95bdc9d8b956b7ce013f757059e11c73330 /server/src/core
parent9bee0cdec02c07fb5b78d3781b912b9e193f0dbd (diff)
downloadlua-language-server-3342b201614baeb067e29b7941e26807ff13a244.zip
更新api
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/completion.lua25
-rw-r--r--server/src/core/document_symbol.lua4
-rw-r--r--server/src/core/vm.lua7
3 files changed, 26 insertions, 10 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 1cf05b35..3538f4e0 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -112,10 +112,28 @@ local function searchLocals(vm, pos, name, callback)
end
end
+local function sortPairs(t)
+ local keys = {}
+ for k in pairs(t) do
+ keys[#keys+1] = k
+ end
+ table.sort(keys)
+ local i = 0
+ return function ()
+ i = i + 1
+ local k = keys[i]
+ return k, t[k]
+ end
+end
+
local function searchFields(name, source, parent, object, callback)
if not parent or not parent.value then
return
end
+ if type(name) ~= 'string' then
+ return
+ end
+ local map = {}
parent.value:eachField(function (key, field)
if type(key) ~= 'string' then
goto CONTINUE
@@ -128,11 +146,14 @@ local function searchFields(name, source, parent, object, callback)
if field.source == source then
goto CONTINUE
end
- if type(name) == 'string' and matchKey(name, key) then
- callback(field)
+ if matchKey(name, key) then
+ map[key] = field
end
::CONTINUE::
end)
+ for _, field in sortPairs(map) do
+ callback(field)
+ end
end
local KEYS = {'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while', 'toclose'}
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua
index e2253594..fcd5344b 100644
--- a/server/src/core/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -33,7 +33,7 @@ local SymbolKind = {
local function buildFunction(vm, func)
local source = func.source
- local declarat = func.declarat
+ local declarat = func:getDeclarat()
local name
local var
if declarat then
@@ -83,7 +83,7 @@ local function isLocalTable(var)
if var.value.source.start == 0 then
return false
end
- if var.source ~= var.value.declarat then
+ if var.source ~= var.value:getDeclarat() then
return false
end
if var.value.source.finish < var.source.finish then
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index 9c7ee732..1291383b 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -169,11 +169,6 @@ function mt:addInfo(obj, type, source, value)
else
self.results.sources[source] = obj
end
- if type == 'set' or type == 'return' then
- if not obj.declarat then
- obj.declarat = source
- end
- end
end
return obj
end
@@ -919,7 +914,7 @@ function mt:getSimple(simple, mode)
if object then
table.insert(args, 1, self:getValue(object))
end
- local func = value
+ local func = self:selectList(value, 1)
-- 函数的返回值一定是list
value = self:call(func, args, obj)
if i < #simple then