summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/reference.lua8
-rw-r--r--script/provider/provider.lua2
-rw-r--r--script/vm/operator.lua7
3 files changed, 13 insertions, 4 deletions
diff --git a/script/core/reference.lua b/script/core/reference.lua
index c1d99ed9..b338e9ec 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -55,7 +55,10 @@ local accept = {
}
---@async
-return function (uri, position)
+---@param uri uri
+---@param position integer
+---@param includeDeclaration boolean
+return function (uri, position, includeDeclaration)
local ast = files.getState(uri)
if not ast then
return nil
@@ -82,6 +85,9 @@ return function (uri, position)
if src.type == 'self' then
goto CONTINUE
end
+ if not includeDeclaration and guide.isSet(src) then
+ goto CONTINUE
+ end
src = src.field or src.method or src
if src.type == 'getindex'
or src.type == 'setindex'
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 7386ded0..8e99b354 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -484,7 +484,7 @@ m.register 'textDocument/references' {
end
local core = require 'core.reference'
local pos = converter.unpackPosition(state, params.position)
- local result = core(uri, pos)
+ local result = core(uri, pos, params.context.includeDeclaration)
if not result then
return nil
end
diff --git a/script/vm/operator.lua b/script/vm/operator.lua
index 9dea01c1..015eba38 100644
--- a/script/vm/operator.lua
+++ b/script/vm/operator.lua
@@ -273,7 +273,7 @@ vm.binarySwitch = util.switch()
or op == '//' and a // b
or op == '^' and a ^ b
vm.setNode(source, {
- type = math.type(result) == 'integer' and 'integer' or 'number',
+ type = (op == '//' or math.type(result) == 'integer') and 'integer' or 'number',
start = source.start,
finish = source.finish,
parent = source,
@@ -288,7 +288,6 @@ vm.binarySwitch = util.switch()
if op == '+'
or op == '-'
or op == '*'
- or op == '//'
or op == '%' then
local uri = guide.getUri(source)
local infer1 = vm.getInfer(source[1])
@@ -302,6 +301,10 @@ vm.binarySwitch = util.switch()
end
end
end
+ if op == '//' then
+ vm.setNode(source, node or vm.declareGlobal('type', 'integer'))
+ return
+ end
vm.setNode(source, node or vm.declareGlobal('type', 'number'))
end
end)