summaryrefslogtreecommitdiff
path: root/script/core/linker.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-13 16:32:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-13 16:32:37 +0800
commitbd8b30417e87959510545847d4db580d34603943 (patch)
tree02d049e6e1942fec7a1427ee2473d43d76dead6c /script/core/linker.lua
parent6475fa2e14a22a81e45e1c5a1c6e90121077511d (diff)
downloadlua-language-server-bd8b30417e87959510545847d4db580d34603943.zip
mark id
Diffstat (limited to 'script/core/linker.lua')
-rw-r--r--script/core/linker.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/script/core/linker.lua b/script/core/linker.lua
new file mode 100644
index 00000000..6c475e70
--- /dev/null
+++ b/script/core/linker.lua
@@ -0,0 +1,31 @@
+local guide = require 'parser.guide'
+
+local function getKey(source)
+ if source.type == 'local' then
+ return ('l%d%s'):format(source.start, source[1])
+ end
+end
+
+---创建source的链接信息
+local function createLink(source)
+ local idList = {}
+ if getKey then
+ idList[#idList+1] = getKey(source)
+ end
+ local id = table.concat(idList, '|')
+ return {
+ id = id,
+ }
+end
+
+local m = {}
+
+---获取source的链接信息
+function m.getLink(source)
+ if not source._link then
+ source._link = createLink(source)
+ end
+ return source._link
+end
+
+return m