summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/definition.lua30
-rw-r--r--server/src/vm/source.lua5
-rw-r--r--server/src/vm/vm.lua2
3 files changed, 36 insertions, 1 deletions
diff --git a/server/src/core/definition.lua b/server/src/core/definition.lua
index 60964676..6685f00d 100644
--- a/server/src/core/definition.lua
+++ b/server/src/core/definition.lua
@@ -131,6 +131,9 @@ local function parseLocal(vm, loc, lsp)
loc.source.start,
loc.source.finish,
}
+ if #positions == 0 then
+ return nil
+ end
return positions
end
@@ -144,6 +147,32 @@ local function parseValue(vm, value, lsp)
}
end
end)
+ if #positions == 0 then
+ return nil
+ end
+ return positions
+end
+
+local function parseValueSimily(vm, source, lsp)
+ local key = source[1]
+ if not key then
+ return nil
+ end
+ local positions = {}
+ for _, other in ipairs(vm.sources) do
+ if other == source then
+ break
+ end
+ if other[1] == key and not other:bindLocal() and other:bindValue() and other:action() == 'set' then
+ positions[#positions+1] = {
+ other.start,
+ other.finish,
+ }
+ end
+ end
+ if #positions == 0 then
+ return nil
+ end
return positions
end
@@ -156,5 +185,6 @@ return function (vm, source, lsp)
end
if source:bindValue() then
return parseValue(vm, source:bindValue(), lsp)
+ or parseValueSimily(vm, source, lsp)
end
end
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua
index 1e9001d1..a4839c69 100644
--- a/server/src/vm/source.lua
+++ b/server/src/vm/source.lua
@@ -29,12 +29,17 @@ end
function mt:bindValue(value, action)
if value then
self._bindValue = value
+ self._action = action
value:addInfo(action, self)
else
return self._bindValue
end
end
+function mt:action()
+ return self._action
+end
+
function mt:setUri(uri)
self._uri = uri
end
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 9eb46c58..c140589c 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -62,6 +62,7 @@ function mt:buildTable(source)
local value = self:getFirstInMulti(self:getExp(obj[2]))
local key = obj[1]
self:instantSource(key)
+ key:bindValue(value, 'set')
if key.index then
local index = self:getIndex(key)
tbl:setChild(index, value)
@@ -89,7 +90,6 @@ function mt:buildTable(source)
end
-- 处理写了一半的 key = value,把name类的数组元素视为哈希键
if obj.type == 'name' then
- obj.isIndex = true
end
end
end