summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-14 18:46:12 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-14 18:46:12 +0800
commit4a0a07f81df346170bc71ca83b154448faf1f586 (patch)
treedfe3f77b680e5373dca52713fd799e109bcb905f /script
parentb154ddeb48450cdb78a589abf3705d3f9df758d7 (diff)
downloadlua-language-server-4a0a07f81df346170bc71ca83b154448faf1f586.zip
bind source for class
Diffstat (limited to 'script')
-rw-r--r--script/core/jump-source.lua3
-rw-r--r--script/parser/luadoc.lua4
-rw-r--r--script/provider/build-meta.lua1
3 files changed, 7 insertions, 1 deletions
diff --git a/script/core/jump-source.lua b/script/core/jump-source.lua
index 15afae39..2de23b29 100644
--- a/script/core/jump-source.lua
+++ b/script/core/jump-source.lua
@@ -3,7 +3,8 @@ local guide = require 'parser.guide'
---@param results table
return function (results)
for _, result in ipairs(results) do
- if result.target.type == 'doc.field.name' then
+ if result.target.type == 'doc.field.name'
+ or result.target.type == 'doc.class.name' then
local doc = result.target.parent.source
if doc then
result.uri = doc.source
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 9ea99f39..2cde6bff 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -1787,6 +1787,10 @@ local function bindCommentsAndFields(binded)
if class then
class.bindSource = nil
end
+ if source then
+ doc.source = source
+ source.bindSource = doc
+ end
class = doc
bindCommentsToDoc(doc, comments)
comments = {}
diff --git a/script/provider/build-meta.lua b/script/provider/build-meta.lua
index 2c4a29c2..baabe39c 100644
--- a/script/provider/build-meta.lua
+++ b/script/provider/build-meta.lua
@@ -105,6 +105,7 @@ local function buildText(root, class)
lines[#lines+1] = ('---@field %s %s'):format(field.name, field.typeName)
end
+ lines[#lines+1] = ('---@source %s'):format(class.location:gsub('#', ':'))
local name = mergeString(root, class.namespace, class.name)
lines[#lines+1] = ('%s = {}'):format(name)
lines[#lines+1] = ''