diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-09 19:57:04 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-09 19:57:04 +0800 |
commit | 7eccb5fd20db8f4d983a0426fe6f852559d22921 (patch) | |
tree | abde3bbc41325e4adab2765bc3bf926954bcf1f3 /script-beta | |
parent | 27cea93262eb2f7ca3bc0fd022dfe2fff4b39e17 (diff) | |
download | lua-language-server-7eccb5fd20db8f4d983a0426fe6f852559d22921.zip |
暂存
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/completion.lua | 37 | ||||
-rw-r--r-- | script-beta/core/definition.lua | 1 |
2 files changed, 35 insertions, 3 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index b4baace2..3152a793 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -16,6 +16,7 @@ local findSource = require 'core.find-source' local await = require 'await' local parser = require 'parser' local keyWordMap = require 'core.keyword' +local workspace = require 'workspace' local stackID = 0 local resolveID = 0 @@ -455,8 +456,38 @@ local function isAfterLocal(text, start) return word == 'local' end -local function checkUri(word, text, results) - +local function checkUri(ast, text, offset, results) + local uris = guide.eachSourceContain(ast.ast, offset, function (source) + if source.type ~= 'string' then + return + end + local callargs = source.parent + if callargs.type ~= 'callargs' then + return + end + if callargs[1] ~= source then + return + end + local call = callargs.parent + local func = call.node + local literal = guide.getLiteral(source) + local lib = vm.getLibrary(func) + if not lib then + return + end + if lib.name == 'require' then + return workspace.findUrisByRequirePath(literal, false) + elseif lib.name == 'dofile' + or lib.name == 'loadfile' then + return workspace.findUrisByFilePath(literal, false) + end + end) + if not uris then + return + end + for _, uri in ipairs(uris) do + + end end local function checkLenPlusOne(ast, text, offset, results) @@ -532,7 +563,7 @@ local function tryWord(ast, text, offset, results) local hasSpace = finish ~= offset if isInString(ast, offset) then if not hasSpace then - checkUri(word, text, results) + checkUri(ast, text, offset, results) end else local parent, oop = findParent(ast, text, start - 1) diff --git a/script-beta/core/definition.lua b/script-beta/core/definition.lua index 2799c052..ae6dce4a 100644 --- a/script-beta/core/definition.lua +++ b/script-beta/core/definition.lua @@ -111,6 +111,7 @@ return function (uri, offset) target = { start = 0, finish = 0, + uri = uri, } } end |