summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-07 03:34:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-07 03:34:53 +0800
commitafaf9114d2ea37b1567b6e09ab018ae594f88e08 (patch)
tree5f8926da709b91a86f9d857e36641f72aaface20
parentd45984a61c94447c7c55ff5efffa9209c0b98d7c (diff)
downloadlua-language-server-afaf9114d2ea37b1567b6e09ab018ae594f88e08.zip
update
-rw-r--r--script/core/diagnostics/duplicate-doc-field.lua8
-rw-r--r--script/core/diagnostics/duplicate-index.lua4
-rw-r--r--script/core/diagnostics/duplicate-set-field.lua3
-rw-r--r--script/core/diagnostics/not-yieldable.lua4
-rw-r--r--script/core/diagnostics/undefined-field.lua12
-rw-r--r--script/core/highlight.lua3
-rw-r--r--script/core/rename.lua16
-rw-r--r--script/core/semantic-tokens.lua6
-rw-r--r--test/diagnostics/init.lua2
-rw-r--r--test/highlight/init.lua1
-rw-r--r--test/rename/init.lua1
11 files changed, 32 insertions, 28 deletions
diff --git a/script/core/diagnostics/duplicate-doc-field.lua b/script/core/diagnostics/duplicate-doc-field.lua
index 0ad2045e..03f4dee5 100644
--- a/script/core/diagnostics/duplicate-doc-field.lua
+++ b/script/core/diagnostics/duplicate-doc-field.lua
@@ -1,6 +1,10 @@
local files = require 'files'
local lang = require 'language'
+local function getFieldEventName(doc)
+
+end
+
return function (uri, callback)
local state = files.getState(uri)
if not state then
@@ -18,8 +22,8 @@ return function (uri, callback)
mark = {}
elseif doc.type == 'doc.field' then
if mark then
- local name = doc.field[1]
- local eventName = noder.getFieldEventName(doc)
+ local name = ('%q'):format(doc.field[1])
+ local eventName = getFieldEventName(doc)
if eventName then
name = name .. '|' .. eventName
end
diff --git a/script/core/diagnostics/duplicate-index.lua b/script/core/diagnostics/duplicate-index.lua
index bf46996e..5097ab3a 100644
--- a/script/core/diagnostics/duplicate-index.lua
+++ b/script/core/diagnostics/duplicate-index.lua
@@ -15,8 +15,8 @@ return function (uri, callback)
if obj.type == 'tablefield'
or obj.type == 'tableindex'
or obj.type == 'tableexp' then
- local name = noder.getID(obj)
- if name and name:sub(-1) ~= '*' then
+ local name = guide.getKeyName(obj)
+ if name then
if not mark[name] then
mark[name] = {}
end
diff --git a/script/core/diagnostics/duplicate-set-field.lua b/script/core/diagnostics/duplicate-set-field.lua
index 96abe37c..8052c420 100644
--- a/script/core/diagnostics/duplicate-set-field.lua
+++ b/script/core/diagnostics/duplicate-set-field.lua
@@ -1,7 +1,8 @@
local files = require 'files'
local lang = require 'language'
local define = require 'proto.define'
-local guide = require "parser.guide"
+local guide = require 'parser.guide'
+local vm = require 'vm'
return function (uri, callback)
local ast = files.getState(uri)
diff --git a/script/core/diagnostics/not-yieldable.lua b/script/core/diagnostics/not-yieldable.lua
index 706c83e0..0588bbde 100644
--- a/script/core/diagnostics/not-yieldable.lua
+++ b/script/core/diagnostics/not-yieldable.lua
@@ -12,7 +12,7 @@ local function isYieldAble(defs, i)
local arg = def.args and def.args[i]
if arg then
hasFuncDef = true
- if infer.hasType(arg, 'any')
+ if infer.getInfer(arg):hasType 'any'
or vm.isAsync(arg, true)
or arg.type == '...' then
return true
@@ -23,7 +23,7 @@ local function isYieldAble(defs, i)
local arg = def.args and def.args[i]
if arg then
hasFuncDef = true
- if infer.hasType(arg.extends, 'any')
+ if infer.getInfer(arg.extends):hasType 'any'
or vm.isAsync(arg.extends, true) then
return true
end
diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua
index ea15dcda..03fedb7b 100644
--- a/script/core/diagnostics/undefined-field.lua
+++ b/script/core/diagnostics/undefined-field.lua
@@ -24,22 +24,11 @@ return function (uri, callback)
return
end
- local cache = {}
-
---@async
local function checkUndefinedField(src)
- local id = noder.getID(src)
- if not id then
- return
- end
- if cache[id] then
- return
- end
-
await.delay()
if #vm.getDefs(src) > 0 then
- cache[id] = true
return
end
local node = src.node
@@ -54,7 +43,6 @@ return function (uri, callback)
end
end
if not ok then
- cache[id] = true
return
end
end
diff --git a/script/core/highlight.lua b/script/core/highlight.lua
index 903c824c..d02f9004 100644
--- a/script/core/highlight.lua
+++ b/script/core/highlight.lua
@@ -5,6 +5,7 @@ local findSource = require 'core.find-source'
local util = require 'utility'
local guide = require 'parser.guide'
+---@async
local function eachRef(source, callback)
local results = vm.getRefs(source)
for i = 1, #results do
@@ -21,6 +22,7 @@ local function eachLocal(source, callback)
end
end
+---@async
local function find(source, uri, callback)
if source.type == 'local' then
eachLocal(source, callback)
@@ -236,6 +238,7 @@ local function isLiteralValue(source)
return true
end
+---@async
return function (uri, offset)
local state = files.getState(uri)
if not state then
diff --git a/script/core/rename.lua b/script/core/rename.lua
index c8e011b9..2ee1d273 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -178,29 +178,33 @@ local function ofFieldThen(key, src, newname, callback)
end
end
+---@async
local function ofField(source, newname, callback)
local key = guide.getKeyName(source)
- for _, src in ipairs(vm.getAllRefs(source)) do
+ for _, src in ipairs(vm.getRefs(source)) do
ofFieldThen(key, src, newname, callback)
end
end
+---@async
local function ofGlobal(source, newname, callback)
local key = guide.getKeyName(source)
- for _, src in ipairs(vm.getAllRefs(source)) do
+ for _, src in ipairs(vm.getRefs(source)) do
ofFieldThen(key, src, newname, callback)
end
end
+---@async
local function ofLabel(source, newname, callback)
- for _, src in ipairs(vm.getAllRefs(source)) do
+ for _, src in ipairs(vm.getRefs(source)) do
callback(src, src.start, src.finish, newname)
end
end
+---@async
local function ofDocTypeName(source, newname, callback)
local oldname = source[1]
- for _, doc in ipairs(vm.getAllRefs(source)) do
+ for _, doc in ipairs(vm.getRefs(source)) do
if doc.type == 'doc.class.name'
or doc.type == 'doc.type.name'
or doc.type == 'doc.alias.name' then
@@ -213,7 +217,7 @@ end
local function ofDocParamName(source, newname, callback)
callback(source, source.start, source.finish, newname)
- local doc = noder.getDocState(source)
+ local doc = source.parent
if doc.bindSources then
for _, src in ipairs(doc.bindSources) do
if src.type == 'local'
@@ -230,6 +234,7 @@ local function ofDocParamName(source, newname, callback)
end
end
+---@async
local function rename(source, newname, callback)
if source.type == 'label'
or source.type == 'goto' then
@@ -326,6 +331,7 @@ local accept = {
local m = {}
+---@async
function m.rename(uri, pos, newname)
if not newname then
return nil
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index 066ef68c..552e17d4 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -17,7 +17,7 @@ local Care = util.switch()
return
end
local isLib = vm.isGlobalLibraryName(source[1])
- local isFunc = infer.hasType(source, 'function')
+ local isFunc = infer.getInfer(source):hasFunction()
local type = isFunc and define.TokenTypes['function'] or define.TokenTypes.variable
local modifier = isLib and define.TokenModifiers.defaultLibrary or define.TokenModifiers.static
@@ -66,7 +66,7 @@ local Care = util.switch()
return
end
end
- if infer.hasType(source, 'function') then
+ if infer.getInfer(source):hasFunction() then
results[#results+1] = {
start = source.start,
finish = source.finish,
@@ -179,7 +179,7 @@ local Care = util.switch()
end
end
-- 6. References to other functions
- if infer.hasType(loc, 'function') then
+ if infer.getInfer(loc):hasFunction() then
results[#results+1] = {
start = source.start,
finish = source.finish,
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 58414b60..91dfb62f 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -43,7 +43,7 @@ function TEST(script, ...)
error(('%s\n%s'):format(util.dump(catched['!']), util.dump(results)))
end
else
- assert(catched['!'] == nil)
+ assert(#catched['!'] == 0)
end
files.remove('')
diff --git a/test/highlight/init.lua b/test/highlight/init.lua
index 8e07c5f0..0cca79f1 100644
--- a/test/highlight/init.lua
+++ b/test/highlight/init.lua
@@ -1,3 +1,4 @@
+---@diagnostic disable: await-in-sync
local core = require 'core.highlight'
local files = require 'files'
local catch = require 'catch'
diff --git a/test/rename/init.lua b/test/rename/init.lua
index 3b386778..64e3916a 100644
--- a/test/rename/init.lua
+++ b/test/rename/init.lua
@@ -1,3 +1,4 @@
+---@diagnostic disable: await-in-sync
local core = require 'core.rename'
local files = require 'files'
local catch = require 'catch'