summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/core/definition.lua13
-rw-r--r--server-beta/src/searcher/eachField.lua16
-rw-r--r--server-beta/src/searcher/eachRef.lua22
3 files changed, 36 insertions, 15 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua
index 8a808e23..b3b5c173 100644
--- a/server-beta/src/core/definition.lua
+++ b/server-beta/src/core/definition.lua
@@ -3,6 +3,19 @@ local workspace = require 'workspace'
local files = require 'files'
local function findDef(searcher, source, callback)
+ if source.type ~= 'local'
+ and source.type ~= 'getlocal'
+ and source.type ~= 'setlocal'
+ and source.type ~= 'setglobal'
+ and source.type ~= 'getglobal'
+ and source.type ~= 'field'
+ and source.type ~= 'method'
+ and source.type ~= 'string'
+ and source.type ~= 'number'
+ and source.type ~= 'boolean'
+ and source.type ~= 'goto' then
+ return
+ end
searcher:eachRef(source, function (info)
if info.mode == 'declare'
or info.mode == 'set'
diff --git a/server-beta/src/searcher/eachField.lua b/server-beta/src/searcher/eachField.lua
index 6a86314b..71968aea 100644
--- a/server-beta/src/searcher/eachField.lua
+++ b/server-beta/src/searcher/eachField.lua
@@ -19,12 +19,6 @@ local function ofTabel(searcher, value, callback)
end
end
-local function ofValue(searcher, value, callback)
- if value.type == 'table' then
- ofTabel(searcher, value, callback)
- end
-end
-
local function rawField(searcher, source, callback)
if source.type == 'getlocal' then
local parent = source.parent
@@ -53,10 +47,6 @@ return function (searcher, source, callback)
rawField(info.searcher, ref, callback)
end
end
- elseif src.type == 'local' then
- if src.value then
- ofValue(searcher, src.value, callback)
- end
elseif src.type == 'getlocal' then
if src.parent then
local field = info.searcher:getField(src.parent)
@@ -67,8 +57,6 @@ return function (searcher, source, callback)
}
end
end
- elseif src.type == 'setlocal' then
- ofValue(info.searcher, src.value, callback)
elseif src.type == 'getglobal' then
if src.parent then
local field = info.searcher:getField(src.parent)
@@ -79,8 +67,8 @@ return function (searcher, source, callback)
}
end
end
- elseif src.type == 'setglobal' then
- ofValue(info.searcher, src.value, callback)
+ elseif src.type == 'table' then
+ ofTabel(searcher, src, callback)
end
end)
end
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua
index ab3de029..970334bd 100644
--- a/server-beta/src/searcher/eachRef.lua
+++ b/server-beta/src/searcher/eachRef.lua
@@ -22,13 +22,19 @@ local function ofCall(searcher, func, index, callback)
end
local function ofValue(searcher, value, callback)
- -- 检查函数返回值
if value.type == 'select' then
+ -- 检查函数返回值
local call = value.vararg
if call.type == 'call' then
ofCall(searcher, call.node, value.index, callback)
end
+ return
end
+ callback {
+ searcher = searcher,
+ source = value,
+ mode = 'value',
+ }
end
local function ofSelf(searcher, loc, callback)
@@ -84,8 +90,10 @@ local function checkField(key, info, callback)
end
local stype = src.type
local mode
+ local value
if stype == 'setglobal' then
mode = 'set'
+ value = src.value
elseif stype == 'getglobal' then
mode = 'get'
elseif stype == 'field' then
@@ -97,6 +105,7 @@ local function checkField(key, info, callback)
elseif parent.type == 'tablefield' then
mode = 'set'
end
+ value = parent.value
elseif stype == 'index' then
local parent = src.parent
if parent.type == 'setindex' then
@@ -106,6 +115,7 @@ local function checkField(key, info, callback)
elseif parent.type == 'tableindex' then
mode = 'set'
end
+ value = parent.value
elseif stype == 'method' then
local parent = src.parent
if parent.type == 'setmethod' then
@@ -113,6 +123,7 @@ local function checkField(key, info, callback)
elseif parent.type == 'getmethod' then
mode = 'get'
end
+ value = parent.value
elseif stype == 'number'
or stype == 'string'
or stype == 'boolean' then
@@ -130,6 +141,9 @@ local function checkField(key, info, callback)
mode = mode,
}
end
+ if value then
+ ofValue(info.searcher, value, callback)
+ end
end
local function ofGlobal(searcher, source, callback)
@@ -187,6 +201,12 @@ return function (searcher, source, callback)
or stype == 'method'
or stype == 'index' then
ofField(searcher, source, callback)
+ elseif stype == 'setfield'
+ or stype == 'getfield' then
+ ofField(searcher, source.field, callback)
+ elseif stype == 'setmethod'
+ or stype == 'getmethod' then
+ ofField(searcher, source.method, callback)
elseif stype == 'number'
or stype == 'boolean'
or stype == 'string' then