summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/diagnostics/redundant-value.lua13
-rw-r--r--server-beta/src/parser/guide.lua30
-rw-r--r--server-beta/test/diagnostics/init.lua7
3 files changed, 38 insertions, 12 deletions
diff --git a/server-beta/src/core/diagnostics/redundant-value.lua b/server-beta/src/core/diagnostics/redundant-value.lua
index b3d19c21..71749f56 100644
--- a/server-beta/src/core/diagnostics/redundant-value.lua
+++ b/server-beta/src/core/diagnostics/redundant-value.lua
@@ -1,3 +1,14 @@
-return function ()
+local files = require 'files'
+local guide = require 'parser.guide'
+
+local function check(source)
end
+
+return function (uri, callback)
+ local ast = files.getAst(uri)
+ if not ast then
+ return
+ end
+
+end
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index 92dd79bc..952fa3c6 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -309,23 +309,31 @@ end
--- 遍历所有指定类型的source
function m.eachSourceType(ast, type, callback)
- if not ast.typeCache then
- ast.typeCache = {}
- end
- local cache = ast.typeCache[type]
+ local cache = ast.typeCache
if not cache then
- cache = {}
- ast.typeCache[type] = cache
local mark = {}
+ cache = {}
+ ast.typeCache = cache
m.eachSource(ast, function (source)
- if source.type == type and not mark[source] then
- mark[source] = true
- cache[#cache+1] = source
+ if mark[source] then
+ return
end
+ mark[source] = true
+ local tp = source.type
+ local myCache = cache[tp]
+ if not myCache then
+ myCache = {}
+ cache[tp] = myCache
+ end
+ myCache[#myCache+1] = source
end)
end
- for i = 1, #cache do
- callback(cache[i])
+ local myCache = cache[type]
+ if not myCache then
+ return
+ end
+ for i = 1, #myCache do
+ callback(myCache[i])
end
end
diff --git a/server-beta/test/diagnostics/init.lua b/server-beta/test/diagnostics/init.lua
index d8724375..430ead8d 100644
--- a/server-beta/test/diagnostics/init.lua
+++ b/server-beta/test/diagnostics/init.lua
@@ -262,6 +262,13 @@ return [[
]]
]=]
+TEST [[
+local t = {}
+<!function t:x()
+end!>
+return t
+]]
+
config.config.diagnostics.disable['unused-function'] = true
TEST [[
local mt, x