diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-06-11 14:52:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-06-11 14:52:40 +0800 |
commit | 50e6cd02d535e12e085eab7d8bdcb4757be857f2 (patch) | |
tree | 5811e18bf8ce45ce243c388f296aebd60523e2ba /script/vm | |
parent | 997f15620b6e4dfe6a21ed52b17ac15c4e6b9a93 (diff) | |
download | lua-language-server-50e6cd02d535e12e085eab7d8bdcb4757be857f2.zip |
rename getAst -> getState
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/getDocs.lua | 6 | ||||
-rw-r--r-- | script/vm/getGlobals.lua.txt (renamed from script/vm/getGlobals.lua) | 0 | ||||
-rw-r--r-- | script/vm/getLinks.lua | 3 | ||||
-rw-r--r-- | script/vm/globals.lua | 31 | ||||
-rw-r--r-- | script/vm/guideInterface.lua | 4 |
5 files changed, 38 insertions, 6 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua index e712c6f7..bc7df626 100644 --- a/script/vm/getDocs.lua +++ b/script/vm/getDocs.lua @@ -25,7 +25,7 @@ end function vm.getDocDefines(name) local results = {} for uri in files.eachFile() do - local ast = files.getAst(uri) + local ast = files.getState(uri) getDocDefinesInAst(results, ast.ast, name) end return results @@ -49,7 +49,7 @@ function vm.getDocEnums(doc) end function vm.isMetaFile(uri) - local status = files.getAst(uri) + local status = files.getState(uri) if not status then return false end @@ -203,7 +203,7 @@ local function makeDiagRange(uri, doc, results) end function vm.isDiagDisabledAt(uri, offset, name) - local status = files.getAst(uri) + local status = files.getState(uri) if not status then return false end diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua.txt index e5bcafc0..e5bcafc0 100644 --- a/script/vm/getGlobals.lua +++ b/script/vm/getGlobals.lua.txt diff --git a/script/vm/getLinks.lua b/script/vm/getLinks.lua index 51a18d58..14b34987 100644 --- a/script/vm/getLinks.lua +++ b/script/vm/getLinks.lua @@ -5,7 +5,7 @@ local files = require 'files' local function getFileLinks(uri) local ws = require 'workspace' local links = {} - local ast = files.getAst(uri) + local ast = files.getState(uri) if not ast then return links end @@ -52,6 +52,7 @@ local function getLinksTo(uri) return links end +-- 获取所有 require(uri) 的文件 function vm.getLinksTo(uri) local cache = vm.getCache('getLinksTo')[uri] if cache ~= nil then diff --git a/script/vm/globals.lua b/script/vm/globals.lua new file mode 100644 index 00000000..cf18aa19 --- /dev/null +++ b/script/vm/globals.lua @@ -0,0 +1,31 @@ +local files = require 'files' +local await = require 'await' +local noder = require 'core.noder' + +local globalsMap = {} +local subscribe = {} + +local function popGlobals(uri) + +end + +local function pushGlobals(uri) + local state = files.getState(uri) + if not state then + return + end + noder.compileNodes(state.ast) + +end + +local m = {} + +files.watch(function (ev, uri) + if ev == 'update' then + popGlobals(uri) + await.delay() + pushGlobals(uri) + end +end) + +return m diff --git a/script/vm/guideInterface.lua b/script/vm/guideInterface.lua index e59fc6e3..a07b6644 100644 --- a/script/vm/guideInterface.lua +++ b/script/vm/guideInterface.lua @@ -31,7 +31,7 @@ function m.require(args, index) local uris = ws.findUrisByRequirePath(reqName) for _, uri in ipairs(uris) do if not files.eq(myUri, uri) then - local ast = files.getAst(uri) + local ast = files.getState(uri) if ast then m.searchFileReturn(results, ast.ast, index) end @@ -51,7 +51,7 @@ function m.dofile(args, index) local uris = ws.findUrisByFilePath(reqName) for _, uri in ipairs(uris) do if not files.eq(myUri, uri) then - local ast = files.getAst(uri) + local ast = files.getState(uri) if ast then m.searchFileReturn(results, ast.ast, index) end |