summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/reference.lua57
1 files changed, 36 insertions, 21 deletions
diff --git a/script/core/reference.lua b/script/core/reference.lua
index 60a25940..1e1b8e11 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -64,7 +64,7 @@ return function (uri, position)
local metaSource = vm.isMetaFile(uri)
- local refs = vm.getAllRefs(source)
+ local refs = vm.getRefs(source)
local results = {}
for _, src in ipairs(refs) do
@@ -78,34 +78,49 @@ return function (uri, position)
if not metaSource and vm.isMetaFile(root.uri) then
goto CONTINUE
end
- if ( src.type == 'doc.class.name'
- or src.type == 'doc.type.name'
- or src.type == 'doc.extends.name'
- )
- and source.type ~= 'doc.type.name'
- and source.type ~= 'doc.class.name' then
- goto CONTINUE
- end
- if src.type == 'setfield'
- or src.type == 'getfield'
- or src.type == 'tablefield' then
- src = src.field
- elseif src.type == 'setindex'
- or src.type == 'getindex'
- or src.type == 'tableindex' then
+ src = src.field or src.method or src
+ if src.type == 'getindex'
+ or src.type == 'setindex'
+ or src.type == 'tableindex' then
src = src.index
- elseif src.type == 'getmethod'
- or src.type == 'setmethod' then
- src = src.method
- elseif src.type == 'table' and src.parent.type ~= 'return' then
+ if not src then
+ goto CONTINUE
+ end
+ if not guide.isLiteral(src) then
+ goto CONTINUE
+ end
+ else
+ if guide.isLiteral(src) and src.type ~= 'function' then
+ goto CONTINUE
+ end
+ end
+ if src.type == 'doc.class' then
+ src = src.class
+ end
+ if src.type == 'doc.alias' then
+ src = src.alias
+ end
+ if src.type == 'doc.class.name'
+ or src.type == 'doc.alias.name'
+ or src.type == 'doc.type.name'
+ or src.type == 'doc.extends.name' then
+ if source.type ~= 'doc.type.name'
+ and source.type ~= 'doc.extends.name'
+ and source.type ~= 'doc.see.name' then
+ goto CONTINUE
+ end
+ end
+ if src.type == 'doc.generic.name' then
goto CONTINUE
end
- if not src then
+ if src.type == 'doc.param' then
goto CONTINUE
end
+
results[#results+1] = {
target = src,
uri = root.uri,
+ source = source,
}
::CONTINUE::
end